diff --git a/addons/settings/XEH_PREP.sqf b/addons/settings/XEH_PREP.sqf index 8c0631f45..88ba4861d 100644 --- a/addons/settings/XEH_PREP.sqf +++ b/addons/settings/XEH_PREP.sqf @@ -24,6 +24,7 @@ if (hasInterface) then { PREP(gui_settingList); PREP(gui_settingSlider); PREP(gui_settingColor); + PREP(gui_settingTime); PREP(gui_SettingDefault); PREP(gui_settingOverwrite); }; diff --git a/addons/settings/XEH_preInit.sqf b/addons/settings/XEH_preInit.sqf index df87edeb0..7e5e81c9b 100644 --- a/addons/settings/XEH_preInit.sqf +++ b/addons/settings/XEH_preInit.sqf @@ -20,6 +20,7 @@ ADDON = false; ["Test_Setting_3", "SLIDER", ["-test slider-", "-tooltip-"], "My Category", [0, 10, 5, 0]] call cba_settings_fnc_init; ["Test_Setting_4", "COLOR", ["-test color-", "-tooltip-"], "My Category", [1, 1 ,0], false, {diag_log text format ["Color Setting Changed: %1", _this];}] call cba_settings_fnc_init; ["Test_Setting_5", "COLOR", ["-test alpha-", "-tooltip-"], "My Category", [1, 0, 0, 0.5], false] call cba_settings_fnc_init; + ["Test_Setting_6", "TIME", ["-test time-", "-tooltip-"], "My Category", [0, 3600, 60], false] call cba_settings_fnc_init; ["Test_Padding", "LIST", "Padding test", "My Category", [[0,1,2,3,4,5,6,7,8,9,10], []]] call cba_settings_fnc_init; ["Test_1", "EDITBOX", "setting 1", "Test Category", "null", nil, {systemChat str [1, _this]}] call cba_settings_fnc_init; diff --git a/addons/settings/fnc_check.sqf b/addons/settings/fnc_check.sqf index 4cfb7692d..a007bf664 100644 --- a/addons/settings/fnc_check.sqf +++ b/addons/settings/fnc_check.sqf @@ -40,5 +40,9 @@ switch (toUpper _settingType) do { case "COLOR": { _value isEqualType [] && {count _value == count _defaultValue} && {_value isEqualTypeAll 0} && {{_x < 0 || _x > 1} count _value == 0} }; + case "TIME": { + _settingData params ["_min", "_max"]; + _value isEqualType 0 && {_value >= _min} && {_value <= _max} && {round _value == _value} + }; default {false}; }; diff --git a/addons/settings/fnc_gui_settingTime.sqf b/addons/settings/fnc_gui_settingTime.sqf new file mode 100644 index 000000000..4cfb9bf19 --- /dev/null +++ b/addons/settings/fnc_gui_settingTime.sqf @@ -0,0 +1,89 @@ +#include "script_component.hpp" + +params ["_controlsGroup", "_setting", "_source", "_currentValue", "_settingData"]; +_settingData params ["_min", "_max"]; + +private _ctrlSlider = _controlsGroup controlsGroupCtrl IDC_SETTING_TIME_SLIDER; +_ctrlSlider setVariable [QGVAR(params), [_setting, _source]]; + +_ctrlSlider sliderSetRange [_min, _max]; +_ctrlSlider sliderSetPosition _currentValue; +private _range = _max - _min; +_ctrlSlider sliderSetSpeed [0.05 * _range, 0.1 * _range]; + +_ctrlSlider ctrlAddEventHandler ["SliderPosChanged", { + params ["_ctrlSlider", "_value"]; + (_ctrlSlider getVariable QGVAR(params)) params ["_setting", "_source"]; + _value = round _value; + + private _controlsGroup = ctrlParentControlsGroup _ctrlSlider; + (_controlsGroup controlsGroupCtrl IDC_SETTING_TIME_HOURS) ctrlSetText ([floor (_value / 3600), 2] call CBA_fnc_formatNumber); + (_controlsGroup controlsGroupCtrl IDC_SETTING_TIME_MINUTES) ctrlSetText ([floor (_value / 60 % 60), 2] call CBA_fnc_formatNumber); + (_controlsGroup controlsGroupCtrl IDC_SETTING_TIME_SECONDS) ctrlSetText ([floor (_value % 60), 2] call CBA_fnc_formatNumber); + + SET_TEMP_NAMESPACE_VALUE(_setting,_value,_source); + + // if new value is same as default value, grey out the default button + private _ctrlDefault = _controlsGroup controlsGroupCtrl IDC_SETTING_DEFAULT; + private _defaultValue = [_setting, "default"] call FUNC(get); + _ctrlDefault ctrlEnable !(_value isEqualTo _defaultValue); + + // automatically check "overwrite client" for mission makers qol + [_controlsGroup, _source] call (_controlsGroup getVariable QFUNC(auto_check_overwrite)); +}]; + +{ + _x params ["_idc", "_value"]; + + private _ctrlEdit = _controlsGroup controlsGroupCtrl _idc; + _ctrlEdit setVariable [QGVAR(params), [_setting, _source]]; + _ctrlEdit ctrlSetText ([_value, 2] call CBA_fnc_formatNumber); + + _ctrlEdit ctrlAddEventHandler ["KillFocus", { + params ["_ctrlEdit"]; + (_ctrlEdit getVariable QGVAR(params)) params ["_setting", "_source"]; + + private _controlsGroup = ctrlParentControlsGroup _ctrlEdit; + private _ctrlSlider = _controlsGroup controlsGroupCtrl IDC_SETTING_TIME_SLIDER; + private _ctrlEditHours = _controlsGroup controlsGroupCtrl IDC_SETTING_TIME_HOURS; + private _ctrlEditMinutes = _controlsGroup controlsGroupCtrl IDC_SETTING_TIME_MINUTES; + private _ctrlEditSeconds = _controlsGroup controlsGroupCtrl IDC_SETTING_TIME_SECONDS; + + private _value = round (parseNumber ctrlText _ctrlEditHours * 3600 + parseNumber ctrlText _ctrlEditMinutes * 60 + parseNumber ctrlText _ctrlEditSeconds); + _ctrlSlider sliderSetPosition _value; + _value = sliderPosition _ctrlSlider; + + _ctrlEditHours ctrlSetText ([floor (_value / 3600), 2] call CBA_fnc_formatNumber); + _ctrlEditMinutes ctrlSetText ([floor (_value / 60 % 60), 2] call CBA_fnc_formatNumber); + _ctrlEditSeconds ctrlSetText ([floor (_value % 60), 2] call CBA_fnc_formatNumber); + + SET_TEMP_NAMESPACE_VALUE(_setting,_value,_source); + + // if new value is same as default value, grey out the default button + private _ctrlDefault = _controlsGroup controlsGroupCtrl IDC_SETTING_DEFAULT; + private _defaultValue = [_setting, "default"] call FUNC(get); + _ctrlDefault ctrlEnable !(_value isEqualTo _defaultValue); + + // automatically check "overwrite client" for mission makers qol + [_controlsGroup, _source] call (_controlsGroup getVariable QFUNC(auto_check_overwrite)); + }]; +} forEach [ + [IDC_SETTING_TIME_HOURS, floor (_currentValue / 3600)], + [IDC_SETTING_TIME_MINUTES, floor (_currentValue / 60 % 60)], + [IDC_SETTING_TIME_SECONDS, floor (_currentValue % 60)] +]; + +// set setting ui manually to new value +_controlsGroup setVariable [QFUNC(updateUI), { + params ["_controlsGroup", "_value"]; + + (_controlsGroup controlsGroupCtrl IDC_SETTING_TIME_SLIDER) sliderSetPosition _value; + (_controlsGroup controlsGroupCtrl IDC_SETTING_TIME_HOURS) ctrlSetText ([floor (_value / 3600), 2] call CBA_fnc_formatNumber); + (_controlsGroup controlsGroupCtrl IDC_SETTING_TIME_MINUTES) ctrlSetText ([floor (_value / 60 % 60), 2] call CBA_fnc_formatNumber); + (_controlsGroup controlsGroupCtrl IDC_SETTING_TIME_SECONDS) ctrlSetText ([floor (_value % 60), 2] call CBA_fnc_formatNumber); + + // if new value is same as default value, grey out the default button + private _ctrlDefault = _controlsGroup controlsGroupCtrl IDC_SETTING_DEFAULT; + private _defaultValue = [_setting, "default"] call FUNC(get); + _ctrlDefault ctrlEnable !(_value isEqualTo _defaultValue); +}]; diff --git a/addons/settings/fnc_init.sqf b/addons/settings/fnc_init.sqf index 4ddbd883e..7ca31a075 100644 --- a/addons/settings/fnc_init.sqf +++ b/addons/settings/fnc_init.sqf @@ -35,7 +35,10 @@ Examples: ["Test_Setting_4", "COLOR", ["-test color-", "-tooltip-"], "My Category", [1, 1, 0]] call cba_settings_fnc_init; // EDITBOX --- extra argument: default value - ["Test_Setting_5", "EDITBOX", ["-test editbox-", "-tooltip-"], "My Category", "defaultValue"] call cba_settings_fnc_init; + ["Test_Setting_5", "EDITBOX", ["-test editbox-", "-tooltip-"], "My Category", "defaultValue"] call cba_settings_fnc_init; + + // TIME PICKER (time in seconds) --- extra arguments: [_min, _max, _default] + ["Test_Setting_6", "TIME", ["-test time-", "-tooltip-"], "My Category", [0, 3600, 60]] call cba_settings_fnc_init; (end) Author: @@ -136,7 +139,13 @@ switch (toUpper _settingType) do { _settingData append [_min, _max, _trailingDecimals]; }; case "COLOR": { - _defaultValue = [_valueInfo] param [0, [1, 1, 1], [[]], [3,4]]; + _defaultValue = [_valueInfo] param [0, [1, 1, 1], [[]], [3, 4]]; + }; + case "TIME": { + _valueInfo params [["_min", 0, [0]], ["_max", 86400, [0]], ["_default", 0, [0]]]; + + _defaultValue = _default; + _settingData append [_min, _max]; }; default {/* _defaultValue undefined, exit below */}; }; diff --git a/addons/settings/gui.hpp b/addons/settings/gui.hpp index 416ae0140..5ab7ae38e 100644 --- a/addons/settings/gui.hpp +++ b/addons/settings/gui.hpp @@ -449,6 +449,77 @@ class GVAR(Row_ColorAlpha): GVAR(Row_Color) { }; }; +class RscFrame; + +class GVAR(Row_Time): GVAR(Row_Base) { + GVAR(script) = QFUNC(gui_settingTime); + h = POS_H(2) + TABLE_LINE_SPACING; + + class controls: controls { + class Name: Name { + y = POS_H(0.5) + TABLE_LINE_SPACING / 2; + }; + class Slider: RscXSliderH { + idc = IDC_SETTING_TIME_SLIDER; + x = POS_W(16); + y = POS_H(0) + TABLE_LINE_SPACING / 2; + w = POS_W(10); + h = POS_H(1); + }; + class Frame: RscFrame { + x = POS_W(18); + y = POS_H(1.1) + TABLE_LINE_SPACING / 2; + w = POS_W(6); + h = POS_H(0.9); + }; + class Separator: RscText { + style = ST_CENTER; + text = ": :"; + font = "EtelkaMonospaceProBold"; + x = POS_W(18); + y = POS_H(1.1) + TABLE_LINE_SPACING / 2; + w = POS_W(6); + h = POS_H(0.9); + sizeEx = POS_H(1); + colorBackground[] = {0, 0, 0, 0.2}; + }; + class Hours: RscEdit { + idc = IDC_SETTING_TIME_HOURS; + style = ST_CENTER + ST_NO_RECT; + tooltip = "$STR_3DEN_Attributes_SliderTime_Hour_tooltip"; + font = "EtelkaMonospaceProBold"; + x = POS_W(18); + y = POS_H(1.1) + TABLE_LINE_SPACING / 2; + w = POS_W(2); + h = POS_H(0.9); + sizeEx = POS_H(0.9); + maxChars = 2; + }; + class Minutes: Hours { + idc = IDC_SETTING_TIME_MINUTES; + tooltip = "$STR_3DEN_Attributes_SliderTime_Minute_tooltip"; + x = POS_W(20); + }; + class Seconds: Hours { + idc = IDC_SETTING_TIME_SECONDS; + tooltip = "$STR_3DEN_Attributes_SliderTime_Second_tooltip"; + x = POS_W(22); + }; + class Default: Default { + y = POS_H(0.5) + TABLE_LINE_SPACING / 2; + }; + class Locked: Locked { + y = POS_H(0.5) + TABLE_LINE_SPACING / 2; + }; + class OverwriteClients: OverwriteClients { + y = POS_H(0.5) + TABLE_LINE_SPACING / 2; + }; + class OverwriteMission: OverwriteMission { + y = POS_H(0.5) + TABLE_LINE_SPACING / 2; + }; + }; +}; + class RscControlsGroup; class RscTitle; class RscListBox; diff --git a/addons/settings/gui_createCategory.sqf b/addons/settings/gui_createCategory.sqf index 1d5d2433d..fc3fe7693 100644 --- a/addons/settings/gui_createCategory.sqf +++ b/addons/settings/gui_createCategory.sqf @@ -123,6 +123,9 @@ private _lastSubCategory = "$START"; case "COLOR": { _display ctrlCreate [[QGVAR(Row_Color), QGVAR(Row_ColorAlpha)] select (count _defaultValue > 3), IDC_SETTING_CONTROLS_GROUP, _ctrlOptionsGroup] }; + case "TIME": { + _display ctrlCreate [QGVAR(Row_Time), IDC_SETTING_CONTROLS_GROUP, _ctrlOptionsGroup] + }; default {controlNull}; }; diff --git a/addons/settings/script_component.hpp b/addons/settings/script_component.hpp index 9c375513f..185f93141 100644 --- a/addons/settings/script_component.hpp +++ b/addons/settings/script_component.hpp @@ -5,9 +5,9 @@ #include "\a3\ui_f\hpp\defineCommonGrids.inc" #include "\a3\ui_f\hpp\defineResincl.inc" -//#define DEBUG_MODE_FULL -//#define DISABLE_COMPILE_CACHE -//#define DEBUG_ENABLED_SETTINGS +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define DEBUG_ENABLED_SETTINGS #ifdef DEBUG_ENABLED_SETTINGS #define DEBUG_MODE_FULL @@ -54,6 +54,10 @@ #define IDC_SETTING_COLOR_BLUE_EDIT 5136 #define IDC_SETTING_COLOR_ALPHA 5137 #define IDC_SETTING_COLOR_ALPHA_EDIT 5138 +#define IDC_SETTING_TIME_SLIDER 5140 +#define IDC_SETTING_TIME_HOURS 5141 +#define IDC_SETTING_TIME_MINUTES 5142 +#define IDC_SETTING_TIME_SECONDS 5143 #define IDCS_SETTING_COLOR [IDC_SETTING_COLOR_RED, IDC_SETTING_COLOR_GREEN, IDC_SETTING_COLOR_BLUE, IDC_SETTING_COLOR_ALPHA] #define IDCS_SETTING_COLOR_EDIT [IDC_SETTING_COLOR_RED_EDIT, IDC_SETTING_COLOR_GREEN_EDIT, IDC_SETTING_COLOR_BLUE_EDIT, IDC_SETTING_COLOR_ALPHA_EDIT]