mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Use DrawIcon for map tools
This commit is contained in:
parent
04d94bb7be
commit
2ad9193475
@ -28,7 +28,7 @@ GVAR(drawing_controls) = [36732, 36733, 36734, 36735, 36736, 36737];
|
||||
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["MouseMoving", {_this call FUNC(handleMouseMove);}];
|
||||
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}];
|
||||
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}];
|
||||
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["Draw", {[] call FUNC(updateMapToolMarkers);}];
|
||||
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapToolMarkers);}];
|
||||
(finddisplay _d) displayAddEventHandler ["KeyDown", {_this call FUNC(handleKeyDown);}];
|
||||
};
|
||||
|
||||
|
@ -31,72 +31,72 @@ if (_button != 0) exitWith {};
|
||||
|
||||
// If releasing
|
||||
if (_dir != 1 && (GVAR(mapTool_isDragging) or GVAR(mapTool_isRotating))) exitWith {
|
||||
GVAR(mapTool_isDragging) = false;
|
||||
GVAR(mapTool_isRotating) = false;
|
||||
_handled = true;
|
||||
_handled
|
||||
GVAR(mapTool_isDragging) = false;
|
||||
GVAR(mapTool_isRotating) = false;
|
||||
_handled = true;
|
||||
_handled
|
||||
};
|
||||
|
||||
// If clicking
|
||||
if (_dir == 1) exitWith {
|
||||
|
||||
if !(call FUNC(canDraw)) exitWith {_handled = false;};
|
||||
if !(call FUNC(canDraw)) exitWith {_handled = false;};
|
||||
|
||||
// Transform mouse screen position to coordinates
|
||||
_pos = _control ctrlMapScreenToWorld _screenPos;
|
||||
_pos set [count _pos, 0];
|
||||
// Transform mouse screen position to coordinates
|
||||
_pos = _control ctrlMapScreenToWorld _screenPos;
|
||||
_pos set [count _pos, 0];
|
||||
|
||||
if (GVAR(drawing_isDrawing)) exitWith {
|
||||
// Already drawing -> Add tempLineMarker to permanent list
|
||||
if (GVAR(drawing_syncMarkers)) then {
|
||||
deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0);
|
||||
// [GVAR(drawing_tempLineMarker), "FUNC(addLineMarker)", 2] call EFUNC(common,execRemoteFnc);
|
||||
["drawing_addLineMarker", GVAR(drawing_tempLineMarker)] call EFUNC(common,globalEvent);
|
||||
// Log who drew on the briefing screen
|
||||
(text format ["[ACE] Server: Player %1 drew on the briefing screen", name player]) call EFUNC(common,serverLog);
|
||||
} else {
|
||||
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
|
||||
GVAR(drawing_lineMarkers) pushBack (+GVAR(drawing_tempLineMarker));
|
||||
if (GVAR(drawing_isDrawing)) exitWith {
|
||||
// Already drawing -> Add tempLineMarker to permanent list
|
||||
if (GVAR(drawing_syncMarkers)) then {
|
||||
deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0);
|
||||
// [GVAR(drawing_tempLineMarker), "FUNC(addLineMarker)", 2] call EFUNC(common,execRemoteFnc);
|
||||
["drawing_addLineMarker", GVAR(drawing_tempLineMarker)] call EFUNC(common,globalEvent);
|
||||
// Log who drew on the briefing screen
|
||||
(text format ["[ACE] Server: Player %1 drew on the briefing screen", name player]) call EFUNC(common,serverLog);
|
||||
} else {
|
||||
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
|
||||
GVAR(drawing_lineMarkers) pushBack (+GVAR(drawing_tempLineMarker));
|
||||
};
|
||||
GVAR(drawing_tempLineMarker) = [];
|
||||
GVAR(drawing_isDrawing) = false;
|
||||
_handled = true;
|
||||
};
|
||||
GVAR(drawing_tempLineMarker) = [];
|
||||
GVAR(drawing_isDrawing) = false;
|
||||
_handled = true;
|
||||
};
|
||||
|
||||
if (_altKey) exitWith {
|
||||
// Start drawing
|
||||
GVAR(drawing_isDrawing) = true;
|
||||
// Create tempLineMarker
|
||||
_gui = format ["%1%2%3%4", random (100), random (100), random (100), random (100)];
|
||||
GVAR(drawing_tempLineMarker) = [_gui, + _pos, + _pos, GVAR(drawing_drawColor)];
|
||||
_marker = createMarkerLocal [_gui, [0,0]];
|
||||
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
|
||||
_handled = true;
|
||||
};
|
||||
|
||||
GVAR(mapTool_isDragging) = false;
|
||||
GVAR(mapTool_isRotating) = false;
|
||||
|
||||
// If no map tool marker then exit
|
||||
if (isNil QGVAR(mapTool_markerRotatingFixed)) exitWith {_handled = false;};
|
||||
|
||||
// Check if clicking the maptool
|
||||
if (_pos call FUNC(isInsideMapTool)) exitWith {
|
||||
// Store data for dragging
|
||||
GVAR(mapTool_startPos) = + GVAR(mapTool_pos);
|
||||
GVAR(mapTool_startDragPos) = + _pos;
|
||||
if (_ctrlKey) then {
|
||||
// Store data for rotating
|
||||
GVAR(mapTool_startAngle) = + GVAR(mapTool_angle);
|
||||
GVAR(mapTool_startDragAngle) = (180 + ((GVAR(mapTool_startDragPos) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mapTool_startDragPos) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360);
|
||||
// Start rotating
|
||||
GVAR(mapTool_isRotating) = true;
|
||||
} else {
|
||||
// Start dragging
|
||||
GVAR(mapTool_isDragging) = true;
|
||||
if (_altKey) exitWith {
|
||||
// Start drawing
|
||||
GVAR(drawing_isDrawing) = true;
|
||||
// Create tempLineMarker
|
||||
_gui = format ["%1%2%3%4", random (100), random (100), random (100), random (100)];
|
||||
GVAR(drawing_tempLineMarker) = [_gui, + _pos, + _pos, GVAR(drawing_drawColor)];
|
||||
_marker = createMarkerLocal [_gui, [0,0]];
|
||||
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
|
||||
_handled = true;
|
||||
};
|
||||
|
||||
GVAR(mapTool_isDragging) = false;
|
||||
GVAR(mapTool_isRotating) = false;
|
||||
|
||||
// If no map tool marker then exit
|
||||
if (GVAR(mapTool_Shown) == 0) exitWith {_handled = false;};
|
||||
|
||||
// Check if clicking the maptool
|
||||
if (_pos call FUNC(isInsideMapTool)) exitWith {
|
||||
// Store data for dragging
|
||||
GVAR(mapTool_startPos) = + GVAR(mapTool_pos);
|
||||
GVAR(mapTool_startDragPos) = + _pos;
|
||||
if (_ctrlKey) then {
|
||||
// Store data for rotating
|
||||
GVAR(mapTool_startAngle) = + GVAR(mapTool_angle);
|
||||
GVAR(mapTool_startDragAngle) = (180 + ((GVAR(mapTool_startDragPos) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mapTool_startDragPos) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360);
|
||||
// Start rotating
|
||||
GVAR(mapTool_isRotating) = true;
|
||||
} else {
|
||||
// Start dragging
|
||||
GVAR(mapTool_isDragging) = true;
|
||||
};
|
||||
_handled = true;
|
||||
};
|
||||
_handled = true;
|
||||
};
|
||||
};
|
||||
|
||||
_handled
|
||||
|
@ -37,7 +37,7 @@ if (GVAR(drawing_isDrawing)) exitWith {
|
||||
};
|
||||
|
||||
// Handle Map tools
|
||||
if (isNil QGVAR(mapTool_markerRotatingFixed)) exitWith {false};
|
||||
if (GVAR(mapTool_Shown) == 0) exitWith {false};
|
||||
|
||||
// Translation
|
||||
if (GVAR(mapTool_isDragging)) exitWith {
|
||||
|
@ -18,6 +18,8 @@
|
||||
#define DIST_TOP_TO_CENTER_PERC 0.65
|
||||
#define DIST_LEFT_TO_CENTER_PERC 0.30
|
||||
|
||||
|
||||
|
||||
if (GVAR(mapTool_Shown) == 0) exitWith {false};
|
||||
_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1);
|
||||
|
||||
|
@ -18,13 +18,6 @@ if (GVAR(mapVisableLastFrame) && (!visibleMap)) then {
|
||||
GVAR(mapVisableLastFrame) = false;
|
||||
// Hide GPS
|
||||
[false] call FUNC(openMapGps);
|
||||
// Hide Map tools
|
||||
deleteMarkerLocal MARKERNAME_MAPTOOL_FIXED;
|
||||
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGNORMAL;
|
||||
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGSMALL;
|
||||
GVAR(mapTool_markerRotatingFixed) = nil;
|
||||
GVAR(mapTool_markerRotatingNormal) = nil;
|
||||
GVAR(mapTool_markerRotatingSmall) = nil;
|
||||
// Cancel drawing
|
||||
call FUNC(cancelDrawing);
|
||||
};
|
||||
|
@ -1,10 +1,9 @@
|
||||
/*
|
||||
* Author: esteldunedain
|
||||
*
|
||||
* Update the map tool markers, position, size, rotation and visibility.
|
||||
*
|
||||
* Argument:
|
||||
* None
|
||||
* Arguments:
|
||||
* 0: The Map <CONTROL>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
@ -16,58 +15,31 @@
|
||||
#define CENTER_OFFSET_Y_PERC 0.1606
|
||||
#define CONSTANT_SCALE 0.2
|
||||
|
||||
// If markers exist and they should'nt, delete them
|
||||
if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) == 0}) then {
|
||||
// If markers exist, delete them
|
||||
if (!isNil QGVAR(mapTool_markerRotatingFixed)) then {
|
||||
deleteMarkerLocal MARKERNAME_MAPTOOL_FIXED;
|
||||
GVAR(mapTool_markerRotatingFixed) = nil;
|
||||
};
|
||||
};
|
||||
if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) != 1}) then {
|
||||
if (!isNil QGVAR(mapTool_markerRotatingNormal)) then {
|
||||
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGNORMAL;
|
||||
GVAR(mapTool_markerRotatingNormal) = nil;
|
||||
};
|
||||
};
|
||||
if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) != 2}) then {
|
||||
if (!isNil QGVAR(mapTool_markerRotatingSmall)) then {
|
||||
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGSMALL;
|
||||
GVAR(mapTool_markerRotatingSmall) = nil;
|
||||
};
|
||||
};
|
||||
PARAMS_1(_theMap);
|
||||
|
||||
if (!("ACE_MapTools" in items ACE_player)|| {GVAR(mapTool_Shown) == 0}) exitWith {};
|
||||
|
||||
// If markers don't exist and should, create them
|
||||
if (isNil QGVAR(mapTool_markerRotatingFixed)) then {
|
||||
GVAR(mapTool_markerRotatingFixed) = createMarkerLocal [MARKERNAME_MAPTOOL_FIXED, GVAR(mapTool_pos)];
|
||||
MARKERNAME_MAPTOOL_FIXED setMarkerType MARKERNAME_MAPTOOL_FIXED;
|
||||
_rotatingTexture = "";
|
||||
_textureWidth = 0;
|
||||
if (GVAR(mapTool_Shown) == 1) then {
|
||||
_rotatingTexture = QUOTE(PATHTOF(data\mapToolRotatingNormal.paa));
|
||||
_textureWidth = TEXTURE_WIDTH_IN_M;
|
||||
} else {
|
||||
_rotatingTexture = QUOTE(PATHTOF(data\mapToolRotatingSmall.paa));
|
||||
_textureWidth = TEXTURE_WIDTH_IN_M / 2;
|
||||
};
|
||||
if ((isNil QGVAR(mapTool_markerRotatingNormal)) && {GVAR(mapTool_Shown) == 1}) then {
|
||||
GVAR(mapTool_markerRotatingNormal) = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGNORMAL, GVAR(mapTool_pos)];
|
||||
MARKERNAME_MAPTOOL_ROTATINGNORMAL setMarkerType MARKERNAME_MAPTOOL_ROTATINGNORMAL;
|
||||
};
|
||||
if ((isNil QGVAR(mapTool_markerRotatingSmall)) && {GVAR(mapTool_Shown) == 2}) then {
|
||||
GVAR(mapTool_markerRotatingSmall) = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGSMALL, GVAR(mapTool_pos)];
|
||||
MARKERNAME_MAPTOOL_ROTATINGSMALL setMarkerType MARKERNAME_MAPTOOL_ROTATINGSMALL;
|
||||
};
|
||||
|
||||
_rotatingMarker = [MARKERNAME_MAPTOOL_ROTATINGNORMAL, MARKERNAME_MAPTOOL_ROTATINGSMALL] select (GVAR(mapTool_Shown) - 1);
|
||||
_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1);
|
||||
|
||||
// Update scale of both parts
|
||||
_scale = _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale));
|
||||
MARKERNAME_MAPTOOL_FIXED setMarkerSizeLocal [_scale,_scale];
|
||||
_rotatingMarker setMarkerSizeLocal [_scale,_scale];
|
||||
_scale = _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale));
|
||||
|
||||
// Position of the fixed part
|
||||
_xPos = GVAR(mapTool_pos) select 0;
|
||||
_yPos = (GVAR(mapTool_pos) select 1) + _textureWidth * CENTER_OFFSET_Y_PERC;
|
||||
MARKERNAME_MAPTOOL_FIXED setMarkerPosLocal [_xPos,_yPos];
|
||||
|
||||
_theMap drawIcon [QUOTE(PATHTOF(data\mapToolFixed.paa)), [1,1,1,1], [_xPos,_yPos], (32 * _scale), (32 * _scale), 0, "", 0];
|
||||
|
||||
// Position and rotation of the rotating part
|
||||
_xPos = (GVAR(mapTool_pos) select 0) + sin(GVAR(mapTool_angle)) * _textureWidth * CENTER_OFFSET_Y_PERC;
|
||||
_yPos = (GVAR(mapTool_pos) select 1) + cos(GVAR(mapTool_angle)) * _textureWidth * CENTER_OFFSET_Y_PERC;
|
||||
_rotatingMarker setMarkerPosLocal [_xPos,_yPos];
|
||||
_rotatingMarker setMarkerDirLocal GVAR(mapTool_angle);
|
||||
|
||||
_theMap drawIcon [_rotatingTexture, [1,1,1,1], [_xPos,_yPos], (32 * _scale), (32 * _scale), GVAR(mapTool_angle), "", 0];
|
||||
|
Loading…
Reference in New Issue
Block a user