online multiplayer chess game (note server currently down)
gud systematika
36 files changed, 225 insertions, 189 deletions
@@ -6,13 +6,13 @@ const Square := preload("res://Square.tscn") const piece_size := Vector2(80, 80) const default_metadata := { - "wccl": false, # white can castle left - "wccr": false, # white can castle right - "bccl": false, # black can castle left - "bccr": false, # black can castle right - "turn": true, # true = white, false = black - "wcep": [], # white can enpassant - "bcep": [], # black can enpassant + wccl = false, # white can castle left + wccr = false, # white can castle right + bccl = false, # black can castle left + bccr = false, # black can castle right + turn = true, # true = white, false = black + wcep = [], # white can enpassant + bcep = [], # black can enpassant } export(Color) var overlay_color := Color(0.078431, 0.333333, 0.117647, 0.498039) @@ -22,12 +22,12 @@ export(Color) var clocklow := Color(0.313726, 0.156863, 0.14902) var matrix := [] var stop_input := true -var background_matrix := [] +var background_array := [] var history_matrixes := {} var last_clicked: Piece = null var flipped := false -var labels := {"letters": [], "numbers": []} +var labels := {letters = [], numbers = []} onready var background := $Background onready var ASSETS_PATH: String = "res://assets/pieces/%s/" % Globals.piece_set @@ -56,6 +56,7 @@ func _ready() -> void: Debug.monitor(self, "highest value in 3fold", "threefoldrepetition()") stop_input = false + func _exit_tree() -> void: Globals.grid = null # reset the globals grid when leaving tree @@ -232,16 +233,20 @@ func make_piece(position: Vector2, script: String, white: bool = true) -> void: func init_board() -> void: # create the board - for i in range(8): # for each row - background_matrix.append([]) # add a row - for j in range(8): # for each column + for x in range(8): + for y in range(8): # for each column var square := Square.instance() # create a square - square.rect_size = piece_size # set the size - square.rect_global_position = Vector2(i, j) * piece_size # set the position - square.color = Globals.board_color1 if (i + j) % 2 == 0 else Globals.board_color2 # set the color + square.name = Utils.to_algebraic(Vector2(y, x)) + square.hint_tooltip = square.name + square.rect_min_size = piece_size # set the size + square.color = Globals.board_color1 if (x + y) % 2 == 0 else Globals.board_color2 # set the color background.add_child(square) # add the square to the background - square.connect("clicked", self, "square_clicked", [Vector2(i, j)]) # connect the clicked event - background_matrix[i].append(square) # add the square to the background matrix + square.connect("clicked", self, "square_clicked", [Vector2(y, x)]) # connect the clicked event + background_array.append(square) # add the square to the background array + + +func get_background_element(pos: Vector2) -> ColorRect: + return background_array[8 * pos.y + pos.x] func add_pieces() -> void: # add the pieces @@ -293,7 +298,7 @@ func add_kings() -> void: func check_for_circle(position: Vector2) -> bool: # check for a circle, validating movement - return background_matrix[position.x][position.y].circle_on + return get_background_element(position).circle_on func check_for_frame(position: Vector2) -> bool: # check for a frame, validating taking @@ -318,8 +323,9 @@ func square_clicked(position: Vector2) -> void: # square clicked elif check_for_circle(position): # see if theres a circle at the position handle_move(position) # move stop_input = true - last_clicked.clear_clicked() # remove the circles - last_clicked = null # set it to null + if last_clicked: + last_clicked.clear_clicked() # remove the circles + last_clicked = null # set it to null elif last_clicked != spot: # we got a new piece (or pawn) clicked if is_instance_valid(last_clicked): # remove the circles last_clicked.clear_clicked() @@ -370,7 +376,7 @@ func check_promote(pawn, position, calltype: String = "move") -> bool: func clear_fx() -> void: # clear the circles for i in range(8): # for each row for j in range(8): # for each column - var square: ColorRect = background_matrix[i][j] # get the square + var square: ColorRect = get_background_element(Vector2(i, j)) # get the square square.set_circle(false) # set the circle to false var piece: Piece = matrix[i][j] # get the piece if piece: # if there is a piece @@ -11,10 +11,13 @@ __meta__ = { "_edit_group_": true } -[node name="Background" type="Control" parent="."] +[node name="Background" type="GridContainer" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 +custom_constants/vseparation = 0 +custom_constants/hseparation = 0 +columns = 8 [node name="Pieces" type="Control" parent="."] anchor_right = 1.0 @@ -61,7 +61,7 @@ func _draw() -> void: func get_string(set: Array) -> String: var node: Node = set[0] if !is_instance_valid(node): - refs.remove(refs.find(set)) + refs.erase(set) return "invalid!" var what: String = set[1] var gotten = node.get(what) @@ -7,3 +7,4 @@ signal outoftime # called when the time is up signal game_over # called when the game is over signal go_back # called when the game is over, and were ready to go back signal data_recieved # called every time the data comes in +signal set_signed_in(signed_in) @@ -11,10 +11,6 @@ onready var panels = [ func _ready(): if Globals.network: Globals.network.connect("info_recieved", self, "_on_info") - var pnl = panels[int(Globals.team)] - var name = SaveLoad.get_data("id").name - pnl.set_name(name if name else "Anonymous") - pnl.set_flag(SaveLoad.get_data("id").country) func set_status(text: String, length := 5) -> void: @@ -29,3 +25,9 @@ func _on_info(info: Dictionary): var pnl = panels[int(!Globals.team)] pnl.set_name(info.name if info.name else "Anonymous") pnl.set_flag(info.country) + + # set my own panel + pnl = panels[int(Globals.team)] + var name = SaveLoad.get_data("id").name + pnl.set_name(name if name else "Anonymous") + pnl.set_flag(SaveLoad.get_data("id").country) @@ -241,10 +241,3 @@ size_flags_horizontal = 3 size_flags_vertical = 3 [node name="SidebarRight" parent="Holder" instance=ExtResource( 4 )] - -[node name="Darken" type="ColorRect" parent="."] -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_right = -400.0 -color = Color( 0, 0, 0, 0.784314 ) @@ -110,6 +110,18 @@ rect_pivot_offset = Vector2( 50, 50 ) mouse_filter = 2 script = ExtResource( 1 ) +[node name="Popup" type="Popup" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +mouse_filter = 2 +popup_exclusive = true + +[node name="Previews" type="VBoxContainer" parent="Popup"] +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +custom_constants/separation = 0 + [node name="ColorRect" type="ColorRect" parent="."] visible = false anchor_right = 1.0 diff --git a/Square.tscn b/Square.tscn index de3771e..cb05f72 100644 --- a/Square.tscn +++ b/Square.tscn @@ -31,6 +31,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 margin_right = -1180.0 margin_bottom = -780.0 +mouse_filter = 1 script = ExtResource( 1 ) [node name="CircleHolder" type="CenterContainer" parent="."] @@ -156,7 +156,7 @@ func internet_available() -> bool: return returnable -func walk_dir(path := "res://assets/pieces", only_dir := true, of_ext := "png", exclude := []) -> PoolStringArray: # walk the directory, finding the asset packs +func walk_dir(path := "res://assets/pieces", only_dir := true, exclude := []) -> PoolStringArray: # walk the directory, finding the asset packs var files := [] # init the files var dir := Directory.new() # init the directory if dir.open(path) == OK: # open the directory @@ -168,7 +168,7 @@ func walk_dir(path := "res://assets/pieces", only_dir := true, of_ext := "png", files.append(file_name) # add the folder else: var split = file_name.split(".") - if split[-1] == of_ext and !split[0] in exclude: + if split[-1] == "import" and !split[0] in exclude: files.append(split[0]) # add the file file_name = dir.get_next() # get the next file else: diff --git a/export_presets.cfg b/export_presets.cfg index 0bf9ae3..5316d5b 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -116,7 +116,7 @@ custom_features="" export_filter="all_resources" include_filter="COPYING.md, LICENSE" exclude_filter="" -export_path="exports/chess.x86_64" +export_path="exports/linux/chess.x86_64" script_export_mode=1 script_encryption_key="" diff --git a/networking/Network.gd b/networking/Network.gd index 7db31cf..7b19c8f 100644 --- a/networking/Network.gd +++ b/networking/Network.gd @@ -18,16 +18,10 @@ const HEADERS := { "info": "I" } -const MOVEHEADERS := { # subheaders for HEADERS.move - "move": "M", - "take": "K", - "castle": "C", - "passant": "P", - "promote": "Q", -} +const MOVEHEADERS := {move = "M", take = "K", castle = "C", passant = "P", promote = "Q"} # subheaders for HEADERS.move -const RELAYHEADERS := {"chat": "C"} -const SIGNALHEADERS := {"takeback": "T", "draw": "D", "resign": "R", "info": "I"} # subheaders for HEADERS.signal +const RELAYHEADERS := {chat = "C"} +const SIGNALHEADERS := {takeback = "T", draw = "D", resign = "R", info = "I"} # subheaders for HEADERS.signal var notation := "" diff --git a/pieces/Pawn.gd b/pieces/Pawn.gd index e09d8e1..bc94c1c 100644 --- a/pieces/Pawn.gd +++ b/pieces/Pawn.gd @@ -13,31 +13,32 @@ var promotetake := false onready var whiteint := 1 if white else -1 onready var sprites := [] onready var darken: ColorRect = $"../../Darken" +onready var previews = $Popup/Previews +onready var popup: Popup = $Popup func _ready() -> void: Globals.pawns.append(self) Events.connect("turn_over", self, "_on_turn_over") Events.connect("just_before_turn_over", self, "_just_before_turn_over") - for i in range(0, 4): # add 3 sprites - var newsprite: Node2D = load("res://ui/ClickableSprite.tscn").instance() - newsprite.scale = Globals.grid.piece_size / Vector2(100, 100) - newsprite.position = (Globals.grid.piece_size / 2 + Vector2(0, (i * Globals.grid.piece_size.y) * whiteint)) - newsprite.get_node("Sprite").texture = load( - "%s%s%s.png" % [Globals.grid.ASSETS_PATH, team.to_lower(), promotables[i]] - ) + for i in range(4): # add 4 sprites + var newsprite: TextureButton = load("res://ui/PromotionPreview.tscn").instance() + newsprite.texture_normal = load("%s%s%s.png" % [Globals.grid.ASSETS_PATH, team.to_lower(), promotables[i]]) newsprite.name = promotables[i] - newsprite.connect("clicked", self, "handle_sprite_input_event", [newsprite.name]) - newsprite.z_index = 5 # its not a texturebutton so i can use this - newsprite.hide() - add_child(newsprite) + newsprite.connect("pressed", self, "_pressed", [newsprite.name]) + previews.add_child(newsprite) sprites.append(newsprite) +func open_previews() -> void: + var rect := popup.get_global_rect() + rect.position = rect_global_position + popup.popup(rect) + # popup.visible = true + + func _exit_tree() -> void: - var find: int = Globals.pawns.find(self) - if find != -1: - Globals.pawns.remove(find) + Globals.pawns.erase(self) func moveto(position: Vector2, instant := false) -> void: @@ -131,8 +132,8 @@ func promote(position: Vector2, type: String) -> void: move(position) # only move the visuals promoteposition = position darken.show() - for i in range(len(promotables)): - sprites[i].show() + yield(tween, "tween_completed") + open_previews() func promote_to(promote_to: String, is_capture: bool, position: Vector2, instant := false): @@ -143,7 +144,8 @@ func promote_to(promote_to: String, is_capture: bool, position: Vector2, instant took() -func handle_sprite_input_event(promote_to: String) -> void: +func _pressed(promote_to: String) -> void: + previews.hide() darken.hide() var is_cap = at_pos(promoteposition) != null var mov = Move.new(SanParser.PAWN, [real_position, promoteposition], is_cap) diff --git a/pieces/Piece.gd b/pieces/Piece.gd index 1fe8903..6764e62 100644 --- a/pieces/Piece.gd +++ b/pieces/Piece.gd @@ -30,8 +30,8 @@ func _ready() -> void: load_texture() -func set_zindex(zindex: int): - VisualServer.canvas_item_set_z_index(get_canvas_item(), zindex) +func set_zindex(zindex: int, obj: CanvasItem = self): + VisualServer.canvas_item_set_z_index(obj.get_canvas_item(), zindex) func load_texture(path := "%s%s%s.png" % [Globals.grid.ASSETS_PATH, team, shortname.to_upper()]) -> void: @@ -160,7 +160,7 @@ func can_touch(pos: Vector2, attack := true, move := true) -> bool: static func create_move_circles(pos: Vector2) -> void: - Globals.grid.background_matrix[pos.x][pos.y].set_circle(true) # make the move circle + Globals.grid.get_background_element(pos).set_circle(true) # make the move circle static func create_take_circles(spot: Piece) -> void: # create take circles diff --git a/project.godot b/project.godot index 2f7ad99..fa975ae 100644 --- a/project.godot +++ b/project.godot @@ -127,7 +127,7 @@ _global_script_classes=[ { "base": "GridContainer", "class": "Preview", "language": "GDScript", -"path": "res://ui/Preview.gd" +"path": "res://ui/menus/settings/Preview.gd" }, { "base": "Piece", "class": "Queen", @@ -241,7 +241,7 @@ gdscript/warnings/return_value_discarded=false window/size/width=1422 window/size/height=800 window/stretch/mode="2d" -window/stretch/aspect="expand" +window/stretch/aspect="keep" [editor] diff --git a/saveload.gd b/saveload.gd index 293a555..73e1052 100644 --- a/saveload.gd +++ b/saveload.gd @@ -5,25 +5,25 @@ const settings_file := "user://chess.settings" const id := "user://.chess.id" const default_settings_data = { - "vsync": OS.vsync_enabled, - "fullscreen": OS.window_fullscreen, - "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), - "rainbow": true + vsync = OS.vsync_enabled, + fullscreen = OS.window_fullscreen, + 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), + rainbow = true } -const default_id_data = {"id": "", "name": "", "country": "rainbow", "password": ""} +const default_id_data = {id = "", name = "", country = "rainbow", password = ""} var files := { - "settings": {"file": settings_file, "data": default_settings_data.duplicate(true)}, - "id": {"file": id, "data": default_id_data.duplicate()} + settings = {file = settings_file, data = default_settings_data.duplicate(true)}, + id = {file = id, data = default_id_data.duplicate()} } # file types func get_public_info(): - return {"name": files.id.data.name, "country": files.id.data.country, "id": files.id.data.id} + return {name = files.id.data.name, country = files.id.data.country, id = files.id.data.id} func get_data(type: String) -> Dictionary: diff --git a/ui/ClickableSprite.gd b/ui/ClickableSprite.gd deleted file mode 100644 index 5dcf854..0000000 --- a/ui/ClickableSprite.gd +++ /dev/null @@ -1,23 +0,0 @@ -extends Node2D - -signal clicked - -onready var sprite := $Sprite - - -func _ready() -> void: - if get_parent() != get_viewport(): - $Area2D/CollisionShape2D.shape.extents = Globals.grid.piece_size / 2 - - -func _on_Area2D_input_event(_viewport: Node, _event: InputEvent, _shape_idx: int) -> void: - if visible and Input.is_action_just_released("click"): - emit_signal("clicked") - - -func _on_Area2D_mouse_entered() -> void: - sprite.scale = Vector2(1.3, 1.3) - - -func _on_Area2D_mouse_exited() -> void: - sprite.scale = Vector2(.9, .9) diff --git a/ui/ClickableSprite.tscn b/ui/ClickableSprite.tscn deleted file mode 100644 index be3e310..0000000 --- a/ui/ClickableSprite.tscn +++ /dev/null @@ -1,25 +0,0 @@ -[gd_scene load_steps=3 format=2] - -[ext_resource path="res://ui/ClickableSprite.gd" type="Script" id=1] - -[sub_resource type="RectangleShape2D" id=1] - -[node name="ClickableSprite" type="Node2D"] -script = ExtResource( 1 ) - -[node name="Sprite" type="Sprite" parent="."] -__meta__ = { -"_edit_vertical_guides_": [ ] -} - -[node name="Area2D" type="Area2D" parent="."] -collision_mask = 0 -monitoring = false -monitorable = false - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -shape = SubResource( 1 ) - -[connection signal="input_event" from="Area2D" to="." method="_on_Area2D_input_event"] -[connection signal="mouse_entered" from="Area2D" to="." method="_on_Area2D_mouse_entered"] -[connection signal="mouse_exited" from="Area2D" to="." method="_on_Area2D_mouse_exited"] diff --git a/ui/PromotionPreview.gd b/ui/PromotionPreview.gd new file mode 100644 index 0000000..c184746 --- /dev/null +++ b/ui/PromotionPreview.gd @@ -0,0 +1,14 @@ +extends TextureButton + +var focused = false setget set_focused + + +func set_focused(is_focused: bool): + focused = is_focused + rect_scale = Vector2(1.1, 1.1) if focused else Vector2(.9, .9) + + +func _ready(): + rect_pivot_offset = Globals.grid.piece_size / 2 + rect_min_size = Globals.grid.piece_size + set_focused(false) diff --git a/ui/PromotionPreview.tscn b/ui/PromotionPreview.tscn new file mode 100644 index 0000000..71928f6 --- /dev/null +++ b/ui/PromotionPreview.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://ui/PromotionPreview.gd" type="Script" id=1] + +[node name="PromotionPreview" type="TextureButton"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -711.0 +margin_top = -400.0 +margin_right = 711.0 +margin_bottom = 400.0 +mouse_filter = 1 +expand = true +stretch_mode = 5 +script = ExtResource( 1 ) + +[connection signal="mouse_entered" from="." to="." method="set_focused" binds= [ true ]] +[connection signal="mouse_exited" from="." to="." method="set_focused" binds= [ false ]] diff --git a/ui/animations/softbounce.tres b/ui/animations/softbounce.tres index e2fc9db..7a8144a 100644 --- a/ui/animations/softbounce.tres +++ b/ui/animations/softbounce.tres @@ -203,7 +203,6 @@ void light() { } " -graph_offset = Vector2( 0, 524.364 ) mode = 1 flags/light_only = false nodes/fragment/0/position = Vector2( 800, 64 ) diff --git a/ui/barbutton/BarTextureButton.gd b/ui/barbutton/BarTextureButton.gd index cf36bd3..4bb51e2 100644 --- a/ui/barbutton/BarTextureButton.gd +++ b/ui/barbutton/BarTextureButton.gd @@ -20,9 +20,10 @@ func set_disabled(new: bool) -> void: self_modulate = Color(.1, .1, .1, 0.5) if disabled else Color.white -func _input(_event:InputEvent): +func _input(_event: InputEvent): _update() + func _update(): if disabled: background.color = disabled_color diff --git a/ui/confirm/confirm.gd b/ui/confirm/confirm.gd index 1156159..70b2251 100644 --- a/ui/confirm/confirm.gd +++ b/ui/confirm/confirm.gd @@ -6,6 +6,12 @@ signal confirmed(what) var timer := Timer.new() +func _process(_delta): + if visible: + rect_position.x = clamp(rect_position.x, 0, OS.get_window_size().x - rect_size.x) + rect_position.y = clamp(rect_position.y, 50, OS.get_window_size().y - rect_size.y) + + func _ready() -> void: add_child(timer) timer.connect("timeout", self, "_pressed", [false]) diff --git a/ui/flipbutton.gd b/ui/flipbutton.gd deleted file mode 100644 index 720be19..0000000 --- a/ui/flipbutton.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends BarTextureButton - - -func _pressed() -> void: - Globals.grid.flip_board() diff --git a/ui/gridmenu/GridMenu.gd b/ui/gridmenu/GridMenu.gd index 0dda398..6d14477 100644 --- a/ui/gridmenu/GridMenu.gd +++ b/ui/gridmenu/GridMenu.gd @@ -4,22 +4,24 @@ class_name GridMenu const texture_button = preload("res://ui/barbutton/BarTextureButton.tscn") signal pressed(index) + func open(): columns = round(sqrt(get_child_count())) show() -func add_item(icon : Texture, tooltip : String, size:Vector2)->void: + +func add_item(icon: Texture, tooltip: String, size: Vector2) -> void: var pnl := PanelContainer.new() var tex := texture_button.instance() tex.connect("pressed", self, "_pressed", [get_child_count()]) tex.expand = true tex.texture_normal = icon - tex.name = str(get_child_count()+1) + tex.name = str(get_child_count() + 1) tex.rect_min_size = size tex.hint_tooltip = tooltip tex.stretch_mode = tex.STRETCH_KEEP_ASPECT_CENTERED tex.set_anchors_preset(PRESET_WIDE) - var back :ColorRect = tex.get_node("Background") + var back: ColorRect = tex.get_node("Background") back.margin_left = -5 back.margin_right = 5 back.margin_top = -5 @@ -27,6 +29,7 @@ func add_item(icon : Texture, tooltip : String, size:Vector2)->void: pnl.add_child(tex) add_child(pnl) -func _pressed(index:int): + +func _pressed(index: int): get_children()[index].get_children()[0]._focused(false) emit_signal("pressed", index) diff --git a/ui/gridmenu/GridMenuButton.gd b/ui/gridmenu/GridMenuButton.gd index 6df463f..b2d93e1 100644 --- a/ui/gridmenu/GridMenuButton.gd +++ b/ui/gridmenu/GridMenuButton.gd @@ -1,30 +1,34 @@ extends Button class_name GridMenuButton -onready var popup :Popup = $Popup -onready var gridmenu :GridMenu= $Popup/GridMenu +onready var popup: Popup = $Popup +onready var gridmenu: GridMenu = $Popup/GridMenu signal selected(index) var selected := 0 setget set_selected var items := [] -func add_item(icon, tooltip := "", size:=Vector2(40, 30)): + +func add_item(icon, tooltip := "", size := Vector2(40, 30)): items.append(icon) gridmenu.add_item(icon, tooltip, size) -func _on_GridMenu_pressed(index:int): + +func _on_GridMenu_pressed(index: int): set_selected(index) emit_signal("selected", index) popup.hide() -func set_selected(index:int): + +func set_selected(index: int): selected = index icon = items[index] + func _pressed() -> void: - popup.rect_size=Vector2.ZERO + popup.rect_size = Vector2.ZERO var rect := popup.get_global_rect() rect.position = rect_global_position - Vector2(50, 50) popup.popup(rect) - gridmenu.open()
\ No newline at end of file + gridmenu.open() diff --git a/ui/gridmenu/GridMenuButton.tscn b/ui/gridmenu/GridMenuButton.tscn index 5cb1cd4..7695610 100644 --- a/ui/gridmenu/GridMenuButton.tscn +++ b/ui/gridmenu/GridMenuButton.tscn @@ -224,6 +224,8 @@ script = ExtResource( 3 ) margin_right = 50.0 margin_bottom = 40.0 rect_min_size = Vector2( 30, 20 ) +size_flags_horizontal = 4 +size_flags_vertical = 4 [node name="GridMenu" type="GridContainer" parent="Popup"] margin_left = 10.0 diff --git a/ui/menus/Disclaimer.gd b/ui/menus/Disclaimer.gd new file mode 100644 index 0000000..385d4e0 --- /dev/null +++ b/ui/menus/Disclaimer.gd @@ -0,0 +1,9 @@ +extends Label + + +func _ready(): + Events.connect("set_signed_in", self, "update_vis") + + +func update_vis(newvis): + visible = !newvis diff --git a/ui/menus/Lobby.tscn b/ui/menus/Lobby.tscn index ac07cfa..5e81983 100644 --- a/ui/menus/Lobby.tscn +++ b/ui/menus/Lobby.tscn @@ -1,7 +1,9 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://ui/theme/main.tres" type="Theme" id=1] [ext_resource path="res://ui/menus/Lobby.gd" type="Script" id=2] +[ext_resource path="res://ui/menus/Disclaimer.gd" type="Script" id=3] +[ext_resource path="res://ui/verdana-bold-small.tres" type="DynamicFont" id=4] [node name="Lobby" type="CenterContainer"] anchor_right = 1.0 @@ -50,23 +52,23 @@ margin_right = 350.0 margin_bottom = 227.0 [node name="JoinButton" type="Button" parent="Center/HBox/VBox/buttons"] -margin_right = 150.0 +margin_right = 167.0 margin_bottom = 106.0 rect_min_size = Vector2( 150, 0 ) hint_tooltip = "join the game" focus_mode = 0 -size_flags_horizontal = 4 +size_flags_horizontal = 7 disabled = true enabled_focus_mode = 0 text = "join" [node name="HostButton" type="Button" parent="Center/HBox/VBox/buttons"] -margin_left = 165.0 +margin_left = 182.0 margin_right = 350.0 margin_bottom = 106.0 hint_tooltip = "host the game" focus_mode = 0 -size_flags_horizontal = 3 +size_flags_horizontal = 7 disabled = true enabled_focus_mode = 0 text = "host" @@ -74,19 +76,40 @@ text = "host" [node name="StatusOK" type="Label" parent="Center/HBox/VBox"] visible = false margin_top = 242.0 -margin_right = 500.0 +margin_right = 350.0 margin_bottom = 292.0 custom_colors/font_color = Color( 1, 1, 1, 1 ) autowrap = true [node name="StatusFail" type="Label" parent="Center/HBox/VBox"] visible = false -margin_top = 307.0 -margin_right = 500.0 -margin_bottom = 357.0 +margin_top = 242.0 +margin_right = 350.0 +margin_bottom = 292.0 custom_colors/font_color = Color( 0.698039, 0.415686, 0.415686, 1 ) autowrap = true +[node name="Disclaimer" type="Label" parent="Center/HBox/VBox"] +visible = false +margin_top = 242.0 +margin_right = 350.0 +margin_bottom = 342.0 +rect_min_size = Vector2( 0, 100 ) +custom_colors/font_color = Color( 1, 1, 1, 1 ) +custom_fonts/font = ExtResource( 4 ) +text = " Currently logged out. + Upon disconnect, you + will be unable to rejoin. " +valign = 1 +script = ExtResource( 3 ) + +[node name="ColorRect" type="ColorRect" parent="Center/HBox/VBox/Disclaimer"] +show_behind_parent = true +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_right = -46.0 +color = Color( 0.588235, 0.560784, 0.309804, 1 ) + [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"] diff --git a/ui/menus/StartMenu.gd b/ui/menus/StartMenu.gd index 7c3a901..a3156d2 100644 --- a/ui/menus/StartMenu.gd +++ b/ui/menus/StartMenu.gd @@ -1,7 +1,5 @@ extends Control -onready var settings := find_node("Settings") - func _ready() -> void: if OS.has_feature("HTML5"): @@ -10,11 +8,3 @@ func _ready() -> void: func _on_quit_pressed() -> void: get_tree().notification(MainLoop.NOTIFICATION_WM_QUIT_REQUEST) - - -func _on_settings_pressed() -> void: - settings.toggle(true) - - -func _on_multiplayer_pressed() -> void: - get_tree().change_scene("res://ui/Lobby.tscn") diff --git a/ui/menus/StartMenu.tscn b/ui/menus/StartMenu.tscn index baa7dc3..99e0533 100644 --- a/ui/menus/StartMenu.tscn +++ b/ui/menus/StartMenu.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=10 format=2] [ext_resource path="res://ui/menus/account/Account.tscn" type="PackedScene" id=1] -[ext_resource path="res://ui/menus/Settings.tscn" type="PackedScene" id=2] +[ext_resource path="res://ui/menus/settings/Settings.tscn" type="PackedScene" id=2] [ext_resource path="res://assets/ui/verdana-bold.ttf" type="DynamicFontData" id=3] [ext_resource path="res://ui/theme/main.tres" type="Theme" id=4] [ext_resource path="res://ui/menus/Lobby.tscn" type="PackedScene" id=5] diff --git a/ui/menus/account/Account.gd b/ui/menus/account/Account.gd index a64f64a..da819cd 100644 --- a/ui/menus/account/Account.gd +++ b/ui/menus/account/Account.gd @@ -11,12 +11,17 @@ onready var tabs := { "signin": $choose/signin/usernamepass, } -var signed_in = false +var signed_in = false setget set_signed_in var autologin = true onready var tabcontainer = $choose +func set_signed_in(new): + signed_in = new + Events.emit_signal("set_signed_in", new) + + func _ready(): loading.show() tabcontainer.hide() @@ -24,7 +29,7 @@ func _ready(): Globals.network.connect("signinresult", self, "_on_signin_result") Globals.network.connect("signupresult", self, "_on_signup_result") Globals.network.connect("connection_established", self, "attempt_autologin") - flags.append_array(Utils.walk_dir("res://assets/flags", false, "png", ["rainbow"])) + flags.append_array(Utils.walk_dir("res://assets/flags", false, ["rainbow"])) for i in flags: # add the items flagchoice.add_item(load("res://assets/flags/%s.png" % i), i.replace("_", " ")) flagchoice.selected = 0 @@ -34,8 +39,7 @@ func attempt_autologin(): if data.name and data.password: Globals.network.signin(data) else: - tabcontainer.show() - loading.hide() + reset("", false) func _on_signin_pressed(): @@ -49,8 +53,6 @@ func _on_signin_result(result): if autologin: autologin = false yield(get_tree().create_timer(.5), "timeout") - loading.hide() - tabcontainer.show() $choose/signin/signinbutton.disabled = false if typeof(result) == TYPE_STRING: # ew, error, get it away from me return reset(result, status_set) @@ -78,6 +80,9 @@ func reset(reason: String, set_status := true): if set_status: status.set_text(reason) data = SaveLoad.default_id_data + tabcontainer.show() + loading.hide() + set_signed_in(false) save_data() tabcontainer.show() @@ -85,7 +90,7 @@ func reset(reason: String, set_status := true): func _after_result(): save_data() status.set_text("Signed in to " + SaveLoad.get_data("id").name) - signed_in = true # yay + self.signed_in = true # yay $H/LogOut.show() tabcontainer.hide() @@ -109,4 +114,5 @@ func _on_choose_tab_changed(tab: int): func log_out(): + $H/LogOut.hide() reset("You are now logged out!") diff --git a/ui/menus/account/Account.tscn b/ui/menus/account/Account.tscn index e2cc443..c2400ff 100644 --- a/ui/menus/account/Account.tscn +++ b/ui/menus/account/Account.tscn @@ -40,6 +40,7 @@ margin_right = 1245.0 margin_bottom = 634.0 size_flags_horizontal = 4 size_flags_vertical = 4 +use_hidden_tabs_for_min_size = true [node name="signup" type="VBoxContainer" parent="choose"] anchor_right = 1.0 diff --git a/ui/Preview.gd b/ui/menus/settings/Preview.gd index 8807498..8807498 100644 --- a/ui/Preview.gd +++ b/ui/menus/settings/Preview.gd diff --git a/ui/menus/Settings.gd b/ui/menus/settings/Settings.gd index 22e88bd..22e88bd 100644 --- a/ui/menus/Settings.gd +++ b/ui/menus/settings/Settings.gd diff --git a/ui/menus/Settings.tscn b/ui/menus/settings/Settings.tscn index d52d823..f3f01e3 100644 --- a/ui/menus/Settings.tscn +++ b/ui/menus/settings/Settings.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=6 format=2] [ext_resource path="res://ui/theme/main.tres" type="Theme" id=1] -[ext_resource path="res://ui/menus/Settings.gd" type="Script" id=2] +[ext_resource path="res://ui/menus/settings/Settings.gd" type="Script" id=2] [ext_resource path="res://assets/pieces/california/wP.png" type="Texture" id=3] -[ext_resource path="res://ui/Preview.gd" type="Script" id=4] +[ext_resource path="res://ui/menus/settings/Preview.gd" type="Script" id=4] [ext_resource path="res://ui/colorpicker/ColorPickerButton.tscn" type="PackedScene" id=5] [node name="Settings" type="CenterContainer"] diff --git a/ui/menus/sidebarright/SidebarRight.tscn b/ui/menus/sidebarright/SidebarRight.tscn index ebe1e82..78b3046 100644 --- a/ui/menus/sidebarright/SidebarRight.tscn +++ b/ui/menus/sidebarright/SidebarRight.tscn @@ -22,7 +22,7 @@ [ext_resource path="res://ui/menus/sidebarright/UserPanel.tscn" type="PackedScene" id=22] [sub_resource type="StyleBoxFlat" id=8] -content_margin_right = 10.0 +content_margin_right = 0.0 content_margin_top = 10.0 content_margin_bottom = 10.0 bg_color = Color( 0.188235, 0.180392, 0.172549, 1 ) @@ -115,20 +115,17 @@ anchor_right = 1.0 anchor_bottom = 1.0 custom_constants/separation = 0 alignment = 1 -__meta__ = { -"_edit_lock_": true -} [node name="BlackPanel" parent="V" instance=ExtResource( 22 )] anchor_right = 0.0 anchor_bottom = 0.0 margin_top = 184.0 -margin_right = 492.0 +margin_right = 482.0 margin_bottom = 244.0 [node name="buttonbarholder" type="Control" parent="V"] margin_top = 244.0 -margin_right = 492.0 +margin_right = 482.0 margin_bottom = 294.0 rect_min_size = Vector2( 50, 50 ) __meta__ = { @@ -147,28 +144,28 @@ custom_constants/separation = 0 alignment = 1 [node name="FlipBoard" parent="V/buttonbarholder/Panel/buttonbar" instance=ExtResource( 6 )] -margin_left = 171.0 -margin_right = 221.0 +margin_left = 166.0 +margin_right = 216.0 texture_normal = ExtResource( 17 ) script = ExtResource( 19 ) [node name="DrawButton" parent="V/buttonbarholder/Panel/buttonbar" instance=ExtResource( 6 )] -margin_left = 221.0 -margin_right = 271.0 +margin_left = 216.0 +margin_right = 266.0 texture_normal = ExtResource( 16 ) script = ExtResource( 1 ) status = NodePath("../../../../Status") [node name="ResignButton" parent="V/buttonbarholder/Panel/buttonbar" instance=ExtResource( 6 )] -margin_left = 271.0 -margin_right = 321.0 +margin_left = 266.0 +margin_right = 316.0 texture_normal = ExtResource( 20 ) script = ExtResource( 2 ) status = NodePath("../../../../Status") [node name="SanDisplay" type="PanelContainer" parent="V"] margin_top = 294.0 -margin_right = 492.0 +margin_right = 482.0 margin_bottom = 514.0 custom_styles/panel = SubResource( 8 ) @@ -183,12 +180,12 @@ theme = SubResource( 6 ) anchor_right = 0.0 anchor_bottom = 0.0 margin_top = 514.0 -margin_right = 492.0 +margin_right = 482.0 margin_bottom = 574.0 [node name="Status" type="Label" parent="V"] margin_top = 574.0 -margin_right = 492.0 +margin_right = 482.0 margin_bottom = 616.0 custom_fonts/font = SubResource( 1 ) align = 1 |