Skip to content

Commit eae9f2f

Browse files
Improve min and max of number fields in visual editor (#2318)
The number field now defaults to min max of -INF and INF. A few events now specify a min (mainly animation lengths). This allows giving any numers in conditions and in the Set Variable event, which is quite nice.
1 parent b5271df commit eae9f2f

File tree

5 files changed

+24
-36
lines changed

5 files changed

+24
-36
lines changed

addons/dialogic/Editor/Events/Fields/field_condition.tscn

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[ext_resource type="PackedScene" uid="uid://dm5hxmhyyxgq" path="res://addons/dialogic/Editor/Events/Fields/field_bool_check.tscn" id="5_1x02a"]
88
[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" id="6_5a2xd"]
99

10-
[sub_resource type="Image" id="Image_cgfp5"]
10+
[sub_resource type="Image" id="Image_je1w7"]
1111
data = {
1212
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
1313
"format": "RGBA8",
@@ -16,8 +16,8 @@ data = {
1616
"width": 16
1717
}
1818

19-
[sub_resource type="ImageTexture" id="ImageTexture_4jujf"]
20-
image = SubResource("Image_cgfp5")
19+
[sub_resource type="ImageTexture" id="ImageTexture_81s3d"]
20+
image = SubResource("Image_je1w7")
2121

2222
[node name="Field_Condition" type="HBoxContainer"]
2323
offset_right = 77.0
@@ -94,7 +94,7 @@ unique_name_in_owner = true
9494
layout_mode = 2
9595
tooltip_text = "Use complex expression"
9696
toggle_mode = true
97-
icon = SubResource("ImageTexture_4jujf")
97+
icon = SubResource("ImageTexture_81s3d")
9898

9999
[connection signal="value_changed" from="SimpleEditor/Value1Variable" to="." method="_on_value_1_variable_value_changed"]
100100
[connection signal="text_changed" from="ComplexEditor" to="." method="_on_complex_editor_text_changed"]

addons/dialogic/Editor/Events/Fields/field_number.gd

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ extends DialogicVisualEditorField
44

55
## Event block field for integers and floats. Improved version of the native spinbox.
66

7-
@export var allow_string : bool = false
7+
@export var allow_string: bool = false
88
@export var step: float = 0.1
99
@export var enforce_step: bool = true
10-
@export var min: float = 0
11-
@export var max: float= 999
10+
@export var min: float = -INF
11+
@export var max: float = INF
1212
@export var value = 0.0
1313
@export var prefix: String = ""
1414
@export var suffix: String = ""
@@ -24,7 +24,6 @@ func _ready() -> void:
2424

2525
update_prefix(prefix)
2626
update_suffix(suffix)
27-
$Value_Panel.add_theme_stylebox_override('panel', get_theme_stylebox('panel', 'DialogicEventEdit'))
2827

2928

3029
func _load_display_info(info: Dictionary) -> void:
@@ -157,6 +156,8 @@ func _on_decrement_button_down(button: NodePath) -> void:
157156

158157

159158
func _on_value_text_submitted(new_text: String, no_signal:= false) -> void:
159+
if new_text.is_empty() and not allow_string:
160+
new_text = "0.0"
160161
if new_text.is_valid_float():
161162
var temp: float = min(max(new_text.to_float(), min), max)
162163
if !enforce_step:

addons/dialogic/Editor/Events/Fields/field_number.tscn

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ grow_horizontal = 2
4040
grow_vertical = 2
4141
theme_override_constants/separation = 0
4242
script = ExtResource("1_0jdnn")
43-
prefix = null
4443

4544
[node name="Value_Panel" type="PanelContainer" parent="."]
4645
layout_mode = 2
46+
theme_type_variation = &"DialogicEventEdit"
4747

4848
[node name="Layout" type="HBoxContainer" parent="Value_Panel"]
4949
layout_mode = 2
@@ -106,26 +106,17 @@ shortcut_keys_enabled = false
106106
drag_and_drop_selection_enabled = false
107107
text_direction = 1
108108

109-
[node name="HBoxContainer" type="HBoxContainer" parent="Value_Panel/Layout"]
110-
layout_mode = 2
111-
theme_override_constants/separation = 0
112-
113-
[node name="Spacer" type="MarginContainer" parent="Value_Panel/Layout/HBoxContainer"]
114-
layout_mode = 2
115-
mouse_filter = 2
116-
theme_override_constants/margin_right = 1
117-
118-
[node name="Spin" type="VBoxContainer" parent="Value_Panel/Layout/HBoxContainer"]
109+
[node name="Spin" type="VBoxContainer" parent="Value_Panel/Layout"]
119110
unique_name_in_owner = true
120111
layout_mode = 2
121112
theme_override_constants/separation = 0
122113
alignment = 1
123114

124-
[node name="Increment" type="Button" parent="Value_Panel/Layout/HBoxContainer/Spin"]
115+
[node name="Increment" type="Button" parent="Value_Panel/Layout/Spin"]
125116
layout_mode = 2
126117
size_flags_vertical = 3
127118
auto_translate = false
128-
focus_neighbor_left = NodePath("../../../Value")
119+
focus_neighbor_left = NodePath("../../Value")
129120
focus_neighbor_top = NodePath(".")
130121
focus_neighbor_bottom = NodePath("../Decrement")
131122
theme_override_colors/icon_hover_color = Color(0.412738, 0.550094, 0.760917, 1)
@@ -139,11 +130,11 @@ icon = ExtResource("3_v5cne")
139130
flat = true
140131
vertical_icon_alignment = 2
141132

142-
[node name="Decrement" type="Button" parent="Value_Panel/Layout/HBoxContainer/Spin"]
133+
[node name="Decrement" type="Button" parent="Value_Panel/Layout/Spin"]
143134
layout_mode = 2
144135
size_flags_vertical = 3
145136
auto_translate = false
146-
focus_neighbor_left = NodePath("../../../Value")
137+
focus_neighbor_left = NodePath("../../Value")
147138
focus_neighbor_top = NodePath("../Increment")
148139
focus_neighbor_bottom = NodePath(".")
149140
theme_override_colors/icon_hover_color = Color(0.412738, 0.550094, 0.760917, 1)
@@ -157,17 +148,13 @@ icon = ExtResource("4_ph52o")
157148
flat = true
158149
vertical_icon_alignment = 2
159150

160-
[node name="Spacer" type="Control" parent="."]
161-
custom_minimum_size = Vector2(3, 0)
162-
layout_mode = 2
163-
164151
[connection signal="gui_input" from="Value_Panel/Layout/Prefix" to="." method="_on_sublabel_clicked"]
165152
[connection signal="focus_entered" from="Value_Panel/Layout/Value" to="." method="_on_value_focus_entered"]
166153
[connection signal="focus_exited" from="Value_Panel/Layout/Value" to="." method="_on_value_focus_exited"]
167154
[connection signal="gui_input" from="Value_Panel/Layout/Value" to="." method="_on_gui_input"]
168155
[connection signal="text_submitted" from="Value_Panel/Layout/Value" to="." method="_on_value_text_submitted"]
169156
[connection signal="gui_input" from="Value_Panel/Layout/Suffix" to="." method="_on_sublabel_clicked"]
170-
[connection signal="button_down" from="Value_Panel/Layout/HBoxContainer/Spin/Increment" to="." method="_on_increment_button_down" binds= [NodePath("%Spin/Increment")]]
171-
[connection signal="gui_input" from="Value_Panel/Layout/HBoxContainer/Spin/Increment" to="." method="_on_gui_input"]
172-
[connection signal="button_down" from="Value_Panel/Layout/HBoxContainer/Spin/Decrement" to="." method="_on_decrement_button_down" binds= [NodePath("%Spin/Decrement")]]
173-
[connection signal="gui_input" from="Value_Panel/Layout/HBoxContainer/Spin/Decrement" to="." method="_on_gui_input"]
157+
[connection signal="button_down" from="Value_Panel/Layout/Spin/Increment" to="." method="_on_increment_button_down" binds= [NodePath("%Spin/Increment")]]
158+
[connection signal="gui_input" from="Value_Panel/Layout/Spin/Increment" to="." method="_on_gui_input"]
159+
[connection signal="button_down" from="Value_Panel/Layout/Spin/Decrement" to="." method="_on_decrement_button_down" binds= [NodePath("%Spin/Decrement")]]
160+
[connection signal="gui_input" from="Value_Panel/Layout/Spin/Decrement" to="." method="_on_gui_input"]

addons/dialogic/Modules/Character/event_character.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func build_event_editor() -> void:
383383
'placeholder' : 'Default',
384384
'enable_pretty_name' : true},
385385
'should_show_fade_options()')
386-
add_body_edit('fade_length', ValueType.NUMBER, {'left_text':'Length:', 'suffix':'s'},
386+
add_body_edit('fade_length', ValueType.NUMBER, {'left_text':'Length:', 'suffix':'s', "min":0},
387387
'should_show_fade_options() and !fade_animation.is_empty()')
388388
add_body_line_break("should_show_fade_options()")
389389
add_body_edit('animation_name', ValueType.DYNAMIC_OPTIONS,
@@ -393,14 +393,14 @@ func build_event_editor() -> void:
393393
'placeholder' : 'Default',
394394
'enable_pretty_name' : true},
395395
'should_show_animation_options()')
396-
add_body_edit('animation_length', ValueType.NUMBER, {'left_text':'Length:', 'suffix':'s'},
396+
add_body_edit('animation_length', ValueType.NUMBER, {'left_text':'Length:', 'suffix':'s', "min":0},
397397
'should_show_animation_options() and !animation_name.is_empty()')
398398
add_body_edit('animation_wait', ValueType.BOOL, {'left_text':'Await end:'},
399399
'should_show_animation_options() and !animation_name.is_empty()')
400-
add_body_edit('animation_repeats', ValueType.NUMBER, {'left_text':'Repeat:', 'mode':1},
400+
add_body_edit('animation_repeats', ValueType.NUMBER, {'left_text':'Repeat:', 'mode':1, "min":1},
401401
'should_show_animation_options() and !animation_name.is_empty() and action == %s)' %Actions.UPDATE)
402402
add_body_line_break()
403-
add_body_edit('transform_time', ValueType.NUMBER, {'left_text':'Movement duration:'},
403+
add_body_edit('transform_time', ValueType.NUMBER, {'left_text':'Movement duration:', "min":0},
404404
"should_show_transform_options()")
405405
add_body_edit("transform_trans", ValueType.FIXED_OPTIONS, {'options':trans_options, 'left_text':"Trans:"}, 'should_show_transform_options() and transform_time > 0')
406406
add_body_edit("transform_ease", ValueType.FIXED_OPTIONS, {'options':ease_options, 'left_text':"Ease:"}, 'should_show_transform_options() and transform_time > 0')

addons/dialogic/Modules/Wait/event_wait.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func get_shortcode_parameters() -> Dictionary:
7070
################################################################################
7171

7272
func build_event_editor() -> void:
73-
add_header_edit('time', ValueType.NUMBER, {'left_text':'Wait', 'autofocus':true, 'min':0})
73+
add_header_edit('time', ValueType.NUMBER, {'left_text':'Wait', 'autofocus':true, 'min':0.1})
7474
add_header_label('seconds', 'time != 1')
7575
add_header_label('second', 'time == 1')
7676
add_body_edit('hide_text', ValueType.BOOL, {'left_text':'Hide text box:'})

0 commit comments

Comments
 (0)