Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Mar 22, 2021
1 parent de54590 commit aee7669
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Board.gd → Chess/Board.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends TileMap
class_name Board
onready var PIECE = preload("res://Piece.tscn")
onready var PIECE = preload("res://Chess/Piece.tscn")
onready var game = get_parent()

const LET = {"a":1, "b":2, "c":3, "d":4, "e":5, "f":6, "g":7, "h":8}
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion FileParser.tscn → Chess/FileParser.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://FileParser.gd" type="Script" id=1]
[ext_resource path="res://Chess/FileParser.gd" type="Script" id=1]


[node name="FileParser" type="Node"]
script = ExtResource( 1 )
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions Piece.tscn → Chess/Piece.tscn
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://ChessSprite.png" type="Texture" id=1]
[ext_resource path="res://Piece.gd" type="Script" id=2]
[ext_resource path="res://Draggable.tscn" type="PackedScene" id=3]
[ext_resource path="res://Chess/Piece.gd" type="Script" id=1]
[ext_resource path="res://Chess/Sprites/ChessSprite.png" type="Texture" id=2]
[ext_resource path="res://UI/Draggable.tscn" type="PackedScene" id=3]

[node name="Piece" type="Sprite"]
scale = Vector2( 0.3, 0.3 )
z_index = 3
texture = ExtResource( 1 )
texture = ExtResource( 2 )
vframes = 2
hframes = 6
frame = 11
script = ExtResource( 2 )
script = ExtResource( 1 )

[node name="Draggable" parent="." instance=ExtResource( 3 )]
collision_mask = 524288
Expand Down
File renamed without changes
6 changes: 3 additions & 3 deletions BoardTile.png.import → Chess/Sprites/BoardTile.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

importer="texture"
type="StreamTexture"
path="res://.import/BoardTile.png-5335550af8d33ed13a9955d4b1e71850.stex"
path="res://.import/BoardTile.png-7abdce07f19b127eed23c4fdbc200a77.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://BoardTile.png"
dest_files=[ "res://.import/BoardTile.png-5335550af8d33ed13a9955d4b1e71850.stex" ]
source_file="res://Chess/Sprites/BoardTile.png"
dest_files=[ "res://.import/BoardTile.png-7abdce07f19b127eed23c4fdbc200a77.stex" ]

[params]

Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

importer="texture"
type="StreamTexture"
path="res://.import/ChessSprite.png-d12a7d76daa82fda428962c2f90c77d7.stex"
path="res://.import/ChessSprite.png-ddfc2a75239d7df7b3e8856c77815f96.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://ChessSprite.png"
dest_files=[ "res://.import/ChessSprite.png-d12a7d76daa82fda428962c2f90c77d7.stex" ]
source_file="res://Chess/Sprites/ChessSprite.png"
dest_files=[ "res://.import/ChessSprite.png-ddfc2a75239d7df7b3e8856c77815f96.stex" ]

[params]

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion MainGame.gd → Core/MainGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ remotesync func _load_turn(turn: int, loadGame: int = -1):
func _on_Board_piece_moved(turn) -> void:
self.currPlayer = 1 - self.currPlayer
var branching = currTurn < currGame.nTurns()-1
print(branching)

if branching:
var newBranch = branch(currGame, currTurn)
new_game(newBranch)
Expand Down
9 changes: 6 additions & 3 deletions MainGame.tscn → Core/MainGame.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[gd_scene load_steps=5 format=2]

[ext_resource path="res://BoardTile.png" type="Texture" id=2]
[ext_resource path="res://MainGame.gd" type="Script" id=3]
[ext_resource path="res://Board.gd" type="Script" id=4]
[ext_resource path="res://Chess/Sprites/BoardTile.png" type="Texture" id=2]
[ext_resource path="res://Core/MainGame.gd" type="Script" id=3]
[ext_resource path="res://Chess/Board.gd" type="Script" id=4]




[sub_resource type="TileSet" id=1]
0/name = "BoardTile.png 0"
Expand Down
2 changes: 1 addition & 1 deletion Root.gd → Core/Root.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extends Node
onready var UIMain = $VBoxContainer/HBoxContainer/UIPanel
onready var MainGame = $VBoxContainer/HBoxContainer/ViewportContainer/MainGame
onready var GamesList = $GamesDialog/ScrollContainer/VBoxContainer
onready var ConnectionStatus = $VBoxContainer/TopMenu/HBoxContainer/ConnectionStatus
onready var ConnectionStatus = $VBoxContainer/TopMenu/MenuBar/HBoxContainer/ConnectionStatus
func new_game(game: Game):
MainGame.new_game(game)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Draggable.tscn → UI/Draggable.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://Draggable.gd" type="Script" id=1]
[ext_resource path="res://UI/Draggable.gd" type="Script" id=1]

[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 64, 64 )
Expand Down
File renamed without changes.
19 changes: 14 additions & 5 deletions TopMenu.gd → UI/TopMenu.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
extends PanelContainer
extends Node

enum FILE_MENU {NEW, LOAD, SAVE, QUIT}
enum GAME_MENU {PREV, NEXT, EDIT, CLOSE}
enum NETWORK {HOST, CONNECT, DISCONNECT}
enum HELP_MENU {HELP, ABOUT}

const TAGS = ["Event", "Site", "Date", "Round", "White", "Black",
"Result", "Annotator", "PlyCount", "TimeControl",
Expand Down Expand Up @@ -31,9 +32,10 @@ var port : String
var pw : String

func _ready() -> void:
$HBoxContainer/MenuButton.get_popup().connect("id_pressed", self, "_on_FileMenu_id_pressed")
$HBoxContainer/GameButton.get_popup().connect("id_pressed", self, "_on_GameMenu_id_pressed")
$HBoxContainer/NetworkButton.get_popup().connect("id_pressed", self, "_on_NetworkMenu_id_pressed")
$MenuBar/HBoxContainer/MenuButton.get_popup().connect("id_pressed", self, "_on_FileMenu_id_pressed")
$MenuBar/HBoxContainer/GameButton.get_popup().connect("id_pressed", self, "_on_GameMenu_id_pressed")
$MenuBar/HBoxContainer/NetworkButton.get_popup().connect("id_pressed", self, "_on_NetworkMenu_id_pressed")
$MenuBar/HBoxContainer/HelpButton.get_popup().connect("id_pressed", self, "_on_HelpMenu_id_pressed")

func _on_FileMenu_id_pressed(id: int) -> void:
match id:
Expand All @@ -57,6 +59,13 @@ func _on_FileMenu_id_pressed(id: int) -> void:
self.file_loc = ""
FILE_MENU.QUIT:
get_tree().quit()

func _on_HelpMenu_id_pressed(id: int) -> void:
match id:
HELP_MENU.HELP:
$HelpDialog.popup_centered()
HELP_MENU.ABOUT:
$CreditsDialog.popup_centered()

func _on_GameMenu_id_pressed(id: int) -> void:
match id:
Expand Down Expand Up @@ -85,7 +94,7 @@ func _on_NetworkMenu_id_pressed(id: int) -> void:
$Network/CenterContainer/VBoxContainer/IPBlock.hide()
$Network.popup_centered()
yield($Network, "popup_hide")
yield(get_tree().create_timer(0.1), "timeout")
yield(get_tree().create_timer(0.1), "timeout")
if self.port:
emit_signal("host", int(self.port), self.pw)
self.IP = ""
Expand Down
Loading

0 comments on commit aee7669

Please sign in to comment.