Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markers - Add scale slider #8059

Merged
merged 9 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,4 @@ xrufix
Zakant <Zakant@gmx.de>
zGuba
Fyuran <dankemedic@hotmail.com>
Frank <frankplow@protonmail.com>
6 changes: 6 additions & 0 deletions addons/markers/InsertMarker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ class RscDisplayInsertMarker {
class MarkerAngleText: RscText {
idc = IDC_ACE_INSERT_MARKER_ANGLE_TEXT;
};
class MarkerScale: RscXSliderH {
idc = IDC_ACE_INSERT_MARKER_SCALE;
};
class MarkerScaleText: RscText {
idc = IDC_ACE_INSERT_MARKER_SCALE_TEXT;
};
};
};
1 change: 1 addition & 0 deletions addons/markers/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PREP(onLBSelChangedChannel);
PREP(onLBSelChangedColor);
PREP(onLBSelChangedShape);
PREP(onSliderPosChangedAngle);
PREP(onSliderPosChangedScale);
PREP(placeMarker);
PREP(sendMarkersJIP);
PREP(setMarkerJIP);
Expand Down
1 change: 1 addition & 0 deletions addons/markers/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if (isMultiplayer && {!isServer} && {hasInterface}) then {
GVAR(mapDisplaysWithDrawEHs) = [];
GVAR(currentMarkerPosition) = [];
GVAR(currentMarkerAngle) = 0;
GVAR(currentMarkerScale) = 1;
GVAR(currentMarkerColorConfigName) = "";
GVAR(currentMarkerConfigName) = "";

Expand Down
45 changes: 38 additions & 7 deletions addons/markers/functions/fnc_initInsertMarker.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
private _aceColorLB = _display displayctrl IDC_ACE_INSERT_MARKER_COLOR;
private _aceAngleSlider = _display displayctrl IDC_ACE_INSERT_MARKER_ANGLE;
private _aceAngleSliderText = _display displayctrl IDC_ACE_INSERT_MARKER_ANGLE_TEXT;
private _aceScaleSlider = _display displayctrl IDC_ACE_INSERT_MARKER_SCALE;
private _aceScaleSliderText = _display displayctrl IDC_ACE_INSERT_MARKER_SCALE_TEXT;

private _mapDisplay = displayParent _display;
if (isNull _mapDisplay) exitWith {ERROR("No Map");};
Expand Down Expand Up @@ -103,7 +105,8 @@
private _pos = ctrlposition _text;
_pos params ["_posX", "_posY", "_posW", "_posH"];
_posX = _posX + 0.01;
_posY = _posY min ((safeZoneH + safeZoneY) - (8 * _posH + 8 * BORDER)); //prevent buttons being placed below bottom edge of screen
_posY = _posY min ((safeZoneH + safeZoneY) - (11 * _posH + 11 * BORDER)); //prevent buttons being placed below bottom edge of screen

_pos set [0, _posX];
_pos set [1, _posY];
_text ctrlSetPosition _pos;
Expand All @@ -118,9 +121,9 @@
//--- Description
_pos set [1, _posY - 1 * _posH];
if (GVAR(timestampEnabled)) then {
_pos set [3,7 * _posH + 7 * BORDER];
_pos set [3,9 * _posH + 9 * BORDER];
} else {
_pos set [3,6 * _posH + 6 * BORDER];
_pos set [3,10 * _posH + 10 * BORDER];
};
_description ctrlEnable false;
_description ctrlSetPosition _pos;
Expand Down Expand Up @@ -187,16 +190,28 @@
_aceAngleSliderText ctrlSetPosition _pos;
_aceAngleSliderText ctrlCommit 0;

//--- Scale
_pos set [1, _posY + 5 * _posH + 6 * BORDER + _timestampOffset];
_pos set [2, _posW];
_aceScaleSlider ctrlSetPosition _pos;
_aceScaleSlider ctrlCommit 0;

//--- Scale Text
_pos set [1, _posY + 6 * _posH + 7 * BORDER + _timestampOffset];
_pos set [2, _posW];
_aceScaleSliderText ctrlSetPosition _pos;
_aceScaleSliderText ctrlCommit 0;

private _offsetButtons = 0;

if (isMultiplayer) then {
_pos set [1,_posY + 5 * _posH + 7 * BORDER + _timestampOffset];
_pos set [1,_posY + 7 * _posH + 9 * BORDER + _timestampOffset];
_pos set [3,_posH];
_descriptionChannel ctrlSetStructuredText parseText format ["<t size='0.8'>%1:</t>", localize "str_a3_cfgvehicles_modulerespawnposition_f_arguments_marker_0"];
_descriptionChannel ctrlSetPosition _pos;
_descriptionChannel ctrlCommit 0;

_pos set [1,_posY + 6 * _posH + 7 * BORDER + _timestampOffset];
_pos set [1,_posY + 8 * _posH + 9 * BORDER + _timestampOffset];
_pos set [3,_posH];
_channel ctrlSetPosition _pos;
_channel ctrlCommit 0;
Expand Down Expand Up @@ -235,11 +250,11 @@

_channel ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedChannel)}];

_offsetButtons = 7 * _posH + 8 * BORDER;
_offsetButtons = 9 * _posH + 10 * BORDER;
} else {
_descriptionChannel ctrlShow false;
_channel ctrlShow false;
_offsetButtons = 5 * _posH + 7 * BORDER;
_offsetButtons = 7 * _posH + 9 * BORDER;
};

