Skip to content

Commit

Permalink
add CBA settings
Browse files Browse the repository at this point in the history
  • Loading branch information
commy2 committed May 28, 2016
1 parent c812425 commit a071eae
Show file tree
Hide file tree
Showing 54 changed files with 2,176 additions and 15 deletions.
15 changes: 12 additions & 3 deletions addons/common/fnc_createNamespace.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ Description:
The Namespace is destroyed after the mission ends. getVariable ARRAY is not supported.
Parameters:
None
_isGlobal - create a global namespace (optional, default: false) <BOOLEAN>
Returns:
_namespace - a namespace <LOCATION>
_namespace - a namespace <LOCATION, OBJECT>
Examples:
(begin example)
_namespace = call CBA_fnc_createNamespace;
My_GlobalNamespace = true call CBA_fnc_createNamespace;
publicVariable "My_GlobalNamespace";
(end)
Author:
Expand All @@ -23,4 +26,10 @@ Author:
#include "script_component.hpp"
SCRIPT(createNamespace);

createLocation ["CBA_NamespaceDummy", [-1000, -1000, 0], 0, 0]
params [["_isGlobal", false]];

if (_isGlobal isEqualTo true) then {
createVehicle ["Building", [-1000, -1000, 0], [], 0, "NONE"]
} else {
createLocation ["CBA_NamespaceDummy", [-1000, -1000, 0], 0, 0]
};
4 changes: 2 additions & 2 deletions addons/common/fnc_deleteNamespace.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Author:
#include "script_component.hpp"
SCRIPT(deleteNamespace);

params [["_namespace", locationNull, [locationNull]]];
params [["_namespace", locationNull, [locationNull, objNull]]];

