1
0
Fork 0
mirror of https://github.com/tonytins/dressupzack synced 2025-06-25 08:04:43 -04:00

Save game option

- New button themes
- Redid retro and "full snack" shirts
This commit is contained in:
Tony Bark 2024-01-16 16:55:00 -05:00
parent 71dfa4d52f
commit 39bcdcb78c
12 changed files with 613 additions and 534 deletions

View file

@ -1,16 +1,25 @@
extends Node
func debug_config():
func config_file(config_file = "user://config.cfg"):
# If the game is in
if OS.is_debug_build():
print_debug("Loading local config file")
return "res://config.cfg"
else:
return "user://config.cfg"
return config_file
func save_file(save_file = "user://save.cfg"):
# If the game is in
if OS.is_debug_build():
print_debug("Loading local save file")
return "res://save.cfg"
else:
return save_file
func set_config(config_file = "user://config.cfg"):
func save_config(config_file = "user://config.cfg"):
# Create new ConfigFile object.
var config = ConfigFile.new()
# Store some values.
config.set_value("window", "height", 1024)
config.set_value("window", "width", 768)
@ -18,8 +27,21 @@ func set_config(config_file = "user://config.cfg"):
# Save it to a file (overwrite if already exists)
if !FileAccess.file_exists(config_file):
config.save(config_file)
func save_game(tops = 0, bottoms = 0, full_body = 0, save_file = "user://save.cfg", overwrite = false, ):
# Create new ConfigFile object.
var config = ConfigFile.new()
func get_config(section, value, config_file = "user://config.cfg"):
# Store some values.
config.set_value("clothes", "tops", tops)
config.set_value("clothes", "bottoms", bottoms)
config.set_value("clothes", "full_body", full_body)
# Save it to a file (overwrite if already exists)
if !FileAccess.file_exists(save_file) || overwrite == true:
config.save(save_file)
func load_config(section, value, config_file = "user://config.cfg"):
var config = ConfigFile.new()
# Load data from a file.

View file

@ -1,33 +1,71 @@
extends Node
@onready var tops = $Tops
@onready var bottoms = $Bottoms
@onready var tops = $Seperate/Tops
@onready var bottoms = $Seperate/Bottoms
@onready var seperate_items = $Seperate
@onready var bottoms_bck = $Canvas/UI/DressUpCtrls/BottomsBckBtn
@onready var bottoms_fwd = $Canvas/UI/DressUpCtrls/BottomsFwdBtn
@onready var full_body = $FullBody
var is_seperate = true
var is_full_body = false
var config_file = Config.config_file()
var save_file = Config.save_file()
func _ready():
var config_file = Config.debug_config()
if !FileAccess.file_exists(config_file):
Config.set_config()
Config.save_config(config_file)
if !FileAccess.file_exists(save_file):
Config.save_game(save_file)
if FileAccess.file_exists(save_file):
var clothes_section = "clothes"
tops.frame = Config.load_config(clothes_section, "tops", save_file)
bottoms.frame = Config.load_config(clothes_section, "bottoms", save_file)
full_body.frame = Config.load_config(clothes_section, "full_body", save_file)
if FileAccess.file_exists(config_file):
var window_height = Config.get_config("window", "height", config_file)
var window_width = Config.get_config("window", "width", config_file)
print_debug(window_height)
print_debug(window_width)
var window_section = "window"
var window_height = Config.load_config(window_section, "height", config_file)
var window_width = Config.load_config(window_section, "width", config_file)
if window_height && window_width != null:
DisplayServer.window_set_size(Vector2i(window_height, window_width))
func game_save():
Config.save_game(tops.frame, bottoms.frame, full_body.frame, save_file, true)
func _process(delta):
if Input.is_action_just_pressed("exit"):
game_save()
get_tree().quit()
func _on_save_btn_pressed():
game_save()
func _on_tops_fwd_btn_pressed():
var current_frame = tops.frame
tops.frame = current_frame + 1;
var current_frame
if is_seperate:
current_frame = tops.frame
tops.frame = current_frame + 1;
if is_full_body:
current_frame = full_body.frame
full_body.frame = current_frame + 1;
func _on_tops_bck_btn_pressed():
var current_frame = tops.frame
tops.frame = current_frame + -1;
var current_frame
if is_seperate:
current_frame = tops.frame
tops.frame = current_frame + -1;
if is_full_body:
current_frame = full_body.frame
full_body.frame = current_frame + -1;
func _on_bottoms_bck_btn_pressed():
var current_frame = bottoms.frame
@ -38,10 +76,20 @@ func _on_bottoms_fwd_btn_pressed():
var current_frame = bottoms.frame
bottoms.frame = current_frame + 1;
func _on_fullbody_btn_pressed():
pass # Replace with function body.
is_seperate = false
is_full_body = true
seperate_items.hide()
bottoms_bck.hide()
bottoms_fwd.hide()
full_body.show()
func _on_separate_btn_pressed():
pass # Replace with function body.
is_seperate = true
is_full_body = false
seperate_items.show()
bottoms_bck.show()
bottoms_fwd.show()
full_body.hide()