From 55f60dc71fe469d321174657d3defb65fec7fec1 Mon Sep 17 00:00:00 2001 From: Jacob Schmidt Date: Sat, 3 May 2025 19:33:10 -0500 Subject: [PATCH] feat: Revamp admin panel, store, and arsenal systems This commit introduces significant changes to the admin panel, store, and arsenal systems, focusing on improved functionality, UI enhancements, and code optimization. **Admin Panel:** - Migrated to a web-based UI for improved user experience and maintainability. - Implemented dynamic player listing with filtering and search capabilities. - Added functionality for managing player paygrades, sending messages, and transferring funds. - Integrated server-side events for handling admin actions. **Store:** - Added `handleDelivery` event handler. - Streamlined product selection and purchase processes. - Improved handling of organization funds and player balances. - Refactored code for better readability and maintainability. **Arsenal:** - Enhanced initialization process with improved data validation. - Optimized item unlocking logic. These changes aim to provide a more robust, user-friendly, and efficient experience for both administrators and players. --- .hemtt/commands/ctrlWebBrowserAction.yml | 23 + addons/admin/XEH_PREP.hpp | 7 +- addons/admin/XEH_postInit.sqf | 97 ++- addons/admin/config.cpp | 3 +- addons/admin/functions/fnc_adminMessage.sqf | 49 -- addons/admin/functions/fnc_adminPromote.sqf | 51 -- addons/admin/functions/fnc_adminRefresh.sqf | 57 +- addons/admin/functions/fnc_adminTransfer.sqf | 118 ---- addons/admin/functions/fnc_handleTransfer.sqf | 40 ++ addons/admin/functions/fnc_openAdmin.sqf | 66 +- addons/admin/functions/fnc_printAddonName.sqf | 22 - addons/admin/functions/fnc_sendMessage.sqf | 37 ++ addons/admin/functions/fnc_updatePaygrade.sqf | 37 ++ addons/admin/ui/RscAdmin.hpp | 4 +- addons/admin/ui/RscWebAdmin.hpp | 17 + addons/admin/ui/_site/index.html | 78 ++- addons/admin/ui/_site/script.js | 473 ++++++++++---- addons/admin/ui/_site/styles.css | 606 +++++++++++------- .../arsenal/functions/fnc_addArmoryItem.sqf | 14 +- addons/arsenal/functions/fnc_initArsenal.sqf | 49 +- addons/init/functions/fnc_playerDBSave.sqf | 8 +- addons/store/XEH_PREP.hpp | 1 + addons/store/functions/fnc_buyItem.sqf | 7 +- addons/store/functions/fnc_changeFilter.sqf | 18 +- addons/store/functions/fnc_handleDelivery.sqf | 66 ++ addons/store/functions/fnc_handlePurchase.sqf | 23 +- addons/store/functions/fnc_openStore.sqf | 9 +- addons/store/functions/fnc_selectProduct.sqf | 7 +- 28 files changed, 1222 insertions(+), 765 deletions(-) create mode 100644 .hemtt/commands/ctrlWebBrowserAction.yml delete mode 100644 addons/admin/functions/fnc_adminMessage.sqf delete mode 100644 addons/admin/functions/fnc_adminPromote.sqf delete mode 100644 addons/admin/functions/fnc_adminTransfer.sqf create mode 100644 addons/admin/functions/fnc_handleTransfer.sqf delete mode 100644 addons/admin/functions/fnc_printAddonName.sqf create mode 100644 addons/admin/functions/fnc_sendMessage.sqf create mode 100644 addons/admin/functions/fnc_updatePaygrade.sqf create mode 100644 addons/admin/ui/RscWebAdmin.hpp create mode 100644 addons/store/functions/fnc_handleDelivery.sqf 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/XEH_PREP.hpp b/addons/admin/XEH_PREP.hpp index d510380..dcb11aa 100644 --- a/addons/admin/XEH_PREP.hpp +++ b/addons/admin/XEH_PREP.hpp @@ -1,7 +1,6 @@ -PREP(adminMessage); -PREP(adminPromote); PREP(adminRefresh); -PREP(adminTransfer); +PREP(handleTransfer); PREP(initAdmin); PREP(openAdmin); -PREP(printAddonName); \ No newline at end of file +PREP(sendMessage); +PREP(updatePaygrade); \ No newline at end of file diff --git a/addons/admin/XEH_postInit.sqf b/addons/admin/XEH_postInit.sqf index 84f2529..f554e99 100644 --- a/addons/admin/XEH_postInit.sqf +++ b/addons/admin/XEH_postInit.sqf @@ -1 +1,96 @@ -#include "script_component.hpp" \ No newline at end of file +#include "script_component.hpp" + +[QGVAR(handleEvents), { + params ["_control", "_isConfirmDialog", "_message"]; + + diag_log format ["[FORGE: Admin] 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)); + private _funds = GETVAR(_player,FORGE_Bank,0); + + 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 { hintSilent "Message cannot be empty!"; }; + + ["forge_server_admin_handleEvents", ["sendMessage", [_uid, _message]]] call CFUNC(serverEvent); + }; + case "SEND_MESSAGE": { + _data params ["_uid", "_message"]; + + if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { hintSilent "You did not select a player!"; }; + + ["forge_server_admin_handleEvents", ["sendMessage", [_uid, _message]]] call CFUNC(serverEvent); + }; + case "UPDATE_PAYGRADE": { + private _uid = _data select 0; + private _paygrade = _data select 1; + + if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { hintSilent "You did not select a player!"; }; + + ["forge_server_admin_handleEvents", ["updatePaygrade", [_uid, _paygrade]]] call CFUNC(serverEvent); + }; + case "HANDLE_TRANSFER": { + private _condition = _data select 0; + private _amount = _data select 1; + private _uid = _data select 2; + + ["forge_server_admin_handleEvents", ["handleTransfer", [_condition, _amount, _uid]]] call CFUNC(serverEvent); + }; + case "ADVANCE_ALL": { + private _amount = _data select 0; + + ["forge_server_admin_handleEvents", ["advanceAll", [_amount]]] call CFUNC(serverEvent); + }; + case "HANDLE_PAYDAY": { + ["forge_server_admin_handleEvents", ["handlePayday"]] call CFUNC(serverEvent); + }; + default { + diag_log format ["[FORGE: Admin] 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_adminMessage.sqf b/addons/admin/functions/fnc_adminMessage.sqf deleted file mode 100644 index 983d735..0000000 --- a/addons/admin/functions/fnc_adminMessage.sqf +++ /dev/null @@ -1,49 +0,0 @@ -#include "..\script_component.hpp" - -/* - * Function: forge_client_admin_fnc_adminMessage - * Author: IDSolutions - * - * [Description] - * Admin Message Menu - * - * Arguments: - * None - * - * Return Value: - * None - * - * Examples: - * None - * - * Public: Yes - */ - -private ["_data", "_dialog", "_list", "_target", "_targetValue", "_textBox", "_textMessage"]; - -_dialog = findDisplay 202303; -_list = _dialog displayCtrl 2023001; -_textBox = _dialog displayCtrl 2023006; -_targetValue = lbCurSel _list; -_data = _list lbData _targetValue; - -if ((isNil {_data})) exitWith { hintSilent "You did not select a player!" }; - -{ - if (str (name (_x)) == str _data) then { - _target = _x; - }; -} forEach playableUnits; - -hintSilent format ["Player Selected. You have selected %1", _target]; - -if (isNil "_target") then { - hintSilent "Please Select an Active Player First!" -} else { - _textMessage = ctrlText _textBox; - [_target, _textMessage] remoteExec ["forge_server_misc_fnc_textMessage", 2]; - - // [format ["Message sent to %1:
%2", _target, _textMessage], "blue-grey", 3] call EFUNC(misc,notify); -}; - -["dummy"] call FUNC(adminRefresh); \ No newline at end of file diff --git a/addons/admin/functions/fnc_adminPromote.sqf b/addons/admin/functions/fnc_adminPromote.sqf deleted file mode 100644 index 7ced94e..0000000 --- a/addons/admin/functions/fnc_adminPromote.sqf +++ /dev/null @@ -1,51 +0,0 @@ -#include "..\script_component.hpp" - -/* - * Function: forge_client_admin_fnc_adminPromote - * Author: IDSolutions - * - * [Description] - * Admin Promote Menu - * - * Arguments: - * None - * - * Return Value: - * None - * - * Examples: - * None - * - * Public: Yes - */ - -params [["_condition", "", [""]]]; - -private ["_data", "_data2", "_dialog", "_list", "_list2", "_paygrade", "_rankValue", "_target", "_targetValue"]; - -_dialog = findDisplay 202303; -_list = _dialog displayCtrl 2023001; -_list2 = _dialog displayCtrl 2023003; -_targetValue = lbCurSel _list; -_rankValue = lbCurSel _list2; -_data = _list lbData _targetValue; -_data2 = call compile format ["%1", (_list2 lbData _rankValue)]; -_paygrade = _data2 select 0; - -if ((isNil {_data})) exitWith { hintSilent "You did not select a player!" }; -{ - if (str (name (_x)) == str _data) then { - _target = _x; - }; -} forEach playableUnits; - -switch (_condition) do { - case ("promote"): { - SETPVAR(_target,FORGE_PayGrade,_paygrade) - }; - case ("demote"): { - SETPVAR(_target,FORGE_PayGrade,_paygrade) - }; -}; - -["dummy"] call FUNC(adminRefresh); \ No newline at end of file diff --git a/addons/admin/functions/fnc_adminRefresh.sqf b/addons/admin/functions/fnc_adminRefresh.sqf index 2293259..5329f93 100644 --- a/addons/admin/functions/fnc_adminRefresh.sqf +++ b/addons/admin/functions/fnc_adminRefresh.sqf @@ -5,74 +5,39 @@ * Author: IDSolutions * * [Description] - * Admin Refresh Menu + * Refreshes the admin interface player list and resets input fields. + * This function populates the player list with names and paygrades, + * storing player UIDs as data for each entry. Only shows players + * on the same side as the admin. * * Arguments: - * None + * 0: Dummy - Optional parameter, not used (for compatibility with event handlers) * * Return Value: * None * * Examples: - * None + * [] call forge_client_admin_fnc_adminRefresh; + * ["dummy"] call forge_client_admin_fnc_adminRefresh; * - * Public: Yes + * Public: No - Called from admin dialog controls */ -params [["_condition", "", [""]], ["_amount", 0, [0]]]; -private _store = missionNamespace getVariable ["FORGE_ORG_STORE_REG", createHashMap]; -private _org = _store call ["getOrg", []]; - -if (isNil "_org") exitWith { ["You are not in an organization!", "warning", 3] call EFUNC(misc,notify) }; - -private _orgFunds = _org get "funds"; - -private _newFunds = 0; private _dialog = findDisplay 202303; private _list = _dialog displayCtrl 2023001; -switch (_condition) do { - case ("deduct"): { - _newFunds = _orgFunds - _amount; - ctrlSetText [2023002, format ["$%1", (_newFunds call EFUNC(misc,formatNumber))]]; - }; - case ("advance"): { - _newFunds = _orgFunds + _amount; - ctrlSetText [2023002, format ["$%1", (_newFunds call EFUNC(misc,formatNumber))]]; - }; - default { - lbClear _list; - - { - if (str (side _x) == str (playerSide)) then { - private _name = name (_x); - private _defaultPaygrade = "E1"; - private _paygrade = GETVAR(_x,FORGE_PayGrade,_defaultPaygrade); - private _index = _list lbAdd format["%1 - %2", _name, _paygrade]; - - _list lbSetData [_index, name (_x)]; - }; - } forEach playableUnits; - - lbSetCurSel [2023001, 0]; - ctrlSetText [2023005, ""]; - ctrlSetText [2023006, ""]; - }; -}; - lbClear _list; { if (str (side _x) == str (playerSide)) then { private _name = name (_x); - private _defaultPaygrade = "E1"; - private _paygrade = GETVAR(_x,FORGE_PayGrade,_defaultPaygrade); + private _paygrade = GETVAR(_x,FORGE_PayGrade,QUOTE(E1)); private _index = _list lbAdd format["%1 - %2", _name, _paygrade]; - _list lbSetData [_index, name (_x)]; + _list lbSetData [_index, getPlayerUID _x]; }; -} forEach playableUnits; +} forEach allPlayers; lbSetCurSel [2023001, 0]; ctrlSetText [2023005, ""]; diff --git a/addons/admin/functions/fnc_adminTransfer.sqf b/addons/admin/functions/fnc_adminTransfer.sqf deleted file mode 100644 index 6ef1213..0000000 --- a/addons/admin/functions/fnc_adminTransfer.sqf +++ /dev/null @@ -1,118 +0,0 @@ -#include "..\script_component.hpp" - -/* - * Function: forge_client_admin_fnc_adminTransfer - * Author: IDSolutions - * - * [Description] - * Admin Transfer Menu - * - * Arguments: - * None - * - * Return Value: - * None - * - * Examples: - * None - * - * Public: Yes - */ - -params [["_condition", "", [""]]]; - -private _store = missionNamespace getVariable ["FORGE_ORG_STORE_REG", createHashMap]; -private _org = _store call ["getOrg", []]; - -if (isNil "_org") exitWith { ["You are not in an organization!", "warning", 3] call EFUNC(misc,notify) }; - -private _orgFunds = _org get "funds"; - -private _dialog = findDisplay 202303; -private _list = _dialog displayCtrl 2023001; -private _targetValue = lbCurSel _list; -private _data = _list lbData _targetValue; -private _amount = round (parseNumber (ctrlText 2023005)); - -if ((isNil {_data})) exitWith { hint "You did not select a player!" }; - -{ - if (str (name (_x)) == str _data) then { - private _target = _x; - }; -} count playableUnits; - -switch (_condition) do { - case ("advance"): { - private _bank = GETVAR(_target,FORGE_Bank,0); - private _newBalance = _bank + _amount; - - if (_amount > _orgFunds) exitWith { ["Not enough money in the organization's account!", "warning", 3] call EFUNC(misc,notify) }; - - SETPVAR(_target,FORGE_Bank,_newBalance); - - ["deduct", _amount] call FUNC(adminRefresh); - _store call ["updateFunds", -_amount]; - }; - case ("advanceAll"): { - private _count = count playableUnits; - - if ((10000 * _count) > _orgFunds) exitWith { ["Not enough money in the organization's account!", "warning", 3] call EFUNC(misc,notify) }; - - { - private _bank = GETVAR(_x,FORGE_Bank,0); - private _newBalance = _bank + 10000; - - SETPVAR(_x,FORGE_Bank,_newBalance); - } count playableUnits; - - ["deduct", (10000 * _count)] call FUNC(adminRefresh); - _store call ["updateFunds", -(10000 * _count)]; - }; - case ("deduct"): { - private _bank = GETVAR(_target,FORGE_Bank,0); - private _newBalance = _bank - _amount; - - if (_amount > _bank) exitWith { ["Not enough money in the player's account!", "warning", 3] call EFUNC(misc,notify) }; - - SETPVAR(_target,FORGE_Bank,_newBalance); - - ["advance", _amount] call FUNC(adminRefresh); - _store call ["updateFunds", _amount]; - }; - case ("payday"): { - private _totalPayment = 0; - private _paymentToDo = []; - private _payGrades = (missionConfigFile >> "CfgPaygrades" >> "payGrades") call BIS_fnc_getCfgData; - - { - private _player = _x; - private _payGrade = GETVAR(_player,FORGE_PayGrade,nil); - - { - _x params ["_payGradeIndex", "_payGradeBonus"]; - - if ((_x select 0) == _payGrade) then { - _paymentToDo pushBack [_player, _payGradeBonus]; - _totalPayment = _totalPayment + _payGradeBonus; - }; - } forEach _payGrades; - } count playableUnits; - - if (_totalPayment > _orgFunds) exitWith { ["Not enough money in the organization's account!", "warning", 3] call EFUNC(misc,notify) }; - - { - _x params ["_player", "_bonus"]; - - private _bank = GETVAR(_player,FORGE_Bank,0); - private _newBalance = _bank + _bonus; - - SETPVAR(_player,FORGE_Bank,_newBalance); - } count _paymentToDo; - - ["deduct", _totalPayment] call FUNC(adminRefresh); - _store call ["updateFunds", -_totalPayment]; - }; -}; - -ctrlSetText [2023005, ""]; \ No newline at end of file diff --git a/addons/admin/functions/fnc_handleTransfer.sqf b/addons/admin/functions/fnc_handleTransfer.sqf new file mode 100644 index 0000000..54e786d --- /dev/null +++ b/addons/admin/functions/fnc_handleTransfer.sqf @@ -0,0 +1,40 @@ +#include "..\script_component.hpp" + +/* + * Function: forge_client_admin_fnc_handleTransfer + * Author: IDSolutions + * + * [Description] + * Handles fund transfers through the admin interface. + * This function retrieves the selected player's UID and amount + * from the admin dialog, then sends it to the server-side admin store. + * Supports multiple transfer types: advance (to single player), + * deduct (from single player), advanceAll (to all players), + * and payday (distribute based on paygrade). + * + * Arguments: + * 0: Condition - The type of transfer to perform ("advance", "deduct", "advanceAll", "payday") + * + * Return Value: + * None + * + * Examples: + * ["advance"] call forge_client_admin_fnc_handleTransfer; + * ["payday"] call forge_client_admin_fnc_handleTransfer; + * + * Public: No - Called from admin dialog controls + */ + +params [["_condition", "", [""]]]; + +private _dialog = findDisplay 202303; +private _list = _dialog displayCtrl 2023001; +private _index = lbCurSel _list; +private _uid = _list lbData _index; +private _amount = round (parseNumber (ctrlText 2023005)); + +if (_condition in ["advance", "deduct"] && ((isNil "_uid") || { _uid isEqualTo "" })) exitWith { hint "You did not select a player!"; }; + +["forge_server_admin_handleEvents", ["handleTransfer", [_condition, _amount, _uid]]] call CFUNC(serverEvent); + +ctrlSetText [2023005, ""]; \ No newline at end of file diff --git a/addons/admin/functions/fnc_openAdmin.sqf b/addons/admin/functions/fnc_openAdmin.sqf index ccd5fc4..4aff4df 100644 --- a/addons/admin/functions/fnc_openAdmin.sqf +++ b/addons/admin/functions/fnc_openAdmin.sqf @@ -19,33 +19,47 @@ * Public: Yes */ -disableSerialization; -createDialog "RscAdmin"; - -private _dialog = findDisplay 202303; -private _list = _dialog displayCtrl 2023001; -private _list2 = _dialog displayCtrl 2023003; - -{ - if (str (side _x) == str (playerSide)) then { - private _name = name (_x); - private _defaultPaygrade = "E1"; - private _payGrade = GETVAR(_x,FORGE_PayGrade,_defaultPaygrade); - private _index = _list lbAdd format["%1 - %2", _name, _payGrade]; - - _list lbSetData [_index, _name]; - }; -} count (allPlayers); - -lbSetCurSel [2023001, 0]; - +private _productVersion = productVersion; +private _steamBranchName = _productVersion select 8; 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))]]; +}; \ No newline at end of file diff --git a/addons/admin/functions/fnc_printAddonName.sqf b/addons/admin/functions/fnc_printAddonName.sqf deleted file mode 100644 index e0326e0..0000000 --- a/addons/admin/functions/fnc_printAddonName.sqf +++ /dev/null @@ -1,22 +0,0 @@ -#include "..\script_component.hpp" - -/* - * Function: forge_client_admin_fnc_printAddonName - * Author: IDSolutions - * - * [Description] - * Prints the name of the addon to the system chat. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Examples: - * None - * - * Public: No - */ - -systemChat format ["Thank you for using the %1", 'ADDON']; \ No newline at end of file diff --git a/addons/admin/functions/fnc_sendMessage.sqf b/addons/admin/functions/fnc_sendMessage.sqf new file mode 100644 index 0000000..8783e20 --- /dev/null +++ b/addons/admin/functions/fnc_sendMessage.sqf @@ -0,0 +1,37 @@ +#include "..\script_component.hpp" + +/* + * Function: forge_client_admin_fnc_sendMessage + * Author: IDSolutions + * + * [Description] + * Sends a message to a selected player through the admin interface. + * This function retrieves the selected player's UID and message content + * from the admin dialog, then sends it to the server-side admin store. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Examples: + * [] call forge_client_admin_fnc_sendMessage; + * + * Public: No - Called from admin dialog controls + */ + +private _dialog = findDisplay 202303; +private _list = _dialog displayCtrl 2023001; +private _control = _dialog displayCtrl 2023006; +private _index = lbCurSel _list; +private _uid = _list lbData _index; +private _message = ctrlText _control; + +if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { hintSilent "You did not select a player!"; }; + +["forge_server_admin_handleEvents", ["sendMessage", [_uid, _message]]] call CFUNC(serverEvent); + +hintSilent format ["Message sent to UID %1: %2", _uid, _message]; + +["dummy"] call FUNC(adminRefresh); \ No newline at end of file diff --git a/addons/admin/functions/fnc_updatePaygrade.sqf b/addons/admin/functions/fnc_updatePaygrade.sqf new file mode 100644 index 0000000..1c226e4 --- /dev/null +++ b/addons/admin/functions/fnc_updatePaygrade.sqf @@ -0,0 +1,37 @@ +#include "..\script_component.hpp" + +/* + * Function: forge_client_admin_fnc_updatePaygrade + * Author: IDSolutions + * + * [Description] + * Updates a player's paygrade in the server's admin store. + * This function retrieves the selected player's UID and the target paygrade + * from the admin dialog, then sends it to the server-side admin store. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Examples: + * [] call forge_client_admin_fnc_updatePaygrade; + * + * Public: No - Called from admin dialog controls + */ + +private _dialog = findDisplay 202303; +private _list = _dialog displayCtrl 2023001; +private _list2 = _dialog displayCtrl 2023003; +private _targetIndex = lbCurSel _list; +private _rankIndex = lbCurSel _list2; +private _uid = _list lbData _targetIndex; +private _rankData = call compile format ["%1", (_list2 lbData _rankIndex)]; +private _paygrade = _rankData select 0; + +if ((isNil "_uid") || {_uid isEqualTo ""}) exitWith { hintSilent "You did not select a player!" }; + +["forge_server_admin_handleEvents", ["updatePaygrade", [_uid, _paygrade]]] call CFUNC(serverEvent); + +["dummy"] call FUNC(adminRefresh); \ No newline at end of file diff --git a/addons/admin/ui/RscAdmin.hpp b/addons/admin/ui/RscAdmin.hpp index 8c07dc0..2fdcb4c 100644 --- a/addons/admin/ui/RscAdmin.hpp +++ b/addons/admin/ui/RscAdmin.hpp @@ -83,7 +83,7 @@ class RscAdmin { class RscAdminPromote: RscButton { idc = -1; colorText[] = {1,1,1,1}; - onButtonClick = "['promote'] call forge_client_admin_fnc_adminPromote;"; + onButtonClick = "[] call forge_client_admin_fnc_updatePaygrade;"; soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0.09,1}; text = "Promote"; x = "0.675 * safezoneW + safezoneX"; @@ -163,7 +163,7 @@ class RscAdmin { class RscAdminSend: RscButton { idc = -1; colorText[] = {1,1,1,1}; - onButtonClick = "[] call forge_client_admin_fnc_adminMessage;"; + onButtonClick = "[] call forge_client_admin_fnc_sendMessage;"; soundClick[] = {"\A3\ui_f\data\sound\RscButton\soundClick",0.09,1}; text = "Send Message"; x = "0.6125 * safezoneW + safezoneX"; 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 @@
- +
+ +
- +
- + + +