list all artworks from res://
I cannot simply explore the res:// filesystem on Android. As a workaround, I create a static list of embedded artworks.
This commit is contained in:
parent
e90eb40630
commit
cd49ba8afc
8 changed files with 112 additions and 107 deletions
|
|
@ -52,7 +52,7 @@ var local_max_position := Vector2.ZERO
|
|||
|
||||
var hint_active := false setget set_hint_active, get_hint_active
|
||||
|
||||
var _artwork_path := NewGamePanel.default_artwork_path
|
||||
#var _artwork_path := NewGamePanel.default_artwork_path
|
||||
|
||||
onready var hint_tween = $HintTween
|
||||
|
||||
|
|
@ -87,8 +87,7 @@ func _ready() -> void:
|
|||
if autoload_fresh_game:
|
||||
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)
|
||||
artwork_texture = NewGamePanel.default_artwork_texture
|
||||
new_game(NewGamePanel.normal_columns, NewGamePanel.normal_rows, NewGamePanel.normal_iterations, artwork_texture)
|
||||
|
||||
func _unhandled_input(event):
|
||||
|
|
@ -372,23 +371,19 @@ func save() -> Dictionary:
|
|||
"columns": columns,
|
||||
"pieces": serialized_pieces,
|
||||
"hidden_piece": serialized_pieces.size(),
|
||||
"artwork_path": _artwork_path,
|
||||
# "artwork_path": _artwork_path,
|
||||
}
|
||||
|
||||
func load(saved_state) -> bool:
|
||||
print("load save state: ", saved_state)
|
||||
if not saved_state.has_all(["rows", "columns", "pieces", "hidden_piece", "artwork_path"]):
|
||||
if not saved_state.has_all(["rows", "columns", "pieces", "hidden_piece"]):
|
||||
assert(false, "Invalid save state")
|
||||
return false
|
||||
rows = saved_state["rows"]
|
||||
columns = saved_state["columns"]
|
||||
|
||||
var texture := Utils.load_texture_from_path(saved_state["artwork_path"])
|
||||
if texture == null:
|
||||
return false
|
||||
artwork_texture = texture
|
||||
_artwork_path = saved_state["artwork_path"]
|
||||
print_debug("Load artwork from: ", _artwork_path)
|
||||
|
||||
artwork_texture = Utils.deserialize_texture(NewGamePanel.cached_artwork_path)
|
||||
assert(artwork_texture != null)
|
||||
|
||||
init(saved_state["pieces"], saved_state["hidden_piece"], artwork_texture)
|
||||
return true
|
||||
|
|
@ -498,20 +493,15 @@ func _on_AnimationPlayer_animation_finished(anim_name):
|
|||
"MovingPiece":
|
||||
commit_slide(true, true)
|
||||
|
||||
func _on_NewGamePanel_start_triggered(preferences):
|
||||
func _on_NewGamePanel_start_triggered(preferences, texture):
|
||||
var difficulty_mode = preferences.get_value("game", "difficulty", "normal")
|
||||
print_debug("difficulty mode: ", difficulty_mode)
|
||||
var columns = preferences.get_value("game", "columns", NewGamePanel.normal_columns)
|
||||
var rows = preferences.get_value("game", "rows", NewGamePanel.normal_rows)
|
||||
var shuffle_iterations = preferences.get_value("game", "shuffle_iterations", NewGamePanel.normal_iterations)
|
||||
var artwork_path = preferences.get_value("game", "artwork_path", NewGamePanel.default_artwork_path)
|
||||
print_debug("new game triggered with artwork path: ", artwork_path)
|
||||
artwork_texture = Utils.load_texture_from_path(artwork_path)
|
||||
if artwork_path != null:
|
||||
_artwork_path = artwork_path
|
||||
artwork_texture = texture
|
||||
new_game(columns, rows, shuffle_iterations, artwork_texture)
|
||||
|
||||
|
||||
func _on_Hints_button_down():
|
||||
if not hint_active:
|
||||
show_hints()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue