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

add CBA_fnc_addSetting #1111

Merged
merged 1 commit into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions addons/settings/CfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CfgFunctions {
class CBA {
class Settings {
PATHTO_FNC(addSetting);
};
};
};
1 change: 1 addition & 0 deletions addons/settings/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CfgPatches {
};

#include "CfgEventHandlers.hpp"
#include "CfgFunctions.hpp"
#include "Cfg3DEN.hpp"
#include "Display3DEN.hpp"
#include "gui.hpp"
Expand Down
48 changes: 48 additions & 0 deletions addons/settings/fnc_addSetting.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_addSetting

Description:
Creates a new setting for that session.

Parameters:
_setting - Unique setting name. Matches resulting variable name <STRING>
_settingType - Type of setting. Can be "CHECKBOX", "EDITBOX", "LIST", "SLIDER" or "COLOR" <STRING>
_title - Display name or display name + tooltip (optional, default: same as setting name) <STRING, ARRAY>
_category - Category for the settings menu + optional sub-category <STRING, ARRAY>
_valueInfo - Extra properties of the setting depending of _settingType. See examples below <ANY>
_isGlobal - 1: all clients share the same setting, 2: setting can't be overwritten (optional, default: 0) <ARRAY>
_script - Script to execute when setting is changed. (optional) <CODE>
_needRestart - Setting will be marked as needing mission restart after being changed. (optional, default false) <BOOL>

Returns:
_return - Error code <BOOLEAN>
true: Success, no error
false: Failure, error

Examples:
(begin example)
// CHECKBOX --- extra argument: default value
["Test_Setting_1", "CHECKBOX", ["-test checkbox-", "-tooltip-"], "My Category", true] call CBA_fnc_addSetting;

// LIST --- extra arguments: [_values, _valueTitles, _defaultIndex]
["Test_Setting_2", "LIST", ["-test list-", "-tooltip-"], "My Category", [[1, 0], ["enabled","disabled"], 1]] call CBA_fnc_addSetting;

// SLIDER --- extra arguments: [_min, _max, _default, _trailingDecimals]
["Test_Setting_3", "SLIDER", ["-test slider-", "-tooltip-"], "My Category", [0, 10, 5, 0]] call CBA_fnc_addSetting;

// COLOR PICKER --- extra argument: _color
["Test_Setting_4", "COLOR", ["-test color-", "-tooltip-"], "My Category", [1, 1, 0]] call CBA_fnc_addSetting;

// EDITBOX --- extra argument: default value
["Test_Setting_5", "EDITBOX", ["-test editbox-", "-tooltip-"], "My Category", "defaultValue"] call CBA_fnc_addSetting;

// TIME PICKER (time in seconds) --- extra arguments: [_min, _max, _default]
["Test_Setting_6", "TIME", ["-test time-", "-tooltip-"], "My Category", [0, 3600, 60]] call CBA_fnc_addSetting;
(end)

Author:
commy2
---------------------------------------------------------------------------- */

call (uiNamespace getVariable QFUNC(init)) == 0
2 changes: 1 addition & 1 deletion addons/settings/fnc_init.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_settings_fnc_init
Internal Function: CBA_settings_fnc_init

Description:
Creates a new setting for that session.
Expand Down