Formatting, indentation, minor refactoring + fix for opening settings menu

This commit is contained in:
Glowbal 2015-03-06 18:15:32 +01:00
parent 39be8ffbe7
commit 8064253a4d
8 changed files with 212 additions and 181 deletions

View File

@ -1,12 +1,15 @@
/** /*
* fnc_onListBoxSettingsChanged.sqf * Author: Glowbal
* @Descr: N/A * Called when a listbox selection is changed.
* @Author: Glowbal *
* * Arguments:
* @Arguments: [] *
* @Return: * Return Value:
* @PublicAPI: false * NONE
*/ *
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_settingIndex", "_rightDropDownIndex"]; private ["_settingIndex", "_rightDropDownIndex"];

View File

@ -1,12 +1,16 @@
/** /*
* fnc_onListBoxShowSelectionChanged.sqf * Author: Glowbal
* @Descr: called when the listbox selection has changed. Updates configuration menu information * called when the listbox selection has changed. Updates configuration menu information
* @Author: Glowbal *
* * Arguments:
* @Arguments: [] * 0: Opened category or tab <STRING>
* @Return: *
* @PublicAPI: false * Return Value:
*/ * NONE
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_settingsMenu", "_localizedHeader"]; private ["_settingsMenu", "_localizedHeader"];

View File

@ -1,33 +1,36 @@
/** /*
* fnc_onSettingsMenuOpen.sqf * Author: Glowbal
* @Descr: called when the settings or configuration menu has opened. Do not use anywhere else. * called when the settings or configuration menu has opened. Do not use anywhere else.
* @Author: Glowbal *
* * Arguments:
* @Arguments: [] *
* @Return: * Return Value:
* @PublicAPI: false * NONE
*/ *
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
// Filter only user setable setting // Filter only user setable setting
GVAR(clientSideOptions) = []; GVAR(clientSideOptions) = [];
GVAR(clientSideColors) = []; GVAR(clientSideColors) = [];
{ {
// If the setting is user setable and not forced // If the setting is user setable and not forced
if ((_x select 2) && !(_x select 6)) then { if ((_x select 2) && !(_x select 6)) then {
// Append the current value to the setting metadata // Append the current value to the setting metadata
_setting = + _x; _setting = + _x;
_setting pushBack (missionNamespace getVariable (_x select 0)); _setting pushBack (missionNamespace getVariable (_x select 0));
// Categorize the setting according to types // Categorize the setting according to types
// @todo: allow the user to modify other types of parameters? // @todo: allow the user to modify other types of parameters?
if ((_x select 1) == "SCALAR" || (_x select 1) == "BOOL") then { if ((_x select 1) == "SCALAR" || (_x select 1) == "BOOL") then {
GVAR(clientSideOptions) pushBack _setting; GVAR(clientSideOptions) pushBack _setting;
}; };
if ((_x select 1) == "COLOR") then { if ((_x select 1) == "COLOR") then {
GVAR(clientSideColors) pushBack _setting; GVAR(clientSideColors) pushBack _setting;
}; };
}; };
} forEach EGVAR(common,settings); } forEach EGVAR(common,settings);
//Delay a frame //Delay a frame

View File

