more godot 4.5 transition
This commit is contained in:
parent
0cef1ea769
commit
73411a44f3
7 changed files with 23 additions and 29 deletions
|
|
@ -14,7 +14,7 @@ signal toggled()
|
||||||
@export var toggle_mode := false
|
@export var toggle_mode := false
|
||||||
@export var group: ButtonGroup
|
@export var group: ButtonGroup
|
||||||
|
|
||||||
var pressed : get = is_pressed, set = set_pressed
|
var pressed_state : get = is_pressed, set = set_pressed
|
||||||
|
|
||||||
var _pressed_depth := 4
|
var _pressed_depth := 4
|
||||||
var _toggled := false
|
var _toggled := false
|
||||||
|
|
@ -29,13 +29,13 @@ func _ready():
|
||||||
button.text = text
|
button.text = text
|
||||||
button.offset_bottom = -depth
|
button.offset_bottom = -depth
|
||||||
button.toggle_mode = toggle_mode
|
button.toggle_mode = toggle_mode
|
||||||
button.group = group
|
#button.group = group
|
||||||
button.size.y = size.y - depth
|
button.size.y = size.y - depth
|
||||||
|
|
||||||
#
|
#
|
||||||
# Styles
|
# Styles
|
||||||
#
|
#
|
||||||
var background_style := Styles.get_stylebox_flat(background.get_stylebox("panel", "panel"), "button_background", corner_type)
|
var background_style := Styles.get_stylebox_flat(background.get_theme_stylebox("panel", "panel"), "button_background", corner_type)
|
||||||
background_style.set_bg_color(Color(0.73, 0.35, 0.13))
|
background_style.set_bg_color(Color(0.73, 0.35, 0.13))
|
||||||
background.set('theme_override_styles/panel', background_style)
|
background.set('theme_override_styles/panel', background_style)
|
||||||
match corner_type:
|
match corner_type:
|
||||||
|
|
@ -54,7 +54,7 @@ func _ready():
|
||||||
|
|
||||||
|
|
||||||
for style_name in ["normal", "hover", "focus", "pressed"]:
|
for style_name in ["normal", "hover", "focus", "pressed"]:
|
||||||
var original_style = button.get_stylebox(style_name)
|
var original_style = button.get_theme_stylebox(style_name)
|
||||||
# print_debug("style for ", style_name, ": ", original_style)
|
# print_debug("style for ", style_name, ": ", original_style)
|
||||||
var stylebox := Styles.get_stylebox_flat(original_style, style_name, corner_type)
|
var stylebox := Styles.get_stylebox_flat(original_style, style_name, corner_type)
|
||||||
button.set("custom_styles/%s" % style_name, stylebox)
|
button.set("custom_styles/%s" % style_name, stylebox)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ signal texture_selected(texture)
|
||||||
|
|
||||||
var _parent_display_name := "<parent directory>"
|
var _parent_display_name := "<parent directory>"
|
||||||
var _sep := "/"
|
var _sep := "/"
|
||||||
var _dir := DirAccess.new()
|
var _dir : DirAccess
|
||||||
|
|
||||||
@export var root_dir: String
|
@export var root_dir: String
|
||||||
@export var walkable := false
|
@export var walkable := false
|
||||||
|
|
@ -21,7 +21,8 @@ func populate(dir: String) -> void:
|
||||||
print_debug("populate ", dir)
|
print_debug("populate ", dir)
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
if _dir.change_dir(dir) != OK:
|
_dir = DirAccess.open(dir)
|
||||||
|
if !_dir:
|
||||||
print_debug("Cannot open path ", dir)
|
print_debug("Cannot open path ", dir)
|
||||||
assert(false)
|
assert(false)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ func layout_reflow():
|
||||||
|
|
||||||
# https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html
|
# https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html
|
||||||
func save_game():
|
func save_game():
|
||||||
var save_game = FileAccess.open("user://savegame.save", FileAccess.WRITE)
|
var save_file = FileAccess.open("user://savegame.save", FileAccess.WRITE)
|
||||||
var save_nodes = get_tree().get_nodes_in_group("Persist")
|
var save_nodes = get_tree().get_nodes_in_group("Persist")
|
||||||
for node in save_nodes:
|
for node in save_nodes:
|
||||||
# Check the node has a save function
|
# Check the node has a save function
|
||||||
|
|
@ -50,8 +50,8 @@ func save_game():
|
||||||
node_data["path"] = node.get_path()
|
node_data["path"] = node.get_path()
|
||||||
|
|
||||||
# Store the save dictionary as a new line in the save file
|
# Store the save dictionary as a new line in the save file
|
||||||
save_game.store_line(JSON.new().stringify(node_data))
|
save_file.store_line(JSON.stringify(node_data))
|
||||||
save_game.close()
|
save_file.close()
|
||||||
|
|
||||||
func load_game():
|
func load_game():
|
||||||
if not FileAccess.file_exists("user://savegame.save"):
|
if not FileAccess.file_exists("user://savegame.save"):
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ layout_mode = 2
|
||||||
text = "Hints"
|
text = "Hints"
|
||||||
|
|
||||||
[node name="NewGamePanel" parent="." instance=ExtResource("3")]
|
[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="about_to_popup" from="NewGamePanel" to="." method="_on_NewGamePanel_about_to_show"]
|
||||||
[connection signal="popup_hide" from="NewGamePanel" to="." method="_on_NewGamePanel_popup_hide"]
|
[connection signal="popup_hide" from="NewGamePanel" to="." method="_on_NewGamePanel_popup_hide"]
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,12 @@ func _init():
|
||||||
var err = preferences.load(pref_path)
|
var err = preferences.load(pref_path)
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pivot_offset = size / 2
|
#pivot_offset = size / 2
|
||||||
|
|
||||||
assert(popup.theme != null)
|
assert(popup.theme != null)
|
||||||
var popup_style : = popup.get_stylebox("panel", "PopupPanel") as StyleBoxFlat
|
var popup_style : = popup.get_theme_stylebox("panel", "PopupPanel") as StyleBoxFlat
|
||||||
assert(popup_style != null)
|
assert(popup_style != null)
|
||||||
var panel_style := panel.get_stylebox("panel", "Panel") as StyleBoxFlat
|
var panel_style := panel.get_theme_stylebox("panel", "Panel") as StyleBoxFlat
|
||||||
assert(panel_style != null)
|
assert(panel_style != null)
|
||||||
var modified_panel_style = panel_style.duplicate()
|
var modified_panel_style = panel_style.duplicate()
|
||||||
modified_panel_style.corner_radius_bottom_left = popup_style.corner_radius_bottom_left
|
modified_panel_style.corner_radius_bottom_left = popup_style.corner_radius_bottom_left
|
||||||
|
|
@ -67,7 +67,7 @@ func _ready():
|
||||||
edit_panel.hide()
|
edit_panel.hide()
|
||||||
|
|
||||||
var button_max_width: int = $EditPanel/VBoxContainer.size.x / 3.5
|
var button_max_width: int = $EditPanel/VBoxContainer.size.x / 3.5
|
||||||
var button_width := min(200, button_max_width)
|
var button_width: int = min(200, button_max_width)
|
||||||
print_debug("button max width = ", button_max_width)
|
print_debug("button max width = ", button_max_width)
|
||||||
easy_button.custom_minimum_size.x = button_width
|
easy_button.custom_minimum_size.x = button_width
|
||||||
normal_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]
|
# $Panel/Description.text = "Dimension: %d x %d\nIterations: %d" % [columns, rows, iterations]
|
||||||
desc.clear()
|
desc.clear()
|
||||||
|
|
||||||
desc.push_align(RichTextLabel.ALIGNMENT_CENTER)
|
desc.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||||
desc.add_text("Board: ")
|
desc.add_text("Board: ")
|
||||||
|
|
||||||
desc.push_bold()
|
desc.push_bold()
|
||||||
|
|
@ -155,11 +155,8 @@ func _update_description():
|
||||||
func _set_artwork(tex: Texture2D) -> void:
|
func _set_artwork(tex: Texture2D) -> void:
|
||||||
preview.texture = tex
|
preview.texture = tex
|
||||||
|
|
||||||
var file = File.new()
|
var file = FileAccess.open(cached_artwork_path, FileAccess.WRITE)
|
||||||
if file.open(cached_artwork_path, File.WRITE) != OK:
|
|
||||||
assert(false)
|
|
||||||
file.store_var(tex.get_data(), true)
|
file.store_var(tex.get_data(), true)
|
||||||
file.close()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Signals
|
# Signals
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ func _ready() -> void:
|
||||||
if autoload_fresh_game:
|
if autoload_fresh_game:
|
||||||
start_fresh()
|
start_fresh()
|
||||||
if artwork_texture == null:
|
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)
|
new_game(NewGamePanel.normal_columns, NewGamePanel.normal_rows, NewGamePanel.normal_iterations, artwork_texture)
|
||||||
|
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
|
|
@ -98,7 +98,7 @@ func _gui_input(event):
|
||||||
if $AnimationPlayer.is_playing():
|
if $AnimationPlayer.is_playing():
|
||||||
# Disable input during animation
|
# Disable input during animation
|
||||||
return
|
return
|
||||||
if hint_active or hint_tween.is_active():
|
if hint_active or hint_tween:
|
||||||
return
|
return
|
||||||
|
|
||||||
match current_state:
|
match current_state:
|
||||||
|
|
@ -238,7 +238,7 @@ func move_piece(direction, speed: float) -> bool:
|
||||||
assert(moving_piece_animation != null)
|
assert(moving_piece_animation != null)
|
||||||
assert(moving_piece_animation.get_track_count() > 0)
|
assert(moving_piece_animation.get_track_count() > 0)
|
||||||
|
|
||||||
var moving_piece_track_index: int = moving_piece_animation.find_track(current_animation_path)
|
var moving_piece_track_index: int = moving_piece_animation.find_track(current_animation_path, Animation.TYPE_ANIMATION)
|
||||||
|
|
||||||
assert(moving_piece_track_index != -1)
|
assert(moving_piece_track_index != -1)
|
||||||
|
|
||||||
|
|
@ -273,7 +273,7 @@ func commit_slide(audio: bool, check_solved: bool):
|
||||||
|
|
||||||
ensure_validity()
|
ensure_validity()
|
||||||
reset_slide()
|
reset_slide()
|
||||||
update()
|
#update()
|
||||||
if check_solved:
|
if check_solved:
|
||||||
check_solved()
|
check_solved()
|
||||||
|
|
||||||
|
|
@ -447,8 +447,8 @@ func new_game(columns: int, rows: int, shuffle_iterations: int, artwork_texture:
|
||||||
|
|
||||||
func start_fresh():
|
func start_fresh():
|
||||||
if artwork_texture == null:
|
if artwork_texture == null:
|
||||||
print_debug("Load texture from: ", NewGamePanel.default_artwork_path)
|
print_debug("Load texture from: ", $NewGamePanel.default_artwork_path)
|
||||||
artwork_texture = Utils.load_texture_from_path(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)
|
new_game(NewGamePanel.normal_columns, NewGamePanel.normal_rows, NewGamePanel.normal_iterations, artwork_texture)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,8 @@ static func load_texture_from_path(path: String) -> Texture2D:
|
||||||
return texture
|
return texture
|
||||||
|
|
||||||
static func deserialize_texture(path: String) -> Texture2D:
|
static func deserialize_texture(path: String) -> Texture2D:
|
||||||
var file := File.new()
|
var file := FileAccess.open(path, FileAccess.READ)
|
||||||
if file.open(path, File.READ) != OK:
|
|
||||||
return null
|
|
||||||
var img: Image = file.get_var(true)
|
var img: Image = file.get_var(true)
|
||||||
file.close()
|
|
||||||
var img_tex = ImageTexture.new()
|
var img_tex = ImageTexture.new()
|
||||||
img_tex.create_from_image(img)
|
img_tex.create_from_image(img)
|
||||||
return img_tex
|
return img_tex
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue