Skip to content

Commit

Permalink
fix every warning accross the entire addon
Browse files Browse the repository at this point in the history
  • Loading branch information
HungryProton committed Oct 21, 2021
1 parent 2717b63 commit fbf846a
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 45 deletions.
4 changes: 4 additions & 0 deletions plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func _enter_tree():

_editor_selection = get_editor_interface().get_selection()
_editor_selection.connect("selection_changed", self, "_on_selection_changed")

# warning-ignore:return_value_discarded
connect("scene_changed", self, "_on_scene_changed")


Expand Down Expand Up @@ -137,6 +139,8 @@ func _setup_options_panel() -> void:
])
_gizmo_options = preload("./src/tools/path_gizmo/gizmo_options.tscn").instance()
_options_root.add_child(_gizmo_options)

# warning-ignore:return_value_discarded
_gizmo_options.connect("snap_to_colliders_enabled", self, "_on_snap_to_colliders_enabled")
_gizmo_options.visible = false

Expand Down
4 changes: 2 additions & 2 deletions src/common/poisson_disc_sampling.gd
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ func _init_vars() -> void:
push_error("Unrecognized shape!!! Please input a valid shape")

_cell_size = _radius / sqrt(2)
_cols = max(floor(_sample_region_rect.size.x / _cell_size), 1)
_rows = max(floor(_sample_region_rect.size.y / _cell_size), 1)
_cols = int(max(floor(_sample_region_rect.size.x / _cell_size), 1))
_rows = int(max(floor(_sample_region_rect.size.y / _cell_size), 1))
# scale the cell size in each axis
_cell_size_scaled.x = _sample_region_rect.size.x / _cols
_cell_size_scaled.y = _sample_region_rect.size.y / _rows
Expand Down
2 changes: 1 addition & 1 deletion src/core/scatter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func _get(property):
return null


func _set(property, value):
func _set(property, _value):
if not Engine.editor_hint:
return false

Expand Down
1 change: 1 addition & 0 deletions src/core/scatter_exclude_path.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends "scatter_path.gd"


func _ready():
# warning-ignore:return_value_discarded
connect("curve_updated", self, "update")


Expand Down
11 changes: 0 additions & 11 deletions src/core/scatter_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,6 @@ func update_shadows() -> void:
return

mmi.cast_shadow = cast_shadow
return

match cast_shadow:
0:
mmi.cast_shadows = GeometryInstance.SHADOW_CASTING_SETTING_OFF
1:
mmi.cast_shadows = GeometryInstance.SHADOW_CASTING_SETTING_ON
2:
mmi.cast_shadows = GeometryInstance.SHADOW_CASTING_SETTING_DOUBLE_SIDED
3:
mmi.cast_shadows = GeometryInstance.SHADOW_CASTING_SETTING_SHADOWS_ONLY


func _get_mesh_from_scene(node):
Expand Down
3 changes: 2 additions & 1 deletion src/core/scatter_path.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var _previous_transform: Transform

func _ready():
set_notify_transform(true)
self.connect("curve_changed", self, "_on_curve_changed")
# warning-ignore:return_value_discarded
connect("curve_changed", self, "_on_curve_changed")
_update_from_curve()


Expand Down
2 changes: 1 addition & 1 deletion src/core/transforms.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func remove(count: int) -> void:

func resize(count: int) -> void:
if max_count >= 0:
count = min(count, max_count)
count = int(min(count, max_count))

var size = list.size()
if count > size:
Expand Down
5 changes: 2 additions & 3 deletions src/modifiers/add_around_point_grid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ func _process_transforms(transforms, global_seed) -> void:
var size = bounds_max - bounds_min
var half_size = size * 0.5
var center: Vector3 = bounds_min + half_size
var width: int = ceil(size.x / x_spacing)
var length: int = ceil(size.z / z_spacing)
var width := int(ceil(size.x / x_spacing))
var length := int(ceil(size.z / z_spacing))
var max_count: int = width * length
var gt = transforms.path.get_global_transform()

for i in max_count:
var pos = Vector3.ZERO
Expand Down
2 changes: 1 addition & 1 deletion src/modifiers/base_modifier.gd
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func process_transforms(transforms, global_seed) -> void:


# Override in inherited class
func _process_transforms(transforms, global_seed) -> void:
func _process_transforms(_transforms, _global_seed) -> void:
pass


Expand Down
2 changes: 1 addition & 1 deletion src/modifiers/base_point_modifier.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func is_inside(pos: Vector3, p) -> bool:
return distance_to_point <= max_distance


func _process_transforms(transforms, global_seed) -> void:
func _process_transforms(transforms, _global_seed) -> void:
if node_name.empty():
warning += "You must select a node for this modifier to work."
_notify_warning_changed()
Expand Down
4 changes: 2 additions & 2 deletions src/modifiers/clusterize.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func _init() -> void:
category = "Edit"


func _process_transforms(transforms, global_seed) -> void:
func _process_transforms(transforms, _global_seed) -> void:
if not ResourceLoader.exists(mask):
warning += "The specified file " + mask + " could not be loaded"
return
Expand All @@ -26,7 +26,7 @@ func _process_transforms(transforms, global_seed) -> void:
return

var image: Image = texture.get_data()
image.decompress()
var _err = image.decompress()
image.lock()

var width = image.get_width()
Expand Down
2 changes: 1 addition & 1 deletion src/modifiers/distribute_along_even.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func _init() -> void:
func _process_transforms(transforms, _seed) -> void:
var path = transforms.path
var length: float = path.curve.get_baked_length()
var total_count: int = round(length / interval)
var total_count := int(round(length / interval))
var stepped_length: float = total_count * interval

