Skip to content

Commit 75609f3

Browse files
Markers - Allow placing quick number markers (#11019)
* Markers - Allow placing quick number markers * stash * setting for side sync * Update addons/markers/XEH_postInit.sqf Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * Update addons/markers/stringtable.xml Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * Update addons/markers/XEH_postInit.sqf Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * Update events-framework.md * Apply suggestion from @rautamiekka Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * fix regex * Update addons/markers/stringtable.xml Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> * update docs\markers.md --------- Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
1 parent 5f80479 commit 75609f3

File tree

8 files changed

+84
-0
lines changed

8 files changed

+84
-0
lines changed

addons/markers/CfgMarkers.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class CfgMarkers {
2+
class Empty;
3+
class GVAR(textOnly): Empty {
4+
scope = 2;
5+
size = 1;
6+
};
7+
};

addons/markers/XEH_postInit.sqf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,50 @@ GVAR(userPlacedMarkers) = [];
3939
_data set [2, _pos];
4040
};
4141
}] call CBA_fnc_addEventHandler;
42+
43+
if (hasInterface) then {
44+
GVAR(numberNextMarker) = false;
45+
GVAR(numberLocalLast) = 0;
46+
[QGVAR(editingMarker), {
47+
params ["_marker", "_display"];
48+
TRACE_2("editingMarker",_marker,_display);
49+
if (GVAR(quickNumberMarks) == 0) exitWith {};
50+
if (!cba_events_alt) exitWith {}; // not available before mission start
51+
if (_marker != "") exitWith {}; // editing an existing marker
52+
53+
private _description = _display displayCtrl IDC_INSERT_MARKER;
54+
private _number = if ((GVAR(quickNumberMarks) == 1) || {currentChannel != 1}) then {
55+
GVAR(numberLocalLast) = GVAR(numberLocalLast) + 1;
56+
GVAR(numberLocalLast) // local numbering
57+
} else {
58+
private _hash = missionNamespace getVariable [QGVAR(numberSideLast), createHashMap];
59+
private _side = side group player;
60+
private _next = (_hash getOrDefault [_side, 0]) + 1;
61+
_hash set [_side, _next];
62+
missionNamespace setVariable [QGVAR(numberSideLast), _hash, true];
63+
_next // side-synchronized numbering
64+
};
65+
_description ctrlSetText str _number;
66+
GVAR(numberNextMarker) = true;
67+
_display closeDisplay 1; // push ok button
68+
}] call CBA_fnc_addEventHandler;
69+
70+
[QGVAR(markerPlaced), {
71+
params ["_newestMarker"];
72+
TRACE_1("markerPlaced",_newestMarker);
73+
if (missionNamespace getVariable [QGVAR(numberNextMarker), false]) then {
74+
// set marker type to text only (temporarily for this marker)
75+
GVAR(numberNextMarker) = false;
76+
GVAR(currentMarkerConfigName) = QGVAR(textOnly);
77+
} else {
78+
// try to update our local marker index when placing a text-only marker with a number
79+
if ((GVAR(quickNumberMarks) == 2) && {currentChannel == 1}) exitWith {};
80+
if ((markerType _newestMarker) != QGVAR(textOnly)) exitWith {};
81+
private _text = markerText _newestMarker;
82+
if (count _text > 6) exitWith {};
83+
if !(_text regexMatch "^\d+$") exitWith {}; // just digits
84+
GVAR(numberLocalLast) = parseNumber _text;
85+
TRACE_1("Updated local marker number",GVAR(numberLocalLast));
86+
};
87+
}] call CBA_fnc_addEventHandler;
88+
};

addons/markers/config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ class CfgPatches {
1717
#include "CfgEventHandlers.hpp"
1818
#include "ACE_Settings.hpp"
1919
#include "CfgVehicles.hpp"
20+
#include "CfgMarkers.hpp"
2021

2122
#include "InsertMarker.hpp"

addons/markers/functions/fnc_initInsertMarker.sqf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,6 @@
356356
[_aceScaleSlider, _curSelScale] call FUNC(onSliderPosChangedScale);
357357
_aceScaleSlider ctrlAddEventHandler ["SliderPosChanged", {call FUNC(onSliderPosChangedScale)}];
358358
_aceScaleSlider ctrlAddEventHandler ["MouseButtonUp", {call FUNC(onSliderMouseButtonUpScale)}];
359+
360+
[QGVAR(editingMarker), [GVAR(editingMarker), _display]] call CBA_fnc_localEvent;
359361
}, _this] call CBA_fnc_execNextFrame;

addons/markers/initSettings.inc.sqf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,10 @@ private _formatDescription = [
9393
1
9494
]
9595
] call CBA_fnc_addSetting;
96+
97+
[
98+
QGVAR(quickNumberMarks), "LIST",
99+
[LSTRING(quickNumberMarks), LSTRING(quickNumberMarksDescription)],
100+
[_categoryName, LLSTRING(Module_DisplayName)],
101+
[[0,1,2], [disabled, "STR_cba_settings_ButtonLocal", LSTRING(quickNumberMarksSideSync)], 2]
102+
] call CBA_fnc_addSetting;

addons/markers/stringtable.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,5 +524,14 @@
524524
<Chinesesimp>更改UTC时间戳的时间偏移量</Chinesesimp>
525525
<Ukrainian>Змініть зміщення часу для мітки часу UTC</Ukrainian>
526526
</Key>
527+
<Key ID="STR_ACE_Markers_quickNumberMarks">
528+
<English>Quick Number Marks</English>
529+
</Key>
530+
<Key ID="STR_ACE_Markers_quickNumberMarksDescription">
531+
<English>Allows easy placement of numbered markers by holding ALT when placing a marker</English>
532+
</Key>
533+
<Key ID="STR_ACE_Markers_quickNumberMarksSideSync">
534+
<English>Side-Synchronized</English>
535+
</Key>
527536
</Package>
528537
</Project>

docs/wiki/feature/markers.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ Adds the ability to move map markers after they are placed. (Note: Must be enabl
3434
<h5>Note:</h5>
3535
<p>Does not work in Editor Preview! Conflicts with vanilla teleport keybind.</p>
3636
</div>
37+
38+
### 2.2 Placing Numbered Markers
39+
40+
To quickly place an incrementing numbered marker hold <kbd>Alt</kbd> and double left click

docs/wiki/framework/events-framework.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ MenuType: 0 = Interaction, 1 = Self Interaction
209209
|`ace_versioning_clientCheckDone` | [[_missingAddonsClient, _additionalAddonsClient, _olderVersionsClient, _newerVersionsClient]] | Local | Listen | When PBO checking has finished on a client |
210210
|`ace_versioning_serverCheckDone` | [[_serverFiles, _serverVersions]] | Local | Listen | When PBO checking has finished on the server |
211211

212+
### 2.22 Markers (`ace_markers`)
213+
214+
| Event Key | Parameters | Locality | Type | Description |
215+
|---------- |------------|----------|------|-------------|
216+
| `ace_markers_editingMarker` | [markerName, display] | Local | Listen | Editing a marker
217+
| `ace_markers_markerPlaced` | [markerName, isEditingMarker] | Local | Listen | Marker placed
218+
212219
## 3. Usage
213220
Also Reference [CBA Events System](https://github.com/CBATeam/CBA_A3/wiki/Custom-Events-System){:target="_blank"} documentation.
214221

0 commit comments

Comments
 (0)