@ -1,29 +1,34 @@
/** /*
* fnc_onSliderPosChanged.sqf * Author: PabstMirror
* @Descr: N/A * Called when a slider position is changed.
* @Author: PabstMirror *
* * Arguments:
* @Arguments: [] *
* @Return: * Return Value:
* @PublicAPI: false * NONE
*/ *
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_newColor", "_settingIndex"]; private ["_newColor", "_settingIndex"];
_newColor = [];
{
_newColor pushBack ((sliderPosition _x) / 255);
} forEach [410, 411, 412, 413];
_settingIndex = lbCurSel 200; _settingIndex = lbCurSel 200;
switch (GVAR(optionMenu_openTab)) do { switch (GVAR(optionMenu_openTab)) do {
case (MENU_TAB_COLORS): { case (MENU_TAB_COLORS): {
if ((_settingIndex >= 0) && (_settingIndex < (count GVAR(clientSideColors)))) then {
_settingIndex = (GVAR(clientSideColors) select _settingIndex) select 0; _newColor = [];
[MENU_TAB_COLORS, _settingIndex, _newColor] call FUNC(updateSetting); {
}; _newColor pushBack ((sliderPosition _x) / 255);
[false] call FUNC(settingsMenuUpdateList); } 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 {};
}; };

View File

@ -1,30 +1,33 @@
/** /*
* fnc_resetSettings.sqf * Author: Glowbal
* @Descr: * Sets all client side settings back to default.
* @Author: Glowbal *
* * Arguments:
* @Arguments: [] *
* @Return: * Return Value:
* @PublicAPI: true * NONE
*/ *
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_name", "_default", "_lastSelected"]; private ["_name", "_default", "_lastSelected"];
{ {
_name = _x select 0; _name = _x select 0;
_default = _x select 7; _default = _x select 7;
[MENU_TAB_OPTIONS, _name, _default] call FUNC(updateSetting); [MENU_TAB_OPTIONS, _name, _default] call FUNC(updateSetting);
} forEach GVAR(clientSideOptions); } forEach GVAR(clientSideOptions);
{ {
_name = _x select 0; _name = _x select 0;
_default = _x select 7; _default = _x select 7;
[MENU_TAB_COLORS, _name, _default] call FUNC(updateSetting); [MENU_TAB_COLORS, _name, _default] call FUNC(updateSetting);
} forEach GVAR(clientSideColors); } forEach GVAR(clientSideColors);
_lastSelected = lbCurSel 200; _lastSelected = lbCurSel 200;
[GVAR(optionMenu_openTab)] call FUNC(onListBoxShowSelectionChanged); [GVAR(optionMenu_openTab)] call FUNC(onListBoxShowSelectionChanged);
if (_lastSelected != -1) then { if (_lastSelected != -1) then {
lbSetCurSel [200, _lastSelected]; lbSetCurSel [200, _lastSelected];
}; };

View File

@ -1,12 +1,15 @@
/** /*
* fnc_settingsMenuUpdateKeyView.sqf * Author: Glowbal
* @Descr: N/A * Updates the view on the right side with the selected settings details
* @Author: Glowbal *
* * Arguments:
* @Arguments: [] *
* @Return: * Return Value:
* @PublicAPI: false * NONE
*/ *
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_settingsMenu", "_ctrlList", "_collection", "_settingIndex", "_setting", "_entryName", "_localizedName", "_localizedDescription", "_possibleValues", "_settingsValue", "_currentColor"]; 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; _ctrlList = _settingsMenu displayCtrl 200;
_collection = switch (GVAR(optionMenu_openTab)) do { _collection = switch (GVAR(optionMenu_openTab)) do {
case MENU_TAB_OPTIONS: {GVAR(clientSideOptions)}; case MENU_TAB_OPTIONS: {GVAR(clientSideOptions)};
case MENU_TAB_COLORS: {GVAR(clientSideColors)}; case MENU_TAB_COLORS: {GVAR(clientSideColors)};
default {[]}; default {[]};
}; };
if (count _collection > 0) then { if (count _collection > 0) then {
_settingIndex = (lbCurSel _ctrlList); _settingIndex = (lbCurSel _ctrlList);
if (_settingIndex > (count _collection)) then { if (_settingIndex > (count _collection)) then {
_settingIndex = count _collection - 1; _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;
}; };
case (MENU_TAB_COLORS): {
_currentColor = _setting select 8; if (_settingIndex < 0) then {
{ _settingIndex = 0;
sliderSetPosition [_x, (255 * (_currentColor select _forEachIndex))]; };
} forEach [410, 411, 412, 413]; _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: } else { //no settings in list:
lbClear 400; lbClear 400;
(_settingsMenu displayCtrl 250) ctrlSetText _localizedName; (_settingsMenu displayCtrl 250) ctrlSetText "No settings available";
(_settingsMenu displayCtrl 251) ctrlSetText _localizedDescription; (_settingsMenu displayCtrl 251) ctrlSetText "No settings available";
(_settingsMenu displayCtrl 300) ctrlSetText _entryName; (_settingsMenu displayCtrl 300) ctrlSetText "No settings available";
}; };

View File

@ -1,12 +1,16 @@
/** /*
* fnc_settingsMenuUpdateList.sqf * Author: Glowbal
* @Descr: N/A * Updates the list with all settings in the menu.
* @Author: Glowbal *
* * Arguments:
* @Arguments: [] * 0: update The selection view <BOOL>
* @Return: *
* @PublicAPI: false * Return Value:
*/ * NONE
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_settingsMenu", "_ctrlList", "_settingsText", "_color", "_settingsColor", "_updateKeyView"]; private ["_settingsMenu", "_ctrlList", "_settingsText", "_color", "_settingsColor", "_updateKeyView"];
@ -19,35 +23,35 @@ _ctrlList = _settingsMenu displayCtrl 200;
lbclear _ctrlList; lbclear _ctrlList;
switch (GVAR(optionMenu_openTab)) do { 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); _color = +(_x select 8);
{
_settingsValue = _x select 8; _color set [_forEachIndex, ((round (_x * 100))/100)];
} forEach _color;
// Created disable/enable options for bools _settingsColor = str _color;
_settingsText = if ((_x select 1) == "BOOL") then { _ctrlList lbadd (_x select 3);
[(localize "STR_ACE_OptionsMenu_Disabled"), (localize "STR_ACE_OptionsMenu_Enabled")] select _settingsValue; _ctrlList lbadd (_settingsColor);
} else { _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 8)];
(_x select 5) select _settingsValue; }foreach GVAR(clientSideColors);
}; };
_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);
};
}; };
if (_updateKeyView) then { if (_updateKeyView) then {
[] call FUNC(settingsMenuUpdateKeyView); [] call FUNC(settingsMenuUpdateKeyView);
}; };

View File

@ -1,12 +1,18 @@
/** /*
* fnc_updateSetting.sqf * Author: Glowbal
* @Descr: * Upidates a setting.
* @Author: Glowbal *
* * Arguments:
* @Arguments: [] * 0: Type Of setting <NUMBER>
* @Return: * 1: Name of setting <STRING>
* @PublicAPI: true * 2: New value <ANY>
*/ *
* Return Value:
* NONE
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_changed"]; private ["_changed"];