diff options
| author | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:55:24 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:55:24 +0300 |
| commit | 628d33984d9228f1781d13a65fbb80f35facc899 (patch) | |
| tree | cd909141f87e14f22c3511549a9bc067d9ff8b50 /Client/GUI/GUI_Menu_Economy.sqf | |
| download | a2wf_sara-628d33984d9228f1781d13a65fbb80f35facc899.tar.gz a2wf_sara-628d33984d9228f1781d13a65fbb80f35facc899.tar.bz2 a2wf_sara-628d33984d9228f1781d13a65fbb80f35facc899.zip | |
init
Diffstat (limited to 'Client/GUI/GUI_Menu_Economy.sqf')
| -rw-r--r-- | Client/GUI/GUI_Menu_Economy.sqf | 239 |
1 files changed, 239 insertions, 0 deletions
diff --git a/Client/GUI/GUI_Menu_Economy.sqf b/Client/GUI/GUI_Menu_Economy.sqf new file mode 100644 index 0000000..aa0fac0 --- /dev/null +++ b/Client/GUI/GUI_Menu_Economy.sqf @@ -0,0 +1,239 @@ +disableSerialization;
+
+_display = _this select 0;
+_map = _display DisplayCtrl 23002;
+
+_hqDeployed = (sideJoined) Call GetSideHQDeployed;
+if (!_hqDeployed || !paramUseWorkers) then {ctrlEnable [23004, false];ctrlEnable [23006, false]};
+if !(paramUseWorkers) then {ctrlSetText[23005, localize 'STR_WF_Disabled']};
+
+MenuAction = -1;
+
+_maxWorkers = 'WFBE_WORKERS_MAX' Call GetNamespace;
+_workerPrice = 'WFBE_WORKERS_PRICE' Call GetNamespace;
+_incomeSystem = 'WFBE_INCOMESYSTEM' Call GetNamespace;
+_incomeDividision = 'WFBE_INC_DIVIDE_COM' Call GetNamespace;
+_supplySystem = 'WFBE_SUPPLYSYSTEM' Call GetNamespace;
+_aliveWorkers = [];
+_workers = [];
+_lastWorkersUpdate = -10;
+_lastComboUpdate = -30;
+_lastPurchase = -5;
+_income = 0;
+_updateComboWorker = true;
+_hasStarted = true;
+
+_lastUse = 0;
+ctrlEnable [23016,false];
+if (_supplySystem != 0) then {ctrlShow [23016, false]};
+
+if (_incomeSystem in [3,4]) then {
+ sliderSetRange[23010,0,100];
+ _income = Call Compile Format["%1CommanderPercent",sideJoined];
+ sliderSetPosition[23010, _income];
+} else {
+ ctrlEnable [23012, false];
+};
+
+while {alive player && dialog} do {
+ if (side player != sideJoined) exitWith {closeDialog 0};
+ if !(dialog) exitWith {};
+
+ _funds = Call GetPlayerFunds;
+
+ //--- Income System.
+ if (_incomeSystem in [3,4]) then {
+ ctrlSetText[23011, Format["%1%2",_income,"%"]];
+ _currentPercent = Call Compile Format["%1CommanderPercent",sideJoined];
+
+ _income = floor(sliderPosition 23010);
+
+ sliderSetPosition[23010, _income];
+
+ _calInc = (sideJoined) Call GetTownsIncome;
+
+ if (_currentPercent != _income || _hasStarted) then {
+ if (_hasStarted) then {_hasStarted = false};
+
+ _income_players = 0;
+ _income_commander = 0;
+ switch (_incomeSystem) do {
+ case 3: {
+ _income_players = round(_calInc * (((100 - _income)/100)/maxPlayers));
+ _income_commander = round((_calInc * (_income/100)) / _incomeDividision) + _income_players;
+ };
+ case 4: {
+ _income_players = round(_calInc * (100 - _income) / 100);
+ _income_commander = round((_calInc - _income_players)*maxPlayers) + _income_players;
+ };
+ };
+
+ ctrlSetText [23013, localize 'STR_WF_ECONOMY_Income_Sys_Com' + ": $" + str(_income_commander)];
+ ctrlSetText [23014, localize 'STR_WF_ECONOMY_Income_Sys_Ply' + ": $" + str(_income_players)];
+ };
+
+ if (MenuAction == 3) then {
+ MenuAction = -1;
+
+ if (_currentPercent != _income) then {
+ Call Compile Format["%1CommanderPercent = _income; publicVariable '%1CommanderPercent';",sideJoined];
+ };
+ };
+ };
+
+ //--- Workers System.
+ if (paramUseWorkers) then {
+ if (time - _lastComboUpdate > 5) then {
+ _updateComboWorker = true;
+ _lastComboUpdate = time;
+ };
+
+ _workers = Call Compile Format ["WF_%1Workers",sideJoinedText];
+ if (time - _lastWorkersUpdate > 5) then {_aliveWorkers = (_workers) Call GetLiveUnits;_lastWorkersUpdate = time};
+ _hqDeployed = (sideJoined) Call GetSideHQDeployed;
+
+ if (!_hqDeployed || time - _lastPurchase < 3 || count _aliveWorkers >= _maxWorkers || _funds < _workerPrice) then {ctrlEnable [23004, false]} else {ctrlEnable [23004, true]};
+
+ //--- Workers tracker.
+ if (_updateComboWorker) then {
+ _updateComboWorker = false;
+ lbClear 23007;
+
+ for '_i' from 0 to count(_aliveWorkers)-1 do {
+ lbAdd [23007, localize "STR_WF_ECONOMY_Workers" + " " + str(_i+1)];
+ };
+ };
+
+ ctrlSetText [23005, Format ["$%1 (%2/%3)",_workerPrice,count _aliveWorkers,_maxWorkers]];
+ };
+
+ //--- Hire Workers.
+ if (MenuAction == 1) then {
+ MenuAction = -1;
+
+ //--- Which index.
+ _index = 0;
+ for '_i' from 0 to count(_workers)-1 do {
+ if (isNull (_workers select _i)) exitWith {_index = _i};
+ };
+
+ if (_index == 0 && count(_workers) > 0) then {_index = count _workers};
+
+ if (count _aliveWorkers <= _maxWorkers && _hqDeployed) then {
+ -(_workerPrice) Call ChangePlayerFunds;
+
+ WFBE_RequestWorker = ['SRVFNCREQUESTWORKER',[sideJoined,(sideJoined) Call GetSideHQ,_index]];
+ publicVariable 'WFBE_RequestWorker';
+ if (isHostedServer) then {['SRVFNCREQUESTWORKER',[sideJoined,(sideJoined) Call GetSideHQ,_index]] Spawn HandleSPVF};
+
+ _workers set [_index, WF_Logic];
+ Call Compile Format ["WF_%1Workers = _workers; publicVariable 'WF_%1Workers';",sideJoinedText];
+
+ _lastPurchase = time;
+ _lastWorkersUpdate = -10;
+ _updateComboWorker = true;
+ };
+ };
+
+ //--- Disband Worker.
+ if (MenuAction == 2) then {
+ MenuAction = -1;
+
+ _value = lbCurSel 23007;
+
+ if (_value != -1) then {
+ (_aliveWorkers select _value) setDammage 1;
+ _lastWorkersUpdate = -10;
+ _updateComboWorker = true;
+ };
+ };
+
+ //--- ST Handler.
+ if (_supplySystem == 0) then {
+ _isCommander = false;
+ if (!isNull(commanderTeam)) then {if (commanderTeam == group player) then {_isCommander = true}};
+ ctrlEnable [23016,if (time - _lastUse > 5 && _isCommander) then {true} else {false}];
+ };
+
+ //--- Respawn Supply Trucks.
+ if (MenuAction == 4) then {
+ MenuAction = -1;
+ WFBE_RequestSpecial = ['SRVFNCREQUESTSPECIAL',["RespawnST",sideJoined]];
+ publicVariable 'WFBE_RequestSpecial';
+ if (isHostedServer) then {['SRVFNCREQUESTSPECIAL',["RespawnST",sideJoined]] Spawn HandleSPVF};
+ _lastUse = time;
+ };
+
+ //--- Minimap update.
+ if (MenuAction == 100) then {
+ MenuAction = -1;
+ _value = lbCurSel 23007;
+
+ if (_value != -1) then {
+ ctrlMapAnimClear _map;
+ _map ctrlMapAnimAdd [1,.175,getPos(_aliveWorkers select _value)];
+ ctrlMapAnimCommit _map;
+ };
+ };
+
+ //added-MrNiceGuy
+ if (mouseButtonUp == 0) then {
+ mouseButtonUp = -1;
+ //--- Sell Building.
+ if (MenuAction == 105) then {
+ MenuAction = -1;
+ _position = _map posScreenToWorld[mouseX,mouseY];
+ _structures = (sideJoinedText) Call GetSideStructures;
+ _existingStruct = [_position,_structures] Call SortByDistance;
+ if (count _existingStruct > 0) then {
+ _closest = _existingStruct select 0;
+ //--- 100 meters close only.
+ if (_closest distance _position < 100 && isNil {_closest getVariable "WFBE_SOLD"}) then {
+ //--- Spawn a sell thread.
+ (_closest) Spawn {
+ Private ["_closest","_delay","_id","_supplyB","_type"];
+ _closest = _this;
+ _closest setVariable ["WFBE_SOLD", true];
+ _delay = 'WFBE_BUILDINGSELLDELAY' Call GetNamespace;
+ _type = typeOf _closest;
+
+ //--- Inform the side (before).
+ WFBE_LocalizeMessage = [sideJoined,'CLTFNCLOCALIZEMESSAGE',['StructureSell',_type,_delay]];
+ publicVariable 'WFBE_LocalizeMessage';
+ ['StructureSell',_type,_delay] Spawn CLTFNCLocalizeMessage;
+
+ sleep _delay;
+
+ if !(alive _closest) exitWith {};
+
+ _id = (Format ["WFBE_%1STRUCTURENAMES",sideJoinedText] Call GetNamespace) find _type;
+
+ //--- TODO: Change the find system with a getvar system.
+ if (_id > 0) then {
+ _supplyB = (Format ["WFBE_%1STRUCTURECOSTS",sideJoinedText] Call GetNamespace) select _id;
+ _supplyB = round((_supplyB * ('WFBE_STRUCTURESELLPERCENT' Call GetNamespace)) / 100);
+
+ if !(paramMoneyOnly) then {[sideJoined, _supplyB] Call ChangeSideSupply} else {(_supplyB) Call ChangePlayerFunds};
+ };
+
+ //--- Inform the side.
+ WFBE_LocalizeMessage = [sideJoined,'CLTFNCLOCALIZEMESSAGE',['StructureSold',_type]];
+ publicVariable 'WFBE_LocalizeMessage';
+ ['StructureSold',_type] Spawn CLTFNCLocalizeMessage;
+ if (paramUseWorkers) then {_closest setVariable ["sold",true,true]};
+ _closest setDammage 1;
+ };
+ };
+ };
+ };
+ };
+
+ sleep 0.1;
+
+ //--- Back Button.
+ if (MenuAction == 5) exitWith { //---added-MrNiceGuy
+ MenuAction = -1;
+ closeDialog 0;
+ createDialog "WF_Menu";
+ };
+};
\ No newline at end of file |