deleteLocation _namespace;
_namespace call CBA_fnc_deleteEntity;
14 changes: 9 additions & 5 deletions addons/keybinding/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
class Extended_PreInit_EventHandlers
{
class ADDON
{
clientInit = QUOTE(call COMPILE_FILE(XEH_preClientInit));

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

class Extended_DisplayLoad_EventHandlers {
class RscDisplayConfigure {
ADDON = QUOTE(_this call COMPILE_FILE(XEH_configureDisplayLoad));
};
};
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "script_component.hpp"
SCRIPT(XEH_preInit);

if (!hasInterface) exitWith {};

ADDON = false;

// Load DIK to string conversion table.
Expand Down
2 changes: 0 additions & 2 deletions addons/keybinding/gui/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class RscListBoxKeys;
///////////////////////////////////////////////////////////////////////////////

class RscDisplayConfigure {
onLoad = "[""onLoad"",_this,""RscDisplayConfigure"",'GUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; _this call compile preprocessfilelinenumbers ""\x\cba\addons\keybinding\gui\initDisplay.sqf""";

class controls {
class CA_ButtonCancel: RscButtonMenuCancel {
onButtonClick = "_this call cba_keybinding_fnc_onButtonClick_cancel";
Expand Down
Empty file added addons/linux/$NOBIN$
Empty file.
4 changes: 2 additions & 2 deletions addons/main/script_macros_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ Macro: GVARMAIN()
#define PREP(var1) TRIPLES(ADDON,fnc,var1) = compile preProcessFileLineNumbers 'PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))'
#define PREPMAIN(var1) TRIPLES(PREFIX,fnc,var1) = compile preProcessFileLineNumbers 'PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))'
#else
#define PREP(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(ADDON,fnc,var1)'] call SLX_XEH_COMPILE_NEW
#define PREPMAIN(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(PREFIX,fnc,var1)'] call SLX_XEH_COMPILE_NEW
#define PREP(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(ADDON,fnc,var1)'] call CBA_fnc_compileFunction
#define PREPMAIN(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(PREFIX,fnc,var1)'] call CBA_fnc_compileFunction
#endif

#define FUNC(var1) TRIPLES(ADDON,fnc,var1)
Expand Down
1 change: 1 addition & 0 deletions addons/settings/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x\cba\addons\settings
54 changes: 54 additions & 0 deletions addons/settings/CBA_Settings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

class CBA_Setting_Boolean_base {
type = "BOOLEAN";
displayName = "";
tooltip = "";
defaultValue = 0;
};

class CBA_Setting_List_base {
type = "LIST";
displayName = "";
tooltip = "";
values[] = {0,1};
//valueNames[] = {"disabled","enabled"};
defaultIndex = 0;
};

class CBA_Setting_Slider_base {
type = "SLIDER";
displayName = "";
tooltip = "";
min = 0;
max = 100;
defaultValue = 50;
};

class CBA_Setting_Slider_2_base: CBA_Setting_Slider_base {
min = 0;
max = 1;
defaultValue = 0.5;
trailingDecimals = 2;
};

class CBA_Setting_Color_base {
type = "COLOR";
displayName = "";
tooltip = "";
defaultValue[] = {1,1,1};
};

class CBA_Setting_Color_Alpha_base: CBA_Setting_Color_base {
defaultValue[] = {1,1,1,1};
};

class CBA_Settings {
class CBA {
displayName = "CBA";
class CBA_TEST1: CBA_Setting_List_base {};
class CBA_TEST2: CBA_Setting_Boolean_base {};
class CBA_TEST3: CBA_Setting_Slider_base {};
class CBA_TEST_C: CBA_Setting_Color_base { displayName = "Test Setting Color"; };
class CBA_TEST_A: CBA_Setting_Color_Alpha_base { displayName = "Test Setting Color Alpha"; };
};
};
25 changes: 25 additions & 0 deletions addons/settings/Cfg3DEN.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

class Cfg3DEN {
class Mission {
class Scenario {
class AttributeCategories {
class Presentation { // any existing
class Attributes {
class BriefingName;
class Author; // needed, to put blank space at the end. for looks
class GVAR(missionSettings) {
property = QGVAR(missionSettings);
value = 0;
control = "Default"; // blank space. not editable by hand
displayName = "";
tooltip = "";
defaultValue = "[]";
expression = QUOTE(missionNamespace setVariable [ARR_3(QUOTE(QGVAR(3denSettings)),_value,true)]);
wikiType = "[[Array]]";
};
};
};
};
};
};
};
27 changes: 27 additions & 0 deletions addons/settings/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

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));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

class Extended_DisplayLoad_EventHandlers {
class RscDisplayGameOptions {
ADDON = QUOTE(_this call COMPILE_FILE(gui\gui_initDisplay));
};
class Display3DEN {
ADDON = QUOTE(_this call COMPILE_FILE(init_3den));
};
};
10 changes: 10 additions & 0 deletions addons/settings/CfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#define F_FILEPATH(func) class func {\
file = QUOTE(PATHTOF(DOUBLES(fnc,func).sqf));\
}

class CfgFunctions {
class CBA {
class Settings {};
};
};
18 changes: 18 additions & 0 deletions addons/settings/XEH_PREP.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

PREP(init);
PREP(set);
PREP(get);
PREP(check);
PREP(parse);
PREP(import);
PREP(export);
PREP(clear);
PREP(saveTempData);
PREP(isForced);
PREP(isOverwritten);
PREP(create);

PREP(gui_addonChanged);
PREP(gui_sourceChanged);
PREP(gui_configure);
PREP(gui_closeMenu);
9 changes: 9 additions & 0 deletions addons/settings/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"
SCRIPT(XEH_postInit);

// refresh all settings after postInit to guarantee that events are added
{
{
[QGVAR(refreshSetting), _x] call CBA_fnc_localEvent;
} forEach GVAR(allSettings);
} call CBA_fnc_execNextFrame;
52 changes: 52 additions & 0 deletions addons/settings/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "script_component.hpp"
SCRIPT(XEH_preInit);

ADDON = false;

#include "XEH_PREP.sqf"

call FUNC(init);

// event to refresh missionNamespace value if setting has changed and call public event
[QGVAR(refreshSetting), {
params ["_setting"];
private _value = _setting call FUNC(get);

missionNamespace setVariable [_setting, _value];
["CBA_SettingChanged", [_setting, _value]] call CBA_fnc_localEvent;
}] call CBA_fnc_addEventHandler;

// event to refresh all settings at once - saves bandwith
[QGVAR(refreshAllSettings), {
{
[QGVAR(refreshSetting), _x] call CBA_fnc_globalEvent;
} forEach GVAR(allSettings);
}] call CBA_fnc_addEventHandler;

#ifdef DEBUG_MODE_FULL
["CBA_SettingChanged", {
params ["_setting", "_value"];

private _message = format ["[CBA] (settings): %1 = %2", _setting, _value];
systemChat _message;
diag_log text _message;
}] call CBA_fnc_addEventHandler;
#endif

// event to modify settings on a dedicated server as admin
if (isServer) then {
[QGVAR(setSettingServer), {
params ["_setting", "_value", "_forced"];
[_setting, _value, _forced, "server"] call FUNC(set);
}] call CBA_fnc_addEventHandler;
};

// import settings from file if filepatching is enabled
if (isFilePatchingEnabled) then {
[loadFile PATH_SETTINGS_FILE, "client"] call FUNC(import);
diag_log text "[CBA] (settings): Settings file loaded.";
} else {
diag_log text "[CBA] (settings): Cannot load settings file. File patching disabled. Use -filePatching flag.";
};

ADDON = true;
4 changes: 4 additions & 0 deletions addons/settings/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "script_component.hpp"
SCRIPT(XEH_preStart);

#include "XEH_PREP.sqf"
21 changes: 21 additions & 0 deletions addons/settings/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"CBA_common", "A3_UI_F"};
version = VERSION;
author[] = {"commy2"};
authorUrl = "https://github.com/CBATeam/CBA_A3";
};
};

#include "CfgEventHandlers.hpp"
#include "CfgFunctions.hpp"

#include "CBA_Settings.hpp"
#include "Cfg3DEN.hpp"

#include "gui\gui.hpp"
40 changes: 40 additions & 0 deletions addons/settings/fnc_check.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* ----------------------------------------------------------------------------
Internal Function: CBA_settings_fnc_check
Description:
Check if provided value is valid.
Parameters:
_setting - Name of the setting <STRING>
_value - Value of to test <ANY>
Returns:
All setting info. Additionally to being put into clipboard <BOOLEAN>
Author:
commy2
---------------------------------------------------------------------------- */
#include "script_component.hpp"

params [["_setting", "", [""]], "_value"];

if (isNil "_value") exitWith {false};

(GVAR(defaultSettings) getVariable _setting) params ["_defaultValue", "", "_settingType", "_values"];

switch (toUpper _settingType) do {
case ("BOOLEAN"): {
_value isEqualType false
};
case ("LIST"): {
_value in _values
};
case ("SLIDER"): {
_values params ["_min", "_max"];
_value isEqualType 0 && {_value >= _min} && {_value <= _max}
};
case ("COLOR"): {
_value isEqualType [] && {count _value == count _defaultValue} && {{_x < 0 || _x > 1} count _value == 0}
};
default {false};
};
Loading

0 comments on commit a071eae

Please sign in to comment.