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

CBA Settings frame work #317

Merged
merged 5 commits into from
Jul 6, 2016
Merged

CBA Settings frame work #317

merged 5 commits into from
Jul 6, 2016

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Apr 25, 2016

  • Adds dynamically created "game options" that can also be set and enforced on dedicated servers without having to move around or edit any files.

http://i.imgur.com/49lCIfV.png
http://i.imgur.com/qHEtUem.png
http://i.imgur.com/u7KQmui.png

@commy2 commy2 added the WIP label Apr 25, 2016
@commy2 commy2 force-pushed the cba_settings branch 2 times, most recently from 98630d7 to 318fbbf Compare April 28, 2016 19:02
@commy2 commy2 force-pushed the cba_settings branch 3 times, most recently from 517dcbc to a071eae Compare May 28, 2016 19:55
@commy2 commy2 force-pushed the cba_settings branch 3 times, most recently from 5b018d7 to c92cfcc Compare June 18, 2016 20:08
@commy2
Copy link
Contributor Author

commy2 commented Jun 20, 2016

CBA Settings system

Basics
  • All settings are created with CBA_Settings_fnc_init. The function can be used anywhere and has local effects (function has to be executed on every machine, e.g. init.sqf or init box of a game logic etc.)
  • Settings can be changed in the ingame settings menu.
  • If a settings value is changed, it will be stored in the profile. The changed value will also be applied the next time the setting is initialized (e.g. next mission start), even when the game was closed.
Server and Mission settings
  • The settings of the server are broadcasted to all clients. The server can be a local host or a dedicated server.
  • To change the settings of a dedicated server, just log in as admin and select the "Server" tab
  • All settings can also be stored in a mission. Mission makers can change the missions settings in the 3den editor by selecting the "Mission" tab
  • The settings of a "Server" and a "Mission" can be forced, which means they overwrite the clients settings. The servers forced settings take precedence over a missions forced setting.
  • If a setting uses the _isGlobal flag, it will always be forced by the server. This ensures that the settings value is synchronized on all clients
Import / Export functions and userconfig
  • Settings can be exported and imported via the ingame settings menu in a format that can be stored in any type of text file.
  • These exported settings can be placed in \userconfig\cba\settings.sqf. This file is completely optional.
Presets system
  • The ingame settings menu can save whole presets of settings.
  • These presets can be used to quickly transfer settings from the client to the server or the mission and vice versa.
  • The presets of the last three missions you played and of the last three servers you played on will be "autosaved" as preset.
  • Presets can be selected during the briefing. The admin can also change the servers preset (or change any individual setting).
Supported setting types

Currently four different setting "types" are supported:

  • CHECKBOX : A checkbox. The resulting setting is a boolean.
  • SLIDER: Resulting setting is a number between a min and a max value. (e.g. view distance slider)
  • LIST: A dropdown list. Resulting value can be anything, but only one item can be selected at any time.
  • COLOR: Will create a "color picker" setting. The value will be an array representing a color.
    The array size can be 3 or 4, depending on the passed default value. The fourth element will represent the opacity ("alpha value").
Arguments of CBA_Settings_fnc_init
Parameters:
    _setting     - Unique setting name. Matches resulting variable name <STRING>
    _settingType - Type of setting. Can be "CHECKBOX", "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 <STRING>
    _valueInfo   - Extra properties of the setting depending of _settingType. See examples below <ANY>
    _isGlobal    - true: all clients share the same state of the setting (optional, default: false) <ARRAY>
    _script      - Script to execute when setting is changed or forced. (optional) <CODE>
Setting specific arguments (_valueInfo)

CHECKBOX:

  • Default value

SLIDER:

  • 0: Minimum (lowest possible value)
  • 1: Maximum (highest possible value)
  • 2: Default value
  • 3: Number of displayed trailing decimals (should be 0, 1 or 2)

LIST:

  • 0: Values this setting can take.
  • 1: Corresponding pretty names for the ingame settings menu. Can be stringtable entries.
  • 2: Index of the default value. Not the default value itself.

COLOR:

  • Default color. Array size can be 3 or 4, depending on whether the setting uses the alpha value. Example: red = [1,0,0], Transparent yellow = [1,1,0,0.5]
Example - View distance slider:
[
    "Commy_ViewDistance", // Internal setting name, should always contain a tag! This will be the global variable which takes the value of the setting.
    "SLIDER", // setting type
    "View Distance", // Pretty name shown inside the ingame settings menu. Can be stringtable entry.
    "My Mission Settings", // Pretty name of the category where the setting can be found. Can be stringtable entry.
    [200, 15000, 5000, 0], // data for this setting: [min, max, default, number of shown trailing decimals]
    nil, // "global" flag. Set this to true to always have this setting synchronized between all clients in multiplayer
    {  
        params ["_value"];
        setViewDistance _value;
    } // function that will be executed once on mission start and every time the setting is changed.
] call CBA_Settings_fnc_init;

@commy2 commy2 added Feature and removed WIP labels Jun 20, 2016
@commy2 commy2 changed the title [WIP] CBA Settings frame work CBA Settings frame work Jun 20, 2016
@Killswitch00 Killswitch00 merged commit b04c7c9 into master Jul 6, 2016
@nicolasbadano
Copy link
Contributor

nicolasbadano commented Jul 6, 2016

Yay for this being merged! Any estimate on when the next CBA will be released?

@jonpas
Copy link
Member

jonpas commented Jul 6, 2016

@esteldunedain When it will be ready! 😆

@commy2 commy2 added this to the 2.4.2 milestone Jul 10, 2016
@ghost
Copy link

ghost commented Jul 18, 2016

If I wanted to reference an option in a script without using GVAR, what namespace should I look for?

@commy2
Copy link
Contributor Author

commy2 commented Jul 26, 2016

@nathan423 Please explain what you are trying to do.

@ghost
Copy link

ghost commented Aug 2, 2016

@commy2 Well, I have a part of a script that is checking for a said variable, the code is

if (player getVariable ["uogm_mapMon_enableGroupID", false]) then {
    _marker setMarkerTextLocal format ["%1 | %2",(name _x), (groupID (group _x))];
} else {
    setMarkerTextLocal format ["%1",(name _x)];
};

And I would like to directly reference the variable instead of creating another variable and writing to that. For reference, here is my code to create the setting (executed locally on the client)

["uogm_mapMon_enableGroupID", "CHECKBOX", "Enable Group ID (Map Monitor)", "United Operations", [true], nil, {
        params ["_value"];
        player setVariable ["uogm_mapMon_enableGroupID", _value];
        systemChat str _value;
}] call CBA_Settings_fnc_init;

@commy2
Copy link
Contributor Author

commy2 commented Aug 6, 2016

I still don't understand. I don't see GVAR anywhere in your code.
Also, this is a weird place to ask this question. I don't receive mails from closed issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants