A Minecraft style clone in Godot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

67 lines
1.9 KiB

class_name SaveFilePanel
extends Panel
@export var save_panel_highlight: StyleBoxFlat
@export var save_panel_normal: StyleBoxFlat
@export_group("Node Exports")
@export var save_name_label: Label
@export var save_date_label: Label
@export var save_icon: TextureRect
@export var load_button: TextureButton
@export var delete_confirm_ui: Control
@export var delete_button: TextureButton
@export var delete_confirm_button: BaseButton
@export var delete_cancel_button: BaseButton
var save_file_details: SaveFileDetailsResource
func _ready() -> void:
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
delete_button.pressed.connect(_on_delete_button_pressed)
load_button.pressed.connect(_on_load_button_pressed)
delete_confirm_button.pressed.connect(_on_delete_confirm_button_pressed)
delete_cancel_button.pressed.connect(_on_delete_cancel_button_pressed)
func initialize(_resource: SaveFileDetailsResource) -> void:
save_file_details = _resource
set_save_date()
set_save_icon()
set_save_name()
func set_save_date() -> void:
save_date_label.text = save_file_details.date_created
func set_save_icon() -> void:
save_icon.texture = load(save_file_details.save_icon)
func set_save_name() -> void:
save_name_label.text = save_file_details.save_name
if save_file_details.save_name == null or save_file_details.save_name == "":
save_name_label.text = save_file_details.filename
func _on_delete_button_pressed() -> void:
delete_confirm_ui.show()
func _on_delete_confirm_button_pressed() -> void:
SaveGameManager.delete_save_file.emit(save_file_details.filename)
queue_free()
func _on_delete_cancel_button_pressed() -> void:
delete_confirm_ui.hide()
func _on_load_button_pressed() -> void:
SaveGameManager.load_save_file.emit(save_file_details.filename)
func _on_mouse_entered() -> void:
set("theme_override_styles/panel", save_panel_highlight)
func _on_mouse_exited() -> void:
set("theme_override_styles/panel", save_panel_normal)