From 2565a80a22133f5708db5cf707ef0129e352da26 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 10 Aug 2015 17:19:30 -0500 Subject: [PATCH] #2098 - Option Menu Fixes for categories Use lbValue to store the index of the filtered selection --- .../functions/fnc_onCategorySelectChanged.sqf | 4 ++-- .../fnc_onListBoxSettingsChanged.sqf | 22 ++++++++++-------- .../functions/fnc_onServerSaveInputField.sqf | 6 ++++- .../functions/fnc_onSettingsMenuOpen.sqf | 2 +- .../functions/fnc_onSliderPosChanged.sqf | 8 +++++-- .../fnc_serverSettingsMenuUpdateKeyView.sqf | 23 +++++-------------- .../fnc_serverSettingsMenuUpdateList.sqf | 21 ++++++++++++----- .../fnc_settingsMenuUpdateKeyView.sqf | 23 ++++++------------- .../functions/fnc_settingsMenuUpdateList.sqf | 15 ++++++++---- .../functions/fnc_stringEscape.sqf | 2 +- addons/optionsmenu/gui/settingsMenu.hpp | 2 +- 11 files changed, 68 insertions(+), 60 deletions(-) diff --git a/addons/optionsmenu/functions/fnc_onCategorySelectChanged.sqf b/addons/optionsmenu/functions/fnc_onCategorySelectChanged.sqf index 3b97892cdb..3129e32bef 100644 --- a/addons/optionsmenu/functions/fnc_onCategorySelectChanged.sqf +++ b/addons/optionsmenu/functions/fnc_onCategorySelectChanged.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" -private ["_settingsMenu"]; +private ["_settingsMenu", "_ctrlComboBox"]; disableSerialization; _settingsMenu = uiNamespace getVariable 'ACE_settingsMenu'; @@ -24,4 +24,4 @@ _settingsMenu = uiNamespace getVariable 'ACE_settingsMenu'; _ctrlComboBox = (_settingsMenu displayCtrl 14); GVAR(currentCategorySelection) = lbCurSel _ctrlComboBox; -[false] call FUNC(settingsMenuUpdateList); +[true] call FUNC(settingsMenuUpdateList); diff --git a/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf b/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf index 1543a2c8d5..e1be221531 100644 --- a/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf +++ b/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf @@ -16,26 +16,30 @@ #include "script_component.hpp" -private ["_settingIndex", "_rightDropDownIndex"]; +private ["_settingsMenu", "_settingIndex", "_rightDropDownIndex"]; -_settingIndex = lbCurSel 200; //Index of left list _rightDropDownIndex = lbCurSel 400; //Index of right drop down - if (_rightDropDownIndex < 0) then {_rightDropDownIndex = 0;}; +_settingIndex = -1; +if (((lbCurSel 200) >= 0) && {(lbCurSel 200) < ((lbSize 200)/2)}) then { + _settingIndex = lbValue [200, (lbCurSel 200)]; +}; +if (_settingIndex == -1) exitWith {}; + switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_OPTIONS): { if ((_settingIndex >= 0) && (_settingIndex < (count GVAR(clientSideOptions)))) then { - _settingIndex = (GVAR(clientSideOptions) select _settingIndex) select 0; - [MENU_TAB_OPTIONS, _settingIndex, _rightDropDownIndex] call FUNC(updateSetting); + _settingIndex = (GVAR(clientSideOptions) select _settingIndex) select 0; + [MENU_TAB_OPTIONS, _settingIndex, _rightDropDownIndex] call FUNC(updateSetting); }; [false] call FUNC(settingsMenuUpdateList); - }; + }; case (MENU_TAB_SERVER_OPTIONS): { if ((_settingIndex >= 0) && (_settingIndex < (count GVAR(serverSideOptions)))) then { - _settingIndex = (GVAR(serverSideOptions) select _settingIndex) select 0; - [MENU_TAB_SERVER_OPTIONS, _settingIndex, _rightDropDownIndex] call FUNC(updateSetting); + _settingIndex = (GVAR(serverSideOptions) select _settingIndex) select 0; + [MENU_TAB_SERVER_OPTIONS, _settingIndex, _rightDropDownIndex] call FUNC(updateSetting); }; [false] call FUNC(serverSettingsMenuUpdateList); - }; + }; }; diff --git a/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf b/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf index 11aadc76e4..de37bc620d 100644 --- a/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf +++ b/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf @@ -18,9 +18,13 @@ private ["_settingIndex", "_inputText", "_setting", "_settingName", "_convertedValue"]; -_settingIndex = lbCurSel 200; //Index of left list _inputText = ctrlText 414; //Index of right drop down +_settingIndex = -1; +if (((lbCurSel 200) >= 0) && {(lbCurSel 200) < ((lbSize 200)/2)}) then { + _settingIndex = lbValue [200, (lbCurSel 200)]; +}; + switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_SERVER_VALUES): { if ((_settingIndex >= 0) && (_settingIndex < (count GVAR(serverSideValues)))) then { diff --git a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf index af3e2232f3..4feace3b55 100644 --- a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf +++ b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf @@ -56,7 +56,7 @@ if (GVAR(serverConfigGeneration) == 0) then { lbClear (_menu displayCtrl 14); { if (_x == "") then { - _x = localize "STR_ACE_OptionsMenu_category_all"; + _x = localize LSTRING(category_all); }; if (isLocalized _x) then {_x = localize _x}; (_menu displayCtrl 14) lbAdd _x; diff --git a/addons/optionsmenu/functions/fnc_onSliderPosChanged.sqf b/addons/optionsmenu/functions/fnc_onSliderPosChanged.sqf index b69d8bd734..549b60484f 100644 --- a/addons/optionsmenu/functions/fnc_onSliderPosChanged.sqf +++ b/addons/optionsmenu/functions/fnc_onSliderPosChanged.sqf @@ -16,9 +16,13 @@ #include "script_component.hpp" -private ["_newColor", "_settingIndex"]; +private ["_newColor", "_settingIndex", "_settingsMenu"]; -_settingIndex = lbCurSel 200; +_settingIndex = -1; +if (((lbCurSel 200) >= 0) && {(lbCurSel 200) < ((lbSize 200)/2)}) then { + _settingIndex = lbValue [200, (lbCurSel 200)]; +}; +if (_settingIndex == -1) exitWith {}; switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_COLORS): { diff --git a/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateKeyView.sqf b/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateKeyView.sqf index ac25d719e1..c78bbd7e53 100644 --- a/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateKeyView.sqf +++ b/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateKeyView.sqf @@ -29,24 +29,13 @@ _collection = switch (GVAR(optionMenu_openTab)) do { default {[]}; }; -_selectedCategory = GVAR(categories) select GVAR(currentCategorySelection); -_filteredCollection = []; -{ - if (_selectedCategory == "" || {_selectedCategory == (_x select 8)}) then { - _filteredCollection pushBack _x; - }; -} forEach _collection; +_settingIndex = -1; +if (((lbCurSel _ctrlList) >= 0) && {(lbCurSel _ctrlList) < ((lbSize _ctrlList)/2)}) then { + _settingIndex = _ctrlList lbValue (lbCurSel _ctrlList); +}; -if (count _filteredCollection > 0) then { - _settingIndex = (lbCurSel _ctrlList); - if (_settingIndex > (count _filteredCollection)) then { - _settingIndex = count _filteredCollection - 1; - }; - - if (_settingIndex < 0) then { - _settingIndex = 0; - }; - _setting = _filteredCollection select _settingIndex; +if ((_settingIndex >= 0) && {_settingIndex <= (count _collection)}) then { + _setting = _collection select _settingIndex; _entryName = _setting select 0; _localizedName = _setting select 3; diff --git a/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateList.sqf b/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateList.sqf index 4a6648878a..f418d63b5a 100644 --- a/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateList.sqf +++ b/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateList.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" -private ["_settingsMenu", "_ctrlList", "_settingsText", "_color", "_settingsColor", "_updateKeyView", "_settingsValue", "_selectedCategory"]; +private ["_added", "_settingsMenu", "_ctrlList", "_settingsText", "_color", "_settingsColor", "_updateKeyView", "_settingsValue", "_selectedCategory"]; DEFAULT_PARAM(0,_updateKeyView,true); disableSerialization; @@ -27,11 +27,11 @@ lbclear _ctrlList; _selectedCategory = GVAR(categories) select GVAR(currentCategorySelection); - +_added = 0; switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_SERVER_OPTIONS): { { - if (_selectedCategory == "" || _selectedCategory == (_X select 8)) then { + if (_selectedCategory == "" || {_selectedCategory == (_x select 8)}) then { if ((_x select 3) != "") then { _ctrlList lbadd (_x select 3); } else { @@ -48,12 +48,15 @@ switch (GVAR(optionMenu_openTab)) do { }; _ctrlList lbadd (_settingsText); + + _ctrlList lbSetValue [_added, _forEachIndex]; + _added = _added + 1; }; }foreach GVAR(serverSideOptions); }; case (MENU_TAB_SERVER_COLORS): { { - if (_selectedCategory == "" || _selectedCategory == (_X select 8)) then { + if (_selectedCategory == "" || {_selectedCategory == (_x select 8)}) then { _color = +(_x select 9); { _color set [_forEachIndex, ((round (_x * 100))/100)]; @@ -66,22 +69,28 @@ switch (GVAR(optionMenu_openTab)) do { }; _ctrlList lbadd (_settingsColor); _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 9)]; + + _ctrlList lbSetValue [_added, _forEachIndex]; + _added = _added + 1; }; }foreach GVAR(serverSideColors); }; case (MENU_TAB_SERVER_VALUES): { { - if (_selectedCategory == "" || _selectedCategory == (_X select 8)) then { + if (_selectedCategory == "" || {_selectedCategory == (_x select 8)}) then { if ((_x select 3) != "") then { _ctrlList lbadd (_x select 3); } else { _ctrlList lbadd (_x select 0); }; _settingsValue = _x select 9; - if (typeName _settingsValue != "STRINg") then { + if (typeName _settingsValue != "STRING") then { _settingsValue = format["%1", _settingsValue]; }; _ctrlList lbadd (_settingsValue); + + _ctrlList lbSetValue [_added, _forEachIndex]; + _added = _added + 1; }; }foreach GVAR(serverSideValues); }; diff --git a/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf b/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf index 442a1ceb50..21440125ea 100644 --- a/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf +++ b/addons/optionsmenu/functions/fnc_settingsMenuUpdateKeyView.sqf @@ -28,24 +28,15 @@ _collection = switch (GVAR(optionMenu_openTab)) do { default {[]}; }; -_selectedCategory = GVAR(categories) select GVAR(currentCategorySelection); -_filteredCollection = []; -{ - if (_selectedCategory == "" || {_selectedCategory == (_x select 8)}) then { - _filteredCollection pushBack _x; - }; -} forEach _collection; +_settingIndex = -1; +if (((lbCurSel _ctrlList) >= 0) && {(lbCurSel _ctrlList) < ((lbSize _ctrlList)/2)}) then { + _settingIndex = _ctrlList lbValue (lbCurSel _ctrlList); +}; -if (count _filteredCollection > 0) then { - _settingIndex = (lbCurSel _ctrlList); - if (_settingIndex > (count _filteredCollection)) then { - _settingIndex = count _filteredCollection - 1; - }; +TRACE_3("Selected",_settingIndex,(lbCurSel _ctrlList),((lbSize _ctrlList)/2)); - if (_settingIndex < 0) then { - _settingIndex = 0; - }; - _setting = _filteredCollection select _settingIndex; +if ((_settingIndex >= 0) && {_settingIndex <= (count _collection)}) then { + _setting = _collection select _settingIndex; _entryName = _setting select 0; _localizedName = _setting select 3; diff --git a/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf b/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf index 18075a1844..ea31e4b759 100644 --- a/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf +++ b/addons/optionsmenu/functions/fnc_settingsMenuUpdateList.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" -private ["_settingsMenu", "_ctrlList", "_settingsText", "_color", "_settingsColor", "_updateKeyView", "_settingsValue", "_selectedCategory"]; +private ["_added", "_settingsMenu", "_ctrlList", "_settingsText", "_color", "_settingsColor", "_updateKeyView", "_settingsValue", "_selectedCategory"]; DEFAULT_PARAM(0,_updateKeyView,true); disableSerialization; @@ -27,10 +27,11 @@ lbclear _ctrlList; _selectedCategory = GVAR(categories) select GVAR(currentCategorySelection); +_added = 0; switch (GVAR(optionMenu_openTab)) do { case (MENU_TAB_OPTIONS): { { - if (_selectedCategory == "" || _selectedCategory == (_X select 8)) then { + if (_selectedCategory == "" || {_selectedCategory == (_x select 8)}) then { _ctrlList lbadd (_x select 3); _settingsValue = _x select 9; @@ -41,12 +42,15 @@ switch (GVAR(optionMenu_openTab)) do { (_x select 5) select _settingsValue; }; _ctrlList lbadd (_settingsText); + + _ctrlList lbSetValue [_added, _forEachIndex]; + _added = _added + 1; }; - }foreach GVAR(clientSideOptions); + } foreach GVAR(clientSideOptions); }; case (MENU_TAB_COLORS): { { - if (_selectedCategory == "" || _selectedCategory == (_X select 8)) then { + if (_selectedCategory == "" || {_selectedCategory == (_x select 8)}) then { _color = +(_x select 9); { _color set [_forEachIndex, ((round (_x * 100))/100)]; @@ -55,6 +59,9 @@ switch (GVAR(optionMenu_openTab)) do { _ctrlList lbadd (_x select 3); _ctrlList lbadd (_settingsColor); _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 9)]; + + _ctrlList lbSetValue [_added, _forEachIndex]; + _added = _added + 1; }; }foreach GVAR(clientSideColors); }; diff --git a/addons/optionsmenu/functions/fnc_stringEscape.sqf b/addons/optionsmenu/functions/fnc_stringEscape.sqf index fe3930f68c..1493f76445 100644 --- a/addons/optionsmenu/functions/fnc_stringEscape.sqf +++ b/addons/optionsmenu/functions/fnc_stringEscape.sqf @@ -14,7 +14,7 @@ * Public: No */ -private ["_str", "_array", "_maxIndex"]; +private ["_str", "_array", "_maxIndex", "_isEven"]; _str = _this; _isEven = { diff --git a/addons/optionsmenu/gui/settingsMenu.hpp b/addons/optionsmenu/gui/settingsMenu.hpp index 2c79bdab1d..d2f3ea7996 100644 --- a/addons/optionsmenu/gui/settingsMenu.hpp +++ b/addons/optionsmenu/gui/settingsMenu.hpp @@ -277,7 +277,7 @@ class ACE_settingsMenu { }; class ACE_serverSettingsMenu: ACE_settingsMenu { onLoad = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', _this select 0)]; [] call FUNC(onServerSettingsMenuOpen);); - onUnload = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', nil)];); + onUnload = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', nil)]; [] call FUNC(onSettingsMenuOpen);); class controls: controls { class HeaderName { idc = 1;