Skip to content

Instantly share code, notes, and snippets.

@commy2
Last active March 30, 2019 14:10
Show Gist options
  • Save commy2/12b4311d62dd5bdd659febc1eb3f7603 to your computer and use it in GitHub Desktop.
Save commy2/12b4311d62dd5bdd659febc1eb3f7603 to your computer and use it in GitHub Desktop.
// open respawn screen
private _mission = uiNamespace getVariable "RscDisplayMission";
private _display = _mission createDisplay "RscDisplayEmpty";
private _vignette = _display displayCtrl 1202;
_vignette ctrlShow false;
private _map = _display ctrlCreate ["RscMapControl", -1];
_display setVariable ["PZG_respawnPositions", []];
_display setVariable ["PZG_respawnMarkers", []];
_display setVariable ["PZG_selectedSpawn", objNull];
_map ctrlSetPosition [safezoneX, safezoneY, safezoneW, safezoneH];
_map ctrlCommit 0;
// selected respawn marker
private _selectedMarker = "PZG_respawnMarker_selected";
createMarkerLocal [_selectedMarker, [0,0,0]];
_selectedMarker setMarkerShapeLocal "ICON";
_selectedMarker setMarkerTypeLocal "mil_circle_noShadow";
_selectedMarker setMarkerSizeLocal [1.25,1.25];
_selectedMarker setMarkerColorLocal "ColorOrange";
// confirm
private _confirm = _display ctrlCreate ["RscLoadingText", 1]; // centered RscText
private _width = safezoneW*0.8;
private _height = safezoneH/25;
_confirm ctrlSetPosition [
0.5 - _width/2,
safezoneY + safezoneH - 1.1 * _height,
_width, _height
];
_confirm ctrlCommit 0;
_confirm ctrlAddEventHandler ["KillFocus", {
_this spawn {ctrlSetFocus (_this select 0)};
}];
_confirm ctrlSetText toUpper "Respawn";
_confirm ctrlSetFont "PuristaLight";
_confirm ctrlSetBackgroundColor [0,0,0,0.8];
_confirm ctrlEnable true;
ctrlSetFocus _confirm;
_confirm ctrlAddEventHandler ["MouseButtonDown", {
params ["_confirm", "_button"];
if (_button != 0) exitWith {};
private _display = ctrlParent _confirm;
private _spawn = _display getVariable "PZG_selectedSpawn";
if (alive _spawn) then {
[_display] spawn {(_this select 0) closeDisplay 0};
player setPosASL getPosASL _spawn;
};
}];
// draw and event scripts
_map ctrlAddEventHandler ["Draw", {
params ["_map"];
private _display = ctrlParent _map;
private _markers = _display getVariable "PZG_respawnMarkers";
private _prevSpawns = _display getVariable "PZG_respawnPositions";
private _currSpawns = entities [["B_Truck_01_mover_F"], [], true, true];
if !(_prevSpawns isEqualTo _currSpawns) then {
_display setVariable ["PZG_respawnPositions", _currSpawns];
{
deleteMarkerLocal _x;
} forEach _markers;
_markers = [];
_display setVariable ["PZG_respawnMarkers", _markers];
{
private _marker = format ["PZG_respawnMarker_%1", _forEachIndex];
_markers pushBack _marker;
createMarkerLocal [_marker, [0,0,0]];
_marker setMarkerShapeLocal "ICON";
_marker setMarkerTypeLocal "respawn_inf";
} forEach _currSpawns;
};
private _selectedSpawn = _display getVariable "PZG_selectedSpawn";
"PZG_respawnMarker_selected" setMarkerPosLocal getPosWorld _selectedSpawn;
private _confirm = _display displayCtrl 1;
if (alive _selectedSpawn) then {
_confirm ctrlSetTextColor [1,1,1,1];
} else {
_confirm ctrlSetTextColor [0.5,0.5,0.5,1];
};
{
private _marker = _markers select _forEachIndex;
_marker setMarkerPosLocal getPosWorld _x;
private _color = "ColorGreen";
if (!alive _x) then {
_color = "ColorGrey";
};
_marker setMarkerColorLocal _color;
} forEach _currSpawns;
}];
_map ctrlAddEventHandler ["MouseButtonDown", {
params ["_map", "_button"];
if (_button != 0) exitWith {};
private _display = ctrlParent _map;
private _markers = _display getVariable "PZG_respawnMarkers";
private _spawns = _display getVariable "PZG_respawnPositions";
ctrlMapMouseOver _map params [["_type", ""], "_marker"];
if (_type == "Marker" && {_marker in _markers}) then {
private _spawn = _spawns select (_markers find _marker);
_display setVariable ["PZG_selectedSpawn", _spawn];
};
}];
_display displayAddEventHandler ["Unload", {
params ["_display"];
deleteMarkerLocal "PZG_respawnMarker_selected";
private _markers = _display getVariable "PZG_respawnMarkers";
{
deleteMarkerLocal _x;
} forEach _markers;
}];
_display displayAddEventHandler ["KeyDown", {true}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment