online multiplayer chess game (note server currently down)
disable exit button on html5
on html5 `get_tree().quit()` freezes the game.
bendn 2022-05-22
parent 428dabb · commit f10a4cb
-rw-r--r--assets/ui/flag.png3
-rw-r--r--assets/ui/flag.png.import35
-rw-r--r--assets/ui/svg/flag.svg3
-rw-r--r--ui/GameUI.tscn15
-rw-r--r--ui/StartMenu.gd2
-rw-r--r--ui/StartMenu.tscn32
-rw-r--r--ui/barbutton/BarTextureButton.tscn1
-rw-r--r--ui/barbutton/resignbutton.gd5
8 files changed, 77 insertions, 19 deletions
diff --git a/assets/ui/flag.png b/assets/ui/flag.png
new file mode 100644
index 0000000..d35a110
--- /dev/null
+++ b/assets/ui/flag.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:3d92a4ee251e177f3b72625989c81c856e49d35602cc899dbff1daf771d43f0a
+size 389
diff --git a/assets/ui/flag.png.import b/assets/ui/flag.png.import
new file mode 100644
index 0000000..4b333f1
--- /dev/null
+++ b/assets/ui/flag.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/flag.png-77c9b7bf98c3bdd0a6037ebd527e5287.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://assets/ui/flag.png"
+dest_files=[ "res://.import/flag.png-77c9b7bf98c3bdd0a6037ebd527e5287.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=true
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/assets/ui/svg/flag.svg b/assets/ui/svg/flag.svg
new file mode 100644
index 0000000..0d31b91
--- /dev/null
+++ b/assets/ui/svg/flag.svg
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c4214b7bdfdeb88170e37cd5f39102b3f0e78a39cb6e5fc0dadb1638b487386e
+size 1235
diff --git a/ui/GameUI.tscn b/ui/GameUI.tscn
index 43901e7..c85aeb5 100644
--- a/ui/GameUI.tscn
+++ b/ui/GameUI.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=16 format=2]
+[gd_scene load_steps=18 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]
@@ -7,6 +7,8 @@
[ext_resource path="res://ui/Timer.gd" type="Script" id=5]
[ext_resource path="res://ui/sandisplay/SanDisplay.tscn" type="PackedScene" id=6]
[ext_resource path="res://ui/Status.gd" type="Script" id=7]
+[ext_resource path="res://ui/barbutton/resignbutton.gd" type="Script" id=8]
+[ext_resource path="res://assets/ui/flag.png" type="Texture" id=9]
[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]
@@ -106,16 +108,24 @@ custom_styles/panel = SubResource( 10 )
[node name="buttonbar" type="HBoxContainer" parent="Holder/Back/VBox/buttonbarholder"]
margin_right = 400.0
margin_bottom = 50.0
+custom_constants/separation = 0
alignment = 1
[node name="FlipBoard" parent="Holder/Back/VBox/buttonbarholder/buttonbar" instance=ExtResource( 16 )]
margin_left = 175.0
margin_right = 225.0
margin_bottom = 50.0
-rect_min_size = Vector2( 50, 50 )
script = ExtResource( 18 )
texture = ExtResource( 17 )
+[node name="ResignButton" parent="Holder/Back/VBox/buttonbarholder/buttonbar" instance=ExtResource( 16 )]
+visible = false
+margin_left = 200.0
+margin_right = 250.0
+margin_bottom = 50.0
+script = ExtResource( 8 )
+texture = ExtResource( 9 )
+
[node name="WhiteTime" type="Label" parent="Holder/Back/VBox"]
margin_top = 485.0
margin_right = 400.0
@@ -176,3 +186,4 @@ margin_right = -400.0
color = Color( 0, 0, 0, 0.784314 )
[connection signal="pressed" from="Holder/Back/VBox/buttonbarholder/buttonbar/FlipBoard" to="Holder/Back/VBox/buttonbarholder/buttonbar/FlipBoard" method="_pressed"]
+[connection signal="pressed" from="Holder/Back/VBox/buttonbarholder/buttonbar/ResignButton" to="Holder/Back/VBox/buttonbarholder/buttonbar/ResignButton" method="_pressed"]
diff --git a/ui/StartMenu.gd b/ui/StartMenu.gd
index 9911974..dd4e5fc 100644
--- a/ui/StartMenu.gd
+++ b/ui/StartMenu.gd
@@ -18,6 +18,8 @@ func _ready() -> void:
colorrect.color = nice_colors[randi() % nice_colors.size()]
timer.start(timer_length)
_on_Timer_timeout()
+ if OS.has_feature("HTML5"):
+ find_node("quit").queue_free()
func rand(clr) -> float:
diff --git a/ui/StartMenu.tscn b/ui/StartMenu.tscn
index 2102bab..e42a053 100644
--- a/ui/StartMenu.tscn
+++ b/ui/StartMenu.tscn
@@ -22,28 +22,26 @@ color = Color( 0, 0, 0, 1 )
[node name="MainButtons" type="VBoxContainer" parent="ColorRect" groups=["control"]]
anchor_left = 0.5
-anchor_top = 0.5
anchor_right = 0.5
-anchor_bottom = 0.5
-margin_left = -192.0
-margin_top = -224.0
-margin_right = 196.0
-margin_bottom = 412.0
+anchor_bottom = 1.0
+margin_left = -157.5
+margin_right = 157.5
+alignment = 1
[node name="multiplayer" type="Button" parent="ColorRect/MainButtons" groups=["control"]]
-margin_left = 36.0
-margin_right = 351.0
-margin_bottom = 106.0
+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="ColorRect/MainButtons" groups=["control"]]
-margin_left = 75.0
-margin_top = 121.0
-margin_right = 313.0
-margin_bottom = 227.0
+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
@@ -62,10 +60,10 @@ enabled_focus_mode = 0
text = "local"
[node name="quit" type="Button" parent="ColorRect/MainButtons" groups=["control"]]
-margin_left = 123.0
-margin_top = 242.0
-margin_right = 265.0
-margin_bottom = 348.0
+margin_left = 86.0
+margin_top = 468.0
+margin_right = 228.0
+margin_bottom = 574.0
focus_mode = 0
size_flags_horizontal = 4
enabled_focus_mode = 0
diff --git a/ui/barbutton/BarTextureButton.tscn b/ui/barbutton/BarTextureButton.tscn
index a18b6d9..b7091fc 100644
--- a/ui/barbutton/BarTextureButton.tscn
+++ b/ui/barbutton/BarTextureButton.tscn
@@ -5,6 +5,7 @@
[node name="BarTextureButton" type="Control"]
margin_right = 64.0
margin_bottom = 64.0
+rect_min_size = Vector2( 50, 50 )
script = ExtResource( 2 )
[node name="Background" type="ColorRect" parent="."]
diff --git a/ui/barbutton/resignbutton.gd b/ui/barbutton/resignbutton.gd
new file mode 100644
index 0000000..fb553ad
--- /dev/null
+++ b/ui/barbutton/resignbutton.gd
@@ -0,0 +1,5 @@
+extends BarTextureButton
+
+
+func _pressed():
+ pass