Skip to content
Open
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
52 changes: 44 additions & 8 deletions addons/ui/fnc_initDisplayRemoteMissions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ private _authorFullLocalized = localize "STR_FORMAT_AUTHOR_SCRIPTED";
_worldFeatures set [_worldName, [_pictureMap, _author]];
} forEach (configProperties [configFile >> "CfgWorldList", "isClass _x"]);

// Show worldnames as tooltips on map list
for "_index" from 0 to ((lbSize _ctrlMaps) - 1) do {
private _description = _ctrlMaps lbText _index;
private _worldName = _worldNames getOrDefault [_description, ""];
_ctrlMaps lbSetTooltip [_index, _worldName];
};

_ctrlMaps setVariable [QGVAR(worldFeatures), _worldFeatures];

ctrlPosition _ctrlMaps params ["_mapsLeft", "_mapsTop", "_mapsWidth", "_mapsHeight"];
Expand Down Expand Up @@ -83,6 +76,42 @@ _ctrlMaps ctrlAddEventHandler ["LBSelChanged", {
lbSort _ctrlMaps;
_ctrlMaps lbSetCurSel 0;

private _worldSelected = uiNamespace getVariable [QGVAR(lastWorld), ""];
if (_worldSelected isEqualTo "" || {!(_worldSelected isEqualType "")}) then {
// worldName == last loaded world
// when startup parameter -world=empty and game is just started, worldName == ""
_worldSelected = worldName;
};

// Show worldnames as tooltips on map list
for "_index" from 0 to ((lbSize _ctrlMaps) - 1) do {
private _description = _ctrlMaps lbText _index;
private _worldName = _worldNames getOrDefault [_description, ""];
_ctrlMaps lbSetTooltip [_index, _worldName];
if (_worldName == _worldSelected) then {
_ctrlMaps lbSetCurSel _index;
};
};

private _fnc_onMissionSelected = {
params ["_ctrl"];
private _display = ctrlParent _ctrl;

private _ctrlMaps = _display displayCtrl IDC_SERVER_ISLAND;
private _worldSelected = _ctrlMaps lbData lbCurSel _ctrlMaps;
uiNamespace setVariable [QGVAR(lastWorld), _worldSelected];

private _ctrlMissions = _display displayCtrl IDC_SERVER_MISSION;
private _missionSelected = _ctrlMissions lbData lbCurSel _ctrlMissions;
uiNamespace setVariable [QGVAR(lastMission), _missionSelected];

false
};
private _ctrlOK = _display displayCtrl IDC_OK;
_ctrlOK ctrlAddEventHandler ["ButtonClick", _fnc_onMissionSelected];
_ctrlMissions ctrlAddEventHandler ["LBDblClick", _fnc_onMissionSelected];


ctrlPosition _ctrlMissions params ["_left", "_top", "_width", "_height"];

private _widthSearchBar = (_width - 11 * GUI_GRID_W) min (10 * GUI_GRID_W);
Expand Down Expand Up @@ -188,6 +217,8 @@ _display setVariable [QFUNC(filter), {
private _showStockMissions = profileNamespace getVariable [QGVAR(ShowStockMissions), true];

lbClear _ctrlMissions;
private _selectIndex = -1;
private _lastMission = uiNamespace getVariable [QGVAR(lastMission), ""];

{
_x params ["_name", "_value", "_data", "_color", "_picture", "_pictureRight"];
Expand All @@ -201,10 +232,15 @@ _display setVariable [QFUNC(filter), {
_ctrlMissions lbSetPicture [_index, _picture];
_ctrlMissions lbSetPictureRight [_index, _pictureRight];
_ctrlMissions lbSetTooltip [_index, format ["%1", _data]];
if (_selectIndex == -1 || {_data isEqualTo _lastMission}) then {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (_selectIndex == -1 || {_data isEqualTo _lastMission}) then {
if (_selectIndex isEqualTo -1 || _data isEqualTo _lastMission) then {

isEqualTo is faster than lazy eval. How big the _data is I don't have a clue, but it probly doesn't matter very much.

_selectIndex = _index;
};
};
} forEach _missions;

_ctrlMissions lbSetCurSel 0;
if (_selectIndex > -1) then {
_ctrlMissions lbSetCurSel _selectIndex;
};
}];

// update every time search parameters are changed
Expand Down