online multiplayer chess game (note server currently down)
ui fix :smile:
bendn 2022-05-26
parent 15f7e19 · commit 46797c4
-rw-r--r--networking/Network.gd2
-rw-r--r--networking/PacketHandler.gd24
-rw-r--r--project.godot2
-rw-r--r--ui/Lobby.gd18
-rw-r--r--ui/Lobby.tscn55
-rw-r--r--ui/Preview.gd39
-rw-r--r--ui/Settings.gd17
-rw-r--r--ui/Settings.tscn207
-rw-r--r--ui/StartMenu.gd2
-rw-r--r--ui/StartMenu.tscn94
-rw-r--r--ui/colorpicker/ColorPicker.gd2
-rw-r--r--ui/colorpicker/ColorPicker.tscn2
-rw-r--r--ui/colorpicker/ColorSelect.gd4
-rw-r--r--ui/colorpicker/HueSlider.gd16
-rw-r--r--ui/theme/main.tres27
15 files changed, 268 insertions, 243 deletions
diff --git a/networking/Network.gd b/networking/Network.gd
index 9d3c165..d5d845e 100644
--- a/networking/Network.gd
+++ b/networking/Network.gd
@@ -98,7 +98,7 @@ func _data_recieved() -> void:
HEADERS.stopgame:
if PacketHandler.leaving:
PacketHandler.leaving = false
- else: # dont emit the signal if its a stophost thing (HACK)
+ else: # dont emit the signal if its a stophost thing (HACK)
emit_signal("game_over", "your opponent requested stop", true)
HEADERS.startgame:
emit_signal("start_game")
diff --git a/networking/PacketHandler.gd b/networking/PacketHandler.gd
index 9ce4a09..571091a 100644
--- a/networking/PacketHandler.gd
+++ b/networking/PacketHandler.gd
@@ -5,25 +5,32 @@ class_name NetManager
signal set_buttons(enabled)
signal set_status(status, err, isok)
signal set_visible(visibility)
-signal set_back_button(disabled)
+signal hosting(newhosting)
signal game_over
signal game_started
-var hosting = false
+var hosting = false setget set_hosting
var leaving = false
var status = ["", true, false]
+
func set_buttons(enabled):
status[2] = enabled
emit_signal("set_buttons", enabled)
+
+func set_hosting(newhosting):
+ hosting = newhosting
+ emit_signal("hosting", newhosting)
+
+
func return():
if hosting:
leaving = true
Globals.network.send_packet(Globals.network.game_code, Network.HEADERS.stopgame) # stop hosting
- hosting = false
+ set_hosting(false)
set_buttons(true)
set_status("", true)
@@ -45,14 +52,12 @@ func _ready():
func requestjoin():
- set_buttons( false)
- emit_signal("set_back_button", true)
+ set_buttons(false)
Globals.network.send_packet(Globals.network.game_code, Globals.network.HEADERS.joinrequest)
func requesthost():
set_buttons(false)
- emit_signal("set_back_button", true)
Globals.network.send_packet(Globals.network.game_code, Globals.network.HEADERS.hostrequest)
@@ -73,17 +78,16 @@ func _on_join_result(accepted: String) -> void:
func _on_host_result(accepted: String) -> void:
- hosting = handle_result(accepted, "Hosted!")
+ set_hosting(handle_result(accepted, "Hosted!"))
func handle_result(accepted: String, resultstring: String, team: bool = true) -> bool:
- emit_signal("set_back_button", false)
Globals.team = team
if accepted == "Y":
set_status(resultstring, true)
return true
set_status(accepted, false)
- set_buttons( true)
+ set_buttons(true)
return false
@@ -97,7 +101,7 @@ func _handle_game_over(error = "game over", isok = true) -> void:
func _start_game() -> void:
- hosting = false
+ set_hosting(false)
var board = load("res://Board.tscn").instance()
get_tree().get_root().add_child(board)
emit_signal("set_visible", false)
diff --git a/project.godot b/project.godot
index 029ce81..74e6847 100644
--- a/project.godot
+++ b/project.godot
@@ -89,7 +89,7 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://pieces/Piece.gd"
}, {
-"base": "Node",
+"base": "GridContainer",
"class": "Preview",
"language": "GDScript",
"path": "res://ui/Preview.gd"
diff --git a/ui/Lobby.gd b/ui/Lobby.gd
index 3217b41..cca387c 100644
--- a/ui/Lobby.gd
+++ b/ui/Lobby.gd
@@ -1,9 +1,9 @@
extends Control
-onready var address: LineEdit = $Darken/Center/HBox/VBox/Address
-onready var buttons = $Darken/Center/HBox/VBox/buttons
-onready var status_ok = $Darken/Center/HBox/VBox/StatusOK
-onready var status_fail = $Darken/Center/HBox/VBox/StatusFail
+onready var address: LineEdit = find_node("Address")
+onready var buttons = find_node("buttons")
+onready var status_ok = find_node("StatusOK")
+onready var status_fail = find_node("StatusFail")
func toggle(onoff) -> void:
@@ -11,10 +11,10 @@ func toggle(onoff) -> void:
func _ready():
- PacketHandler.connect("set_back_button", $Darken/Center/HBox/VBox/backbutton, "set_disabled")
PacketHandler.connect("set_status", self, "_set_status")
PacketHandler.connect("set_buttons", self, "_set_buttons")
PacketHandler.connect("set_visible", self, "toggle")
+ PacketHandler.connect("hosting", find_node("stophost"), "set_visible")
_set_status(PacketHandler.status[0], PacketHandler.status[1])
if !Utils.internet_available():
_set_status("no internet", false)
@@ -64,6 +64,10 @@ func _on_Address_text_entered(new_text: String):
validate_text(new_text)
-func _on_backbutton_pressed():
+func _on_tabs_tab_changed(tab: int):
+ if tab != get_parent().get_children().find(self):
+ PacketHandler.return()
+
+
+func _on_stophost_pressed():
PacketHandler.return()
- get_tree().change_scene("res://ui/StartMenu.tscn")
diff --git a/ui/Lobby.tscn b/ui/Lobby.tscn
index 66ec1e5..fd3451f 100644
--- a/ui/Lobby.tscn
+++ b/ui/Lobby.tscn
@@ -9,36 +9,31 @@ anchor_bottom = 1.0
theme = ExtResource( 1 )
script = ExtResource( 2 )
-[node name="Darken" type="ColorRect" parent="."]
+[node name="Center" type="CenterContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
-color = Color( 0, 0, 0, 0.396078 )
-[node name="Center" type="CenterContainer" parent="Darken"]
-anchor_right = 1.0
-anchor_bottom = 1.0
-
-[node name="HBox" type="HBoxContainer" parent="Darken/Center"]
+[node name="HBox" type="HBoxContainer" parent="Center"]
margin_left = 536.0
-margin_top = 226.0
+margin_top = 286.0
margin_right = 886.0
-margin_bottom = 574.0
+margin_bottom = 513.0
-[node name="VBox" type="VBoxContainer" parent="Darken/Center/HBox"]
+[node name="VBox" type="VBoxContainer" parent="Center/HBox"]
margin_right = 350.0
-margin_bottom = 348.0
+margin_bottom = 227.0
-[node name="backbutton" type="Button" parent="Darken/Center/HBox/VBox"]
-margin_right = 350.0
+[node name="stophost" type="Button" parent="Center/HBox/VBox"]
+visible = false
+margin_left = 7.0
+margin_right = 343.0
margin_bottom = 106.0
-focus_mode = 0
-enabled_focus_mode = 0
-text = "go back"
+size_flags_horizontal = 4
+text = "stop hosting"
-[node name="Address" type="LineEdit" parent="Darken/Center/HBox/VBox"]
-margin_top = 121.0
+[node name="Address" type="LineEdit" parent="Center/HBox/VBox"]
margin_right = 350.0
-margin_bottom = 227.0
+margin_bottom = 106.0
rect_min_size = Vector2( 350, 0 )
focus_mode = 1
text = "game_code"
@@ -48,12 +43,12 @@ placeholder_text = "game_code"
caret_blink = true
caret_blink_speed = 0.35
-[node name="buttons" type="HBoxContainer" parent="Darken/Center/HBox/VBox"]
-margin_top = 242.0
+[node name="buttons" type="HBoxContainer" parent="Center/HBox/VBox"]
+margin_top = 121.0
margin_right = 350.0
-margin_bottom = 348.0
+margin_bottom = 227.0
-[node name="JoinButton" type="Button" parent="Darken/Center/HBox/VBox/buttons"]
+[node name="JoinButton" type="Button" parent="Center/HBox/VBox/buttons"]
margin_right = 150.0
margin_bottom = 106.0
rect_min_size = Vector2( 150, 0 )
@@ -63,7 +58,7 @@ disabled = true
enabled_focus_mode = 0
text = "join"
-[node name="HostButton" type="Button" parent="Darken/Center/HBox/VBox/buttons"]
+[node name="HostButton" type="Button" parent="Center/HBox/VBox/buttons"]
margin_left = 165.0
margin_right = 350.0
margin_bottom = 106.0
@@ -73,7 +68,7 @@ disabled = true
enabled_focus_mode = 0
text = "host"
-[node name="StatusOK" type="Label" parent="Darken/Center/HBox/VBox"]
+[node name="StatusOK" type="Label" parent="Center/HBox/VBox"]
visible = false
margin_top = 242.0
margin_right = 500.0
@@ -81,7 +76,7 @@ margin_bottom = 292.0
custom_colors/font_color = Color( 1, 1, 1, 1 )
autowrap = true
-[node name="StatusFail" type="Label" parent="Darken/Center/HBox/VBox"]
+[node name="StatusFail" type="Label" parent="Center/HBox/VBox"]
visible = false
margin_top = 307.0
margin_right = 500.0
@@ -89,7 +84,7 @@ margin_bottom = 357.0
custom_colors/font_color = Color( 0.698039, 0.415686, 0.415686, 1 )
autowrap = true
-[connection signal="pressed" from="Darken/Center/HBox/VBox/backbutton" to="." method="_on_backbutton_pressed"]
-[connection signal="text_entered" from="Darken/Center/HBox/VBox/Address" to="." method="_on_Address_text_entered"]
-[connection signal="pressed" from="Darken/Center/HBox/VBox/buttons/JoinButton" to="." method="_on_join_pressed"]
-[connection signal="pressed" from="Darken/Center/HBox/VBox/buttons/HostButton" to="." method="_on_HostButton_pressed"]
+[connection signal="pressed" from="Center/HBox/VBox/stophost" to="." method="_on_stophost_pressed"]
+[connection signal="text_entered" from="Center/HBox/VBox/Address" to="." method="_on_Address_text_entered"]
+[connection signal="pressed" from="Center/HBox/VBox/buttons/JoinButton" to="." method="_on_join_pressed"]
+[connection signal="pressed" from="Center/HBox/VBox/buttons/HostButton" to="." method="_on_HostButton_pressed"]
diff --git a/ui/Preview.gd b/ui/Preview.gd
index ffb3f03..1ad2fd3 100644
--- a/ui/Preview.gd
+++ b/ui/Preview.gd
@@ -1,10 +1,39 @@
-extends Node
+tool
+extends GridContainer
class_name Preview
-onready var squares = get_children()
+var size = Vector2(5, 4)
+
+const pieces = [
+ "R", "N", "B", "Q", "K",
+ "P", "P", "P", "P", "P",
+ "P", "P", "P", "P", "P",
+ "K", "Q", "B", "N", "R",
+]
+
+func _init():
+ columns = size.x
+ for x in size.x:
+ for y in size.y:
+ var clr = ColorRect.new()
+ clr.name = "%s%s" % [x, y]
+ clr.rect_min_size = Vector2(100, 100)
+ var tex = TextureRect.new()
+ tex.rect_min_size = Vector2(100, 100)
+ tex.expand = true
+ tex.name = "Piece"
+ clr.add_child(tex)
+ add_child(clr)
+ if Engine.is_editor_hint():
+ update_preview(Color(0.870588, 0.890196, 0.901961), Color(0.54902, 0.635294, 0.678431), "california")
func update_preview(color1, color2, piece_set):
- for i in range(4):
- squares[i].color = color1 if i == 0 or i == 3 else color2
- squares[0].get_node("Piece").texture = load("res://assets/pieces/%s/wP.png" % piece_set)
+ var squares = get_children()
+ for i in range(size.x * size.y):
+ squares[i].color = color1 if i % 2 == 0 else color2
+ var top = (size.x * size.y) / 2
+ for i in size.x * size.y:
+ var node = squares[i].get_node("Piece")
+ var things = [piece_set, "b" if i < top else "w", pieces[i]]
+ node.texture = load("res://assets/pieces/%s/%s%s.png" % things)
diff --git a/ui/Settings.gd b/ui/Settings.gd
index ce550c3..04d568e 100644
--- a/ui/Settings.gd
+++ b/ui/Settings.gd
@@ -1,14 +1,13 @@
extends Control
onready var piece_sets := Utils.walk_dir()
-onready var piece_set_button := $ColorRect/HBoxContainer/VBoxContainer/PieceSet
-onready var fullscreenbutton := $ColorRect/HBoxContainer/VBoxContainer2/FullscreenButton
-onready var vsyncbutton := $ColorRect/HBoxContainer/VBoxContainer2/VsyncButton
-onready var borderlessbutton := $ColorRect/HBoxContainer/VBoxContainer2/Borderless
-onready var preview: Preview = $ColorRect/HBoxContainer/VBoxContainer/Preview
-
-onready var board_color1: ColorPickerButtonBetter = $ColorRect/HBoxContainer/VBoxContainer3/boardcolor1
-onready var board_color2: ColorPickerButtonBetter = $ColorRect/HBoxContainer/VBoxContainer3/boardcolor2
+onready var piece_set_button := find_node("PieceSet")
+onready var fullscreenbutton := find_node("FullscreenButton")
+onready var vsyncbutton := find_node("VsyncButton")
+onready var borderlessbutton := find_node("Borderless")
+onready var preview: Preview = find_node("Preview")
+onready var board_color1: ColorPickerButtonBetter = find_node("boardcolor1")
+onready var board_color2: ColorPickerButtonBetter = find_node("boardcolor2")
onready var settings: Dictionary = SaveLoad.files["settings"]["data"] setget set_settings
@@ -30,7 +29,7 @@ func update_button_visuals(set = settings) -> void:
borderlessbutton.pressed = !set["borderless"]
board_color1.color = set["board_color1"]
board_color2.color = set["board_color2"]
- preview.update_preview(set["board_color1"], set["board_color2"], set["piece_set"])
+ preview.call_deferred("update_preview", set["board_color1"], set["board_color2"], set["piece_set"])
func _ready() -> void:
diff --git a/ui/Settings.tscn b/ui/Settings.tscn
index 317f99b..84ea5b3 100644
--- a/ui/Settings.tscn
+++ b/ui/Settings.tscn
@@ -12,152 +12,141 @@ anchor_bottom = 1.0
theme = ExtResource( 1 )
script = ExtResource( 2 )
-[node name="ColorRect" type="ColorRect" parent="."]
+[node name="H" type="HBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
-color = Color( 0, 0, 0, 0.384314 )
+mouse_filter = 2
+size_flags_horizontal = 0
+size_flags_vertical = 0
+alignment = 1
-[node name="HBoxContainer" type="HBoxContainer" parent="ColorRect"]
+[node name="TabContainer" type="TabContainer" parent="H"]
+margin_left = 203.0
+margin_right = 703.0
+margin_bottom = 530.0
+rect_min_size = Vector2( 500, 0 )
+size_flags_vertical = 0
+custom_constants/hseparation = 20
+drag_to_rearrange_enabled = true
+use_hidden_tabs_for_min_size = true
+
+[node name="colors" type="VBoxContainer" parent="H/TabContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
-margin_top = 80.0
-mouse_filter = 2
+margin_left = 30.0
+margin_top = 90.0
+margin_right = -30.0
+margin_bottom = -30.0
alignment = 1
-[node name="VBoxContainer" type="VBoxContainer" parent="ColorRect/HBoxContainer"]
-margin_left = 165.0
-margin_right = 531.0
-margin_bottom = 720.0
-mouse_filter = 2
+[node name="boardcolor1" parent="H/TabContainer/colors" instance=ExtResource( 5 )]
+margin_left = 77.0
+margin_top = 26.0
+margin_right = 403.0
+margin_bottom = 132.0
+size_flags_horizontal = 4
+text = "boardcolor1"
-[node name="BackButton" type="Button" parent="ColorRect/HBoxContainer/VBoxContainer"]
-margin_right = 366.0
-margin_bottom = 106.0
-text = "back"
+[node name="boardcolor2" parent="H/TabContainer/colors" instance=ExtResource( 5 )]
+margin_left = 77.0
+margin_top = 147.0
+margin_right = 403.0
+margin_bottom = 253.0
+size_flags_horizontal = 4
+text = "boardcolor2"
-[node name="PieceSet" type="OptionButton" parent="ColorRect/HBoxContainer/VBoxContainer"]
-margin_top = 121.0
-margin_right = 366.0
-margin_bottom = 277.0
+[node name="PieceSet" type="OptionButton" parent="H/TabContainer/colors"]
+margin_left = 57.0
+margin_top = 268.0
+margin_right = 423.0
+margin_bottom = 424.0
focus_mode = 0
+size_flags_horizontal = 4
+size_flags_vertical = 0
custom_constants/hseparation = 3
enabled_focus_mode = 0
text = "piece set"
icon = ExtResource( 3 )
-[node name="PreviewLabel" type="Label" parent="ColorRect/HBoxContainer/VBoxContainer"]
-margin_top = 292.0
-margin_right = 366.0
-margin_bottom = 342.0
-text = "Preview"
-align = 1
-
-[node name="Preview" type="GridContainer" parent="ColorRect/HBoxContainer/VBoxContainer"]
-margin_left = 83.0
-margin_top = 357.0
-margin_right = 283.0
-margin_bottom = 557.0
-size_flags_horizontal = 4
-custom_constants/vseparation = 0
-custom_constants/hseparation = 0
-columns = 2
-script = ExtResource( 4 )
-__meta__ = {
-"_edit_group_": true
-}
-
-[node name="00" type="ColorRect" parent="ColorRect/HBoxContainer/VBoxContainer/Preview"]
-margin_right = 100.0
-margin_bottom = 100.0
-rect_min_size = Vector2( 100, 100 )
-
-[node name="Piece" type="TextureRect" parent="ColorRect/HBoxContainer/VBoxContainer/Preview/00"]
+[node name="window" type="VBoxContainer" parent="H/TabContainer"]
+visible = false
anchor_right = 1.0
anchor_bottom = 1.0
-texture = ExtResource( 3 )
-expand = true
-stretch_mode = 1
-
-[node name="10" type="ColorRect" parent="ColorRect/HBoxContainer/VBoxContainer/Preview"]
-margin_left = 100.0
-margin_right = 200.0
-margin_bottom = 100.0
-rect_min_size = Vector2( 100, 100 )
-color = Color( 0, 0, 0, 1 )
-
-[node name="01" type="ColorRect" parent="ColorRect/HBoxContainer/VBoxContainer/Preview"]
-margin_top = 100.0
-margin_right = 100.0
-margin_bottom = 200.0
-rect_min_size = Vector2( 100, 100 )
-color = Color( 0, 0, 0, 1 )
-
-[node name="11" type="ColorRect" parent="ColorRect/HBoxContainer/VBoxContainer/Preview"]
-margin_left = 100.0
-margin_top = 100.0
-margin_right = 200.0
-margin_bottom = 200.0
-rect_min_size = Vector2( 100, 100 )
-
-[node name="VBoxContainer2" type="VBoxContainer" parent="ColorRect/HBoxContainer"]
-margin_left = 546.0
-margin_right = 915.0
-margin_bottom = 720.0
+margin_top = 60.0
mouse_filter = 2
+alignment = 1
-[node name="VsyncButton" type="CheckBox" parent="ColorRect/HBoxContainer/VBoxContainer2"]
-margin_right = 369.0
-margin_bottom = 140.0
+[node name="VsyncButton" type="CheckBox" parent="H/TabContainer/window"]
+margin_left = 113.0
+margin_top = 65.0
+margin_right = 386.0
+margin_bottom = 205.0
focus_mode = 0
+size_flags_horizontal = 4
pressed = true
enabled_focus_mode = 0
text = "vsync"
-[node name="FullscreenButton" type="CheckBox" parent="ColorRect/HBoxContainer/VBoxContainer2"]
-margin_top = 155.0
-margin_right = 369.0
-margin_bottom = 295.0
+[node name="FullscreenButton" type="CheckBox" parent="H/TabContainer/window"]
+margin_left = 65.0
+margin_top = 220.0
+margin_right = 434.0
+margin_bottom = 360.0
focus_mode = 0
+size_flags_horizontal = 4
enabled_focus_mode = 0
text = "fullscreen"
-[node name="Borderless" type="CheckBox" parent="ColorRect/HBoxContainer/VBoxContainer2"]
-margin_top = 310.0
-margin_right = 369.0
-margin_bottom = 450.0
-focus_mode = 1
+[node name="Borderless" type="CheckBox" parent="H/TabContainer/window"]
+margin_left = 91.0
+margin_top = 375.0
+margin_right = 409.0
+margin_bottom = 515.0
+focus_mode = 0
+size_flags_horizontal = 4
enabled_focus_mode = 0
text = "borders"
-[node name="VBoxContainer3" type="VBoxContainer" parent="ColorRect/HBoxContainer"]
-margin_left = 930.0
-margin_right = 1256.0
-margin_bottom = 720.0
+[node name="Container" type="VBoxContainer" parent="H"]
+margin_left = 718.0
+margin_right = 1218.0
+margin_bottom = 800.0
+rect_min_size = Vector2( 300, 0 )
-[node name="resetbutton" type="Button" parent="ColorRect/HBoxContainer/VBoxContainer3"]
-margin_right = 326.0
+[node name="resetbutton" type="Button" parent="H/Container"]
+margin_left = 129.0
+margin_right = 370.0
margin_bottom = 106.0
focus_mode = 0
+size_flags_horizontal = 4
enabled_focus_mode = 0
text = "reset all"
-[node name="boardcolor1" parent="ColorRect/HBoxContainer/VBoxContainer3" instance=ExtResource( 5 )]
+[node name="PreviewLabel" type="Label" parent="H/Container"]
margin_top = 121.0
-margin_right = 326.0
-margin_bottom = 227.0
-text = "boardcolor1"
+margin_right = 500.0
+margin_bottom = 171.0
+text = "Preview"
+align = 1
-[node name="boardcolor2" parent="ColorRect/HBoxContainer/VBoxContainer3" instance=ExtResource( 5 )]
-margin_top = 242.0
-margin_right = 326.0
-margin_bottom = 348.0
-text = "boardcolor2"
+[node name="Preview" type="GridContainer" parent="H/Container"]
+margin_top = 186.0
+margin_right = 500.0
+margin_bottom = 586.0
+rect_min_size = Vector2( 500, 0 )
+size_flags_horizontal = 4
+custom_constants/vseparation = 0
+custom_constants/hseparation = 0
+columns = 5
+script = ExtResource( 4 )
+__meta__ = {
+"_edit_group_": true
+}
-[connection signal="pressed" from="ColorRect/HBoxContainer/VBoxContainer/BackButton" to="." method="_on_BackButton_pressed"]
-[connection signal="item_selected" from="ColorRect/HBoxContainer/VBoxContainer/PieceSet" to="." method="_on_PieceSet_item_selected"]
-[connection signal="toggled" from="ColorRect/HBoxContainer/VBoxContainer2/VsyncButton" to="." method="_on_VsyncButton_toggled"]
-[connection signal="toggled" from="ColorRect/HBoxContainer/VBoxContainer2/FullscreenButton" to="." method="_on_FullscreenButton_toggled"]
-[connection signal="toggled" from="ColorRect/HBoxContainer/VBoxContainer2/Borderless" to="." method="_on_Borderless_toggled"]
-[connection signal="pressed" from="ColorRect/HBoxContainer/VBoxContainer3/resetbutton" to="." method="_on_resetbutton_pressed"]
-[connection signal="newcolor" from="ColorRect/HBoxContainer/VBoxContainer3/boardcolor1" to="." method="_on_boardcolor1_newcolor"]
-[connection signal="newcolor" from="ColorRect/HBoxContainer/VBoxContainer3/boardcolor2" to="." method="_on_boardcolor2_newcolor"]
+[connection signal="newcolor" from="H/TabContainer/colors/boardcolor1" to="." method="_on_boardcolor1_newcolor"]
+[connection signal="newcolor" from="H/TabContainer/colors/boardcolor2" to="." method="_on_boardcolor2_newcolor"]
+[connection signal="item_selected" from="H/TabContainer/colors/PieceSet" to="." method="_on_PieceSet_item_selected"]
+[connection signal="toggled" from="H/TabContainer/window/VsyncButton" to="." method="_on_VsyncButton_toggled"]
+[connection signal="toggled" from="H/TabContainer/window/FullscreenButton" to="." method="_on_FullscreenButton_toggled"]
+[connection signal="toggled" from="H/TabContainer/window/Borderless" to="." method="_on_Borderless_toggled"]
+[connection signal="pressed" from="H/Container/resetbutton" to="." method="_on_resetbutton_pressed"]
diff --git a/ui/StartMenu.gd b/ui/StartMenu.gd
index de541e2..78ab03f 100644
--- a/ui/StartMenu.gd
+++ b/ui/StartMenu.gd
@@ -2,7 +2,7 @@ extends Control
const world = preload("res://Board.tscn")
-onready var settings := $Darken/Settings
+onready var settings := find_node("Settings")
func _ready() -> void:
diff --git a/ui/StartMenu.tscn b/ui/StartMenu.tscn
index 63b7595..cc69433 100644
--- a/ui/StartMenu.tscn
+++ b/ui/StartMenu.tscn
@@ -1,8 +1,16 @@
-[gd_scene load_steps=4 format=2]
+[gd_scene load_steps=7 format=2]
[ext_resource path="res://ui/theme/main.tres" type="Theme" id=1]
[ext_resource path="res://ui/StartMenu.gd" type="Script" id=2]
[ext_resource path="res://ui/Settings.tscn" type="PackedScene" id=3]
+[ext_resource path="res://ui/Lobby.tscn" type="PackedScene" id=4]
+[ext_resource path="res://assets/ui/verdana-bold.ttf" type="DynamicFontData" id=5]
+
+[sub_resource type="DynamicFont" id=1]
+size = 300
+use_mipmaps = true
+use_filter = true
+font_data = ExtResource( 5 )
[node name="StartMenu" type="Control"]
anchor_right = 1.0
@@ -11,66 +19,42 @@ mouse_filter = 2
theme = ExtResource( 1 )
script = ExtResource( 2 )
-[node name="Darken" type="ColorRect" parent="."]
+[node name="tabs" type="TabContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
-mouse_filter = 2
-color = Color( 0, 0, 0, 0.392157 )
-
-[node name="MainButtons" type="VBoxContainer" parent="Darken"]
-anchor_left = 0.5
-anchor_right = 0.5
-anchor_bottom = 1.0
-margin_left = -157.5
-margin_right = 157.5
-mouse_filter = 2
-alignment = 1
-
-[node name="multiplayer" type="Button" parent="Darken/MainButtons"]
-margin_top = 226.0
-margin_right = 315.0
-margin_bottom = 332.0
-focus_mode = 0
-size_flags_horizontal = 4
-enabled_focus_mode = 0
-text = "multiplayer"
-
-[node name="settings" type="Button" parent="Darken/MainButtons"]
-margin_left = 38.0
-margin_top = 347.0
-margin_right = 276.0
-margin_bottom = 453.0
-focus_mode = 0
-size_flags_horizontal = 4
-enabled_focus_mode = 0
-text = "settings"
-
-[node name="local" type="Button" parent="Darken/MainButtons"]
+margin_left = 24.0
+margin_top = 32.0
+margin_right = -30.0
+margin_bottom = -40.0
+size_flags_horizontal = 0
+size_flags_vertical = 0
+drag_to_rearrange_enabled = true
+
+[node name="Settings" parent="tabs" instance=ExtResource( 3 )]
+margin_left = 30.0
+margin_top = 90.0
+margin_right = -30.0
+margin_bottom = -30.0
+
+[node name="Lobby" parent="tabs" instance=ExtResource( 4 )]
visible = false
-margin_left = 113.0
-margin_top = 242.0
-margin_right = 275.0
-margin_bottom = 348.0
-rect_min_size = Vector2( 100, 0 )
-focus_mode = 0
-size_flags_horizontal = 4
-enabled_focus_mode = 0
-text = "local"
+margin_left = 10.0
+margin_top = 60.0
+margin_right = -10.0
+margin_bottom = -10.0
-[node name="quit" type="Button" parent="Darken/MainButtons"]
-margin_left = 86.0
-margin_top = 468.0
-margin_right = 228.0
-margin_bottom = 574.0
+[node name="quit" type="Button" parent="tabs"]
+visible = false
+margin_left = -157.0
+margin_top = 315.0
+margin_right = -15.0
+margin_bottom = 421.0
focus_mode = 0
size_flags_horizontal = 4
+size_flags_vertical = 4
+custom_fonts/font = SubResource( 1 )
enabled_focus_mode = 0
text = "exit"
-[node name="Settings" parent="Darken" instance=ExtResource( 3 )]
-visible = false
-
-[connection signal="pressed" from="Darken/MainButtons/multiplayer" to="." method="_on_multiplayer_pressed"]
-[connection signal="pressed" from="Darken/MainButtons/settings" to="." method="_on_settings_pressed"]
-[connection signal="pressed" from="Darken/MainButtons/local" to="." method="_on_local_pressed"]
-[connection signal="pressed" from="Darken/MainButtons/quit" to="." method="_on_quit_pressed"]
+[connection signal="tab_changed" from="tabs" to="tabs/Lobby" method="_on_tabs_tab_changed"]
+[connection signal="pressed" from="tabs/quit" to="." method="_on_quit_pressed"]
diff --git a/ui/colorpicker/ColorPicker.gd b/ui/colorpicker/ColorPicker.gd
index 0aeed3e..415953c 100644
--- a/ui/colorpicker/ColorPicker.gd
+++ b/ui/colorpicker/ColorPicker.gd
@@ -26,7 +26,7 @@ func _ready():
func update_color():
newcolorpreview.color = color
colorselect.color = color
- hueslider.hue = color.h
+ hueslider.color = color
func set_color(newcolor):
diff --git a/ui/colorpicker/ColorPicker.tscn b/ui/colorpicker/ColorPicker.tscn
index 99658d5..2e15d4b 100644
--- a/ui/colorpicker/ColorPicker.tscn
+++ b/ui/colorpicker/ColorPicker.tscn
@@ -104,8 +104,8 @@ margin_right = 125.0
margin_bottom = 20.0
rect_min_size = Vector2( 50, 20 )
+[connection signal="color_changed" from="Panel/V/H/HueSlider" to="." method="_color_changed"]
[connection signal="gui_input" from="Panel/V/H/HueSlider" to="Panel/V/H/HueSlider" method="_gui_input"]
-[connection signal="hue_changed" from="Panel/V/H/HueSlider" to="Panel/V/H/ColorSelect" method="apply_hue"]
[connection signal="color_changed" from="Panel/V/H/ColorSelect" to="." method="_color_changed"]
[connection signal="gui_input" from="Panel/V/H/ColorSelect" to="Panel/V/H/ColorSelect" method="_gui_input"]
[connection signal="pressed" from="Panel/V/H2/Close" to="." method="done"]
diff --git a/ui/colorpicker/ColorSelect.gd b/ui/colorpicker/ColorSelect.gd
index 5ee779b..4533514 100644
--- a/ui/colorpicker/ColorSelect.gd
+++ b/ui/colorpicker/ColorSelect.gd
@@ -15,10 +15,6 @@ func set_color(newcolor):
update()
-func apply_hue(newhue):
- self.color.h = newhue
-
-
func _gui_input(event):
if Input.is_action_pressed("click") and event is InputEventMouse:
var position = event.position
diff --git a/ui/colorpicker/HueSlider.gd b/ui/colorpicker/HueSlider.gd
index 30bce64..bbc8234 100644
--- a/ui/colorpicker/HueSlider.gd
+++ b/ui/colorpicker/HueSlider.gd
@@ -1,28 +1,28 @@
extends Control
class_name HueSlider
-signal hue_changed(hue)
+signal color_changed(color)
-var hue: float setget set_hue
+var color: Color setget set_color
func _gui_input(event):
if Input.is_action_pressed("click") and event is InputEventMouse:
var position = event.position
var tmphue = clamp(position.y / rect_size.y, 0, 1)
- set_hue(tmphue)
- emit_signal("hue_changed", hue)
+ set_color(Color.from_hsv(tmphue, color.s, color.v))
+ emit_signal("color_changed", color)
-func set_hue(newhue):
- if newhue != hue:
- hue = newhue
+func set_color(newcolor):
+ if newcolor != color:
+ color = newcolor
update()
func _draw():
var x = rect_size.x
- var y = hue * rect_size.y
+ var y = color.h * rect_size.y
draw_line(Vector2(0, y - 1), Vector2(x, y - 1), Color.black, 1, true)
draw_line(Vector2(0, y), Vector2(x, y), Color.white, 1, true)
draw_line(Vector2(0, y + 1), Vector2(x, y + 1), Color.black, 1, true)
diff --git a/ui/theme/main.tres b/ui/theme/main.tres
index cfe884e..5e526c1 100644
--- a/ui/theme/main.tres
+++ b/ui/theme/main.tres
@@ -1,4 +1,4 @@
-[gd_resource type="Theme" load_steps=15 format=2]
+[gd_resource type="Theme" load_steps=18 format=2]
[ext_resource path="res://ui/verdana.tres" type="DynamicFont" id=1]
[ext_resource path="res://ui/theme/button.tres" type="StyleBox" id=2]
@@ -34,6 +34,26 @@ border_width_bottom = 2
border_color = Color( 1, 1, 1, 1 )
corner_detail = 20
+[sub_resource type="StyleBoxFlat" id=10]
+content_margin_left = 30.0
+content_margin_right = 30.0
+content_margin_top = 30.0
+content_margin_bottom = 30.0
+bg_color = Color( 0, 0, 0, 0.313726 )
+
+[sub_resource type="StyleBoxFlat" id=12]
+content_margin_left = 10.0
+content_margin_right = 10.0
+bg_color = Color( 0, 0, 0, 0.313726 )
+border_color = Color( 0, 0, 0, 0 )
+expand_margin_left = 10.0
+
+[sub_resource type="StyleBoxFlat" id=11]
+content_margin_left = 10.0
+content_margin_right = 10.0
+bg_color = Color( 0.188235, 0.188235, 0.188235, 1 )
+border_color = Color( 0, 0, 0, 0 )
+
[sub_resource type="StyleBoxEmpty" id=5]
[resource]
@@ -94,5 +114,10 @@ PopupMenu/icons/radio_unchecked = ExtResource( 3 )
PopupMenu/styles/hover = SubResource( 3 )
PopupMenu/styles/panel = ExtResource( 7 )
SpinBox/icons/updown = ExtResource( 3 )
+TabContainer/colors/font_color_bg = Color( 0.709804, 0.709804, 0.709804, 0.72549 )
+TabContainer/colors/font_color_fg = Color( 1, 1, 1, 1 )
+TabContainer/styles/panel = SubResource( 10 )
+TabContainer/styles/tab_bg = SubResource( 12 )
+TabContainer/styles/tab_fg = SubResource( 11 )
VBoxContainer/constants/separation = 15
VScrollBar/styles/scroll = SubResource( 5 )