Added a touchscreen mode setting, and an AdaptiveButton that will set it's own min size if the setting is enabled. I did not replace all buttons yet, just made sure everything looks consistent. Also smaller theme improvements.

This commit is contained in:
Relintai 2020-06-15 18:37:51 +02:00
parent b9ecd4248d
commit 483c50dfac
13 changed files with 112 additions and 23 deletions

View File

@ -36,6 +36,9 @@ var _settings : Dictionary = {
"use_vsync" : ProjectSettings.get("display/window/vsync/use_vsync"),
"vsync_via_compositor" : ProjectSettings.get("display/window/vsync/vsync_via_compositor"),
},
"ui" : {
"touchscreen_mode" : OS.has_touchscreen_ui_hint(),
},
"debug" : {
"debug_info" : false
}
@ -132,3 +135,4 @@ func set_rendering_vsync_via_compositor(value : bool) -> void:
ProjectSettings.set("display/window/vsync/vsync_via_compositor", value)
OS.vsync_via_compositor = value

View File

@ -21,6 +21,9 @@ extends Button
# SOFTWARE.
func _ready():
if Settings.get_value("ui", "touchscreen_mode"):
rect_min_size = Vector2(rect_min_size.x, 40)
get_tree().connect("connected_to_server", self, "connected_to_server")
get_tree().connect("server_disconnected", self, "server_disconnected")

View File

