diff --git a/.hemtt/commands/ctrlWebBrowserAction.yml b/.hemtt/commands/ctrlWebBrowserAction.yml new file mode 100644 index 0000000..45a65f3 --- /dev/null +++ b/.hemtt/commands/ctrlWebBrowserAction.yml @@ -0,0 +1,23 @@ +name: ctrlWebBrowserAction +description: Executes an action on a web browser control +groups: + - GUI Control +syntax: + - call: !Binary [control, action] + ret: + - Nothing + - Nothing + params: + - name: control + type: Control + - name: action + type: String +argument_loc: Local +effect_loc: Local +since: + arma_3: + major: 2 + minor: 2 +examples: + - _control ctrlWebBrowserAction ["ExecJS", "document.getElementById('test').innerHTML = 'Hello World!'"]; + - _control ctrlWebBrowserAction ["LoadURL", "https://community.bistudio.com"]; \ No newline at end of file diff --git a/addons/admin/README.md b/addons/admin/README.md index 77b61fb..4b6e03a 100644 --- a/addons/admin/README.md +++ b/addons/admin/README.md @@ -1,7 +1,7 @@ # Forge Admin Module ## Overview -The Admin module provides administrative functionality for the Forge client system. It includes features for user management, messaging, and administrative controls. +The Admin module provides comprehensive administrative functionality for the Forge client system. It includes features for user management, financial operations, messaging, and administrative controls through both traditional and web-based interfaces. ## Dependencies - forge_client_main @@ -18,9 +18,13 @@ The Admin module provides administrative functionality for the Forge client syst - Initializes the admin system - Sets up necessary permissions and configurations -2. **Admin Interface** (`fnc_openAdmin.sqf`) - - Opens the administrative user interface - - Provides access to administrative controls +2. **Admin Interface** + - **Traditional UI** (`fnc_openAdmin.sqf`) + - Opens the administrative user interface + - Provides access to administrative controls + - **Web-based UI** (`RscWebAdmin.hpp`) + - Modern web interface for administrative tasks + - Real-time player statistics and management 3. **User Management** - **Promotion** (`fnc_adminPromote.sqf`) @@ -30,16 +34,36 @@ The Admin module provides administrative functionality for the Forge client syst - **Refresh** (`fnc_adminRefresh.sqf`) - Updates administrative permissions and states -4. **Communication** +4. **Financial Operations** + - **Payday System** + - Distributes funds based on player ranks + - Configurable paygrade amounts + - **Money Management** + - Advance funds to players + - Deduct funds from players + - Global money distribution + - Company account balance tracking + +5. **Communication** - **Admin Messages** (`fnc_adminMessage.sqf`) - Handles administrative messaging system + - **Broadcast System** + - Send messages to all players + - Targeted player messaging -### User Interface -The module includes two main UI components: -1. **RscCommon.hpp** - - Common UI elements and definitions -2. **RscAdmin.hpp** - - Administrative interface specific elements +### User Interface Components +1. **Traditional UI** (`RscAdmin.hpp`) + - Player list management + - Rank selection and promotion + - Financial operations + - Messaging system + +2. **Web Interface** (`ui/_site/`) + - Modern, responsive design + - Real-time statistics + - Player management + - Financial operations + - Messaging system ## Event Handlers The module uses several event handlers for initialization and execution: @@ -50,7 +74,9 @@ The module uses several event handlers for initialization and execution: ## Usage To use the admin module: 1. Ensure the module is properly loaded in your mission -2. Access administrative functions through the provided UI +2. Access administrative functions through either: + - Traditional UI: Use the provided dialog interface + - Web Interface: Access through the modern web-based panel 3. Use appropriate administrative commands based on your role ## Debugging @@ -60,4 +86,18 @@ Debug mode can be enabled by uncommenting the following in `script_component.hpp ``` ## Version Information -Version information is managed through the main Forge client system configuration. \ No newline at end of file +Version information is managed through the main Forge client system configuration. + +## Security +The module includes built-in security features: +- Admin authentication +- Permission-based access control +- Secure financial transactions +- Protected administrative functions + +## Technical Details +- Supports both traditional Arma 3 UI and modern web interface +- Real-time data updates +- Configurable paygrade system +- Comprehensive player management +- Secure financial operations \ No newline at end of file diff --git a/addons/admin/XEH_PREP.hpp b/addons/admin/XEH_PREP.hpp index 530d7d4..ceea202 100644 --- a/addons/admin/XEH_PREP.hpp +++ b/addons/admin/XEH_PREP.hpp @@ -4,4 +4,4 @@ PREP(handleTransfer); PREP(initAdmin); PREP(openAdmin); PREP(sendMessage); -PREP(updatePaygrade); \ No newline at end of file +PREP(updatePaygrade); diff --git a/addons/admin/XEH_postInit_client.sqf b/addons/admin/XEH_postInit_client.sqf index 84f2529..1f04e6c 100644 --- a/addons/admin/XEH_postInit_client.sqf +++ b/addons/admin/XEH_postInit_client.sqf @@ -1 +1,93 @@ -#include "script_component.hpp" \ No newline at end of file +#include "script_component.hpp" + +[QGVAR(handleEvents), { + params ["_control", "_isConfirmDialog", "_message"]; + + diag_log format ["[FORGE::Client::Admin::XEH_postInit] Received event: %1", _message]; + + _message = fromJSON _message; + private _event = _message get "event"; + private _data = _message get "data"; + + switch (_event) do { + case "REQUEST::PLAYER::DATA": { + private _playerData = createHashMap; + private _playerList = []; + + { + private _player = _x; + private _uid = getPlayerUID _player; + private _name = name _player; + private _paygrade = GETVAR(_player,FORGE_PayGrade,QUOTE(E1)); //TODO: Implement paygrade from server + private _funds = GETVAR(_player,FORGE_Bank,0); //TODO: Implement funds from server + + private _playerInfo = createHashMapFromArray [ + ["uid", _uid], + ["name", _name], + ["paygrade", _paygrade], + ["funds", _funds], + ["side", str (side _player)] + ]; + + _playerList pushBack _playerInfo; + } forEach allPlayers; + + _playerData set ["players", _playerList]; + _control ctrlWebBrowserAction ["ExecJS", format ["handlePlayerDataRequest(%1)", (toJSON _playerList)]]; + }; + case "REQUEST::PAYGRADE::DATA": { + private _payGrades = (missionConfigFile >> "CfgPaygrades" >> "payGrades") call BIS_fnc_getCfgData; + private _paygradeData = createHashMap; + private _paygradeList = []; + + { + private _paygradeInfo = createHashMapFromArray [ + ["paygrade", _x select 0], + ["bonus", _x select 1] + ]; + + _paygradeList pushBack _paygradeInfo; + } forEach _payGrades; + + _paygradeData set ["paygrades", _paygradeList]; + _control ctrlWebBrowserAction ["ExecJS", format ["handlePaygradeDataRequest(%1)", (toJSON _paygradeList)]]; + }; + case "BROADCAST::MESSAGE": { + _data params ["_uid", "_message"]; + + if ((isNil "_message") || {_message isEqualTo ""}) exitWith { systemChat "Message cannot be empty!"; }; + + ["forge_server_admin_handleEvents", ["ADMIN::SEND::MESSAGE", [_uid, _message]]] call CFUNC(serverEvent); + }; + case "SEND::MESSAGE": { + _data params ["_uid", "_message"]; + + if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { systemChat "You did not select a player!"; }; + + ["forge_server_admin_handleEvents", ["ADMIN::SEND::MESSAGE", [_uid, _message]]] call CFUNC(serverEvent); + }; + case "UPDATE::PAYGRADE": { + _data params ["_uid", "_paygrade"]; + + if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { systemChat "You did not select a player!"; }; + + ["forge_server_admin_handleEvents", ["ADMIN::UPDATE::PAYGRADE", [_uid, _paygrade]]] call CFUNC(serverEvent); + }; + case "HANDLE::TRANSFER": { + _data params ["_condition", "_amount", "_uid"]; + + ["forge_server_admin_handleEvents", ["ADMIN::TRANSFER", [_condition, _amount, _uid]]] call CFUNC(serverEvent); + }; + case "ADVANCE::ALL": { + _data params ["_amount"]; + + ["forge_server_admin_handleEvents", ["ADMIN::ADVANCE::ALL", [_amount]]] call CFUNC(serverEvent); + }; + case "HANDLE::PAYDAY": { + ["forge_server_admin_handleEvents", ["ADMIN::PAYDAY"]] call CFUNC(serverEvent); + }; + default { + diag_log format ["[FORGE::Client::Admin::XEH_postInit] Unhandled event: %1", _event]; + }; + }; +}] call CFUNC(addEventHandler); \ No newline at end of file diff --git a/addons/admin/config.cpp b/addons/admin/config.cpp index 26e0730..ef3011f 100644 --- a/addons/admin/config.cpp +++ b/addons/admin/config.cpp @@ -15,4 +15,5 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "ui\RscCommon.hpp" -#include "ui\RscAdmin.hpp" \ No newline at end of file +#include "ui\RscAdmin.hpp" +#include "ui\RscWebAdmin.hpp" \ No newline at end of file diff --git a/addons/admin/functions/fnc_adminRefresh.sqf b/addons/admin/functions/fnc_adminRefresh.sqf index 5329f93..75a8eba 100644 --- a/addons/admin/functions/fnc_adminRefresh.sqf +++ b/addons/admin/functions/fnc_adminRefresh.sqf @@ -1,7 +1,6 @@ #include "..\script_component.hpp" /* - * Function: forge_client_admin_fnc_adminRefresh * Author: IDSolutions * * [Description] @@ -41,4 +40,4 @@ lbClear _list; lbSetCurSel [2023001, 0]; ctrlSetText [2023005, ""]; -ctrlSetText [2023006, ""]; \ No newline at end of file +ctrlSetText [2023006, ""]; diff --git a/addons/admin/functions/fnc_handleTransfer.sqf b/addons/admin/functions/fnc_handleTransfer.sqf index 8ad6004..1f183c8 100644 --- a/addons/admin/functions/fnc_handleTransfer.sqf +++ b/addons/admin/functions/fnc_handleTransfer.sqf @@ -37,4 +37,4 @@ if (_condition in ["advance", "deduct"] && ((isNil "_uid") || { _uid isEqualTo " [_condition, _amount, _uid] remoteExec ["forge_server_admin_fnc_handleTransfer", 2]; -ctrlSetText [2023005, ""]; \ No newline at end of file +ctrlSetText [2023005, ""]; diff --git a/addons/admin/functions/fnc_initAdmin.sqf b/addons/admin/functions/fnc_initAdmin.sqf deleted file mode 100644 index 6bb88dc..0000000 --- a/addons/admin/functions/fnc_initAdmin.sqf +++ /dev/null @@ -1,37 +0,0 @@ -#include "..\script_component.hpp" - -/* - * Function: forge_client_admin_fnc_initAdmin - * Author: IDSolutions - * - * [Description] - * Initializes the admin menu. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Examples: - * None - * - * Public: No - */ - -{ - private _configName = configName(_x); - private _className = (missionConfigFile >> "CfgCpofs" >> "cpofs" >> _configName >> "className") call BFUNC(getCfgData); - private _pos = (missionConfigFile >> "CfgCpofs" >> "cpofs" >> _configName >> "pos") call BFUNC(getCfgData); - private _dir = (missionConfigFile >> "CfgCpofs" >> "cpofs" >> _configName >> "dir") call BFUNC(getCfgData); - - private _cpof = createSimpleObject [_className, [0, 0, 0]]; - - _cpof setPosATL _pos; - _cpof setDir _dir; - _cpof allowDamage false; - _cpof setVariable ["isCPOF", true, true]; - - diag_log text format ["[FORGE Admin] ClassName: '%1' Pos: '%2' Dir: '%3'", _className, _pos, _dir]; - -} forEach ("true" configClasses (missionConfigFile >> "CfgCpofs" >> "cpofs")); \ No newline at end of file diff --git a/addons/admin/functions/fnc_openAdmin.sqf b/addons/admin/functions/fnc_openAdmin.sqf index a9f965c..da141ca 100644 --- a/addons/admin/functions/fnc_openAdmin.sqf +++ b/addons/admin/functions/fnc_openAdmin.sqf @@ -1,11 +1,8 @@ #include "..\script_component.hpp" /* - * Function: forge_client_admin_fnc_openAdmin * Author: IDSolutions - * - * [Description] - * Opens the admin menu. + * Opens the admin dialog. * * Arguments: * None @@ -13,8 +10,8 @@ * Return Value: * None * - * Examples: - * None + * Example: + * [] call forge_client_admin_fnc_openAdmin; * * Public: Yes */ @@ -41,11 +38,43 @@ lbSetCurSel [2023001, 0]; private _payGrades = (missionConfigFile >> "CfgPaygrades" >> "payGrades") call BFUNC(getCfgData); -{ - private _index = _list2 lbAdd format ["%1 - $%2", (_x select 0), ((_x select 1) call EFUNC(misc,formatNumber))]; +if (_steamBranchName == "profiling") then { + private _display = (findDisplay 46) createDisplay "RscWebAdmin"; + private _ctrl = _display displayCtrl 2025; - _list2 lbSetData [_index, str _x]; -} forEach _payGrades; + _ctrl ctrlAddEventHandler ["JSDialog", { + params ["_control", "_isConfirmDialog", "_message"]; + [QGVAR(handleEvents), [_control, _isConfirmDialog, _message]] call CFUNC(localEvent); + }]; -lbSetCurSel [2023003, 0]; -ctrlSetText [2023002, format ["$%1", (companyFunds call EFUNC(misc,formatNumber))]]; \ No newline at end of file + _ctrl ctrlWebBrowserAction ["LoadFile", QUOTE(PATHTOF(ui\_site\index.html))]; +} else { + disableSerialization; + createDialog "RscAdmin"; + + private _dialog = findDisplay 202303; + private _list = _dialog displayCtrl 2023001; + private _list2 = _dialog displayCtrl 2023003; + + { + if (str (side _x) == str (playerSide) && isPlayer _x) then { + private _name = name (_x); + private _uid = getPlayerUID _x; + private _payGrade = GETVAR(_x,FORGE_PayGrade,QUOTE(E1)); + private _index = _list lbAdd format["%1 - %2", _name, _payGrade]; + + _list lbSetData [_index, _uid]; + }; + } count (allPlayers); + + lbSetCurSel [2023001, 0]; + + { + private _index = _list2 lbAdd format ["%1 - $%2", (_x select 0), ((_x select 1) call EFUNC(misc,formatNumber))]; + + _list2 lbSetData [_index, str _x]; + } forEach _payGrades; + + lbSetCurSel [2023003, 0]; + ctrlSetText [2023002, format ["$%1", (companyFunds call EFUNC(misc,formatNumber))]]; +}; diff --git a/addons/admin/functions/fnc_sendMessage.sqf b/addons/admin/functions/fnc_sendMessage.sqf index 34e50d9..ad365be 100644 --- a/addons/admin/functions/fnc_sendMessage.sqf +++ b/addons/admin/functions/fnc_sendMessage.sqf @@ -34,4 +34,4 @@ if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { hintSilent "You did not se hintSilent format ["Message sent to UID %1: %2", _uid, _message]; -["dummy"] call FUNC(adminRefresh); \ No newline at end of file +["dummy"] call FUNC(adminRefresh); diff --git a/addons/admin/functions/fnc_updatePaygrade.sqf b/addons/admin/functions/fnc_updatePaygrade.sqf index c9ad0e3..606f672 100644 --- a/addons/admin/functions/fnc_updatePaygrade.sqf +++ b/addons/admin/functions/fnc_updatePaygrade.sqf @@ -34,4 +34,4 @@ if ((isNil "_targetUID") || {_targetUID isEqualTo ""}) exitWith { hintSilent "Yo [_targetUID, _paygrade] remoteExec ["forge_server_admin_fnc_updatePaygrade", 2]; -["dummy"] call FUNC(adminRefresh); \ No newline at end of file +["dummy"] call FUNC(adminRefresh); diff --git a/addons/admin/ui/RscWebAdmin.hpp b/addons/admin/ui/RscWebAdmin.hpp new file mode 100644 index 0000000..0ae04e5 --- /dev/null +++ b/addons/admin/ui/RscWebAdmin.hpp @@ -0,0 +1,17 @@ +class RscWebAdmin { + idd = 20250502; + fadein = 0; + fadeout = 0; + duration = 1e+011; + + class controls { + class Background: RscText { + type = 106; + idc = 2025; + x = "safeZoneY * (pixelW/pixelH) * 2.975"; + y = "safeZoneY + (safeZoneH * 0.05)"; + w = "safeZoneW * (pixelW/pixelH) * 1.17"; + h = "safeZoneH * 0.875"; + }; + }; +}; \ No newline at end of file diff --git a/addons/admin/ui/_site/index.html b/addons/admin/ui/_site/index.html index 42434e7..86bc1a0 100644 --- a/addons/admin/ui/_site/index.html +++ b/addons/admin/ui/_site/index.html @@ -1,22 +1,44 @@ - - - Forge Admin Panel - - - - - + + +

Admin Panel

+
-
👥
Online Players 0 @@ -24,7 +46,6 @@
-
👑
Staff Online 0 @@ -34,10 +55,18 @@
+
+
- +

Global Actions

@@ -47,7 +76,7 @@
- +

Give All Money

@@ -57,7 +86,7 @@
- +

Broadcast Message

@@ -68,24 +97,37 @@
- +
+ +
- +
- + + +