mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-03 19:01:16 +00:00
Vsync checkbox
This commit is contained in:
parent
af356bbd82
commit
eb748b462d
2 changed files with 21 additions and 2 deletions
|
|
@ -13,7 +13,7 @@ font_size = 20
|
||||||
outline_size = 4
|
outline_size = 4
|
||||||
outline_color = Color(0, 0, 0, 1)
|
outline_color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
[node name="OptionsMenu" type="VBoxContainer" node_paths=PackedStringArray("ResolutionsList")]
|
[node name="OptionsMenu" type="VBoxContainer" node_paths=PackedStringArray("ResolutionsList", "VSyncToggle")]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
|
@ -21,6 +21,7 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_mpohc")
|
script = ExtResource("1_mpohc")
|
||||||
ResolutionsList = NodePath("ScrollContainer/HBoxContainer/HFlowContainer/Resolution/ResolutionsList")
|
ResolutionsList = NodePath("ScrollContainer/HBoxContainer/HFlowContainer/Resolution/ResolutionsList")
|
||||||
|
VSyncToggle = NodePath("ScrollContainer/HBoxContainer/HFlowContainer/VsyncCheckbox")
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
@ -70,7 +71,7 @@ text = "Resolution"
|
||||||
[node name="ResolutionsList" type="OptionButton" parent="ScrollContainer/HBoxContainer/HFlowContainer/Resolution"]
|
[node name="ResolutionsList" type="OptionButton" parent="ScrollContainer/HBoxContainer/HFlowContainer/Resolution"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="CheckBox" type="CheckBox" parent="ScrollContainer/HBoxContainer/HFlowContainer"]
|
[node name="VsyncCheckbox" type="CheckBox" parent="ScrollContainer/HBoxContainer/HFlowContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 0
|
size_flags_vertical = 0
|
||||||
text = "VSync"
|
text = "VSync"
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ public partial class OptionsMenu : MenuBase
|
||||||
|
|
||||||
[Export] public OptionButton ResolutionsList { get; private set; }
|
[Export] public OptionButton ResolutionsList { get; private set; }
|
||||||
|
|
||||||
|
[Export] public CheckBox VSyncToggle { get; private set; }
|
||||||
|
|
||||||
//[Export] public HSlider MusicVolumeSlider { get; private set; }
|
//[Export] public HSlider MusicVolumeSlider { get; private set; }
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
|
|
@ -28,6 +30,22 @@ public partial class OptionsMenu : MenuBase
|
||||||
|
|
||||||
ResolutionsList.ItemSelected += ResolutionsListOnItemSelected;
|
ResolutionsList.ItemSelected += ResolutionsListOnItemSelected;
|
||||||
|
|
||||||
|
VSyncToggle.SetPressed(DisplayServer.WindowGetVsyncMode() == DisplayServer.VSyncMode.Enabled);
|
||||||
|
|
||||||
|
VSyncToggle.Toggled += VSyncToggleOnToggled;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void VSyncToggleOnToggled(bool toggledOn)
|
||||||
|
{
|
||||||
|
if (toggledOn)
|
||||||
|
{
|
||||||
|
DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Enabled);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DisplayServer.WindowSetVsyncMode(DisplayServer.VSyncMode.Disabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResolutionsListOnItemSelected(long index)
|
private void ResolutionsListOnItemSelected(long index)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue