Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul activateAddons #1051

Merged
merged 9 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from 8 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
6 changes: 6 additions & 0 deletions addons/common/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
Expand Down
6 changes: 2 additions & 4 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ call COMPILE_FILE(init_perFrameHandler);
call COMPILE_FILE(init_delayLess);

// Due to activateAddons being overwritten by eachother (only the last executed command will be active), we apply this bandaid
private _addons = ("true" configClasses (configFile >> "CfgPatches")) apply {configName _x};

activateAddons _addons;
GVAR(addons) = _addons;
activateAddons call (uiNamespace getVariable [QGVAR(unitAddons), {[]}]);
GVAR(addons) = call (uiNamespace getVariable [QGVAR(addons), {[]}]);

// BWC
#include "backwards_comp.sqf"
Expand Down
23 changes: 23 additions & 0 deletions addons/common/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "script_component.hpp"

//See usage in XEH_preInit
private _cfgPatches = configFile >> "CfgPatches";
private _allComponents = "true" configClasses _cfgPatches apply {configName _x};

//Filter out addons that don't have any units defined as we don't need to activate these
private _unitAddons = _allComponents select {
!(getArray (_cfgPatches >> _x >> "units") isEqualTo [])
};

//Filter out addons defined in CfgAddons as they are always activated
private _allAddons = "true" configClasses (configFile >> "CfgAddons");
private _preloadedAddons = [];

{
_preloadedAddons append getArray (_x >> "list");
dedmen marked this conversation as resolved.
Show resolved Hide resolved
} forEach _allAddons;

_unitAddons = _unitAddons - _preloadedAddons;

uiNamespace setVariable [QGVAR(addons), compileFinal str _allComponents];
uiNamespace setVariable [QGVAR(unitAddons), compileFinal str _unitAddons];