48 lines
1.3 KiB
GDScript
48 lines
1.3 KiB
GDScript
extends Node
|
|
|
|
const SAVE_FILE : String = "user://SAVEFILE.save"
|
|
var game_data = {}
|
|
var default_game_data = {
|
|
"display_mode": 0,
|
|
"vsync_on": false,
|
|
"current_resolution_index": 0,
|
|
"master_volume": 0,
|
|
"music_volume": 0,
|
|
"sfx_volume": 0,
|
|
"controls": {
|
|
"move_up": KEY_W,
|
|
"move_left": KEY_A,
|
|
"move_down": KEY_S,
|
|
"move_right": KEY_D,
|
|
"attack": "m" + str(MOUSE_BUTTON_LEFT),
|
|
"move_up_controller": "j" + str(JOY_AXIS_LEFT_Y) + "/-1.00",
|
|
"move_left_controller": "j" + str(JOY_AXIS_LEFT_X) + "/-1.00",
|
|
"move_down_controller": "j" + str(JOY_AXIS_LEFT_Y) + "/1.00",
|
|
"move_right_controller": "j" + str(JOY_AXIS_LEFT_X) + "/1.00",
|
|
"attack_controller": "b" + str(JOY_BUTTON_A),
|
|
"aim_up_controller": "j" + str(JOY_AXIS_RIGHT_Y) + "/-1.00",
|
|
"aim_left_controller": "j" + str(JOY_AXIS_RIGHT_X) + "/-1.00",
|
|
"aim_down_controller": "j" + str(JOY_AXIS_RIGHT_Y) + "/1.00",
|
|
"aim_right_controller": "j" + str(JOY_AXIS_RIGHT_X) + "/1.00",
|
|
}
|
|
}
|
|
|
|
func _ready():
|
|
load_data()
|
|
|
|
func load_data():
|
|
var file = FileAccess.open(SAVE_FILE, FileAccess.READ)
|
|
if file == null:
|
|
game_data = default_game_data
|
|
save_data()
|
|
else:
|
|
game_data = file.get_var()
|
|
file.close()
|
|
pass
|
|
|
|
func save_data():
|
|
var file = FileAccess.open(SAVE_FILE, FileAccess.WRITE)
|
|
file.store_var(game_data)
|
|
file.flush()
|
|
file.close()
|
|
pass
|