From 8902d53e44bf570c4d6269cd45a62a4bd390fcb0 Mon Sep 17 00:00:00 2001 From: John Jordan Date: Sat, 20 Apr 2024 16:33:30 +0100 Subject: [PATCH 1/3] Allow guest commanders limited use of arsenal limits dialog and set default guest limit to 0 --- A3A/addons/core/Params.hpp | 2 +- A3A/addons/core/dialogs.hpp | 2 +- A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp | 2 +- A3A/addons/gui/dialogues/ids.inc | 1 + .../gui/functions/GUI/fn_arsenalLimitsDialog.sqf | 11 +++++++++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/A3A/addons/core/Params.hpp b/A3A/addons/core/Params.hpp index eadf359eb0..32711a28f0 100644 --- a/A3A/addons/core/Params.hpp +++ b/A3A/addons/core/Params.hpp @@ -308,7 +308,7 @@ class Params title = $STR_A3A_Params_guestItemLimit_title; values[] = {0,10,15,25,40}; texts[] = {$STR_A3A_Params_generic_nolimit,"10","15","25","40"}; - default = 25; + default = 0; }; class unlockedUnlimitedAmmo { diff --git a/A3A/addons/core/dialogs.hpp b/A3A/addons/core/dialogs.hpp index 1d82bb4119..92f0f90e73 100644 --- a/A3A/addons/core/dialogs.hpp +++ b/A3A/addons/core/dialogs.hpp @@ -1802,7 +1802,7 @@ class commander_comm { w = 0.175015 * safezoneW; h = 0.0560125 * safezoneH; tooltip = "Manage arsenal limitations of guests"; //$STR_antistasi_dialogs_commander_comm_faction_garage_tooltip; - action = "if (player == theBoss && theBoss call A3A_fnc_isMember) then {closeDialog 0; createDialog ""A3A_ArsenalLimitsDialog""} else {[""Arsenal limits"", ""Only member commanders have access to this function""] call A3A_fnc_customHint}"; + action = "if (player == theBoss) then {closeDialog 0; createDialog ""A3A_ArsenalLimitsDialog""} else {[""Arsenal limits"", ""Only commanders have access to this function""] call A3A_fnc_customHint}"; }; class 8slots_L4: A3A_core_BattleMenuRedButton { diff --git a/A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp b/A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp index 369cdc1b3f..feb5d9ae6d 100644 --- a/A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp +++ b/A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp @@ -15,7 +15,7 @@ class A3A_ArsenalLimitsDialog { idd = A3A_IDD_ARSENALLIMITSDIALOG; movingenable = false; - onLoad = "['typeSelect'] spawn A3A_fnc_arsenalLimitsDialog"; + onLoad = "['init'] spawn A3A_fnc_arsenalLimitsDialog"; onUnload = "publicVariable 'A3A_arsenalLimits'"; class ControlsBackground { diff --git a/A3A/addons/gui/dialogues/ids.inc b/A3A/addons/gui/dialogues/ids.inc index dd563e68f7..d773f5d4d9 100644 --- a/A3A/addons/gui/dialogues/ids.inc +++ b/A3A/addons/gui/dialogues/ids.inc @@ -322,6 +322,7 @@ Maintainer: DoomMetal #define A3A_IDC_ARSLIMTYPESELECT 9504 #define A3A_IDC_ARSLIMSTEPBUTTON 9505 #define A3A_IDC_ARSLIMCLOSEBUTTON 9506 +#define A3A_IDC_ARSLIMRESETBUTTON 9507 #define A3A_IDC_ARSLIMTYPESBASE 9550 // Setup interface diff --git a/A3A/addons/gui/functions/GUI/fn_arsenalLimitsDialog.sqf b/A3A/addons/gui/functions/GUI/fn_arsenalLimitsDialog.sqf index 0f2bcf6058..02be60e129 100644 --- a/A3A/addons/gui/functions/GUI/fn_arsenalLimitsDialog.sqf +++ b/A3A/addons/gui/functions/GUI/fn_arsenalLimitsDialog.sqf @@ -25,6 +25,15 @@ private _listBox = _display displayCtrl A3A_IDC_ARSLIMLISTBOX; switch (_mode) do { + case ("init"): + { + if !(player call A3A_fnc_isMember) then { + ["Arsenal limits", "As a guest commander you can only increase arsenal limits, not decrease them."] call A3A_fnc_customHint; + (_display displayctrl A3A_IDC_ARSLIMRESETBUTTON) ctrlEnable false; + }; + ["typeSelect"] call A3A_fnc_arsenalLimitsDialog; + }; + case ("typeSelect"): { private _typeIndex = if (isNil "_params") then { 0 } else { (_params#0) - A3A_IDC_ARSLIMTYPESBASE }; @@ -61,6 +70,7 @@ switch (_mode) do case ("listButton"): { + if (_params#0 < 0 and !(player call A3A_fnc_isMember)) exitWith {}; if (isNil {_display getVariable "stepSize"}) exitWith {}; private _stepSize = _display getVariable "stepSize"; private _curRow = lnbCurSelRow _listBox; @@ -68,6 +78,7 @@ switch (_mode) do private _curVal = _listBox lnbValue [_curRow, 2]; private _newVal = 0 max (_curVal + _stepSize*(_params#0)); + _newVal = if (minWeaps < 0) then { _newVal min 100 } else { _newVal min minWeaps }; _listBox lnbSetText [[_curRow, 2], str _newVal]; _listBox lnbSetValue [[_curRow, 2], _newVal]; A3A_arsenalLimits set [_class, _newVal]; From 9c7cb89b38eea0f22b6b22ce135e1f9f94307577 Mon Sep 17 00:00:00 2001 From: John Jordan Date: Sun, 21 Apr 2024 02:23:04 +0100 Subject: [PATCH 2/3] Enable save and load of arsenal limits data --- A3A/addons/core/functions/Save/fn_deleteSave.sqf | 2 +- A3A/addons/core/functions/Save/fn_loadServer.sqf | 1 + A3A/addons/core/functions/Save/fn_loadStat.sqf | 5 ++++- A3A/addons/core/functions/Save/fn_saveLoop.sqf | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/A3A/addons/core/functions/Save/fn_deleteSave.sqf b/A3A/addons/core/functions/Save/fn_deleteSave.sqf index 4d06309ba0..f94448118d 100644 --- a/A3A/addons/core/functions/Save/fn_deleteSave.sqf +++ b/A3A/addons/core/functions/Save/fn_deleteSave.sqf @@ -46,7 +46,7 @@ private _savedPlayers = _namespace getVariable ["savedPlayers" + _postfix, []]; "outpostsFIA", "tasks", "idlebases", "idleassets", "killZones", "controlsSDK", "params", "attackCountdownOccupants", "attackCountdownInvaders", "prestigeNATO", "prestigeCSAT", "savedPlayers", "testingTimerIsActive", "HR_Garage", "A3A_fuelAmountleftArray", "HQKnowledge", "enemyResources", - "version", "name", "saveTime", "ended", "factions", "addonVics", "DLC"]; + "version", "name", "saveTime", "ended", "factions", "addonVics", "DLC", "arsenalLimits"]; // Remove this campaign from the save list, if present diff --git a/A3A/addons/core/functions/Save/fn_loadServer.sqf b/A3A/addons/core/functions/Save/fn_loadServer.sqf index f5ff905e22..fea398ef24 100644 --- a/A3A/addons/core/functions/Save/fn_loadServer.sqf +++ b/A3A/addons/core/functions/Save/fn_loadServer.sqf @@ -38,6 +38,7 @@ if (isServer) then { ["killZones"] call A3A_fnc_getStatVariable; ["controlsSDK"] call A3A_fnc_getStatVariable; ["bombRuns"] call A3A_fnc_getStatVariable; + ["arsenalLimits"] call A3A_fnc_getStatVariable; ["jna_dataList"] call A3A_fnc_getStatVariable; //=========================================================================== diff --git a/A3A/addons/core/functions/Save/fn_loadStat.sqf b/A3A/addons/core/functions/Save/fn_loadStat.sqf index de49ea4684..c86ef55f86 100644 --- a/A3A/addons/core/functions/Save/fn_loadStat.sqf +++ b/A3A/addons/core/functions/Save/fn_loadStat.sqf @@ -33,7 +33,7 @@ private _specialVarLoads = [ "garrison","tasks","membersX","vehInGarage","destroyedBuildings","idlebases", "chopForest","weather","killZones","jna_dataList","controlsSDK","mrkCSAT","nextTick", "bombRuns","wurzelGarrison","aggressionOccupants", "aggressionInvaders", "enemyResources", "HQKnowledge", - "testingTimerIsActive", "version", "HR_Garage", "A3A_fuelAmountleftArray" + "testingTimerIsActive", "version", "HR_Garage", "A3A_fuelAmountleftArray", "arsenalLimits" ]; private _varName = _this select 0; @@ -375,6 +375,9 @@ if (_varName in _specialVarLoads) then { }; }; }; + if (_varname == "arsenalLimits") then { + A3A_arsenalLimits = _varValue; publicVariable "A3A_arsenalLimits"; + }; if(_varname == 'testingTimerIsActive') then { diff --git a/A3A/addons/core/functions/Save/fn_saveLoop.sqf b/A3A/addons/core/functions/Save/fn_saveLoop.sqf index 0069ae5e52..c45373d395 100644 --- a/A3A/addons/core/functions/Save/fn_saveLoop.sqf +++ b/A3A/addons/core/functions/Save/fn_saveLoop.sqf @@ -87,6 +87,7 @@ private _antennasDeadPositions = []; ["maxUnits", 140] call A3A_fnc_setStatVariable; // backwards compatibility ["nextTick", nextTick - time] call A3A_fnc_setStatVariable; ["weather",[fogParams,rain]] call A3A_fnc_setStatVariable; +["arsenalLimits", A3A_arsenalLimits] call A3A_fnc_setStatVariable; private _destroyedPositions = destroyedBuildings apply { getPosATL _x }; ["destroyedBuildings",_destroyedPositions] call A3A_fnc_setStatVariable; From 4b8f155e41564bf2eeebc4912974c1cfbf6a91ea Mon Sep 17 00:00:00 2001 From: John Jordan Date: Sun, 2 Jun 2024 20:56:12 +0100 Subject: [PATCH 3/3] Port arsenal limits dialog to Antistasi GUI style, store member-set values --- A3A/addons/gui/Stringtable.xml | 9 + .../gui/dialogues/arsenalLimitsDialog.hpp | 195 +++++++----------- A3A/addons/gui/dialogues/controls.hpp | 5 + .../functions/GUI/fn_arsenalLimitsDialog.sqf | 98 ++++++--- A3A/addons/jeroen_arsenal/JNA/fn_arsenal.sqf | 2 +- .../JNA/fn_arsenal_loadInventory.sqf | 2 +- .../jeroen_arsenal/JNA/fn_vehicleArsenal.sqf | 2 +- 7 files changed, 153 insertions(+), 160 deletions(-) diff --git a/A3A/addons/gui/Stringtable.xml b/A3A/addons/gui/Stringtable.xml index 7d48d41574..3e82baa1df 100644 --- a/A3A/addons/gui/Stringtable.xml +++ b/A3A/addons/gui/Stringtable.xml @@ -2,6 +2,12 @@ + + Arsenal Guest Limits + + + As a guest commander you can't reduce arsenal limits below default, or below values set by members. + CLOSE Schließen @@ -58,6 +64,9 @@ RESET 重置 + + Reset all items in this category to the default guest limit + STEP Schritt diff --git a/A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp b/A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp index feb5d9ae6d..8562d23532 100644 --- a/A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp +++ b/A3A/addons/gui/dialogues/arsenalLimitsDialog.hpp @@ -1,112 +1,61 @@ -// From 3den\UI\macros.inc. DoomGUI uses different values for GRID_W, GRID_H, CENTER_X, CENTER_Y -#define AL_GRID_W (pixelW * pixelGrid * 0.5) -#define AL_GRID_H (pixelH * pixelGrid * 0.5) -#define AL_CENTER_X ((getResolution select 2) * 0.5 * pixelW) -#define AL_CENTER_Y ((getResolution select 3) * 0.5 * pixelH) - #include "ids.inc" -class RscText; -class RscButton; -class RscListNBox; -class RscControlsGroup; - -class A3A_ArsenalLimitsDialog { +class A3A_ArsenalLimitsDialog : A3A_DefaultDialog { idd = A3A_IDD_ARSENALLIMITSDIALOG; movingenable = false; onLoad = "['init'] spawn A3A_fnc_arsenalLimitsDialog"; onUnload = "publicVariable 'A3A_arsenalLimits'"; - class ControlsBackground { - class blackAllBlack : RscText { - colorBackground[]={0.1,0.1,0.1,0.8}; - x = AL_CENTER_X - 80*AL_GRID_W; - y = safezoneY + 30*AL_GRID_H; - w = 160*AL_GRID_W; - h = safezoneH - 60*AL_GRID_H; - }; - class TitleBar: RscText { - colorBackground[]={0.7,0.3,0,1}; - style = ST_CENTER; - sizeEx = 6*AL_GRID_H; + class Controls { + class TitlebarText : A3A_TitlebarText { + idc = -1; text = $STR_antistasi_arsenal_limits_dialog_title; - font = "TahomaB"; - x = AL_CENTER_X - 80*AL_GRID_W; - y = safezoneY + 20*AL_GRID_H; - w = 160*AL_GRID_W; - h = 10*AL_GRID_H; + x = DIALOG_X; + y = DIALOG_Y - 5*GRID_H; + w = DIALOG_W * GRID_W; + h = 5*GRID_H; }; - }; - class Controls { - class ArrowLeft: RscButton { - idc = A3A_IDC_ARSLIMARROWMINUS; - text = "-"; - colorBackground[]={0,0,0,0.8}; - onButtonClick = "['listButton', [-1]] call A3A_fnc_arsenalLimitsDialog"; - fade = 1; - enable = 0; - w = 6*AL_GRID_W; // x/y ignored - h = 6*AL_GRID_H; - sizeEx = 6*AL_GRID_H; - }; - class ArrowRight: ArrowLeft { - idc = A3A_IDC_ARSLIMARROWPLUS; - onButtonClick = "['listButton', [1]] call A3A_fnc_arsenalLimitsDialog"; - text="+"; - }; - class MainListBox : RscListNBox { + class MainListBox : A3A_ControlsGroup { idc = A3A_IDC_ARSLIMLISTBOX; - colorBackground[]={0,0,0.5,0.8}; // completely ignored? - colorSelectBackground[]={0.7,0.3,0,0.5}; - colorSelectBackground2[]={0.7,0.3,0,0.5}; - colorPictureSelected[]={1,1,1,1}; - colorSelect[]={1,1,1,1}; - colorSelect2[]={1,1,1,1}; - colorPictureRightSelected[]={1,1,1,1}; - columns[]={0.05, 0.67, 0.80}; - idcLeft = A3A_IDC_ARSLIMARROWMINUS; - idcRIght = A3A_IDC_ARSLIMARROWPLUS; - drawSideArrows=1; - disableOverflow=1; - x = AL_CENTER_X - 60*AL_GRID_W; - y = safezoneY + 36*AL_GRID_H; - w = 130*AL_GRID_W; - h = safezoneH - 80*AL_GRID_H; - sizeEx = 5*AL_GRID_H; + x = DIALOG_X + 42*GRID_W; + y = DIALOG_Y + 6*GRID_H; + w = 102*GRID_W; + h = 88*GRID_H; }; - class HeaderCurrent : RscText { + class HeaderCurrent : A3A_TextRight { idc = -1; - colorBackground[]={0,0,0,0}; - colorText[]={1,1,1,0.8}; - x = AL_CENTER_X - 60*AL_GRID_W + 85*AL_GRID_W; - y = safezoneY + 30*AL_GRID_H; - w = 50*AL_GRID_W; - h = 6*AL_GRID_H; - sizeEx = 5*AL_GRID_H; + x = DIALOG_X + 95*GRID_W; + y = DIALOG_Y + 2*GRID_H; + w = 10*GRID_W; + h = 4*GRID_H; text = $STR_antistasi_arsenal_limits_dialog_current; }; class HeaderLimit : HeaderCurrent { - x = AL_CENTER_X - 60*AL_GRID_W + 104*AL_GRID_W; + x = DIALOG_X + 115*GRID_W; text = $STR_antistasi_arsenal_limits_dialog_limit; }; - class CloseButton : RscButton { + class ResetButton : A3A_Button { + idc = A3A_IDC_ARSLIMRESETBUTTON; + x = DIALOG_X + 14*GRID_W; + y = DIALOG_Y + 78*GRID_H; + text = $STR_antistasi_arsenal_limits_dialog_reset; + tooltip = $STR_antistasi_arsenal_limits_dialog_reset_tooltip; + onButtonClick = "['resetButton'] call A3A_fnc_arsenalLimitsDialog"; + }; + + class CloseButton : A3A_Button { idc = A3A_IDC_ARSLIMCLOSEBUTTON; - colorBackground[]={0.7,0.3,0,1}; - colorFocused[]={0.7,0.3,0,1}; - colorText[]={1,1,1,1}; - font = "PuristaBold"; - style = ST_CENTER; - sizeEx = 6*AL_GRID_H; - x = AL_CENTER_X - 80*AL_GRID_W; - y = safezoneY + safezoneH - 38*AL_GRID_H; - w = 40*AL_GRID_W; - h = 8*AL_GRID_H; + x = DIALOG_X + 14*GRID_W; + y = DIALOG_Y + 88*GRID_H; text = $STR_antistasi_arsenal_limits_dialog_close; onButtonClick = "closeDialog 0"; }; + + +/* class StepButton : CloseButton { idc = A3A_IDC_ARSLIMSTEPBUTTON; x = AL_CENTER_X - 20*AL_GRID_W; @@ -114,143 +63,137 @@ class A3A_ArsenalLimitsDialog { onButtonClick = "['stepButton'] call A3A_fnc_arsenalLimitsDialog"; onLoad = "['stepButton'] spawn A3A_fnc_arsenalLimitsDialog"; }; - class ResetButton : CloseButton { - idc = A3A_IDC_ARSLIMRESETBUTTON; - x = AL_CENTER_X + 40*AL_GRID_W; - text = $STR_antistasi_arsenal_limits_dialog_reset; - onButtonClick = "['resetButton'] call A3A_fnc_arsenalLimitsDialog"; - }; - - class TypeSelection : RscControlsGroup { +*/ + class TypeSelection : A3A_ControlsGroup { idc = A3A_IDC_ARSLIMTYPESELECT; - x = AL_CENTER_X - 76*AL_GRID_W; - y = safezoneY + 34*AL_GRID_H; - w = 10*AL_GRID_W; - h = safezoneH - 80*AL_GRID_H; + x = DIALOG_X + 14*GRID_W; + y = DIALOG_Y + 6*GRID_H; + w = 16*GRID_W; + h = 68*GRID_H; class controls { - class buttonPrimaryWeapon : RscButton { + class buttonPrimaryWeapon : A3A_Button { style = ST_PICTURE + ST_KEEP_ASPECT_RATIO; idc = A3A_IDC_ARSLIMTYPESBASE + 0; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\PrimaryWeapon_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_PrimaryWeapon"; onButtonClick = "['typeSelect', [ctrlIDC (_this#0)]] call A3A_fnc_arsenalLimitsDialog"; - colorBackground[]={0,0,0,0.5}; colorDisabled[] = {0,0,0,1}; colorBackgroundDisabled[] = {1,1,1,1}; x = 0; y = 0; - w = 8*AL_GRID_W; - h = 8*AL_GRID_H; + w = 6*GRID_W; + h = 6*GRID_H; }; class buttonHandgun : buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 2; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Handgun_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_Handgun"; - y = 8*AL_GRID_H; + y = 6*GRID_H; }; class buttonSecondaryWeapon : buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 1; tooltip="$STR_A3_RscDisplayArsenal_tab_SecondaryWeapon"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\SecondaryWeapon_ca.paa"; - y = 16*AL_GRID_H; + y = 12*GRID_H; }; class buttonHeadgear : buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 6; tooltip="$STR_A3_RscDisplayArsenal_tab_Headgear"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Headgear_ca.paa"; - y = 24*AL_GRID_H; + y = 18*GRID_H; }; class buttonUniform : buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 3; tooltip="$STR_A3_RscDisplayArsenal_tab_Uniform"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Uniform_ca.paa"; - y = 32*AL_GRID_H; + y = 24*GRID_H; }; class buttonVest: buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 4; tooltip="$STR_A3_RscDisplayArsenal_tab_Vest"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Vest_ca.paa"; - y = 40*AL_GRID_H; + y = 30*GRID_H; }; class buttonBackpack: buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 5; tooltip="$STR_A3_RscDisplayArsenal_tab_Backpack"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Backpack_ca.paa"; - y = 48*AL_GRID_H; + y = 36*GRID_H; }; class buttonNVG: buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 8; tooltip="$STR_A3_RscDisplayArsenal_tab_NVGs"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\NVGs_ca.paa"; - y = 56*AL_GRID_H; + y = 42*GRID_H; }; class buttonBinoculars: buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 9; tooltip="$STR_A3_RscDisplayArsenal_tab_Binoculars"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Binoculars_ca.paa"; - y = 64*AL_GRID_H; + y = 48*GRID_H; }; class buttonGPS: buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 11; tooltip="$STR_A3_RscDisplayArsenal_tab_GPS"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\GPS_ca.paa"; - y = 72*AL_GRID_H; + y = 54*GRID_H; }; class buttonRadio: buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 12; tooltip="$STR_A3_RscDisplayArsenal_tab_Radio"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\Radio_ca.paa"; - y = 80*AL_GRID_H; + y = 60*GRID_H; }; class buttonOptic: buttonPrimaryWeapon { idc = A3A_IDC_ARSLIMTYPESBASE + 18; tooltip="$STR_A3_RscDisplayArsenal_tab_ItemOptic"; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemOptic_ca.paa"; - y = 92*AL_GRID_H; + x = 10*GRID_W; + y = 0*GRID_H; }; - class buttonItemAcc: buttonPrimaryWeapon { + class buttonItemAcc: buttonOptic { idc = A3A_IDC_ARSLIMTYPESBASE + 19; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemAcc_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_ItemAcc"; - y = 100*AL_GRID_H; + y = 6*GRID_H; }; - class buttonMuzzle: buttonPrimaryWeapon { + class buttonMuzzle: buttonOptic { idc = A3A_IDC_ARSLIMTYPESBASE + 20; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemMuzzle_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_ItemMuzzle"; - y = 108*AL_GRID_H; + y = 12*GRID_H; }; - class buttonBipod: buttonPrimaryWeapon { + class buttonBipod: buttonOptic { idc = A3A_IDC_ARSLIMTYPESBASE + 25; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\ItemBipod_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_ItemBipod"; - y = 116*AL_GRID_H; + y = 18*GRID_H; }; - class buttonMag: buttonPrimaryWeapon { + class buttonMag: buttonOptic { idc = A3A_IDC_ARSLIMTYPESBASE + 26; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoMagAll_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_CargoMagAll"; - y = 128*AL_GRID_H; + y = 28*GRID_H; }; - class buttonThrow: buttonPrimaryWeapon { + class buttonThrow: buttonOptic { idc = A3A_IDC_ARSLIMTYPESBASE + 22; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoThrow_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_CargoThrow"; - y = 136*AL_GRID_H; + y = 34*GRID_H; }; - class buttonPut: buttonPrimaryWeapon { + class buttonPut: buttonOptic { idc = A3A_IDC_ARSLIMTYPESBASE + 23; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoPut_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_CargoPut"; - y = 144*AL_GRID_H; + y = 40*GRID_H; }; - class buttonMisc: buttonPrimaryWeapon { + class buttonMisc: buttonOptic { idc = A3A_IDC_ARSLIMTYPESBASE + 24; text="\A3\Ui_f\data\GUI\Rsc\RscDisplayArsenal\CargoMisc_ca.paa"; tooltip="$STR_A3_RscDisplayArsenal_tab_CargoMisc"; - y = 152*AL_GRID_H; + y = 46*GRID_H; }; }; }; diff --git a/A3A/addons/gui/dialogues/controls.hpp b/A3A/addons/gui/dialogues/controls.hpp index fcc11db881..596fa8cb5d 100644 --- a/A3A/addons/gui/dialogues/controls.hpp +++ b/A3A/addons/gui/dialogues/controls.hpp @@ -57,6 +57,11 @@ class A3A_Text : A3A_CtrlDefault colorBackground[] = A3A_COLOR_TRANSPARENT; }; +class A3A_TextRight : A3A_Text +{ + style = ST_RIGHT; +}; + class A3A_TextMulti: A3A_Text { style = ST_LEFT + ST_MULTI + ST_NO_RECT; diff --git a/A3A/addons/gui/functions/GUI/fn_arsenalLimitsDialog.sqf b/A3A/addons/gui/functions/GUI/fn_arsenalLimitsDialog.sqf index 02be60e129..85dd988e7b 100644 --- a/A3A/addons/gui/functions/GUI/fn_arsenalLimitsDialog.sqf +++ b/A3A/addons/gui/functions/GUI/fn_arsenalLimitsDialog.sqf @@ -13,6 +13,7 @@ Environment: */ #include "..\..\dialogues\ids.inc" +#include "..\..\dialogues\defines.hpp" #include "..\..\script_component.hpp" FIX_LINE_NUMBERS() @@ -23,22 +24,23 @@ private _fnc_defaultLimit = { [A3A_guestItemLimit, 3*A3A_guestItemLimit] select private _display = findDisplay A3A_IDD_ARSENALLIMITSDIALOG; private _listBox = _display displayCtrl A3A_IDC_ARSLIMLISTBOX; + switch (_mode) do { case ("init"): { if !(player call A3A_fnc_isMember) then { - ["Arsenal limits", "As a guest commander you can only increase arsenal limits, not decrease them."] call A3A_fnc_customHint; + [localize "STR_antistasi_arsenal_limits_dialog_hint_title", localize "STR_antistasi_arsenal_limits_dialog_guest_warning"] call A3A_fnc_customHint; (_display displayctrl A3A_IDC_ARSLIMRESETBUTTON) ctrlEnable false; }; - ["typeSelect"] call A3A_fnc_arsenalLimitsDialog; + ["typeSelect", [A3A_IDC_ARSLIMTYPESBASE]] call A3A_fnc_arsenalLimitsDialog; }; case ("typeSelect"): { - private _typeIndex = if (isNil "_params") then { 0 } else { (_params#0) - A3A_IDC_ARSLIMTYPESBASE }; + private _typeIndex = (_params#0) - A3A_IDC_ARSLIMTYPESBASE; _display setVariable ["typeIndex", _typeIndex]; - private _defaultLimit = _typeIndex call _fnc_defaultLimit; + private _defLimit = _typeIndex call _fnc_defaultLimit; private _cfgCat = switch (_typeIndex) do { case 5: { configFile / "cfgVehicles" }; @@ -46,20 +48,44 @@ switch (_mode) do default { configFile / "cfgWeapons" }; }; - lnbClear _listBox; + { ctrlDelete _x } forEach allControls _listBox; { _x params ["_class", "_count"]; - if (_count == -1) then { continue }; private _itemName = getText (_cfgCat / _class / "displayName"); - private _limit = A3A_arsenalLimits getOrDefault [_class, _defaultLimit]; + private _limit = A3A_arsenalLimits getOrDefault [_class, [_defLimit]] select 0; if (_typeIndex == 26) then { private _capacity = 1 max getNumber (_cfgCat / _class / "count"); _count = round (_count / _capacity); }; - private _rowIndex = _listBox lnbAddRow [_itemName, str _count, str _limit]; - _listBox lnbSetValue [[_rowIndex, 2], _limit]; - _listBox lnbSetData [[_rowIndex, 0], _class]; // store original classname for updating - } forEach (jna_datalist#_typeIndex); + private _index = _forEachIndex; + + private _nameCtrl = _display ctrlCreate ["A3A_Text", -1, _listBox]; + _nameCtrl ctrlSetPosition [0, _index*GRID_H*4, 54*GRID_W, 4*GRID_H]; + _nameCtrl ctrlCommit 0; + _nameCtrl ctrlSetText _itemName; + + private _numCtrl = _display ctrlCreate ["A3A_TextRight", -1, _listBox]; + _numCtrl ctrlSetPosition [54*GRID_W, _index*GRID_H*4, 6*GRID_W, 4*GRID_H]; + _numCtrl ctrlCommit 0; + _numCtrl ctrlSetText str _count; + + private _valCtrl = _display ctrlCreate ["A3A_TextRight", -1, _listBox]; + _valCtrl ctrlSetPosition [75*GRID_W, _index*GRID_H*4, 6*GRID_W, 4*GRID_H]; + _valCtrl ctrlCommit 0; + _valCtrl ctrlSetText str _limit; + _valCtrl setVariable ["A3A_class", _class]; + + { + _x params ["_text", "_adjust", "_xpos"]; + private _button = _display ctrlCreate ["A3A_Button", -1, _listBox]; + _button ctrlSetPosition [_xpos*GRID_W, _index*4*GRID_H, 4*GRID_W, 4*GRID_H]; + _button ctrlCommit 0; + _button ctrlSetText _text; + _button setVariable ["A3A_params", [_valCtrl, _adjust]]; + _button ctrlAddEventHandler ["ButtonClick", { ["listButton", _this] call A3A_fnc_arsenalLimitsDialog }]; + } forEach [["R", "R", 66], ["-", -5, 70], ["+", 5, 82], ["U", "U", 86]]; + + } forEach (jna_datalist#_typeIndex select {_x#1>0}); // only show non-unlocked items // color-invert the selected button, restore the others { @@ -70,34 +96,43 @@ switch (_mode) do case ("listButton"): { - if (_params#0 < 0 and !(player call A3A_fnc_isMember)) exitWith {}; - if (isNil {_display getVariable "stepSize"}) exitWith {}; - private _stepSize = _display getVariable "stepSize"; - private _curRow = lnbCurSelRow _listBox; - private _class = _listBox lnbData [_curRow, 0]; - - private _curVal = _listBox lnbValue [_curRow, 2]; - private _newVal = 0 max (_curVal + _stepSize*(_params#0)); - _newVal = if (minWeaps < 0) then { _newVal min 100 } else { _newVal min minWeaps }; - _listBox lnbSetText [[_curRow, 2], str _newVal]; - _listBox lnbSetValue [[_curRow, 2], _newVal]; - A3A_arsenalLimits set [_class, _newVal]; + private _ctrl = _params#0; + _ctrl getVariable "A3A_params" params ["_valCtrl", "_adjust"]; + + private _defLimit = (_display getVariable "typeIndex") call _fnc_defaultLimit; + private _class = _valCtrl getVariable "A3A_class"; + A3A_arsenalLimits getOrDefault [_class, [_defLimit, _defLimit]] params ["_curVal", "_memberVal"]; + + private _newVal = call { + if (_adjust isEqualTo "R") exitWith { _defLimit }; + if (_adjust isEqualTo "U") exitWith { [minWeaps, 100] select (minWeaps < 0) }; + (_curVal + _adjust) max 0 min 100; + }; + // If we're not a member, then cap to member limit. + if !(player call A3A_fnc_isMember) then { + _newVal = _newVal max _memberVal; + } else { + _memberVal = _newVal; + }; + + _valCtrl ctrlSetText str _newVal; + if (_newVal == _defaultLimit) exitWith { A3A_arsenalLimits deleteAt _class }; + A3A_arsenalLimits set [_class, [_newVal, _memberVal]]; }; case ("resetButton"): { if (isNil {_display getVariable "typeIndex"}) exitWith {}; - private _defaultLimit = (_display getVariable "typeIndex") call _fnc_defaultLimit; + private _typeIndex = _display getVariable "typeIndex"; - private _rowCount = lnbSize _listBox select 0; - for "_row" from 0 to (_rowCount-1) do { - _listBox lnbSetText [[_row, 2], str _defaultLimit]; - _listBox lnbSetValue [[_row, 2], _defaultLimit]; - A3A_arsenalLimits deleteAt (_listBox lnbData [_row, 0]); - }; + { + A3A_arsenalLimits deleteAt (_x#0); + } forEach (jna_datalist#_typeIndex); + + ["typeSelect", [_typeIndex + A3A_IDC_ARSLIMTYPESBASE]] call A3A_fnc_arsenalLimitsDialog; // refresh the display }; - case ("stepButton"): +/* case ("stepButton"): { private _stepSize = _display getVariable ["stepSize", 1]; private _newstepSize = [1, 5] select (_stepSize == 1); @@ -105,4 +140,5 @@ switch (_mode) do private _newText = localize "STR_antistasi_arsenal_limits_dialog_step" + " ±" + str _newStepSize; ctrlSetText [A3A_IDC_ARSLIMSTEPBUTTON, _newText]; }; +*/ }; diff --git a/A3A/addons/jeroen_arsenal/JNA/fn_arsenal.sqf b/A3A/addons/jeroen_arsenal/JNA/fn_arsenal.sqf index c325063848..cc6155afbc 100644 --- a/A3A/addons/jeroen_arsenal/JNA/fn_arsenal.sqf +++ b/A3A/addons/jeroen_arsenal/JNA/fn_arsenal.sqf @@ -131,7 +131,7 @@ _arrayContains = { private _minItemsMember = { params ["_index", "_item"]; // Arsenal tab index, item classname private _min = jna_minItemMember select _index; - _min = A3A_arsenalLimits getOrDefault [_item, _min]; + _min = A3A_arsenalLimits getOrDefault [_item, [_min]] select 0; if (_index == IDC_RSCDISPLAYARSENAL_TAB_CARGOMAG || _index == IDC_RSCDISPLAYARSENAL_TAB_CARGOMAGALL) then { _min = _min * getNumber (configfile >> "CfgMagazines" >> _item >> "count"); }; diff --git a/A3A/addons/jeroen_arsenal/JNA/fn_arsenal_loadInventory.sqf b/A3A/addons/jeroen_arsenal/JNA/fn_arsenal_loadInventory.sqf index 433691097b..2839307923 100644 --- a/A3A/addons/jeroen_arsenal/JNA/fn_arsenal_loadInventory.sqf +++ b/A3A/addons/jeroen_arsenal/JNA/fn_arsenal_loadInventory.sqf @@ -164,7 +164,7 @@ _itemCounts =+ _availableItems; _item = _x select 0; _amount = (_x select 1); if (_amount != -1 && !_isMember) then { - _itemMin = A3A_arsenalLimits getOrDefault [_item, _arrayMin]; + _itemMin = A3A_arsenalLimits getOrDefault [_item, [_arrayMin]] select 0; if (_isMagArray) then { _itemMin = _itemMin * getNumber (configfile >> "CfgMagazines" >> _item >> "count") }; _subArray set [_foreachindex, [_item, (_amount - _itemMin) max 0]]; }; diff --git a/A3A/addons/jeroen_arsenal/JNA/fn_vehicleArsenal.sqf b/A3A/addons/jeroen_arsenal/JNA/fn_vehicleArsenal.sqf index d6f807f4d2..792128f07b 100644 --- a/A3A/addons/jeroen_arsenal/JNA/fn_vehicleArsenal.sqf +++ b/A3A/addons/jeroen_arsenal/JNA/fn_vehicleArsenal.sqf @@ -118,7 +118,7 @@ disableserialization; private _minItemsMember = { params ["_index", "_item"]; // Arsenal tab index, item classname private _min = jna_minItemMember select _index; - _min = A3A_arsenalLimits getOrDefault [_item, _min]; + _min = A3A_arsenalLimits getOrDefault [_item, [_min]] select 0; if (_index == IDC_RSCDISPLAYARSENAL_TAB_CARGOMAG || _index == IDC_RSCDISPLAYARSENAL_TAB_CARGOMAGALL) then { _min = _min * getNumber (configfile >> "CfgMagazines" >> _item >> "count"); };