Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Commit

Permalink
Added comments to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sitton76 committed Jul 23, 2023
1 parent 71186dc commit 78813d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 10 additions & 3 deletions assets/objects/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ const offset_value = 32

onready var L_window = $Left_window/Container
onready var R_window = $Right_window/Container
var loaded_json_file
var loaded_json_file #Holds data pulled from shipofharkinian.json file after being loaded.
var opened_dialog = false
var dia_ref #unintiated reference to the popup dialog box that is used when selecting files/folders
var soh_folder = ""


func populate_list(entry : String, container : Node, group_name : String):
#Populates a given field with entry_button nodes representing a .otr file
var new_instance = entry_button_file.instance()
Expand All @@ -23,7 +22,7 @@ func populate_list(entry : String, container : Node, group_name : String):
new_instance.toggle_dir_buttons(true)

func handle_offset():
#Handles spacing of listings
#Handles spacing between items in lists.
var side_groups = ["R-side", "L-side"]
for group in side_groups:
var iter_count = 1
Expand Down Expand Up @@ -86,6 +85,7 @@ func purge_mod_entries():
opened_dialog = false

func read_json_file():
#parses existing shipofharkinian.json file if it exists.
var dir = Directory.new()
if dir.file_exists(soh_folder + "/shipofharkinian.json") == true:
var file = File.new()
Expand All @@ -95,6 +95,8 @@ func read_json_file():
check_if_mods_is_on_list()

func check_if_mods_is_on_list():
#When loading the .json file, it will read through it and add mods already in the load order in the file to the
#Load order list in the application
if loaded_json_file.has("Mod-Load-Order"):
if loaded_json_file.get("Mod-Load-Order").has("List-size"):
var mod_count = loaded_json_file.get("Mod-Load-Order").get("List-size")
Expand All @@ -108,6 +110,7 @@ func check_if_mods_is_on_list():


func find_soh_config(path : String) -> bool:
#Checks if it can find the .json config file
var config_file_name = "/shipofharkinian.json"
var file = File.new()
if file.file_exists(path + config_file_name) == true:
Expand All @@ -119,6 +122,7 @@ func clear_selection(group : String):
nodes.queue_free()

func check_if_can_save():
#Prevents clearing list when empty, and saving when no soh_path is found
if L_window.get_child_count() != 0:
$Middle_window/VBoxContainer/clear_load_list.disabled = false
else:
Expand All @@ -137,6 +141,7 @@ func check_if_on_list(file_name : String, group : String) -> bool:
return false

func on_soh_folder_select(opened_path):
#Opens dialog to select folder containing shipofharkinian.json file.
dia_ref.queue_free()
opened_dialog = false
var dir = Directory.new()
Expand Down Expand Up @@ -167,6 +172,7 @@ func on_dialog_close():
opened_dialog = false

func _on_save_list_pressed():
#Button to start either Adding/editing entries for mod load order, or removing it.
if soh_folder != "":
if L_window.get_child_count() != 0:
save_mod_list()
Expand All @@ -176,6 +182,7 @@ func _on_save_list_pressed():
$msg_label.display_text("Please select a SoH folder first.")

func _on_clear_load_list_pressed():
#Empties Load order list and repopulatates the Mods list
for nodes in get_tree().get_nodes_in_group("L-side"):
swap_sides(nodes)

Expand Down
4 changes: 4 additions & 0 deletions assets/objects/entry_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ func get_text() -> String:
return $move_side_button.text

func toggle_dir_buttons(state : bool):
#toggles visibility of the up and down buttons, intended to only be used on the Load Order list
$Up_button.visible = state
$Down_button.visible = state

func _on_move_side_button_pressed():
#When clicked, it will tell the main scene to move this object to the other side.
get_tree().current_scene.swap_sides(self)

func _on_Up_button_pressed():
#Moves item up one level on the Load Order List if it is not the top
if get_index() != 0:
get_parent().move_child(self, get_index() - 1)
get_tree().current_scene.handle_offset()

func _on_Down_button_pressed():
#Move item down one level on the Load Order List
get_parent().move_child(self, get_index() + 1)
get_tree().current_scene.handle_offset()

0 comments on commit 78813d1

Please sign in to comment.