Version: 0.0.4
Scrolling implemented in view and creator, so you can add infinite variables to the content.
This commit is contained in:
parent
21bcce37fa
commit
5e4f79ee19
5 changed files with 48 additions and 15 deletions
|
@ -23,16 +23,17 @@ func _ready():
|
|||
if loadJSON("res://content/stats.json"):
|
||||
for i in range(int(data.get("amount"))):
|
||||
var fieldInstance = field.instantiate()
|
||||
add_child(fieldInstance)
|
||||
get_child(i+1).position = Vector2(16,(16+i*88))
|
||||
get_child(i+1).placeholder_text = data.get(str(i))
|
||||
$"ScrollContainer/VBoxContainer".add_child(fieldInstance)
|
||||
$"ScrollContainer/VBoxContainer".get_child(i).position = Vector2(16,(16+i*88))
|
||||
$"ScrollContainer/VBoxContainer".get_child(i).placeholder_text = data.get(str(i))
|
||||
$"ScrollContainer/VBoxContainer".get_child(i).custom_minimum_size.y = 40
|
||||
|
||||
func saveJSON(savePath):
|
||||
var saveData = {}
|
||||
|
||||
for i in range(int(data.get("amount"))):
|
||||
if i > 0:
|
||||
saveData[data.get(str(i))] = get_child(i+1).text
|
||||
saveData[data.get(str(i))] = $"ScrollContainer/VBoxContainer".get_child(i).text
|
||||
|
||||
var jsonString = JSON.stringify(saveData)
|
||||
|
||||
|
@ -45,7 +46,7 @@ func saveJSON(savePath):
|
|||
fileAccess.close()
|
||||
|
||||
func _on_button_pressed():
|
||||
var savePath = str("user://player_data"+get_child(1).text+".json")
|
||||
var savePath = str("user://player_data"+$"ScrollContainer/VBoxContainer".get_child(0).text+".json")
|
||||
saveJSON(savePath)
|
||||
|
||||
func _process(delta):
|
||||
|
|
|
@ -24,20 +24,20 @@ func _ready():
|
|||
if loadJSON("res://content/stats.json"):
|
||||
for i in range(int(data.get("amount"))):
|
||||
var fieldInstance = field.instantiate()
|
||||
add_child(fieldInstance)
|
||||
get_child(i+1).position = Vector2(16,(16+i*88))
|
||||
get_child(i+1).placeholder_text = data.get(str(i))
|
||||
$"ScrollContainer/VBoxContainer".add_child(fieldInstance)
|
||||
$"ScrollContainer/VBoxContainer".get_child(i).placeholder_text = data.get(str(i))
|
||||
$"ScrollContainer/VBoxContainer".get_child(i).custom_minimum_size.y = 40
|
||||
if i > 0:
|
||||
get_child(i+1).editable = false
|
||||
$"ScrollContainer/VBoxContainer".get_child(i).editable = false
|
||||
amount = data.get("amount")
|
||||
|
||||
func _on_button_pressed():
|
||||
var savePath = str("user://player_data"+get_child(1).text+".json")
|
||||
var savePath = str("user://player_data"+$"ScrollContainer/VBoxContainer".get_child(0).text+".json")
|
||||
if loadJSON(savePath):
|
||||
for i in range(int(amount)-1):
|
||||
get_child(i+2).text = data.get(str(get_child(i+2).placeholder_text))
|
||||
$"ScrollContainer/VBoxContainer".get_child(i+1).text = data.get(str($"ScrollContainer/VBoxContainer".get_child(i+1).placeholder_text))
|
||||
|
||||
func _process(delta):
|
||||
func _process(_delta):
|
||||
if Input.is_action_pressed("escape"):
|
||||
get_tree().change_scene_to_file("res://scenes/menu/main.tscn")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue