-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.