Skip to content

Add Tween Event #2151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions addons/dialogic/Core/DialogicUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,30 @@ static func logical_convert(value:Variant) -> Variant:
return value


static func vector2_to_vector3(vector: Vector2) -> Vector3:
return Vector3(vector.x, vector.y, 0)


static func vector3_to_vector2(vector: Vector3) -> Vector2:
return Vector2(vector.x, vector.y)


static func vector4_to_vector2(vector: Vector4) -> Vector2:
return Vector2(vector.x, vector.y)


static func vector2_to_vector4(vector: Vector2) -> Vector4:
return Vector4(vector.x, vector.y, 0, 0)


static func vector3_to_vector4(vector:Vector3) -> Vector4:
return Vector4(vector.x, vector.y, vector.z, 0)


static func vector4_to_vector3(vector: Vector4) -> Vector3:
return Vector3(vector.x, vector.y, vector.z)


## Takes [param source] and builds a dictionary of keys only.
## The values are `null`.
static func str_to_hash_set(source: String) -> Dictionary:
Expand Down
39 changes: 30 additions & 9 deletions addons/dialogic/Editor/Events/Fields/field_number.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ extends DialogicVisualEditorField
@export var allow_string: bool = false
@export var step: float = 0.1
@export var enforce_step: bool = true
@export var limit_value: bool = false
@export var min: float = -INF
@export var max: float = INF
@export var only_positive: bool = false
@export var value = 0.0
@export var prefix: String = ""
@export var suffix: String = ""
Expand All @@ -32,11 +34,13 @@ func _load_display_info(info: Dictionary) -> void:
use_float_mode(info.get('step', 0.1))
1: #INT
use_int_mode(info.get('step', 1))
2: #DECIBLE:
2: #DECIBEL:
use_decibel_mode(info.get('step', step))

for option in info.keys():

for option: String in info.keys():
match option:
'limit_value': limit_value = info[option]
'min': min = info[option]
'max': max = info[option]
'prefix': update_prefix(info[option])
Expand Down Expand Up @@ -72,7 +76,7 @@ func use_int_mode(value_step: float = 1) -> void:
enforce_step = true


func use_decibel_mode(value_step: float = step) -> void:
func use_decibel_mode(_value_step: float = step) -> void:
max = 6
update_suffix("dB")
min = -80
Expand Down Expand Up @@ -159,19 +163,36 @@ func _on_value_text_submitted(new_text: String, no_signal:= false) -> void:
if new_text.is_empty() and not allow_string:
new_text = "0.0"
if new_text.is_valid_float():
var temp: float = min(max(new_text.to_float(), min), max)
var final_value := new_text.to_float()

if limit_value:
final_value = min(max(final_value, min), max)

elif only_positive:
final_value = max(0, final_value)

if !enforce_step:
value = temp
value = final_value
else:
value = snapped(temp, step)
value = snapped(final_value, step)

elif allow_string:
value = new_text

%Value.text = str(value).pad_decimals(len(str(float(step)-floorf(step)))-2)

if not no_signal:
value_changed.emit(property_name, value)
# Visually disable Up or Down arrow when limit is reached to better indicate a limit has been hit
%Spin/Decrement.disabled = value <= min
%Spin/Increment.disabled = value >= max

if limit_value:
# Visually disable Up or Down arrow when limit is reached to better
## indicate a limit has been hit.
%Spin/Decrement.disabled = value <= min
%Spin/Increment.disabled = value >= max

else:
%Spin/Decrement.disabled = false
%Spin/Increment.disabled = false


# If prefix or suffix was clicked, select the actual value box instead and move the caret to the closest side.
Expand Down
11 changes: 10 additions & 1 deletion addons/dialogic/Editor/Events/Fields/field_options_fixed.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,31 @@ var current_value: Variant = -1
func _ready() -> void:
add_theme_color_override("font_disabled_color", get_theme_color("font_color", "MenuButton"))
self.about_to_popup.connect(insert_options)
self.text = placeholder_text
call("get_popup").index_pressed.connect(index_pressed)


func _load_display_info(info:Dictionary) -> void:
options = info.get('options', [])
self.disabled = info.get('disabled', false)
symbol_only = info.get('symbol_only', false)
placeholder_text = info.get('placeholder', 'Select Resource')


func _set_value(value:Variant) -> void:
func _set_value(value: Variant) -> void:

if value == null:
self.text = placeholder_text

for option in options:
if option['value'] == value:

if typeof(option.get('icon')) == TYPE_ARRAY:
option.icon = callv('get_theme_icon', option.get('icon'))

if !symbol_only:
self.text = option['label']

self.icon = option.get('icon', null)
current_value = value

Expand Down
36 changes: 36 additions & 0 deletions addons/dialogic/Editor/Events/Fields/field_vector2.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,54 @@
extends DialogicVisualEditorFieldVector
## Event block field for a Vector2.

@export var step: float = 0.1
@export var enforce_step: bool = true

var current_value := Vector2()


func _set_value(value: Variant) -> void:

