mirror of
https://github.com/Nokorpo/LibreAim.git
synced 2025-06-09 09:35:16 +09:00
import and export settings
This commit is contained in:
parent
ce0bc4d098
commit
a582eadded
3 changed files with 67 additions and 8 deletions
|
@ -118,6 +118,34 @@ text = "Target color"
|
|||
color = Color(1, 1, 0, 1)
|
||||
edit_alpha = false
|
||||
|
||||
[node name="ImportExport" type="Label" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "IMPORT / EXPORT"
|
||||
uppercase = true
|
||||
|
||||
[node name="Export" type="Button" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Export"
|
||||
|
||||
[node name="ExportFileDialog" type="FileDialog" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
initial_position = 2
|
||||
size = Vector2i(1995, 1500)
|
||||
visible = true
|
||||
access = 2
|
||||
|
||||
[node name="Import" type="Button" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Import"
|
||||
|
||||
[node name="ImportFileDialog" type="FileDialog" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
title = "Open a File"
|
||||
initial_position = 2
|
||||
size = Vector2i(1758, 1500)
|
||||
visible = true
|
||||
ok_button_text = "Open"
|
||||
file_mode = 0
|
||||
access = 2
|
||||
|
||||
[node name="Back" type="Button" parent="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Back"
|
||||
|
@ -135,4 +163,8 @@ text = "Back"
|
|||
[connection signal="color_changed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer/CrosshairColor" to="." method="_on_crosshair_color_color_changed"]
|
||||
[connection signal="color_changed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer/OutlineColor" to="." method="_on_outline_color_color_changed"]
|
||||
[connection signal="color_changed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/TargetColor" to="." method="_on_target_color_color_changed"]
|
||||
[connection signal="pressed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/Export" to="." method="_on_export_pressed"]
|
||||
[connection signal="file_selected" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/ExportFileDialog" to="." method="_on_export_file_dialog_file_selected"]
|
||||
[connection signal="pressed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/Import" to="." method="_on_import_pressed"]
|
||||
[connection signal="file_selected" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/ImportFileDialog" to="." method="_on_import_file_dialog_file_selected"]
|
||||
[connection signal="pressed" from="ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/Back" to="." method="_on_back_pressed"]
|
||||
|
|
|
@ -6,27 +6,33 @@ const file_path = "user://" + file_name
|
|||
var game_data = {}
|
||||
|
||||
func _ready():
|
||||
game_data = load_data()
|
||||
load_all_data()
|
||||
|
||||
|
||||
func save_data(key, value):
|
||||
func save_data(key, value, file_directory = file_path) :
|
||||
|
||||
game_data[key] = value
|
||||
var json = JSON.stringify(game_data)
|
||||
var file = FileAccess.open(file_path, FileAccess.WRITE)
|
||||
var file = FileAccess.open(file_directory, FileAccess.WRITE)
|
||||
file.store_line(json)
|
||||
file.close()
|
||||
|
||||
func save_all_data(file_directory = file_path) :
|
||||
var json = JSON.stringify(game_data)
|
||||
var file = FileAccess.open(file_directory, FileAccess.WRITE)
|
||||
file.store_line(json)
|
||||
file.close()
|
||||
|
||||
func get_data(key):
|
||||
var result = null
|
||||
if game_data != null:
|
||||
result = game_data.get(key)
|
||||
return result
|
||||
|
||||
func load_data():
|
||||
func load_all_data(file_directory = file_path):
|
||||
var json = JSON.new()
|
||||
var result = {}
|
||||
var file = FileAccess.open(file_path, FileAccess.READ)
|
||||
var file = FileAccess.open(file_directory, FileAccess.READ)
|
||||
if file:
|
||||
game_data = json.parse(file.get_as_text())
|
||||
file.close()
|
||||
|
@ -35,4 +41,4 @@ func load_data():
|
|||
|
||||
if json.data != null:
|
||||
result = json.data
|
||||
return result
|
||||
game_data = result
|
||||
|
|
|
@ -3,11 +3,13 @@ extends Control
|
|||
signal refresh_crosshair
|
||||
|
||||
@onready var crosshair = $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer/Crosshair
|
||||
@onready var file_export = $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/ExportFileDialog
|
||||
@onready var file_import = $ScrollContainer/MarginContainer/HBoxContainer/VBoxContainer/ImportFileDialog
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
# print(crosshair.is_pressed())
|
||||
# crosshair.set_pressed(true)
|
||||
file_export.visible = false
|
||||
file_import.visible = false
|
||||
loadSaved()
|
||||
var all_put_labels = get_tree().get_nodes_in_group("PutLabel")
|
||||
for put_label in all_put_labels:
|
||||
|
@ -102,3 +104,22 @@ func _on_outline_color_color_changed(color):
|
|||
func _on_target_color_color_changed(color):
|
||||
DataManager.save_data("TargetColor", str(color))
|
||||
emit_signal("refresh_crosshair")
|
||||
|
||||
|
||||
func _on_export_pressed():
|
||||
file_export.current_dir = "/"
|
||||
file_export.visible = true
|
||||
|
||||
|
||||
func _on_import_pressed():
|
||||
file_import.current_dir = "/"
|
||||
file_import.visible = true
|
||||
|
||||
|
||||
func _on_export_file_dialog_file_selected(path):
|
||||
DataManager.save_all_data(path)
|
||||
|
||||
|
||||
func _on_import_file_dialog_file_selected(path):
|
||||
DataManager.load_all_data(path)
|
||||
DataManager.save_all_data()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue