forked from Simnation/Main
YACA UI add
This commit is contained in:
parent
f925fba0b1
commit
3893e02741
11 changed files with 895 additions and 1 deletions
Binary file not shown.
Binary file not shown.
25
resources/[voice]/yaca-ui/assets/assets/index-CTefETlP.js
Normal file
25
resources/[voice]/yaca-ui/assets/assets/index-CTefETlP.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
649
resources/[voice]/yaca-ui/assets/assets/logo-fo-1jOqX.svg
Normal file
649
resources/[voice]/yaca-ui/assets/assets/logo-fo-1jOqX.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 272 KiB |
BIN
resources/[voice]/yaca-ui/assets/assets/radio-BsFvNJjv.png
Normal file
BIN
resources/[voice]/yaca-ui/assets/assets/radio-BsFvNJjv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 732 KiB |
13
resources/[voice]/yaca-ui/assets/index.html
Normal file
13
resources/[voice]/yaca-ui/assets/index.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>yaca-systems UI</title>
|
||||||
|
<script type="module" crossorigin src="./assets/index-CTefETlP.js"></script>
|
||||||
|
<link rel="stylesheet" crossorigin href="./assets/index-_IdvlNEH.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
175
resources/[voice]/yaca-ui/client.js
Normal file
175
resources/[voice]/yaca-ui/client.js
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
const defaultValues = {
|
||||||
|
noactive_plugin_ui: {
|
||||||
|
usage: false,
|
||||||
|
freezeplayer: true,
|
||||||
|
style: 1,
|
||||||
|
logo: ""
|
||||||
|
},
|
||||||
|
keybinds: {
|
||||||
|
open_Radio: "O"
|
||||||
|
},
|
||||||
|
locales: {
|
||||||
|
open_Radio: "Open Radio",
|
||||||
|
no_plugin_active_header: "No plugin activated",
|
||||||
|
no_plugin_active_body: "You have no plugin active. Please activate a plugin in the settings."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadConfig() {
|
||||||
|
const fileData = LoadResourceFile(GetCurrentResourceName(), "config.json")
|
||||||
|
|
||||||
|
if (!fileData) {
|
||||||
|
return defaultValues
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedData = JSON.parse(fileData)
|
||||||
|
|
||||||
|
for (const key in defaultValues) {
|
||||||
|
if (!(key in parsedData)) {
|
||||||
|
console.warn(
|
||||||
|
`[YaCA-UI] Missing config value for key '${key}' setting to default value: ${defaultValues[key]}\nMissing config values can cause unexpected behavior of the script.`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key in parsedData) {
|
||||||
|
if (!(key in defaultValues)) {
|
||||||
|
console.warn(`[YaCA-UI] Unknown config key '${key}' found in config file. This keys will be ignored and can be removed.`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { ...defaultValues, ...parsedData }
|
||||||
|
}
|
||||||
|
|
||||||
|
function locale(key) {
|
||||||
|
return config.locales[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = loadConfig()
|
||||||
|
registerKeybinds();
|
||||||
|
|
||||||
|
let isRadioOpen = false;
|
||||||
|
function openRadio(state) {
|
||||||
|
SendNuiMessage(JSON.stringify({
|
||||||
|
eventName: 'webview:yaca:openState',
|
||||||
|
show: state
|
||||||
|
}))
|
||||||
|
|
||||||
|
SetNuiFocus(state, state);
|
||||||
|
|
||||||
|
isRadioOpen = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports('openRadio', openRadio)
|
||||||
|
exports('isRadioOpen', () => isRadioOpen)
|
||||||
|
exports('setRadioChannelData', (data) => {
|
||||||
|
SendNuiMessage(JSON.stringify({
|
||||||
|
eventName: 'webview:yaca:setChannelData',
|
||||||
|
data: data
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yaca:enableRadio')
|
||||||
|
on('__cfx_nui:client:yaca:enableRadio', (data, cb) => {
|
||||||
|
exports['yaca-voice'].enableRadio(data[0]);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yaca:closeRadio')
|
||||||
|
on('__cfx_nui:client:yaca:closeRadio', (data, cb) => {
|
||||||
|
openRadio(false);
|
||||||
|
emit('yaca:external:radioClosed');
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yaca:changeRadioChannelStereo')
|
||||||
|
on('__cfx_nui:client:yaca:changeRadioChannelStereo', (data, cb) => {
|
||||||
|
exports['yaca-voice'].changeRadioChannelStereo();
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yaca:changeRadioFrequency')
|
||||||
|
on('__cfx_nui:client:yaca:changeRadioFrequency', (data, cb) => {
|
||||||
|
exports['yaca-voice'].changeRadioFrequency(data[0]);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yaca:changeActiveRadioChannel')
|
||||||
|
on('__cfx_nui:client:yaca:changeActiveRadioChannel', (data, cb) => {
|
||||||
|
exports['yaca-voice'].setActiveRadioChannel(data[0]);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yaca:changeRadioChannelVolume')
|
||||||
|
on('__cfx_nui:client:yaca:changeRadioChannelVolume', (data, cb) => {
|
||||||
|
exports['yaca-voice'].changeRadioChannelVolume(data[0]);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yaca:muteRadioChannel')
|
||||||
|
on('__cfx_nui:client:yaca:muteRadioChannel', (data, cb) => {
|
||||||
|
exports['yaca-voice'].muteRadioChannel(data[0]);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yaca:setSecondaryChannel')
|
||||||
|
on('__cfx_nui:client:yaca:setSecondaryChannel', (data, cb) => {
|
||||||
|
exports['yaca-voice'].setSecondaryRadioChannel(data[0]);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
RegisterNuiCallbackType('client:yacaui:ready')
|
||||||
|
on('__cfx_nui:client:yacaui:ready', (data, cb) => {
|
||||||
|
SendNuiMessage(JSON.stringify({
|
||||||
|
eventName: 'webview:yaca:ready',
|
||||||
|
locale: config.locales,
|
||||||
|
useNoActivePluginUI: config.noactive_plugin_ui
|
||||||
|
}))
|
||||||
|
|
||||||
|
if (config.noactive_plugin_ui.usage) {
|
||||||
|
SendNuiMessage(JSON.stringify({
|
||||||
|
eventName: 'webview:yaca:isActive',
|
||||||
|
state: isPluginActive(exports['yaca-voice'].getPluginState())
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
on("yaca:external:pluginStateChanged", state => {
|
||||||
|
if (!config.noactive_plugin_ui.usage) return;
|
||||||
|
|
||||||
|
SendNuiMessage(JSON.stringify({
|
||||||
|
eventName: 'webview:yaca:isActive',
|
||||||
|
state: isPluginActive(state)
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
|
||||||
|
let pluginActive = false;
|
||||||
|
function isPluginActive(state) {
|
||||||
|
const isIngame = ["IN_INGAME_CHANNEL", "IN_EXCLUDED_CHANNEL"].includes(state);
|
||||||
|
|
||||||
|
if (config.noactive_plugin_ui.freezeplayer) {
|
||||||
|
FreezeEntityPosition(PlayerPedId(), !isIngame);
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginActive = isIngame;
|
||||||
|
|
||||||
|
return isIngame
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Keybinds */
|
||||||
|
function registerKeybinds() {
|
||||||
|
if (config.keybinds.open_Radio !== false) {
|
||||||
|
RegisterCommand(
|
||||||
|
'+yaca:openRadio',
|
||||||
|
() => {
|
||||||
|
if (config.noactive_plugin_ui.usage && !pluginActive) return;
|
||||||
|
|
||||||
|
this.openRadio(!isRadioOpen)
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
RegisterKeyMapping('+yaca:openRadio', locale('open_Radio'), 'keyboard', config.keybinds.open_Radio)
|
||||||
|
}
|
||||||
|
}
|
16
resources/[voice]/yaca-ui/config.json
Normal file
16
resources/[voice]/yaca-ui/config.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"noactive_plugin_ui": {
|
||||||
|
"usage": false,
|
||||||
|
"freezeplayer": true,
|
||||||
|
"style": 1,
|
||||||
|
"logo": ""
|
||||||
|
},
|
||||||
|
"keybinds": {
|
||||||
|
"open_Radio": "O"
|
||||||
|
},
|
||||||
|
"locales": {
|
||||||
|
"open_Radio": "Open Radio",
|
||||||
|
"no_plugin_active_header": "Plugin",
|
||||||
|
"no_plugin_active_body": "Das Yaca Plugin muss auf dein Teamspeak Aktiv sein!"
|
||||||
|
}
|
||||||
|
}
|
11
resources/[voice]/yaca-ui/fxmanifest.lua
Normal file
11
resources/[voice]/yaca-ui/fxmanifest.lua
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
games { 'gta5', 'rdr3' }
|
||||||
|
fx_version 'cerulean'
|
||||||
|
|
||||||
|
ui_page 'assets/index.html'
|
||||||
|
|
||||||
|
files {
|
||||||
|
'config.json',
|
||||||
|
'assets/**/*'
|
||||||
|
}
|
||||||
|
|
||||||
|
client_script 'client.js'
|
|
@ -81,7 +81,7 @@
|
||||||
* - "Direct": The radio system is based on the distance between the players.
|
* - "Direct": The radio system is based on the distance between the players.
|
||||||
* - "None": The radio always works no matter the distance.
|
* - "None": The radio always works no matter the distance.
|
||||||
*/
|
*/
|
||||||
"mode": "Tower",
|
"mode": "Direct",
|
||||||
// The maximum distance between two players or to the tower to be able to hear each other.
|
// The maximum distance between two players or to the tower to be able to hear each other.
|
||||||
"maxDistance": 5000
|
"maxDistance": 5000
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue