Skip to content

Commit

Permalink
add custom mission filter (#1066)
Browse files Browse the repository at this point in the history
* add custom mission filter

* check if class is a mission or a 'folder'
  • Loading branch information
commy2 authored Feb 16, 2019
1 parent c2534bf commit b1dbeff
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 47 deletions.
49 changes: 46 additions & 3 deletions addons/ui/fnc_initDisplayRemoteMissions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,67 @@ params ["_display"];
private _ctrlMaps = _display displayCtrl IDC_SERVER_ISLAND;
private _ctrlMissions = _display displayCtrl IDC_SERVER_MISSION;

// find all stock missions
private _stockMissions = [];

private _fnc_findMissions = {
{
if (isText (_x >> "directory")) then {
_stockMissions pushBack configName _x;
};

_x call _fnc_findMissions;
} forEach configProperties [_this, "isClass _x"];
};

(configFile >> "CfgMissions" >> "MPMissions") call _fnc_findMissions;

_display setVariable [QGVAR(stockMissions), _stockMissions];

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

private _ctrlSearch = _display ctrlCreate ["RscEdit", IDC_SEARCH];
_ctrlSearch ctrlSetPosition [
_left + 0.1 * GUI_GRID_W,
_top,
_width - 1.2 * GUI_GRID_W,
_width - 21.2 * GUI_GRID_W,
GUI_GRID_H
];
_ctrlSearch ctrlCommit 0;

private _ctrlSearchButton = _display ctrlCreate ["RscButtonSearch", IDC_SEARCH_BUTTON];
_ctrlSearchButton ctrlSetPosition [
_left + _width - GUI_GRID_W,
_left + _width - 21 * GUI_GRID_W,
_top,
GUI_GRID_W,
GUI_GRID_H
];
_ctrlSearchButton ctrlCommit 0;

private _ctrlShowStockMissions = _display ctrlCreate ["RscButton", -1];
_ctrlShowStockMissions ctrlSetPosition [
_left + _width - 10 * GUI_GRID_W,
_top,
10 * GUI_GRID_W,
GUI_GRID_H
];
_ctrlShowStockMissions ctrlCommit 0;
_ctrlShowStockMissions ctrlSetFont "PuristaLight";

_ctrlShowStockMissions ctrlAddEventHandler ["ButtonClick", {
params ["_ctrlShowStockMissions"];

private _showStockMissions = !(profileNamespace getVariable [QGVAR(ShowStockMissions), true]);
profileNamespace setVariable [QGVAR(ShowStockMissions), _showStockMissions];
saveProfileNamespace;

_ctrlShowStockMissions ctrlSetText toUpper localize (["STR_CBA_Ui_CustomMissions", "STR_CBA_Ui_AllMissions"] select _showStockMissions);
}];

private _showStockMissions = profileNamespace getVariable [QGVAR(ShowStockMissions), true];
_ctrlShowStockMissions ctrlSetText toUpper localize (["STR_CBA_Ui_CustomMissions", "STR_CBA_Ui_AllMissions"] select _showStockMissions);

_ctrlMissions ctrlSetPosition [
_left,
_top + 1.1 * GUI_GRID_H,
Expand Down Expand Up @@ -65,13 +105,15 @@ _display setVariable [QFUNC(filter), {

private _filter = toLower ctrlText _ctrlSearch;
private _missions = _ctrlMissions getVariable QGVAR(missions);
private _stockMissions = _display getVariable QGVAR(stockMissions);
private _showStockMissions = profileNamespace getVariable [QGVAR(ShowStockMissions), true];

lbClear _ctrlMissions;

{
_x params ["_name", "_value", "_data", "_color"];

if (toLower _name find _filter != -1) then {
if (toLower _name find _filter != -1 && {_showStockMissions || {!(_data in _stockMissions)}}) then {
private _index = _ctrlMissions lbAdd _name;
_ctrlMissions lbSetValue [_index, _value];
_ctrlMissions lbSetData [_index, _data];
Expand All @@ -92,3 +134,4 @@ private _fnc_update = {_this spawn {isNil { // delay a frame
_ctrlSearch ctrlAddEventHandler ["KeyDown", _fnc_update];
_ctrlSearch ctrlAddEventHandler ["KeyUp", _fnc_update];
_ctrlSearchButton ctrlAddEventHandler ["ButtonClick", _fnc_update];
_ctrlShowStockMissions ctrlAddEventHandler ["ButtonClick", _fnc_update];
8 changes: 8 additions & 0 deletions addons/ui/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,13 @@
<German>Textrückmeldung an den Spieler.</German>
<Polish>Tekstowa informacja dla gracza.</Polish>
</Key>
<Key ID="STR_CBA_Ui_AllMissions">
<English>Show all missions</English>
<German>Alle Missionen anzeigen</German>
</Key>
<Key ID="STR_CBA_Ui_CustomMissions">
<English>Show custom missions</English>
<German>Eigene Missionen anzeigen</German>
</Key>
</Package>
</Project>
1 change: 0 additions & 1 deletion optionals/no_stock_missions/$PBOPREFIX$

This file was deleted.

19 changes: 0 additions & 19 deletions optionals/no_stock_missions/config.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions optionals/no_stock_missions/no_stock_missions_prep/config.cpp

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions optionals/no_stock_missions/script_component.hpp

This file was deleted.

0 comments on commit b1dbeff

Please sign in to comment.