update to godot 4.5
This commit is contained in:
parent
8e8823fb0c
commit
732a7329bc
28 changed files with 210 additions and 24 deletions
1
src/DepthButton.gd.uid
Normal file
1
src/DepthButton.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cdn73git076hr
|
||||
1
src/FileList.gd.uid
Normal file
1
src/FileList.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://by50vos4xnap8
|
||||
1
src/ImagePicker.gd.uid
Normal file
1
src/ImagePicker.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://gn1dmf64p11j
|
||||
28
src/Main.gd
28
src/Main.gd
|
|
@ -13,7 +13,7 @@ func _ready():
|
|||
print("Starting state: ", taquin.current_state_name())
|
||||
|
||||
func _notification(what):
|
||||
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
|
||||
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
||||
save_game()
|
||||
get_tree().quit() # default behavior
|
||||
|
||||
|
|
@ -31,12 +31,11 @@ func layout_reflow():
|
|||
else:
|
||||
# landscape
|
||||
container.columns = 2
|
||||
update()
|
||||
#update()
|
||||
|
||||
# https://docs.godotengine.org/en/3.2/tutorials/io/saving_games.html
|
||||
# https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html
|
||||
func save_game():
|
||||
var save_game = File.new()
|
||||
save_game.open("user://savegame.save", File.WRITE)
|
||||
var save_game = FileAccess.open("user://savegame.save", FileAccess.WRITE)
|
||||
var save_nodes = get_tree().get_nodes_in_group("Persist")
|
||||
for node in save_nodes:
|
||||
# Check the node has a save function
|
||||
|
|
@ -55,17 +54,16 @@ func save_game():
|
|||
save_game.close()
|
||||
|
||||
func load_game():
|
||||
var save_game = File.new()
|
||||
if not save_game.file_exists("user://savegame.save"):
|
||||
return false # Error! We don't have a save to load.
|
||||
if not FileAccess.file_exists("user://savegame.save"):
|
||||
return # Error! We don't have a save to load.
|
||||
|
||||
# Load the file line by line and process that dictionary to restore
|
||||
# the object it represents.
|
||||
save_game.open("user://savegame.save", File.READ)
|
||||
while save_game.get_position() < save_game.get_length():
|
||||
var save_file = FileAccess.open("user://savegame.save", FileAccess.READ)
|
||||
while save_file.get_position() < save_file.get_length():
|
||||
# Get the saved dictionary from the next line in the save file
|
||||
var test_json_conv = JSON.new()
|
||||
test_json_conv.parse(save_game.get_line())
|
||||
test_json_conv.parse(save_file.get_line())
|
||||
var node_data = test_json_conv.get_data()
|
||||
|
||||
# Call the node's save function
|
||||
|
|
@ -76,7 +74,7 @@ func load_game():
|
|||
else:
|
||||
print("Cannot load node ", node_data["path"])
|
||||
|
||||
save_game.close()
|
||||
save_file.close()
|
||||
return true
|
||||
|
||||
func start_fresh():
|
||||
|
|
@ -86,11 +84,11 @@ func start_fresh():
|
|||
# Signals
|
||||
#
|
||||
func _on_Taquin_state_changed(previous, new):
|
||||
print("Taquin state: ", Taquin.State.keys()[previous], " -> ", Taquin.State.keys()[new])
|
||||
print("Taquin state: ", taquin.State.keys()[previous], " -> ", taquin.State.keys()[new])
|
||||
match new:
|
||||
Taquin.State.WINNING:
|
||||
taquin.State.WINNING:
|
||||
print("Solved!")
|
||||
Taquin.State.GAME_OVER:
|
||||
taquin.State.GAME_OVER:
|
||||
pass
|
||||
|
||||
func _on_New_game_pressed():
|
||||
|
|
|
|||
1
src/Main.gd.uid
Normal file
1
src/Main.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://rn30misiiww4
|
||||
|
|
@ -1,21 +1,20 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://cj4uqgtnylppu"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/Main.gd" id="1"]
|
||||
[ext_resource type="Script" uid="uid://rn30misiiww4" path="res://src/Main.gd" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://src/Taquin.tscn" id="2"]
|
||||
[ext_resource type="PackedScene" path="res://src/NewGamePanel.tscn" id="3"]
|
||||
[ext_resource type="PackedScene" path="res://src/DepthButton.tscn" id="4"]
|
||||
[ext_resource type="Theme" path="res://assets/taqin_theme.tres" id="5"]
|
||||
[ext_resource type="Theme" uid="uid://b7gu1bjpj8ixp" path="res://assets/taqin_theme.tres" id="5"]
|
||||
|
||||
[node name="Main" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("5")
|
||||
script = ExtResource("1")
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Background" type="Panel" parent="."]
|
||||
layout_mode = 0
|
||||
|
|
|
|||
1
src/NewGamePanel.gd.uid
Normal file
1
src/NewGamePanel.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dbsvkfo8rwlk3
|
||||
1
src/Piece.gd.uid
Normal file
1
src/Piece.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cqq4ynmtdbb8q
|
||||
1
src/Styles.gd.uid
Normal file
1
src/Styles.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cjynnh7od7kav
|
||||
|
|
@ -218,7 +218,7 @@ func sliding_piece_for_direction(direction) -> Piece:
|
|||
|
||||
if (destination.x < 0 || destination.x >= columns
|
||||
|| destination.y < 0 || destination.y >= rows):
|
||||
print("\/!\\ Impossible move")
|
||||
print("/!\\ Impossible move")
|
||||
return null
|
||||
|
||||
var piece = pieces[destination.x][destination.y]
|
||||
|
|
|
|||
1
src/Taquin.gd.uid
Normal file
1
src/Taquin.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://xctq46c6kgwo
|
||||
1
src/Utils.gd.uid
Normal file
1
src/Utils.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c0m3ub6h2dq8c
|
||||
Loading…
Add table
Add a link
Reference in a new issue