Skip to content

Commit 464cde4

Browse files
authored
Use constants where possible (#365)
1 parent a8cb9fb commit 464cde4

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

addons/beehave/debug/new_graph_edit.gd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func process_tick(instance_id: int, status: int) -> void:
164164
node.text = "Status: %s" % get_status(status)
165165
node.set_status(status)
166166
node.set_meta("status", status)
167-
if status == 0 or status == 2:
167+
if status == BeehaveNode.SUCCESS or status == BeehaveNode.RUNNING:
168168
if not active_nodes.has(node.name):
169169
active_nodes.push_back(node.name)
170170

@@ -176,13 +176,13 @@ func process_end(instance_id: int) -> void:
176176
for child in _get_child_nodes():
177177
var status := child.get_meta("status", -1)
178178
match status:
179-
0:
179+
BeehaveNode.SUCCESS:
180180
active_nodes.erase(child.name)
181181
child.set_color(SUCCESS_COLOR)
182-
1:
182+
BeehaveNode.FAILURE:
183183
active_nodes.erase(child.name)
184184
child.set_color(INACTIVE_COLOR)
185-
2:
185+
BeehaveNode.RUNNING:
186186
child.set_color(ACTIVE_COLOR)
187187
_:
188188
child.text = " "
@@ -213,7 +213,7 @@ func _get_connection_line(from_position: Vector2, to_position: Vector2) -> Packe
213213

214214
func _get_elbow_connection_line(from_position: Vector2, to_position: Vector2) -> PackedVector2Array:
215215
var points: PackedVector2Array
216-
216+
217217
points.push_back(from_position)
218218

219219
var mid_position := ((to_position + from_position) / 2).round()
@@ -225,7 +225,7 @@ func _get_elbow_connection_line(from_position: Vector2, to_position: Vector2) ->
225225
points.push_back(Vector2(to_position.x, mid_position.y))
226226

227227
points.push_back(to_position)
228-
228+
229229
return points
230230

231231

@@ -265,12 +265,12 @@ func _draw() -> void:
265265
var input_port_position: Vector2
266266

267267
var scale_factor: float = from.get_rect().size.x / from.size.x
268-
268+
269269
var line := _get_elbow_connection_line(
270270
from.position + from.get_custom_output_port_position(horizontal_layout) * scale_factor,
271271
to.position + to.get_custom_input_port_position(horizontal_layout) * scale_factor
272272
)
273-
273+
274274
var curve = Curve2D.new()
275275
for l in line:
276276
curve.add_point(l)

addons/beehave/debug/new_graph_node.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func _init(frames:RefCounted, horizontal: bool = false) -> void:
5050
func _ready() -> void:
5151
custom_minimum_size = Vector2(50, 50) * BeehaveUtils.get_editor_scale()
5252
draggable = false
53-
53+
5454
add_theme_color_override("close_color", Color.TRANSPARENT)
5555
add_theme_icon_override("close", ImageTexture.new())
5656

@@ -119,9 +119,9 @@ func get_custom_output_port_position(horizontal: bool) -> Vector2:
119119

120120
func set_status(status: int) -> void:
121121
match status:
122-
0: _set_stylebox_overrides(frames.panel_success, frames.titlebar_success)
123-
1: _set_stylebox_overrides(frames.panel_failure, frames.titlebar_failure)
124-
2: _set_stylebox_overrides(frames.panel_running, frames.titlebar_running)
122+
BeehaveNode.SUCCESS: _set_stylebox_overrides(frames.panel_success, frames.titlebar_success)
123+
BeehaveNode.FAILURE: _set_stylebox_overrides(frames.panel_failure, frames.titlebar_failure)
124+
BeehaveNode.RUNNING: _set_stylebox_overrides(frames.panel_running, frames.titlebar_running)
125125
_: _set_stylebox_overrides(frames.panel_normal, frames.titlebar_normal)
126126

127127

addons/beehave/debug/old_graph_edit.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func process_tick(instance_id: int, status: int) -> void:
162162
node.text = "Status: %s" % get_status(status)
163163
node.set_status(status)
164164
node.set_meta("status", status)
165-
if status == 0 or status == 2:
165+
if status == BeehaveNode.SUCCESS or status == BeehaveNode.RUNNING:
166166
if not active_nodes.has(node.name):
167167
active_nodes.push_back(node.name)
168168

@@ -174,13 +174,13 @@ func process_end(instance_id: int) -> void:
174174
for child in _get_child_nodes():
175175
var status := child.get_meta("status", -1)
176176
match status:
177-
0:
177+
BeehaveNode.SUCCESS:
178178
active_nodes.erase(child.name)
179179
child.set_color(SUCCESS_COLOR)
180-
1:
180+
BeehaveNode.FAILURE:
181181
active_nodes.erase(child.name)
182182
child.set_color(INACTIVE_COLOR)
183-
2:
183+
BeehaveNode.RUNNING:
184184
child.set_color(ACTIVE_COLOR)
185185
_:
186186
child.text = " "

addons/beehave/debug/old_graph_node.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ func set_status(status: int) -> void:
117117

118118
func _get_stylebox(status: int) -> StyleBox:
119119
match status:
120-
0:
120+
BeehaveNode.SUCCESS:
121121
return frames.success
122-
1:
122+
BeehaveNode.FAILURE:
123123
return frames.failure
124-
2:
124+
BeehaveNode.RUNNING:
125125
return frames.running
126126
_:
127127
return frames.normal

0 commit comments

Comments
 (0)