@ -26,7 +26,8 @@ extends Button
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
if Settings.get_value("ui", "touchscreen_mode"):
rect_min_size = Vector2(rect_min_size.x, 40)
#func _pressed():
# Server.start_hosting()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=2]
[gd_scene load_steps=24 format=2]
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=1]
[ext_resource path="res://ui/menu/CharacterEntry.tscn" type="PackedScene" id=2]
@ -19,13 +19,7 @@
[ext_resource path="res://modules/planets/test_planet/voxel_library/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=17]
[ext_resource path="res://scripts/world_generators/MainPlanetGenerator.gd" type="Script" id=18]
[ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=19]
[ext_resource path="res://scripts/ui/AdaptiveButton.gd" type="Script" id=20]
[sub_resource type="VoxelmanLevelGenerator" id=1]
script = ExtResource( 18 )
@ -168,6 +162,7 @@ margin_top = 8.0
margin_right = 261.0
margin_bottom = 34.269
text = "Continue"
script = ExtResource( 20 )
[node name="Renounce" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
margin_top = 42.0
@ -176,6 +171,7 @@ margin_bottom = 68.269
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Renounce"
script = ExtResource( 20 )
[node name="New" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
margin_top = 76.0
@ -184,6 +180,7 @@ margin_bottom = 102.269
size_flags_horizontal = 3
size_flags_vertical = 3
text = "New"
script = ExtResource( 20 )
[node name="PlayerDisplays" type="Node" parent="CharacterSelectorMenu"]
@ -268,6 +265,7 @@ margin_right = 253.0
margin_bottom = 81.269
size_flags_horizontal = 3
text = "Create"
script = ExtResource( 20 )
__meta__ = {
"_edit_use_anchors_": false
}
@ -277,6 +275,7 @@ margin_top = 89.0
margin_right = 253.0
margin_bottom = 115.269
text = "Back"
script = ExtResource( 20 )
[node name="ConnectMenu" type="Control" parent="."]
visible = false
@ -367,6 +366,7 @@ margin_top = 224.0
margin_right = 244.0
margin_bottom = 250.269
text = "Cancel"
script = ExtResource( 20 )
[node name="HostMenu" type="Control" parent="."]
visible = false
@ -444,6 +444,7 @@ margin_top = 169.0
margin_right = 244.0
margin_bottom = 195.269
text = "Cancel"
script = ExtResource( 20 )
[node name="OptionsButton" type="MarginContainer" parent="."]
anchor_right = 1.0
@ -491,9 +492,9 @@ __meta__ = {
}
[node name="Connect" type="Button" parent="OptionsButton/Control/VBoxContainer"]
margin_top = 13.0
margin_top = 81.0
margin_right = 120.0
margin_bottom = 39.269
margin_bottom = 107.269
rect_min_size = Vector2( 120, 0 )
text = "Connect"
script = ExtResource( 11 )
@ -502,9 +503,9 @@ __meta__ = {
}
[node name="Host" type="Button" parent="OptionsButton/Control/VBoxContainer"]
margin_top = 47.0
margin_top = 115.0
margin_right = 120.0
margin_bottom = 73.269
margin_bottom = 141.269
rect_min_size = Vector2( 120, 0 )
text = "Host"
script = ExtResource( 12 )
@ -513,6 +514,7 @@ __meta__ = {
}
[node name="Button2" type="Button" parent="OptionsButton/Control/VBoxContainer"]
visible = false
margin_top = 81.0
margin_right = 120.0
margin_bottom = 107.269
@ -523,6 +525,7 @@ __meta__ = {
}
[node name="Button3" type="Button" parent="OptionsButton/Control/VBoxContainer"]
visible = false
margin_top = 115.0
margin_right = 120.0
margin_bottom = 141.269
@ -538,6 +541,7 @@ margin_right = 120.0
margin_bottom = 175.269
rect_min_size = Vector2( 120, 0 )
text = "Options"
script = ExtResource( 20 )
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -0,0 +1,6 @@
extends Button
func _ready():
if Settings.get_value("ui", "touchscreen_mode"):
rect_min_size = Vector2(rect_min_size.x, 40)

View File

@ -22,6 +22,9 @@ extends Button
func _ready():
if Settings.get_value("ui", "touchscreen_mode"):
rect_min_size = Vector2(rect_min_size.x, 40)
connect("pressed", self, "on_click")
func on_click() -> void:

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=1]
[ext_resource path="res://ui/options/Options.tscn" type="PackedScene" id=2]
[ext_resource path="res://ui/ingame_menu/ExitButton.gd" type="Script" id=3]
[ext_resource path="res://ui/keybinds/Keybinds.tscn" type="PackedScene" id=4]
[ext_resource path="res://scripts/ui/AdaptiveButton.gd" type="Script" id=5]
[node name="IngameMenu" type="Control"]
anchor_right = 1.0
@ -37,18 +38,21 @@ margin_bottom = 132.0
margin_right = 147.0
margin_bottom = 26.269
text = "Resume"
script = ExtResource( 5 )
[node name="Keybinds" type="Button" parent="Menu/VBoxContainer"]
margin_top = 34.0
margin_right = 147.0
margin_bottom = 60.269
text = "Keybinds"
script = ExtResource( 5 )
[node name="Options" type="Button" parent="Menu/VBoxContainer"]
margin_top = 68.0
margin_right = 147.0
margin_bottom = 94.269
text = "Options"
script = ExtResource( 5 )
[node name="Exit" type="Button" parent="Menu/VBoxContainer"]
margin_top = 102.0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=9 format=2]
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=1]
[ext_resource path="res://ui/player_ui/RemoveProfile.gd" type="Script" id=2]
@ -6,6 +6,7 @@
[ext_resource path="res://ui/options/OptionCheckboxRow.tscn" type="PackedScene" id=4]
[ext_resource path="res://ui/options/OptionCheckBox.gd" type="Script" id=5]
[ext_resource path="res://ui/options/OptionEnumRow.tscn" type="PackedScene" id=6]
[ext_resource path="res://scripts/ui/AdaptiveButton.gd" type="Script" id=7]
[ext_resource path="res://ui/options/OptionsSpinboxRow.tscn" type="PackedScene" id=8]
[node name="Options" type="Control"]
@ -47,7 +48,7 @@ tab_align = 0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 30.0
margin_top = 31.0
margin_right = -4.0
margin_bottom = -4.0
size_flags_horizontal = 3
@ -69,7 +70,9 @@ property_category = "rendering"
property_name = "viewport_scale"
property_label = "Viewport Scale"
min_value = 20
max_value = 100
step = 5
prefix = ""
suffix = "%"
[node name="Borderless" parent="PanelContainer/VBoxContainer/TabContainer/Video" instance=ExtResource( 4 )]
@ -122,12 +125,29 @@ property_category = "rendering"
property_name = "vsync_via_compositor"
property_label = "VSync Via Compositor"
[node name="Interface" type="VBoxContainer" parent="PanelContainer/VBoxContainer/TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 31.0
margin_right = -4.0
margin_bottom = -4.0
size_flags_horizontal = 3
[node name="OptionToggleRow" parent="PanelContainer/VBoxContainer/TabContainer/Interface" instance=ExtResource( 4 )]
margin_top = 0.0
margin_bottom = 26.0
property_category = "ui"
property_name = "touchscreen_mode"
property_label = "Touchscreen Mode"
[node name="Debug" type="VBoxContainer" parent="PanelContainer/VBoxContainer/TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 30.0
margin_top = 31.0
margin_right = -4.0
margin_bottom = -4.0
size_flags_horizontal = 3
@ -153,4 +173,5 @@ margin_top = 439.0
margin_right = 535.0
margin_bottom = 465.269
text = "Close"
script = ExtResource( 7 )
[connection signal="pressed" from="PanelContainer/VBoxContainer/Close" to="." method="hide"]

View File

@ -431,8 +431,7 @@ margin_left = -331.0
margin_bottom = 123.0
[node name="Castbar" parent="GUI" instance=ExtResource( 16 )]
margin_top = 0.0
mouse_filter = 2
visible = false
[node name="ErrorFrame" parent="GUI" instance=ExtResource( 4 )]
anchor_left = 0.5

View File

@ -0,0 +1,14 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
[ext_resource path="res://ui/theme/button_bg_atlas.tres" type="Texture" id=1]
[resource]
texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 13, 14 )
margin_left = 8.65868
margin_right = 8.7872
margin_top = 6.0
margin_bottom = 6.0
axis_stretch_horizontal = 2
axis_stretch_vertical = 2
modulate_color = Color( 0.772549, 0.772549, 0.772549, 1 )

View File

@ -0,0 +1,14 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
[ext_resource path="res://ui/theme/button_bg_atlas.tres" type="Texture" id=1]
[resource]
texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 13, 14 )
margin_left = 8.40166
margin_right = 8.01612
margin_top = 6.0
margin_bottom = 6.0
axis_stretch_horizontal = 2
axis_stretch_vertical = 2
modulate_color = Color( 0.807843, 0.807843, 0.807843, 1 )

View File

@ -0,0 +1,13 @@
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
[ext_resource path="res://ui/theme/button_bg_atlas.tres" type="Texture" id=1]
[resource]
texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 13, 14 )
margin_left = 8.27315
margin_right = 8.14463
margin_top = 6.0
margin_bottom = 6.0
axis_stretch_horizontal = 2
axis_stretch_vertical = 2

View File

@ -1,4 +1,4 @@
[gd_resource type="Theme" load_steps=30 format=2]
[gd_resource type="Theme" load_steps=33 format=2]
[ext_resource path="res://ui/theme/h_scroll_bar_texture.tres" type="Texture" id=1]
[ext_resource path="res://ui/theme/button_bg_stylebox_disabled.tres" type="StyleBox" id=2]
@ -20,6 +20,9 @@
[ext_resource path="res://ui/theme/checkbox_texture.tres" type="Texture" id=18]
[ext_resource path="res://ui/theme/checkbox_checked_texture.tres" type="Texture" id=19]
[ext_resource path="res://ui/theme/dropdown_icon.tres" type="Texture" id=20]
[ext_resource path="res://ui/theme/tab_button_bg_stylebox_focus.tres" type="StyleBox" id=21]
[ext_resource path="res://ui/theme/tab_button_bg_stylebox_hover.tres" type="StyleBox" id=22]
[ext_resource path="res://ui/theme/tab_button_bg_stylebox.tres" type="StyleBox" id=23]
[sub_resource type="Image" id=10]
data = {
@ -234,9 +237,9 @@ TabContainer/icons/increment_highlight = null
TabContainer/icons/menu = null
TabContainer/icons/menu_highlight = null
TabContainer/styles/panel = ExtResource( 8 )
TabContainer/styles/tab_bg = ExtResource( 4 )
TabContainer/styles/tab_disabled = ExtResource( 5 )
TabContainer/styles/tab_fg = ExtResource( 3 )
TabContainer/styles/tab_bg = ExtResource( 23 )
TabContainer/styles/tab_disabled = ExtResource( 22 )
TabContainer/styles/tab_fg = ExtResource( 21 )
Tabs/colors/font_color_bg = Color( 0.69, 0.69, 0.69, 1 )
Tabs/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
Tabs/colors/font_color_fg = Color( 0.94, 0.94, 0.94, 1 )