mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Formatting, indentation, minor refactoring + fix for opening settings menu
This commit is contained in:
parent
39be8ffbe7
commit
8064253a4d
@ -1,12 +1,15 @@
|
||||
/**
|
||||
* fnc_onListBoxSettingsChanged.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Called when a listbox selection is changed.
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_settingIndex", "_rightDropDownIndex"];
|
||||
|
@ -1,12 +1,16 @@
|
||||
/**
|
||||
* fnc_onListBoxShowSelectionChanged.sqf
|
||||
* @Descr: called when the listbox selection has changed. Updates configuration menu information
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* called when the listbox selection has changed. Updates configuration menu information
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Opened category or tab <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_settingsMenu", "_localizedHeader"];
|
||||
|
@ -1,33 +1,36 @@
|
||||
/**
|
||||
* fnc_onSettingsMenuOpen.sqf
|
||||
* @Descr: called when the settings or configuration menu has opened. Do not use anywhere else.
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* called when the settings or configuration menu has opened. Do not use anywhere else.
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
// Filter only user setable setting
|
||||
GVAR(clientSideOptions) = [];
|
||||
GVAR(clientSideColors) = [];
|
||||
{
|
||||
// If the setting is user setable and not forced
|
||||
if ((_x select 2) && !(_x select 6)) then {
|
||||
// Append the current value to the setting metadata
|
||||
_setting = + _x;
|
||||
_setting pushBack (missionNamespace getVariable (_x select 0));
|
||||
// If the setting is user setable and not forced
|
||||
if ((_x select 2) && !(_x select 6)) then {
|
||||
// Append the current value to the setting metadata
|
||||
_setting = + _x;
|
||||
_setting pushBack (missionNamespace getVariable (_x select 0));
|
||||
|
||||
// Categorize the setting according to types
|
||||
// @todo: allow the user to modify other types of parameters?
|
||||
if ((_x select 1) == "SCALAR" || (_x select 1) == "BOOL") then {
|
||||
GVAR(clientSideOptions) pushBack _setting;
|
||||
};
|
||||
if ((_x select 1) == "COLOR") then {
|
||||
GVAR(clientSideColors) pushBack _setting;
|
||||
};
|
||||
};
|
||||
// Categorize the setting according to types
|
||||
// @todo: allow the user to modify other types of parameters?
|
||||
if ((_x select 1) == "SCALAR" || (_x select 1) == "BOOL") then {
|
||||
GVAR(clientSideOptions) pushBack _setting;
|
||||
};
|
||||
if ((_x select 1) == "COLOR") then {
|
||||
GVAR(clientSideColors) pushBack _setting;
|
||||
};
|
||||
};
|
||||
} forEach EGVAR(common,settings);
|
||||
|
||||
//Delay a frame
|
||||
|
@ -1,29 +1,34 @@
|
||||
/**
|
||||
* fnc_onSliderPosChanged.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: PabstMirror
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Called when a slider position is changed.
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_newColor", "_settingIndex"];
|
||||
|
||||
_newColor = [];
|
||||
{
|
||||
_newColor pushBack ((sliderPosition _x) / 255);
|
||||
} forEach [410, 411, 412, 413];
|
||||
|
||||
_settingIndex = lbCurSel 200;
|
||||
|
||||
switch (GVAR(optionMenu_openTab)) do {
|
||||
case (MENU_TAB_COLORS): {
|
||||
if ((_settingIndex >= 0) && (_settingIndex < (count GVAR(clientSideColors)))) then {
|
||||
_settingIndex = (GVAR(clientSideColors) select _settingIndex) select 0;
|
||||
[MENU_TAB_COLORS, _settingIndex, _newColor] call FUNC(updateSetting);
|
||||
};
|
||||
[false] call FUNC(settingsMenuUpdateList);
|
||||
};
|
||||
case (MENU_TAB_COLORS): {
|
||||
|
||||
_newColor = [];
|
||||
{
|
||||
_newColor pushBack ((sliderPosition _x) / 255);
|
||||
} forEach [410, 411, 412, 413];
|
||||
|
||||
if ((_settingIndex >= 0) && (_settingIndex < (count GVAR(clientSideColors)))) then {
|
||||
_settingIndex = (GVAR(clientSideColors) select _settingIndex) select 0;
|
||||
[MENU_TAB_COLORS, _settingIndex, _newColor] call FUNC(updateSetting);
|
||||
};
|
||||
[false] call FUNC(settingsMenuUpdateList);
|
||||
};
|
||||
default {};
|
||||
};
|
||||
|
@ -1,30 +1,33 @@
|
||||
/**
|
||||
* fnc_resetSettings.sqf
|
||||
* @Descr:
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: true
|
||||
*/
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Sets all client side settings back to default.
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_name", "_default", "_lastSelected"];
|
||||
|
||||
{
|
||||
_name = _x select 0;
|
||||
_default = _x select 7;
|
||||
[MENU_TAB_OPTIONS, _name, _default] call FUNC(updateSetting);
|
||||
_name = _x select 0;
|
||||
_default = _x select 7;
|
||||
[MENU_TAB_OPTIONS, _name, _default] call FUNC(updateSetting);
|
||||
} forEach GVAR(clientSideOptions);
|
||||
|
||||
{
|
||||
_name = _x select 0;
|
||||
_default = _x select 7;
|
||||
[MENU_TAB_COLORS, _name, _default] call FUNC(updateSetting);
|
||||
_name = _x select 0;
|
||||
_default = _x select 7;
|
||||
[MENU_TAB_COLORS, _name, _default] call FUNC(updateSetting);
|
||||
} forEach GVAR(clientSideColors);
|
||||
|
||||
_lastSelected = lbCurSel 200;
|
||||
[GVAR(optionMenu_openTab)] call FUNC(onListBoxShowSelectionChanged);
|
||||
if (_lastSelected != -1) then {
|
||||
lbSetCurSel [200, _lastSelected];
|
||||
lbSetCurSel [200, _lastSelected];
|
||||
};
|
||||
|
@ -1,12 +1,15 @@
|
||||
/**
|
||||
* fnc_settingsMenuUpdateKeyView.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Updates the view on the right side with the selected settings details
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_settingsMenu", "_ctrlList", "_collection", "_settingIndex", "_setting", "_entryName", "_localizedName", "_localizedDescription", "_possibleValues", "_settingsValue", "_currentColor"];
|
||||
@ -16,58 +19,58 @@ _settingsMenu = uiNamespace getVariable 'ACE_settingsMenu';
|
||||
_ctrlList = _settingsMenu displayCtrl 200;
|
||||
|
||||
_collection = switch (GVAR(optionMenu_openTab)) do {
|
||||
case MENU_TAB_OPTIONS: {GVAR(clientSideOptions)};
|
||||
case MENU_TAB_COLORS: {GVAR(clientSideColors)};
|
||||
default {[]};
|
||||
case MENU_TAB_OPTIONS: {GVAR(clientSideOptions)};
|
||||
case MENU_TAB_COLORS: {GVAR(clientSideColors)};
|
||||
default {[]};
|
||||
};
|
||||
|
||||
if (count _collection > 0) then {
|
||||
_settingIndex = (lbCurSel _ctrlList);
|
||||
if (_settingIndex > (count _collection)) then {
|
||||
_settingIndex = count _collection - 1;
|
||||
};
|
||||
|
||||
if (_settingIndex < 0) exitwith {
|
||||
_settingIndex = 0;
|
||||
};
|
||||
_setting = _collection select _settingIndex;
|
||||
|
||||
_entryName = _setting select 0;
|
||||
_localizedName = _setting select 3;
|
||||
_localizedDescription = _setting select 4;
|
||||
|
||||
if (_localizedName == "") then {_localizedName = _entryName;};
|
||||
(_settingsMenu displayCtrl 250) ctrlSetText _localizedName;
|
||||
(_settingsMenu displayCtrl 251) ctrlSetText _localizedDescription;
|
||||
(_settingsMenu displayCtrl 300) ctrlSetText _entryName;
|
||||
|
||||
switch (GVAR(optionMenu_openTab)) do {
|
||||
case (MENU_TAB_OPTIONS): {
|
||||
_possibleValues = _setting select 5;
|
||||
_settingsValue = _setting select 8;
|
||||
|
||||
// Created disable/enable options for bools
|
||||
if ((_setting select 1) == "BOOL") then {
|
||||
lbClear 400;
|
||||
lbAdd [400, (localize "STR_ACE_OptionsMenu_Disabled")];
|
||||
lbAdd [400, (localize "STR_ACE_OptionsMenu_Enabled")];
|
||||
_settingsValue = [0, 1] select _settingsValue;
|
||||
} else {
|
||||
lbClear 400;
|
||||
{ lbAdd [400, _x]; } foreach _possibleValues;
|
||||
};
|
||||
(_settingsMenu displayCtrl 400) lbSetCurSel _settingsValue;
|
||||
_settingIndex = (lbCurSel _ctrlList);
|
||||
if (_settingIndex > (count _collection)) then {
|
||||
_settingIndex = count _collection - 1;
|
||||
};
|
||||
case (MENU_TAB_COLORS): {
|
||||
_currentColor = _setting select 8;
|
||||
{
|
||||
sliderSetPosition [_x, (255 * (_currentColor select _forEachIndex))];
|
||||
} forEach [410, 411, 412, 413];
|
||||
|
||||
if (_settingIndex < 0) then {
|
||||
_settingIndex = 0;
|
||||
};
|
||||
_setting = _collection select _settingIndex;
|
||||
|
||||
_entryName = _setting select 0;
|
||||
_localizedName = _setting select 3;
|
||||
_localizedDescription = _setting select 4;
|
||||
|
||||
if (_localizedName == "") then {_localizedName = _entryName;};
|
||||
(_settingsMenu displayCtrl 250) ctrlSetText _localizedName;
|
||||
(_settingsMenu displayCtrl 251) ctrlSetText _localizedDescription;
|
||||
(_settingsMenu displayCtrl 300) ctrlSetText _entryName;
|
||||
|
||||
switch (GVAR(optionMenu_openTab)) do {
|
||||
case (MENU_TAB_OPTIONS): {
|
||||
_possibleValues = _setting select 5;
|
||||
_settingsValue = _setting select 8;
|
||||
|
||||
// Created disable/enable options for bools
|
||||
if ((_setting select 1) == "BOOL") then {
|
||||
lbClear 400;
|
||||
lbAdd [400, (localize "STR_ACE_OptionsMenu_Disabled")];
|
||||
lbAdd [400, (localize "STR_ACE_OptionsMenu_Enabled")];
|
||||
_settingsValue = [0, 1] select _settingsValue;
|
||||
} else {
|
||||
lbClear 400;
|
||||
{ lbAdd [400, _x]; } foreach _possibleValues;
|
||||
};
|
||||
(_settingsMenu displayCtrl 400) lbSetCurSel _settingsValue;
|
||||
};
|
||||
case (MENU_TAB_COLORS): {
|
||||
_currentColor = _setting select 8;
|
||||
{
|
||||
sliderSetPosition [_x, (255 * (_currentColor select _forEachIndex))];
|
||||
} forEach [410, 411, 412, 413];
|
||||
};
|
||||
};
|
||||
};
|
||||
} else { //no settings in list:
|
||||
lbClear 400;
|
||||
(_settingsMenu displayCtrl 250) ctrlSetText _localizedName;
|
||||
(_settingsMenu displayCtrl 251) ctrlSetText _localizedDescription;
|
||||
(_settingsMenu displayCtrl 300) ctrlSetText _entryName;
|
||||
lbClear 400;
|
||||
(_settingsMenu displayCtrl 250) ctrlSetText "No settings available";
|
||||
(_settingsMenu displayCtrl 251) ctrlSetText "No settings available";
|
||||
(_settingsMenu displayCtrl 300) ctrlSetText "No settings available";
|
||||
};
|
||||
|
@ -1,12 +1,16 @@
|
||||
/**
|
||||
* fnc_settingsMenuUpdateList.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Updates the list with all settings in the menu.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: update The selection view <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_settingsMenu", "_ctrlList", "_settingsText", "_color", "_settingsColor", "_updateKeyView"];
|
||||
@ -19,35 +23,35 @@ _ctrlList = _settingsMenu displayCtrl 200;
|
||||
lbclear _ctrlList;
|
||||
|
||||
switch (GVAR(optionMenu_openTab)) do {
|
||||
case (MENU_TAB_OPTIONS): {
|
||||
case (MENU_TAB_OPTIONS): {
|
||||
{
|
||||
_ctrlList lbadd (_x select 3);
|
||||
|
||||
_settingsValue = _x select 8;
|
||||
|
||||
// Created disable/enable options for bools
|
||||
_settingsText = if ((_x select 1) == "BOOL") then {
|
||||
[(localize "STR_ACE_OptionsMenu_Disabled"), (localize "STR_ACE_OptionsMenu_Enabled")] select _settingsValue;
|
||||
} else {
|
||||
(_x select 5) select _settingsValue;
|
||||
};
|
||||
|
||||
_ctrlList lbadd (_settingsText);
|
||||
}foreach GVAR(clientSideOptions);
|
||||
};
|
||||
case (MENU_TAB_COLORS): {
|
||||
{
|
||||
_ctrlList lbadd (_x select 3);
|
||||
|
||||
_settingsValue = _x select 8;
|
||||
|
||||
// Created disable/enable options for bools
|
||||
_settingsText = if ((_x select 1) == "BOOL") then {
|
||||
[(localize "STR_ACE_OptionsMenu_Disabled"), (localize "STR_ACE_OptionsMenu_Enabled")] select _settingsValue;
|
||||
} else {
|
||||
(_x select 5) select _settingsValue;
|
||||
};
|
||||
|
||||
_ctrlList lbadd (_settingsText);
|
||||
}foreach GVAR(clientSideOptions);
|
||||
};
|
||||
case (MENU_TAB_COLORS): {
|
||||
{
|
||||
_color = +(_x select 8);
|
||||
{
|
||||
_color set [_forEachIndex, ((round (_x * 100))/100)];
|
||||
} forEach _color;
|
||||
_settingsColor = str _color;
|
||||
_ctrlList lbadd (_x select 3);
|
||||
_ctrlList lbadd (_settingsColor);
|
||||
_ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 8)];
|
||||
}foreach GVAR(clientSideColors);
|
||||
};
|
||||
_color = +(_x select 8);
|
||||
{
|
||||
_color set [_forEachIndex, ((round (_x * 100))/100)];
|
||||
} forEach _color;
|
||||
_settingsColor = str _color;
|
||||
_ctrlList lbadd (_x select 3);
|
||||
_ctrlList lbadd (_settingsColor);
|
||||
_ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 8)];
|
||||
}foreach GVAR(clientSideColors);
|
||||
};
|
||||
};
|
||||
if (_updateKeyView) then {
|
||||
[] call FUNC(settingsMenuUpdateKeyView);
|
||||
[] call FUNC(settingsMenuUpdateKeyView);
|
||||
};
|
||||
|
@ -1,12 +1,18 @@
|
||||
/**
|
||||
* fnc_updateSetting.sqf
|
||||
* @Descr:
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: true
|
||||
*/
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Upidates a setting.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Type Of setting <NUMBER>
|
||||
* 1: Name of setting <STRING>
|
||||
* 2: New value <ANY>
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_changed"];
|
||||
|
Loading…
Reference in New Issue
Block a user