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

Map - Fix effects breaking mid mission #6566

Merged
merged 9 commits into from
Oct 21, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions addons/map/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ class Extended_PostInit_EventHandlers {
serverInit = QUOTE(call COMPILE_FILE(XEH_postInitServer));
};
};

class Extended_DisplayLoad_EventHandlers {
class RscDiary {
GVAR(initMainMap) = QUOTE((_this select 0) call (uiNamespace getVariable 'FUNC(initMainMap)'));
};
};
1 change: 1 addition & 0 deletions addons/map/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ PREP(onDrawMap);
PREP(simulateMapLight);
PREP(switchFlashlight);
PREP(updateMapEffects);
PREP(initMainMap);
46 changes: 0 additions & 46 deletions addons/map/XEH_postInitClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,6 @@ LOG(MSG_INIT);
// Calculate the maximum zoom allowed for this map
call FUNC(determineZoom);

[{
if (isNull findDisplay 12) exitWith {};
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved

GVAR(lastStillPosition) = ((findDisplay 12) displayCtrl 51) ctrlMapScreenToWorld [0.5, 0.5];
GVAR(lastStillTime) = CBA_missionTime;
GVAR(isShaking) = false;

//map sizes are multiples of 1280
GVAR(worldSize) = worldSize / 1280;
GVAR(mousePos) = [0.5,0.5];

//Allow panning the lastStillPosition while mapShake is active
GVAR(rightMouseButtonLastPos) = [];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapEffects)}];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {
if (GVAR(isShaking) && {(count GVAR(rightMouseButtonLastPos)) == 2}) then {
private _lastPos = (_this select 0) ctrlMapScreenToWorld GVAR(rightMouseButtonLastPos);
private _newPos = (_this select 0) ctrlMapScreenToWorld (_this select [1,2]);
GVAR(lastStillPosition) set [0, (GVAR(lastStillPosition) select 0) + (_lastPos select 0) - (_newPos select 0)];
GVAR(lastStillPosition) set [1, (GVAR(lastStillPosition) select 1) + (_lastPos select 1) - (_newPos select 1)];
GVAR(rightMouseButtonLastPos) = _this select [1,2];
TRACE_3("Mouse Move",_lastPos,_newPos,GVAR(rightMouseButtonLastPos));
};
}];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", {
if ((_this select 1) == 1) then {
GVAR(rightMouseButtonLastPos) = _this select [2,2];
};
}];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", {
if ((_this select 1) == 1) then {
GVAR(rightMouseButtonLastPos) = [];
};
}];

//get mouse position on map
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {
GVAR(mousePos) = (_this select 0) ctrlMapScreenToWorld [_this select 1, _this select 2];
}];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseHolding", {
GVAR(mousePos) = (_this select 0) ctrlMapScreenToWorld [_this select 1, _this select 2];
}];

[_this select 1] call CBA_fnc_removePerFrameHandler;
}, 0] call CBA_fnc_addPerFrameHandler;

["ace_settingsInitialized", {
if (isMultiplayer && {GVAR(DefaultChannel) != -1}) then {
//Set the chat channel once the map has finished loading
Expand Down
56 changes: 56 additions & 0 deletions addons/map/functions/fnc_initMainMap.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc"

params ["_display"];
if (ctrlIDD _display != IDD_MAIN_MAP) exitWith {};

private _control = _display displayCtrl IDC_MAP;

GVAR(lastStillPosition) = _control ctrlMapScreenToWorld [0.5, 0.5];
GVAR(lastStillTime) = CBA_missionTime;
GVAR(isShaking) = false;

//map sizes are multiples of 1280
GVAR(worldSize) = worldSize / 1280;
GVAR(mousePos) = [0.5, 0.5];

//Allow panning the lastStillPosition while mapShake is active
GVAR(rightMouseButtonLastPos) = [];

_control ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapEffects)}];
_control ctrlAddEventHandler ["MouseMoving", {
params ["_control", "_x", "_y"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could move inside the if

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that's worth it, tbh.

if (GVAR(isShaking) && {count GVAR(rightMouseButtonLastPos) == 2}) then {
private _lastPos = _control ctrlMapScreenToWorld GVAR(rightMouseButtonLastPos);
private _newPos = _control ctrlMapScreenToWorld [_x, _y];
GVAR(lastStillPosition) set [0, (GVAR(lastStillPosition) select 0) + (_lastPos select 0) - (_newPos select 0)];
GVAR(lastStillPosition) set [1, (GVAR(lastStillPosition) select 1) + (_lastPos select 1) - (_newPos select 1)];
GVAR(rightMouseButtonLastPos) = [_x, _y];
TRACE_3("Mouse Move",_lastPos,_newPos,GVAR(rightMouseButtonLastPos));
};
}];

_control ctrlAddEventHandler ["MouseButtonDown", {
params ["", "_button", "_x", "_y"];
if (_button == 1) then {
GVAR(rightMouseButtonLastPos) = [_x, _y];
};
}];

_control ctrlAddEventHandler ["MouseButtonUp", {
params ["", "_button"];
if (_button == 1) then {
GVAR(rightMouseButtonLastPos) = [];
};
}];

//get mouse position on map
_control ctrlAddEventHandler ["MouseMoving", {
params ["_control", "_x", "_y"];
GVAR(mousePos) = _control ctrlMapScreenToWorld [_x, _y];
}];

_control ctrlAddEventHandler ["MouseHolding", {
params ["_control", "_x", "_y"];
GVAR(mousePos) = _control ctrlMapScreenToWorld [_x, _y];
}];
1 change: 0 additions & 1 deletion addons/map/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "\z\ace\addons\main\script_macros.hpp"


#define MARKERNAME_MAPTOOL_FIXED "ACE_MapToolFixed"
#define MARKERNAME_MAPTOOL_ROTATINGNORMAL "ACE_MapToolRotatingNormal"
#define MARKERNAME_MAPTOOL_ROTATINGSMALL "ACE_MapToolRotatingSmall"