Skip to content

Commit

Permalink
Merge pull request #49 from AsherGlick/minimum_size_setting
Browse files Browse the repository at this point in the history
Minimum Size Setting
  • Loading branch information
AsherGlick authored Dec 11, 2021
2 parents fc2513d + becbbcd commit 60927ef
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 82 deletions.
9 changes: 9 additions & 0 deletions Settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const CONFIG_PATH = "user://settings.json"

var _config_data = {}

var minimum_width: int = 800
var minimum_height: int = 600

var override_size_enabled: bool = false;
var override_size_height: int = 1080
var override_size_width: int = 1920
Expand All @@ -23,6 +26,10 @@ func _ready():
if self._config_data == null:
self._config_data = {}

if "minimum_width" in self._config_data:
self.minimum_width = self._config_data["minimum_width"]
if "minimum_height" in self._config_data:
self.minimum_height = self._config_data["minimum_height"]
if "override_size_enabled" in self._config_data:
self.override_size_enabled = self._config_data["override_size_enabled"]
if "override_size_height" in self._config_data:
Expand All @@ -39,6 +46,8 @@ func _ready():

func save():
_config_data = {
"minimum_width": minimum_width,
"minimum_height": minimum_height,
"override_size_enabled": override_size_enabled,
"override_size_height": override_size_height,
"override_size_width": override_size_width,
Expand Down
34 changes: 22 additions & 12 deletions SettingsDialog.gd
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
extends WindowDialog

func load_settings():
var override_size: CheckButton = $GridContainer/OverrideSize
var minimum_width: LineEdit = $ScrollContainer/GridContainer/MinimumWidth
minimum_width.text = String(Settings.minimum_width)
var minimum_height: LineEdit = $ScrollContainer/GridContainer/MinimumHeight
minimum_height.text = String(Settings.minimum_height)

var override_size: CheckButton = $ScrollContainer/GridContainer/OverrideSize
override_size.pressed = Settings.override_size_enabled
var override_height: LineEdit = $GridContainer/OverrideHeight
var override_height: LineEdit = $ScrollContainer/GridContainer/OverrideHeight
override_height.text = String(Settings.override_size_height)
var override_width: LineEdit = $GridContainer/OverrideWidth
var override_width: LineEdit = $ScrollContainer/GridContainer/OverrideWidth
override_width.text = String(Settings.override_size_width)

var autolaunch_burrito_link: CheckButton = $GridContainer/AutoLaunchBurritoLink
var autolaunch_burrito_link: CheckButton = $ScrollContainer/GridContainer/AutoLaunchBurritoLink
autolaunch_burrito_link.pressed = Settings.burrito_link_auto_launch_enabled
var wine_path: LineEdit = $GridContainer/WinePath
var wine_path: LineEdit = $ScrollContainer/GridContainer/WinePath
wine_path.text = Settings.burrito_link_wine_path
var environment_vars: TextEdit = $GridContainer/EnvironmentVars
var environment_vars: TextEdit = $ScrollContainer/GridContainer/EnvironmentVars
environment_vars.text = Settings.burrito_link_env_args

func save_settings(new_value=null):
var override_size: CheckButton = $GridContainer/OverrideSize
var minimum_width: LineEdit = $ScrollContainer/GridContainer/MinimumWidth
Settings.minimum_width = int(minimum_width.text)
var minimum_height: LineEdit = $ScrollContainer/GridContainer/MinimumHeight
Settings.minimum_height = int(minimum_height.text)

var override_size: CheckButton = $ScrollContainer/GridContainer/OverrideSize
Settings.override_size_enabled = override_size.pressed
var override_height: LineEdit = $GridContainer/OverrideHeight
var override_height: LineEdit = $ScrollContainer/GridContainer/OverrideHeight
Settings.override_size_height = int(override_height.text)
var override_width: LineEdit = $GridContainer/OverrideWidth
var override_width: LineEdit = $ScrollContainer/GridContainer/OverrideWidth
Settings.override_size_width = int(override_width.text)

var autolaunch_burrito_link: CheckButton = $GridContainer/AutoLaunchBurritoLink
var autolaunch_burrito_link: CheckButton = $ScrollContainer/GridContainer/AutoLaunchBurritoLink
Settings.burrito_link_auto_launch_enabled = autolaunch_burrito_link.pressed
var wine_path: LineEdit = $GridContainer/WinePath
var wine_path: LineEdit = $ScrollContainer/GridContainer/WinePath
Settings.burrito_link_wine_path = wine_path.text
var environment_vars: TextEdit = $GridContainer/EnvironmentVars
var environment_vars: TextEdit = $ScrollContainer/GridContainer/EnvironmentVars
Settings.burrito_link_env_args = environment_vars.text

Settings.save()
Expand Down
14 changes: 12 additions & 2 deletions Spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ func _ready():
x11_window_id_burrito = OS.get_native_handle(OS.WINDOW_HANDLE)
OS.window_maximized = false
# Start off with a small size before GW2 client is up
OS.window_size = Vector2(800, 600)

if Settings.override_size_enabled:
OS.window_size = Vector2(Settings.override_size_width, Settings.override_size_height)
else:
OS.window_size = Vector2(Settings.minimum_width, Settings.minimum_height)
# Postion at top left corner
OS.set_window_position(Vector2(0,0))
set_minimal_mouse_block()
Expand Down Expand Up @@ -285,14 +289,20 @@ func decode_context_packet(spb: StreamPeerBuffer):
if !is_transient:
is_transient = x11_fg.set_transient_for(x11_window_id_burrito, x11_window_id_gw2)

var size = Vector2(800, 600)
var size = Vector2(Settings.minimum_width, Settings.minimum_height)
if Settings.override_size_enabled:
size.x = Settings.override_size_width
size.y = Settings.override_size_height
else:
var size_tuple = x11_fg.get_window_geometry(x11_window_id_gw2)
size.x = size_tuple[0]
size.y = size_tuple[1]

if size.x < Settings.minimum_width:
size.x = Settings.minimum_width
if size.y < Settings.minimum_height:
size.y = Settings.minimum_height

OS.window_size = size
var identity_length: int = spb.get_32()
var identity_str = spb.get_utf8_string(identity_length)
Expand Down
174 changes: 106 additions & 68 deletions Spatial.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ __meta__ = {
}

[node name="MainMenu" type="WindowDialog" parent="Control/Dialogs"]
visible = true
margin_left = 48.1808
margin_top = 88.7138
margin_right = 261.181
margin_bottom = 714.714
margin_left = 39.0
margin_top = 71.0
margin_right = 252.0
margin_bottom = 583.0
window_title = "Main Menu"
resizable = true
__meta__ = {
"_edit_group_": true,
"_edit_use_anchors_": false
}

Expand Down Expand Up @@ -610,120 +610,156 @@ margin_top = 146.0
margin_right = 981.0
margin_bottom = 575.0
window_title = "Settings"
resizable = true
script = ExtResource( 12 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="GridContainer" type="GridContainer" parent="Control/Dialogs/SettingsDialog"]
[node name="ScrollContainer" type="ScrollContainer" parent="Control/Dialogs/SettingsDialog"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 10.0
margin_top = 10.0
margin_right = -10.0
margin_bottom = -10.0
margin_left = 5.0
margin_top = 5.0
margin_bottom = -5.0
scroll_horizontal_enabled = false
__meta__ = {
"_edit_use_anchors_": false
}

[node name="GridContainer" type="GridContainer" parent="Control/Dialogs/SettingsDialog/ScrollContainer"]
margin_right = 384.002
margin_bottom = 419.001
size_flags_horizontal = 3
size_flags_vertical = 3
columns = 2
__meta__ = {
"_edit_use_anchors_": false
}

[node name="OverrideSizeLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"]
margin_top = 13.0
[node name="MinimumWidthLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 5.0
margin_right = 112.0
margin_bottom = 27.0
text = "Override Size"
margin_bottom = 19.0
text = "Minimum Width"

[node name="OverrideSize" type="CheckButton" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="MinimumWidth" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_right = 369.0
margin_bottom = 40.0
margin_right = 384.0
margin_bottom = 24.0
size_flags_horizontal = 3

[node name="OverrideWidthLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"]
margin_top = 49.0
[node name="MinimumHeightLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 33.0
margin_right = 112.0
margin_bottom = 63.0
text = "Override Width"
margin_bottom = 47.0
text = "Minimum Height"

[node name="OverrideWidth" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="MinimumHeight" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_top = 44.0
margin_right = 369.0
margin_bottom = 68.0
margin_top = 28.0
margin_right = 384.0
margin_bottom = 52.0
size_flags_horizontal = 3

[node name="OverrideHeightLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"]
margin_top = 77.0
[node name="OverrideSizeLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 69.0
margin_right = 112.0
margin_bottom = 91.0
text = "Override Height"
margin_bottom = 83.0
text = "Use Fixed Size"

[node name="OverrideHeight" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="OverrideSize" type="CheckButton" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_top = 72.0
margin_right = 369.0
margin_top = 56.0
margin_right = 384.0
margin_bottom = 96.0
size_flags_horizontal = 3

[node name="HSeparator" type="HSeparator" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="OverrideWidthLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 105.0
margin_right = 112.0
margin_bottom = 119.0
text = "Fixed Width"

[node name="OverrideWidth" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_top = 100.0
margin_right = 384.0
margin_bottom = 124.0
size_flags_horizontal = 3

[node name="OverrideHeightLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 133.0
margin_right = 112.0
margin_bottom = 104.0
margin_bottom = 147.0
text = "Fixed Height"

[node name="OverrideHeight" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_top = 128.0
margin_right = 384.0
margin_bottom = 152.0
size_flags_horizontal = 3

[node name="HSeparator" type="HSeparator" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 156.0
margin_right = 112.0
margin_bottom = 160.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="HSeparator2" type="HSeparator" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="HSeparator2" type="HSeparator" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_top = 100.0
margin_right = 369.0
margin_bottom = 104.0
margin_top = 156.0
margin_right = 384.0
margin_bottom = 160.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="AutoLaunchBurritoLinkLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"]
margin_top = 112.0
[node name="AutoLaunchBurritoLinkLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 168.0
margin_right = 112.0
margin_bottom = 143.0
margin_bottom = 199.0
text = "Auto Launch
Burrito Link"

[node name="AutoLaunchBurritoLink" type="CheckButton" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="AutoLaunchBurritoLink" type="CheckButton" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_top = 108.0
margin_right = 369.0
margin_bottom = 148.0
margin_top = 164.0
margin_right = 384.0
margin_bottom = 204.0
size_flags_horizontal = 3

[node name="WinePathLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"]
margin_top = 157.0
[node name="WinePathLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 213.0
margin_right = 112.0
margin_bottom = 171.0
margin_bottom = 227.0
text = "Wine Path"

[node name="WinePath" type="LineEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="WinePath" type="LineEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_top = 152.0
margin_right = 369.0
margin_bottom = 176.0
margin_top = 208.0
margin_right = 384.0
margin_bottom = 232.0
size_flags_horizontal = 3

[node name="EnvironmentVarsLabel" type="Label" parent="Control/Dialogs/SettingsDialog/GridContainer"]
margin_top = 223.0
[node name="EnvironmentVarsLabel" type="Label" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_top = 279.0
margin_right = 112.0
margin_bottom = 237.0
margin_bottom = 293.0
text = "Environment Vars"

[node name="EnvironmentVars" type="TextEdit" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="EnvironmentVars" type="TextEdit" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
margin_left = 116.0
margin_top = 180.0
margin_right = 369.0
margin_bottom = 280.0
margin_top = 236.0
margin_right = 384.0
margin_bottom = 336.0
rect_min_size = Vector2( 0, 100 )
size_flags_horizontal = 3

[node name="Spacer" type="Control" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="Spacer" type="Control" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
visible = false
margin_top = 284.0
margin_right = 112.0
Expand All @@ -732,11 +768,11 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="LoadLutrisProfile" type="Button" parent="Control/Dialogs/SettingsDialog/GridContainer"]
[node name="LoadLutrisProfile" type="Button" parent="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer"]
visible = false
margin_left = 116.0
margin_top = 284.0
margin_right = 369.0
margin_right = 384.0
margin_bottom = 304.0
text = "Load Lutris Profile"

Expand Down Expand Up @@ -863,9 +899,11 @@ material/0 = SubResource( 4 )
[connection signal="pressed" from="Control/Dialogs/NodeEditorDialog/ScrollContainer/VBoxContainer/SetActivePath" to="." method="_on_SetActivePath_pressed"]
[connection signal="pressed" from="Control/Dialogs/NodeEditorDialog/ScrollContainer/VBoxContainer/ReversePathDirection" to="." method="_on_ReversePathDirection_pressed"]
[connection signal="hide" from="Control/Dialogs/SettingsDialog" to="." method="_on_NodeEditorDialog_hide"]
[connection signal="pressed" from="Control/Dialogs/SettingsDialog/GridContainer/OverrideSize" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/OverrideWidth" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/OverrideHeight" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="pressed" from="Control/Dialogs/SettingsDialog/GridContainer/AutoLaunchBurritoLink" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/WinePath" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/EnvironmentVars" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/MinimumWidth" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/MinimumHeight" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="pressed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/OverrideSize" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/OverrideWidth" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/OverrideHeight" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="pressed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/AutoLaunchBurritoLink" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/WinePath" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/EnvironmentVars" to="Control/Dialogs/SettingsDialog" method="save_settings"]

0 comments on commit 60927ef

Please sign in to comment.