-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Settings - Add time setting type #967
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#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; | ||
|
||
{ | ||
_x params ["_idc", "_value"]; | ||
|
||
private _ctrlEdit = _controlsGroup controlsGroupCtrl _idc; | ||
private _editText = if (_value < 10) then {format ["0%1", _value]} else {str _value}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could do, but this works too. Only difference I believe would be rounding instead of truncating. |
||
_ctrlEdit ctrlSetText _editText; | ||
} forEach [ | ||
[IDC_SETTING_TIME_HOURS, floor (_value / 3600)], | ||
[IDC_SETTING_TIME_MINUTES, floor (_value / 60 % 60)], | ||
[IDC_SETTING_TIME_SECONDS, floor (_value % 60)] | ||
]; | ||
|
||
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]]; | ||
private _editText = if (_value < 10) then {format ["0%1", _value]} else {str _value}; | ||
_ctrlEdit ctrlSetText _editText; | ||
|
||
_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; | ||
|
||
{ | ||
_x params ["_idc", "_value"]; | ||
|
||
private _ctrlEdit = _controlsGroup controlsGroupCtrl _idc; | ||
private _editText = if (_value < 10) then {format ["0%1", _value]} else {str _value}; | ||
_ctrlEdit ctrlSetText _editText; | ||
} forEach [ | ||
[IDC_SETTING_TIME_HOURS, floor (_value / 3600)], | ||
[IDC_SETTING_TIME_MINUTES, floor (_value / 60 % 60)], | ||
[IDC_SETTING_TIME_SECONDS, floor (_value % 60)] | ||
]; | ||
|
||
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); | ||
}]; | ||
} 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"]; | ||
|
||
private _ctrlSlider = _controlsGroup controlsGroupCtrl IDC_SETTING_TIME_SLIDER; | ||
_ctrlSlider sliderSetPosition _value; | ||
|
||
{ | ||
_x params ["_idc", "_value"]; | ||
|
||
private _ctrlEdit = _controlsGroup controlsGroupCtrl _idc; | ||
private _editText = if (_value < 10) then {format ["0%1", _value]} else {str _value}; | ||
_ctrlEdit ctrlSetText _editText; | ||
} forEach [ | ||
[IDC_SETTING_TIME_HOURS, floor (_value / 3600)], | ||
[IDC_SETTING_TIME_MINUTES, floor (_value / 60 % 60)], | ||
[IDC_SETTING_TIME_SECONDS, floor (_value % 60)] | ||
]; | ||
|
||
// 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); | ||
}]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 --- extra arguments: [_min, _max, _default] | ||
["Test_Setting_6", "TIME", ["-test time-", "-tooltip-"], "My Category", [0, 3600, 60]] call cba_settings_fnc_init; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should mention "time in seconds" somewhere. |
||
(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 */}; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -449,6 +449,78 @@ 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; | ||
text = "00"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Omg I need this for the SLIDER. |
||
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; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reminder to disable |
||
|
||
#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] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
round _value == _value
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the visual doesn't show decimals, checking if rounded like the default slider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
SLIDER
does the same, then I suppose this is correct.