if value is float or value is int:
var number := value as float
value = Vector2(number, number)

elif value is Vector4:
value = DialogicUtil.vector4_to_vector2(value as Vector4)

elif value is Vector3:
value = DialogicUtil.vector3_to_vector2(value as Vector3)

elif not value is Vector2:
value = Vector2()

current_value = value

value_changed.emit(property_name, value)
super(value)


func get_value() -> Vector2:
return current_value


func _load_display_info(info: Dictionary) -> void:
for option: String in info.keys():
match option:
#'min': min = info[option]
#'max': max = info[option]
#'prefix': update_prefix(info[option])
#'suffix': update_suffix(info[option])
'step':
enforce_step = true
step = info[option]
#'hide_step_button': %Spin.hide()

if enforce_step:
$X.step = step
$Y.step = step


func _on_sub_value_changed(sub_component: String, value: float) -> void:
match sub_component:
'X': current_value.x = value
Expand Down
35 changes: 35 additions & 0 deletions addons/dialogic/Editor/Events/Fields/field_vector3.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@ extends DialogicVisualEditorFieldVector

var current_value := Vector3()

@export var step: float = 0.1
@export var enforce_step: bool = true

func _set_value(value: Variant) -> void:
if value is float or value is int:
var number: float = value.as_float()
value = Vector3(number, number, number)

elif value is Vector2:
value = DialogicUtil.vector2_to_vector3(value as Vector2)

elif value is Vector4:
value = DialogicUtil.vector4_to_vector3(value as Vector4)

elif not value.is_valid_vector3():
value = Vector3()

current_value = value

value_changed.emit(property_name, value)
super(value)


Expand All @@ -22,6 +39,24 @@ func _on_sub_value_changed(sub_component: String, value: float) -> void:
_on_value_changed(current_value)


func _load_display_info(info: Dictionary) -> void:
for option: String in info.keys():
match option:
#'min': min = info[option]
#'max': max = info[option]
#'prefix': update_prefix(info[option])
#'suffix': update_suffix(info[option])
'step':
enforce_step = true
step = info[option]
#'hide_step_button': %Spin.hide()

if enforce_step:
$X.step = step
$Y.step = step
$Z.step = step


func _update_sub_component_text(value: Variant) -> void:
$X._on_value_text_submitted(str(value.x), true)
$Y._on_value_text_submitted(str(value.y), true)
Expand Down
37 changes: 37 additions & 0 deletions addons/dialogic/Editor/Events/Fields/field_vector4.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,53 @@ extends DialogicVisualEditorFieldVector

var current_value := Vector4()

@export var step: float = 0.1
@export var enforce_step: bool = true

func _set_value(value: Variant) -> void:

if value is float or value is int:
var number: float = value.as_float()
value = Vector4(number, number, number, number)

elif value is Vector2:
value = DialogicUtil.vector2_to_vector4(value as Vector2)

elif value is Vector3:
value = DialogicUtil.vector3_to_vector4(value as Vector3)

elif not value is Vector4:
value = Vector4()

current_value = value

value_changed.emit(property_name, value)
super(value)


func get_value() -> Vector4:
return current_value


func _load_display_info(info: Dictionary) -> void:
for option: String in info.keys():
match option:
#'min': min = info[option]
#'max': max = info[option]
#'prefix': update_prefix(info[option])
#'suffix': update_suffix(info[option])
'step':
enforce_step = true
step = info[option]
#'hide_step_button': %Spin.hide()

if enforce_step:
$X.step = step
$Y.step = step
$Z.step = step
$W.step = step


func _on_sub_value_changed(sub_component: String, value: float) -> void:
match sub_component:
'X': current_value.x = value
Expand Down
2 changes: 1 addition & 1 deletion addons/dialogic/Editor/Events/Fields/field_vector_base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extends DialogicVisualEditorField


func _ready() -> void:
for child in get_children():
for child: Node in get_children():
child.tooltip_text = tooltip_text
child.property_name = child.name #to identify the name of the changed sub-component
child.value_changed.connect(_on_sub_value_changed)
Expand Down
15 changes: 15 additions & 0 deletions addons/dialogic/Modules/Background/subsystem_backgrounds.gd
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,21 @@ func add_background_node(scene:PackedScene, parent:DialogicNode_BackgroundHolder
return v_con


## Returns the current background node.
func get_current_background_node() -> Node:
var background_holder: DialogicNode_BackgroundHolder = null

if dialogic.has_subsystem("Styles"):
background_holder = dialogic.Styles.get_first_node_in_layout("dialogic_background_holders")
else:
background_holder = get_tree().get_first_node_in_group("dialogic_background_holders")

var current_viewport: Node = background_holder.get_meta("current_viewport")
var current_background_node: Node = current_viewport.get_meta("node")

return current_background_node


## Whether a background is set.
func has_background() -> bool:
return !dialogic.current_state_info.get('background_scene', '').is_empty() or !dialogic.current_state_info.get('background_argument','').is_empty()
Expand Down
Loading
Loading