online multiplayer chess game (note server currently down)
ui better!
bendn 2022-06-03
parent fc07001 · commit 15fec5c
-rw-r--r--Grid.gd17
-rw-r--r--SanParse/Move.gd2
-rw-r--r--project.godot4
-rw-r--r--saveload.gd5
-rw-r--r--ui/GameUI.tscn50
-rw-r--r--ui/Settings.gd8
-rw-r--r--ui/Settings.tscn47
-rw-r--r--ui/account/Account.tscn28
-rw-r--r--ui/background/ColorfullBackground.gd25
-rw-r--r--ui/background/ColorfullBackground.tscn3
-rw-r--r--ui/barbutton/drawbutton.gd30
-rw-r--r--ui/barbutton/resignbutton.gd29
-rw-r--r--ui/boardlabels/BottomLeftLabel.tscn (renamed from ui/BottomLeftLabel.tscn)0
-rw-r--r--ui/boardlabels/TopRightLabel.tscn (renamed from ui/TopRightLabel.tscn)0
-rw-r--r--ui/colorpicker/ColorPickerButton.tscn4
-rw-r--r--ui/colorpicker/ColorSelect.gd20
-rw-r--r--ui/confirm/Confirm.tscn44
-rw-r--r--ui/confirm/confirm.gd23
-rw-r--r--ui/confirmbar.gd41
-rw-r--r--ui/theme/main.tres31
20 files changed, 233 insertions, 178 deletions
diff --git a/Grid.gd b/Grid.gd
index 5026c5c..514fc94 100644
--- a/Grid.gd
+++ b/Grid.gd
@@ -1,17 +1,10 @@
extends Node2D
class_name Grid
-const topper_header := "┏━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┓"
-const middle_header := "┣━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━┫"
-const middish_heads := "┗━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━┫"
-const bottom_header := "┗━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┛"
-const smaller_heads := " ┗━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┛"
-const letter_header := " ┃ a ┃ b ┃ c ┃ d ┃ e ┃ f ┃ g ┃ h ┃"
-const ender := " ┃ " # for pretty prints
const Piece := preload("res://Piece.tscn")
const Square := preload("res://Square.tscn")
-const BottomLeftLabel := preload("res://ui/BottomLeftLabel.tscn")
-const TopRightLabel := preload("res://ui/TopRightLabel.tscn")
+const BottomLeftLabel := preload("res://ui/boardlabels/BottomLeftLabel.tscn")
+const TopRightLabel := preload("res://ui/boardlabels/TopRightLabel.tscn")
const piece_size := Vector2(100, 100)
const default_metadata := {
@@ -71,6 +64,12 @@ func _input(event: InputEvent) -> void: # input
static func print_matrix_pretty(mat: Array) -> void: # print the matrix
+ var topper_header := "┏━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┓"
+ var middle_header := "┣━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━┫"
+ var middish_heads := "┗━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━┫"
+ var smaller_heads := " ┗━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┛"
+ var letter_header := " ┃ a ┃ b ┃ c ┃ d ┃ e ┃ f ┃ g ┃ h ┃"
+ var ender := " ┃ " # for pretty prints
for j in range(8): # for each row
var r: Array = mat[j] # get the row
if j == 0:
diff --git a/SanParse/Move.gd b/SanParse/Move.gd
index 5bb35b1..f5e40d8 100644
--- a/SanParse/Move.gd
+++ b/SanParse/Move.gd
@@ -47,7 +47,7 @@ func compile() -> String: # compiles the structure to a san
res += "+"
CHECKTYPES.CHECKMATE:
res += "#"
- return res
+ return res.strip_edges()
## tests
diff --git a/project.godot b/project.godot
index 6b4aec9..64e8663 100644
--- a/project.godot
+++ b/project.godot
@@ -34,10 +34,10 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://ui/colorpicker/ColorSelect.gd"
}, {
-"base": "Control",
+"base": "WindowDialog",
"class": "Confirm",
"language": "GDScript",
-"path": "res://ui/confirmbar.gd"
+"path": "res://ui/confirm/confirm.gd"
}, {
"base": "BarTextureButton",
"class": "DrawButton",
diff --git a/saveload.gd b/saveload.gd
index 65866e1..7d54b5f 100644
--- a/saveload.gd
+++ b/saveload.gd
@@ -10,7 +10,8 @@ const default_settings_data = {
"borderless": OS.window_borderless,
"piece_set": "california",
"board_color1": Color(0.870588, 0.890196, 0.901961),
- "board_color2": Color(0.54902, 0.635294, 0.678431)
+ "board_color2": Color(0.54902, 0.635294, 0.678431),
+ "rainbow": true
}
var files := {
@@ -48,7 +49,7 @@ func load_data(type: String) -> Dictionary:
var read_dictionary = from_base64(text)
if typeof(read_dictionary) != TYPE_DICTIONARY:
save(type) # OVERWRITE
- elif files[type]["data"].size() == read_dictionary.size():
+ elif files[type]["data"].keys() == read_dictionary.keys():
files[type]["data"] = read_dictionary
save(type) # overwrite.
file.close()
diff --git a/ui/GameUI.tscn b/ui/GameUI.tscn
index dc2112b..497a4f1 100644
--- a/ui/GameUI.tscn
+++ b/ui/GameUI.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=24 format=2]
+[gd_scene load_steps=21 format=2]
[ext_resource path="res://ui/theme/main.tres" type="Theme" id=1]
[ext_resource path="res://ui/roboto.tres" type="DynamicFont" id=2]
@@ -10,10 +10,7 @@
[ext_resource path="res://ui/barbutton/drawbutton.gd" type="Script" id=8]
[ext_resource path="res://assets/ui/draw.png" type="Texture" id=9]
[ext_resource path="res://ui/GameUI.gd" type="Script" id=10]
-[ext_resource path="res://assets/ui/check.png" type="Texture" id=11]
-[ext_resource path="res://assets/ui/close.png" type="Texture" id=12]
[ext_resource path="res://ui/barbutton/resignbutton.gd" type="Script" id=13]
-[ext_resource path="res://ui/confirmbar.gd" type="Script" id=14]
[ext_resource path="res://ui/FENlabel.gd" type="Script" id=15]
[ext_resource path="res://ui/barbutton/BarTextureButton.tscn" type="PackedScene" id=16]
[ext_resource path="res://assets/ui/flip_board.png" type="Texture" id=17]
@@ -135,7 +132,6 @@ margin_right = 337.0
texture_normal = ExtResource( 9 )
script = ExtResource( 8 )
status = NodePath("../../../Status")
-confirmbar = NodePath("../../../confirmbar")
[node name="ResignButton" parent="Holder/Back/VBox/buttonbarholder/buttonbar" instance=ExtResource( 16 )]
margin_left = 337.0
@@ -143,45 +139,6 @@ margin_right = 387.0
texture_normal = ExtResource( 19 )
script = ExtResource( 13 )
status = NodePath("../../../Status")
-drawbutton = NodePath("../DrawButton")
-confirmbar = NodePath("../../../confirmbar")
-
-[node name="confirmbar" type="Control" parent="Holder/Back/VBox"]
-visible = false
-margin_top = 490.0
-margin_right = 624.0
-margin_bottom = 590.0
-rect_min_size = Vector2( 0, 100 )
-script = ExtResource( 14 )
-__meta__ = {
-"_edit_group_": true,
-"_edit_lock_": true
-}
-status = NodePath("../Status")
-
-[node name="H" type="HBoxContainer" parent="Holder/Back/VBox/confirmbar"]
-anchor_right = 1.0
-anchor_bottom = 1.0
-custom_constants/separation = 0
-alignment = 1
-
-[node name="yes" parent="Holder/Back/VBox/confirmbar/H" instance=ExtResource( 16 )]
-margin_left = 212.0
-margin_right = 312.0
-margin_bottom = 100.0
-rect_min_size = Vector2( 100, 100 )
-size_flags_horizontal = 4
-size_flags_vertical = 4
-texture_normal = ExtResource( 11 )
-
-[node name="no" parent="Holder/Back/VBox/confirmbar/H" instance=ExtResource( 16 )]
-margin_left = 312.0
-margin_right = 412.0
-margin_bottom = 100.0
-rect_min_size = Vector2( 100, 100 )
-size_flags_horizontal = 4
-size_flags_vertical = 4
-texture_normal = ExtResource( 12 )
[node name="WhiteTime" type="Label" parent="Holder/Back/VBox"]
visible = false
@@ -249,8 +206,3 @@ anchor_right = 1.0
anchor_bottom = 1.0
margin_right = -400.0
color = Color( 0, 0, 0, 0.784314 )
-
-[connection signal="confirmed" from="Holder/Back/VBox/confirmbar" to="Holder/Back/VBox/buttonbarholder/buttonbar/DrawButton" method="_handle_confirm"]
-[connection signal="confirmed" from="Holder/Back/VBox/confirmbar" to="Holder/Back/VBox/buttonbarholder/buttonbar/ResignButton" method="_confirmed"]
-[connection signal="pressed" from="Holder/Back/VBox/confirmbar/H/yes" to="Holder/Back/VBox/confirmbar" method="_pressed" binds= [ true ]]
-[connection signal="pressed" from="Holder/Back/VBox/confirmbar/H/no" to="Holder/Back/VBox/confirmbar" method="_pressed" binds= [ false ]]
diff --git a/ui/Settings.gd b/ui/Settings.gd
index c74c4c3..24c148a 100644
--- a/ui/Settings.gd
+++ b/ui/Settings.gd
@@ -8,6 +8,7 @@ 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 rainbow = find_node("rainbow")
onready var settings: Dictionary = SaveLoad.files["settings"]["data"] setget set_settings
@@ -31,6 +32,7 @@ func update_button_visuals(set: Dictionary = settings) -> void:
borderlessbutton.pressed = !set["borderless"]
board_color1.color = set["board_color1"]
board_color2.color = set["board_color2"]
+ rainbow.pressed = set["rainbow"]
preview.update_preview(set["board_color1"], set["board_color2"], set["piece_set"])
ignore_set_settings = false
@@ -56,6 +58,7 @@ func update_vars() -> void:
OS.vsync_enabled = settings.vsync
OS.window_fullscreen = settings.fullscreen
OS.window_borderless = settings.borderless
+ ColorBack.rainbow = settings.rainbow
SaveLoad.files["settings"]["data"] = settings
SaveLoad.save("settings")
@@ -93,3 +96,8 @@ func _on_boardcolor2_newcolor(color: Color) -> void:
func _on_resetbutton_pressed() -> void:
self.settings = SaveLoad.default_settings_data.duplicate(true)
update_vars()
+
+
+func _on_rainbow_toggled(button_pressed: bool) -> void:
+ ColorBack.rainbow = button_pressed
+ self.settings.rainbow = button_pressed
diff --git a/ui/Settings.tscn b/ui/Settings.tscn
index 3faf8e3..c7f5f4e 100644
--- a/ui/Settings.tscn
+++ b/ui/Settings.tscn
@@ -21,8 +21,8 @@ size_flags_vertical = 0
alignment = 1
[node name="TabContainer" type="TabContainer" parent="H"]
-margin_left = 239.0
-margin_right = 668.0
+margin_left = 119.0
+margin_right = 788.0
margin_bottom = 570.0
size_flags_vertical = 0
custom_constants/hseparation = 20
@@ -39,26 +39,26 @@ margin_bottom = -30.0
alignment = 1
[node name="boardcolor1" parent="H/TabContainer/colors" instance=ExtResource( 5 )]
-margin_left = 21.0
-margin_top = 26.0
-margin_right = 347.0
-margin_bottom = 132.0
+margin_left = 141.0
+margin_top = 51.0
+margin_right = 467.0
+margin_bottom = 157.0
size_flags_horizontal = 4
text = "boardcolor1"
[node name="boardcolor2" parent="H/TabContainer/colors" instance=ExtResource( 5 )]
-margin_left = 21.0
-margin_top = 147.0
-margin_right = 347.0
-margin_bottom = 253.0
+margin_left = 141.0
+margin_top = 172.0
+margin_right = 467.0
+margin_bottom = 278.0
size_flags_horizontal = 4
text = "boardcolor2"
[node name="PieceSet" type="OptionButton" parent="H/TabContainer/colors"]
-margin_left = 1.0
-margin_top = 268.0
-margin_right = 367.0
-margin_bottom = 424.0
+margin_left = 173.0
+margin_top = 293.0
+margin_right = 436.0
+margin_bottom = 399.0
focus_mode = 0
size_flags_horizontal = 4
size_flags_vertical = 0
@@ -66,6 +66,7 @@ custom_constants/hseparation = 3
enabled_focus_mode = 0
text = "piece set"
icon = ExtResource( 3 )
+expand_icon = true
[node name="window" type="VBoxContainer" parent="H/TabContainer"]
visible = false
@@ -108,9 +109,22 @@ size_flags_horizontal = 4
enabled_focus_mode = 0
text = "borders"
+[node name="misc" type="VBoxContainer" parent="H/TabContainer"]
+visible = false
+margin_right = 40.0
+margin_bottom = 40.0
+
+[node name="rainbow" type="CheckBox" parent="H/TabContainer/misc"]
+margin_right = 609.0
+margin_bottom = 140.0
+focus_mode = 0
+enabled_focus_mode = 0
+text = "rainbow background"
+align = 2
+
[node name="Container" type="VBoxContainer" parent="H"]
-margin_left = 683.0
-margin_right = 1183.0
+margin_left = 803.0
+margin_right = 1303.0
margin_bottom = 800.0
rect_min_size = Vector2( 300, 0 )
@@ -150,4 +164,5 @@ __meta__ = {
[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="toggled" from="H/TabContainer/misc/rainbow" to="." method="_on_rainbow_toggled"]
[connection signal="pressed" from="H/Container/resetbutton" to="." method="_on_resetbutton_pressed"]
diff --git a/ui/account/Account.tscn b/ui/account/Account.tscn
index c71e953..ae0e072 100644
--- a/ui/account/Account.tscn
+++ b/ui/account/Account.tscn
@@ -41,10 +41,12 @@ margin_bottom = 140.0
script = ExtResource( 7 )
[node name="choose" type="TabContainer" parent="."]
+margin_left = 177.0
margin_top = 155.0
-margin_right = 1422.0
-margin_bottom = 800.0
-size_flags_vertical = 3
+margin_right = 1245.0
+margin_bottom = 613.0
+size_flags_horizontal = 4
+size_flags_vertical = 4
[node name="signup" type="VBoxContainer" parent="choose"]
anchor_right = 1.0
@@ -58,8 +60,7 @@ custom_constants/separation = 5
[node name="usernamepass" parent="choose/signup" instance=ExtResource( 5 )]
anchor_right = 0.0
anchor_bottom = 0.0
-margin_left = 177.0
-margin_right = 1185.0
+margin_right = 1008.0
margin_bottom = 227.0
[node name="flag" type="OptionButton" parent="choose/signup"]
@@ -77,9 +78,9 @@ align = 1
expand_icon = true
[node name="signupbutton" type="Button" parent="choose/signup"]
-margin_left = 566.0
+margin_left = 389.0
margin_top = 232.0
-margin_right = 796.0
+margin_right = 619.0
margin_bottom = 338.0
rect_min_size = Vector2( 230, 0 )
focus_mode = 0
@@ -98,12 +99,17 @@ margin_bottom = -30.0
custom_constants/separation = 5
[node name="usernamepass" parent="choose/signin" instance=ExtResource( 5 )]
+anchor_right = 0.0
+anchor_bottom = 0.0
+margin_left = 177.0
+margin_right = 1185.0
+margin_bottom = 227.0
[node name="signinbutton" type="Button" parent="choose/signin"]
-margin_left = 577.0
-margin_top = 240.0
-margin_right = 785.0
-margin_bottom = 346.0
+margin_left = 566.0
+margin_top = 232.0
+margin_right = 796.0
+margin_bottom = 338.0
rect_min_size = Vector2( 230, 0 )
focus_mode = 0
size_flags_horizontal = 4
diff --git a/ui/background/ColorfullBackground.gd b/ui/background/ColorfullBackground.gd
index 590211d..6c14b8a 100644
--- a/ui/background/ColorfullBackground.gd
+++ b/ui/background/ColorfullBackground.gd
@@ -5,15 +5,18 @@ export(PoolColorArray) var colors := [
Color(0.913725, 0.847059, 0.403922, 1),
Color(0.380392, 0.741176, 0.647059, 1),
Color(0.321569, 0.368627, 0.858824, 1),
- Color(0.843137, 0.133333, 0.133333, 1),
+ Color(0.596078, 0.188235, 0.619608),
Color(0.109804, 0.160784, 0.564706, 1),
Color(0.376471, 0.796078, 0.317647, 1),
Color(0.8, 0.364706, 0.588235, 1),
Color(0.984314, 0.858824, 0.282353, 1),
- Color(0.164706, 0.0862745, 0.247059, 1)
+ Color(0.164706, 0.0862745, 0.247059, 1),
+ Color(0.509804, 0.509804, 0.509804, 1),
+ Color(0.679297, 0.679297, 0.679297, 1)
]
export(float) var length := 2.8
+var rainbow := true setget set_rainbow
var tween := Tween.new()
var timer := Timer.new()
@@ -22,18 +25,26 @@ static func rand(clr) -> float:
return clamp(clr + rand_range(0, .1) if randi() % 2 else clr - rand_range(0, .1), 0, 1)
+func set_rainbow(newrainbow):
+ rainbow = newrainbow
+ change_color()
+
+
func _ready() -> void:
randomize()
- add_child(timer)
add_child(tween)
+ add_child(timer)
timer.connect("timeout", self, "change_color")
color = colors[randi() % colors.size()]
change_color()
func change_color() -> void:
- var clr: Color = colors[randi() % colors.size()]
- clr = Color(rand(clr.r), rand(clr.g), rand(clr.b), 1)
- tween.interpolate_property(self, "color", color, clr, length, Tween.TRANS_ELASTIC)
- tween.start()
timer.start(length)
+ if rainbow:
+ var clr: Color = colors[randi() % colors.size()]
+ clr = Color(rand(clr.r), rand(clr.g), rand(clr.b), 1)
+ tween.interpolate_property(self, "color", color, clr, length, Tween.TRANS_ELASTIC)
+ else:
+ tween.interpolate_property(self, "color", color, colors[-1], length, Tween.TRANS_ELASTIC)
+ tween.start()
diff --git a/ui/background/ColorfullBackground.tscn b/ui/background/ColorfullBackground.tscn
index d941557..dd9f95c 100644
--- a/ui/background/ColorfullBackground.tscn
+++ b/ui/background/ColorfullBackground.tscn
@@ -6,6 +6,5 @@
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
-color = Color( 0, 0, 0, 1 )
script = ExtResource( 1 )
-colors = [ Color( 0.784314, 0.427451, 0.427451, 1 ), Color( 0.913725, 0.847059, 0.403922, 1 ), Color( 0.380392, 0.741176, 0.647059, 1 ), Color( 0.321569, 0.368627, 0.858824, 1 ), Color( 0.345098, 0.345098, 0.345098, 1 ), Color( 0.109804, 0.160784, 0.564706, 1 ), Color( 0.376471, 0.796078, 0.317647, 1 ), Color( 0.8, 0.364706, 0.588235, 1 ), Color( 0.984314, 0.858824, 0.282353, 1 ), Color( 0.164706, 0.0862745, 0.247059, 1 ) ]
+colors = PoolColorArray( 0.784314, 0.427451, 0.427451, 1, 0.913725, 0.847059, 0.403922, 1, 0.380392, 0.741176, 0.647059, 1, 0.321569, 0.368627, 0.858824, 1, 0.596078, 0.188235, 0.619608, 1, 0.109804, 0.160784, 0.564706, 1, 0.376471, 0.796078, 0.317647, 1, 0.8, 0.364706, 0.588235, 1, 0.984314, 0.858824, 0.282353, 1, 0.164706, 0.0862745, 0.247059, 1, 0.603922, 0.596078, 0.701961, 1, 0.592157, 0.592157, 0.592157, 1 )
diff --git a/ui/barbutton/drawbutton.gd b/ui/barbutton/drawbutton.gd
index 6aa3cb4..fd2f01c 100644
--- a/ui/barbutton/drawbutton.gd
+++ b/ui/barbutton/drawbutton.gd
@@ -1,22 +1,25 @@
extends BarTextureButton
class_name DrawButton, "res://assets/ui/draw.png"
-export(NodePath) onready var status = get_node(status) as StatusLabel
-export(NodePath) onready var confirmbar = get_node(confirmbar) as Confirm
+const Confirm = preload("res://ui/confirm/Confirm.tscn")
+var waiting_on_answer: Confirm = null
-var waiting_on_answer := false
+export(NodePath) onready var status = get_node(status) as StatusLabel
-func _ready():
+func _ready() -> void:
+ PacketHandler.connect("game_over", self, "set_disabled", [true])
if Globals.network:
Globals.network.connect("signal_recieved", self, "_on_signal")
-func _on_signal(what: Dictionary):
+func _on_signal(what: Dictionary) -> void:
if what.type == Network.SIGNALHEADERS.draw:
if "question" in what:
- confirmbar.confirm(self, "Your opponent requests a draw", 20)
- waiting_on_answer = true
+ var confirm = Confirm.instance()
+ add_child(confirm)
+ confirm.confirm(self, "Your opponent wants to draw", 20)
+ waiting_on_answer = confirm
else:
disabled = false
if what.accepted:
@@ -29,24 +32,21 @@ func drawed() -> GDScriptFunctionState:
return Globals.grid.drawed("mutual agreement")
-func stoplooking() -> void:
- _handle_confirm(false)
-
-
func _pressed() -> void:
if waiting_on_answer:
- _handle_confirm(true)
- confirmbar.stop_looking()
+ _confirmed(true)
else:
disabled = true
Globals.network.signal("", Network.SIGNALHEADERS.draw, "question")
status.set_text("Draw request sent")
-func _handle_confirm(yes: bool) -> void: # called from confirmbar.confirmed
+func _confirmed(yes: bool) -> void: # called from confirmbar.confirmed
if waiting_on_answer:
+ if !waiting_on_answer.is_queued_for_deletion():
+ waiting_on_answer.queue_free()
disabled = false
- waiting_on_answer = false
+ waiting_on_answer = null
Globals.network.signal(yes, Network.SIGNALHEADERS.draw, "accepted")
if yes:
drawed()
diff --git a/ui/barbutton/resignbutton.gd b/ui/barbutton/resignbutton.gd
index e66c42a..a5a3041 100644
--- a/ui/barbutton/resignbutton.gd
+++ b/ui/barbutton/resignbutton.gd
@@ -1,19 +1,19 @@
extends BarTextureButton
class_name ResignButton, "res://assets/ui/flag.png"
-export(NodePath) onready var status = get_node(status) as StatusLabel
-export(NodePath) onready var drawbutton = get_node(drawbutton) as DrawButton
-export(NodePath) onready var confirmbar = get_node(confirmbar) as Confirm
+const Confirm = preload("res://ui/confirm/Confirm.tscn")
+var waiting_on_answer: Confirm = null
-var waiting_on_answer = false
+export(NodePath) onready var status = get_node(status) as StatusLabel
func _ready() -> void:
+ PacketHandler.connect("game_over", self, "set_disabled", [true])
if Globals.network:
Globals.network.connect("signal_recieved", self, "resigned")
-func resigned(what: Dictionary):
+func resigned(what: Dictionary) -> void:
if what.type == Network.SIGNALHEADERS.resign:
Globals.grid.win(Globals.team, "resignation")
@@ -21,21 +21,18 @@ func resigned(what: Dictionary):
func _pressed() -> void:
if waiting_on_answer:
_confirmed(true)
- confirmbar.stop_looking()
else:
- confirmbar.confirm(self, "Resign?", 20)
- waiting_on_answer = true
- drawbutton.disabled = true
-
-
-func stoplooking() -> void:
- _confirmed(false)
+ var confirm = Confirm.instance()
+ add_child(confirm)
+ confirm.confirm(self, "Resign?", 20)
+ waiting_on_answer = confirm
-func _confirmed(what: bool):
+func _confirmed(what: bool) -> void:
if waiting_on_answer:
- waiting_on_answer = false
- drawbutton.disabled = what # dont un disable it if the game is over
+ if !waiting_on_answer.is_queued_for_deletion():
+ waiting_on_answer.queue_free()
+ waiting_on_answer = null
if what:
Globals.network.signal("", Network.SIGNALHEADERS.resign)
Globals.grid.win(!Globals.team, "resignation")
diff --git a/ui/BottomLeftLabel.tscn b/ui/boardlabels/BottomLeftLabel.tscn
index f8b2c2d..f8b2c2d 100644
--- a/ui/BottomLeftLabel.tscn
+++ b/ui/boardlabels/BottomLeftLabel.tscn
diff --git a/ui/TopRightLabel.tscn b/ui/boardlabels/TopRightLabel.tscn
index 3e78fe7..3e78fe7 100644
--- a/ui/TopRightLabel.tscn
+++ b/ui/boardlabels/TopRightLabel.tscn
diff --git a/ui/colorpicker/ColorPickerButton.tscn b/ui/colorpicker/ColorPickerButton.tscn
index 36c89d8..5d39c1f 100644
--- a/ui/colorpicker/ColorPickerButton.tscn
+++ b/ui/colorpicker/ColorPickerButton.tscn
@@ -10,6 +10,10 @@ content_margin_right = 10.0
content_margin_top = 10.0
content_margin_bottom = 10.0
bg_color = Color( 0, 0, 0, 0.784314 )
+corner_radius_top_left = 10
+corner_radius_top_right = 10
+corner_radius_bottom_right = 10
+corner_radius_bottom_left = 10
[node name="ColorPickerButton" type="Button"]
margin_right = 232.0
diff --git a/ui/colorpicker/ColorSelect.gd b/ui/colorpicker/ColorSelect.gd
index 1a8ddfa..a36c98b 100644
--- a/ui/colorpicker/ColorSelect.gd
+++ b/ui/colorpicker/ColorSelect.gd
@@ -29,15 +29,23 @@ func _gui_input(event: InputEvent) -> void:
func _draw() -> void:
var draw_color := color.inverted()
- var vlinex := clamp(last_clicked_pos.x, 0, rect_size.x)
+ if color.h == 0:
+ var vlinex := clamp(last_clicked_pos.x, 0, rect_size.x)
- draw_line(Vector2(vlinex, 0), Vector2(vlinex, rect_size.x), draw_color)
+ draw_line(Vector2(vlinex, 0), Vector2(vlinex, rect_size.x), draw_color)
- var hliney = clamp(last_clicked_pos.y, 0, rect_size.y)
+ var hliney = clamp(last_clicked_pos.y, 0, rect_size.y)
- draw_line(Vector2(0, hliney), Vector2(rect_size.x, hliney), draw_color)
+ draw_line(Vector2(0, hliney), Vector2(rect_size.x, hliney), draw_color)
+ else:
+ var vlinex = color.s * rect_size.x
+
+ draw_line(Vector2(vlinex, 0), Vector2(vlinex, rect_size.y), draw_color)
+
+ var hliney = rect_size.y - color.v * rect_size.y
+
+ draw_line(Vector2(0, hliney), Vector2(rect_size.x, hliney), draw_color)
func _hue_changed(hue: float) -> void:
- color.h = hue
- set_color(color, true)
+ set_color(Color.from_hsv(hue, color.s, color.v), true)
diff --git a/ui/confirm/Confirm.tscn b/ui/confirm/Confirm.tscn
new file mode 100644
index 0000000..400fd5c
--- /dev/null
+++ b/ui/confirm/Confirm.tscn
@@ -0,0 +1,44 @@
+[gd_scene load_steps=6 format=2]
+
+[ext_resource path="res://ui/theme/main.tres" type="Theme" id=1]
+[ext_resource path="res://ui/barbutton/BarTextureButton.tscn" type="PackedScene" id=2]
+[ext_resource path="res://assets/ui/close.png" type="Texture" id=3]
+[ext_resource path="res://ui/confirm/confirm.gd" type="Script" id=4]
+[ext_resource path="res://assets/ui/check.png" type="Texture" id=5]
+
+[node name="Confirm" type="WindowDialog"]
+margin_right = 576.0
+margin_bottom = 168.0
+rect_min_size = Vector2( 700, 0 )
+theme = ExtResource( 1 )
+popup_exclusive = true
+script = ExtResource( 4 )
+
+[node name="H" type="HBoxContainer" parent="."]
+anchor_right = 1.0
+anchor_bottom = 1.0
+custom_constants/separation = 0
+alignment = 1
+
+[node name="yes" parent="H" instance=ExtResource( 2 )]
+margin_left = 250.0
+margin_top = 34.0
+margin_right = 350.0
+margin_bottom = 134.0
+rect_min_size = Vector2( 100, 100 )
+size_flags_horizontal = 4
+size_flags_vertical = 4
+texture_normal = ExtResource( 5 )
+
+[node name="no" parent="H" instance=ExtResource( 2 )]
+margin_left = 350.0
+margin_top = 34.0
+margin_right = 450.0
+margin_bottom = 134.0
+rect_min_size = Vector2( 100, 100 )
+size_flags_horizontal = 4
+size_flags_vertical = 4
+texture_normal = ExtResource( 3 )
+
+[connection signal="pressed" from="H/yes" to="." method="_pressed" binds= [ true ]]
+[connection signal="pressed" from="H/no" to="." method="_pressed" binds= [ false ]]
diff --git a/ui/confirm/confirm.gd b/ui/confirm/confirm.gd
new file mode 100644
index 0000000..1156159
--- /dev/null
+++ b/ui/confirm/confirm.gd
@@ -0,0 +1,23 @@
+extends WindowDialog
+class_name Confirm
+
+signal confirmed(what)
+
+var timer := Timer.new()
+
+
+func _ready() -> void:
+ add_child(timer)
+ timer.connect("timeout", self, "_pressed", [false])
+
+
+func confirm(who, what: String, timeout := 5, called := "_confirmed"):
+ connect("confirmed", who, called)
+ popup_centered()
+ window_title = what
+ timer.start(timeout)
+
+
+func _pressed(what: bool):
+ emit_signal("confirmed", what)
+ queue_free()
diff --git a/ui/confirmbar.gd b/ui/confirmbar.gd
deleted file mode 100644
index 8b188aa..0000000
--- a/ui/confirmbar.gd
+++ /dev/null
@@ -1,41 +0,0 @@
-extends Control
-class_name Confirm
-
-signal confirmed(what)
-
-export(NodePath) onready var status = get_node(status) as StatusLabel
-
-var timer := Timer.new()
-var looking: Node = null
-
-
-func _ready() -> void:
- add_child(timer)
- timer.connect("timeout", self, "_pressed", [false])
-
-
-func _timeout() -> void:
- _pressed(false)
-
-
-func stop_looking() -> void:
- looking = null
- timer.stop()
- hide()
-
-
-func confirm(who: Node, what: String, timeout := 5):
- if is_instance_valid(looking):
- looking.stoplooking()
- looking = who
- show()
- status.set_text(what, timeout)
- timer.start(timeout)
-
-
-func _pressed(what: bool):
- for i in $H.get_children():
- i._focused(false)
- status.set_text("", 0)
- emit_signal("confirmed", what)
- stop_looking()
diff --git a/ui/theme/main.tres b/ui/theme/main.tres
index c729f76..2061107 100644
--- a/ui/theme/main.tres
+++ b/ui/theme/main.tres
@@ -1,4 +1,4 @@
-[gd_resource type="Theme" load_steps=18 format=2]
+[gd_resource type="Theme" load_steps=20 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]
@@ -7,6 +7,7 @@
[ext_resource path="res://ui/theme/buttonhover.tres" type="StyleBox" id=5]
[ext_resource path="res://assets/ui/checkedbox.png" type="Texture" id=6]
[ext_resource path="res://ui/theme/flatblack.tres" type="StyleBox" id=7]
+[ext_resource path="res://ui/theme/transblack.tres" type="StyleBox" id=8]
[sub_resource type="StyleBoxTexture" id=6]
texture = ExtResource( 4 )
@@ -42,6 +43,12 @@ content_margin_right = 30.0
content_margin_top = 30.0
content_margin_bottom = 30.0
bg_color = Color( 0, 0, 0, 0.313726 )
+border_blend = true
+corner_radius_top_left = 50
+corner_radius_top_right = 50
+corner_radius_bottom_right = 30
+corner_radius_bottom_left = 30
+corner_detail = 15
[sub_resource type="StyleBoxFlat" id=12]
content_margin_left = 10.0
@@ -65,6 +72,20 @@ border_color = Color( 0, 0, 0, 0.392157 )
[sub_resource type="StyleBoxEmpty" id=5]
+[sub_resource type="StyleBoxFlat" id=13]
+content_margin_left = 10.0
+content_margin_right = 10.0
+content_margin_bottom = 10.0
+bg_color = Color( 0, 0, 0, 0.588235 )
+border_width_top = 65
+border_color = Color( 0.180392, 0.180392, 0.180392, 1 )
+corner_radius_top_left = 30
+corner_radius_top_right = 30
+corner_radius_bottom_right = 30
+corner_radius_bottom_left = 30
+corner_detail = 15
+expand_margin_top = 65.0
+
[resource]
default_font = ExtResource( 1 )
Button/colors/font_color = Color( 1, 1, 1, 1 )
@@ -122,6 +143,7 @@ PopupMenu/icons/radio_checked = ExtResource( 3 )
PopupMenu/icons/radio_unchecked = ExtResource( 3 )
PopupMenu/styles/hover = SubResource( 3 )
PopupMenu/styles/panel = ExtResource( 7 )
+PopupPanel/styles/panel = ExtResource( 8 )
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 )
@@ -130,3 +152,10 @@ TabContainer/styles/tab_bg = SubResource( 12 )
TabContainer/styles/tab_fg = SubResource( 11 )
VBoxContainer/constants/separation = 15
VScrollBar/styles/scroll = SubResource( 5 )
+WindowDialog/colors/title_color = Color( 1, 1, 1, 1 )
+WindowDialog/constants/close_h_ofs = 0
+WindowDialog/constants/close_v_ofs = 0
+WindowDialog/constants/title_height = 60
+WindowDialog/icons/close = ExtResource( 3 )
+WindowDialog/icons/close_highlight = ExtResource( 3 )
+WindowDialog/styles/panel = SubResource( 13 )