online multiplayer chess game (note server currently down)
-rw-r--r--.github/workflows/export.yml13
-rw-r--r--.gitignore1
-rw-r--r--Utils.gd23
-rw-r--r--export_presets.cfg35
-rw-r--r--project.godot10
-rw-r--r--ui/board/Board.gd10
-rw-r--r--ui/board/Game.gd2
-rw-r--r--ui/menus/StartMenu.tscn77
-rw-r--r--ui/menus/lobby/Lobby.gd10
-rw-r--r--ui/menus/lobby/Lobby.tscn5
-rw-r--r--ui/menus/startmenu/StartMenu.gd (renamed from ui/menus/StartMenu.gd)2
-rw-r--r--ui/menus/startmenu/StartMenu.tscn97
-rw-r--r--ui/menus/startmenu/VersionLabel.gd6
13 files changed, 185 insertions, 106 deletions
diff --git a/.github/workflows/export.yml b/.github/workflows/export.yml
index 0434ad4..f71fb96 100644
--- a/.github/workflows/export.yml
+++ b/.github/workflows/export.yml
@@ -8,12 +8,13 @@ on:
- "**.import"
- "**.tres"
- "**.ttf"
+ - "**.yml"
branches:
- main
env:
GODOT_VERSION: 3.5
- RELEASE: rc6
+ RELEASE: rc
NAME: ${{ github.event.repository.name }}
jobs:
@@ -21,7 +22,7 @@ jobs:
name: Windows Export
runs-on: ubuntu-20.04
container:
- image: ghcr.io/theorioli/godot-ci:3.5.rc6
+ image: ghcr.io/bend-n/godot-2d:3.5.rc
steps:
- name: Build
uses: bend-n/godot-actions/.github/actions/export-windows@main
@@ -30,7 +31,7 @@ jobs:
name: Linux Export
runs-on: ubuntu-20.04
container:
- image: ghcr.io/theorioli/godot-ci:3.5.rc6
+ image: ghcr.io/bend-n/godot-2d:3.5.rc
steps:
- name: Build
uses: bend-n/godot-actions/.github/actions/export-linux@main
@@ -39,7 +40,7 @@ jobs:
name: Web Export
runs-on: ubuntu-20.04
container:
- image: ghcr.io/theorioli/godot-ci:3.5.rc6
+ image: ghcr.io/bend-n/godot-2d:3.5.rc
steps:
- name: Build
uses: bend-n/godot-actions/.github/actions/export-web@main
@@ -48,7 +49,7 @@ jobs:
name: Mac Export
runs-on: ubuntu-20.04
container:
- image: ghcr.io/theorioli/godot-ci:3.5.rc6
+ image: ghcr.io/bend-n/godot-2d:3.5.rc
steps:
- name: Build
uses: bend-n/godot-actions/.github/actions/export-mac@main
@@ -57,7 +58,7 @@ jobs:
name: Android Export
runs-on: ubuntu-20.04
container:
- image: ghcr.io/theorioli/godot-ci:3.5.rc6
+ image: ghcr.io/bend-n/godot-2d:3.5.rc
steps:
- name: Build
uses: bend-n/godot-actions/.github/actions/export-android@main
diff --git a/.gitignore b/.gitignore
index 5bbe921..1e3ed2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ logs/
.vscode/
exports/
*.x86_64
+version
diff --git a/Utils.gd b/Utils.gd
index 70ac59b..ddac1ae 100644
--- a/Utils.gd
+++ b/Utils.gd
@@ -17,6 +17,10 @@ func expand_color(color: String) -> String:
return "white" if color == "w" else "black"
+func get_version() -> String:
+ return SaveLoad.load_string("res://version")
+
+
func _ready() -> void:
request() # check internet ok?
cli()
@@ -37,6 +41,16 @@ func cli() -> void:
parser.add_argument(
Arg.new(
{
+ triggers = ["--version", "-v", "-V"],
+ n_args = 0,
+ help = "show version and exit",
+ action = "store_true",
+ }
+ )
+ )
+ parser.add_argument(
+ Arg.new(
+ {
triggers = ["--host", "-h"],
n_args = 1,
default = "game_code",
@@ -82,9 +96,12 @@ func cli() -> void:
)
var args = parser.parse_arguments()
Debug.debug = str_bool(args["debug"]) if args.has("debug") else OS.is_debug_build()
- if args.has("help") and args["help"]:
+ if args.get("help", false):
print(parser.help("chess game"))
get_tree().quit() # dont wait
+ elif args.get("version", false):
+ print("chess %s" % get_version())
+ get_tree().quit() # dont wait
elif args.has("host") or args.has("join"):
if !internet:
printerr("No internet")
@@ -170,10 +187,8 @@ static func to_str(type: int) -> String:
return "PNBRQK"[type]
-# cant wait for 4.0 dict.merge(dict) :C
static func append_dict(dict: Dictionary, newdict: Dictionary) -> Dictionary:
- for key in newdict:
- dict[key] = newdict[key]
+ dict.merge(newdict)
return dict
diff --git a/export_presets.cfg b/export_presets.cfg
index a7ca01a..847a219 100644
--- a/export_presets.cfg
+++ b/export_presets.cfg
@@ -5,7 +5,7 @@ platform="Mac OSX"
runnable=true
custom_features=""
export_filter="all_resources"
-include_filter="COPYING.md, LICENSE"
+include_filter="COPYING.md, LICENSE, version"
exclude_filter=""
export_path=""
script_export_mode=1
@@ -79,7 +79,7 @@ platform="HTML5"
runnable=true
custom_features=""
export_filter="all_resources"
-include_filter="COPYING.md, LICENSE"
+include_filter="COPYING.md, LICENSE, version"
exclude_filter="assets/pieces/alpha/*, assets/pieces/governor/*, assets/pieces/horsey/*, assets/pieces/libra/*, assets/pieces/maestro/*, assets/pieces/pixel/*"
export_path=""
script_export_mode=1
@@ -114,7 +114,7 @@ platform="Windows Desktop"
runnable=true
custom_features=""
export_filter="all_resources"
-include_filter="COPYING.md, LICENSE"
+include_filter="COPYING.md, LICENSE, version"
exclude_filter=""
export_path=""
script_export_mode=1
@@ -157,7 +157,7 @@ platform="Linux/X11"
runnable=true
custom_features=""
export_filter="all_resources"
-include_filter="COPYING.md, LICENSE"
+include_filter="COPYING.md, LICENSE, version"
exclude_filter=""
export_path=""
script_export_mode=1
@@ -182,7 +182,7 @@ platform="Android"
runnable=true
custom_features=""
export_filter="all_resources"
-include_filter=""
+include_filter="COPYING.md, LICENSE, version"
exclude_filter=""
export_path=""
script_export_mode=1
@@ -380,3 +380,28 @@ permissions/write_sms=false
permissions/write_social_stream=false
permissions/write_sync_settings=false
permissions/write_user_dictionary=false
+
+[preset.5]
+
+name="Linux/X11"
+platform="Linux/X11"
+runnable=false
+custom_features=""
+export_filter="all_resources"
+include_filter=""
+exclude_filter=""
+export_path=""
+script_export_mode=1
+script_encryption_key=""
+
+[preset.5.options]
+
+custom_template/debug=""
+custom_template/release=""
+binary_format/64_bits=true
+binary_format/embed_pck=false
+texture_format/bptc=false
+texture_format/s3tc=true
+texture_format/etc=false
+texture_format/etc2=false
+texture_format/no_bptc_fallbacks=true
diff --git a/project.godot b/project.godot
index 254d4a5..f79d9a0 100644
--- a/project.godot
+++ b/project.godot
@@ -223,6 +223,11 @@ _global_script_classes=[ {
"class": "UsernamePass",
"language": "GDScript",
"path": "res://ui/menus/account/usernamepass.gd"
+}, {
+"base": "Label",
+"class": "VersionLabel",
+"language": "GDScript",
+"path": "res://ui/menus/startmenu/VersionLabel.gd"
} ]
_global_script_class_icons={
"Arg": "",
@@ -267,14 +272,15 @@ _global_script_class_icons={
"TextEditor": "",
"UndoButton": "",
"UserPanel": "",
-"UsernamePass": ""
+"UsernamePass": "",
+"VersionLabel": ""
}
[application]
config/name="chess"
config/description="pog"
-run/main_scene="res://ui/menus/StartMenu.tscn"
+run/main_scene="res://ui/menus/startmenu/StartMenu.tscn"
config/use_custom_user_dir=true
config/custom_user_dir_name="chess"
boot_splash/image="res://icon.png"
diff --git a/ui/board/Board.gd b/ui/board/Board.gd
index 1da4089..f0f388d 100644
--- a/ui/board/Board.gd
+++ b/ui/board/Board.gd
@@ -107,8 +107,8 @@ func create_labels() -> void:
font.size = 15
for k in Chess.SQUARE_MAP:
if k == "h1":
- var l = init_label(font,k,k[0],VALIGN_BOTTOM,0,false)
- var n = init_label(font,k, k[1], 0,VALIGN_BOTTOM,false)
+ var l = init_label(font, k, k[0], VALIGN_BOTTOM, 0, false)
+ var n = init_label(font, k, k[1], 0, VALIGN_BOTTOM, false)
var h = HBoxContainer.new()
h.mouse_filter = MOUSE_FILTER_IGNORE
h.add_child(l)
@@ -116,9 +116,9 @@ func create_labels() -> void:
labels.numbers.append(n)
labels.letters.append(l)
foreground.add_child(h)
- elif k[0] == "h": # file h contains numbers
+ elif k[0] == "h": # file h contains numbers
labels.numbers.append(init_label(font, k, k[1], 0, VALIGN_BOTTOM))
- elif k[1] == "1": # rank 1 contains letters
+ elif k[1] == "1": # rank 1 contains letters
labels.letters.append(init_label(font, k, k[0], VALIGN_BOTTOM))
else:
var spacer = Control.new()
@@ -129,7 +129,7 @@ func create_labels() -> void:
foreground.add_child(spacer)
-func init_label(font: DynamicFont, alg: String, text: String, valign := 0, align := 0, add:=true) -> Label:
+func init_label(font: DynamicFont, alg: String, text: String, valign := 0, align := 0, add := true) -> Label:
var label := Label.new()
label.align = align
label.valign = valign
diff --git a/ui/board/Game.gd b/ui/board/Game.gd
index 556c184..7f28653 100644
--- a/ui/board/Game.gd
+++ b/ui/board/Game.gd
@@ -39,4 +39,4 @@ func set_panel(pnl: UserPanel, name: String, country: String) -> void:
func _unhandled_input(event: InputEvent):
if event is InputEventKey and event.pressed and event.scancode == KEY_Z:
- chat.visible = !chat.visible \ No newline at end of file
+ chat.visible = !chat.visible
diff --git a/ui/menus/StartMenu.tscn b/ui/menus/StartMenu.tscn
deleted file mode 100644
index b6f3f38..0000000
--- a/ui/menus/StartMenu.tscn
+++ /dev/null
@@ -1,77 +0,0 @@
-[gd_scene load_steps=9 format=2]
-
-[ext_resource path="res://ui/menus/account/Account.tscn" type="PackedScene" id=1]
-[ext_resource path="res://ui/menus/settings/Settings.tscn" type="PackedScene" id=2]
-[ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=3]
-[ext_resource path="res://ui/theme/main.theme" type="Theme" id=4]
-[ext_resource path="res://ui/menus/lobby/Lobby.tscn" type="PackedScene" id=5]
-[ext_resource path="res://ui/menus/StartMenu.gd" type="Script" id=7]
-[ext_resource path="res://ui/menus/tests/test_runner.tscn" type="PackedScene" id=8]
-
-[sub_resource type="DynamicFont" id=1]
-size = 400
-use_mipmaps = true
-use_filter = true
-font_data = ExtResource( 3 )
-
-[node name="StartMenu" type="CenterContainer"]
-anchor_right = 1.0
-anchor_bottom = 1.0
-mouse_filter = 2
-theme = ExtResource( 4 )
-script = ExtResource( 7 )
-
-[node name="tabs" type="TabContainer" parent="."]
-margin_left = 147.0
-margin_top = 57.0
-margin_right = 1275.0
-margin_bottom = 743.0
-rect_min_size = Vector2( 2, 2 )
-mouse_filter = 1
-size_flags_horizontal = 0
-size_flags_vertical = 0
-drag_to_rearrange_enabled = true
-use_hidden_tabs_for_min_size = true
-
-[node name="" parent="tabs" instance=ExtResource( 5 )]
-margin_left = 30.0
-margin_top = 86.0
-margin_right = -30.0
-margin_bottom = -30.0
-
-[node name="漣" parent="tabs" instance=ExtResource( 2 )]
-visible = false
-margin_left = 30.0
-margin_top = 60.0
-margin_right = -30.0
-margin_bottom = -30.0
-
-[node name="אּ" parent="tabs" instance=ExtResource( 1 )]
-visible = false
-margin_left = 30.0
-margin_top = 60.0
-margin_right = -30.0
-margin_bottom = -30.0
-
-[node name="ﭧ" parent="tabs" instance=ExtResource( 8 )]
-visible = false
-margin_left = 30.0
-margin_top = 60.0
-margin_right = -30.0
-margin_bottom = -30.0
-
-[node name="" type="Button" parent="tabs"]
-visible = false
-anchor_right = 1.0
-anchor_bottom = 1.0
-margin_left = 30.0
-margin_top = 60.0
-margin_right = -30.0
-margin_bottom = -30.0
-focus_mode = 0
-size_flags_horizontal = 4
-size_flags_vertical = 4
-custom_fonts/font = SubResource( 1 )
-text = "exit"
-
-[connection signal="pressed" from="tabs/" to="." method="_on_quit_pressed"]
diff --git a/ui/menus/lobby/Lobby.gd b/ui/menus/lobby/Lobby.gd
index 4979f49..6c04c27 100644
--- a/ui/menus/lobby/Lobby.gd
+++ b/ui/menus/lobby/Lobby.gd
@@ -1,11 +1,11 @@
extends Control
class_name Lobby
-onready var address: LineEdit = find_node("Address")
+onready var address: LineEdit = $"%Address"
onready var buttons := find_node("buttons")
-onready var status_ok := find_node("StatusOK")
-onready var status_fail := find_node("StatusFail")
-onready var hostbutton = find_node("HostButton")
+onready var status_ok := $"%StatusOK"
+onready var status_fail := $"%StatusFail"
+onready var hostbutton = $"%HostButton"
func toggle(onoff: bool) -> void:
@@ -14,7 +14,7 @@ func toggle(onoff: bool) -> void:
func _ready() -> void:
PacketHandler.lobby = self
- PacketHandler.connect("hosting", find_node("stophost"), "set_visible")
+ PacketHandler.connect("hosting", $"%stophost", "set_visible")
PacketHandler.connect("connection_established", self, "reset")
if !Utils.internet:
set_status("no internet", false)
diff --git a/ui/menus/lobby/Lobby.tscn b/ui/menus/lobby/Lobby.tscn
index a9beb3d..7fe87f6 100644
--- a/ui/menus/lobby/Lobby.tscn
+++ b/ui/menus/lobby/Lobby.tscn
@@ -30,6 +30,7 @@ margin_right = 727.0
margin_bottom = 450.0
[node name="stophost" type="Button" parent="Center/VBox"]
+unique_name_in_owner = true
visible = false
margin_right = 296.0
margin_bottom = 102.0
@@ -38,6 +39,7 @@ size_flags_horizontal = 4
text = "stop hosting"
[node name="Address" type="LineEdit" parent="Center/VBox"]
+unique_name_in_owner = true
margin_right = 600.0
margin_bottom = 102.0
rect_min_size = Vector2( 600, 0 )
@@ -76,6 +78,7 @@ disabled = true
text = "join"
[node name="HostButton" type="Button" parent="Center/VBox/buttons"]
+unique_name_in_owner = true
margin_left = 421.0
margin_right = 600.0
margin_bottom = 102.0
@@ -86,6 +89,7 @@ disabled = true
text = "create"
[node name="StatusOK" type="Label" parent="Center/VBox"]
+unique_name_in_owner = true
visible = false
margin_top = 242.0
margin_right = 350.0
@@ -94,6 +98,7 @@ custom_colors/font_color = Color( 1, 1, 1, 1 )
autowrap = true
[node name="StatusFail" type="Label" parent="Center/VBox"]
+unique_name_in_owner = true
visible = false
margin_top = 242.0
margin_right = 350.0
diff --git a/ui/menus/StartMenu.gd b/ui/menus/startmenu/StartMenu.gd
index 63bbd63..c64c9c2 100644
--- a/ui/menus/StartMenu.gd
+++ b/ui/menus/startmenu/StartMenu.gd
@@ -3,7 +3,7 @@ extends Control
func _ready() -> void:
if OS.has_feature("web"):
- find_node("").queue_free()
+ get_node("%").queue_free()
func _on_quit_pressed() -> void:
diff --git a/ui/menus/startmenu/StartMenu.tscn b/ui/menus/startmenu/StartMenu.tscn
new file mode 100644
index 0000000..1fadbc7
--- /dev/null
+++ b/ui/menus/startmenu/StartMenu.tscn
@@ -0,0 +1,97 @@
+[gd_scene load_steps=11 format=2]
+
+[ext_resource path="res://assets/ui/ubuntu/ubuntu-bold.ttf" type="DynamicFontData" id=1]
+[ext_resource path="res://ui/theme/main.theme" type="Theme" id=2]
+[ext_resource path="res://ui/menus/startmenu/StartMenu.gd" type="Script" id=3]
+[ext_resource path="res://ui/ubuntu-bold-small.tres" type="DynamicFont" id=4]
+[ext_resource path="res://ui/menus/lobby/Lobby.tscn" type="PackedScene" id=5]
+[ext_resource path="res://ui/menus/tests/test_runner.tscn" type="PackedScene" id=6]
+[ext_resource path="res://ui/menus/settings/Settings.tscn" type="PackedScene" id=7]
+[ext_resource path="res://ui/menus/account/Account.tscn" type="PackedScene" id=8]
+[ext_resource path="res://ui/menus/startmenu/VersionLabel.gd" type="Script" id=9]
+
+[sub_resource type="DynamicFont" id=1]
+size = 400
+use_mipmaps = true
+use_filter = true
+font_data = ExtResource( 1 )
+
+[node name="StartMenu" type="Control"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+script = ExtResource( 3 )
+
+[node name="CenterContainer" type="CenterContainer" parent="."]
+anchor_right = 1.0
+anchor_bottom = 1.0
+mouse_filter = 2
+theme = ExtResource( 2 )
+
+[node name="tabs" type="TabContainer" parent="CenterContainer"]
+margin_left = 147.0
+margin_top = 57.0
+margin_right = 1275.0
+margin_bottom = 743.0
+rect_min_size = Vector2( 2, 2 )
+mouse_filter = 1
+size_flags_horizontal = 0
+size_flags_vertical = 0
+drag_to_rearrange_enabled = true
+use_hidden_tabs_for_min_size = true
+
+[node name="" parent="CenterContainer/tabs" instance=ExtResource( 5 )]
+margin_left = 30.0
+margin_top = 86.0
+margin_right = -30.0
+margin_bottom = -30.0
+
+[node name="漣" parent="CenterContainer/tabs" instance=ExtResource( 7 )]
+visible = false
+margin_left = 30.0
+margin_top = 60.0
+margin_right = -30.0
+margin_bottom = -30.0
+
+[node name="אּ" parent="CenterContainer/tabs" instance=ExtResource( 8 )]
+visible = false
+margin_left = 30.0
+margin_top = 60.0
+margin_right = -30.0
+margin_bottom = -30.0
+
+[node name="ﭧ" parent="CenterContainer/tabs" instance=ExtResource( 6 )]
+visible = false
+margin_left = 30.0
+margin_top = 60.0
+margin_right = -30.0
+margin_bottom = -30.0
+
+[node name="" type="Button" parent="CenterContainer/tabs"]
+unique_name_in_owner = true
+visible = false
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_left = 30.0
+margin_top = 60.0
+margin_right = -30.0
+margin_bottom = -30.0
+focus_mode = 0
+size_flags_horizontal = 4
+size_flags_vertical = 4
+custom_fonts/font = SubResource( 1 )
+text = "exit"
+
+[node name="VersionLabel" type="Label" parent="."]
+anchor_top = 1.0
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_top = -34.0
+margin_right = -11.0
+margin_bottom = -11.0
+custom_fonts/font = ExtResource( 4 )
+text = "ver "
+align = 2
+valign = 1
+script = ExtResource( 9 )
+
+[connection signal="pressed" from="CenterContainer/tabs/" to="." method="_on_quit_pressed"]
diff --git a/ui/menus/startmenu/VersionLabel.gd b/ui/menus/startmenu/VersionLabel.gd
new file mode 100644
index 0000000..dc035e7
--- /dev/null
+++ b/ui/menus/startmenu/VersionLabel.gd
@@ -0,0 +1,6 @@
+extends Label
+class_name VersionLabel
+
+
+func _ready():
+ text = "chess " + Utils.get_version()