Update 'xileClient_gui_selectSpawnLocation_show.sqf'

This commit is contained in:
Zepheris 2018-03-04 22:26:08 -07:00
parent abd78249cb
commit 3710c81d89

View File

@ -1,184 +1,184 @@
private["_display","_spawnButton","_listBox","_listItemIndex","_numberOfSpawnPoints","_randNum","_randData","_randomSpawnIndex"]; private["_display","_spawnButton","_listBox","_listItemIndex","_numberOfSpawnPoints","_randNum","_randData","_randomSpawnIndex"];
if(isNil "spawnRegistry") then if(isNil "spawnRegistry") then
{ {
spawnRegistry = []; spawnRegistry = [];
}; };
fn_checkRespawnDelay = { fn_checkRespawnDelay = {
_markerName = _this select 0; _markerName = _this select 0;
if(isNil "_markerName") exitWith { diag_log "checkRespawn: invalid parameter 1"; true; }; if(isNil "_markerName") exitWith { diag_log "checkRespawn: invalid parameter 1"; true; };
diag_log format["checkRespawn: Checking flag %1...", _markerName]; diag_log format["checkRespawn: Checking flag %1...", _markerName];
_counter = 0; _counter = 0;
{ {
_name = _x select 0; _name = _x select 0;
_time = _x select 1; _time = _x select 1;
if(isNil "_name") exitWith { true; }; if(isNil "_name") exitWith { true; };
if(isNil "_time") exitWith { true; }; if(isNil "_time") exitWith { true; };
diag_log format["checkRespawn: checking flag %1, with reg %2", _markerName, _name]; diag_log format["checkRespawn: checking flag %1, with reg %2", _markerName, _name];
if(_name isEqualTo _markerName) then if(_name isEqualTo _markerName) then
{ {
if(_time > time-300) then if(_time > time-300) then
{ {
_counter = _counter + 1; _counter = _counter + 1;
}; };
}; };
} forEach spawnRegistry; } forEach spawnRegistry;
diag_log format["checkRespawn: counter for flag %1 = %2",_markerName, _counter]; diag_log format["checkRespawn: counter for flag %1 = %2",_markerName, _counter];
if(_counter >= 1) exitWith if(_counter >= 1) exitWith
{ {
diag_log format["checkRespawn: returned false"]; diag_log format["checkRespawn: returned false"];
false; false;
}; };
diag_log format["checkRespawn: returned true"]; diag_log format["checkRespawn: returned true"];
true; true;
}; };
disableSerialization; disableSerialization;
diag_log "Selecting spawn location..."; diag_log "Selecting spawn location...";
ExileClientSpawnLocationSelectionDone = false; ExileClientSpawnLocationSelectionDone = false;
ExileClientSelectedSpawnLocationMarkerName = ""; ExileClientSelectedSpawnLocationMarkerName = "";
createDialog "RscExileSelectSpawnLocationDialog"; createDialog "RscExileSelectSpawnLocationDialog";
waitUntil {_display = findDisplay 24002;!isNull _display}; waitUntil {_display = findDisplay 24002;!isNull _display};
_display displayAddEventHandler ["KeyDown", "_this call ExileClient_gui_loadingScreen_event_onKeyDown"]; _display displayAddEventHandler ["KeyDown", "_this call ExileClient_gui_loadingScreen_event_onKeyDown"];
_listBox = _display displayCtrl 24002; _listBox = _display displayCtrl 24002;
lbClear _listBox; lbClear _listBox;
{ {
if (getMarkerType _x == "ExileSpawnZone") then if (getMarkerType _x == "ExileSpawnZone") then
{ {
_name = markerText _x; _name = markerText _x;
if(! ( [_name] call fn_checkRespawnDelay) ) exitWith { diag_log format["checkRespawn returned false for spawn zone: %1, respawn disabled",_name]; }; if(! ( [_name] call fn_checkRespawnDelay) ) exitWith { diag_log format["checkRespawn returned false for spawn zone: %1, respawn disabled",_name]; };
diag_log format["Adding spawn zone: %1",markerText _x]; diag_log format["Adding spawn zone: %1",markerText _x];
_listItemIndex = _listBox lbAdd (markerText _x); _listItemIndex = _listBox lbAdd (markerText _x);
_listBox lbSetData [_listItemIndex, _x]; _listBox lbSetData [_listItemIndex, _x];
}; };
} forEach allMapMarkers; } forEach allMapMarkers;
// _numberOfSpawnPoints = {getMarkerType _x == "ExileSpawnZone"} count allMapMarkers; // _numberOfSpawnPoints = {getMarkerType _x == "ExileSpawnZone"} count allMapMarkers;
// if(_numberOfSpawnPoints > 0)then // if(_numberOfSpawnPoints > 0)then
// { // {
// _randNum = floor(random _numberOfSpawnPoints); // _randNum = floor(random _numberOfSpawnPoints);
// _randData = lbData [24002,_randNum]; // _randData = lbData [24002,_randNum];
// _randomSpawnIndex = _listBox lbAdd "Random"; // _randomSpawnIndex = _listBox lbAdd "Random";
// _listBox lbSetData [_randomSpawnIndex, _randData]; // _listBox lbSetData [_randomSpawnIndex, _randData];
// }; // };
defaultLBsize = lbSize _listBox; defaultLBsize = lbSize _listBox;
myUID = getPlayerUID player; myUID = getPlayerUID player;
myFlags = []; myFlags = [];
{ {
_flag = _x; _flag = _x;
_owner = _flag getVariable ["ExileOwnerUID", ""]; _owner = _flag getVariable ["ExileOwnerUID", ""];
_arrBuildRights = _x getVariable["ExileTerritoryBuildRights",[]]; // by Nerexis _arrBuildRights = _x getVariable["ExileTerritoryBuildRights",[]]; // by Nerexis
if(myUID isEqualTo _owner OR ( !(isNil "_arrBuildRights") AND (count _arrBuildRights>0) AND (myUID in _arrBuildRights) ) )then if(myUID isEqualTo _owner OR ( !(isNil "_arrBuildRights") AND (count _arrBuildRights>0) AND (myUID in _arrBuildRights) ) )then
{ {
_name = _flag getVariable ["ExileTerritoryName", ""]; _name = _flag getVariable ["ExileTerritoryName", ""];
if(! ( [_name] call fn_checkRespawnDelay) ) exitWith { diag_log format["checkRespawn returned false for flag: %1, respawn disabled",_name]; }; if(! ( [_name] call fn_checkRespawnDelay) ) exitWith { diag_log format["checkRespawn returned false for flag: %1, respawn disabled",_name]; };
_lbid = _listBox lbAdd (_flag getVariable ["ExileTerritoryName", ""]); _lbid = _listBox lbAdd (_flag getVariable ["ExileTerritoryName", ""]);
_listBox lbSetColor [_lbid, [0,0.68,1,1]]; _listBox lbSetColor [_lbid, [0,0.68,1,1]];
_listBox lbSetData [_lbid,str(count myFlags)]; _listBox lbSetData [_lbid,str(count myFlags)];
myFlags pushBack _flag; myFlags pushBack _flag;
// localmarkerName = format['LOCALFLAG_%1',myUID]; // localmarkerName = format['LOCALFLAG_%1',myUID];
// deleteMarkerLocal localmarkerName; // deleteMarkerLocal localmarkerName;
// _marker = createMarkerLocal [localmarkerName,getPosATL _flag]; // _marker = createMarkerLocal [localmarkerName,getPosATL _flag];
// _marker setMarkerShapeLocal "ICON"; // _marker setMarkerShapeLocal "ICON";
// _marker setMarkerTypeLocal "loc_Bunker"; // _marker setMarkerTypeLocal "loc_Bunker";
// _marker setMarkerColorLocal "ColorGreen"; // _marker setMarkerColorLocal "ColorGreen";
// _marker setMarkerSize [3, 3]; // _marker setMarkerSize [3, 3];
// _marker setMarkerTextLocal (_flag getVariable ["ExileTerritoryName", ""]); // _marker setMarkerTextLocal (_flag getVariable ["ExileTerritoryName", ""]);
}; };
} forEach (allMissionObjects "Exile_Construction_Flag_Static"); } forEach (allMissionObjects "Exile_Construction_Flag_Static");
fnc_LBSelChanged_24002 = { fnc_LBSelChanged_24002 = {
disableSerialization; disableSerialization;
_ctrl = _this select 0; _ctrl = _this select 0;
_curSel = lbCurSel _ctrl; _curSel = lbCurSel _ctrl;
if(_curSel < defaultLBsize)then if(_curSel < defaultLBsize)then
{ {
_this call ExileClient_gui_selectSpawnLocation_event_onListBoxSelectionChanged; _this call ExileClient_gui_selectSpawnLocation_event_onListBoxSelectionChanged;
} }
else else
{ {
_data = _ctrl lbData _curSel; _data = _ctrl lbData _curSel;
_num = parseNumber _data; _num = parseNumber _data;
_flag = myFlags select _num; _flag = myFlags select _num;
markerName = format['FLAG_%1',myUID]; markerName = format['FLAG_%1',myUID];
deleteMarker markerName; deleteMarker markerName;
createMarker [markerName,getPosATL _flag]; createMarker [markerName,getPosATL _flag];
ExileClientSelectedSpawnLocationMarkerName = markerName; ExileClientSelectedSpawnLocationMarkerName = markerName;
// localmarkerName = format['LOCALFLAG_%1',myUID]; // localmarkerName = format['LOCALFLAG_%1',myUID];
// deleteMarkerLocal localmarkerName; // deleteMarkerLocal localmarkerName;
// _marker = createMarkerLocal [localmarkerName,getPosATL _flag]; // _marker = createMarkerLocal [localmarkerName,getPosATL _flag];
// _marker setMarkerShapeLocal "ICON"; // _marker setMarkerShapeLocal "ICON";
// _marker setMarkerTypeLocal "loc_Bunker"; // _marker setMarkerTypeLocal "loc_Bunker";
// _marker setMarkerColorLocal "ColorGreen"; // _marker setMarkerColorLocal "ColorGreen";
// _marker setMarkerSize [3, 3]; // _marker setMarkerSize [3, 3];
// _marker setMarkerTextLocal (_flag getVariable ["ExileTerritoryName", ""]); // _marker setMarkerTextLocal (_flag getVariable ["ExileTerritoryName", ""]);
_mapControl = (findDisplay 24002) displayCtrl 24001; _mapControl = (findDisplay 24002) displayCtrl 24001;
_mapControl ctrlMapAnimAdd [1, 0.1, getMarkerPos ExileClientSelectedSpawnLocationMarkerName]; _mapControl ctrlMapAnimAdd [1, 0.1, getMarkerPos ExileClientSelectedSpawnLocationMarkerName];
ctrlMapAnimCommit _mapControl; ctrlMapAnimCommit _mapControl;
}; };
}; };
_listBox ctrlRemoveAllEventHandlers "LBSelChanged"; _listBox ctrlRemoveAllEventHandlers "LBSelChanged";
_listBox ctrlAddEventHandler ["LBSelChanged", "_this call fnc_LBSelChanged_24002;"]; _listBox ctrlAddEventHandler ["LBSelChanged", "_this call fnc_LBSelChanged_24002;"];
fnc_ButtonClick_24003 = { fnc_ButtonClick_24003 = {
disableSerialization; disableSerialization;
_display = nil; _display = nil;
waitUntil {_display = findDisplay 24002;!isNull _display}; waitUntil {_display = findDisplay 24002;!isNull _display};
_lB = _display displayCtrl 24002; _lB = _display displayCtrl 24002;
_curSel = lbCurSel _lB; _curSel = lbCurSel _lB;
_data = _lB lbData _curSel; _data = _lB lbData _curSel;
_num = parseNumber _data; _num = parseNumber _data;
_flag = myFlags select _num; _flag = myFlags select _num;
_name = lbText [24002, _curSel]; //_flag getVariable ["ExileTerritoryName", ""]; _name = lbText [24002, _curSel]; //_flag getVariable ["ExileTerritoryName", ""];
//spawnRegistry pushBack [_name, time]; //spawnRegistry pushBack [_name, time];
spawnRegistry pushBack [_name, time]; spawnRegistry pushBack [_name, time];
//diag_log format["Plr selected spawn %1", lbText [24002, _curSel]]; //diag_log format["Plr selected spawn %1", lbText [24002, _curSel]];
diag_log format["Plr respawning at flag %1 - time: %2",_name, _time]; diag_log format["Plr respawning at flag %1 - time: %2",_name, _time];
[] call ExileClient_gui_selectSpawnLocation_event_onSpawnButtonClick; [] call ExileClient_gui_selectSpawnLocation_event_onSpawnButtonClick;
// if(!isNil 'markerName')then // if(!isNil 'markerName')then
// { // {
// [] spawn { // [] spawn {
// waitUntil {!isNil 'ExileClientLoadedIn'}; // waitUntil {!isNil 'ExileClientLoadedIn'};
// uiSleep 3; // uiSleep 3;
// deleteMarker markerName; // deleteMarker markerName;
// deleteMarkerLocal localmarkerName; // deleteMarkerLocal localmarkerName;
// }; // };
// }; // };
}; };
_spawnButton = _display displayCtrl 24003; _spawnButton = _display displayCtrl 24003;
_spawnButton ctrlRemoveAllEventHandlers "ButtonClick"; _spawnButton ctrlRemoveAllEventHandlers "ButtonClick";
_spawnButton ctrlSetEventHandler["ButtonClick","call fnc_ButtonClick_24003"]; _spawnButton ctrlSetEventHandler["ButtonClick","call fnc_ButtonClick_24003"];
_spawnButton ctrlSetText "Spawn!"; _spawnButton ctrlSetText "Spawn!";
_spawnButton ctrlEnable true; _spawnButton ctrlEnable true;
_spawnButton ctrlCommit 0; _spawnButton ctrlCommit 0;
true true