if total_count == 0:
Expand Down
4 changes: 2 additions & 2 deletions src/modifiers/distribute_inside_grid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func _process_transforms(transforms, global_seed) -> void:
var half_size = size * 0.5
var height: float = transforms.path.bounds_max.y

var width: int = ceil(size.x / x_spacing)
var length: int = ceil(size.z / z_spacing)
var width := int(ceil(size.x / x_spacing))
var length := int(ceil(size.z / z_spacing))
var max_count: int = width * length
transforms.resize(max_count)

Expand Down
5 changes: 2 additions & 3 deletions src/modifiers/randomize_rotation.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func _process_transforms(transforms, global_seed) -> void:

var t: Transform
var b: Basis
var s: Vector3

var gt: Transform = transforms.path.get_global_transform()
var gb: Basis = gt.basis
Expand Down Expand Up @@ -60,8 +59,8 @@ func _random_vec3() -> Vector3:
return vec3


func _random_angle(rotation: float, snap: float) -> float:
return deg2rad(stepify(_rng.randf_range(-1.0, 1.0) * rotation, snap))
func _random_angle(rot: float, snap: float) -> float:
return deg2rad(stepify(_rng.randf_range(-1.0, 1.0) * rot, snap))


func _clamp_vector(vec3, vmin, vmax) -> Vector3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func can_handle(object):
return object is _namespace.Scatter


func parse_property(object, type, path, hint, hint_text, usage):
func parse_property(object, type, path, _hint, hint_text, _usage):
if type == TYPE_OBJECT and hint_text == "ScatterModifierStack":
var editor_property = _editor.new()
editor_property.set_node(object)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
tool
extends Button

signal add_modifier


onready var _popup = $ModifiersPopup
var _modifiers := []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ var _previous
var _locked := false


func set_parameter_name(text: String) -> void:
func set_parameter_name(_text: String) -> void:
pass


func set_hint_string(hint: String) -> void:
func set_hint_string(_hint: String) -> void:
pass


Expand All @@ -27,7 +27,7 @@ func get_value():
pass


func _set_value(val):
func _set_value(_val):
pass


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# warning-ignore-all:return_value_discarded

tool
extends Control

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func _ready() -> void:
_popup.add_check_item(layer_name, _layer_count - 1 - i)

_sync_popup_state()

# warning-ignore:return_value_discarded
_popup.connect("id_pressed", self, "_on_id_pressed")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ onready var _check_box: CheckBox = $CheckBox


func _ready() -> void:
# warning-ignore:return_value_discarded
_check_box.connect("toggled", self, "_on_value_changed")


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# warning-ignore-all:return_value_discarded

tool
extends "base_parameter.gd"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# warning-ignore-all:return_value_discarded

tool
extends "base_parameter.gd"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ onready var _warning_popup: AcceptDialog = $AcceptDialog


func _ready() -> void:
# warning-ignore:return_value_discarded
_margin_container.connect("resized", self, "_on_child_resized")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ var _save_popup: WindowDialog
func _ready() -> void:
_popup = get_popup()
_popup.clear()

# warning-ignore:return_value_discarded
_popup.connect("id_pressed", self, "_on_id_pressed")

_popup.add_icon_item(_save_icon, "Save Preset", 0)
_popup.add_icon_item(_load_icon, "Load Preset", 1)

_load_popup = get_node("LoadPresetPopup")
_save_popup = get_node("SavePresetPopup")

Expand Down
17 changes: 10 additions & 7 deletions src/tools/modifier_stack_inspector_plugin/ui/stack_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ var _root: Control
var _scatter
var _modifier_stack
var _modifier_panel = preload("./modifier_panel.tscn")
var _ready := false
var _is_ready := false


func _ready():
_modifiers_popup = get_node(modifiers_popup)
_root = get_node(root)

# warning-ignore:return_value_discarded
_modifiers_popup.connect("add_modifier", self, "_on_add_modifier")
_ready = true

_is_ready = true
rebuild_ui()


Expand All @@ -30,7 +33,7 @@ func set_node(node) -> void:


func rebuild_ui() -> void:
if not _ready:
if not _is_ready:
return

_validate_stack_connections()
Expand Down Expand Up @@ -68,11 +71,11 @@ func _validate_stack_connections() -> void:
_on_load_preset("default")


func _set_children_owner(root: Node, node: Node):
func _set_children_owner(new_owner: Node, node: Node):
for child in node.get_children():
child.set_owner(root)
child.set_owner(new_owner)
if child.get_children().size() > 0:
_set_children_owner(root, child)
_set_children_owner(new_owner, child)


func _get_root_folder() -> String:
Expand Down Expand Up @@ -126,7 +129,7 @@ func _on_save_preset(preset_name) -> void:
return

var preset_path = _get_root_folder() + "/presets/" + preset_name + ".tscn"
ResourceSaver.save(preset_path, packed_scene)
var _err= ResourceSaver.save(preset_path, packed_scene)


func _on_load_preset(preset_name) -> void:
Expand Down
1 change: 0 additions & 1 deletion src/tools/path_gizmo/scatter_path_gizmo_plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ func _on_curve_changed() -> void:

var previous_count: int = _previous_state.point_count
var previous_pos: Vector3 = _previous_state.position
var previous_version: int = _previous_state.version

_previous_state.point_count = current_count
_previous_state.position = current_position
Expand Down

0 comments on commit fbf846a

Please sign in to comment.