Skip to content

Commit

Permalink
Code Style cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jowan-Spooner committed Jul 4, 2024
1 parent d77c31d commit 72ffbe9
Show file tree
Hide file tree
Showing 96 changed files with 312 additions and 304 deletions.
2 changes: 1 addition & 1 deletion addons/dialogic/Core/DialogicUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static func get_scene_export_defaults(node:Node) -> Dictionary:
if !Engine.get_main_loop().has_meta('dialogic_scene_export_defaults'):
Engine.get_main_loop().set_meta('dialogic_scene_export_defaults', {})
var defaults := {}
var property_info :Array[Dictionary] = node.script.get_script_property_list()
var property_info: Array[Dictionary] = node.script.get_script_property_list()
for i in property_info:
if i['usage'] & PROPERTY_USAGE_EDITOR:
defaults[i['name']] = node.get(i['name'])
Expand Down
2 changes: 1 addition & 1 deletion addons/dialogic/Core/index_class.gd
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func _get_layout_parts() -> Array[Dictionary]:
## Helper that allows scanning sub directories that might be layout parts or styles
func scan_for_layout_parts() -> Array[Dictionary]:
var dir := DirAccess.open(this_folder)
var style_list :Array[Dictionary] = []
var style_list: Array[Dictionary] = []
if !dir:
return style_list
dir.list_dir_begin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func _recheck(data: Dictionary, force:=false):

## On any change, save the export override to the portrait items metadata.
func set_export_override(property_name:String, value:String = "") -> void:
var data:Dictionary = selected_item.get_metadata(0)
var data: Dictionary = selected_item.get_metadata(0)
if !data.has('export_overrides'):
data['export_overrides'] = {}
if !value.is_empty():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ func _load_portrait_data(data:Dictionary) -> void:


func _on_portrait_scale_value_changed(value:float) -> void:
var data:Dictionary = selected_item.get_metadata(0)
var data: Dictionary = selected_item.get_metadata(0)
data['scale'] = value/100.0
update_preview.emit()
changed.emit()


func _on_portrait_mirror_toggled(button_pressed:bool)-> void:
var data:Dictionary = selected_item.get_metadata(0)
var data: Dictionary = selected_item.get_metadata(0)
data['mirror'] = button_pressed
update_preview.emit()
changed.emit()


func _on_ignore_scale_toggled(button_pressed:bool) -> void:
var data:Dictionary = selected_item.get_metadata(0)
var data: Dictionary = selected_item.get_metadata(0)
data['ignore_char_scale'] = button_pressed
update_preview.emit()
changed.emit()


func _on_portrait_offset_value_changed(property:String, value:Vector2) -> void:
var data:Dictionary = selected_item.get_metadata(0)
var data: Dictionary = selected_item.get_metadata(0)
data['offset'] = value
update_preview.emit()
changed.emit()
6 changes: 3 additions & 3 deletions addons/dialogic/Editor/CharacterEditor/character_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var current_scene_path: String = ""

# References
var selected_item: TreeItem
var def_portrait_path :String= DialogicUtil.get_module_path('Character').path_join('default_portrait.tscn')
var def_portrait_path: String = DialogicUtil.get_module_path('Character').path_join('default_portrait.tscn')


######### EDITOR STUFF and LOADING/SAVING ######################################
Expand All @@ -27,7 +27,7 @@ func _register() -> void:
editors_manager.register_resource_editor("dch", self)

## Add an "add character" button
var add_character_button = editors_manager.add_icon_button(
var add_character_button: Button = editors_manager.add_icon_button(
load("res://addons/dialogic/Editor/Images/Toolbar/add-character.svg"),
'Add Character',
self)
Expand Down Expand Up @@ -314,7 +314,7 @@ func import_portraits_from_folder(path:String) -> void:

var dir := DirAccess.open(path)
dir.list_dir_begin()
var file_name :String = dir.get_next()
var file_name: String = dir.get_next()
while file_name != "":
if not dir.current_is_dir():
var file_lower := file_name.to_lower()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extends Control
signal changed

## Reference to the character editor, set when instantiated
var character_editor:Control
var character_editor: Control

## If not empty, a hint icon is added to the section title.
var hint_text := ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ signal changed
signal update_preview

## Reference to the character editor, set when instantiated
var character_editor:Control
var character_editor: Control
## Reference to the selected portrait item.
## `selected_item.get_metadata(0)` can access the portraits data
var selected_item :TreeItem = null
var selected_item: TreeItem = null

## If not empty a hint icon is added to the section title
var hint_text := ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func create_necessary_group_items(path: String) -> TreeItem:
if current_group_nodes.has(item_path+"/"+i):
last_item = current_group_nodes[item_path+"/"+i]
else:
var new_item:TreeItem = add_portrait_group(i, last_item)
var new_item: TreeItem = add_portrait_group(i, last_item)
current_group_nodes[item_path+"/"+i] = new_item
last_item = new_item
return last_item
Expand Down Expand Up @@ -97,7 +97,7 @@ func _can_drop_data(position: Vector2, data: Variant) -> bool:
func _drop_data(position: Vector2, item: Variant) -> void:
var to_item := get_item_at_position(position)
if to_item:
var test_item:= to_item
var test_item := to_item
while true:
if test_item == item:
return
Expand Down
4 changes: 2 additions & 2 deletions addons/dialogic/Editor/Common/BrowserItem.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ signal middle_clicked
signal double_clicked
signal focused

var base_size = 1
var base_size := 1


func _ready() -> void:
if get_parent() is SubViewport:
return

%Name.add_theme_font_override("font", get_theme_font("bold", "EditorFonts"))
custom_minimum_size = base_size*Vector2(200, 150) * DialogicUtil.get_editor_scale()
custom_minimum_size = base_size * Vector2(200, 150) * DialogicUtil.get_editor_scale()
%CurrentIcon.texture = get_theme_icon("Favorites", "EditorIcons")
if %Image.texture == null:
%Image.texture = get_theme_icon("ImportFail", "EditorIcons")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extends PanelContainer
enum Modes {EDIT, ADD}

var mode := Modes.EDIT
var item :TreeItem = null
var item: TreeItem = null


func _ready() -> void:
Expand Down Expand Up @@ -86,7 +86,7 @@ func get_character_suggestions(search_text:String) -> Dictionary:
var suggestions := {}

#override the previous _character_directory with the meta, specifically for searching otherwise new nodes wont work
var _character_directory = DialogicResourceUtil.get_character_directory()
var _character_directory := DialogicResourceUtil.get_character_directory()

var icon := load("res://addons/dialogic/Editor/Images/Resources/character.svg")
suggestions['(No one)'] = {'value':null, 'editor_icon':["GuiRadioUnchecked", "EditorIcons"]}
Expand Down
24 changes: 12 additions & 12 deletions addons/dialogic/Editor/Common/broken_reference_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extends VSplitContainer

## This manager shows a list of changed references and allows searching for them and replacing them.

var reference_changes :Array[Dictionary] = []:
var reference_changes: Array[Dictionary] = []:
set(changes):
reference_changes = changes
update_indicator()
Expand Down Expand Up @@ -55,7 +55,7 @@ func open() -> void:
%ChangeTree.set_column_custom_minimum_width(2, 50)
var categories := {null:%ChangeTree.get_root()}
for i in reference_changes:
var parent : TreeItem = null
var parent: TreeItem = null
if !i.get('category', null) in categories:
parent = %ChangeTree.create_item()
parent.set_text(1, i.category)
Expand All @@ -64,7 +64,7 @@ func open() -> void:
else:
parent = categories[i.get('category')]

var item :TreeItem = %ChangeTree.create_item(parent)
var item: TreeItem = %ChangeTree.create_item(parent)
item.set_text(1, i.what+" -> "+i.forwhat)
item.add_button(1, get_theme_icon("Edit", "EditorIcons"), 1, false, 'Edit')
item.add_button(1, get_theme_icon("Remove", "EditorIcons"), 0, false, 'Remove Change from List')
Expand Down Expand Up @@ -98,8 +98,8 @@ func _on_change_tree_item_edited() -> void:


func _on_check_button_pressed() -> void:
var to_be_checked :Array[Dictionary]= []
var item :TreeItem = %ChangeTree.get_root()
var to_be_checked: Array[Dictionary]= []
var item: TreeItem = %ChangeTree.get_root()
while item.get_next_visible():
item = item.get_next_visible()

Expand Down Expand Up @@ -245,7 +245,7 @@ func get_line(string:String, at_index:int) -> String:


func update_count_coloring() -> void:
var item :TreeItem = %ChangeTree.get_root()
var item: TreeItem = %ChangeTree.get_root()
while item.get_next_visible():
item = item.get_next_visible()

Expand All @@ -264,9 +264,9 @@ func update_count_coloring() -> void:


func _on_replace_pressed() -> void:
var to_be_replaced :Array[Dictionary]= []
var item :TreeItem = %ReferenceTree.get_root()
var affected_timelines :Array[String]= []
var to_be_replaced: Array[Dictionary]= []
var item: TreeItem = %ReferenceTree.get_root()
var affected_timelines: Array[String]= []

while item.get_next_visible():
item = item.get_next_visible()
Expand All @@ -284,7 +284,7 @@ func _on_replace_pressed() -> void:

func replace(timelines:Array[String], replacement_info:Array[Dictionary]) -> void:
var reopen_timeline := ""
var timeline_editor :DialogicEditor = find_parent('EditorView').editors_manager.editors['Timeline'].node
var timeline_editor: DialogicEditor = find_parent('EditorView').editors_manager.editors['Timeline'].node
if timeline_editor.current_resource != null and timeline_editor.current_resource.resource_path in timelines:
reopen_timeline = timeline_editor.current_resource.resource_path
find_parent('EditorView').editors_manager.clear_editor(timeline_editor)
Expand All @@ -295,7 +295,7 @@ func replace(timelines:Array[String], replacement_info:Array[Dictionary]) -> voi
%State.text = "Loading '"+timeline_path+"'"

var timeline_file := FileAccess.open(timeline_path, FileAccess.READ_WRITE)
var timeline_text :String = timeline_file.get_as_text()
var timeline_text: String = timeline_file.get_as_text()
var timeline_events := timeline_text.split('\n')
timeline_file.close()

Expand Down Expand Up @@ -343,7 +343,7 @@ func update_indicator() -> void:


func close() -> void:
var item :TreeItem = %ChangeTree.get_root()
var item: TreeItem = %ChangeTree.get_root()
if item:
while item.get_next_visible():
item = item.get_next_visible()
Expand Down
2 changes: 1 addition & 1 deletion addons/dialogic/Editor/Common/hint_tooltip_icon.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@tool
extends TextureRect

@export_multiline var hint_text = ""
@export_multiline var hint_text := ""

func _ready() -> void:
if owner and owner.get_parent() is SubViewport:
Expand Down
4 changes: 2 additions & 2 deletions addons/dialogic/Editor/Common/reference_manager_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extends Window
enum Where {EVERYWHERE, BY_CHARACTER, TEXTS_ONLY}
enum Types {TEXT, VARIABLE, PORTRAIT, CHARACTER_NAME, TIMELINE_NAME}

var icon_button :Button = null
var icon_button: Button = null


func _ready() -> void:
Expand All @@ -31,7 +31,7 @@ func _ready() -> void:

icon_button.add_child(dot)

var old_changes :Array = DialogicUtil.get_editor_setting('reference_changes', [])
var old_changes: Array = DialogicUtil.get_editor_setting('reference_changes', [])
if !old_changes.is_empty():
broken_manager.reference_changes = old_changes

Expand Down
4 changes: 2 additions & 2 deletions addons/dialogic/Editor/Common/sidebar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ signal file_activated(file_path)

signal content_item_activated(item_name)

@onready var editors_manager = get_parent().get_parent()
@onready var editors_manager: Node = get_parent().get_parent()


func _ready() -> void:
Expand Down Expand Up @@ -62,7 +62,7 @@ func clean_resource_list(resources_list:Array = []) -> PackedStringArray:


func update_resource_list(resources_list:PackedStringArray = []) -> void:
var filter :String = %Search.text
var filter: String = %Search.text
var current_file := ""
if editors_manager.current_editor and editors_manager.current_editor.current_resource:
current_file = editors_manager.current_editor.current_resource.resource_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func fill_table() -> void:

func _on_identifier_table_item_edited() -> void:
var item: TreeItem = %IdentifierTable.get_edited()
var new_identifier : String = item.get_text(1)
var new_identifier: String = item.get_text(1)


if new_identifier == item.get_metadata(1):
Expand Down
2 changes: 1 addition & 1 deletion addons/dialogic/Editor/Common/update_install_window.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@tool
extends Control

var current_info : Dictionary = {}
var current_info := {}
@onready var editor_view := find_parent('EditorView')


Expand Down
16 changes: 8 additions & 8 deletions addons/dialogic/Editor/Common/update_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ enum DownloadResult {SUCCESS, FAILURE}
enum ReleaseState {ALPHA, BETA, STABLE}

const REMOTE_RELEASES_URL := "https://api.github.com/repos/dialogic-godot/dialogic/releases"
const TEMP_FILE_NAME = "user://temp.zip"
const TEMP_FILE_NAME := "user://temp.zip"

var current_version : String = ""
var current_version := ""
var update_info: Dictionary
var current_info: Dictionary

var version_indicator :Button
var version_indicator: Button

func _ready() -> void:
request_update_check()
Expand All @@ -43,14 +43,14 @@ func _on_UpdateCheck_request_completed(result:int, response_code:int, headers:Pa
return

# Work out the next version from the releases information on GitHub
var response :Variant= JSON.parse_string(body.get_string_from_utf8())
var response: Variant = JSON.parse_string(body.get_string_from_utf8())
if typeof(response) != TYPE_ARRAY: return


var current_release_info := get_release_tag_info(get_current_version())

# GitHub releases are in order of creation, not order of version
var versions :Array = (response as Array).filter(compare_versions.bind(current_release_info))
var versions: Array = (response as Array).filter(compare_versions.bind(current_release_info))
if versions.size() > 0:
update_info = versions[0]
update_check_completed.emit(UpdateCheckResult.UPDATE_AVAILABLE)
Expand Down Expand Up @@ -98,7 +98,7 @@ func get_release_tag_info(release_tag:String) -> Dictionary:
if !result:
return {}

var info:Dictionary = {'tag':release_tag}
var info: Dictionary = {'tag':release_tag}
info['major'] = float(result.get_string('major'))
info['minor'] = int(result.get_string('minor'))

Expand Down Expand Up @@ -141,7 +141,7 @@ func _on_DownloadRequest_completed(result:int, response_code:int, headers:Packed
zip_reader.open(TEMP_FILE_NAME)
var files: PackedStringArray = zip_reader.get_files()

var base_path = files[0].path_join('addons/')
var base_path: String = files[0].path_join('addons/')
for path in files:
if not "dialogic/" in path:
continue
Expand Down Expand Up @@ -169,7 +169,7 @@ func setup_version_indicator() -> void:


func _on_update_check_completed(result:int):
var result_color : Color
var result_color: Color
match result:
UpdateCheckResult.UPDATE_AVAILABLE:
result_color = version_indicator.get_theme_color("warning_color", "Editor")
Expand Down
Loading

0 comments on commit 72ffbe9

Please sign in to comment.