Added AdaptiveTheme, it modifies the margins in the ui's theme. Removed AdaptiveButton.

This commit is contained in:
Relintai 2020-06-15 19:27:49 +02:00
parent 483c50dfac
commit 2b0c4821e2
11 changed files with 85 additions and 65 deletions

View File

@ -21,9 +21,12 @@ extends Node
# SOFTWARE.
signal setting_changed(section, key, value)
signal settings_loaded()
const SAVE_PATH : String = "user://settings.cfg"
var loaded : bool = false
var _config_file : ConfigFile = ConfigFile.new()
var _settings : Dictionary = {
"rendering" : {
@ -100,6 +103,8 @@ func load_settings() -> void:
for key in _settings[section]:
_set_value(section, key, _config_file.get_value(section, key, _settings[section][key]))
loaded = true
emit_signal("settings_loaded")
func set_rendering_thread_model(value : int) -> void:
ProjectSettings.set("rendering/threads/thread_model", value)

View File

@ -21,9 +21,6 @@ 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

@ -25,9 +25,6 @@ extends Button
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
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=24 format=2]
[gd_scene load_steps=23 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,7 +19,6 @@
[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 )
@ -160,27 +159,24 @@ size_flags_horizontal = 3
[node name="Continue" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
margin_top = 8.0
margin_right = 261.0
margin_bottom = 34.269
margin_bottom = 34.5702
text = "Continue"
script = ExtResource( 20 )
[node name="Renounce" type="Button" parent="CharacterSelectorMenu/CharacterSelector/VBoxContainer/CharacterSelector/VBoxContainer"]
margin_top = 42.0
margin_right = 261.0
margin_bottom = 68.269
margin_bottom = 68.5702
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
margin_right = 261.0
margin_bottom = 102.269
margin_bottom = 102.57
size_flags_horizontal = 3
size_flags_vertical = 3
text = "New"
script = ExtResource( 20 )
[node name="PlayerDisplays" type="Node" parent="CharacterSelectorMenu"]
@ -262,10 +258,9 @@ margin_bottom = 47.3413
[node name="Create" type="Button" parent="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer"]
margin_top = 55.0
margin_right = 253.0
margin_bottom = 81.269
margin_bottom = 81.5702
size_flags_horizontal = 3
text = "Create"
script = ExtResource( 20 )
__meta__ = {
"_edit_use_anchors_": false
}
@ -273,9 +268,8 @@ __meta__ = {
[node name="Back" type="Button" parent="CharacterCreationMenu/CharacterSelector2/CharacterSelector/VBoxContainer/PanelContainer/VBoxContainer"]
margin_top = 89.0
margin_right = 253.0
margin_bottom = 115.269
margin_bottom = 115.57
text = "Back"
script = ExtResource( 20 )
[node name="ConnectMenu" type="Control" parent="."]
visible = false
@ -339,7 +333,7 @@ text = "23223"
[node name="CheckBox" type="CheckBox" parent="ConnectMenu/PanelContainer/VBoxContainer"]
margin_top = 133.0
margin_right = 244.0
margin_bottom = 159.269
margin_bottom = 159.57
text = "Use WebSockets"
[node name="Status" type="Label" parent="ConnectMenu/PanelContainer/VBoxContainer"]
@ -352,7 +346,7 @@ valign = 1
[node name="ConnectButton" type="Button" parent="ConnectMenu/PanelContainer/VBoxContainer"]
margin_top = 190.0
margin_right = 244.0
margin_bottom = 216.269
margin_bottom = 216.57
text = "Connect"
script = ExtResource( 14 )
container_path = NodePath("../../..")
@ -364,9 +358,8 @@ port_line_edit_path = NodePath("../LineEdit2")
[node name="Button2" type="Button" parent="ConnectMenu/PanelContainer/VBoxContainer"]
margin_top = 224.0
margin_right = 244.0
margin_bottom = 250.269
margin_bottom = 250.57
text = "Cancel"
script = ExtResource( 20 )
[node name="HostMenu" type="Control" parent="."]
visible = false
@ -418,7 +411,7 @@ text = "23223"
[node name="CheckBox" type="CheckBox" parent="HostMenu/PanelContainer/VBoxContainer"]
margin_top = 78.0
margin_right = 244.0
margin_bottom = 104.269
margin_bottom = 104.57
text = "Use WebSockets"
[node name="Status" type="Label" parent="HostMenu/PanelContainer/VBoxContainer"]
@ -431,7 +424,7 @@ valign = 1
[node name="HostButton" type="Button" parent="HostMenu/PanelContainer/VBoxContainer"]
margin_top = 135.0
margin_right = 244.0
margin_bottom = 161.269
margin_bottom = 161.57
text = "Host"
script = ExtResource( 15 )
container_path = NodePath("../../..")
@ -442,9 +435,8 @@ port_line_edit_path = NodePath("../LineEdit2")
[node name="Button2" type="Button" parent="HostMenu/PanelContainer/VBoxContainer"]
margin_top = 169.0
margin_right = 244.0
margin_bottom = 195.269
margin_bottom = 195.57
text = "Cancel"
script = ExtResource( 20 )
[node name="OptionsButton" type="MarginContainer" parent="."]
anchor_right = 1.0
@ -494,7 +486,7 @@ __meta__ = {
[node name="Connect" type="Button" parent="OptionsButton/Control/VBoxContainer"]
margin_top = 81.0
margin_right = 120.0
margin_bottom = 107.269
margin_bottom = 107.57
rect_min_size = Vector2( 120, 0 )
text = "Connect"
script = ExtResource( 11 )
@ -505,7 +497,7 @@ __meta__ = {
[node name="Host" type="Button" parent="OptionsButton/Control/VBoxContainer"]
margin_top = 115.0
margin_right = 120.0
margin_bottom = 141.269
margin_bottom = 141.57
rect_min_size = Vector2( 120, 0 )
text = "Host"
script = ExtResource( 12 )
@ -515,9 +507,9 @@ __meta__ = {
[node name="Button2" type="Button" parent="OptionsButton/Control/VBoxContainer"]
visible = false
margin_top = 81.0
margin_top = 115.0
margin_right = 120.0
margin_bottom = 107.269
margin_bottom = 141.57
rect_min_size = Vector2( 120, 0 )
text = "Login"
__meta__ = {
@ -528,7 +520,7 @@ __meta__ = {
visible = false
margin_top = 115.0
margin_right = 120.0
margin_bottom = 141.269
margin_bottom = 141.57
rect_min_size = Vector2( 120, 0 )
text = "Register"
__meta__ = {
@ -538,10 +530,9 @@ __meta__ = {
[node name="Button" type="Button" parent="OptionsButton/Control/VBoxContainer"]
margin_top = 149.0
margin_right = 120.0
margin_bottom = 175.269
margin_bottom = 175.57
rect_min_size = Vector2( 120, 0 )
text = "Options"
script = ExtResource( 20 )
__meta__ = {
"_edit_use_anchors_": false
}

View File

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

View File

@ -0,0 +1,41 @@
extends Theme
export(float) var content_margin_vertical_normal : float = 6
export(float) var content_margin_vertical_touch : float = 10
func _init():
Settings.connect("setting_changed", self, "setting_changed")
Settings.connect("settings_loaded", self, "settings_loaded")
if Settings.loaded:
adapt(Settings.get_value("ui", "touchscreen_mode"))
func setting_changed(section, key, value):
if section == "ui" and key == "touchscreen_mode":
adapt(value)
func settings_loaded():
adapt(Settings.get_value("ui", "touchscreen_mode"))
func adapt(touchscreen_mode : bool) -> void:
var content_martgin_vert : float = 0
if touchscreen_mode:
content_martgin_vert = content_margin_vertical_touch
else:
content_martgin_vert = content_margin_vertical_normal
for sbs in get_stylebox_list("Button"):
var sb : StyleBoxTexture = get_stylebox(sbs, "Button") as StyleBoxTexture
if sb == null:
continue
sb.margin_top = content_martgin_vert
sb.margin_bottom = content_martgin_vert

View File

@ -22,9 +22,6 @@ 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,10 +1,9 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=5 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
@ -36,28 +35,25 @@ margin_bottom = 132.0
[node name="Resume" type="Button" parent="Menu/VBoxContainer"]
margin_right = 147.0
margin_bottom = 26.269
margin_bottom = 26.5702
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
margin_bottom = 60.5702
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
margin_bottom = 94.5702
text = "Options"
script = ExtResource( 5 )
[node name="Exit" type="Button" parent="Menu/VBoxContainer"]
margin_top = 102.0
margin_right = 147.0
margin_bottom = 128.269
margin_bottom = 128.57
text = "Exit"
script = ExtResource( 3 )

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=8 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,7 +6,6 @@
[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"]
@ -171,7 +170,6 @@ script = ExtResource( 2 )
[node name="Close" type="Button" parent="PanelContainer/VBoxContainer"]
margin_top = 439.0
margin_right = 535.0
margin_bottom = 465.269
margin_bottom = 465.57
text = "Close"
script = ExtResource( 7 )
[connection signal="pressed" from="PanelContainer/VBoxContainer/Close" to="." method="hide"]

View File

@ -7,7 +7,7 @@ texture = ExtResource( 1 )
region_rect = Rect2( 0, 0, 13, 14 )
margin_left = 5.0562
margin_right = 5.57024
margin_top = 5.69876
margin_top = 6.0
margin_bottom = 5.57024
axis_stretch_horizontal = 2
axis_stretch_vertical = 2

File diff suppressed because one or more lines are too long