mirror of
https://github.com/Nokorpo/LibreAim.git
synced 2025-06-09 09:35:16 +09:00
save in variable
This commit is contained in:
parent
6aaf63011e
commit
87cb1680c0
3 changed files with 48 additions and 1 deletions
|
@ -19,6 +19,7 @@ config/icon="res://icon.png"
|
|||
[autoload]
|
||||
|
||||
Global="*res://scripts/global.gd"
|
||||
DataManager="*res://scripts/data_manager.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
38
scripts/data_manager.gd
Normal file
38
scripts/data_manager.gd
Normal file
|
@ -0,0 +1,38 @@
|
|||
extends Node
|
||||
|
||||
const file_name = "open_aim_trainer.json"
|
||||
const file_path = "user://" + file_name
|
||||
|
||||
var game_data = {}
|
||||
|
||||
func _ready():
|
||||
game_data = load_data()
|
||||
print("....")
|
||||
print(game_data)
|
||||
|
||||
|
||||
func save_data(key, value):
|
||||
|
||||
game_data[key] = value
|
||||
var json = JSON.stringify(game_data)
|
||||
print(json)
|
||||
var file = FileAccess.open(file_path, FileAccess.WRITE)
|
||||
file.store_line(json)
|
||||
file.close()
|
||||
|
||||
func get_data(key):
|
||||
return game_data.get(key)
|
||||
|
||||
func load_data():
|
||||
var json = {}
|
||||
var file = FileAccess.open(file_path, FileAccess.READ)
|
||||
if file:
|
||||
json = JSON.new()
|
||||
print(game_data)
|
||||
game_data = json.parse(file.get_as_text())
|
||||
print(json.data)
|
||||
file.close()
|
||||
else:
|
||||
print("File not found.")
|
||||
|
||||
return json.data
|
|
@ -3,6 +3,7 @@ extends Control
|
|||
@onready var ResOptionButton = $MarginContainer/HBoxContainer/VBoxContainer/OptionButton
|
||||
@onready var resolution_label := $MarginContainer/HBoxContainer/VBoxContainer/ResolutionLabel
|
||||
@onready var gamelist := $Panel/ScrollContainer/VBoxContainer2
|
||||
@onready var slider_quality := $MarginContainer/HBoxContainer/VBoxContainer/QualitySlider
|
||||
|
||||
#var Resoltuions: Dictionary = {
|
||||
# "3840x2160" : Vector2(3840,2160),
|
||||
|
@ -53,6 +54,10 @@ var models3d: Dictionary = {
|
|||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
# AddResolutions()
|
||||
|
||||
if DataManager.get_data("resolution"):
|
||||
slider_quality.value = DataManager.get_data("resolution")
|
||||
|
||||
AddGames()
|
||||
get_viewport().size_changed.connect(self.update_resolution_label)
|
||||
update_resolution_label()
|
||||
|
@ -123,9 +128,12 @@ func _on_play_pressed():
|
|||
|
||||
|
||||
func _on_quality_slider_value_changed(value: float) -> void:
|
||||
quality_change(value)
|
||||
DataManager.save_data("resolution", value)
|
||||
|
||||
func quality_change(value: float) -> void:
|
||||
get_viewport().scaling_3d_scale = value
|
||||
update_resolution_label()
|
||||
|
||||
|
||||
func _on_quit_pressed():
|
||||
get_tree().quit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue