Skip to content

Commit

Permalink
added user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ArMM1998 committed Nov 10, 2023
1 parent a62e03f commit 0def9f3
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 14 deletions.
66 changes: 66 additions & 0 deletions main_scene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,64 @@ offset_bottom = 32.0
texture_normal = ExtResource("10_iig2l")
script = ExtResource("11_tcy6v")

[node name="Settings" type="AcceptDialog" parent="Layer3_Popups"]
title = "User Settings"
position = Vector2i(350, 192)
size = Vector2i(400, 195)
exclusive = false
unresizable = true
min_size = Vector2i(144, 0)
ok_button_text = "Close"
dialog_autowrap = true

[node name="Node2D" type="Node2D" parent="Layer3_Popups/Settings"]
position = Vector2(470, 240)

[node name="btn_autosave" type="CheckButton" parent="Layer3_Popups/Settings/Node2D"]
offset_left = -150.0
offset_top = -200.0
offset_right = -106.0
offset_bottom = -176.0

[node name="Label" type="Label" parent="Layer3_Popups/Settings/Node2D/btn_autosave"]
layout_mode = 0
offset_left = -290.0
offset_right = -191.0
offset_bottom = 26.0
text = "Autosave"

[node name="autosave_interval" type="SpinBox" parent="Layer3_Popups/Settings/Node2D"]
offset_left = -150.0
offset_top = -165.0
offset_right = -106.0
offset_bottom = -141.0
scale = Vector2(0.8, 0.8)
min_value = 1.0
max_value = 30.0
value = 1.0

[node name="Label" type="Label" parent="Layer3_Popups/Settings/Node2D/autosave_interval"]
layout_mode = 0
offset_left = -362.5
offset_top = 0.5
offset_right = -263.5
offset_bottom = 26.5
scale = Vector2(1.2, 1.2)
text = "Autosave Interval (minutes)"

[node name="btn_check_updates" type="CheckButton" parent="Layer3_Popups/Settings/Node2D"]
offset_left = -150.0
offset_top = -130.0
offset_right = -106.0
offset_bottom = -106.0

[node name="Label" type="Label" parent="Layer3_Popups/Settings/Node2D/btn_check_updates"]
layout_mode = 0
offset_left = -290.0
offset_right = -191.0
offset_bottom = 26.0
text = "Check for Updates"

[node name="Update" type="AcceptDialog" parent="Layer3_Popups"]
title = "New version available"
position = Vector2i(380, 192)
Expand All @@ -384,6 +442,11 @@ dialog_text = "asdsd
"
dialog_autowrap = true

[node name="Changelog" type="AcceptDialog" parent="Layer3_Popups"]
title = "Changelog"
initial_position = 2
ok_button_text = "Close"

[node name="directory_watcher" type="Node" parent="."]

[node name="HTTPRequest" type="HTTPRequest" parent="."]
Expand All @@ -407,5 +470,8 @@ script = ExtResource("20_r06tp")
[connection signal="mouse_exited" from="Layer3_Popups/About/Node2D/TextureButton" to="Layer3_Popups/About/Node2D/TextureButton" method="_on_mouse_exited"]
[connection signal="pressed" from="Layer3_Popups/About/Node2D/TextureButton" to="Layer3_Popups/About/Node2D/TextureButton" method="_on_pressed"]
[connection signal="visibility_changed" from="Layer3_Popups/About/Node2D/TextureButton" to="Layer3_Popups/About/Node2D/TextureButton" method="_on_visibility_changed"]
[connection signal="pressed" from="Layer3_Popups/Settings/Node2D/btn_autosave" to="." method="_on_btn_autosave_pressed"]
[connection signal="value_changed" from="Layer3_Popups/Settings/Node2D/autosave_interval" to="." method="_on_autosave_interval_changed"]
[connection signal="pressed" from="Layer3_Popups/Settings/Node2D/btn_check_updates" to="." method="_on_btn_check_updates_pressed"]
[connection signal="confirmed" from="Layer3_Popups/Update" to="." method="_on_update_confirmed"]
[connection signal="request_completed" from="HTTPRequest" to="HTTPRequest" method="_on_request_completed"]
6 changes: 5 additions & 1 deletion scripts/PanelTop.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func _ready():
$MenuButton_File.get_popup().add_item("Save")
$MenuButton_File.get_popup().add_item("Save As...")
$MenuButton_File.get_popup().add_separator()
$MenuButton_File.get_popup().add_item("User Settings")
$MenuButton_File.get_popup().add_separator()
$MenuButton_File.get_popup().add_item("Exit")

var platform_menu = PopupMenu.new()
Expand Down Expand Up @@ -47,7 +49,7 @@ func _ready():
platform_menu.connect("id_pressed", platformMenu)

func fileMenu(item_id):
#print(item_id)
print(item_id)
if item_id == 0:
owner.newFile()
if item_id == 1:
Expand All @@ -57,6 +59,8 @@ func fileMenu(item_id):
if item_id == 4:
owner.startSaveAsTask()
if item_id == 6:
owner.settings.popup()
if item_id == 8:
get_tree().quit()

$MenuButton_File.release_focus()
Expand Down
59 changes: 46 additions & 13 deletions scripts/main.gd
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
extends Node2D

var current_version = "0.5.3"
var current_version = "0.6"

var changelog = "-You can undo 3D depth and element duplication.
-fixed an issue where selecting an element from the left panel wouldn't update the right panel.
-If you press F2 after clicking an element on the left panel, you can quickly rename it
-Hold CTRL to select multiple keyframes
-Select multiple \"position\" keyframes to offset their data while dragging and dropping an element."
var changelog = "
NEW FEATURES:
-You can now undo 3D depth and element duplication. (press CTRL + D to duplicate)
-Added a \"user settings\" menu.
-You can now press F2 after clicking an element on the left panel, you can quickly rename it
-Multiple \"position\" keyframes to offset their data while dragging and dropping an element
-CTRL to add a keyframe to the multiple keyframes selection.
FIXES:
-Fixed an issue where selecting an element from the left panel wouldn't update the right panel.
"

@onready var layer_2_panels = $Layer2_Panels
@onready var fileDialog = $Layer3_Popups/FileDialog
Expand All @@ -21,6 +27,7 @@ var changelog = "-You can undo 3D depth and element duplication.
@onready var panel_right = $Layer2_Panels/PanelRight
@onready var panel_bottom = $Layer2_Panels/PanelBottom
@onready var timeline = $Layer2_Panels/PanelBottom/timeline
@onready var settings = $Layer3_Popups/Settings


var undoHistory = []
Expand Down Expand Up @@ -52,7 +59,8 @@ var user_settings = {"platform" : "PSP", #Default
"hide_axis" : false,
"boot_up_times": 0,
"autobackup" : true,
"backuptimer" : 120}
"backuptimer" : 120,
"auto_update" : true}

var platformSettings = []
var textureList = []
Expand Down Expand Up @@ -83,24 +91,37 @@ func _ready():
user_settings = JSON.parse_string(userData.get_as_text())
userData.close()

if not "auto_update" in user_settings:
user_settings["auto_update"] = true

$Layer3_Popups/Settings/Node2D/btn_check_updates.button_pressed = user_settings["auto_update"]

if "autobackup" in user_settings:
autobackup = user_settings["autobackup"]
backupTimeLimit = user_settings["backuptimer"]

else:
user_settings["autobackup"] = autobackup
user_settings["backuptimer"] = backupTimeLimit

$Layer3_Popups/Settings/Node2D/btn_autosave.button_pressed = autobackup
$Layer3_Popups/Settings/Node2D/autosave_interval.value = backupTimeLimit / 60


if user_settings["platform"] not in platformSettings:
user_settings["platform"] = "PSP"

if "version" not in user_settings:
print("open up changelog")
$Layer3_Popups/Changelog.dialog_text = changelog
$Layer3_Popups/Changelog.popup()
user_settings["version"] = current_version
else:
if user_settings["version"] != current_version:
print("open up changelog")
$Layer3_Popups/Changelog.dialog_text = changelog
$Layer3_Popups/Changelog.popup()
user_settings["version"] = current_version


#update project_settings
project_settings["platform"] = user_settings["platform"]
project_settings["field"] = platformSettings[user_settings["platform"]]["field"]
Expand Down Expand Up @@ -698,7 +719,7 @@ func toggleAxis():

func newFile():
resetVariables()
get_viewport().title = "Puyo Edit - Puyo Puyo Animation Editor"
get_viewport().title = "Puyo Edit - Puyo Puyo Animation Editor v" + current_version
project_settings["file_path"] = ""
project_settings["texture_dir"] = ""
updatePathLabel()
Expand Down Expand Up @@ -770,7 +791,7 @@ func loadJsonFile(file_path, backup = false):

if not backup:
user_settings["filedialog_dir"] = $Layer3_Popups/FileDialog.current_dir
get_viewport().title = "Puyo Edit - Puyo Puyo Animation Editor : " + file_path
get_viewport().title = "Puyo Edit - Puyo Puyo Animation Editor : " + file_path + " v" + current_version
var jsonFile = FileAccess.open(file_path, FileAccess.READ)
var jsonData = JSON.parse_string(jsonFile.get_as_text())
fileDialog.hide()
Expand Down Expand Up @@ -828,7 +849,7 @@ func loadJsonFile(file_path, backup = false):
if loadReady:
if backup:
project_settings["file_path"] = jsonData["Editor Settings"]["file_dir"]
get_viewport().title = "Puyo Edit - Puyo Puyo Animation Editor: " + jsonData["Editor Settings"]["file_dir"]
get_viewport().title = "Puyo Edit - Puyo Puyo Animation Editor: " + jsonData["Editor Settings"]["file_dir"] + " v" + current_version
else:
project_settings["file_path"] = file_path
status_message.displayMessage("Loaded: " + file_path + ".", true)
Expand Down Expand Up @@ -935,7 +956,7 @@ func saveAt(path, backup = false, update_path = false):
else:
if update_path:
user_settings["filedialog_dir"] = $Layer3_Popups/SaveDialog.current_dir
get_viewport().title = "Puyo Edit - Puyo Puyo Animation Editor :" + path
get_viewport().title = "Puyo Edit - Puyo Puyo Animation Editor :" + path + " v" + current_version
status_message.displayMessage("Saved at: " + path, true)
new_json = JSON.stringify(new_json, "\t", false)
var file = FileAccess.open(path, FileAccess.WRITE)
Expand Down Expand Up @@ -1755,3 +1776,15 @@ func _on_update_confirmed():
func clipboardElement():
pass



func _on_btn_autosave_pressed():
user_settings["autobackup"] = $Layer3_Popups/Settings/Node2D/btn_autosave.button_pressed


func _on_autosave_interval_changed(_dummy):
user_settings["backuptimer"] = $Layer3_Popups/Settings/Node2D/autosave_interval.value * 60


func _on_btn_check_updates_pressed():
user_settings["auto_update"] = $Layer3_Popups/Settings/Node2D/btn_check_updates.button_pressed

0 comments on commit 0def9f3

Please sign in to comment.