mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Show placement angle in preview
This commit is contained in:
parent
24bba5dea6
commit
e5cbca02e4
@ -14,3 +14,10 @@ if (isMultiplayer && {!isServer} && {hasInterface}) then {
|
||||
|
||||
[QGVAR(sendMarkersJIP), _logic] call EFUNC(common,serverEvent);
|
||||
};
|
||||
|
||||
|
||||
GVAR(mapDisplaysWithDrawEHs) = [];
|
||||
GVAR(currentMarkerPosition) = [];
|
||||
GVAR(currentMarkerAngle) = 0;
|
||||
GVAR(currentMarkerColorConfigName) = "";
|
||||
GVAR(currentMarkerConfigName) = "";
|
@ -3,6 +3,7 @@
|
||||
ADDON = false;
|
||||
|
||||
PREP(initInsertMarker);
|
||||
PREP(mapDrawEH);
|
||||
PREP(onLBSelChangedColor);
|
||||
PREP(onLBSelChangedShape);
|
||||
PREP(onSliderPosChangedAngle);
|
||||
|
@ -20,16 +20,13 @@
|
||||
|
||||
[{
|
||||
disableserialization;
|
||||
_display = _this select 0;
|
||||
PARAMS_1(_display);
|
||||
|
||||
//Can't place markers when can't interact
|
||||
if (!([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith))) exitWith {
|
||||
_display closeDisplay 2; //emulate "Cancel" button
|
||||
};
|
||||
|
||||
// prevent vanilla key input
|
||||
_display displayAddEventHandler ["KeyDown", {(_this select 1) in [200, 208]}];
|
||||
|
||||
//BIS Controls:
|
||||
_text = _display displayctrl 101;
|
||||
_picture = _display displayctrl 102;
|
||||
@ -48,6 +45,33 @@
|
||||
_aceAngleSlider = _display displayctrl 1220;
|
||||
_aceAngleSliderText = _display displayctrl 1221;
|
||||
|
||||
|
||||
//Install MapDrawEH on current map
|
||||
_mapIDD = -1;
|
||||
{
|
||||
if (!isNull (findDisplay _x)) exitWith {_mapIDD = _x};
|
||||
} forEach [12, 37, 52, 53];
|
||||
if (_mapIDD == -1) exitWith {ERROR("No Map?");};
|
||||
if (!(_mapIDD in GVAR(mapDisplaysWithDrawEHs))) then {
|
||||
GVAR(mapDisplaysWithDrawEHs) pushBack _mapIDD;
|
||||
systemChat str _mapIDD;
|
||||
systemChat str ((finddisplay _mapIDD) displayctrl 51);
|
||||
((finddisplay _mapIDD) displayctrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(mapDrawEH)}];
|
||||
};
|
||||
|
||||
//Calculate center position of the marker placement ctrl
|
||||
_pos = ctrlPosition _picture;
|
||||
_pos = [(_pos select 0) + (_pos select 2) / 2, (_pos select 1) + (_pos select 3) / 2];
|
||||
GVAR(currentMarkerPosition) = ((findDisplay _mapIDD) displayCtrl 51) ctrlMapScreenToWorld _pos;
|
||||
|
||||
//Hide the bis picture:
|
||||
_picture ctrlShow false;
|
||||
|
||||
// prevent vanilla key input
|
||||
_display displayAddEventHandler ["KeyDown", {(_this select 1) in [200, 208]}];
|
||||
|
||||
|
||||
//Focus on the text input
|
||||
ctrlSetFocus _text;
|
||||
|
||||
//--- Background
|
||||
|
45
addons/markers/functions/fnc_mapDrawEH.sqf
Normal file
45
addons/markers/functions/fnc_mapDrawEH.sqf
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Draws the current temp marker. Allows rotation.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: TheMap <Control>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [theMapControl] call ace_markers_fnc_mapDrawEH;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_theMap", "_sizeX", "_sizeY", "_textureConfig", "_texture", "_markerSize", "_markerShadow", "_colorConfig", "_drawColor"];
|
||||
|
||||
PARAMS_1(_theMap);
|
||||
|
||||
//Only show if marker place is open:
|
||||
if (isNull (findDisplay 54)) exitWith {};
|
||||
//Error checking:
|
||||
if ((GVAR(currentMarkerConfigName) == "") || {GVAR(currentMarkerColorConfigName) == ""} || {GVAR(currentMarkerPosition) isEqualTo []}) exitWith {ERROR("Bad Data");};
|
||||
|
||||
_sizeX = 1;
|
||||
_sizeY = 1;
|
||||
|
||||
_textureConfig = configFile >> "CfgMarkers" >> GVAR(currentMarkerConfigName);
|
||||
_texture = getText (_textureConfig >> "icon");
|
||||
_markerSize = getNumber (_textureConfig >> "size");
|
||||
_markerShadow = getNumber (_textureConfig >> "shadow");
|
||||
_colorConfig = (configFile >> "CfgMarkerColors" >> GVAR(currentMarkerColorConfigName));
|
||||
_drawColor = getArray (_colorConfig >> "color");
|
||||
|
||||
//Convert possible code into numbers
|
||||
{
|
||||
if (typeName _x == "STRING") then {
|
||||
_drawColor set [_forEachIndex, (call compile _x)];
|
||||
};
|
||||
} forEach _drawColor;
|
||||
_drawColor set [3, ((_drawColor select 3) * 0.875)]; //Arma adds a slight transparency
|
||||
|
||||
_theMap drawIcon [_texture, _drawColor, GVAR(currentMarkerPosition), (_sizeX * _markerSize), (_sizeY * _markerSize), GVAR(currentMarkerAngle), "", _markerShadow];
|
@ -25,15 +25,4 @@ GVAR(curSelMarkerColor) = _index;
|
||||
|
||||
_config = (configfile >> "CfgMarkerColors") select _data;
|
||||
|
||||
_color = getArray (_config >> "color");
|
||||
|
||||
//Array could be strings of code that need to be converted:
|
||||
{
|
||||
if (typeName _x != "SCALAR") then {
|
||||
_color set [_forEachIndex, call compile _x];
|
||||
};
|
||||
} forEach _color;
|
||||
|
||||
((ctrlParent _ctrl) displayCtrl 102) ctrlSetTextColor _color;
|
||||
|
||||
GVAR(currentMarkerColorConfigName) = (configName _config);
|
||||
|
@ -25,8 +25,4 @@ GVAR(curSelMarkerShape) = _index;
|
||||
|
||||
_config = (configfile >> "CfgMarkers") select _data;
|
||||
|
||||
_icon = getText (_config >> "icon");
|
||||
|
||||
((ctrlParent _ctrl) displayCtrl 102) ctrlSetText _icon;
|
||||
|
||||
GVAR(currentMarkerConfigName) = (configName _config);
|
||||
|
@ -16,46 +16,21 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
disableserialization;
|
||||
PARAMS_2(_display,_closeNum);
|
||||
|
||||
if (_closeNum == 1) then {
|
||||
disableserialization;
|
||||
|
||||
_pos = ctrlPosition (_display displayCtrl 102);
|
||||
_pos = [
|
||||
(_pos select 0) + (_pos select 2) / 2,
|
||||
(_pos select 1) + (_pos select 3) / 2
|
||||
];
|
||||
|
||||
switch (true) do {
|
||||
case (!isNull findDisplay 12): {
|
||||
_pos = (findDisplay 12 displayCtrl 51) ctrlMapScreenToWorld _pos;
|
||||
};
|
||||
case (!isNull findDisplay 37): {
|
||||
_pos = (findDisplay 37 displayCtrl 51) ctrlMapScreenToWorld _pos;
|
||||
};
|
||||
case (!isNull findDisplay 52): {
|
||||
_pos = (findDisplay 52 displayCtrl 51) ctrlMapScreenToWorld _pos;
|
||||
};
|
||||
case (!isNull findDisplay 53): {
|
||||
_pos = (findDisplay 53 displayCtrl 51) ctrlMapScreenToWorld _pos;
|
||||
};
|
||||
};
|
||||
|
||||
// set and send marker data the next frame. the actual marker isn't created yet
|
||||
[
|
||||
{
|
||||
|
||||
[{
|
||||
[QGVAR(setMarkerNetwork), [
|
||||
allMapMarkers select (count allMapMarkers - 1), [
|
||||
GETGVAR(currentMarkerConfigName,""),
|
||||
GETGVAR(currentMarkerColorConfigName,""),
|
||||
_this,
|
||||
GETGVAR(currentMarkerPosition,[]),
|
||||
GETGVAR(currentMarkerAngle,0)
|
||||
]
|
||||
]] call EFUNC(common,globalEvent);
|
||||
|
||||
},
|
||||
_pos
|
||||
] call EFUNC(common,execNextFrame);
|
||||
|
||||
}, []] call EFUNC(common,execNextFrame);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user