First work on dialogic, resized guild, and started implementing portraits.
This commit is contained in:
4
addons/dialogic/Modules/Variable/add-variable.svg
Normal file
4
addons/dialogic/Modules/Variable/add-variable.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13.0909 9.45452H15.2727V10.9091H13.0909V13.0909H11.6363V10.9091H9.45453V9.45452H11.6363V7.27271H13.0909V9.45452Z" fill="#A5EFAC"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.1186 5.22444L13.2372 2.62927C12.9687 2.49006 12.6903 2.38069 12.402 2.30114C12.1136 2.2216 11.8153 2.18182 11.5071 2.18182C11.179 2.18182 10.8757 2.23651 10.5973 2.34589C10.3189 2.44532 10.0604 2.58452 9.82172 2.7635C9.59302 2.94248 9.38422 3.15128 9.1953 3.38992C9.00637 3.62856 8.83734 3.88708 8.68819 4.16549C8.60865 4.32458 8.51916 4.5135 8.41973 4.73225C8.33024 4.94106 8.24075 5.14489 8.15126 5.34376C8.04189 5.58239 7.93748 5.82103 7.83805 6.05966C7.73862 5.85086 7.63422 5.65697 7.52484 5.47799C7.43535 5.3189 7.34089 5.15981 7.24146 5.00072C7.15197 4.83168 7.06745 4.69248 6.98791 4.5831C6.82882 4.34447 6.64984 4.08594 6.45098 3.80753C6.25211 3.52912 6.03336 3.2706 5.79473 3.03197C5.55609 2.79333 5.29757 2.59447 5.01916 2.43537C4.74075 2.26634 4.43748 2.18182 4.10936 2.18182C3.84089 2.18182 3.5774 2.23651 3.31888 2.34589C3.06035 2.44532 2.81674 2.57955 2.58805 2.74859C2.35936 2.90768 2.14558 3.09162 1.94672 3.30043C1.7578 3.4993 1.59373 3.70313 1.45453 3.91194L1.85723 4.43395C1.99643 4.32458 2.14061 4.24006 2.28976 4.1804C2.4389 4.1108 2.59799 4.076 2.76703 4.076C2.96589 4.076 3.15481 4.12572 3.33379 4.22515C3.52271 4.31464 3.6818 4.43395 3.81106 4.5831L6.61504 9.07245C6.52555 9.34091 6.43606 9.59447 6.34657 9.8331L6.10794 10.4595C6.02839 10.6683 5.95382 10.8374 5.88422 10.9666C5.8345 11.0859 5.75993 11.1903 5.66049 11.2798C5.56106 11.3594 5.44672 11.429 5.31745 11.4886C5.19814 11.5384 5.07385 11.5781 4.94459 11.608C4.81532 11.6278 4.69103 11.6378 4.57172 11.6378C4.19388 11.6378 3.81603 11.5632 3.43819 11.4141C3.06035 11.255 2.71234 11.076 2.39416 10.8771L1.45453 13.353C1.73294 13.5717 2.0362 13.7457 2.36433 13.875C2.69245 14.0142 3.03052 14.0838 3.37853 14.0838C3.76632 14.0838 4.13422 13.9993 4.48223 13.8303C4.83024 13.6513 5.14842 13.4276 5.43677 13.1591C5.73507 12.8807 5.99856 12.5724 6.22726 12.2344C6.45595 11.8963 6.64487 11.5682 6.79402 11.25C6.83379 11.1705 6.87853 11.0561 6.92825 10.907C6.97797 10.7578 7.02271 10.6136 7.06248 10.4744C7.10226 10.3054 7.147 10.1364 7.19672 9.96734C7.31603 10.1364 7.44032 10.3452 7.56959 10.5938C7.69885 10.8324 7.82811 11.081 7.95737 11.3395C8.08663 11.598 8.21092 11.8516 8.33024 12.1001C8.4595 12.3388 8.57882 12.5426 8.68819 12.7117C8.8274 12.8906 8.96163 13.0646 9.09089 13.2337C9.22015 13.4027 9.35936 13.5519 9.50851 13.6811C9.65765 13.8004 9.82172 13.8949 10.0007 13.9645C10.1896 14.044 10.4034 14.0838 10.642 14.0838C10.9105 14.0838 11.174 14.0242 11.4325 13.9048C11.4983 13.878 11.5629 13.8492 11.6262 13.8182H10.9091V11.6364H8.72726V8.72728H9.30068C9.2095 8.54765 9.11969 8.36938 9.03123 8.19248C8.83237 7.79475 8.62853 7.37714 8.41973 6.93964L8.71802 6.08949C8.79757 5.91052 8.897 5.73154 9.01632 5.55256C9.13564 5.36364 9.27484 5.19461 9.43393 5.04546C9.59302 4.89631 9.76703 4.77699 9.95595 4.68751C10.1548 4.59802 10.3636 4.55327 10.5824 4.55327C10.8608 4.55327 11.1292 4.62287 11.3878 4.76208C11.6562 4.89134 11.8998 5.04546 12.1186 5.22444Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
44
addons/dialogic/Modules/Variable/add-variable.svg.import
Normal file
44
addons/dialogic/Modules/Variable/add-variable.svg.import
Normal file
@@ -0,0 +1,44 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://qhuk0fuwxbtq"
|
||||
path="res://.godot/imported/add-variable.svg-26eb3bd7fac746c574d054e8416d3aac.ctex"
|
||||
metadata={
|
||||
"has_editor_variant": true,
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dialogic/Modules/Variable/add-variable.svg"
|
||||
dest_files=["res://.godot/imported/add-variable.svg-26eb3bd7fac746c574d054e8416d3aac.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=true
|
||||
editor/convert_colors_with_editor_theme=true
|
||||
363
addons/dialogic/Modules/Variable/event_variable.gd
Normal file
363
addons/dialogic/Modules/Variable/event_variable.gd
Normal file
@@ -0,0 +1,363 @@
|
||||
@tool
|
||||
class_name DialogicVariableEvent
|
||||
extends DialogicEvent
|
||||
|
||||
## Event that allows changing a dialogic variable or a property of an autoload.
|
||||
|
||||
|
||||
enum Operations {SET, ADD, SUBSTRACT, MULTIPLY, DIVIDE}
|
||||
enum VarValueType {
|
||||
STRING = 0,
|
||||
NUMBER = 1,
|
||||
VARIABLE = 2,
|
||||
BOOL = 3,
|
||||
EXPRESSION = 4,
|
||||
RANDOM_NUMBER = 5,
|
||||
}
|
||||
|
||||
## Settings
|
||||
|
||||
## Name/Path of the variable that should be changed.
|
||||
var name := "":
|
||||
set(_value):
|
||||
name = _value
|
||||
if Engine.is_editor_hint() and not value:
|
||||
match DialogicUtil.get_variable_type(name):
|
||||
DialogicUtil.VarTypes.ANY, DialogicUtil.VarTypes.STRING:
|
||||
_value_type = VarValueType.STRING
|
||||
DialogicUtil.VarTypes.FLOAT, DialogicUtil.VarTypes.INT:
|
||||
_value_type = VarValueType.NUMBER
|
||||
DialogicUtil.VarTypes.BOOL:
|
||||
_value_type = VarValueType.BOOL
|
||||
ui_update_needed.emit()
|
||||
update_editor_warning()
|
||||
|
||||
## The operation to perform.
|
||||
var operation := Operations.SET:
|
||||
set(value):
|
||||
operation = value
|
||||
if operation != Operations.SET and _value_type == VarValueType.STRING:
|
||||
_value_type = VarValueType.NUMBER
|
||||
ui_update_needed.emit()
|
||||
update_editor_warning()
|
||||
|
||||
## The value that is used. Can be a variable as well.
|
||||
var value: Variant = ""
|
||||
var _value_type := 0 :
|
||||
set(_value):
|
||||
_value_type = _value
|
||||
if not _suppress_default_value:
|
||||
match _value_type:
|
||||
VarValueType.STRING, VarValueType.VARIABLE, VarValueType.EXPRESSION:
|
||||
value = ""
|
||||
VarValueType.NUMBER:
|
||||
value = 0
|
||||
VarValueType.BOOL:
|
||||
value = false
|
||||
VarValueType.RANDOM_NUMBER:
|
||||
value = null
|
||||
ui_update_needed.emit()
|
||||
update_editor_warning()
|
||||
|
||||
## If true, a random number between [random_min] and [random_max] is used instead of [value].
|
||||
var random_min: int = 0
|
||||
var random_max: int = 100
|
||||
|
||||
## Used to suppress _value_type from overwriting value with a default value when the type changes
|
||||
## This is only used when initializing the event_variable.
|
||||
var _suppress_default_value := false
|
||||
|
||||
|
||||
################################################################################
|
||||
## EXECUTE
|
||||
################################################################################
|
||||
|
||||
func _execute() -> void:
|
||||
if name:
|
||||
var original_value: Variant = dialogic.VAR.get_variable(name, null, operation == Operations.SET and "[" in name)
|
||||
|
||||
if value != null and (original_value != null or (operation == Operations.SET and "[" in name)):
|
||||
|
||||
var interpreted_value: Variant
|
||||
var result: Variant
|
||||
|
||||
match _value_type:
|
||||
VarValueType.STRING:
|
||||
interpreted_value = dialogic.VAR.get_variable('"' + value + '"')
|
||||
VarValueType.VARIABLE:
|
||||
interpreted_value = dialogic.VAR.get_variable('{' + value + '}')
|
||||
VarValueType.NUMBER, VarValueType.BOOL, VarValueType.EXPRESSION, VarValueType.RANDOM_NUMBER:
|
||||
interpreted_value = dialogic.VAR.get_variable(str(value))
|
||||
|
||||
if operation != Operations.SET and (not str(original_value).is_valid_float() or not str(interpreted_value).is_valid_float()):
|
||||
printerr("[Dialogic] Set Variable event failed because one value wasn't a float! [", original_value, ", ",interpreted_value,"]")
|
||||
finish()
|
||||
return
|
||||
|
||||
if operation == Operations.SET:
|
||||
result = interpreted_value
|
||||
|
||||
else:
|
||||
original_value = float(original_value)
|
||||
interpreted_value = float(interpreted_value)
|
||||
|
||||
match operation:
|
||||
Operations.ADD:
|
||||
result = original_value + interpreted_value
|
||||
Operations.SUBSTRACT:
|
||||
result = original_value - interpreted_value
|
||||
Operations.MULTIPLY:
|
||||
result = original_value * interpreted_value
|
||||
Operations.DIVIDE:
|
||||
result = original_value / interpreted_value
|
||||
|
||||
dialogic.VAR.set_variable(name, result)
|
||||
dialogic.VAR.variable_was_set.emit(
|
||||
{
|
||||
'variable' : name,
|
||||
'value' : interpreted_value,
|
||||
'value_str' : value,
|
||||
'orig_value' : original_value,
|
||||
'new_value' : result,
|
||||
})
|
||||
|
||||
else:
|
||||
printerr("[Dialogic] Set Variable event failed because one value wasn't set!")
|
||||
|
||||
finish()
|
||||
|
||||
|
||||
################################################################################
|
||||
## INITIALIZE
|
||||
################################################################################
|
||||
|
||||
func _init() -> void:
|
||||
event_name = "Set Variable"
|
||||
set_default_color('Color6')
|
||||
event_category = "Logic"
|
||||
event_sorting_index = 0
|
||||
help_page_path = "https://docs.dialogic.pro/variables.html#23-set-variable-event"
|
||||
|
||||
|
||||
################################################################################
|
||||
## SAVING/LOADING
|
||||
################################################################################
|
||||
|
||||
func to_text() -> String:
|
||||
var string := "set "
|
||||
if name:
|
||||
string += "{" + name.trim_prefix('{').trim_suffix('}') + "}"
|
||||
match operation:
|
||||
Operations.SET:
|
||||
string+= " = "
|
||||
Operations.ADD:
|
||||
string+= " += "
|
||||
Operations.SUBSTRACT:
|
||||
string+= " -= "
|
||||
Operations.MULTIPLY:
|
||||
string+= " *= "
|
||||
Operations.DIVIDE:
|
||||
string+= " /= "
|
||||
|
||||
value = str(value)
|
||||
match _value_type:
|
||||
VarValueType.STRING: # String
|
||||
string += '"'+value.replace('"', '\\"')+'"'
|
||||
VarValueType.NUMBER,VarValueType.BOOL,VarValueType.EXPRESSION: # Float Bool, or Expression
|
||||
string += str(value)
|
||||
VarValueType.VARIABLE: # Variable
|
||||
string += '{'+value+'}'
|
||||
VarValueType.RANDOM_NUMBER:
|
||||
string += 'range('+str(random_min)+','+str(random_max)+').pick_random()'
|
||||
|
||||
return string
|
||||
|
||||
|
||||
func from_text(string:String) -> void:
|
||||
var reg := RegEx.new()
|
||||
reg.compile("set(?<name>[^=+\\-*\\/]*)?(?<operation>=|\\+=|-=|\\*=|\\/=)?(?<value>.*)")
|
||||
var result := reg.search(string)
|
||||
if !result:
|
||||
return
|
||||
name = result.get_string('name').strip_edges().replace("{", "").replace("}", "")
|
||||
match result.get_string('operation').strip_edges():
|
||||
'=':
|
||||
operation = Operations.SET
|
||||
'-=':
|
||||
operation = Operations.SUBSTRACT
|
||||
'+=':
|
||||
operation = Operations.ADD
|
||||
'*=':
|
||||
operation = Operations.MULTIPLY
|
||||
'/=':
|
||||
operation = Operations.DIVIDE
|
||||
|
||||
_suppress_default_value = true
|
||||
value = result.get_string('value').strip_edges()
|
||||
if not value.is_empty():
|
||||
if value.begins_with('"') and value.ends_with('"') and value.count('"')-value.count('\\"') == 2:
|
||||
value = result.get_string('value').strip_edges().replace('"', '')
|
||||
_value_type = VarValueType.STRING
|
||||
elif value.begins_with('{') and value.ends_with('}') and value.count('{') == 1:
|
||||
value = result.get_string('value').strip_edges().trim_suffix('}').trim_prefix('{')
|
||||
_value_type = VarValueType.VARIABLE
|
||||
elif value in ["true", "false"]:
|
||||
value = value == "true"
|
||||
_value_type = VarValueType.BOOL
|
||||
elif value.begins_with('range(') and value.ends_with(').pick_random()'):
|
||||
_value_type = VarValueType.RANDOM_NUMBER
|
||||
var randinf := str(value).trim_prefix('range(').trim_suffix(').pick_random()').split(',')
|
||||
random_min = int(randinf[0])
|
||||
random_max = int(randinf[1])
|
||||
else:
|
||||
value = result.get_string('value').strip_edges()
|
||||
if value.is_valid_float():
|
||||
_value_type = VarValueType.NUMBER
|
||||
else:
|
||||
_value_type = VarValueType.EXPRESSION
|
||||
else:
|
||||
value = null
|
||||
_suppress_default_value = false
|
||||
|
||||
|
||||
func is_valid_event(string:String) -> bool:
|
||||
return string.begins_with('set')
|
||||
|
||||
|
||||
################################################################################
|
||||
## EDITOR REPRESENTATION
|
||||
################################################################################
|
||||
|
||||
func build_event_editor() -> void:
|
||||
add_header_edit('name', ValueType.DYNAMIC_OPTIONS, {
|
||||
'left_text' : 'Set',
|
||||
'suggestions_func' : get_var_suggestions,
|
||||
'icon' : load("res://addons/dialogic/Editor/Images/Pieces/variable.svg"),
|
||||
'placeholder' :'Select Variable'}
|
||||
)
|
||||
add_header_edit('operation', ValueType.FIXED_OPTIONS, {
|
||||
'options': [
|
||||
{
|
||||
'label': 'to be',
|
||||
'icon': load("res://addons/dialogic/Editor/Images/Dropdown/set.svg"),
|
||||
'value': Operations.SET
|
||||
},{
|
||||
'label': 'to itself plus',
|
||||
'icon': load("res://addons/dialogic/Editor/Images/Dropdown/plus.svg"),
|
||||
'value': Operations.ADD
|
||||
},{
|
||||
'label': 'to itself minus',
|
||||
'icon': load("res://addons/dialogic/Editor/Images/Dropdown/minus.svg"),
|
||||
'value': Operations.SUBSTRACT
|
||||
},{
|
||||
'label': 'to itself multiplied by',
|
||||
'icon': load("res://addons/dialogic/Editor/Images/Dropdown/multiply.svg"),
|
||||
'value': Operations.MULTIPLY
|
||||
},{
|
||||
'label': 'to itself divided by',
|
||||
'icon': load("res://addons/dialogic/Editor/Images/Dropdown/divide.svg"),
|
||||
'value': Operations.DIVIDE
|
||||
}
|
||||
]
|
||||
}, '!name.is_empty()')
|
||||
add_header_edit('_value_type', ValueType.FIXED_OPTIONS, {
|
||||
'options': [
|
||||
{
|
||||
'label': 'String',
|
||||
'icon': ["String", "EditorIcons"],
|
||||
'value': VarValueType.STRING
|
||||
},{
|
||||
'label': 'Number',
|
||||
'icon': ["float", "EditorIcons"],
|
||||
'value': VarValueType.NUMBER
|
||||
},{
|
||||
'label': 'Variable',
|
||||
'icon': load("res://addons/dialogic/Editor/Images/Pieces/variable.svg"),
|
||||
'value': VarValueType.VARIABLE
|
||||
},{
|
||||
'label': 'Bool',
|
||||
'icon': ["bool", "EditorIcons"],
|
||||
'value': VarValueType.BOOL
|
||||
},{
|
||||
'label': 'Expression',
|
||||
'icon': ["Variant", "EditorIcons"],
|
||||
'value': VarValueType.EXPRESSION
|
||||
},{
|
||||
'label': 'Random Number',
|
||||
'icon': ["RandomNumberGenerator", "EditorIcons"],
|
||||
'value': VarValueType.RANDOM_NUMBER
|
||||
}],
|
||||
'symbol_only':true},
|
||||
'!name.is_empty()')
|
||||
add_header_edit('value', ValueType.SINGLELINE_TEXT, {}, '!name.is_empty() and (_value_type == VarValueType.STRING or _value_type == VarValueType.EXPRESSION) ')
|
||||
add_header_edit('value', ValueType.BOOL, {}, '!name.is_empty() and (_value_type == VarValueType.BOOL) ')
|
||||
add_header_edit('value', ValueType.NUMBER, {}, '!name.is_empty() and _value_type == VarValueType.NUMBER')
|
||||
add_header_edit('value', ValueType.DYNAMIC_OPTIONS,
|
||||
{'suggestions_func' : get_value_suggestions, 'placeholder':'Select Variable'},
|
||||
'!name.is_empty() and _value_type == VarValueType.VARIABLE')
|
||||
add_header_label('a number between', '_value_type == VarValueType.RANDOM_NUMBER')
|
||||
add_header_edit('random_min', ValueType.NUMBER, {'right_text':'and', 'mode':1}, '!name.is_empty() and _value_type == VarValueType.RANDOM_NUMBER')
|
||||
add_header_edit('random_max', ValueType.NUMBER, {'mode':1}, '!name.is_empty() and _value_type == VarValueType.RANDOM_NUMBER')
|
||||
add_header_button('', _on_variable_editor_pressed, 'Variable Editor', ["ExternalLink", "EditorIcons"])
|
||||
|
||||
|
||||
func get_var_suggestions(filter:String) -> Dictionary:
|
||||
var suggestions := {}
|
||||
if filter:
|
||||
suggestions[filter] = {'value':filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]}
|
||||
for var_path in DialogicUtil.list_variables(DialogicUtil.get_default_variables()):
|
||||
suggestions[var_path] = {'value':var_path, 'icon':load("res://addons/dialogic/Editor/Images/Pieces/variable.svg")}
|
||||
return suggestions
|
||||
|
||||
|
||||
func get_value_suggestions(_filter:String) -> Dictionary:
|
||||
var suggestions := {}
|
||||
|
||||
for var_path in DialogicUtil.list_variables(DialogicUtil.get_default_variables()):
|
||||
suggestions[var_path] = {'value':var_path, 'icon':load("res://addons/dialogic/Editor/Images/Pieces/variable.svg")}
|
||||
return suggestions
|
||||
|
||||
|
||||
func _on_variable_editor_pressed() -> void:
|
||||
var editor_manager := editor_node.find_parent('EditorsManager')
|
||||
if editor_manager:
|
||||
editor_manager.open_editor(editor_manager.editors['VariablesEditor']['node'], true)
|
||||
|
||||
|
||||
func update_editor_warning() -> void:
|
||||
if _value_type == VarValueType.STRING and operation != Operations.SET:
|
||||
ui_update_warning.emit('You cannot do this operation with a string!')
|
||||
elif operation != Operations.SET:
|
||||
var type := DialogicUtil.get_variable_type(name)
|
||||
if not type in [DialogicUtil.VarTypes.INT, DialogicUtil.VarTypes.FLOAT, DialogicUtil.VarTypes.ANY]:
|
||||
ui_update_warning.emit('The selected variable is not a number!')
|
||||
else:
|
||||
ui_update_warning.emit('')
|
||||
else:
|
||||
ui_update_warning.emit('')
|
||||
|
||||
|
||||
|
||||
####################### CODE COMPLETION ########################################
|
||||
################################################################################
|
||||
|
||||
func _get_code_completion(CodeCompletionHelper:Node, TextNode:TextEdit, line:String, _word:String, symbol:String) -> void:
|
||||
if CodeCompletionHelper.get_line_untill_caret(line) == 'set ':
|
||||
TextNode.add_code_completion_option(CodeEdit.KIND_MEMBER, '{', '{', TextNode.syntax_highlighter.variable_color)
|
||||
if symbol == '{':
|
||||
CodeCompletionHelper.suggest_variables(TextNode)
|
||||
|
||||
|
||||
func _get_start_code_completion(_CodeCompletionHelper:Node, TextNode:TextEdit) -> void:
|
||||
TextNode.add_code_completion_option(CodeEdit.KIND_PLAIN_TEXT, 'set', 'set ', event_color.lerp(TextNode.syntax_highlighter.normal_color, 0.5))
|
||||
|
||||
|
||||
#################### SYNTAX HIGHLIGHTING #######################################
|
||||
################################################################################
|
||||
|
||||
func _get_syntax_highlighting(Highlighter:SyntaxHighlighter, dict:Dictionary, line:String) -> Dictionary:
|
||||
dict[line.find('set')] = {"color":event_color.lerp(Highlighter.normal_color, 0.5)}
|
||||
dict[line.find('set')+3] = {"color":Highlighter.normal_color}
|
||||
dict = Highlighter.color_region(dict, Highlighter.string_color, line, '"', '"', line.find('set'))
|
||||
dict = Highlighter.color_region(dict, Highlighter.variable_color, line, '{', '}', line.find('set'))
|
||||
return dict
|
||||
1
addons/dialogic/Modules/Variable/event_variable.gd.uid
Normal file
1
addons/dialogic/Modules/Variable/event_variable.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://11tncc8gq32w
|
||||
BIN
addons/dialogic/Modules/Variable/icon.png
Normal file
BIN
addons/dialogic/Modules/Variable/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 639 B |
40
addons/dialogic/Modules/Variable/icon.png.import
Normal file
40
addons/dialogic/Modules/Variable/icon.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://xt46jy62513i"
|
||||
path="res://.godot/imported/icon.png-99064bb3920f49262c581fccbfcfc353.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dialogic/Modules/Variable/icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-99064bb3920f49262c581fccbfcfc353.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
12
addons/dialogic/Modules/Variable/index.gd
Normal file
12
addons/dialogic/Modules/Variable/index.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
@tool
|
||||
extends DialogicIndexer
|
||||
|
||||
|
||||
func _get_events() -> Array:
|
||||
return [this_folder.path_join('event_variable.gd')]
|
||||
|
||||
func _get_editors() -> Array:
|
||||
return [this_folder.path_join('variables_editor/variables_editor.tscn')]
|
||||
|
||||
func _get_subsystems() -> Array:
|
||||
return [{'name':'VAR', 'script':this_folder.path_join('subsystem_variables.gd')}]
|
||||
1
addons/dialogic/Modules/Variable/index.gd.uid
Normal file
1
addons/dialogic/Modules/Variable/index.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvfd2ptyx1l7c
|
||||
278
addons/dialogic/Modules/Variable/subsystem_variables.gd
Normal file
278
addons/dialogic/Modules/Variable/subsystem_variables.gd
Normal file
@@ -0,0 +1,278 @@
|
||||
extends DialogicSubsystem
|
||||
|
||||
## Subsystem that manages variables and allows to access them.
|
||||
|
||||
## Emitted if a dialogic variable changes, gives a dictionary with the following keys:[br]
|
||||
## [br]
|
||||
## Key | Value Type | Value [br]
|
||||
## ----------- | ------------- | ----- [br]
|
||||
## `variable` | [type String] | The name of the variable that is getting changed. [br]
|
||||
## `new_value` | [type Variant]| The value that [variable] has after the change (the result). [br]
|
||||
signal variable_changed(info:Dictionary)
|
||||
|
||||
## Emitted on a set variable event, gives a dictionary with the following keys:[br]
|
||||
## [br]
|
||||
## Key | Value Type | Value [br]
|
||||
## ----------- | ------------- | ----- [br]
|
||||
## `variable` | [type String] | The name of the variable that is getting changed. [br]
|
||||
## `orig_value`| [type Variant]| The value that [variable] had before. [br]
|
||||
## `new_value` | [type Variant]| The value that [variable] has after the change (the result). [br]
|
||||
## `value` | [type Variant]| The value that the variable is changed by/to. [br]
|
||||
## `value_str` | [type String] | Whatever has been given as the value (not interpreted, so a variable is just a string).[br]
|
||||
signal variable_was_set(info:Dictionary)
|
||||
|
||||
|
||||
#region STATE
|
||||
####################################################################################################
|
||||
|
||||
func clear_game_state(clear_flag:=DialogicGameHandler.ClearFlags.FULL_CLEAR):
|
||||
# loading default variables
|
||||
if ! clear_flag & DialogicGameHandler.ClearFlags.KEEP_VARIABLES:
|
||||
reset()
|
||||
|
||||
|
||||
func load_game_state(load_flag:=LoadFlags.FULL_LOAD):
|
||||
if load_flag == LoadFlags.ONLY_DNODES:
|
||||
return
|
||||
dialogic.current_state_info['variables'] = merge_folder(dialogic.current_state_info['variables'], ProjectSettings.get_setting('dialogic/variables', {}).duplicate(true))
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region MAIN METHODS
|
||||
####################################################################################################
|
||||
|
||||
## This function will try to get the value of variables provided inside curly brackets
|
||||
## and replace them with their values.
|
||||
## It will:
|
||||
## - look for the strings to replace
|
||||
## - search all autoloads
|
||||
## - try to get the value from context
|
||||
##
|
||||
## So if you provide a string like `Hello, how are you doing {Game.player_name}
|
||||
## it will try to search for an autoload with the name `Game` and get the value
|
||||
## of `player_name` to replace it.
|
||||
func parse_variables(text:String) -> String:
|
||||
# First some dirty checks to avoid parsing
|
||||
if not '{' in text:
|
||||
return text
|
||||
|
||||
# Trying to extract the curly brackets from the text
|
||||
var regex := RegEx.new()
|
||||
regex.compile("(?<!\\\\)\\{(?<variable>([^{}]|\\{.*\\})*)\\}")
|
||||
|
||||
var parsed := text.replace('\\{', '{')
|
||||
for result in regex.search_all(text):
|
||||
var value: Variant = get_variable(result.get_string('variable'), "<NOT FOUND>")
|
||||
parsed = parsed.replace("{"+result.get_string('variable')+"}", str(value))
|
||||
|
||||
return parsed
|
||||
|
||||
|
||||
func set_variable(variable_name: String, value: Variant) -> bool:
|
||||
variable_name = variable_name.trim_prefix('{').trim_suffix('}')
|
||||
|
||||
# First assume this is a simple dialogic variable
|
||||
if has(variable_name):
|
||||
DialogicUtil._set_value_in_dictionary(variable_name, dialogic.current_state_info['variables'], value)
|
||||
variable_changed.emit({'variable':variable_name, 'new_value':value})
|
||||
return true
|
||||
|
||||
# Second assume this is an autoload variable
|
||||
elif '.' in variable_name:
|
||||
var from := variable_name.get_slice('.', 0)
|
||||
var variable := variable_name.trim_prefix(from+'.')
|
||||
|
||||
var autoloads := get_autoloads()
|
||||
var object: Object = null
|
||||
if from in autoloads:
|
||||
object = autoloads[from]
|
||||
while variable.count("."):
|
||||
from = variable.get_slice('.', 0)
|
||||
if from in object and object.get(from) is Object:
|
||||
object = object.get(from)
|
||||
variable = variable.trim_prefix(from+'.')
|
||||
|
||||
if object:
|
||||
var sub_idx := ""
|
||||
if '[' in variable:
|
||||
sub_idx = variable.substr(variable.find('['))
|
||||
variable = variable.trim_suffix(sub_idx)
|
||||
sub_idx = sub_idx.trim_prefix('[').trim_suffix(']')
|
||||
|
||||
if variable in object:
|
||||
match typeof(object.get(variable)):
|
||||
TYPE_ARRAY:
|
||||
if not sub_idx:
|
||||
if typeof(value) == TYPE_ARRAY:
|
||||
object.set(variable, value)
|
||||
return true
|
||||
elif sub_idx.is_valid_float():
|
||||
object.get(variable).remove_at(int(sub_idx))
|
||||
object.get(variable).insert(int(sub_idx), value)
|
||||
return true
|
||||
TYPE_DICTIONARY:
|
||||
if not sub_idx:
|
||||
if typeof(value) == TYPE_DICTIONARY:
|
||||
object.set(variable, value)
|
||||
return true
|
||||
else:
|
||||
object.get(variable).merge({str_to_var(sub_idx):value}, true)
|
||||
return true
|
||||
_:
|
||||
object.set(variable, value)
|
||||
return true
|
||||
|
||||
printerr("[Dialogic] Tried setting non-existant variable '"+variable_name+"'.")
|
||||
return false
|
||||
|
||||
|
||||
func get_variable(variable_path:String, default: Variant = null, no_warning := false) -> Variant:
|
||||
if variable_path.begins_with('{') and variable_path.ends_with('}') and variable_path.count('{') == 1:
|
||||
variable_path = variable_path.trim_prefix('{').trim_suffix('}')
|
||||
|
||||
# First assume this is just a single variable
|
||||
var value: Variant = DialogicUtil._get_value_in_dictionary(variable_path, dialogic.current_state_info['variables'])
|
||||
if value != null:
|
||||
return value
|
||||
|
||||
# Second assume this is an expression.
|
||||
else:
|
||||
value = dialogic.Expressions.execute_string(variable_path, null, no_warning)
|
||||
if value != null:
|
||||
return value
|
||||
|
||||
# If everything fails, tell the user and return the default
|
||||
if not no_warning:
|
||||
printerr("[Dialogic] Failed parsing variable/expression '"+variable_path+"'.")
|
||||
return default
|
||||
|
||||
|
||||
## Resets all variables or a specific variable to the value(s) defined in the variable editor
|
||||
func reset(variable:="") -> void:
|
||||
if variable.is_empty():
|
||||
dialogic.current_state_info['variables'] = ProjectSettings.get_setting("dialogic/variables", {}).duplicate(true)
|
||||
else:
|
||||
DialogicUtil._set_value_in_dictionary(variable, dialogic.current_state_info['variables'], DialogicUtil._get_value_in_dictionary(variable, ProjectSettings.get_setting('dialogic/variables', {})))
|
||||
|
||||
|
||||
## Returns true if a variable with the given path exists
|
||||
func has(variable:="") -> bool:
|
||||
return DialogicUtil._get_value_in_dictionary(variable, dialogic.current_state_info['variables']) != null
|
||||
|
||||
|
||||
|
||||
## Allows to set dialogic built-in variables
|
||||
func _set(property, value) -> bool:
|
||||
property = str(property)
|
||||
var vars: Dictionary = dialogic.current_state_info['variables']
|
||||
if property in vars.keys():
|
||||
if typeof(vars[property]) != TYPE_DICTIONARY:
|
||||
vars[property] = value
|
||||
return true
|
||||
if value is VariableFolder:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
## Allows to get dialogic built-in variables
|
||||
func _get(property):
|
||||
property = str(property)
|
||||
if property in dialogic.current_state_info['variables'].keys():
|
||||
if typeof(dialogic.current_state_info['variables'][property]) == TYPE_DICTIONARY:
|
||||
return VariableFolder.new(dialogic.current_state_info['variables'][property], property, self)
|
||||
else:
|
||||
return DialogicUtil.logical_convert(dialogic.current_state_info['variables'][property])
|
||||
|
||||
|
||||
func folders() -> Array:
|
||||
var result := []
|
||||
for i in dialogic.current_state_info['variables'].keys():
|
||||
if dialogic.current_state_info['variables'][i] is Dictionary:
|
||||
result.append(VariableFolder.new(dialogic.current_state_info['variables'][i], i, self))
|
||||
return result
|
||||
|
||||
|
||||
func variables(_absolute:=false) -> Array:
|
||||
var result := []
|
||||
for i in dialogic.current_state_info['variables'].keys():
|
||||
if not dialogic.current_state_info['variables'][i] is Dictionary:
|
||||
result.append(i)
|
||||
return result
|
||||
#endregion
|
||||
|
||||
#region HELPERS
|
||||
################################################################################
|
||||
|
||||
func get_autoloads() -> Dictionary:
|
||||
var autoloads := {}
|
||||
for node: Node in get_tree().root.get_children():
|
||||
autoloads[node.name] = node
|
||||
return autoloads
|
||||
|
||||
|
||||
func merge_folder(new:Dictionary, defs:Dictionary) -> Dictionary:
|
||||
# also go through all groups in this folder
|
||||
for x in new.keys():
|
||||
if x in defs and typeof(new[x]) == TYPE_DICTIONARY:
|
||||
new[x] = merge_folder(new[x], defs[x])
|
||||
# add all new variables
|
||||
for x in defs.keys():
|
||||
if not x in new:
|
||||
new[x] = defs[x]
|
||||
return new
|
||||
|
||||
#endregion
|
||||
|
||||
#region VARIABLE FOLDER
|
||||
################################################################################
|
||||
class VariableFolder:
|
||||
var data := {}
|
||||
var path := ""
|
||||
var outside: DialogicSubsystem
|
||||
|
||||
func _init(_data:Dictionary, _path:String, _outside:DialogicSubsystem):
|
||||
data = _data
|
||||
path = _path
|
||||
outside = _outside
|
||||
|
||||
|
||||
func _get(property:StringName):
|
||||
property = str(property)
|
||||
if property in data:
|
||||
if typeof(data[property]) == TYPE_DICTIONARY:
|
||||
return VariableFolder.new(data[property], path+"."+property, outside)
|
||||
else:
|
||||
return DialogicUtil.logical_convert(data[property])
|
||||
|
||||
|
||||
func _set(property:StringName, value:Variant) -> bool:
|
||||
property = str(property)
|
||||
if not value is VariableFolder:
|
||||
DialogicUtil._set_value_in_dictionary(path+"."+property, outside.dialogic.current_state_info['variables'], value)
|
||||
return true
|
||||
|
||||
|
||||
func has(key:String) -> bool:
|
||||
return key in data
|
||||
|
||||
|
||||
func folders() -> Array:
|
||||
var result := []
|
||||
for i in data.keys():
|
||||
if data[i] is Dictionary:
|
||||
result.append(VariableFolder.new(data[i], path+"."+i, outside))
|
||||
return result
|
||||
|
||||
|
||||
func variables(absolute:=false) -> Array:
|
||||
var result := []
|
||||
for i in data.keys():
|
||||
if not data[i] is Dictionary:
|
||||
if absolute:
|
||||
result.append(path+'.'+i)
|
||||
else:
|
||||
result.append(i)
|
||||
return result
|
||||
|
||||
#endregion
|
||||
@@ -0,0 +1 @@
|
||||
uid://bdc3efaqj7mx1
|
||||
3
addons/dialogic/Modules/Variable/variable.svg
Normal file
3
addons/dialogic/Modules/Variable/variable.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13.9645 2.62927L12.8459 5.22444C12.6271 5.04546 12.3835 4.89134 12.1151 4.76208C11.8565 4.62287 11.5881 4.55327 11.3097 4.55327C11.0909 4.55327 10.8821 4.59802 10.6832 4.68751C10.4943 4.77699 10.3203 4.89631 10.1612 5.04546C10.0021 5.19461 9.86293 5.36364 9.74361 5.55256C9.6243 5.73154 9.52486 5.91052 9.44532 6.08949L9.14702 6.93964C9.35583 7.37714 9.55966 7.79475 9.75853 8.19248C9.92756 8.53055 10.1016 8.87359 10.2805 9.2216C10.4595 9.55966 10.6087 9.82813 10.728 10.027C10.9169 10.3153 11.1058 10.6136 11.2948 10.9219C11.4837 11.2202 11.6925 11.4936 11.9212 11.7422C12.0206 11.8516 12.1399 11.9261 12.2791 11.9659C12.4283 11.9957 12.5625 12.0107 12.6818 12.0107C12.8707 12.0107 13.0497 11.9858 13.2188 11.9361C13.3878 11.8864 13.5469 11.8217 13.696 11.7422L14.0689 12.2195C13.9297 12.4382 13.7607 12.657 13.5618 12.8757C13.3629 13.0945 13.1442 13.2933 12.9055 13.4723C12.6769 13.6513 12.4283 13.7955 12.1598 13.9048C11.9013 14.0242 11.6378 14.0838 11.3693 14.0838C11.1307 14.0838 10.9169 14.044 10.728 13.9645C10.549 13.8949 10.3849 13.8004 10.2358 13.6811C10.0867 13.5519 9.94745 13.4027 9.81819 13.2337C9.68893 13.0646 9.55469 12.8906 9.41549 12.7117C9.30611 12.5426 9.1868 12.3388 9.05753 12.1001C8.93822 11.8516 8.81393 11.598 8.68466 11.3395C8.5554 11.081 8.42614 10.8324 8.29688 10.5938C8.16762 10.3452 8.04333 10.1364 7.92401 9.96734C7.8743 10.1364 7.82955 10.3054 7.78978 10.4744C7.75001 10.6136 7.70526 10.7578 7.65555 10.907C7.60583 11.0561 7.56109 11.1705 7.52131 11.25C7.37216 11.5682 7.18324 11.8963 6.95455 12.2344C6.72586 12.5724 6.46236 12.8807 6.16407 13.1591C5.87572 13.4276 5.55753 13.6513 5.20952 13.8303C4.86151 13.9993 4.49361 14.0838 4.10583 14.0838C3.75782 14.0838 3.41975 14.0142 3.09162 13.875C2.7635 13.7457 2.46023 13.5717 2.18182 13.353L3.12145 10.8771C3.43964 11.076 3.78765 11.255 4.16549 11.4141C4.54333 11.5632 4.92117 11.6378 5.29901 11.6378C5.41833 11.6378 5.54262 11.6278 5.67188 11.608C5.80114 11.5781 5.92543 11.5384 6.04475 11.4886C6.17401 11.429 6.28836 11.3594 6.38779 11.2798C6.48722 11.1903 6.5618 11.0859 6.61151 10.9666C6.68111 10.8374 6.75569 10.6683 6.83523 10.4595C6.91478 10.2507 6.99432 10.0419 7.07387 9.8331C7.16336 9.59447 7.25285 9.34091 7.34234 9.07245L4.53836 4.5831C4.4091 4.43395 4.25001 4.31464 4.06109 4.22515C3.88211 4.12572 3.69319 4.076 3.49432 4.076C3.32529 4.076 3.1662 4.1108 3.01705 4.1804C2.8679 4.24006 2.72373 4.32458 2.58452 4.43395L2.18182 3.91194C2.32103 3.70313 2.48509 3.4993 2.67401 3.30043C2.87287 3.09162 3.08665 2.90768 3.31535 2.74859C3.54404 2.57955 3.78765 2.44532 4.04617 2.34589C4.30469 2.23651 4.56819 2.18182 4.83665 2.18182C5.16478 2.18182 5.46805 2.26634 5.74645 2.43537C6.02486 2.59447 6.28339 2.79333 6.52202 3.03197C6.76066 3.2706 6.97941 3.52912 7.17827 3.80753C7.37714 4.08594 7.55611 4.34447 7.7152 4.5831C7.79475 4.69248 7.87927 4.83168 7.96876 5.00072C8.06819 5.15981 8.16265 5.3189 8.25214 5.47799C8.36151 5.65697 8.46591 5.85086 8.56535 6.05966C8.66478 5.82103 8.76918 5.58239 8.87856 5.34376C8.96805 5.14489 9.05753 4.94106 9.14702 4.73225C9.24645 4.5135 9.33594 4.32458 9.41549 4.16549C9.56464 3.88708 9.73367 3.62856 9.92259 3.38992C10.1115 3.15128 10.3203 2.94248 10.549 2.7635C10.7876 2.58452 11.0462 2.44532 11.3246 2.34589C11.603 2.23651 11.9063 2.18182 12.2344 2.18182C12.5426 2.18182 12.8409 2.2216 13.1293 2.30114C13.4176 2.38069 13.696 2.49006 13.9645 2.62927Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
44
addons/dialogic/Modules/Variable/variable.svg.import
Normal file
44
addons/dialogic/Modules/Variable/variable.svg.import
Normal file
@@ -0,0 +1,44 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ckilxvwc34s84"
|
||||
path="res://.godot/imported/variable.svg-52aeb47fe1705a3f04d919f8dcd5d319.ctex"
|
||||
metadata={
|
||||
"has_editor_variant": true,
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dialogic/Modules/Variable/variable.svg"
|
||||
dest_files=["res://.godot/imported/variable.svg-52aeb47fe1705a3f04d919f8dcd5d319.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=true
|
||||
editor/convert_colors_with_editor_theme=true
|
||||
@@ -0,0 +1,352 @@
|
||||
@tool
|
||||
extends Tree
|
||||
|
||||
enum TreeButtons {ADD_FOLDER, ADD_VARIABLE, DUPLICATE_FOLDER, DELETE, CHANGE_TYPE}
|
||||
|
||||
@onready var editor: DialogicEditor = find_parent("VariablesEditor")
|
||||
|
||||
|
||||
#region INITIAL SETUP
|
||||
|
||||
func _ready() -> void:
|
||||
set_column_title(0, "Name")
|
||||
set_column_title(1, "")
|
||||
set_column_title(2, "Default Value")
|
||||
set_column_expand(1, false)
|
||||
set_column_expand_ratio(2, 2)
|
||||
set_column_title_alignment(0, 0)
|
||||
set_column_title_alignment(2, 0)
|
||||
|
||||
%ChangeTypePopup.self_modulate = get_theme_color("dark_color_3", "Editor")
|
||||
%ChangeTypePopup.theme.set_stylebox('pressed', 'Button', get_theme_stylebox("LaunchPadMovieMode", "EditorStyles"))
|
||||
%ChangeTypePopup.theme.set_stylebox('hover', 'Button', get_theme_stylebox("LaunchPadMovieMode", "EditorStyles"))
|
||||
for child in %ChangeTypePopup/HBox.get_children():
|
||||
child.toggled.connect(_on_type_pressed.bind(child.get_index()+1))
|
||||
child.icon = get_theme_icon(["String", "float", "int", "bool"][child.get_index()], "EditorIcons")
|
||||
|
||||
%RightClickMenu.set_item_icon(0, get_theme_icon("ActionCopy", "EditorIcons"))
|
||||
#endregion
|
||||
|
||||
|
||||
#region POPULATING THE TREE
|
||||
|
||||
func load_info(dict:Dictionary, parent:TreeItem = null, is_new:=false) -> void:
|
||||
if parent == null:
|
||||
clear()
|
||||
parent = add_folder_item("VAR", null)
|
||||
|
||||
var sorted_keys := dict.keys()
|
||||
sorted_keys.sort()
|
||||
for key in sorted_keys:
|
||||
if typeof(dict[key]) != TYPE_DICTIONARY:
|
||||
var item := add_variable_item(key, dict[key], parent)
|
||||
if is_new:
|
||||
item.set_meta("new", true)
|
||||
|
||||
for key in sorted_keys:
|
||||
if typeof(dict[key]) == TYPE_DICTIONARY:
|
||||
var folder := add_folder_item(key, parent)
|
||||
if is_new:
|
||||
folder.set_meta("new", true)
|
||||
load_info(dict[key], folder, is_new)
|
||||
|
||||
|
||||
|
||||
func add_variable_item(name:String, value:Variant, parent:TreeItem) -> TreeItem:
|
||||
var item := create_item(parent)
|
||||
item.set_meta("type", "VARIABLE")
|
||||
|
||||
item.set_text(0, name)
|
||||
item.set_editable(0, true)
|
||||
item.set_metadata(0, name)
|
||||
item.set_icon(0, load(DialogicUtil.get_module_path('Variable').path_join("variable.svg")))
|
||||
var folder_color: Color = parent.get_meta('color', Color.DARK_GOLDENROD)
|
||||
item.set_custom_bg_color(0, folder_color.lerp(get_theme_color("background", "Editor"), 0.8))
|
||||
|
||||
item.add_button(1, get_theme_icon("String", "EditorIcons"), TreeButtons.CHANGE_TYPE)
|
||||
adjust_variable_type(item, DialogicUtil.get_variable_value_type(value), value)
|
||||
item.set_editable(2, true)
|
||||
item.add_button(2, get_theme_icon("Remove", "EditorIcons"), TreeButtons.DELETE)
|
||||
|
||||
item.set_meta('prev_path', get_item_path(item))
|
||||
return item
|
||||
|
||||
|
||||
func add_folder_item(name:String, parent:TreeItem) -> TreeItem:
|
||||
var item := create_item(parent)
|
||||
item.set_icon(0, get_theme_icon("Folder", "EditorIcons"))
|
||||
item.set_text(0, name)
|
||||
item.set_editable(0, item != get_root())
|
||||
|
||||
var folder_color: Color
|
||||
if parent == null:
|
||||
folder_color = Color(0.33000001311302, 0.15179999172688, 0.15179999172688)
|
||||
else:
|
||||
folder_color = parent.get_meta('color')
|
||||
folder_color.h = wrap(folder_color.h+0.15*(item.get_index()+1), 0, 1)
|
||||
item.set_custom_bg_color(0, folder_color)
|
||||
item.set_custom_bg_color(1, folder_color)
|
||||
item.set_custom_bg_color(2, folder_color)
|
||||
item.set_meta('color', folder_color)
|
||||
item.add_button(2, load(self.get_script().get_path().get_base_dir().get_base_dir() + "/add-variable.svg"), TreeButtons.ADD_VARIABLE)
|
||||
item.add_button(2, load("res://addons/dialogic/Editor/Images/Pieces/add-folder.svg"), TreeButtons.ADD_FOLDER)
|
||||
item.add_button(2, get_theme_icon("Duplicate", "EditorIcons"), TreeButtons.DUPLICATE_FOLDER, item == get_root())
|
||||
item.add_button(2, get_theme_icon("Remove", "EditorIcons"), TreeButtons.DELETE, item == get_root())
|
||||
item.set_meta("type", "FOLDER")
|
||||
return item
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region EDITING THE TREE
|
||||
|
||||
func set_variable_item_type(item:TreeItem, type:int) -> void:
|
||||
item.set_meta('value_type', type)
|
||||
item.set_button(1, 0, get_theme_icon(["Variant", "String", "float", "int", "bool"][type], "EditorIcons"))
|
||||
|
||||
|
||||
func get_variable_item_default(item:TreeItem) -> Variant:
|
||||
match int(item.get_meta('value_type', DialogicUtil.VarTypes.STRING)):
|
||||
DialogicUtil.VarTypes.STRING:
|
||||
return item.get_text(2)
|
||||
DialogicUtil.VarTypes.FLOAT:
|
||||
return item.get_range(2)
|
||||
DialogicUtil.VarTypes.INT:
|
||||
return int(item.get_range(2))
|
||||
DialogicUtil.VarTypes.BOOL:
|
||||
return item.is_checked(2)
|
||||
return ""
|
||||
|
||||
|
||||
func _on_button_clicked(item: TreeItem, column: int, id: int, mouse_button_index: int) -> void:
|
||||
match id:
|
||||
TreeButtons.ADD_FOLDER:
|
||||
var new_item := add_folder_item("Folder", item)
|
||||
new_item.select(0)
|
||||
new_item.set_meta("new", true)
|
||||
await get_tree().process_frame
|
||||
edit_selected()
|
||||
TreeButtons.ADD_VARIABLE:
|
||||
var new_item := add_variable_item("Var", "", item)
|
||||
new_item.select(0)
|
||||
new_item.set_meta("new", true)
|
||||
await get_tree().process_frame
|
||||
edit_selected()
|
||||
TreeButtons.DELETE:
|
||||
item.free()
|
||||
TreeButtons.DUPLICATE_FOLDER:
|
||||
load_info({item.get_text(0)+"(copy)":get_info(item)}, item.get_parent(), true)
|
||||
TreeButtons.CHANGE_TYPE:
|
||||
%ChangeTypePopup.show()
|
||||
%ChangeTypePopup.set_meta('item', item)
|
||||
%ChangeTypePopup.position = get_local_mouse_position()+Vector2(-%ChangeTypePopup.size.x/2, 10)
|
||||
for child in %ChangeTypePopup/HBox.get_children():
|
||||
child.set_pressed_no_signal(false)
|
||||
%ChangeTypePopup/HBox.get_child(int(item.get_meta('value_type', DialogicUtil.VarTypes.STRING)-1)).set_pressed_no_signal(true)
|
||||
|
||||
|
||||
func _on_type_pressed(pressed:bool, type:int) -> void:
|
||||
%ChangeTypePopup.hide()
|
||||
var item: Variant = %ChangeTypePopup.get_meta('item')
|
||||
adjust_variable_type(item, type, item.get_metadata(2))
|
||||
|
||||
|
||||
func _on_item_edited() -> void:
|
||||
var item := get_edited()
|
||||
match item.get_meta('type'):
|
||||
"VARIABLE":
|
||||
match get_edited_column():
|
||||
0:
|
||||
if item.get_text(0).is_empty():
|
||||
item.set_text(0, item.get_metadata(0))
|
||||
|
||||
else:
|
||||
if item.get_text(0) != item.get_metadata(0):
|
||||
item.set_metadata(0, item.get_text(0))
|
||||
report_name_changes(item)
|
||||
|
||||
2:
|
||||
item.set_metadata(2, get_variable_item_default(item))
|
||||
"FOLDER":
|
||||
report_name_changes(item)
|
||||
|
||||
|
||||
func adjust_variable_type(item:TreeItem, type:int, prev_value:Variant) -> void:
|
||||
set_variable_item_type(item, type)
|
||||
match type:
|
||||
DialogicUtil.VarTypes.STRING:
|
||||
item.set_metadata(2, str(prev_value))
|
||||
item.set_cell_mode(2, TreeItem.CELL_MODE_STRING)
|
||||
item.set_text(2, str(prev_value))
|
||||
DialogicUtil.VarTypes.FLOAT:
|
||||
item.set_metadata(2, float(prev_value))
|
||||
item.set_cell_mode(2, TreeItem.CELL_MODE_RANGE)
|
||||
item.set_range_config(2, -9999, 9999, 0.001, false)
|
||||
item.set_range(2, float(prev_value))
|
||||
DialogicUtil.VarTypes.INT:
|
||||
item.set_metadata(2, int(prev_value))
|
||||
item.set_cell_mode(2, TreeItem.CELL_MODE_RANGE)
|
||||
item.set_range_config(2, -9999, 9999, 1, false)
|
||||
item.set_range(2, int(prev_value))
|
||||
DialogicUtil.VarTypes.BOOL:
|
||||
item.set_metadata(2, prev_value and true)
|
||||
item.set_cell_mode(2, TreeItem.CELL_MODE_CHECK)
|
||||
item.set_checked(2, prev_value and true)
|
||||
|
||||
|
||||
func _input(event):
|
||||
if !%ChangeTypePopup.visible:
|
||||
return
|
||||
if event is InputEventMouseButton and event.pressed:
|
||||
if not %ChangeTypePopup.get_global_rect().has_point(get_global_mouse_position()):
|
||||
%ChangeTypePopup.hide()
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
func filter(filter_term:String, item:TreeItem = null) -> bool:
|
||||
if item == null:
|
||||
item = get_root()
|
||||
|
||||
var any := false
|
||||
for child in item.get_children():
|
||||
match child.get_meta('type'):
|
||||
"VARIABLE":
|
||||
child.visible = filter_term.is_empty() or filter_term.to_lower() in child.get_text(0).to_lower()
|
||||
|
||||
"FOLDER":
|
||||
child.visible = filter(filter_term, child)
|
||||
if child.visible:
|
||||
any = true
|
||||
return any
|
||||
|
||||
|
||||
## Parses the tree and returns a dictionary representing it.
|
||||
func get_info(item:TreeItem = null) -> Dictionary:
|
||||
if item == null:
|
||||
item = get_root()
|
||||
if item == null:
|
||||
return {}
|
||||
|
||||
var dict := {}
|
||||
|
||||
for child in item.get_children():
|
||||
match child.get_meta('type'):
|
||||
"VARIABLE":
|
||||
dict[child.get_text(0)] = child.get_metadata(2)
|
||||
"FOLDER":
|
||||
dict[child.get_text(0)] = get_info(child)
|
||||
|
||||
return dict
|
||||
|
||||
|
||||
#region DRAG AND DROP
|
||||
################################################################################
|
||||
|
||||
func _get_drag_data(position:Vector2) -> Variant:
|
||||
drop_mode_flags = DROP_MODE_INBETWEEN
|
||||
var preview := Label.new()
|
||||
preview.text = " "+get_selected().get_text(0)
|
||||
preview.add_theme_stylebox_override('normal', get_theme_stylebox("Background", "EditorStyles"))
|
||||
set_drag_preview(preview)
|
||||
|
||||
return get_selected()
|
||||
|
||||
|
||||
func _can_drop_data(position:Vector2, data:Variant) -> bool:
|
||||
return data is TreeItem
|
||||
|
||||
|
||||
func _drop_data(position:Vector2, item:Variant) -> void:
|
||||
var to_item := get_item_at_position(position)
|
||||
|
||||
if !to_item:
|
||||
return
|
||||
|
||||
var drop_section := get_drop_section_at_position(position)
|
||||
var parent: TreeItem = null
|
||||
if (drop_section == 1 and to_item.get_meta('type') == "FOLDER") or to_item == get_root():
|
||||
parent = to_item
|
||||
else:
|
||||
parent = to_item.get_parent()
|
||||
|
||||
## Test for inheritance-recursion
|
||||
var test_item := to_item
|
||||
while true:
|
||||
if test_item == item:
|
||||
return
|
||||
test_item = test_item.get_parent()
|
||||
if test_item == get_root():
|
||||
break
|
||||
|
||||
var new_item: TreeItem = null
|
||||
match item.get_meta('type'):
|
||||
"VARIABLE":
|
||||
new_item = add_variable_item(item.get_text(0), item.get_metadata(2), parent)
|
||||
new_item.set_meta('prev_path', get_item_path(item))
|
||||
if item.get_meta("new", false):
|
||||
new_item.set_meta("new", true)
|
||||
"FOLDER":
|
||||
new_item = add_folder_item(item.get_text(0), parent)
|
||||
load_info(get_info(item), new_item)
|
||||
if item.get_meta("new", false):
|
||||
new_item.set_meta("new", true)
|
||||
|
||||
# If this was dropped on a variable (or the root node)
|
||||
if to_item != parent:
|
||||
if drop_section == -1:
|
||||
new_item.move_before(to_item)
|
||||
else:
|
||||
new_item.move_after(to_item)
|
||||
|
||||
report_name_changes(new_item)
|
||||
|
||||
item.free()
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region NAME CHANGES
|
||||
################################################################################
|
||||
|
||||
func report_name_changes(item:TreeItem) -> void:
|
||||
|
||||
match item.get_meta('type'):
|
||||
"VARIABLE":
|
||||
if item.get_meta("new", false):
|
||||
return
|
||||
var new_path := get_item_path(item)
|
||||
editor.variable_renamed(item.get_meta('prev_path'), new_path)
|
||||
item.set_meta('prev_path', new_path)
|
||||
"FOLDER":
|
||||
for child in item.get_children():
|
||||
report_name_changes(child)
|
||||
|
||||
|
||||
func get_item_path(item:TreeItem) -> String:
|
||||
var path := item.get_text(0)
|
||||
while item.get_parent() != get_root():
|
||||
item = item.get_parent()
|
||||
path = item.get_text(0)+"."+path
|
||||
return path
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
func _on_gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_MASK_RIGHT and event.pressed:
|
||||
var item := get_item_at_position(get_local_mouse_position())
|
||||
if item and item != get_root():
|
||||
%RightClickMenu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2()))
|
||||
%RightClickMenu.set_item_text(0, 'Copy "' + get_item_path(item) + '"')
|
||||
%RightClickMenu.set_meta("item", item)
|
||||
%RightClickMenu.size = Vector2()
|
||||
|
||||
|
||||
func _on_right_click_menu_id_pressed(id: int) -> void:
|
||||
if %RightClickMenu.get_meta("item", null) == null:
|
||||
return
|
||||
match id:
|
||||
0:
|
||||
DisplayServer.clipboard_set(get_item_path(%RightClickMenu.get_meta("item")))
|
||||
@@ -0,0 +1 @@
|
||||
uid://c88wa435f7ak0
|
||||
@@ -0,0 +1,58 @@
|
||||
@tool
|
||||
extends DialogicEditor
|
||||
|
||||
## Editor that allows
|
||||
|
||||
#region EDITOR STUFF
|
||||
|
||||
func _get_title() -> String:
|
||||
return "Variables"
|
||||
|
||||
|
||||
func _get_icon() -> Texture:
|
||||
return load(self.get_script().get_path().get_base_dir().get_base_dir() + "/variable.svg")
|
||||
|
||||
|
||||
func _register() -> void:
|
||||
editors_manager.register_simple_editor(self)
|
||||
alternative_text = "Create and edit dialogic variables and their default values"
|
||||
|
||||
|
||||
func _open(argument:Variant = null):
|
||||
%ReferenceInfo.hide()
|
||||
%Tree.load_info(ProjectSettings.get_setting('dialogic/variables', {}))
|
||||
|
||||
|
||||
func _save() -> void:
|
||||
ProjectSettings.set_setting('dialogic/variables', %Tree.get_info())
|
||||
ProjectSettings.save()
|
||||
|
||||
|
||||
func _close() -> void:
|
||||
_save()
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
func _ready() -> void:
|
||||
%ReferenceInfo.get_node('Label').add_theme_color_override('font_color', get_theme_color("warning_color", "Editor"))
|
||||
%Search.right_icon = get_theme_icon("Search", "EditorIcons")
|
||||
|
||||
#region RENAMING
|
||||
|
||||
func variable_renamed(old_name:String, new_name:String):
|
||||
if old_name == new_name:
|
||||
return
|
||||
editors_manager.reference_manager.add_variable_ref_change(old_name, new_name)
|
||||
%ReferenceInfo.show()
|
||||
|
||||
|
||||
func _on_reference_manager_pressed() -> void:
|
||||
editors_manager.reference_manager.open()
|
||||
%ReferenceInfo.hide()
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
func _on_search_text_changed(new_text: String) -> void:
|
||||
%Tree.filter(new_text)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dtucy3td5s643
|
||||
@@ -0,0 +1,197 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://6tdle4y5o03o"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Modules/Variable/variables_editor/variables_editor.gd" id="2"]
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Modules/Variable/variables_editor/variable_tree.gd" id="2_1i17i"]
|
||||
|
||||
[sub_resource type="Image" id="Image_e1dkh"]
|
||||
data = {
|
||||
"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),
|
||||
"format": "RGBA8",
|
||||
"height": 16,
|
||||
"mipmaps": false,
|
||||
"width": 16
|
||||
}
|
||||
|
||||
[sub_resource type="ImageTexture" id="ImageTexture_sr7s6"]
|
||||
image = SubResource("Image_e1dkh")
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7aodm"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0.44, 0.73, 0.98, 0.1)
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
border_color = Color(0.44, 0.73, 0.98, 1)
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
corner_detail = 3
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_vn21i"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ffuxp"]
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0.44, 0.73, 0.98, 0.1)
|
||||
border_width_bottom = 2
|
||||
border_color = Color(0.44, 0.73, 0.98, 1)
|
||||
expand_margin_left = 4.0
|
||||
expand_margin_top = 2.0
|
||||
expand_margin_right = 4.0
|
||||
expand_margin_bottom = 4.0
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="Theme" id="Theme_17j6i"]
|
||||
Button/styles/hover = SubResource("StyleBoxFlat_7aodm")
|
||||
Button/styles/normal = SubResource("StyleBoxEmpty_vn21i")
|
||||
Button/styles/pressed = SubResource("StyleBoxFlat_7aodm")
|
||||
pressed/styles/Button = SubResource("StyleBoxFlat_ffuxp")
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ncgqs"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
|
||||
[node name="VariablesEditor" type="HSplitContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Editor" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="Editor"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Editor/HBox"]
|
||||
layout_mode = 2
|
||||
theme_type_variation = &"DialogicSubTitle"
|
||||
text = "Variables"
|
||||
|
||||
[node name="Search" type="LineEdit" parent="Editor/HBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Search"
|
||||
right_icon = SubResource("ImageTexture_sr7s6")
|
||||
|
||||
[node name="Tree" type="Tree" parent="Editor"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_type_variation = &"DialogicPanelB"
|
||||
theme_override_constants/button_margin = 4
|
||||
theme_override_constants/draw_guides = 1
|
||||
columns = 3
|
||||
column_titles_visible = true
|
||||
script = ExtResource("2_1i17i")
|
||||
|
||||
[node name="ChangeTypePopup" type="PanelContainer" parent="Editor/Tree"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
self_modulate = Color(0, 0, 0, 1)
|
||||
layout_mode = 0
|
||||
offset_left = 140.0
|
||||
offset_top = 160.0
|
||||
offset_right = 272.0
|
||||
offset_bottom = 190.0
|
||||
theme = SubResource("Theme_17j6i")
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ncgqs")
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="Editor/Tree/ChangeTypePopup"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="String" type="Button" parent="Editor/Tree/ChangeTypePopup/HBox"]
|
||||
custom_minimum_size = Vector2(30, 30)
|
||||
layout_mode = 2
|
||||
tooltip_text = "String (Any text)"
|
||||
toggle_mode = true
|
||||
icon = SubResource("ImageTexture_sr7s6")
|
||||
icon_alignment = 1
|
||||
|
||||
[node name="Float" type="Button" parent="Editor/Tree/ChangeTypePopup/HBox"]
|
||||
custom_minimum_size = Vector2(30, 30)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Float (Number with Decimals)"
|
||||
toggle_mode = true
|
||||
icon = SubResource("ImageTexture_sr7s6")
|
||||
icon_alignment = 1
|
||||
|
||||
[node name="Int" type="Button" parent="Editor/Tree/ChangeTypePopup/HBox"]
|
||||
custom_minimum_size = Vector2(30, 30)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Int (Integer)"
|
||||
toggle_mode = true
|
||||
icon = SubResource("ImageTexture_sr7s6")
|
||||
icon_alignment = 1
|
||||
|
||||
[node name="Bool" type="Button" parent="Editor/Tree/ChangeTypePopup/HBox"]
|
||||
custom_minimum_size = Vector2(30, 30)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Bool (True/False flag)"
|
||||
toggle_mode = true
|
||||
icon = SubResource("ImageTexture_sr7s6")
|
||||
icon_alignment = 1
|
||||
|
||||
[node name="RightClickMenu" type="PopupMenu" parent="Editor/Tree"]
|
||||
unique_name_in_owner = true
|
||||
size = Vector2i(67, 35)
|
||||
item_count = 1
|
||||
item_0/text = "Copy"
|
||||
item_0/id = 0
|
||||
|
||||
[node name="ReferenceInfo" type="HBoxContainer" parent="Editor"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Editor/ReferenceInfo"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
text = "You've made some changes to existing variables! Use the reference manager to check if something broke."
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="ReferenceManager" type="Button" parent="Editor/ReferenceInfo"]
|
||||
layout_mode = 2
|
||||
text = "Reference Manager"
|
||||
|
||||
[node name="Info" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="Info"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="Info/HBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_type_variation = &"DialogicSection"
|
||||
text = "How to use variables"
|
||||
|
||||
[node name="Documentation" type="LinkButton" parent="Info/HBox"]
|
||||
layout_mode = 2
|
||||
text = "Read the Docs"
|
||||
uri = "https://docs.dialogic.pro/variables.html"
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Info"]
|
||||
layout_mode = 2
|
||||
text = "Variables are good way to keep track of all kinds of things during your game. Dialogic has an easy-to-use and beginner friendly variable system built in. However Dialogic allows to use outside variables (of Autoload Singletons) just as easily. You can also access the Dialogic variables from outside scripts."
|
||||
fit_content = true
|
||||
|
||||
[connection signal="text_changed" from="Editor/HBox/Search" to="." method="_on_search_text_changed"]
|
||||
[connection signal="button_clicked" from="Editor/Tree" to="Editor/Tree" method="_on_button_clicked"]
|
||||
[connection signal="gui_input" from="Editor/Tree" to="Editor/Tree" method="_on_gui_input"]
|
||||
[connection signal="item_edited" from="Editor/Tree" to="Editor/Tree" method="_on_item_edited"]
|
||||
[connection signal="id_pressed" from="Editor/Tree/RightClickMenu" to="Editor/Tree" method="_on_right_click_menu_id_pressed"]
|
||||
[connection signal="pressed" from="Editor/ReferenceInfo/ReferenceManager" to="." method="_on_reference_manager_pressed"]
|
||||
Reference in New Issue
Block a user