From 7a091215e1f2e316cfce51eda87a5382138a366e Mon Sep 17 00:00:00 2001 From: Glowbal Date: Fri, 27 Mar 2015 16:26:18 +0100 Subject: [PATCH 01/13] Draft #188 --- .../functions/fnc_loadSettingsOnServer.sqf | 56 ++++++------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/addons/common/functions/fnc_loadSettingsOnServer.sqf b/addons/common/functions/fnc_loadSettingsOnServer.sqf index 2548c44bec..96e025cff7 100644 --- a/addons/common/functions/fnc_loadSettingsOnServer.sqf +++ b/addons/common/functions/fnc_loadSettingsOnServer.sqf @@ -15,52 +15,32 @@ GVAR(settings) = []; -// Load settings from main config -_countOptions = count (configFile >> "ACE_Settings"); -for "_index" from 0 to (_countOptions - 1) do { - _optionEntry = (configFile >> "ACE_Settings") select _index; +_parseConfigForSettings = { + private ["_config", "_countOptions", "_optionEntry", "_index"]; - [_optionEntry] call FUNC(setSettingFromConfig); -}; -// Check if all settings should be forced -if (GVAR(forceAllSettings)) then { - { - _x set [6, true]; - } forEach GVAR(settings); -}; - -// @todo -// Load settings from server userconfig only if the ACE_ServerSettings is loaded -/*if (isClass (configFile >> "CfgPatches" >> "ACE_ServerSettings")) then { - DFUNC(serverUserConfig) = compile preprocessFileLineNumbers "\userconfig\ACE\ACE_Settings.hpp"; - if !(isNil DFUNC(serverUserConfig)) then { - [] call FUNC(serverUserConfig); + _config = _this select 0; + _countOptions = count _config; + for "_index" from 0 to (_countOptions - 1) do { + _optionEntry = _config select _index; + [_optionEntry] call FUNC(setSettingFromConfig); }; // Check if all settings should be forced if (GVAR(forceAllSettings)) then { { - if !(missionNamespace getVariable format ["%1_forced", _x]) then { - missionNamespace setVariable format ["%1_forced", _x, true]; - publicVariable format ["%1_forced", _name]; - }; - } forEach GVAR(settingsList); + _x set [6, true]; + } forEach GVAR(settings); }; -};*/ - -// Load settings from mission config -_countOptions = count (missionConfigFile >> "ACE_Settings"); -for "_index" from 0 to (_countOptions - 1) do { - _optionEntry = (missionConfigFile >> "ACE_Settings") select _index; - - [_optionEntry] call FUNC(setSettingFromConfig); -}; -// Check if all settings should be forced -if (GVAR(forceAllSettings)) then { - { - _x set [6, true]; - } forEach GVAR(settings); }; +// Server config +[configFile >> "ACE_ServerSettings"] call _parseConfigForSettings; + +// Regular config +[configFile >> "ACE_Settings"] call _parseConfigForSettings; + +// mission side settings +[missionConfigFile >> "ACE_Settings"] call _parseConfigForSettings; + // Publish all settings data publicVariable QGVAR(settings); // Publish all setting values From 9713b505ee39ae53b71fc58cfac722fb35a5a1b4 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Fri, 27 Mar 2015 20:35:44 +0100 Subject: [PATCH 02/13] Optional server config file --- optionals/server/config.cpp | 17 +++++++++++++++++ optionals/server/script_component.hpp | 12 ++++++++++++ optionals/userconfig/ace/serverconfig.hpp | 8 ++++++++ 3 files changed, 37 insertions(+) create mode 100644 optionals/server/config.cpp create mode 100644 optionals/server/script_component.hpp create mode 100644 optionals/userconfig/ace/serverconfig.hpp diff --git a/optionals/server/config.cpp b/optionals/server/config.cpp new file mode 100644 index 0000000000..9cfcb35012 --- /dev/null +++ b/optionals/server/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Glowbal"}; + authorUrl = "https://github.com/Glowbal/"; + VERSION_CONFIG; + }; +}; + +class ACE_ServerSettings { + #include "\userconfig\ace\serverconfig.hpp" +}; diff --git a/optionals/server/script_component.hpp b/optionals/server/script_component.hpp new file mode 100644 index 0000000000..f044c9601a --- /dev/null +++ b/optionals/server/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT serverconfig +#include "\z\ace\Addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_SERVERCONFIG + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_SERVERCONFIG + #define DEBUG_SETTINGS DEBUG_SETTINGS_SERVERCONFIG +#endif + +#include "\z\ace\Addons\main\script_macros.hpp" diff --git a/optionals/userconfig/ace/serverconfig.hpp b/optionals/userconfig/ace/serverconfig.hpp new file mode 100644 index 0000000000..950d08986b --- /dev/null +++ b/optionals/userconfig/ace/serverconfig.hpp @@ -0,0 +1,8 @@ + +// TODO fill with all possible settings ? + +// Example: +class ACE_common_forceAllSettings { + value = 0; + typeName = "BOOL"; +}; From 8e457d43ff7e7d9e03461a7e717c2f38cfc62738 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 4 Apr 2015 22:58:14 +0200 Subject: [PATCH 03/13] Update serverconfig.hpp --- optionals/userconfig/ace/serverconfig.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/optionals/userconfig/ace/serverconfig.hpp b/optionals/userconfig/ace/serverconfig.hpp index 950d08986b..ebabfe12bd 100644 --- a/optionals/userconfig/ace/serverconfig.hpp +++ b/optionals/userconfig/ace/serverconfig.hpp @@ -1,6 +1,4 @@ -// TODO fill with all possible settings ? - // Example: class ACE_common_forceAllSettings { value = 0; From 7928ca71a5c7f7fc20e23fd14cabe4dcec8acef8 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 02:17:43 +0200 Subject: [PATCH 04/13] Server side config export --- addons/optionsmenu/CfgVehicles.hpp | 28 +++ addons/optionsmenu/XEH_preInit.sqf | 15 ++ addons/optionsmenu/config.cpp | 4 +- .../functions/fnc_exportSettings.sqf | 57 +++++ .../functions/fnc_moduleAllowConfigExport.sqf | 25 +++ .../fnc_onListBoxSettingsChanged.sqf | 21 +- ...nc_onServerListBoxShowSelectionChanged.sqf | 88 ++++++++ .../functions/fnc_onServerSaveInputField.sqf | 43 ++++ .../fnc_onServerSettingsMenuOpen.sqf | 59 +++++ .../functions/fnc_onSettingsMenuOpen.sqf | 9 + .../functions/fnc_onSliderPosChanged.sqf | 13 ++ .../functions/fnc_serverResetSettings.sqf | 43 ++++ .../fnc_serverSettingsMenuUpdateKeyView.sqf | 94 ++++++++ .../fnc_serverSettingsMenuUpdateList.sqf | 81 +++++++ .../fnc_toggleIncludeClientSettings.sqf | 27 +++ .../functions/fnc_updateSetting.sqf | 76 +++++-- addons/optionsmenu/gui/settingsMenu.hpp | 208 +++++++++++++++++- addons/optionsmenu/script_component.hpp | 3 + addons/optionsmenu/stringtable.xml | 30 +++ 19 files changed, 895 insertions(+), 29 deletions(-) create mode 100644 addons/optionsmenu/CfgVehicles.hpp create mode 100644 addons/optionsmenu/functions/fnc_exportSettings.sqf create mode 100644 addons/optionsmenu/functions/fnc_moduleAllowConfigExport.sqf create mode 100644 addons/optionsmenu/functions/fnc_onServerListBoxShowSelectionChanged.sqf create mode 100644 addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf create mode 100644 addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf create mode 100644 addons/optionsmenu/functions/fnc_serverResetSettings.sqf create mode 100644 addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateKeyView.sqf create mode 100644 addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateList.sqf create mode 100644 addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf diff --git a/addons/optionsmenu/CfgVehicles.hpp b/addons/optionsmenu/CfgVehicles.hpp new file mode 100644 index 0000000000..cd352782a1 --- /dev/null +++ b/addons/optionsmenu/CfgVehicles.hpp @@ -0,0 +1,28 @@ +class CfgVehicles { + class ACE_Module; + // TODO localization for all the modules + class ACE_moduleAllowConfigExport: ACE_Module { + scope = 2; + displayName = "Allow Config Export [ACE]"; + //icon = ""; + category = "ACE"; + function = QUOTE(DFUNC(moduleAllowConfigExport)); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + author = "$STR_ACE_Common_ACETeam"; + class Arguments { + class allowconfigurationExport { + displayName = "Allow"; + description = "Allow export of all settings to a server config formatted."; + typeName = "BOOL"; + defaultValue = 0; + }; + }; + class ModuleDescription { + description = "When allowed, you have access to the settings modification and export in SP. Clicking export will place the formated config on your clipboard."; + sync[] = {}; + }; + }; + +}; \ No newline at end of file diff --git a/addons/optionsmenu/XEH_preInit.sqf b/addons/optionsmenu/XEH_preInit.sqf index 83a50bce65..42f50287f2 100644 --- a/addons/optionsmenu/XEH_preInit.sqf +++ b/addons/optionsmenu/XEH_preInit.sqf @@ -6,12 +6,27 @@ PREP(onListBoxSettingsChanged); PREP(onListBoxShowSelectionChanged); PREP(onSettingsMenuOpen); PREP(onSliderPosChanged); +PREP(onServerSaveInputField); +PREP(onServerSettingsMenuOpen); +PREP(onServerListBoxShowSelectionChanged); PREP(resetSettings); +PREP(serverResetSettings); PREP(settingsMenuUpdateKeyView); PREP(settingsMenuUpdateList); +PREP(serverSettingsMenuUpdateKeyView); +PREP(serverSettingsMenuUpdateList); PREP(updateSetting); +PREP(exportSettings); +PREP(toggleIncludeClientSettings); +PREP(moduleAllowConfigExport); GVAR(clientSideOptions) = []; GVAR(clientSideColors) = []; +GVAR(serverConfigGeneration) = 0; +GVAR(ClientSettingsExportIncluded) = false; +GVAR(serverSideOptions) = []; +GVAR(serverSideColors) = []; +GVAR(serverSideValues) = []; + ADDON = true; diff --git a/addons/optionsmenu/config.cpp b/addons/optionsmenu/config.cpp index 7850e5972e..89d5768603 100644 --- a/addons/optionsmenu/config.cpp +++ b/addons/optionsmenu/config.cpp @@ -2,7 +2,7 @@ class CfgPatches { class ADDON { - units[] = {}; + units[] = {"ACE_moduleAllowConfigExport"}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; @@ -25,3 +25,5 @@ class CfgAddons { #include "gui\define.hpp" #include "gui\settingsMenu.hpp" #include "gui\pauseMenu.hpp" + +#include "CFgVehicles.hpp" diff --git a/addons/optionsmenu/functions/fnc_exportSettings.sqf b/addons/optionsmenu/functions/fnc_exportSettings.sqf new file mode 100644 index 0000000000..51ca7d447b --- /dev/null +++ b/addons/optionsmenu/functions/fnc_exportSettings.sqf @@ -0,0 +1,57 @@ +/* + * Author: Glowbal + * Export all config settings with their current values. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ACE_optionsmenu_fnc_exportSettings + * + * Public: No + */ + +#include "script_component.hpp" + +_compiledConfig = " +"; +{ + /*_settingData = [ + _name, + _typeName, + _isClientSetable, + _localizedName, + _localizedDescription, + _possibleValues, + _isForced, + _defaultValue + ];*/ + + _name = _x select 0; + _typeName = _x select 1; + _isClientSetable = _x select 2; + _localizedName = _x select 3; + _localizedDescription = _x select 4; + _possibleValues = _x select 5; + _defaultValue = _x select 6; + + if (GVAR(ClientSettingsExportIncluded) || !_isClientSetable) then { + _value = missionNamespace getvariable [_name, _defaultValue]; + if (_typeName == "STRING") then { // I dont think we have string values, but just in case + _value = format['"%1"', _value]; + }; + + _compiledConfigEntry = format [" + class %1 { + value = %2; + typeName = %3; + }; + ", _name, _value, format['"%1"', _typeName]]; + _compiledConfig = _compiledConfig + _compiledConfigEntry; + }; +} forEach EGVAR(common,settings); + +copyToClipboard format["%1",_compiledConfig]; diff --git a/addons/optionsmenu/functions/fnc_moduleAllowConfigExport.sqf b/addons/optionsmenu/functions/fnc_moduleAllowConfigExport.sqf new file mode 100644 index 0000000000..1d98384a09 --- /dev/null +++ b/addons/optionsmenu/functions/fnc_moduleAllowConfigExport.sqf @@ -0,0 +1,25 @@ +/* + * Author: Glowbal + * + * + * Arguments: + * none + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_logic"]; +_logic = _this select 0; + +if (isMultiplayer) exitwith {}; + +if (_logic getvariable ["allowconfigurationExport", false]) then { + GVAR(serverConfigGeneration) = 1; +} else { + GVAR(serverConfigGeneration) = 0; +}; diff --git a/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf b/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf index 5846d0dccb..50b2d5302a 100644 --- a/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf +++ b/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf @@ -24,11 +24,18 @@ _rightDropDownIndex = lbCurSel 400; //Index of right drop down if (_rightDropDownIndex < 0) then {_rightDropDownIndex = 0;}; 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); - }; - [false] call FUNC(settingsMenuUpdateList); - }; + 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); + }; + [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); + }; + [false] call FUNC(serverSettingsMenuUpdateList); + }; }; diff --git a/addons/optionsmenu/functions/fnc_onServerListBoxShowSelectionChanged.sqf b/addons/optionsmenu/functions/fnc_onServerListBoxShowSelectionChanged.sqf new file mode 100644 index 0000000000..aaeec2d9ac --- /dev/null +++ b/addons/optionsmenu/functions/fnc_onServerListBoxShowSelectionChanged.sqf @@ -0,0 +1,88 @@ +/* + * Author: Glowbal + * Changes which tab is open (options or colors) + * + * Arguments: + * The tab to open (defined in script_component) + * + * Return Value: + * None + * + * Example: + * [MENU_TAB_COLORS] call ACE_optionsmenu_fnc_onListBoxShowSelectionChanged + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_settingsMenu", "_localizedHeader"]; + +PARAMS_1(_openTab); +GVAR(optionMenu_openTab) = _openTab; + +disableSerialization; +_settingsMenu = uiNamespace getVariable 'ACE_serverSettingsMenu'; + +switch (GVAR(optionMenu_openTab)) do { +case (MENU_TAB_SERVER_OPTIONS): { + _localizedHeader = format ["%1: %2", (localize "STR_ACE_OptionsMenu_OpenConfigMenu"), (localize "STR_ACE_OptionsMenu_TabOptions")]; + ctrlSetText [13, _localizedHeader]; + lbClear 400; + + (_settingsMenu displayCtrl 301) ctrlShow true; + + (_settingsMenu displayCtrl 400) ctrlShow true; + (_settingsMenu displayCtrl 410) ctrlShow false; + (_settingsMenu displayCtrl 411) ctrlShow false; + (_settingsMenu displayCtrl 412) ctrlShow false; + (_settingsMenu displayCtrl 413) ctrlShow false; + (_settingsMenu displayCtrl 414) ctrlShow false; + (_settingsMenu displayCtrl 415) ctrlShow false; + (_settingsMenu displayCtrl 416) ctrlShow false; + (_settingsMenu displayCtrl 416) ctrlEnable false; + }; +case (MENU_TAB_SERVER_COLORS): { + _localizedHeader = format ["%1: %2", (localize "STR_ACE_OptionsMenu_OpenConfigMenu"), (localize "STR_ACE_OptionsMenu_TabColors")]; + ctrlSetText [13, _localizedHeader]; + + lbClear 400; + + (_settingsMenu displayCtrl 301) ctrlShow false; + + (_settingsMenu displayCtrl 400) ctrlShow false; + (_settingsMenu displayCtrl 410) ctrlShow true; + (_settingsMenu displayCtrl 411) ctrlShow true; + (_settingsMenu displayCtrl 412) ctrlShow true; + (_settingsMenu displayCtrl 413) ctrlShow true; + + (_settingsMenu displayCtrl 410) sliderSetRange [0, 255]; + (_settingsMenu displayCtrl 411) sliderSetRange [0, 255]; + (_settingsMenu displayCtrl 412) sliderSetRange [0, 255]; + (_settingsMenu displayCtrl 413) sliderSetRange [0, 255]; + + (_settingsMenu displayCtrl 414) ctrlShow false; + (_settingsMenu displayCtrl 415) ctrlShow false; + (_settingsMenu displayCtrl 416) ctrlShow false; + (_settingsMenu displayCtrl 416) ctrlEnable false; + }; +case (MENU_TAB_SERVER_VALUES): { + _localizedHeader = format ["%1: %2", (localize "STR_ACE_OptionsMenu_OpenConfigMenu"), (localize "STR_ACE_OptionsMenu_TabValues")]; + ctrlSetText [13, _localizedHeader]; + + lbClear 400; + (_settingsMenu displayCtrl 301) ctrlShow false; + (_settingsMenu displayCtrl 400) ctrlShow false; + (_settingsMenu displayCtrl 410) ctrlShow false; + (_settingsMenu displayCtrl 411) ctrlShow false; + (_settingsMenu displayCtrl 412) ctrlShow false; + (_settingsMenu displayCtrl 413) ctrlShow false; + + (_settingsMenu displayCtrl 414) ctrlShow true; + (_settingsMenu displayCtrl 415) ctrlShow true; + (_settingsMenu displayCtrl 416) ctrlShow true; + (_settingsMenu displayCtrl 416) ctrlEnable true; + }; +}; + +[true] call FUNC(serverSettingsMenuUpdateList); diff --git a/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf b/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf new file mode 100644 index 0000000000..f4dc6956c4 --- /dev/null +++ b/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf @@ -0,0 +1,43 @@ +/* + * Author: Glowbal + * Called when the listbox selection is changed for an options (eg: chaning a setting from false to true) + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ACE_optionsmenu_fnc_onListBoxSettingsChanged + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_settingIndex", "_inputText"]; + +_settingIndex = lbCurSel 200; //Index of left list +_inputText = ctrlText 414; //Index of right drop down + +switch (GVAR(optionMenu_openTab)) do { + case (MENU_TAB_SERVER_VALUES): { + if ((_settingIndex >= 0) && (_settingIndex < (count GVAR(serverSideValues)))) then { + try { + _setting = (GVAR(serverSideValues) select _settingIndex); + _settingName = _setting select 0; + + _convertedValue = switch (toUpper (_setting select 1)) do { + case "STRING": {format ['"%1"', _inputText]}; + case "ARRAY": {format [call compile "[%1]", _inputText]}; + case "SCALAR": {parseNumber _inputText;}; + default {throw "Error"}; + }; + [MENU_TAB_SERVER_VALUES, _settingName, _convertedValue] call FUNC(updateSetting); + } catch { + }; + }; + [false] call FUNC(serverSettingsMenuUpdateList); + }; +}; diff --git a/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf b/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf new file mode 100644 index 0000000000..b419e25b32 --- /dev/null +++ b/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf @@ -0,0 +1,59 @@ +/* + * Author: Glowbal + * Called from the onLoad of ACE_settingsMenu dialog. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [onLoadEvent] call ACE_optionsmenu_fnc_onSettingsMenuOpen + * + * Public: No + */ + +#include "script_component.hpp" + +// Filter only user setable setting +GVAR(serverSideOptions) = []; +GVAR(serverSideColors) = []; +GVAR(serverSideValues) = []; +{ + _name = _x select 0; + _typeName = _x select 1; + _isClientSetable = _x select 2; + _localizedName = _x select 3; + _localizedDescription = _x select 4; + _possibleValues = _x select 5; + _defaultValue = _x select 6; + + // Exclude client side options if they are not included for the export + if (!(_isClientSetable) || GVAR(ClientSettingsExportIncluded)) 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 ((_typeName == "SCALAR" && count _possibleValues > 0) || (_x select 1) == "BOOL") then { + GVAR(serverSideOptions) pushBack _setting; + }; + if (_typeName == "COLOR") then { + GVAR(serverSideColors) pushBack _setting; + }; + if ((_typeName == "SCALAR" && count _possibleValues == 0) || _typeName == "ARRAY" || _typeName == "STRING") then { + GVAR(serverSideValues) pushBack _setting; + }; + }; +} forEach EGVAR(common,settings); + +//Delay a frame +[{ [MENU_TAB_SERVER_OPTIONS] call FUNC(onServerListBoxShowSelectionChanged) }, []] call EFUNC(common,execNextFrame); + +private "_menu"; +disableSerialization; +_menu = uiNamespace getvariable "ACE_serverSettingsMenu"; +(_menu displayCtrl 1003) ctrlEnable false; + diff --git a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf index 7c5f03af0b..66f803b1f2 100644 --- a/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf +++ b/addons/optionsmenu/functions/fnc_onSettingsMenuOpen.sqf @@ -16,6 +16,10 @@ #include "script_component.hpp" +if (isMultiplayer /* || !(GVAR(allowServerConfigGeneration))*/) exitwith { + closeDialog 0; +}; + // Filter only user setable setting GVAR(clientSideOptions) = []; GVAR(clientSideColors) = []; @@ -45,3 +49,8 @@ disableSerialization; _menu = uiNamespace getvariable "ACE_settingsMenu"; (_menu displayCtrl 1002) ctrlEnable false; (_menu displayCtrl 1003) ctrlEnable false; + +if (GVAR(serverConfigGeneration) == 0) then { + (_menu displayCtrl 1102) ctrlEnable false; + (_menu displayCtrl 1102) ctrlShow false; +}; diff --git a/addons/optionsmenu/functions/fnc_onSliderPosChanged.sqf b/addons/optionsmenu/functions/fnc_onSliderPosChanged.sqf index 4e0e603862..b69d8bd734 100644 --- a/addons/optionsmenu/functions/fnc_onSliderPosChanged.sqf +++ b/addons/optionsmenu/functions/fnc_onSliderPosChanged.sqf @@ -34,5 +34,18 @@ switch (GVAR(optionMenu_openTab)) do { }; [false] call FUNC(settingsMenuUpdateList); }; + case (MENU_TAB_SERVER_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_SERVER_COLORS, _settingIndex, _newColor] call FUNC(updateSetting); + }; + [false] call FUNC(serverSettingsMenuUpdateList); + }; default {}; }; diff --git a/addons/optionsmenu/functions/fnc_serverResetSettings.sqf b/addons/optionsmenu/functions/fnc_serverResetSettings.sqf new file mode 100644 index 0000000000..434e622818 --- /dev/null +++ b/addons/optionsmenu/functions/fnc_serverResetSettings.sqf @@ -0,0 +1,43 @@ +/* + * Author: Glowbal + * Resets all server settings to default. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ACE_optionsmenu_fnc_onListBoxSettingsChanged + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_name", "_default", "_lastSelected"]; + +{ + _name = _x select 0; + _default = _x select 7; + [MENU_TAB_SERVER_OPTIONS, _name, _default] call FUNC(updateSetting); +} forEach GVAR(serverSideOptions); + +{ + _name = _x select 0; + _default = _x select 7; + [MENU_TAB_SERVER_COLORS, _name, _default] call FUNC(updateSetting); +} forEach GVAR(serverSideColors); + +{ + _name = _x select 0; + _default = _x select 7; + [MENU_TAB_SERVER_VALUES, _name, _default] call FUNC(updateSetting); +} forEach GVAR(serverSideVakyes); + +_lastSelected = lbCurSel 200; +[GVAR(optionMenu_openTab)] call FUNC(onserverListBoxShowSelectionChanged); +if (_lastSelected != -1) then { + lbSetCurSel [200, _lastSelected]; +}; diff --git a/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateKeyView.sqf b/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateKeyView.sqf new file mode 100644 index 0000000000..2dcf9f7fe7 --- /dev/null +++ b/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateKeyView.sqf @@ -0,0 +1,94 @@ +/* + * Author: Glowbal + * Updates the right half of the option menu for the currently selected option. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ACE_optionsmenu_fnc_settingsMenuUpdateKeyView + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_settingsMenu", "_ctrlList", "_collection", "_settingIndex", "_setting", "_entryName", "_localizedName", "_localizedDescription", "_possibleValues", "_settingsValue", "_currentColor"]; +disableSerialization; + +_settingsMenu = uiNamespace getVariable 'ACE_serverSettingsMenu'; +_ctrlList = _settingsMenu displayCtrl 200; + +_collection = switch (GVAR(optionMenu_openTab)) do { + case MENU_TAB_SERVER_OPTIONS: {GVAR(serverSideOptions)}; + case MENU_TAB_SERVER_COLORS: {GVAR(serverSideColors)}; + case MENU_TAB_SERVER_VALUES: {GVAR(serverSideValues)}; + default {[]}; +}; + +if (count _collection > 0) then { + _settingIndex = (lbCurSel _ctrlList); + if (_settingIndex > (count _collection)) then { + _settingIndex = count _collection - 1; + }; + + 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_SERVER_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_SERVER_COLORS): { + _currentColor = _setting select 8; + { + sliderSetPosition [_x, (255 * (_currentColor select _forEachIndex))]; + } forEach [410, 411, 412, 413]; + }; + case (MENU_TAB_SERVER_VALUES): { + // TODO implement + _settingsValue = _setting select 8; + + // Created disable/enable options for bools + _expectedType = switch (_setting select 1) do { + case "STRING": {"STR_ACE_OptionsMenu_stringType"}; + case "ARRAY": {"STR_ACE_OptionsMenu_arrayType"}; + case "SCALAR": {"STR_ACE_OptionsMenu_scalarType"}; + default {"STR_ACE_optionsMenu_unknownType"}; + }; + (_settingsMenu displayCtrl 414) ctrlSetText format["%1", _settingsValue]; + (_settingsMenu displayCtrl 415) ctrlSetText format[localize _expectedType]; + }; + }; +} else { //no settings in list: + lbClear 400; + (_settingsMenu displayCtrl 250) ctrlSetText "No settings available"; + (_settingsMenu displayCtrl 251) ctrlSetText "No settings available"; + (_settingsMenu displayCtrl 300) ctrlSetText "No settings available"; +}; diff --git a/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateList.sqf b/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateList.sqf new file mode 100644 index 0000000000..ad5d647c16 --- /dev/null +++ b/addons/optionsmenu/functions/fnc_serverSettingsMenuUpdateList.sqf @@ -0,0 +1,81 @@ +/* + * Author: Glowbal + * Updates the setting when the client has selected a new value. Saves to profilenamespace. + * + * Arguments: + * 0: Update the keylist as well + * + * Return Value: + * None + * + * Example: + * [false] call ACE_optionsmenu_fnc_settingsMenuUpdateList + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_settingsMenu", "_ctrlList", "_settingsText", "_color", "_settingsColor", "_updateKeyView"]; +DEFAULT_PARAM(0,_updateKeyView,true); + +disableSerialization; +_settingsMenu = uiNamespace getVariable 'ACE_serverSettingsMenu'; +_ctrlList = _settingsMenu displayCtrl 200; + +lbclear _ctrlList; +switch (GVAR(optionMenu_openTab)) do { + case (MENU_TAB_SERVER_OPTIONS): { + { + if ((_x select 3) != "") then { + _ctrlList lbadd (_x select 3); + } else { + _ctrlList lbadd (_x select 0); + }; + + _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(serverSideOptions); + }; + case (MENU_TAB_SERVER_COLORS): { + { + _color = +(_x select 8); + { + _color set [_forEachIndex, ((round (_x * 100))/100)]; + } forEach _color; + _settingsColor = str _color; + if ((_x select 3) != "") then { + _ctrlList lbadd (_x select 3); + } else { + _ctrlList lbadd (_x select 0); + }; + _ctrlList lbadd (_settingsColor); + _ctrlList lnbSetColor [[_forEachIndex, 1], (_x select 8)]; + }foreach GVAR(serverSideColors); + }; + case (MENU_TAB_SERVER_VALUES): { + { + if ((_x select 3) != "") then { + _ctrlList lbadd (_x select 3); + } else { + _ctrlList lbadd (_x select 0); + }; + _settingsValue = _x select 8; + if (typeName _settingsValue != "STRINg") then { + _settingsValue = format["%1", _settingsValue]; + }; + _ctrlList lbadd (_settingsValue); + }foreach GVAR(serverSideValues); + }; +}; +if (_updateKeyView) then { + [] call FUNC(serverSettingsMenuUpdateKeyView); +}; diff --git a/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf b/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf new file mode 100644 index 0000000000..0558c81831 --- /dev/null +++ b/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf @@ -0,0 +1,27 @@ +/* + * Author: Glowbal + * + * + * Arguments: + * none + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +GVAR(ClientSettingsExportIncluded) = !(GVAR(ClientSettingsExportIncluded)); + +private "_settingsMenu"; +disableSerialization; +_settingsMenu = uiNamespace getVariable 'ACE_serverSettingsMenu'; +if (GVAR(ClientSettingsExportIncluded)) then { + (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_exClientSettings"); +} else { + (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_inClientSettings"); +}; + +[] call FUNC(onServerSettingsMenuOpen); diff --git a/addons/optionsmenu/functions/fnc_updateSetting.sqf b/addons/optionsmenu/functions/fnc_updateSetting.sqf index bc5969d54c..d1a7825671 100644 --- a/addons/optionsmenu/functions/fnc_updateSetting.sqf +++ b/addons/optionsmenu/functions/fnc_updateSetting.sqf @@ -24,33 +24,69 @@ PARAMS_3(_type,_name,_newValue); _changed = false; switch (_type) do { -case (MENU_TAB_OPTIONS): { - { - if ((_x select 0) == _name) then { + case (MENU_TAB_OPTIONS): { + { + if ((_x select 0) == _name) then { + + if ((_x select 1) == "BOOL") then { + _newValue = [false, true] select _newValue; + }; + + if !((_x select 8) isEqualTo _newValue) then { + _changed = true; + _x set [8, _newValue]; + } ; - if ((_x select 1) == "BOOL") then { - _newValue = [false, true] select _newValue; }; - - if !((_x select 8) isEqualTo _newValue) then { + } foreach GVAR(clientSideOptions); + }; + case (MENU_TAB_COLORS): { + { + if (((_x select 0) == _name) && {!((_x select 8) isEqualTo _newValue)}) then { _changed = true; _x set [8, _newValue]; - } ; - - }; - } foreach GVAR(clientSideOptions); + }; + } foreach GVAR(clientSideColors); }; -case (MENU_TAB_COLORS): { - { - if (((_x select 0) == _name) && {!((_x select 8) isEqualTo _newValue)}) then { - _changed = true; - _x set [8, _newValue]; - }; - } foreach GVAR(clientSideColors); + case (MENU_TAB_SERVER_OPTIONS): { + { + if ((_x select 0) == _name) then { + + if ((_x select 1) == "BOOL") then { + _newValue = [false, true] select _newValue; + }; + + if !((_x select 8) isEqualTo _newValue) then { + _changed = true; + _x set [8, _newValue]; + } ; + + }; + } foreach GVAR(serverSideOptions); + }; + case (MENU_TAB_SERVER_COLORS): { + { + if (((_x select 0) == _name) && {!((_x select 8) isEqualTo _newValue)}) then { + _changed = true; + _x set [8, _newValue]; + }; + } foreach GVAR(serverSideColors); + }; + case (MENU_TAB_SERVER_VALUES): { + { + if (((_x select 0) == _name) && {!((_x select 8) isEqualTo _newValue)}) then { + _changed = true; + _x set [8, _newValue]; + }; + } foreach GVAR(serverSideValues); }; }; if (_changed) then { - profileNamespace setVariable [_name, _newValue]; - [_name, _newValue] call EFUNC(common,setSetting); + if (GVAR(serverConfigGeneration) > 0) then { + missionNamespace setvariable [_name, _newValue]; + } else { + profileNamespace setVariable [_name, _newValue]; + [_name, _newValue] call EFUNC(common,setSetting); + }; }; diff --git a/addons/optionsmenu/gui/settingsMenu.hpp b/addons/optionsmenu/gui/settingsMenu.hpp index 995c7850a5..d5c8eeeb84 100644 --- a/addons/optionsmenu/gui/settingsMenu.hpp +++ b/addons/optionsmenu/gui/settingsMenu.hpp @@ -228,5 +228,211 @@ class ACE_settingsMenu { x = 26.1 * (SIZEX / 40) + OFFSETX; action = QUOTE([] call FUNC(resetSettings)); }; + class action_exportServerConfig: actionClose { + idc = 1102; + text = "$STR_ACE_OptionsMenu_OpenExport"; + x = 1 * (SIZEX / 40) + OFFSETX; + action = QUOTE(if (GVAR(serverConfigGeneration) > 0) then {createDialog 'ACE_serverSettingsMenu'; }); + }; }; -}; \ No newline at end of file +}; +class ACE_serverSettingsMenu: ACE_settingsMenu { + onLoad = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', _this select 0)]; [] call FUNC(onServerSettingsMenuOpen); GVAR(serverConfigGeneration) = true;); + onUnload = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', nil)]; GVAR(serverConfigGeneration) = false;); + class controls: controls { + class HeaderName { + idc = 1; + type = CT_STATIC; + x = 1 * UNITX + OFFSETX; + y = 1 * UNITY + OFFSETY; + w = 38 * UNITX; + h = 1 * UNITY; + style = ST_LEFT + ST_SHADOW; + font = "PuristaMedium"; + SizeEx = (UNITY * 1); + colorText[] = {0.95, 0.95, 0.95, 0.75}; + colorBackground[] = {0,0,0,0}; + text = "$STR_ACE_OptionsMenu_OpenConfigMenu"; + }; + class labelSubHeader: ACE_gui_staticBase { + idc = 13; + x = 2 * UNITX + OFFSETX; + y = 3.4 * UNITY + OFFSETY; + w = 30 * UNITX; + h = 1 * UNITY; + text = ""; + }; + class selectionAction_1: ACE_gui_buttonBase { + idc = 1000; + text = "$STR_ACE_OptionsMenu_TabOptions"; + x = 1 * UNITX + OFFSETX; + y = 2.1 * UNITY + OFFSETY; + w = 9.5 * UNITX; + h = 1 * UNITY; + animTextureNormal = "#(argb,8,8,3)color(0,0,0,0.9)"; + animTextureDisabled = "#(argb,8,8,3)color(0,0,0,0.8)"; + animTextureOver = "#(argb,8,8,3)color(1,1,1,1)"; + animTextureFocused = "#(argb,8,8,3)color(1,1,1,1)"; + animTexturePressed = "#(argb,8,8,3)color(1,1,1,1)"; + animTextureDefault = "#(argb,8,8,3)color(1,1,1,1)"; + color[] = {1, 1, 1, 1}; + color2[] = {0,0,0, 1}; + colorBackgroundFocused[] = {1,1,1,1}; + colorBackground[] = {1,1,1,1}; + colorbackground2[] = {1,1,1,1}; + colorDisabled[] = {1,1,1,1}; + colorFocused[] = {0,0,0,1}; + periodFocus = 1; + periodOver = 1; + action = QUOTE([MENU_TAB_SERVER_OPTIONS] call FUNC(onServerListBoxShowSelectionChanged);); + }; + class selectionAction_2: selectionAction_1 { + idc = 1001; + text = "$STR_ACE_OptionsMenu_TabColors"; + x = 10.5 * UNITX + OFFSETX; + action = QUOTE([MENU_TAB_SERVER_COLORS] call FUNC(onServerListBoxShowSelectionChanged);); + }; + class selectionAction_3: selectionAction_1 { + idc = 1002; + text = "$STR_ACE_OptionsMenu_TabValues"; + x = 20 * UNITX + OFFSETX; + action = QUOTE([MENU_TAB_SERVER_VALUES] call FUNC(onServerListBoxShowSelectionChanged);); + }; + class selectionAction_4: selectionAction_1 { + idc = 1003; + text = ""; + x = 29.5 * UNITX + OFFSETX; + action = ""; + }; + class listBoxSettingsList: ACE_gui_listNBox { + idc = 200; + x = 2 * UNITX + OFFSETX; + y = 5.5 * UNITY + OFFSETY; + w = 23 * UNITX; + h = 15 * UNITY; + SizeEx = (UNITY * 0.8); + colorBackground[] = {0, 0, 0, 0.9}; + colorSelectBackground[] = {0, 0, 0, 0.9}; + columns[] = {0.0, 0.6}; + onLBSelChanged = QUOTE(_this call FUNC(serverSettingsMenuUpdateKeyView)); + }; + class labelTitle: ACE_gui_staticBase { + idc = 250; + x = 27.1 * UNITX + OFFSETX; + y = 5.1 * UNITY + OFFSETY; + w = 11 * UNITX; + h = 1 * UNITY; + text = ""; + SizeEx = (UNITY *1); + }; + class labelKey: ACE_gui_staticBase { //Variable Name + idc = 300; + x = 27.1 * UNITX + OFFSETX; + y = 6.2 * UNITY + OFFSETY; + w = 11 * UNITX; + h = 1 * UNITY; + text = ""; + SizeEx = (UNITY * 0.65); + }; + class Label2: labelKey { + idc = 301; + y = 7.3 * UNITY + OFFSETY; + text = "$STR_ACE_OptionsMenu_Setting"; + SizeEx = (UNITY * 1); + }; + class comboBox1: ACE_gui_comboBoxBase { + idc = 400; + x = 31.1 * UNITX + OFFSETX; + y = 7.3 * UNITY + OFFSETY; + w = 7 * UNITX; + h = 1 * UNITY; + onLBSelChanged = QUOTE( call FUNC(onListBoxSettingsChanged)); + SizeEx = (UNITY * 0.9); + }; + class sliderBar1: RscXSliderH { + idc = 410; + x = 27.1 * UNITX + OFFSETX; + y = 7.3 * UNITY + OFFSETY; + w = 11 * UNITX; + h = 0.75 * UNITY; + onSliderPosChanged = QUOTE(_this call FUNC(onSliderPosChanged)); + color[] = {1,0,0,0.4}; + colorActive[] = {1,0,0,1}; + }; + class sliderBar2: sliderBar1 { + idc = 411; + y = 8.2 * UNITY + OFFSETY; + color[] = {0,1,0,0.4}; + colorActive[] = {0,1,0,1}; + }; + class sliderBar3: sliderBar1 { + idc = 412; + y = 9.1 * UNITY + OFFSETY; + color[] = {0,0,1,0.4}; + colorActive[] = {0,0,1,1}; + }; + class sliderBar4: sliderBar1 { + idc = 413; + y = 10 * UNITY + OFFSETY; + color[] = {1,1,1,0.4}; + colorActive[] = {1,1,1,1}; + }; + class inputField1: ACE_gui_editBase { + idc = 414; + x = 27.1 * UNITX + OFFSETX; + y = 7.3 * UNITY + OFFSETY; + w = 11 * UNITX; + h = 0.75 * UNITY; + }; + class inputFieldTypeLabel: ACE_gui_staticBase { + idc = 415; + x = 27.1 * UNITX + OFFSETX; + y = 8.2 * UNITY + OFFSETY; + w = 11 * UNITX; + h = 0.75 * UNITY; + text = ""; + style = ST_LEFT + ST_MULTI; + lineSpacing = 1; + SizeEx = (UNITY * 0.8); + }; + class saveInputButton: selectionAction_1 { + idc = 416; + text = "$STR_ACE_OptionsMenu_SaveInput"; + x = 27.1 * UNITX + OFFSETX; + y = 9.1 * UNITY + OFFSETY; + w = 11 * UNITX; + h = 1 * UNITY; + action = QUOTE([] call FUNC(onServerSaveInputField);); + }; + class labelDesc: ACE_gui_staticBase { + idc = 251; + x = 27.1 * UNITX + OFFSETX; + y = 11 * UNITY + OFFSETY; + w = 11 * UNITX; + h = 11 * UNITY; + text = ""; + style = ST_LEFT + ST_MULTI; + lineSpacing = 1; + SizeEx = (UNITY * 0.8); + }; + class actionClose; + class action_reset: actionClose { + idc = 1100; + text = "$STR_ACE_OptionsMenu_ResetAll"; + x = 26.1 * (SIZEX / 40) + OFFSETX; + action = QUOTE([] call FUNC(serverResetSettings)); + }; + class action_exportServerConfig: actionClose { + idc = 1101; + text = "$STR_ACE_OptionsMenu_Export"; + x = 1 * (SIZEX / 40) + OFFSETX; + action = QUOTE([] call FUNC(exportSettings)); + }; + class action_toggleIncludeClientSettings: actionClose { + idc = 1102; + text = "$STR_ACE_OptionsMenu_inClientSettings"; + x = 9 * (SIZEX / 40) + OFFSETX; + action = QUOTE([] call FUNC(toggleIncludeClientSettings)); + }; + }; +}; diff --git a/addons/optionsmenu/script_component.hpp b/addons/optionsmenu/script_component.hpp index 5120791b76..7b86dbe0dd 100644 --- a/addons/optionsmenu/script_component.hpp +++ b/addons/optionsmenu/script_component.hpp @@ -17,3 +17,6 @@ #define MENU_TAB_OPTIONS 0 #define MENU_TAB_COLORS 1 +#define MENU_TAB_SERVER_OPTIONS 10 +#define MENU_TAB_SERVER_COLORS 11 +#define MENU_TAB_SERVER_VALUES 12 diff --git a/addons/optionsmenu/stringtable.xml b/addons/optionsmenu/stringtable.xml index bb5744ab16..4a8c574755 100644 --- a/addons/optionsmenu/stringtable.xml +++ b/addons/optionsmenu/stringtable.xml @@ -39,6 +39,9 @@ Opciók Opzioni + + Values + Yes Ja @@ -70,5 +73,32 @@ Yстановки: Ajuste: + + Export + + + Open Export Menu + + + String input. + + + Array. Seperate elements by using ,. + + + Number + + + Uknown input type + + + Save input + + + Include Client Settings + + + Exclude Client Settings + \ No newline at end of file From a0af0559170665ae717ef312718909895f647236 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 02:22:24 +0200 Subject: [PATCH 05/13] export config should force the settings --- addons/optionsmenu/functions/fnc_exportSettings.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/optionsmenu/functions/fnc_exportSettings.sqf b/addons/optionsmenu/functions/fnc_exportSettings.sqf index 51ca7d447b..252933ffdf 100644 --- a/addons/optionsmenu/functions/fnc_exportSettings.sqf +++ b/addons/optionsmenu/functions/fnc_exportSettings.sqf @@ -48,6 +48,7 @@ _compiledConfig = " class %1 { value = %2; typeName = %3; + force = 1; }; ", _name, _value, format['"%1"', _typeName]]; _compiledConfig = _compiledConfig + _compiledConfigEntry; From 110635df7b0a7194bb0912c0e9bd933c5d616aee Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 02:33:11 +0200 Subject: [PATCH 06/13] improved formatting --- addons/optionsmenu/functions/fnc_exportSettings.sqf | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/optionsmenu/functions/fnc_exportSettings.sqf b/addons/optionsmenu/functions/fnc_exportSettings.sqf index 252933ffdf..bb94d38db3 100644 --- a/addons/optionsmenu/functions/fnc_exportSettings.sqf +++ b/addons/optionsmenu/functions/fnc_exportSettings.sqf @@ -45,12 +45,11 @@ _compiledConfig = " }; _compiledConfigEntry = format [" - class %1 { - value = %2; - typeName = %3; - force = 1; - }; - ", _name, _value, format['"%1"', _typeName]]; +class %1 { + value = %2; + typeName = %3; + force = 1; +};", _name, _value, format['"%1"', _typeName]]; _compiledConfig = _compiledConfig + _compiledConfigEntry; }; } forEach EGVAR(common,settings); From d487092d845839fd7c8fc33b18da026ed2f6de78 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 02:33:45 +0200 Subject: [PATCH 07/13] formatting --- .../functions/fnc_exportSettings.sqf | 4 +-- .../functions/fnc_moduleAllowConfigExport.sqf | 4 +-- .../fnc_onListBoxSettingsChanged.sqf | 28 +++++++++---------- .../functions/fnc_onServerSaveInputField.sqf | 28 +++++++++---------- .../fnc_toggleIncludeClientSettings.sqf | 4 +-- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/addons/optionsmenu/functions/fnc_exportSettings.sqf b/addons/optionsmenu/functions/fnc_exportSettings.sqf index bb94d38db3..8718698a18 100644 --- a/addons/optionsmenu/functions/fnc_exportSettings.sqf +++ b/addons/optionsmenu/functions/fnc_exportSettings.sqf @@ -19,7 +19,7 @@ _compiledConfig = " "; { - /*_settingData = [ + /*_settingData = [ _name, _typeName, _isClientSetable, @@ -41,7 +41,7 @@ _compiledConfig = " if (GVAR(ClientSettingsExportIncluded) || !_isClientSetable) then { _value = missionNamespace getvariable [_name, _defaultValue]; if (_typeName == "STRING") then { // I dont think we have string values, but just in case - _value = format['"%1"', _value]; + _value = format['"%1"', _value]; }; _compiledConfigEntry = format [" diff --git a/addons/optionsmenu/functions/fnc_moduleAllowConfigExport.sqf b/addons/optionsmenu/functions/fnc_moduleAllowConfigExport.sqf index 1d98384a09..d756a0ef83 100644 --- a/addons/optionsmenu/functions/fnc_moduleAllowConfigExport.sqf +++ b/addons/optionsmenu/functions/fnc_moduleAllowConfigExport.sqf @@ -19,7 +19,7 @@ _logic = _this select 0; if (isMultiplayer) exitwith {}; if (_logic getvariable ["allowconfigurationExport", false]) then { - GVAR(serverConfigGeneration) = 1; + GVAR(serverConfigGeneration) = 1; } else { - GVAR(serverConfigGeneration) = 0; + GVAR(serverConfigGeneration) = 0; }; diff --git a/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf b/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf index 50b2d5302a..1543a2c8d5 100644 --- a/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf +++ b/addons/optionsmenu/functions/fnc_onListBoxSettingsChanged.sqf @@ -24,18 +24,18 @@ _rightDropDownIndex = lbCurSel 400; //Index of right drop down if (_rightDropDownIndex < 0) then {_rightDropDownIndex = 0;}; 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); - }; - [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); - }; - [false] call FUNC(serverSettingsMenuUpdateList); - }; + 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); + }; + [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); + }; + [false] call FUNC(serverSettingsMenuUpdateList); + }; }; diff --git a/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf b/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf index f4dc6956c4..ca4a00891a 100644 --- a/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf +++ b/addons/optionsmenu/functions/fnc_onServerSaveInputField.sqf @@ -22,22 +22,22 @@ _settingIndex = lbCurSel 200; //Index of left list _inputText = ctrlText 414; //Index of right drop down switch (GVAR(optionMenu_openTab)) do { - case (MENU_TAB_SERVER_VALUES): { + case (MENU_TAB_SERVER_VALUES): { if ((_settingIndex >= 0) && (_settingIndex < (count GVAR(serverSideValues)))) then { - try { - _setting = (GVAR(serverSideValues) select _settingIndex); - _settingName = _setting select 0; + try { + _setting = (GVAR(serverSideValues) select _settingIndex); + _settingName = _setting select 0; - _convertedValue = switch (toUpper (_setting select 1)) do { - case "STRING": {format ['"%1"', _inputText]}; - case "ARRAY": {format [call compile "[%1]", _inputText]}; - case "SCALAR": {parseNumber _inputText;}; - default {throw "Error"}; - }; - [MENU_TAB_SERVER_VALUES, _settingName, _convertedValue] call FUNC(updateSetting); - } catch { - }; - }; + _convertedValue = switch (toUpper (_setting select 1)) do { + case "STRING": {format ['"%1"', _inputText]}; + case "ARRAY": {format [call compile "[%1]", _inputText]}; + case "SCALAR": {parseNumber _inputText;}; + default {throw "Error"}; + }; + [MENU_TAB_SERVER_VALUES, _settingName, _convertedValue] call FUNC(updateSetting); + } catch { + }; + }; [false] call FUNC(serverSettingsMenuUpdateList); }; }; diff --git a/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf b/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf index 0558c81831..5713bf98e4 100644 --- a/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf +++ b/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf @@ -19,9 +19,9 @@ private "_settingsMenu"; disableSerialization; _settingsMenu = uiNamespace getVariable 'ACE_serverSettingsMenu'; if (GVAR(ClientSettingsExportIncluded)) then { - (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_exClientSettings"); + (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_exClientSettings"); } else { - (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_inClientSettings"); + (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_inClientSettings"); }; [] call FUNC(onServerSettingsMenuOpen); From 202904f1f99683bf8df0cf65bc0c5bfa6c86e13f Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 10:32:40 +0200 Subject: [PATCH 08/13] Using 1 and 0 instead of true and false for config export --- addons/optionsmenu/functions/fnc_exportSettings.sqf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/optionsmenu/functions/fnc_exportSettings.sqf b/addons/optionsmenu/functions/fnc_exportSettings.sqf index 8718698a18..de97a9065c 100644 --- a/addons/optionsmenu/functions/fnc_exportSettings.sqf +++ b/addons/optionsmenu/functions/fnc_exportSettings.sqf @@ -43,7 +43,9 @@ _compiledConfig = " if (_typeName == "STRING") then { // I dont think we have string values, but just in case _value = format['"%1"', _value]; }; - + if (_typeName == "BOOL") then { + _value = if (typeOf _value == "BOOL" && {_value}) then {1} else {0}; + }; _compiledConfigEntry = format [" class %1 { value = %2; From 279641787de443142159ed0c13dcb3efa0733fe3 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 11:11:54 +0200 Subject: [PATCH 09/13] Added checks for enforce usage only in SP with settings enabled --- addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf | 2 ++ addons/optionsmenu/functions/fnc_updateSetting.sqf | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf b/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf index b419e25b32..dcdffe9b64 100644 --- a/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf +++ b/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf @@ -16,6 +16,8 @@ #include "script_component.hpp" +if (GVAR(serverConfigGeneration) == 0 || isMultiplayer) exitwith {closeDialog 145246;}; + // Filter only user setable setting GVAR(serverSideOptions) = []; GVAR(serverSideColors) = []; diff --git a/addons/optionsmenu/functions/fnc_updateSetting.sqf b/addons/optionsmenu/functions/fnc_updateSetting.sqf index d1a7825671..3fe1682614 100644 --- a/addons/optionsmenu/functions/fnc_updateSetting.sqf +++ b/addons/optionsmenu/functions/fnc_updateSetting.sqf @@ -84,7 +84,9 @@ switch (_type) do { if (_changed) then { if (GVAR(serverConfigGeneration) > 0) then { - missionNamespace setvariable [_name, _newValue]; + if !(isMultiplayer) then { + missionNamespace setvariable [_name, _newValue]; + }; } else { profileNamespace setVariable [_name, _newValue]; [_name, _newValue] call EFUNC(common,setSetting); From f1a3d588ba7eac9251e59f1d63446df7a9ee7732 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 12:38:10 +0200 Subject: [PATCH 10/13] Changed initialization order of config settings. ACE_Settings should never force any setting by default. Loading it first ensures that all settings from ACE_Settings exist. This way, ACE_ServerSettings will override ACE_Settings, even if no force is used. Mission settings will override the server config settings, if no force is used. This ensures that all settings are of their correct type, in case an outdated or corrupt server config is used, as well as have their correct localized display name and description --- addons/common/functions/fnc_loadSettingsOnServer.sqf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/common/functions/fnc_loadSettingsOnServer.sqf b/addons/common/functions/fnc_loadSettingsOnServer.sqf index 96e025cff7..9255d047b3 100644 --- a/addons/common/functions/fnc_loadSettingsOnServer.sqf +++ b/addons/common/functions/fnc_loadSettingsOnServer.sqf @@ -32,12 +32,18 @@ _parseConfigForSettings = { }; }; -// Server config -[configFile >> "ACE_ServerSettings"] call _parseConfigForSettings; +// Order is this way because: +// ACE_Settings should never force any setting by default. Loading it first ensures that all settings from ACE_Settings exist. +// This way, ACE_ServerSettings will override ACE_Settings, even if no force is used. +// Mission settings will override the server config settings, if no force is used. +// This ensures that all settings are of their correct type, in case an outdated or corrupt server config is used , as well as have their correct localized display name and description // Regular config [configFile >> "ACE_Settings"] call _parseConfigForSettings; +// Server config +[configFile >> "ACE_ServerSettings"] call _parseConfigForSettings; + // mission side settings [missionConfigFile >> "ACE_Settings"] call _parseConfigForSettings; From bae3826bdf3a9ba27f33da5373e9ab90520bdc6a Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 14:48:23 +0200 Subject: [PATCH 11/13] Polished server config export --- addons/optionsmenu/functions/fnc_exportSettings.sqf | 2 ++ .../functions/fnc_onServerSettingsMenuOpen.sqf | 5 +++++ .../functions/fnc_toggleIncludeClientSettings.sqf | 9 --------- addons/optionsmenu/stringtable.xml | 3 +++ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/optionsmenu/functions/fnc_exportSettings.sqf b/addons/optionsmenu/functions/fnc_exportSettings.sqf index de97a9065c..9ef736ac1c 100644 --- a/addons/optionsmenu/functions/fnc_exportSettings.sqf +++ b/addons/optionsmenu/functions/fnc_exportSettings.sqf @@ -57,3 +57,5 @@ class %1 { } forEach EGVAR(common,settings); copyToClipboard format["%1",_compiledConfig]; + +["STR_ACE_OptionsMenu_settingsExported"] call EFUNC(common,displayTextStructured); diff --git a/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf b/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf index dcdffe9b64..7894d2ff1a 100644 --- a/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf +++ b/addons/optionsmenu/functions/fnc_onServerSettingsMenuOpen.sqf @@ -59,3 +59,8 @@ disableSerialization; _menu = uiNamespace getvariable "ACE_serverSettingsMenu"; (_menu displayCtrl 1003) ctrlEnable false; +if (GVAR(ClientSettingsExportIncluded)) then { + (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_exClientSettings"); +} else { + (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_inClientSettings"); +}; diff --git a/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf b/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf index 5713bf98e4..8fd52d8d72 100644 --- a/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf +++ b/addons/optionsmenu/functions/fnc_toggleIncludeClientSettings.sqf @@ -15,13 +15,4 @@ GVAR(ClientSettingsExportIncluded) = !(GVAR(ClientSettingsExportIncluded)); -private "_settingsMenu"; -disableSerialization; -_settingsMenu = uiNamespace getVariable 'ACE_serverSettingsMenu'; -if (GVAR(ClientSettingsExportIncluded)) then { - (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_exClientSettings"); -} else { - (_settingsMenu displayCtrl 1102) ctrlSetText localize ("STR_ACE_OptionsMenu_inClientSettings"); -}; - [] call FUNC(onServerSettingsMenuOpen); diff --git a/addons/optionsmenu/stringtable.xml b/addons/optionsmenu/stringtable.xml index 4a8c574755..76407da435 100644 --- a/addons/optionsmenu/stringtable.xml +++ b/addons/optionsmenu/stringtable.xml @@ -100,5 +100,8 @@ Exclude Client Settings + + Settings exported to clipboard + \ No newline at end of file From c514fde5d350f76740fa9df9bf8150881c4ff233 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 5 Apr 2015 15:13:34 +0200 Subject: [PATCH 12/13] Not necessary here. Makes it only work once. --- addons/optionsmenu/gui/settingsMenu.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/optionsmenu/gui/settingsMenu.hpp b/addons/optionsmenu/gui/settingsMenu.hpp index d5c8eeeb84..93d35b284c 100644 --- a/addons/optionsmenu/gui/settingsMenu.hpp +++ b/addons/optionsmenu/gui/settingsMenu.hpp @@ -237,8 +237,8 @@ class ACE_settingsMenu { }; }; class ACE_serverSettingsMenu: ACE_settingsMenu { - onLoad = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', _this select 0)]; [] call FUNC(onServerSettingsMenuOpen); GVAR(serverConfigGeneration) = true;); - onUnload = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', nil)]; GVAR(serverConfigGeneration) = false;); + onLoad = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', _this select 0)]; [] call FUNC(onServerSettingsMenuOpen);); + onUnload = QUOTE(uiNamespace setVariable [ARR_2('ACE_serverSettingsMenu', nil)];); class controls: controls { class HeaderName { idc = 1; From d6632a0e45be15d5f12cc3979c075d472c665760 Mon Sep 17 00:00:00 2001 From: jaynus Date: Sun, 5 Apr 2015 14:08:42 -0700 Subject: [PATCH 13/13] Module should default to true. --- addons/optionsmenu/CfgVehicles.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/optionsmenu/CfgVehicles.hpp b/addons/optionsmenu/CfgVehicles.hpp index cd352782a1..2a19aa2966 100644 --- a/addons/optionsmenu/CfgVehicles.hpp +++ b/addons/optionsmenu/CfgVehicles.hpp @@ -16,7 +16,7 @@ class CfgVehicles { displayName = "Allow"; description = "Allow export of all settings to a server config formatted."; typeName = "BOOL"; - defaultValue = 0; + defaultValue = 1; }; }; class ModuleDescription {