//--- ButtonOK
Expand Down Expand Up @@ -321,4 +336,20 @@
//Update now and add eventHandler:
[_aceAngleSlider, _curSelAngle] call FUNC(onSliderPosChangedAngle);
_aceAngleSlider ctrlAddEventHandler ["SliderPosChanged", {_this call FUNC(onSliderPosChangedAngle)}];

////////////////////
// init marker scale slider
_aceScaleSlider sliderSetRange [0.5, 2.0];

if !(GVAR(editingMarker) isEqualTo "") then {
//get the original scale
GVAR(currentMarkerScale) = markerSize GVAR(editingMarker);
};

private _curSelScale = GETGVAR(currentMarkerScale,1);
_aceScaleSlider sliderSetPosition _curSelScale;

//Update now and add eventHandler:
[_aceScaleSlider, _curSelScale] call FUNC(onSliderPosChangedScale);
_aceScaleSlider ctrlAddEventHandler ["SliderPosChanged", {_this call FUNC(onSliderPosChangedScale)}];
}, _this] call CBA_fnc_execNextFrame;
6 changes: 3 additions & 3 deletions addons/markers/functions/fnc_mapDrawEH.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Draws the current temp marker. Allows rotation.
* Draws the current temp marker. Allows rotation and scale.
*
* Arguments:
* 0: TheMap <Control>
Expand All @@ -25,8 +25,8 @@ if (GVAR(currentMarkerConfigName) == "" || {GVAR(currentMarkerColorConfigName) =
ERROR("Bad Data");
};

private _sizeX = 1;
private _sizeY = 1;
private _sizeX = GVAR(currentMarkerScale);
private _sizeY = GVAR(currentMarkerScale);

private _textureConfig = configFile >> "CfgMarkers" >> GVAR(currentMarkerConfigName);
private _texture = getText (_textureConfig >> "icon");
Expand Down
28 changes: 28 additions & 0 deletions addons/markers/functions/fnc_onSliderPosChangedScale.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "script_component.hpp"
/*
* Author: frankplow
* Scale Slider Pos changed
jonpas marked this conversation as resolved.
Show resolved Hide resolved
*
* Arguments:
* 0: Slider (idc 1420) <CONTROL>
* 1: Slider Data (scale: 0.5...2.0) <NUMBER>
*
* Return Value:
* None
*
* Example:
* [Slider, 1.5] call ace_markers_fnc_onSliderPosChangedScale;
jonpas marked this conversation as resolved.
Show resolved Hide resolved
*
* Public: No
*/

params ["_ctrl", "_data"];
TRACE_2("params",_ctrl,_data);

private _scale = _data * 100;
_scale = round _scale;
_scale = _scale / 100;

((ctrlParent _ctrl) displayCtrl IDC_ACE_INSERT_MARKER_SCALE_TEXT) ctrlSetText format [localize LSTRING(MarkerScale), _scale];

GVAR(currentMarkerScale) = _data;
3 changes: 2 additions & 1 deletion addons/markers/functions/fnc_placeMarker.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ if (_closeNum isEqualTo 1) then {
GETGVAR(currentMarkerConfigName,""),
GETGVAR(currentMarkerColorConfigName,""),
GETGVAR(currentMarkerPosition,[]),
GETGVAR(currentMarkerAngle,0)
GETGVAR(currentMarkerAngle,0),
GETGVAR(currentMarkerScale,1)
]
]] call CBA_fnc_globalEvent;

Expand Down
3 changes: 2 additions & 1 deletion addons/markers/functions/fnc_setMarkerJIP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TRACE_2("params",_allMapMarkers,_allMapMarkersProperties);

if (_index != -1) then {
private _data = _allMapMarkersProperties select _index;
_data params ["_markerClassname", "_colorClassname", "_pos", "_dir"];
_data params ["_markerClassname", "_colorClassname", "_pos", "_dir", "_scale"];

private _config = (configfile >> "CfgMarkers") >> _markerClassname;

Expand All @@ -47,6 +47,7 @@ TRACE_2("params",_allMapMarkers,_allMapMarkersProperties);

_x setMarkerPosLocal _pos;
_x setMarkerDirLocal _dir;
_x setMarkerSizeLocal _scale;
};
false
} count allMapMarkers;
3 changes: 2 additions & 1 deletion addons/markers/functions/fnc_setMarkerNetwork.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

params ["_marker", "_data"];
TRACE_2("params",_marker,_data);
_data params ["_markerClassname", "_colorClassname", "_pos", "_dir"];
_data params ["_markerClassname", "_colorClassname", "_pos", "_dir", "_scale"];

private _config = configfile >> "CfgMarkers" >> _markerClassname;

Expand All @@ -41,6 +41,7 @@ _marker setMarkerColorLocal configName _config;

_marker setMarkerPosLocal _pos;
_marker setMarkerDirLocal _dir;
_marker setMarkerSizeLocal [_scale, _scale];

// save properties on server machine for JIP, marker editing ready
if (isMultiplayer && {isServer}) then {
Expand Down
2 changes: 2 additions & 0 deletions addons/markers/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@
#define IDC_ACE_INSERT_MARKER_COLOR 1221
#define IDC_ACE_INSERT_MARKER_ANGLE 1230
#define IDC_ACE_INSERT_MARKER_ANGLE_TEXT 1231
#define IDC_ACE_INSERT_MARKER_SCALE 1240
#define IDC_ACE_INSERT_MARKER_SCALE_TEXT 1241
3 changes: 3 additions & 0 deletions addons/markers/stringtable.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Markers">
<Key ID="STR_ACE_Markers_MarkerScale">
<English>Scale: %1</English>
</Key>
<Key ID="STR_ACE_Markers_MarkerDirection">
<English>Direction: %1°</English>
<German>Drehung: %1°</German>
Expand Down