mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
add more filters to ammo boxes
This commit is contained in:
parent
f0642950e3
commit
68388bc976
1
addons/filters/$PBOPREFIX$
Normal file
1
addons/filters/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
|||||||
|
z\ace\addons\filters
|
12
addons/filters/CfgEventHandlers.hpp
Normal file
12
addons/filters/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
class Extended_PreInit_EventHandlers {
|
||||||
|
class ADDON {
|
||||||
|
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class Extended_PostInit_EventHandlers {
|
||||||
|
class ADDON {
|
||||||
|
init = QUOTE(call COMPILE_FILE(XEH_postInit));
|
||||||
|
};
|
||||||
|
};
|
32
addons/filters/XEH_postInit.sqf
Normal file
32
addons/filters/XEH_postInit.sqf
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
if (!hasInterface) exitWith {};
|
||||||
|
|
||||||
|
disableSerialization;
|
||||||
|
|
||||||
|
GVAR(customFilters) = [];
|
||||||
|
GVAR(selectedFilterIndex) = -1;
|
||||||
|
|
||||||
|
["inventoryDisplayLoaded", {_this call FUNC(inventoryDisplayLoaded)}] call EFUNC(common,addEventHandler);
|
||||||
|
|
||||||
|
// add custom filters
|
||||||
|
DFUNC(filterBackpacks) = {
|
||||||
|
params ["_config"];
|
||||||
|
getNumber (_config >> "isBackpack") == 1
|
||||||
|
};
|
||||||
|
|
||||||
|
[localize LSTRING(Backpacks), QFUNC(filterBackpacks)] call FUNC(addCustomFilter);
|
||||||
|
|
||||||
|
DFUNC(filterUniforms) = {
|
||||||
|
params ["_config"];
|
||||||
|
getNumber (_config >> "ItemInfo" >> "type") == 801
|
||||||
|
};
|
||||||
|
|
||||||
|
[localize LSTRING(Uniforms), QFUNC(filterUniforms)] call FUNC(addCustomFilter);
|
||||||
|
|
||||||
|
DFUNC(filterVests) = {
|
||||||
|
params ["_config"];
|
||||||
|
getNumber (_config >> "ItemInfo" >> "type") == 701
|
||||||
|
};
|
||||||
|
|
||||||
|
[localize LSTRING(Vests), QFUNC(filterVests)] call FUNC(addCustomFilter);
|
50
addons/filters/XEH_preInit.sqf
Normal file
50
addons/filters/XEH_preInit.sqf
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
ADDON = false;
|
||||||
|
|
||||||
|
PREP(addCustomFilter);
|
||||||
|
PREP(currentItemListBox);
|
||||||
|
PREP(forceItemListUpdate);
|
||||||
|
PREP(inventoryDisplayLoaded);
|
||||||
|
PREP(onLBSelChanged);
|
||||||
|
|
||||||
|
// cache config
|
||||||
|
if !(uiNamespace getVariable [QGVAR(configCached), false]) then {
|
||||||
|
// weapons, magazines, items
|
||||||
|
{
|
||||||
|
if (getNumber (_x >> "scope") > 0) then {
|
||||||
|
private _displayName = getText (_x >> "displayName");
|
||||||
|
private _picture = getText (_x >> "picture");
|
||||||
|
|
||||||
|
if (_picture select [0,1] == "\") then {
|
||||||
|
_picture = _picture select [1];
|
||||||
|
};
|
||||||
|
|
||||||
|
uiNamespace setVariable [format [QGVAR(ItemKey:%1), _displayName, _picture], _x];
|
||||||
|
};
|
||||||
|
false
|
||||||
|
} count (
|
||||||
|
("true" configClasses (configFile >> "CfgWeapons")) +
|
||||||
|
("true" configClasses (configFile >> "CfgMagazines")) +
|
||||||
|
("true" configClasses (configFile >> "CfgGlasses"))
|
||||||
|
);
|
||||||
|
|
||||||
|
// backpacks
|
||||||
|
{
|
||||||
|
if (getNumber (_x >> "scope") > 0 && {getNumber (_x >> "isBackpack") == 1}) then {
|
||||||
|
private _displayName = getText (_x >> "displayName");
|
||||||
|
private _picture = getText (_x >> "picture");
|
||||||
|
|
||||||
|
if (_picture select [0,1] == "\") then {
|
||||||
|
_picture = _picture select [1];
|
||||||
|
};
|
||||||
|
|
||||||
|
uiNamespace setVariable [format [QGVAR(ItemKey:%1), _displayName, _picture], _x];
|
||||||
|
};
|
||||||
|
false
|
||||||
|
} count ("true" configClasses (configFile >> "CfgVehicles"));
|
||||||
|
|
||||||
|
uiNamespace setVariable [QGVAR(configCached), true];
|
||||||
|
};
|
||||||
|
|
||||||
|
ADDON = true;
|
15
addons/filters/config.cpp
Normal file
15
addons/filters/config.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
class CfgPatches {
|
||||||
|
class ADDON {
|
||||||
|
units[] = {};
|
||||||
|
weapons[] = {};
|
||||||
|
requiredVersion = REQUIRED_VERSION;
|
||||||
|
requiredAddons[] = {"ace_common"};
|
||||||
|
author[] = {""};
|
||||||
|
authorUrl = "";
|
||||||
|
VERSION_CONFIG;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "CfgEventHandlers.hpp"
|
6
addons/filters/functions/fnc_addCustomFilter.sqf
Normal file
6
addons/filters/functions/fnc_addCustomFilter.sqf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params [["_filterName", "ERROR: No Name", [""]], ["_fncName", "", [""]]];
|
||||||
|
|
||||||
|
GVAR(customFilters) pushBack [_filterName, _fncName];
|
17
addons/filters/functions/fnc_currentItemListBox.sqf
Normal file
17
addons/filters/functions/fnc_currentItemListBox.sqf
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_display"];
|
||||||
|
|
||||||
|
scopeName "main";
|
||||||
|
|
||||||
|
{
|
||||||
|
private _control = _display displayCtrl _x;
|
||||||
|
|
||||||
|
if (ctrlShown _control) then {
|
||||||
|
_control breakOut "main"
|
||||||
|
};
|
||||||
|
false
|
||||||
|
} count [632, 640, 633, 638, 619];
|
||||||
|
|
||||||
|
-1
|
29
addons/filters/functions/fnc_forceItemListUpdate.sqf
Normal file
29
addons/filters/functions/fnc_forceItemListUpdate.sqf
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
disableSerialization;
|
||||||
|
params ["_display"];
|
||||||
|
|
||||||
|
private _index = GVAR(selectedFilterIndex);
|
||||||
|
private _itemList = _display call FUNC(currentItemListBox);
|
||||||
|
private _filterFunction = missionNamespace getVariable ((_display displayCtrl 6554) lbData _index);
|
||||||
|
|
||||||
|
if (_filterFunction isEqualType {}) then {
|
||||||
|
private _i = 0;
|
||||||
|
|
||||||
|
while {_i < lbSize _itemList} do {
|
||||||
|
private _config = uiNamespace getVariable [
|
||||||
|
format [QGVAR(ItemKey:%1), _itemList lbText _i, _itemList lbPicture _i],
|
||||||
|
configNull
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!isNull _config && {!(_config call _filterFunction)}) then {
|
||||||
|
_itemList lbDelete _i;
|
||||||
|
|
||||||
|
// in case the filter function returns nil. Otherwise could lock up the game.
|
||||||
|
_i = _i - 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
_i = _i + 1;
|
||||||
|
};
|
||||||
|
};
|
61
addons/filters/functions/fnc_inventoryDisplayLoaded.sqf
Normal file
61
addons/filters/functions/fnc_inventoryDisplayLoaded.sqf
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
disableSerialization;
|
||||||
|
params ["_display"];
|
||||||
|
|
||||||
|
private _filter = _display displayCtrl 6554;
|
||||||
|
|
||||||
|
// engine defined behaviour is the following:
|
||||||
|
// lb value, data and text don't matter, only the index.
|
||||||
|
// the first three indecies are hard coded: 0 - weapons , 1 - magazines, 2 - items
|
||||||
|
// all of them show backpacks, because BI
|
||||||
|
// all other indecies show everything, so all we have to do is delete stuff we dont like
|
||||||
|
_filter ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChanged)}];
|
||||||
|
|
||||||
|
// have to add these a frame later, because this event happens before the engine adds the default filters
|
||||||
|
[{
|
||||||
|
disableSerialization;
|
||||||
|
params ["_filter"];
|
||||||
|
|
||||||
|
// remove "All", so we can push it to the back later.
|
||||||
|
// to keep localization we can keep the lbText (displayed name).
|
||||||
|
private _index = lbSize _filter - 1;
|
||||||
|
private _nameAll = _filter lbText _index;
|
||||||
|
_filter lbDelete _index;
|
||||||
|
|
||||||
|
// add our custom filters
|
||||||
|
{
|
||||||
|
_x params ["_name", "_fncName"];
|
||||||
|
|
||||||
|
_index = _filter lbAdd _name;
|
||||||
|
_filter lbSetData [_index, _fncName];
|
||||||
|
|
||||||
|
false
|
||||||
|
} count GVAR(customFilters);
|
||||||
|
|
||||||
|
// readd "All" filter to last position and select it
|
||||||
|
_index = _filter lbAdd _nameAll;
|
||||||
|
_filter lbSetCurSel _index;
|
||||||
|
}, [_filter]] call EFUNC(common,execNextFrame);
|
||||||
|
|
||||||
|
// monitor changes that can happen and force our upate
|
||||||
|
private _dummyControl = _display ctrlCreate ["RscMapControl", -1];
|
||||||
|
|
||||||
|
_dummyControl ctrlSetPosition [0,0,0,0];
|
||||||
|
_dummyControl ctrlCommit 0;
|
||||||
|
|
||||||
|
_dummyControl ctrlAddEventHandler ["Draw", {
|
||||||
|
disableSerialization;
|
||||||
|
params ["_dummyControl"];
|
||||||
|
|
||||||
|
private _display = ctrlParent _dummyControl;
|
||||||
|
|
||||||
|
private _itemList = _display call FUNC(currentItemListBox);
|
||||||
|
|
||||||
|
// monitoring is done by setting a lb value. These are unused here and are reset every time the list box updates. 127 is just a random constant number.
|
||||||
|
if (_itemList lbValue 0 != 127) then {
|
||||||
|
_display call FUNC(forceItemListUpdate);
|
||||||
|
_itemList lbSetValue [0, 127];
|
||||||
|
};
|
||||||
|
}];
|
14
addons/filters/functions/fnc_onLBSelChanged.sqf
Normal file
14
addons/filters/functions/fnc_onLBSelChanged.sqf
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
disableSerialization;
|
||||||
|
params ["_filter", "_index"];
|
||||||
|
|
||||||
|
GVAR(selectedFilterIndex) = _index;
|
||||||
|
|
||||||
|
[{
|
||||||
|
disableSerialization;
|
||||||
|
params ["_display"];
|
||||||
|
|
||||||
|
[_display] call FUNC(forceItemListUpdate);
|
||||||
|
}, [ctrlParent _filter]] call EFUNC(common,execNextFrame);
|
1
addons/filters/functions/script_component.hpp
Normal file
1
addons/filters/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "\z\ace\addons\filters\script_component.hpp"
|
12
addons/filters/script_component.hpp
Normal file
12
addons/filters/script_component.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#define COMPONENT filters
|
||||||
|
#include "\z\ace\addons\main\script_mod.hpp"
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED_FILTERS
|
||||||
|
#define DEBUG_MODE_FULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED_FILTERS
|
||||||
|
#define DEBUG_SETTINGS DEBUG_ENABLED_FILTERS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "\z\ace\addons\main\script_macros.hpp"
|
29
addons/filters/stringtable.xml
Normal file
29
addons/filters/stringtable.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project name="ACE">
|
||||||
|
<Package name="Filters">
|
||||||
|
<Key ID="STR_ACE_Filters_Backpacks">
|
||||||
|
<English>Backpacks</English>
|
||||||
|
<German>Rucksäcke</German>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Filters_Headgear">
|
||||||
|
<English>Headgear</English>
|
||||||
|
<German>Helme</German>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Filters_Glasses">
|
||||||
|
<English>Glasses</English>
|
||||||
|
<German>Brillen</German>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Filters_Uniforms">
|
||||||
|
<English>Uniforms</English>
|
||||||
|
<German>Uniformen</German>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Filters_Vests">
|
||||||
|
<English>Vests</English>
|
||||||
|
<German>Westen</German>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Filters_Grenades">
|
||||||
|
<English>Grenades</English>
|
||||||
|
<German>Granaten</German>
|
||||||
|
</Key>
|
||||||
|
</Package>
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user