From c1b2d09d033225181cb8a28bd615ddf050aeb37a Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Wed, 28 Nov 2018 21:57:56 +0100 Subject: [PATCH 01/20] Move build confirm to separate method, handle unit direction --- .../04_build/fnc/fn_build_confirmAll.sqf | 64 +++++++++++++++++++ .../04_build/fnc/fn_build_displayLoad.sqf | 46 +------------ .../04_build/fnc/fn_build_loadData.sqf | 5 ++ .../modules/04_build/functions.hpp | 5 +- .../04_build/ui/KPLIB_buildDisplay.hpp | 4 +- 5 files changed, 76 insertions(+), 48 deletions(-) create mode 100644 Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf diff --git a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf new file mode 100644 index 000000000..1ea51ad5e --- /dev/null +++ b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf @@ -0,0 +1,64 @@ +#include "script_components.hpp" +/* + KPLIB_fnc_build_confirmAll + + File: fn_build_confirmAll.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2018-11-28 + Last Update: 2018-11-28 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + No description added yet. + + Parameter(s): + _localVariable - Description [DATATYPE, defaults to DEFAULTVALUE] + + Returns: + Function reached the end [BOOL] +*/ + + +private _validItems = LGVAR(buildQueue) select {_x getVariable ["KPLIB_validPos", true]}; +LSVAR("buildQueue", LGVAR(buildQueue) - _validItems); + +// TODO implement build queue handling (resource check etc.) +systemChat "buildConfirm: Resource check not implemented yet!"; +{ + private _dirAndUp = [vectorDir _x, vectorUp _x]; + private _pos = getPosATL _x; + private _class = typeOf _x; + + deleteVehicle _x; + + [[[_class, _pos, 0, true], _dirAndUp], { + params ["_createParams", "_vectorDirAndUp"]; + _createParams params ["_className", "_pos"]; + + private ["_obj"]; + + // TODO save only builings via Build module, units and vehicles should be moved to persistence module + switch true do { + case (_className isKindOf "Man"): { + _obj = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit; + _obj setPosATL _pos; + _obj setVectorDirAndUp _vectorDirAndUp; + + // Set watching direction + if (_obj isEqualTo formLeader _obj) then { + _obj setFormDir getDir _obj; + }; + + }; + + default { + _obj = _createParams call KPLIB_fnc_common_createVehicle; + _obj setVectorDirAndUp _vectorDirAndUp; + }; + }; + + + ["KPLIB_build_item_built", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_localEvent; + }] remoteExecCall ["call", 2]; + +} forEach _validItems; diff --git a/Missionframework/modules/04_build/fnc/fn_build_displayLoad.sqf b/Missionframework/modules/04_build/fnc/fn_build_displayLoad.sqf index 80ec08495..7fc4ca723 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_displayLoad.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_displayLoad.sqf @@ -6,7 +6,7 @@ File: fn_build_displayLoad.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-09-09 - Last Update: 2018-11-27 + Last Update: 2018-11-28 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -44,50 +44,6 @@ _itemsList ctrlAddEventHandler ["LBSelChanged", { ctrlSetFocus ((ctrlParent _control) displayCtrl _currentTabIDC); }]; -// Add build confirmation handler -private _confirmButton = _display displayCtrl KPLIB_IDC_BUILD_CONFIRM; -_confirmButton ctrlAddEventHandler ["buttonClick", { - - private _validItems = LGVAR(buildQueue) select {_x getVariable ["KPLIB_validPos", true]}; - LSVAR("buildQueue", LGVAR(buildQueue) - _validItems); - - // TODO implement build queue handling (resource check etc.) - systemChat "buildConfirm: Resource check not implemented yet!"; - { - private _dirAndUp = [vectorDir _x, vectorUp _x]; - private _pos = getPosATL _x; - private _class = typeOf _x; - - deleteVehicle _x; - - [[[_class, _pos, 0, true], _dirAndUp], { - params ["_createParams", "_vectorDirAndUp"]; - _createParams params ["_className", "_pos"]; - - private ["_obj"]; - - // TODO save only builings via Build module, units and vehicles should be moved to persistence module - // Confirmation handling must be moved to separate function - switch true do { - case (_className isKindOf "Man"): { - _obj = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit; - _obj setPosATL _pos; - _obj setVectorDirAndUp _vectorDirAndUp; - }; - - default { - _obj = _createParams call KPLIB_fnc_common_createVehicle; - _obj setVectorDirAndUp _vectorDirAndUp; - }; - }; - - - ["KPLIB_build_item_built", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_localEvent; - }] remoteExecCall ["call", 2]; - - } forEach _validItems; -}]; - // Add tab change handler { private _ctrl = _display displayCtrl _x; diff --git a/Missionframework/modules/04_build/fnc/fn_build_loadData.sqf b/Missionframework/modules/04_build/fnc/fn_build_loadData.sqf index b6c167a9c..aa220f72c 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_loadData.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_loadData.sqf @@ -55,6 +55,11 @@ if (_moduleData isEqualTo []) then { _object = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit; _object setPosWorld _posWorld; _object setVectorDirAndUp _vectorDirAndUp; + + // Set watching direction + if (_object isEqualTo formLeader _object) then { + _object setFormDir getDir _object; + }; }; default { diff --git a/Missionframework/modules/04_build/functions.hpp b/Missionframework/modules/04_build/functions.hpp index f539e6307..6902e71b1 100644 --- a/Missionframework/modules/04_build/functions.hpp +++ b/Missionframework/modules/04_build/functions.hpp @@ -4,7 +4,7 @@ File: functions.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-07-01 - Last Update: 2018-11-12 + Last Update: 2018-11-28 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -26,6 +26,9 @@ class build { // Creates the build camera class build_camCreate {}; + // Confirms all items in queue + class build_confirmAll {}; + // Display initialization class build_displayLoad {}; diff --git a/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp b/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp index ed042af58..d04f78a11 100644 --- a/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp +++ b/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp @@ -4,7 +4,7 @@ File: KPLIB_defines.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-07-01 - Last Update: 2018-11-27 + Last Update: 2018-11-28 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -125,7 +125,7 @@ class KPLIB_build { text = "$STR_KPLIB_DIALOG_BUTTON_BUILD"; w = KP_GETWPLAIN(KP_WIDTH_VAL_LP,1); - onButtonClick = "['build', _this] call KPLIB_fnc_build_displayScript"; + onButtonClick = "_this call KPLIB_fnc_build_confirmAll"; }; class KPLIB_DialogCross: KPGUI_PRE_DialogCross_LeftPanel { From b81768be2d74e426054e64e59f597c22fc74a3e1 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Wed, 28 Nov 2018 22:05:09 +0100 Subject: [PATCH 02/20] Global KPLIB_build_item_built event, initialize handlers where needed --- .../04_build/fnc/fn_build_confirmAll.sqf | 2 +- .../modules/04_build/fnc/fn_build_preInit.sqf | 34 +++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf index 1ea51ad5e..887abd563 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf @@ -58,7 +58,7 @@ systemChat "buildConfirm: Resource check not implemented yet!"; }; - ["KPLIB_build_item_built", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_localEvent; + ["KPLIB_build_item_built", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_globalEvent; }] remoteExecCall ["call", 2]; } forEach _validItems; diff --git a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf index 3b20303fc..5a17af959 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf @@ -4,7 +4,7 @@ File: fn_build_preInit.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-18 - Last Update: 2018-11-12 + Last Update: 2018-11-28 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -34,26 +34,30 @@ KPLIB_build_ticker = -1; // Save data KPLIB_build_saveNamespace = locationNull; -// Register build item movement handler -["KPLIB_build_item_moved", KPLIB_fnc_build_validatePosition] call CBA_fnc_addEventHandler; +if (isServer) then { + // Register load event handler + ["KPLIB_doLoad", {[] call KPLIB_fnc_build_loadData}] call CBA_fnc_addEventHandler; -// Register load event handler -["KPLIB_doLoad", {[] call KPLIB_fnc_build_loadData}] call CBA_fnc_addEventHandler; + // Register save event handler + ["KPLIB_doSave", {[] call KPLIB_fnc_build_saveData}] call CBA_fnc_addEventHandler; -// Register save event handler -["KPLIB_doSave", {[] call KPLIB_fnc_build_saveData}] call CBA_fnc_addEventHandler; + ["KPLIB_build_item_built", { + params ["_object", "_fob"]; -["KPLIB_build_item_built", { - params ["_object", "_fob"]; + // If fob has no save data, initialize it + if (isNil {KPLIB_build_saveNamespace getVariable _fob}) then { + KPLIB_build_saveNamespace setVariable [_fob, [], true]; + }; - // If fob has no save data, initialize it - if (isNil {KPLIB_build_saveNamespace getVariable _fob}) then { - KPLIB_build_saveNamespace setVariable [_fob, []]; - }; + (KPLIB_build_saveNamespace getVariable _fob) pushBackUnique _object; - (KPLIB_build_saveNamespace getVariable _fob) pushBackUnique _object; + }] call CBA_fnc_addEventHandler; +}; -}] call CBA_fnc_addEventHandler; +if (hasInterface) then { + // Register build item movement handler + ["KPLIB_build_item_moved", KPLIB_fnc_build_validatePosition] call CBA_fnc_addEventHandler; +}; if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [BUILD] Module initialized", diag_tickTime];}; From c9d7d9cc9057f83576b0a04c6de480d57946e11b Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Wed, 28 Nov 2018 22:13:48 +0100 Subject: [PATCH 03/20] Stop build on death --- Missionframework/modules/04_build/fnc/fn_build_preInit.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf index 5a17af959..b6dbe1422 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf @@ -57,6 +57,8 @@ if (isServer) then { if (hasInterface) then { // Register build item movement handler ["KPLIB_build_item_moved", KPLIB_fnc_build_validatePosition] call CBA_fnc_addEventHandler; + + player addEventHandler ["Killed", KPLIB_fnc_build_stop]; }; if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [BUILD] Module initialized", diag_tickTime];}; From 3983c5f4b4057db1810c89a69a9e977848cc10f4 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Wed, 28 Nov 2018 23:58:48 +0100 Subject: [PATCH 04/20] Add IDC to build background --- Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp | 4 +++- Missionframework/modules/04_build/ui/defines.hpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp b/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp index d04f78a11..a456f2f3e 100644 --- a/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp +++ b/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp @@ -42,7 +42,9 @@ class KPLIB_build { text = "$STR_KPLIB_DIALOG_BUILD_TITLE"; }; - class KP_DialogArea: KPGUI_PRE_DialogBackground_LeftPanel {}; + class KP_DialogArea: KPGUI_PRE_DialogBackground_LeftPanel { + idc = KPLIB_IDC_BUILD_DIALOG_AREA; + }; }; diff --git a/Missionframework/modules/04_build/ui/defines.hpp b/Missionframework/modules/04_build/ui/defines.hpp index 1b54191b8..45e9d3a3a 100644 --- a/Missionframework/modules/04_build/ui/defines.hpp +++ b/Missionframework/modules/04_build/ui/defines.hpp @@ -4,7 +4,7 @@ File: defines.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-07-01 - Last Update: 2018-11-09 + Last Update: 2018-11-28 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -29,5 +29,7 @@ #define KPLIB_IDC_BUILD_CONFIRM 70301 +#define KPLIB_IDC_BUILD_DIALOG_AREA 70401 + // All tabs IDCs #define KPLIB_BUILD_TABS_IDCS_ARRAY [70100,70101,70102,70103,70104,70105,70106,70107] From 2a683c86c9abe3a4f0373868350f71bd97159738 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Wed, 28 Nov 2018 23:59:40 +0100 Subject: [PATCH 05/20] Add KPLIB_build_item_built_local event --- Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf index 887abd563..b71a505be 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf @@ -59,6 +59,7 @@ systemChat "buildConfirm: Resource check not implemented yet!"; ["KPLIB_build_item_built", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_globalEvent; + ["KPLIB_build_item_built_local", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_localEvent; }] remoteExecCall ["call", 2]; } forEach _validItems; From f6d35defa45443d3e56c1c505f413ba799770297 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 00:00:06 +0100 Subject: [PATCH 06/20] Single item building initial implementation --- .../modules/04_build/fnc/fn_build_preInit.sqf | 1 + .../04_build/fnc/fn_build_start_single.sqf | 81 +++++++++++++++++++ .../modules/04_build/functions.hpp | 3 + 3 files changed, 85 insertions(+) create mode 100644 Missionframework/modules/04_build/fnc/fn_build_start_single.sqf diff --git a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf index b6dbe1422..c7c496aa7 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf @@ -43,6 +43,7 @@ if (isServer) then { ["KPLIB_build_item_built", { params ["_object", "_fob"]; + if (_fob isEqualTo "") exitWith {}; // If fob has no save data, initialize it if (isNil {KPLIB_build_saveNamespace getVariable _fob}) then { diff --git a/Missionframework/modules/04_build/fnc/fn_build_start_single.sqf b/Missionframework/modules/04_build/fnc/fn_build_start_single.sqf new file mode 100644 index 000000000..250be4cb9 --- /dev/null +++ b/Missionframework/modules/04_build/fnc/fn_build_start_single.sqf @@ -0,0 +1,81 @@ + +#include "script_components.hpp" +#include "..\ui\defines.hpp" +/* + KPLIB_fnc_build_start_single + + File: fn_build_start_single.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2018-09-09 + Last Update: 2018-11-28 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Starts KP Liberation building mode + + Parameter(s): + _center - Center of building area [POSITION, defaults to position player] + _radius - Allowed building radius [NUMBER, defaults to KPLIB_param_fobRange] + + Returns: + Building logic object [LOCATION] +*/ + +params [ + ["_center", position player, [[]], 3], + ["_radius", (35 max KPLIB_param_fobRange/2), [0]], + ["_buildItem", [], [[]], 4], + ["_onConfirm", {}, [{}]] +]; + +if !(_buildItem isEqualTypeParams ["", 0, 0, 0]) exitWith { + diag_log format ["[KP LIBERATION] [%1] [BUILD] Incorrect build item passed to build_start_single '%2'!", diag_tickTime, _buildItem] +}; + + +private _openEhId = ["KPLIB_build_display_open", { + params ["_display"]; + + private _confirmCtrl = (_display displayCtrl KPLIB_IDC_BUILD_CONFIRM); + + // Get pos of build mode selector + private _confirmCtrlNewPos = (ctrlPosition (_display displayCtrl KPLIB_IDC_BUILD_TAB_INFANTRY)); + // Save only X, Y + _confirmCtrlNewPos resize 2; + // Get original W, H + _confirmCtrlNewPos append ((ctrlPosition _confirmCtrl) select [2, 2]); + // Set the position with original W, H + _confirmCtrl ctrlSetPosition _confirmCtrlNewPos; + _confirmCtrl ctrlCommit 0; + + // Hide tabs, build list and background + { + (_display displayCtrl _x) ctrlShow false; + } forEach KPLIB_BUILD_TABS_IDCS_ARRAY + [KPLIB_IDC_BUILD_ITEM_LIST, KPLIB_IDC_BUILD_DIALOG_AREA]; + + LSVAR("buildItem", _thisArgs); + +}, _buildItem] call CBA_fnc_addEventHandlerArgs; + + +// Handle item placement +private _builtEhId = ["KPLIB_build_item_built_local", { + _this call _thisArgs; + [] call KPLIB_fnc_build_stop; +}, _onConfirm] call CBA_fnc_addEventHandlerArgs; + + +// Stop all single build event handlers +["KPLIB_build_stop", { + [_thisType, _thisId] call CBA_fnc_removeEventHandler; + + _thisArgs params ["_openEhId", "_builtEhId"]; + + ["KPLIB_build_display_open", _openEhId] call CBA_fnc_removeEventHandler; + ["KPLIB_build_item_built_local", _builtEhId] call CBA_fnc_removeEventHandler; + +}, [_openEhId, _builtEhId]] call CBA_fnc_addEventHandlerArgs; + + +// Start build mode +[_center, _radius] call KPLIB_fnc_build_start diff --git a/Missionframework/modules/04_build/functions.hpp b/Missionframework/modules/04_build/functions.hpp index 6902e71b1..ee80ce55d 100644 --- a/Missionframework/modules/04_build/functions.hpp +++ b/Missionframework/modules/04_build/functions.hpp @@ -93,6 +93,9 @@ class build { // Start building logic class build_start {}; + // Start building logic for single item build + class build_start_single {}; + // Stop building logic class build_stop {}; From bea0061f80468450bdecbac575372a3cf654635f Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 00:33:28 +0100 Subject: [PATCH 07/20] Simplify build FOB --- .../modules/02_core/fnc/fn_core_buildFob.sqf | 44 +++++-------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/Missionframework/modules/02_core/fnc/fn_core_buildFob.sqf b/Missionframework/modules/02_core/fnc/fn_core_buildFob.sqf index cfd6a5087..aa6da0126 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_buildFob.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_buildFob.sqf @@ -4,50 +4,28 @@ File: fn_core_buildFob.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-05-11 - Last Update: 2018-11-09 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: - Builds FOB on given position. + Creates FOB on given position. Parameter(s): - _position - Object or position where FOB has to be built [OBJECT/ARRAY, defaults to []] - _player - Player that initiated building. Mandatory for interactive build [OBJECT, defaults to objNull] - _interactive - Should FOB be built interactively for player [BOOL, defaults to false] + _buildPos - Object or position where FOB has to be built [ARRAY, defaults to []] Returns: - Spawned vehicle [OBJECT] + Fob marker [STRING] */ params [ - ["_position", [], [[], objNull]], - ["_player", objNull, [objNull]], - ["_interactive", false, [false]] + ["_buildPos", [], [[]]] ]; -// Get position of build area -private _buildPos = _position; -// If our position is an object we will save it for later deletion -private _box = objNull; - -// If position is object, get position of object -if(typeName _buildPos == typeName objNull) then { - _box = _buildPos; - _buildPos = getPosATL _box; -}; - -// Build FOB -if (_interactive) then { - // TODO we should allow for manual placement of FOB building in interative mode here later - deleteVehicle _box; - private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker; - KPLIB_sectors_fobs pushBack _marker; - ["KPLIB_fob_built", [_marker]] call CBA_fnc_localEvent; -} else { - private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker; - KPLIB_sectors_fobs pushBack _marker; - ["KPLIB_fob_built", [_marker]] call CBA_fnc_localEvent; -}; +private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker; +KPLIB_sectors_fobs pushBack _marker; +["KPLIB_fob_built", [_marker]] call CBA_fnc_globalEvent; publicVariable "KPLIB_sectors_fobs"; -call KPLIB_fnc_core_updateFobMarkers; +[] call KPLIB_fnc_core_updateFobMarkers; + +_marker From 03030d142ca831e8a044f5e179c6a0b2777a147a Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 00:43:49 +0100 Subject: [PATCH 08/20] Refactor core_getNearestSector into core_getNearestMarker --- Missionframework/modules/02_core/README.md | 2 +- .../02_core/fnc/fn_core_canBuildFob.sqf | 4 +-- .../02_core/fnc/fn_core_getNearestMarker.sqf | 36 +++++++++++++++++++ .../02_core/fnc/fn_core_getNearestSector.sqf | 31 ---------------- .../modules/02_core/fnc/fn_core_spawnCam.sqf | 4 +-- .../modules/02_core/functions.hpp | 6 ++-- 6 files changed, 44 insertions(+), 39 deletions(-) create mode 100644 Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf delete mode 100644 Missionframework/modules/02_core/fnc/fn_core_getNearestSector.sqf diff --git a/Missionframework/modules/02_core/README.md b/Missionframework/modules/02_core/README.md index d43248886..a95763e5d 100644 --- a/Missionframework/modules/02_core/README.md +++ b/Missionframework/modules/02_core/README.md @@ -38,7 +38,7 @@ So this is the core gameplay where all other modules are inject their functional *Get all mobile respawn vehicles.* -* KPLIB_fnc_core_getNearestSector +* KPLIB_fnc_core_getNearestMarker *Get the nearest capturable sector.* diff --git a/Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf b/Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf index c445a21da..eab5435a6 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf @@ -4,7 +4,7 @@ File: fn_core_canBuildFob.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-05-11 - Last Update: 2018-11-09 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -28,5 +28,5 @@ private _minSectorDist = KPLIB_param_fobRange + KPLIB_param_sectorCapRange; (alive _box && _box distance2D KPLIB_eden_startbase > 300 -&& ([_minSectorDist, getPos _box] call KPLIB_fnc_core_getNearestSector == "")) +&& ([_minSectorDist, getPos _box, KPLIB_sectors_all + KPLIB_sectors_fobs] call KPLIB_fnc_core_getNearestMarker isEqualTo "")) diff --git a/Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf b/Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf new file mode 100644 index 000000000..260ed4a37 --- /dev/null +++ b/Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf @@ -0,0 +1,36 @@ +/* + KPLIB_fnc_core_getNearestMarker + + File: fn_core_getNearestMarker.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2017-11-26 + Last Update: 2018-11-29 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Get the nearest marker from given array within range of position. + + Parameter(s): + _range - Range to search for sectors [NUMBER, defaults to 0] + _centerPos - Center position from where to start searching for markers [POSITION, defaults to getPos player] + _markers - Array of markers to check [ARRAY, defaults to KPLIB_sectors_all] + + Returns: + Nearest marker [STRING] +*/ + +params [ + ["_range", 0, [0]], + ["_centerPos", getPos player, [[]], 3], + ["_markers", KPLIB_sectors_all, [[]]] +]; + + +private _markersWithinRange = _markers select {((markerPos _x) distance _centerPos) < _range}; +private _markersAscByRange = [_markersWithinRange, [_centerPos], {(markerPos _x) distance _input0}, "ASCEND"] call BIS_fnc_sortBy; +// Return nearest marker +if !(_markersAscByRange isEqualTo []) then { + _markersAscByRange select 0; +} else { + "" +} diff --git a/Missionframework/modules/02_core/fnc/fn_core_getNearestSector.sqf b/Missionframework/modules/02_core/fnc/fn_core_getNearestSector.sqf deleted file mode 100644 index 7f6d488a6..000000000 --- a/Missionframework/modules/02_core/fnc/fn_core_getNearestSector.sqf +++ /dev/null @@ -1,31 +0,0 @@ -/* - KPLIB_fnc_core_getNearestSector - - File: fn_core_getNearestSector.sqf - Author: KP Liberation Dev Team - https://github.com/KillahPotatoes - Date: 2017-11-26 - Last Update: 2018-11-09 - License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html - - Description: - Get the nearest capturable sector from the given position inside the given range. - - Parameter(s): - _range - Range to search for sectors [NUMBER, defaults to 0] - _centerPos - Center position from where to start searching for sectors [POSITION, defaults to getPos player] - - Returns: - Nearest capturable sector [STRING] -*/ - -params [ - ["_range", 0, [0]], - ["_centerPos", getPos player, [[]], 3] -]; - -private _return = ""; -private _foundSectors = KPLIB_sectors_all select {((markerPos _x) distance _centerPos) < _range}; -private _sortedSectors = [_foundSectors, [_centerPos], {(markerPos _x) distance _input0}, "ASCEND"] call BIS_fnc_sortBy; -if !(_sortedSectors isEqualTo []) then {_return = _sortedSectors select 0;}; - -_return diff --git a/Missionframework/modules/02_core/fnc/fn_core_spawnCam.sqf b/Missionframework/modules/02_core/fnc/fn_core_spawnCam.sqf index a7ec782a6..ebaa99871 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_spawnCam.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_spawnCam.sqf @@ -4,7 +4,7 @@ File: fn_core_spawnCam.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2017-11-26 - Last Update: 2018-11-12 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -22,7 +22,7 @@ params [ ]; // Get the nearest sector from the current position for the spawn text display -private _nearestSector = [2000] call KPLIB_fnc_core_getNearestSector; +private _nearestSector = [2000] call KPLIB_fnc_core_getNearestMarker; if (_nearestSector != "") then {_nearestSector = format ["%1 %2", localize "STR_KPLIB_NEAR", markertext _nearestSector];}; // Get the current time for the spawn text display diff --git a/Missionframework/modules/02_core/functions.hpp b/Missionframework/modules/02_core/functions.hpp index eab610613..b48513e53 100644 --- a/Missionframework/modules/02_core/functions.hpp +++ b/Missionframework/modules/02_core/functions.hpp @@ -4,7 +4,7 @@ File: functions.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2017-10-28 - Last Update: 2018-11-27 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -35,8 +35,8 @@ class core { // Get all mobile respawn vehicles class core_getMobSpawns {}; - // Get the nearest capturable sector - class core_getNearestSector {}; + // Get the nearest marker from array of markers + class core_getNearestMarker {}; // Handle an activated sector class core_handleSector {}; From 392c59e29463169e8e995bed6ce9048277167d02 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 00:44:10 +0100 Subject: [PATCH 09/20] Fix public variable on location type --- Missionframework/modules/04_build/fnc/fn_build_preInit.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf index c7c496aa7..a476374e6 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf @@ -4,7 +4,7 @@ File: fn_build_preInit.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-18 - Last Update: 2018-11-28 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -47,7 +47,7 @@ if (isServer) then { // If fob has no save data, initialize it if (isNil {KPLIB_build_saveNamespace getVariable _fob}) then { - KPLIB_build_saveNamespace setVariable [_fob, [], true]; + KPLIB_build_saveNamespace setVariable [_fob, []]; }; (KPLIB_build_saveNamespace getVariable _fob) pushBackUnique _object; From 18d6035b5d05f57f9e86dc33c8a11d43a58d3770 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 00:45:18 +0100 Subject: [PATCH 10/20] Core vehicle handlers should be added in preInit --- Missionframework/modules/02_core/fnc/fn_core_preInit.sqf | 6 +++++- .../modules/02_core/fnc/fn_core_setupPlayerActions.sqf | 8 +------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Missionframework/modules/02_core/fnc/fn_core_preInit.sqf b/Missionframework/modules/02_core/fnc/fn_core_preInit.sqf index f5fc3698e..f40c32c47 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_preInit.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_preInit.sqf @@ -4,7 +4,7 @@ File: fn_core_preInit.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-18 - Last Update: 2018-11-27 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -22,6 +22,10 @@ if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [CORE] Module i // Process CBA Settings [] call KPLIB_fnc_core_settings; +if (isServer) then { + ["KPLIB_vehicle_spawned", KPLIB_fnc_core_handleVehicleSpawn] call CBA_fnc_addEventHandler; +}; + /* ----- Module Globals ----- */ diff --git a/Missionframework/modules/02_core/fnc/fn_core_setupPlayerActions.sqf b/Missionframework/modules/02_core/fnc/fn_core_setupPlayerActions.sqf index 16a4e6adc..c3d59f8f1 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_setupPlayerActions.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_setupPlayerActions.sqf @@ -4,7 +4,7 @@ File: fn_common_setupPlayerActions.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-05-28 - Last Update: 2018-11-12 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -17,12 +17,6 @@ Function reached the end [BOOL] */ -// Actions avalible GLOBALLY on objects -if (isServer) then { - // Add actions to supported vehicles - ["KPLIB_vehicle_spawned", KPLIB_fnc_core_handleVehicleSpawn] call CBA_fnc_addEventHandler; -}; - // Actions avalible LOCALLY to player if(hasInterface) then { // FOB redeploy action From a2ce5bc56ec7e242a1e5eac71811636d84f5f1f4 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 00:46:05 +0100 Subject: [PATCH 11/20] Register build module as FOB building provider --- .../02_core/fnc/fn_core_handleVehicleSpawn.sqf | 4 ++-- .../modules/04_build/fnc/fn_build_preInit.sqf | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Missionframework/modules/02_core/fnc/fn_core_handleVehicleSpawn.sqf b/Missionframework/modules/02_core/fnc/fn_core_handleVehicleSpawn.sqf index a46a1ae61..487eb4153 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_handleVehicleSpawn.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_handleVehicleSpawn.sqf @@ -4,7 +4,7 @@ File: fn_core_handleVehicleSpawn.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-09-10 - Last Update: 2018-11-12 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -27,7 +27,7 @@ switch(typeOf _vehicle) do { // Add FOB build action globaly and for JIP [ _vehicle, - [localize "STR_KPLIB_ACTION_DEPLOY", {[param [0], param [1], param[3]] call KPLIB_fnc_core_buildFob}, true, -800, false, true, "", "[_target, _this] call KPLIB_fnc_core_canBuildFob", 10] + [localize "STR_KPLIB_ACTION_DEPLOY", {["KPLIB_fob_build_requested", _this select 0] call CBA_fnc_localEvent}, true, -800, false, true, "", "[_target, _this] call KPLIB_fnc_core_canBuildFob", 10] ] remoteExecCall ["addAction", 0, true]; }; diff --git a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf index a476374e6..c57e3eb12 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf @@ -59,6 +59,22 @@ if (hasInterface) then { // Register build item movement handler ["KPLIB_build_item_moved", KPLIB_fnc_build_validatePosition] call CBA_fnc_addEventHandler; + // Register Build module as FOB building provider + ["KPLIB_fob_build_requested", { + params ["_object"]; + + [getPos _object, nil, [KPLIB_preset_fobBuilding, 0,0,0], { + params ["_builtObject"]; + // Build FOB when item placed + private _fobName = [getPos _builtObject] call KPLIB_fnc_core_buildFob; + // Emit the built event with FOB and object to assign the object to FOB + ["KPLIB_build_item_built", [_builtObject, _fobName]] call CBA_fnc_globalEvent; + // Remove object + deleteVehicle _builtObject; + }] call KPLIB_fnc_build_start_single; + + }] call CBA_fnc_addEventHandler; + player addEventHandler ["Killed", KPLIB_fnc_build_stop]; }; From 9e4ec7ebb06f88ca2645bcebcc9460aa322aca84 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 00:52:59 +0100 Subject: [PATCH 12/20] Consume FOB container/truck instead of deleting freshly built FOB house --- Missionframework/modules/02_core/README.md | 2 +- Missionframework/modules/04_build/fnc/fn_build_preInit.sqf | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Missionframework/modules/02_core/README.md b/Missionframework/modules/02_core/README.md index a95763e5d..71f8ae3d9 100644 --- a/Missionframework/modules/02_core/README.md +++ b/Missionframework/modules/02_core/README.md @@ -40,7 +40,7 @@ So this is the core gameplay where all other modules are inject their functional * KPLIB_fnc_core_getNearestMarker - *Get the nearest capturable sector.* + *Get the marker from array of markers.* * KPLIB_fnc_core_handleSector diff --git a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf index c57e3eb12..3b7ec97da 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf @@ -34,6 +34,9 @@ KPLIB_build_ticker = -1; // Save data KPLIB_build_saveNamespace = locationNull; +// Object from which FOB build event originated +KPLIB_build_fobBuildObject = objNull; + if (isServer) then { // Register load event handler ["KPLIB_doLoad", {[] call KPLIB_fnc_build_loadData}] call CBA_fnc_addEventHandler; @@ -62,6 +65,7 @@ if (hasInterface) then { // Register Build module as FOB building provider ["KPLIB_fob_build_requested", { params ["_object"]; + KPLIB_build_fobBuildObject = _object; [getPos _object, nil, [KPLIB_preset_fobBuilding, 0,0,0], { params ["_builtObject"]; @@ -70,7 +74,7 @@ if (hasInterface) then { // Emit the built event with FOB and object to assign the object to FOB ["KPLIB_build_item_built", [_builtObject, _fobName]] call CBA_fnc_globalEvent; // Remove object - deleteVehicle _builtObject; + deleteVehicle KPLIB_build_fobBuildObject; }] call KPLIB_fnc_build_start_single; }] call CBA_fnc_addEventHandler; From cd054c46c23441e93a9e5eb967814c957651b5c0 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 01:13:38 +0100 Subject: [PATCH 13/20] Improve build list height config --- Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp b/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp index a456f2f3e..5368f984f 100644 --- a/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp +++ b/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp @@ -115,7 +115,7 @@ class KPLIB_build { x = KP_GETCX(KP_X_VAL_LP,KP_WIDTH_VAL_LP,0,1); y = KP_GETCY(KP_Y_VAL_LP,KP_HEIGHT_VAL_LP,2,20); w = KP_GETW(KP_WIDTH_VAL_LP,1); - h = KP_GETH(KP_HEIGHT_VAL_LP,20) * 19.55; + h = KP_GETH(KP_HEIGHT_VAL_LP,(20/18)); columns[] = { 0, 0.65, 0.75, 0.85 }; From 0585949b6dac03da5c24dfd97dff5783cc94461d Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 02:53:29 +0100 Subject: [PATCH 14/20] Add toolbox to build display, toolbox queue mode change button --- .../04_build/fnc/fn_build_changeQueueMode.sqf | 48 +++++++++++++++++++ .../04_build/fnc/fn_build_start_single.sqf | 6 +-- .../modules/04_build/functions.hpp | 5 +- .../04_build/ui/KPLIB_buildDisplay.hpp | 38 ++++++++++++++- .../modules/04_build/ui/defines.hpp | 4 +- 5 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 Missionframework/modules/04_build/fnc/fn_build_changeQueueMode.sqf diff --git a/Missionframework/modules/04_build/fnc/fn_build_changeQueueMode.sqf b/Missionframework/modules/04_build/fnc/fn_build_changeQueueMode.sqf new file mode 100644 index 000000000..891da8134 --- /dev/null +++ b/Missionframework/modules/04_build/fnc/fn_build_changeQueueMode.sqf @@ -0,0 +1,48 @@ +#include "script_components.hpp" +#include "..\ui\defines.hpp" +/* + KPLIB_fnc_build_changeQueueMode + + File: fn_build_changeQueueMode.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2018-11-29 + Last Update: 2018-11-29 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Changes build system queue mode. + + Parameter(s): + _control - Clicked control [CONTROL, defaults to controlNull] + + Returns: + Queue mode was changed [BOOL] +*/ +params [ + ["_control", controlNull, [controlNull]] +]; + +private _display = ctrlParent _control; +private _confirmBtnControl = _display displayCtrl KPLIB_IDC_BUILD_CONFIRM; + +// TODO preserve and restore current build queue +switch (_control getVariable ["KPLIB_mode", 0]) do { + case 0: { + _control ctrlSetText "Move mode"; + _control setVariable ["KPLIB_mode", 1]; + _confirmBtnControl ctrlEnable false; + + private _currentItems = KPLIB_build_saveNamespace getVariable [player getVariable "KPLIB_fob", []]; + LSVAR("buildQueue", _currentItems); + }; + + case 1: { + _control ctrlSetText "Build mode"; + _control setVariable ["KPLIB_mode", 0]; + _confirmBtnControl ctrlEnable true; + + LSVAR("buildQueue", []); + }; +}; + +true diff --git a/Missionframework/modules/04_build/fnc/fn_build_start_single.sqf b/Missionframework/modules/04_build/fnc/fn_build_start_single.sqf index 250be4cb9..1ff64b70f 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_start_single.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_start_single.sqf @@ -7,7 +7,7 @@ File: fn_build_start_single.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-09-09 - Last Update: 2018-11-28 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -39,7 +39,7 @@ private _openEhId = ["KPLIB_build_display_open", { private _confirmCtrl = (_display displayCtrl KPLIB_IDC_BUILD_CONFIRM); // Get pos of build mode selector - private _confirmCtrlNewPos = (ctrlPosition (_display displayCtrl KPLIB_IDC_BUILD_TAB_INFANTRY)); + private _confirmCtrlNewPos = (ctrlPosition ctrlParentControlsGroup (_display displayCtrl KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS)); // Save only X, Y _confirmCtrlNewPos resize 2; // Get original W, H @@ -51,7 +51,7 @@ private _openEhId = ["KPLIB_build_display_open", { // Hide tabs, build list and background { (_display displayCtrl _x) ctrlShow false; - } forEach KPLIB_BUILD_TABS_IDCS_ARRAY + [KPLIB_IDC_BUILD_ITEM_LIST, KPLIB_IDC_BUILD_DIALOG_AREA]; + } forEach KPLIB_BUILD_TABS_IDCS_ARRAY + [KPLIB_IDC_BUILD_ITEM_LIST, KPLIB_IDC_BUILD_DIALOG_AREA, KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS]; LSVAR("buildItem", _thisArgs); diff --git a/Missionframework/modules/04_build/functions.hpp b/Missionframework/modules/04_build/functions.hpp index ee80ce55d..3dda240f2 100644 --- a/Missionframework/modules/04_build/functions.hpp +++ b/Missionframework/modules/04_build/functions.hpp @@ -4,7 +4,7 @@ File: functions.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-07-01 - Last Update: 2018-11-28 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -26,6 +26,9 @@ class build { // Creates the build camera class build_camCreate {}; + // Change queue mode between moving existing items and placing new + class build_changeQueueMode {}; + // Confirms all items in queue class build_confirmAll {}; diff --git a/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp b/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp index 5368f984f..49ef9aeca 100644 --- a/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp +++ b/Missionframework/modules/04_build/ui/KPLIB_buildDisplay.hpp @@ -4,7 +4,7 @@ File: KPLIB_defines.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-07-01 - Last Update: 2018-11-28 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -122,6 +122,42 @@ class KPLIB_build { onMouseZChanged = "['onMouseZChanged_BuildList', _this] call KPLIB_fnc_build_handleMouse"; }; + class KPLIB_ToolboxContainer: KPGUI_PRE_ControlsGroup { + class VScrollbar: KPGUI_PRE_ScrollBar { + width = 0; + }; + class HScrollbar: KPGUI_PRE_ScrollBar { + color[] = {1, 1, 1, 0.5}; + height = 0.02; + }; + + x = KP_GETCX(KP_X_VAL_LP,KP_WIDTH_VAL_LP,0,1); + y = KP_GETCY(KP_Y_VAL_LP,KP_HEIGHT_VAL_LP,0,20); + w = KP_GETW(KP_WIDTH_VAL_LP,1); + h = KP_GETH(KP_HEIGHT_VAL_LP,20); + + // Toolbox Controls + class Controls { + // TODO move toolbox items creation to script + class KPLIB_Toolbox_MoveItems: KPGUI_PRE_ActiveText { + text = "Build mode"; + idc = KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS; + + colorActive[] = {1, 1, 1, 1}; + colorText[] = {1, 1, 1, 0.75}; + colorDisabled[] = {1, 1, 1, 0.25}; + color[] = {1, 1, 1, 0.55}; + + x = 0; + y = 0; + w = KP_GETW(KP_WIDTH_VAL_LP,4); + h = KP_GETH(KP_HEIGHT_VAL_LP,20) - 0.02; + + onButtonClick = "_this call KPLIB_fnc_build_changeQueueMode" + }; + }; + }; + class KP_ApplyButton: KPGUI_PRE_DialogButton_LeftPanel { idc = KPLIB_IDC_BUILD_CONFIRM; text = "$STR_KPLIB_DIALOG_BUTTON_BUILD"; diff --git a/Missionframework/modules/04_build/ui/defines.hpp b/Missionframework/modules/04_build/ui/defines.hpp index 45e9d3a3a..b28ce5d33 100644 --- a/Missionframework/modules/04_build/ui/defines.hpp +++ b/Missionframework/modules/04_build/ui/defines.hpp @@ -4,7 +4,7 @@ File: defines.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-07-01 - Last Update: 2018-11-28 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -25,6 +25,8 @@ #define KPLIB_IDC_BUILD_TAB_SUPPORT 70106 #define KPLIB_IDC_BUILD_TAB_SQUAD 70107 +#define KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS 70111 + #define KPLIB_IDC_BUILD_ITEM_LIST 70202 #define KPLIB_IDC_BUILD_CONFIRM 70301 From 3bdee6870dec69484c56729c12b00f307da31783 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 03:25:20 +0100 Subject: [PATCH 15/20] Add build_confirmSingle, fix local event being fired on server --- .../04_build/fnc/fn_build_confirmAll.sqf | 33 +----------- .../04_build/fnc/fn_build_confirmSingle.sqf | 52 +++++++++++++++++++ .../modules/04_build/functions.hpp | 3 ++ 3 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf diff --git a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf index b71a505be..f57e09c8a 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf @@ -5,7 +5,7 @@ File: fn_build_confirmAll.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-11-28 - Last Update: 2018-11-28 + Last Update: 2018-11-29 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -31,35 +31,6 @@ systemChat "buildConfirm: Resource check not implemented yet!"; deleteVehicle _x; - [[[_class, _pos, 0, true], _dirAndUp], { - params ["_createParams", "_vectorDirAndUp"]; - _createParams params ["_className", "_pos"]; - - private ["_obj"]; - - // TODO save only builings via Build module, units and vehicles should be moved to persistence module - switch true do { - case (_className isKindOf "Man"): { - _obj = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit; - _obj setPosATL _pos; - _obj setVectorDirAndUp _vectorDirAndUp; - - // Set watching direction - if (_obj isEqualTo formLeader _obj) then { - _obj setFormDir getDir _obj; - }; - - }; - - default { - _obj = _createParams call KPLIB_fnc_common_createVehicle; - _obj setVectorDirAndUp _vectorDirAndUp; - }; - }; - - - ["KPLIB_build_item_built", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_globalEvent; - ["KPLIB_build_item_built_local", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_localEvent; - }] remoteExecCall ["call", 2]; + [[[_class, _pos, 0, true], _dirAndUp, player]] remoteExecCall ["KPLIB_fnc_build_confirmSingle", 2]; } forEach _validItems; diff --git a/Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf b/Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf new file mode 100644 index 000000000..6c3d16f73 --- /dev/null +++ b/Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf @@ -0,0 +1,52 @@ +/* + KPLIB_fnc_build_confirmSingle + + File: fn_build_confirmSingle.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2018-11-29 + Last Update: 2018-11-29 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Confirms single item from build queue. + + Parameter(s): + _createParams - Parameters for common_createVehicle [ARRAY, defaults to nil] + _vectorDirAndUp - Vector dir and up for created object [ARRAY, defaults to nil] + _player - Player that initiated the building of object + + Returns: + Function reached the end [BOOL] +*/ +params [ + "_createParams", + "_vectorDirAndUp", + "_player" +]; +_createParams params ["_className", "_pos", "_dir", "_justBuild"]; + +private ["_obj"]; + +// TODO save only builings via Build module, units and vehicles should be moved to persistence module +switch true do { + case (_className isKindOf "Man"): { + _obj = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit; + _obj setPosATL _pos; + _obj setVectorDirAndUp _vectorDirAndUp; + + // Set watching direction + if (_obj isEqualTo formLeader _obj) then { + _obj setFormDir getDir _obj; + }; + }; + + default { + _obj = _createParams call KPLIB_fnc_common_createVehicle; + _obj setVectorDirAndUp _vectorDirAndUp; + }; +}; + +private _fob = _player getVariable ["KPLIB_fob", ""]; + +["KPLIB_build_item_built", [_obj, _fob] call CBA_fnc_globalEvent; +["KPLIB_build_item_built_local", [_obj, _fob], _player] call CBA_fnc_targetEvent; diff --git a/Missionframework/modules/04_build/functions.hpp b/Missionframework/modules/04_build/functions.hpp index 3dda240f2..fd94788bf 100644 --- a/Missionframework/modules/04_build/functions.hpp +++ b/Missionframework/modules/04_build/functions.hpp @@ -32,6 +32,9 @@ class build { // Confirms all items in queue class build_confirmAll {}; + // Confirms single item from queue + build_confirmSingle {}; + // Display initialization class build_displayLoad {}; From a086e04a5a9291170dcc91077827382964f58ef5 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 03:26:35 +0100 Subject: [PATCH 16/20] Fix missing "class" keyword in functions.hpp --- Missionframework/modules/04_build/functions.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Missionframework/modules/04_build/functions.hpp b/Missionframework/modules/04_build/functions.hpp index fd94788bf..62ed948d6 100644 --- a/Missionframework/modules/04_build/functions.hpp +++ b/Missionframework/modules/04_build/functions.hpp @@ -33,7 +33,7 @@ class build { class build_confirmAll {}; // Confirms single item from queue - build_confirmSingle {}; + class build_confirmSingle {}; // Display initialization class build_displayLoad {}; From c9dbe4baf8c19447d2ea157fddc26c5fd06924d4 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 03:34:24 +0100 Subject: [PATCH 17/20] build_confirmSingle documentation --- .../04_build/fnc/fn_build_confirmSingle.sqf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf b/Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf index 6c3d16f73..fd52d8f52 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf @@ -11,17 +11,17 @@ Confirms single item from build queue. Parameter(s): - _createParams - Parameters for common_createVehicle [ARRAY, defaults to nil] - _vectorDirAndUp - Vector dir and up for created object [ARRAY, defaults to nil] - _player - Player that initiated the building of object + _createParams - Parameters for common_createVehicle [ARRAY, defaults to nil] + _vectorDirAndUp - Vector dir and up for created object [ARRAY, defaults to nil] + _player - Player that initiated the building of object [OBJECT, defaults to objNull] Returns: Function reached the end [BOOL] */ params [ - "_createParams", - "_vectorDirAndUp", - "_player" + ["_createParams", nil, [[]]], + ["_vectorDirAndUp", nil, [[]], 2], + ["_player", objNull, [objNull]] ]; _createParams params ["_className", "_pos", "_dir", "_justBuild"]; @@ -48,5 +48,5 @@ switch true do { private _fob = _player getVariable ["KPLIB_fob", ""]; -["KPLIB_build_item_built", [_obj, _fob] call CBA_fnc_globalEvent; +["KPLIB_build_item_built", [_obj, _fob]] call CBA_fnc_globalEvent; ["KPLIB_build_item_built_local", [_obj, _fob], _player] call CBA_fnc_targetEvent; From ef96a6f80a9e32a790454caeb3c8ec452ddd46c8 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 04:21:13 +0100 Subject: [PATCH 18/20] Create FOB on server --- .../04_build/fnc/fn_build_confirmAll.sqf | 2 +- .../modules/04_build/fnc/fn_build_preInit.sqf | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf index f57e09c8a..5d121ec8d 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf @@ -31,6 +31,6 @@ systemChat "buildConfirm: Resource check not implemented yet!"; deleteVehicle _x; - [[[_class, _pos, 0, true], _dirAndUp, player]] remoteExecCall ["KPLIB_fnc_build_confirmSingle", 2]; + [[_class, _pos, 0, true], _dirAndUp, player] remoteExecCall ["KPLIB_fnc_build_confirmSingle", 2]; } forEach _validItems; diff --git a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf index 3b7ec97da..c13818893 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf @@ -66,17 +66,19 @@ if (hasInterface) then { ["KPLIB_fob_build_requested", { params ["_object"]; KPLIB_build_fobBuildObject = _object; - - [getPos _object, nil, [KPLIB_preset_fobBuilding, 0,0,0], { - params ["_builtObject"]; - // Build FOB when item placed - private _fobName = [getPos _builtObject] call KPLIB_fnc_core_buildFob; - // Emit the built event with FOB and object to assign the object to FOB - ["KPLIB_build_item_built", [_builtObject, _fobName]] call CBA_fnc_globalEvent; - // Remove object - deleteVehicle KPLIB_build_fobBuildObject; + // Start single item build for fob building + [getPos _object, nil, [KPLIB_preset_fobBuilding, 0,0,0], { + // On confirm callback, create FOB on server + [[_this select 0, KPLIB_build_fobBuildObject], { + params ["_fobBuilding", "_fobBoxObject"]; + // Build FOB when item placed + private _fobName = [getPos _fobBuilding] call KPLIB_fnc_core_buildFob; + // Emit the built event with FOB and object to assign the object to FOB + ["KPLIB_build_item_built", [_fobBuilding, _fobName]] call CBA_fnc_globalEvent; + // Remove object + deleteVehicle _fobBoxObject; + }] remoteExec ["call", 2]; }] call KPLIB_fnc_build_start_single; - }] call CBA_fnc_addEventHandler; player addEventHandler ["Killed", KPLIB_fnc_build_stop]; From 8117ee8ec2894a6866dfe2279eac16d2dbee173d Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 09:59:02 +0100 Subject: [PATCH 19/20] Small tweaks --- .../modules/02_core/fnc/fn_core_canBuildFob.sqf | 2 +- .../modules/02_core/fnc/fn_core_getNearestMarker.sqf | 4 ++-- .../modules/04_build/fnc/fn_build_confirmAll.sqf | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf b/Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf index eab5435a6..c52f4f6d8 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_canBuildFob.sqf @@ -27,6 +27,6 @@ params [ private _minSectorDist = KPLIB_param_fobRange + KPLIB_param_sectorCapRange; (alive _box -&& _box distance2D KPLIB_eden_startbase > 300 +&& _box distance2D KPLIB_eden_startbase > 1000 && ([_minSectorDist, getPos _box, KPLIB_sectors_all + KPLIB_sectors_fobs] call KPLIB_fnc_core_getNearestMarker isEqualTo "")) diff --git a/Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf b/Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf index 260ed4a37..fda86fb33 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf @@ -30,7 +30,7 @@ private _markersWithinRange = _markers select {((markerPos _x) distance _center private _markersAscByRange = [_markersWithinRange, [_centerPos], {(markerPos _x) distance _input0}, "ASCEND"] call BIS_fnc_sortBy; // Return nearest marker if !(_markersAscByRange isEqualTo []) then { - _markersAscByRange select 0; + _markersAscByRange select 0 } else { "" -} +}; diff --git a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf index 5d121ec8d..07c5ac196 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf @@ -9,16 +9,15 @@ License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: - No description added yet. + Confirms and builds every item in build queue. Parameter(s): - _localVariable - Description [DATATYPE, defaults to DEFAULTVALUE] + NONE Returns: - Function reached the end [BOOL] + Items were built [BOOL] */ - private _validItems = LGVAR(buildQueue) select {_x getVariable ["KPLIB_validPos", true]}; LSVAR("buildQueue", LGVAR(buildQueue) - _validItems); @@ -34,3 +33,5 @@ systemChat "buildConfirm: Resource check not implemented yet!"; [[_class, _pos, 0, true], _dirAndUp, player] remoteExecCall ["KPLIB_fnc_build_confirmSingle", 2]; } forEach _validItems; + +true From cc4eea5baa8663c3a715c76fb9f8943e82b3172f Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Thu, 29 Nov 2018 10:20:18 +0100 Subject: [PATCH 20/20] Move fob build confirm to external method --- .../fnc/fn_build_handleFobBuildConfirm.sqf | 35 +++++++++++++++++++ .../modules/04_build/fnc/fn_build_preInit.sqf | 10 +----- .../modules/04_build/functions.hpp | 3 ++ 3 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 Missionframework/modules/04_build/fnc/fn_build_handleFobBuildConfirm.sqf diff --git a/Missionframework/modules/04_build/fnc/fn_build_handleFobBuildConfirm.sqf b/Missionframework/modules/04_build/fnc/fn_build_handleFobBuildConfirm.sqf new file mode 100644 index 000000000..313555f15 --- /dev/null +++ b/Missionframework/modules/04_build/fnc/fn_build_handleFobBuildConfirm.sqf @@ -0,0 +1,35 @@ +/* + KPLIB_fnc_build_handleFobBuildConfirm + + File: fn_build_handleFobBuildConfirm.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2018-11-29 + Last Update: 2018-11-29 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Handles FOB build confirmation + + Parameter(s): + _fobBuilding - Building on which FOB will be created [OBJECT, defaults to objNull] + _fobBoxObject - Object from which FOB build orignated [OBJECT, defaults to objNull] + + Returns: + Confirmation was handled [BOOL] +*/ +params [ + ["_fobBuilding", objNull, [objNull]], + ["_fobBoxObject", objNull, [objNull]] +]; + +if (isNull _fobBuilding) exitWith {diag_log format ["[KP LIBERATION] [%1] [BUILD] Null object passed, cannot create FOB", diag_tickTime]}; + +// Create FOB on position of building +private _fobName = [getPos _fobBuilding] call KPLIB_fnc_core_buildFob; +// Emit the built event with FOB and object to assign the object to freshly built FOB +["KPLIB_build_item_built", [_fobBuilding, _fobName]] call CBA_fnc_globalEvent; + +// Remove FOB box from which FOB build originated +deleteVehicle _fobBoxObject; + +true diff --git a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf index c13818893..ce6c24174 100644 --- a/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf +++ b/Missionframework/modules/04_build/fnc/fn_build_preInit.sqf @@ -69,15 +69,7 @@ if (hasInterface) then { // Start single item build for fob building [getPos _object, nil, [KPLIB_preset_fobBuilding, 0,0,0], { // On confirm callback, create FOB on server - [[_this select 0, KPLIB_build_fobBuildObject], { - params ["_fobBuilding", "_fobBoxObject"]; - // Build FOB when item placed - private _fobName = [getPos _fobBuilding] call KPLIB_fnc_core_buildFob; - // Emit the built event with FOB and object to assign the object to FOB - ["KPLIB_build_item_built", [_fobBuilding, _fobName]] call CBA_fnc_globalEvent; - // Remove object - deleteVehicle _fobBoxObject; - }] remoteExec ["call", 2]; + [_this select 0, KPLIB_build_fobBuildObject] remoteExec ["KPLIB_fnc_build_handleFobBuildConfirm", 2]; }] call KPLIB_fnc_build_start_single; }] call CBA_fnc_addEventHandler; diff --git a/Missionframework/modules/04_build/functions.hpp b/Missionframework/modules/04_build/functions.hpp index 62ed948d6..e3823cea0 100644 --- a/Missionframework/modules/04_build/functions.hpp +++ b/Missionframework/modules/04_build/functions.hpp @@ -59,6 +59,9 @@ class build { // Handle object dragging/positon changing class build_handleDrag {}; + // Handles FOB build confirmation + class build_handleFobBuildConfirm {}; + // Handle display keypresses class build_handleKeys {};