diff --git a/flake.lock b/flake.lock deleted file mode 100644 index c0e487e..0000000 --- a/flake.lock +++ /dev/null @@ -1,27 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1764642553, - "narHash": "sha256-mvbFFzVBhVK1FjyPHZGMAKpNiqkr7k++xIwy+p/NQvA=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "f720de59066162ee879adcc8c79e15c51fe6bfb4", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 7c0920d..0000000 --- a/flake.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - description = "Taqin"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - - }; - - outputs = - inputs@{ nixpkgs, ... }: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - in - { - formatter.${system} = pkgs.nixfmt-rfc-style; - - devShell.${system} = - with pkgs; - mkShell { - LD_LIBRARY_PATH = lib.makeLibraryPath [ stdenv.cc.cc ]; # For libstdc++.so.6 - # ANDROID_HOME = "${androidenv.androidPkgs_9_0.androidsdk}/libexec/android-sdk"; - - nativeBuildInputs = [ - clang - just - - godot_4 - - android-tools - # androidenv.androidPkgs_9_0.androidsdk - # androidenv.androidPkgs_9_0.platform-tools - jre_headless - ]; - }; - }; -} diff --git a/src/DepthButton.gd b/src/DepthButton.gd index b00183b..2bbbf74 100644 --- a/src/DepthButton.gd +++ b/src/DepthButton.gd @@ -14,7 +14,7 @@ signal toggled() @export var toggle_mode := false @export var group: ButtonGroup -var pressed_state : get = is_pressed, set = set_pressed +var pressed : get = is_pressed, set = set_pressed var _pressed_depth := 4 var _toggled := false @@ -29,13 +29,13 @@ func _ready(): button.text = text button.offset_bottom = -depth button.toggle_mode = toggle_mode - #button.group = group + button.group = group button.size.y = size.y - depth # # Styles # - var background_style := Styles.get_stylebox_flat(background.get_theme_stylebox("panel", "panel"), "button_background", corner_type) + var background_style := Styles.get_stylebox_flat(background.get_stylebox("panel", "panel"), "button_background", corner_type) background_style.set_bg_color(Color(0.73, 0.35, 0.13)) background.set('theme_override_styles/panel', background_style) match corner_type: @@ -54,7 +54,7 @@ func _ready(): for style_name in ["normal", "hover", "focus", "pressed"]: - var original_style = button.get_theme_stylebox(style_name) + var original_style = button.get_stylebox(style_name) # print_debug("style for ", style_name, ": ", original_style) var stylebox := Styles.get_stylebox_flat(original_style, style_name, corner_type) button.set("custom_styles/%s" % style_name, stylebox) diff --git a/src/FileList.gd b/src/FileList.gd index cca839c..83f40f3 100644 --- a/src/FileList.gd +++ b/src/FileList.gd @@ -5,7 +5,7 @@ signal texture_selected(texture) var _parent_display_name := "" var _sep := "/" -var _dir : DirAccess +var _dir := DirAccess.new() @export var root_dir: String @export var walkable := false @@ -21,8 +21,7 @@ func populate(dir: String) -> void: print_debug("populate ", dir) clear() - _dir = DirAccess.open(dir) - if !_dir: + if _dir.change_dir(dir) != OK: print_debug("Cannot open path ", dir) assert(false) return diff --git a/src/Main.gd b/src/Main.gd index a4eea36..0fde734 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -35,7 +35,7 @@ func layout_reflow(): # https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html func save_game(): - var save_file = FileAccess.open("user://savegame.save", FileAccess.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 @@ -50,8 +50,8 @@ func save_game(): node_data["path"] = node.get_path() # Store the save dictionary as a new line in the save file - save_file.store_line(JSON.stringify(node_data)) - save_file.close() + save_game.store_line(JSON.new().stringify(node_data)) + save_game.close() func load_game(): if not FileAccess.file_exists("user://savegame.save"): diff --git a/src/Main.tscn b/src/Main.tscn index f04a4a7..2e85e2c 100644 --- a/src/Main.tscn +++ b/src/Main.tscn @@ -57,6 +57,7 @@ layout_mode = 2 text = "Hints" [node name="NewGamePanel" parent="." instance=ExtResource("3")] +pivot_offset = Vector2(4, 4) [connection signal="about_to_popup" from="NewGamePanel" to="." method="_on_NewGamePanel_about_to_show"] [connection signal="popup_hide" from="NewGamePanel" to="." method="_on_NewGamePanel_popup_hide"] diff --git a/src/NewGamePanel.gd b/src/NewGamePanel.gd index 0b26af9..f1455d7 100644 --- a/src/NewGamePanel.gd +++ b/src/NewGamePanel.gd @@ -48,12 +48,12 @@ func _init(): var err = preferences.load(pref_path) func _ready(): - #pivot_offset = size / 2 + pivot_offset = size / 2 assert(popup.theme != null) - var popup_style : = popup.get_theme_stylebox("panel", "PopupPanel") as StyleBoxFlat + var popup_style : = popup.get_stylebox("panel", "PopupPanel") as StyleBoxFlat assert(popup_style != null) - var panel_style := panel.get_theme_stylebox("panel", "Panel") as StyleBoxFlat + var panel_style := panel.get_stylebox("panel", "Panel") as StyleBoxFlat assert(panel_style != null) var modified_panel_style = panel_style.duplicate() modified_panel_style.corner_radius_bottom_left = popup_style.corner_radius_bottom_left @@ -67,7 +67,7 @@ func _ready(): edit_panel.hide() var button_max_width: int = $EditPanel/VBoxContainer.size.x / 3.5 - var button_width: int = min(200, button_max_width) + var button_width := min(200, button_max_width) print_debug("button max width = ", button_max_width) easy_button.custom_minimum_size.x = button_width normal_button.custom_minimum_size.x = button_width @@ -131,7 +131,7 @@ func _update_description(): # $Panel/Description.text = "Dimension: %d x %d\nIterations: %d" % [columns, rows, iterations] desc.clear() - desc.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + desc.push_align(RichTextLabel.ALIGNMENT_CENTER) desc.add_text("Board: ") desc.push_bold() @@ -155,8 +155,11 @@ func _update_description(): func _set_artwork(tex: Texture2D) -> void: preview.texture = tex - var file = FileAccess.open(cached_artwork_path, FileAccess.WRITE) + var file = File.new() + if file.open(cached_artwork_path, File.WRITE) != OK: + assert(false) file.store_var(tex.get_data(), true) + file.close() # # Signals diff --git a/src/Taquin.gd b/src/Taquin.gd index f56d3f3..e9ba82a 100644 --- a/src/Taquin.gd +++ b/src/Taquin.gd @@ -87,7 +87,7 @@ func _ready() -> void: if autoload_fresh_game: start_fresh() if artwork_texture == null: - artwork_texture = $NewGamePanel.default_artwork_texture + artwork_texture = NewGamePanel.default_artwork_texture new_game(NewGamePanel.normal_columns, NewGamePanel.normal_rows, NewGamePanel.normal_iterations, artwork_texture) func _unhandled_input(event): @@ -98,7 +98,7 @@ func _gui_input(event): if $AnimationPlayer.is_playing(): # Disable input during animation return - if hint_active or hint_tween: + if hint_active or hint_tween.is_active(): return match current_state: @@ -238,7 +238,7 @@ func move_piece(direction, speed: float) -> bool: assert(moving_piece_animation != null) assert(moving_piece_animation.get_track_count() > 0) - var moving_piece_track_index: int = moving_piece_animation.find_track(current_animation_path, Animation.TYPE_ANIMATION) + var moving_piece_track_index: int = moving_piece_animation.find_track(current_animation_path) assert(moving_piece_track_index != -1) @@ -273,7 +273,7 @@ func commit_slide(audio: bool, check_solved: bool): ensure_validity() reset_slide() - #update() + update() if check_solved: check_solved() @@ -447,8 +447,8 @@ func new_game(columns: int, rows: int, shuffle_iterations: int, artwork_texture: func start_fresh(): if artwork_texture == null: - print_debug("Load texture from: ", $NewGamePanel.default_artwork_path) - artwork_texture = Utils.load_texture_from_path($NewGamePanel.default_artwork_path) + print_debug("Load texture from: ", NewGamePanel.default_artwork_path) + artwork_texture = Utils.load_texture_from_path(NewGamePanel.default_artwork_path) new_game(NewGamePanel.normal_columns, NewGamePanel.normal_rows, NewGamePanel.normal_iterations, artwork_texture) diff --git a/src/Utils.gd b/src/Utils.gd index 3f9cf9a..35796f8 100644 --- a/src/Utils.gd +++ b/src/Utils.gd @@ -8,8 +8,11 @@ static func load_texture_from_path(path: String) -> Texture2D: return texture static func deserialize_texture(path: String) -> Texture2D: - var file := FileAccess.open(path, FileAccess.READ) + var file := File.new() + if file.open(path, File.READ) != OK: + return null var img: Image = file.get_var(true) + file.close() var img_tex = ImageTexture.new() img_tex.create_from_image(img) return img_tex