diff --git a/addons/area_markers/XEH_PREP.hpp b/addons/area_markers/XEH_PREP.hpp index 764cb9539..66859d255 100644 --- a/addons/area_markers/XEH_PREP.hpp +++ b/addons/area_markers/XEH_PREP.hpp @@ -3,11 +3,11 @@ PREP(configure); PREP(createIcon); PREP(createMarker); PREP(deleteIcon); -PREP(initDisplayCurator); PREP(isEditable); +PREP(isInEditMode); PREP(onDraw); PREP(onKeyDown); -PREP(onMapToggled); +PREP(onLoad); PREP(onMarkerCreated); PREP(onMarkerDeleted); PREP(onMarkerUpdated); @@ -15,4 +15,6 @@ PREP(onMouseButtonDown); PREP(onMouseButtonUp); PREP(onMouseDblClick); PREP(onMouseMoving); +PREP(onUnload); +PREP(onVisibilityPFH); PREP(updateIcon); diff --git a/addons/area_markers/XEH_postInit.sqf b/addons/area_markers/XEH_postInit.sqf index cbee9c982..c986794a8 100644 --- a/addons/area_markers/XEH_postInit.sqf +++ b/addons/area_markers/XEH_postInit.sqf @@ -5,12 +5,8 @@ if (isServer) then { }; if (hasInterface) then { - ["zen_curatorDisplayLoaded", LINKFUNC(initDisplayCurator)] call CBA_fnc_addEventHandler; - - // Add EHs to update visibility of area marker icons when the map is toggled - // Need both activate and deactivate to deal with issues around rapidly toggling the map - addUserActionEventHandler ["showMap", "Activate", {call FUNC(onMapToggled)}]; - addUserActionEventHandler ["showMap", "Deactivate", {call FUNC(onMapToggled)}]; + ["zen_curatorDisplayLoaded", LINKFUNC(onLoad)] call CBA_fnc_addEventHandler; + ["zen_curatorDisplayUnloaded", LINKFUNC(onUnload)] call CBA_fnc_addEventHandler; // Add EHs to automatically make any area markers editable addMissionEventHandler ["MarkerCreated", {call FUNC(onMarkerCreated)}]; diff --git a/addons/area_markers/functions/fnc_configure.sqf b/addons/area_markers/functions/fnc_configure.sqf index e078077d7..0c88bee5a 100644 --- a/addons/area_markers/functions/fnc_configure.sqf +++ b/addons/area_markers/functions/fnc_configure.sqf @@ -162,10 +162,6 @@ private _keyDownEH = _display displayAddEventHandler ["KeyDown", { _display displayRemoveEventHandler ["KeyDown", _keyDownEH]; ctrlDelete _ctrlConfigure; - - // Despite returning true to override default handling, pressing ESCAPE - // appears to be hard coded to close the map - call FUNC(onMapToggled); }; true // handled diff --git a/addons/area_markers/functions/fnc_createIcon.sqf b/addons/area_markers/functions/fnc_createIcon.sqf index 3a17fb152..d564ade4b 100644 --- a/addons/area_markers/functions/fnc_createIcon.sqf +++ b/addons/area_markers/functions/fnc_createIcon.sqf @@ -22,7 +22,7 @@ if (isNull _display) exitWith {}; private _ctrlIcon = _display ctrlCreate [QGVAR(icon), IDC_ICON_GROUP]; _ctrlIcon setVariable [QGVAR(marker), _marker]; -_ctrlIcon ctrlShow visibleMap; +_ctrlIcon ctrlShow call FUNC(isInEditMode); GVAR(icons) set [_marker, _ctrlIcon]; diff --git a/addons/area_markers/functions/fnc_isInEditMode.sqf b/addons/area_markers/functions/fnc_isInEditMode.sqf new file mode 100644 index 000000000..a846176f6 --- /dev/null +++ b/addons/area_markers/functions/fnc_isInEditMode.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" +/* + * Author: mharis001 + * Checks if the Zeus display is in marker editing mode. + * + * Arguments: + * None + * + * Return Value: + * In Marker Editing Mode + * + * Example: + * [] call zen_area_markers_fnc_isInEditMode + * + * Public: No + */ + +visibleMap +&& {!dialog} +&& {!call EFUNC(common,isInScreenshotMode)} +&& {RscDisplayCurator_sections select 0 == CURATOR_MODE_MARKERS} diff --git a/addons/area_markers/functions/fnc_onKeyDown.sqf b/addons/area_markers/functions/fnc_onKeyDown.sqf index dd65adf60..d73e53e0b 100644 --- a/addons/area_markers/functions/fnc_onKeyDown.sqf +++ b/addons/area_markers/functions/fnc_onKeyDown.sqf @@ -30,11 +30,4 @@ if (visibleMap && {_keyCode == DIK_DELETE}) exitWith { false }; -// Map visibility can be toggled with the ESCAPE key -// Appears to be hard coded and independent of the "ingamePause" user action -// Also, update the icons when the interface's visibility is toggled -if (_keyCode == DIK_ESCAPE || {_keyCode in actionKeys "curatorToggleInterface"}) then { - call FUNC(onMapToggled); -}; - false diff --git a/addons/area_markers/functions/fnc_initDisplayCurator.sqf b/addons/area_markers/functions/fnc_onLoad.sqf similarity index 74% rename from addons/area_markers/functions/fnc_initDisplayCurator.sqf rename to addons/area_markers/functions/fnc_onLoad.sqf index 0dbead460..39d685810 100644 --- a/addons/area_markers/functions/fnc_initDisplayCurator.sqf +++ b/addons/area_markers/functions/fnc_onLoad.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: mharis001 - * Initializes the Zeus display. + * Handles initializing the Zeus Display. * * Arguments: * 0: Display @@ -10,7 +10,7 @@ * None * * Example: - * [DISPLAY] call zen_area_markers_fnc_initDisplayCurator + * [DISPLAY] call zen_area_markers_fnc_onLoad * * Public: No */ @@ -24,6 +24,9 @@ _ctrlMap ctrlAddEventHandler ["Draw", {call FUNC(onDraw)}]; // Add EH to handle deleting area marker by pressing the DELETE key _display displayAddEventHandler ["KeyDown", {call FUNC(onKeyDown)}]; +// Add PFH to update visibility of area marker icons +GVAR(visibilityPFH) = [LINKFUNC(onVisibilityPFH), 0, [false]] call CBA_fnc_addPerFrameHandler; + // Create area marker icons for all area markers { { diff --git a/addons/area_markers/functions/fnc_onMapToggled.sqf b/addons/area_markers/functions/fnc_onMapToggled.sqf deleted file mode 100644 index 01a351bf2..000000000 --- a/addons/area_markers/functions/fnc_onMapToggled.sqf +++ /dev/null @@ -1,28 +0,0 @@ -#include "script_component.hpp" -/* - * Author: mharis001 - * Handles toggling the Zeus display's map. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * [] call zen_area_markers_fnc_onMapToggled - * - * Public: No - */ - -if (isNull findDisplay IDD_RSCDISPLAYCURATOR) exitWith {}; - -// Need frame delay because both the visisbleMap and the map control's -// visibility are not updated until the next frame -{ - private _show = visibleMap && {!call EFUNC(common,isInScreenshotMode)}; - - { - _y ctrlShow _show; - } forEach GVAR(icons); -} call CBA_fnc_execNextFrame; diff --git a/addons/area_markers/functions/fnc_onUnload.sqf b/addons/area_markers/functions/fnc_onUnload.sqf new file mode 100644 index 000000000..5abc46b72 --- /dev/null +++ b/addons/area_markers/functions/fnc_onUnload.sqf @@ -0,0 +1,19 @@ +#include "script_component.hpp" +/* + * Author: mharis001 + * Handles unloading the Zeus Display. + * + * Arguments: + * 0: Display (not used) + * + * Return Value: + * None + * + * Example: + * [DISPLAY] call zen_area_markers_fnc_onUnload + * + * Public: No + */ + +GVAR(visibilityPFH) call CBA_fnc_removePerFrameHandler; +GVAR(visibilityPFH) = nil; diff --git a/addons/area_markers/functions/fnc_onVisibilityPFH.sqf b/addons/area_markers/functions/fnc_onVisibilityPFH.sqf new file mode 100644 index 000000000..d7f79554a --- /dev/null +++ b/addons/area_markers/functions/fnc_onVisibilityPFH.sqf @@ -0,0 +1,34 @@ +#include "script_component.hpp" +/* + * Author: mharis001 + * Handles updating the visibility of area marker icons. + * + * Arguments: + * 0: Arguments + * 0: Current Visibility + * + * Return Value: + * None + * + * Example: + * [[false]] call zen_area_markers_fnc_onVisibilityPFH + * + * Public: No + */ + +BEGIN_COUNTER(onVisibilityPFH); + +params ["_args"]; +_args params ["_oldVisibility"]; + +private _newVisibility = call FUNC(isInEditMode); + +if (_oldVisibility isNotEqualTo _newVisibility) then { + { + _y ctrlShow _newVisibility; + } forEach GVAR(icons); + + _args set [0, _newVisibility]; +}; + +END_COUNTER(onVisibilityPFH); diff --git a/addons/area_markers/gui.hpp b/addons/area_markers/gui.hpp index 10c35b181..3335ceb2c 100644 --- a/addons/area_markers/gui.hpp +++ b/addons/area_markers/gui.hpp @@ -18,7 +18,7 @@ class GVAR(icon): RscControlsGroupNoScrollbars { w = QUOTE(ICON_WIDTH); h = QUOTE(ICON_HEIGHT); class controls { - class Icon: RscPicture { + class Image: RscPicture { idc = IDC_ICON_IMAGE; text = ICON_CENTER; x = 0; diff --git a/addons/common/functions/fnc_getActiveTree.sqf b/addons/common/functions/fnc_getActiveTree.sqf index b7a90e451..433a5da93 100644 --- a/addons/common/functions/fnc_getActiveTree.sqf +++ b/addons/common/functions/fnc_getActiveTree.sqf @@ -22,20 +22,20 @@ if (isNull _display) exitWith {controlNull}; RscDisplayCurator_sections params ["_mode", "_side"]; private _treeIDC = switch (_mode) do { - case 0: { - IDCS_UNIT_TREES select _side; + case CURATOR_MODE_UNITS: { + IDCS_UNIT_TREES select _side }; - case 1: { - IDCS_GROUP_TREES select _side; + case CURATOR_MODE_GROUPS: { + IDCS_GROUP_TREES select _side }; - case 2: { - IDC_RSCDISPLAYCURATOR_CREATE_MODULES; + case CURATOR_MODE_MODULES: { + IDC_RSCDISPLAYCURATOR_CREATE_MODULES }; - case 3: { - IDC_RSCDISPLAYCURATOR_CREATE_MARKERS; + case CURATOR_MODE_MARKERS: { + IDC_RSCDISPLAYCURATOR_CREATE_MARKERS }; - case 4: { - IDC_RSCDISPLAYCURATOR_CREATE_RECENT; + case CURATOR_MODE_RECENT: { + IDC_RSCDISPLAYCURATOR_CREATE_RECENT }; }; diff --git a/addons/common/functions/fnc_isPlacementActive.sqf b/addons/common/functions/fnc_isPlacementActive.sqf index e13ace503..61f85913d 100644 --- a/addons/common/functions/fnc_isPlacementActive.sqf +++ b/addons/common/functions/fnc_isPlacementActive.sqf @@ -23,5 +23,4 @@ RscDisplayCurator_sections params ["_mode"]; // Get the path length necessary for placement based on the current mode private _pathLength = [3, 4, 2, 1, 1] select _mode; - count tvCurSel call FUNC(getActiveTree) == _pathLength diff --git a/addons/compositions/functions/fnc_initDisplayCurator.sqf b/addons/compositions/functions/fnc_initDisplayCurator.sqf index a61af62c6..405a57c6a 100644 --- a/addons/compositions/functions/fnc_initDisplayCurator.sqf +++ b/addons/compositions/functions/fnc_initDisplayCurator.sqf @@ -29,7 +29,7 @@ }; // Initially hide the custom compositions panel if the compositions tree is not active - if (GETMVAR(RscDisplayCurator_sections,[]) isNotEqualTo [1, 4]) then { + if (GETMVAR(RscDisplayCurator_sections,[]) isNotEqualTo [CURATOR_MODE_GROUPS, CURATOR_SIDE_EMPTY]) then { private _ctrlPanel = _display displayCtrl IDC_PANEL_GROUP; _ctrlPanel ctrlShow false; }; diff --git a/addons/editor/functions/fnc_handleLoad.sqf b/addons/editor/functions/fnc_handleLoad.sqf index e758a9317..4d8c2ed0c 100644 --- a/addons/editor/functions/fnc_handleLoad.sqf +++ b/addons/editor/functions/fnc_handleLoad.sqf @@ -85,7 +85,7 @@ _display displayAddEventHandler ["KeyUp", {call FUNC(handleKeyUp)}]; { private _ctrl = _display displayCtrl _x; _ctrl ctrlAddEventHandler ["MouseButtonDown", { - if (RscDisplayCurator_sections select 0 == 1) then { + if (RscDisplayCurator_sections select 0 == CURATOR_MODE_GROUPS) then { private _ctrlTree = call EFUNC(common,getActiveTree); private _path = tvCurSel _ctrlTree; diff --git a/addons/editor/functions/fnc_handleObjectPlaced.sqf b/addons/editor/functions/fnc_handleObjectPlaced.sqf index 066939f96..63c3a434c 100644 --- a/addons/editor/functions/fnc_handleObjectPlaced.sqf +++ b/addons/editor/functions/fnc_handleObjectPlaced.sqf @@ -27,7 +27,13 @@ if (!GVAR(iconsVisible)) then { RscDisplayCurator_sections params ["_mode"]; -if (!GVAR(includeCrew) && {_mode == 0 || {_mode == 4 && {isClass (configFile >> "CfgVehicles" >> GVAR(recentTreeData))}}}) then { +if ( + !GVAR(includeCrew) + && { + _mode == CURATOR_MODE_UNITS + || {_mode == CURATOR_MODE_RECENT && {isClass (configFile >> "CfgVehicles" >> GVAR(recentTreeData))}} + } +) then { deleteVehicleCrew _object; }; diff --git a/addons/editor/functions/fnc_handleTreeButtons.sqf b/addons/editor/functions/fnc_handleTreeButtons.sqf index a8129fb49..48904e200 100644 --- a/addons/editor/functions/fnc_handleTreeButtons.sqf +++ b/addons/editor/functions/fnc_handleTreeButtons.sqf @@ -21,7 +21,7 @@ params ["", "_expand"]; RscDisplayCurator_sections params ["_mode"]; // Can't collapse or expand marker or recent trees -if (_mode > 2) exitWith {}; +if (_mode > CURATOR_MODE_MODULES) exitWith {}; // Collapse or expand current tree private _ctrlTree = call EFUNC(common,getActiveTree); @@ -32,7 +32,7 @@ if (_expand) then { _ctrlTree call EFUNC(common,collapseTree); // For QOL, keep factions of group trees visible - if (_mode == 1) then { + if (_mode == CURATOR_MODE_GROUPS) then { _ctrlTree tvExpand [0]; }; }; diff --git a/addons/main/script_curator.hpp b/addons/main/script_curator.hpp new file mode 100644 index 000000000..3ac278723 --- /dev/null +++ b/addons/main/script_curator.hpp @@ -0,0 +1,18 @@ +// Create Tree Tabs (Modes and Sides) +#define CURATOR_MODE_UNITS 0 +#define CURATOR_MODE_GROUPS 1 +#define CURATOR_MODE_MODULES 2 +#define CURATOR_MODE_MARKERS 3 +#define CURATOR_MODE_RECENT 4 + +#define CURATOR_SIDE_BLUFOR 0 +#define CURATOR_SIDE_OPFOR 1 +#define CURATOR_SIDE_INDEPENDENT 2 +#define CURATOR_SIDE_CIVILIAN 3 +#define CURATOR_SIDE_EMPTY 4 + +// Selected Entities +#define SELECTED_OBJECTS (curatorSelected select 0) +#define SELECTED_GROUPS (curatorSelected select 1) +#define SELECTED_WAYPOINTS (curatorSelected select 2) +#define SELECTED_MARKERS (curatorSelected select 3) diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index b5a1d91f8..5ea325305 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -78,11 +78,6 @@ #define ZEN_isHC (!hasInterface && !isDedicated) -#define SELECTED_OBJECTS (curatorSelected select 0) -#define SELECTED_GROUPS (curatorSelected select 1) -#define SELECTED_WAYPOINTS (curatorSelected select 2) -#define SELECTED_MARKERS (curatorSelected select 3) - #define GUI_THEME_RGB_R "(profileNamespace getVariable ['GUI_BCG_RGB_R',0.13])" #define GUI_THEME_RGB_G "(profileNamespace getVariable ['GUI_BCG_RGB_G',0.54])" #define GUI_THEME_RGB_B "(profileNamespace getVariable ['GUI_BCG_RGB_B',0.21])" @@ -115,4 +110,5 @@ #define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction #endif +#include "script_curator.hpp" #include "script_debug.hpp" diff --git a/addons/markers_tree/functions/fnc_handleTreeButtons.sqf b/addons/markers_tree/functions/fnc_handleTreeButtons.sqf index 3de000301..32d27568a 100644 --- a/addons/markers_tree/functions/fnc_handleTreeButtons.sqf +++ b/addons/markers_tree/functions/fnc_handleTreeButtons.sqf @@ -19,7 +19,7 @@ params ["_display", "_expand"]; // Only handle the custom icon markers tree, rest are handled by editor component -if (RscDisplayCurator_sections select 0 != 3 || {GVAR(mode) != 0}) exitWith {}; +if (RscDisplayCurator_sections select 0 != CURATOR_MODE_MARKERS || {GVAR(mode) != 0}) exitWith {}; private _ctrlTreeIcons = _display displayCtrl IDC_MARKERS_TREE_ICONS; diff --git a/addons/markers_tree/functions/fnc_initDisplayCurator.sqf b/addons/markers_tree/functions/fnc_initDisplayCurator.sqf index 9a4d2f1fc..56257514e 100644 --- a/addons/markers_tree/functions/fnc_initDisplayCurator.sqf +++ b/addons/markers_tree/functions/fnc_initDisplayCurator.sqf @@ -60,7 +60,7 @@ missionNamespace getVariable ["RscDisplayCurator_sections", [0, 0]] params ["_mo // Need frame delay workaround for usage of ctrlActivate by RscDisplayCurator.sqf // to properly hide the empty side control when initially in markers mode -if (_mode == 3) then { +if (_mode == CURATOR_MODE_MARKERS) then { private _ctrlSideEmpty = _display displayCtrl IDC_RSCDISPLAYCURATOR_SIDEEMPTY; [{_this ctrlShow false}, _ctrlSideEmpty, 3] call CBA_fnc_execAfterNFrames; };