-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adminMenu - Add Menu to Add or Edit Markers (#658)
* initial mockup * put testing buttons on bottom again * Handle new changes to hashKey name changes * split off marker defines for inclusion in adminMenu * Fix methods to use current keys and also persistent markers * chose name * Added marker handle updates * removed unused function * cleaned up double defined variables * Polished interface * comment out debug variables * fixed variable error * removed bad code - not relevant in context
- Loading branch information
1 parent
b4be82d
commit 21f1aab
Showing
9 changed files
with
604 additions
and
161 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
addons/adminMenu/functions/fnc_uihook_handleMarkerDialogUI.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#include "script_component.hpp" | ||
|
||
#ifdef GLUE | ||
#undef GLUE | ||
#endif | ||
#define GLUE(var1,var2) var1##var2 | ||
#ifdef PATHTOF | ||
#undef PATHTOF | ||
#endif | ||
#define PATHTOF(var) GLUE(\z\potato\addons\markers\,var) | ||
#ifdef QPATHTOF | ||
#undef QPATHTOF | ||
#endif | ||
#define QPATHTOF(var) QUOTE(PATHTOF(var)) | ||
#include "\z\potato\addons\markers\defaultMarkerDefines.hpp" | ||
#define POTATO_MARKER_ERROR_MARKSLCT 10 | ||
#define POTATO_MARKER_ERROR_CACHE 20 | ||
#define POTATO_MARKER_ERROR_UNITSLCT 30 | ||
/* | ||
* Author: Lambda.Tiger | ||
* Handle opening and closing of the marker dialog | ||
* | ||
* Arguments: | ||
* None | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Examples: | ||
* [false] call potato_adminMenu_uihook_handleMarkersDialogUI; | ||
* | ||
* Public: No | ||
*/ | ||
params [ | ||
["_display", displayNull, [displayNull]], | ||
["_exitCode", -1, [0, configNull]] | ||
]; | ||
TRACE_2("params",_display,_exitCode); | ||
|
||
if (_exitCode isEqualType configNull) then {_exitCode = -1}; | ||
switch (_exitCode) do { | ||
case -1: { // opening | ||
private _markerControl = UI_TAB_MARKERS_MARKERS; | ||
private _selectedMarkerIndex = lbCurSel _markerControl; | ||
TRACE_2("Editing marker:",GVAR(editMarker),_selectedMarkerIndex); | ||
if (GVAR(editMarker)) then { // we need an active marker | ||
if (_selectedMarkerIndex < 0) exitWith {_display closeDisplay POTATO_MARKER_ERROR_MARKSLCT}; | ||
// Find hashkey and make sure it exists | ||
private _hashKey = _markerControl lbData _selectedMarkerIndex; | ||
private _markerArray = EGVAR(markers,markerHash) getOrDefault [_hashKey, []]; | ||
if (_markerArray isEqualTo []) exitWith {_display closeDisplay POTATO_MARKER_ERROR_CACHE}; | ||
_markerArray params ["", "_text", "_icon", "_color", "_size"]; | ||
|
||
// Setup the display for the current marker | ||
(_display displayCtrl POTATO_MARKER_TEXT_IDC) ctrlSetText _text; | ||
private _colorIdx = COLOR_INDEX_ARRAY find _color; | ||
if (_colorIdx >= 0 && _colorIdx < 8) then { | ||
(_display displayCtrl POTATO_MARKER_COLOR_IDC) lbSetCurSel _colorIdx; | ||
}; | ||
switch (_size) do { | ||
case 16: {(_display displayCtrl POTATO_MARKER_SIZE_IDC) lbSetCurSel 0}; | ||
case 32: {(_display displayCtrl POTATO_MARKER_SIZE_IDC) lbSetCurSel 2}; | ||
default {(_display displayCtrl POTATO_MARKER_SIZE_IDC) lbSetCurSel 1}; | ||
}; | ||
private _iconIdx = [UNIT_MARKERS_STRINGS] find _icon; | ||
if (_iconIdx >= 0 && _iconIdx < 20) then { | ||
(_display displayCtrl POTATO_MARKER_ICON_IDC) lbSetCurSel _iconIdx; | ||
}; | ||
(_display displayCtrl POTATO_MARKER_UNIT_IDC) ctrlShow false; | ||
(_display displayCtrl POTATO_MARKER_OK_IDC) ctrlSetText "Update"; | ||
} else { | ||
// find the unit and make sure it's valid | ||
private _selectedUnit = missionNamespace getVariable [ | ||
UI_TAB_MARKERS_PLAYERS lbData (lbCurSel UI_TAB_MARKERS_PLAYERS), | ||
objNull | ||
]; | ||
if (isNull _selectedUnit) then {_display closeDisplay POTATO_MARKER_ERROR_UNITSLCT}; | ||
(_display displayCtrl POTATO_MARKER_UNIT_IDC) ctrlShow true; | ||
(_display displayCtrl POTATO_MARKER_OK_IDC) ctrlSetText "Create"; | ||
}; | ||
}; | ||
case 1: { // ok | ||
// Gather dialog parameters | ||
private _text = ctrlText (_display displayCtrl POTATO_MARKER_TEXT_IDC); | ||
private _size = switch(lbCurSel (_display displayCtrl POTATO_MARKER_SIZE_IDC)) do { | ||
case 0: {16}; | ||
case 2: {32}; | ||
default {24}; | ||
}; | ||
private _iconIdx = lbCurSel (_display displayCtrl POTATO_MARKER_ICON_IDC); | ||
private _colorIdx = lbCurSel (_display displayCtrl POTATO_MARKER_COLOR_IDC); | ||
|
||
TRACE_5("Closing Dialog:",GVAR(editMarker),_text,_size,_colorIdx,_iconIdx); | ||
if (GVAR(editMarker)) then { // Editing existing marker | ||
private _markerControl = UI_TAB_MARKERS_MARKERS; | ||
private _selectedMarkerIndex = lbCurSel _markerControl; | ||
private _hashKey = _markerControl lbData _selectedMarkerIndex; | ||
[_hashKey, _text, _size, _colorIdx, _iconIdx] remoteExecCall [QEFUNC(markers,updateMarker)]; | ||
["potato_adminMsg", | ||
[format ["Edited marker %1 (%2)", _text, _hashKey], profileName] | ||
] call CBA_fnc_GlobalEvent; | ||
} else { // Creating new marker | ||
private _selectedUnit = missionNamespace getVariable [ | ||
UI_TAB_MARKERS_PLAYERS lbData (lbCurSel UI_TAB_MARKERS_PLAYERS), | ||
objNull | ||
]; | ||
private _hashKey = if (cbChecked (_display displayCtrl POTATO_MARKER_UNIT_IDC)) then { | ||
str side _selectedUnit + groupId group _selectedUnit | ||
} else { | ||
str side _selectedUnit + str _selectedUnit | ||
}; | ||
private _markerArray = [ | ||
_hashKey, | ||
getPosATL _selectedUnit, _selectedUnit, side _selectedUnit, | ||
_text, _colorIdx, _iconIdx, _size | ||
]; | ||
EGVAR(markers,markerCache) setVariable [POTATO_MARKER_JIP_PREFIX + _hashKey, _markerArray, true]; | ||
_markerArray remoteExecCall [QEFUNC(markers,addMarker)]; | ||
["potato_adminMsg", | ||
[format ["Created new marker %1 (%2)", _text, _hashKey], profileName] | ||
] call CBA_fnc_GlobalEvent; | ||
}; | ||
call FUNC(reloadMarkersTab); | ||
}; | ||
case POTATO_MARKER_ERROR_MARKSLCT: { // Invalid marker - not marker selected | ||
["potato_adminMsg", | ||
["Could not find a selected marker", "Marker Dialog", profileName] | ||
] call CBA_fnc_localEvent; | ||
|
||
}; | ||
case POTATO_MARKER_ERROR_CACHE: { // Invalid marker - no hash | ||
["potato_adminMsg", | ||
["Could not find selected marker in cache", "Marker Dialog", profileName] | ||
] call CBA_fnc_localEvent; | ||
|
||
}; | ||
case POTATO_MARKER_ERROR_UNITSLCT: { // Invalid Unit | ||
["potato_adminMsg", | ||
["No valid unit selected to add marker to", "Marker Dialog", profileName] | ||
] call CBA_fnc_localEvent; | ||
|
||
}; | ||
default {}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#define RED_ARRAY [0.9,0,0,1] | ||
#define YELLOW_ARRAY [0.9,0.9,0,1] | ||
#define GREEN_ARRAY [0,0.8,0,1] | ||
#define BLUE_ARRAY [0,0,1,1] | ||
#define WHITE_ARRAY [1,1,1,1] | ||
#define ORANGE_ARRAY [1,0.647,0,1] | ||
#define BLACK_ARRAY [0,0,0,1] | ||
#define PINK_ARRAY [1,0.753,0.796,1] | ||
|
||
#define COLOR_TO_MARKER_HASH [\ | ||
[\ | ||
QUOTE(RED_ARRAY),\ | ||
QUOTE(YELLOW_ARRAY),\ | ||
QUOTE(GREEN_ARRAY),\ | ||
QUOTE(BLUE_ARRAY),\ | ||
QUOTE(WHITE_ARRAY),\ | ||
QUOTE(ORANGE_ARRAY),\ | ||
QUOTE(BLACK_ARRAY),\ | ||
QUOTE(PINK_ARRAY)\ | ||
], [\ | ||
"Red",\ | ||
"Yellow",\ | ||
"Green",\ | ||
"Blue",\ | ||
"White",\ | ||
"Yellow",\ | ||
"Black",\ | ||
"White"\ | ||
]\ | ||
] | ||
|
||
#define COLOR_INDEX_ARRAY [\ | ||
RED_ARRAY,\ | ||
YELLOW_ARRAY,\ | ||
GREEN_ARRAY,\ | ||
BLUE_ARRAY,\ | ||
WHITE_ARRAY,\ | ||
ORANGE_ARRAY,\ | ||
BLACK_ARRAY,\ | ||
PINK_ARRAY\ | ||
] | ||
|
||
#define DEFAULT_MARKER_TEXT "" | ||
#define DEFAULT_MARKER_ICON QPATHTOF(data\infantry.paa) | ||
#define DEFAULT_MARKER_ICON_INDEX 1 | ||
#define DEFAULT_MARKER_COLOR_TEXT "white" | ||
#define DEFAULT_MARKER_COLOR WHITE_ARRAY | ||
#define DEFAULT_MARKER_COLOR_INDEX 4 | ||
#define DEFAULT_MARKER_SIZE 24 | ||
|
||
#define UNIT_MARKER_ICON "\A3\ui_f\data\map\markers\military\start_CA.paa" | ||
#define UNIT_MARKER_SIZE 12 | ||
|
||
#define UNIT_MARKERS 'PATHTOF(data\unknown.paa)',\ | ||
'PATHTOF(data\infantry.paa)',\ | ||
'PATHTOF(data\motorized_infantry.paa)',\ | ||
'PATHTOF(data\mechanized_infantry.paa)',\ | ||
'PATHTOF(data\hq.paa)',\ | ||
'PATHTOF(data\mmg.paa)',\ | ||
'PATHTOF(data\mat.paa)',\ | ||
'PATHTOF(data\msam.paa)',\ | ||
'PATHTOF(data\mortar.paa)',\ | ||
'PATHTOF(data\engineer.paa)',\ | ||
'PATHTOF(data\maintenance.paa)',\ | ||
'PATHTOF(data\recon.paa)',\ | ||
'PATHTOF(data\support.paa)',\ | ||
'PATHTOF(data\medical.paa)',\ | ||
'PATHTOF(data\artillery.paa)',\ | ||
'PATHTOF(data\armor.paa)',\ | ||
'PATHTOF(data\helicopter.paa)',\ | ||
'PATHTOF(data\attack_helicopter.paa)',\ | ||
'PATHTOF(data\fixed_wing.paa)',\ | ||
'PATHTOF(data\attack_fixed_wing.paa)' | ||
|
||
#define UNIT_MARKERS_STRINGS QPATHTOF(data\unknown.paa),\ | ||
QPATHTOF(data\infantry.paa),\ | ||
QPATHTOF(data\motorized_infantry.paa),\ | ||
QPATHTOF(data\mechanized_infantry.paa),\ | ||
QPATHTOF(data\hq.paa),\ | ||
QPATHTOF(data\mmg.paa),\ | ||
QPATHTOF(data\mat.paa),\ | ||
QPATHTOF(data\msam.paa),\ | ||
QPATHTOF(data\mortar.paa),\ | ||
QPATHTOF(data\engineer.paa),\ | ||
QPATHTOF(data\maintenance.paa),\ | ||
QPATHTOF(data\recon.paa),\ | ||
QPATHTOF(data\support.paa),\ | ||
QPATHTOF(data\medical.paa),\ | ||
QPATHTOF(data\artillery.paa),\ | ||
QPATHTOF(data\armor.paa),\ | ||
QPATHTOF(data\helicopter.paa),\ | ||
QPATHTOF(data\attack_helicopter.paa),\ | ||
QPATHTOF(data\fixed_wing.paa),\ | ||
QPATHTOF(data\attack_fixed_wing.paa) | ||
|
||
// e.g. "'\z\potato\addons\markers\data\unknown.paa'" | ||
#define UNIT_MARKERS_STRINGS_STRINGS QUOTE('PATHTOF(data\unknown.paa)'),\ | ||
QUOTE('PATHTOF(data\infantry.paa)'),\ | ||
QUOTE('PATHTOF(data\motorized_infantry.paa)'),\ | ||
QUOTE('PATHTOF(data\mechanized_infantry.paa)'),\ | ||
QUOTE('PATHTOF(data\hq.paa)'),\ | ||
QUOTE('PATHTOF(data\mmg.paa)'),\ | ||
QUOTE('PATHTOF(data\mat.paa)'),\ | ||
QUOTE('PATHTOF(data\msam.paa)'),\ | ||
QUOTE('PATHTOF(data\mortar.paa)'),\ | ||
QUOTE('PATHTOF(data\engineer.paa)'),\ | ||
QUOTE('PATHTOF(data\maintenance.paa)'),\ | ||
QUOTE('PATHTOF(data\recon.paa)'),\ | ||
QUOTE('PATHTOF(data\support.paa)'),\ | ||
QUOTE('PATHTOF(data\medical.paa)'),\ | ||
QUOTE('PATHTOF(data\artillery.paa)'),\ | ||
QUOTE('PATHTOF(data\armor.paa)'),\ | ||
QUOTE('PATHTOF(data\helicopter.paa)'),\ | ||
QUOTE('PATHTOF(data\attack_helicopter.paa)'),\ | ||
QUOTE('PATHTOF(data\fixed_wing.paa)'),\ | ||
QUOTE('PATHTOF(data\attack_fixed_wing.paa)') | ||
|
||
#define UNIT_MARKER_SIZES 16,24,32 | ||
#define UNIT_MARKER_SIZES_STRINGS "Small","Medium","Large" | ||
|
||
#define UNIT_MARKER_COLORS "white","red","blue","green","orange","yellow","pink","black" | ||
#define UNIT_MARKER_COLORS_STRINGS "White","Red","Blue","Green","Orange","Yellow","Pink","Black" | ||
|
||
#define POTATO_MARKER_JIP_PREFIX "marker:" | ||
#define POTATO_MARKER_JIP_PREFIX_LENGTH 7 |
Oops, something went wrong.