First work on dialogic, resized guild, and started implementing portraits.
This commit is contained in:
148
addons/dialogic/Modules/Condition/event_condition.gd
Normal file
148
addons/dialogic/Modules/Condition/event_condition.gd
Normal file
@@ -0,0 +1,148 @@
|
||||
@tool
|
||||
class_name DialogicConditionEvent
|
||||
extends DialogicEvent
|
||||
|
||||
## Event that allows branching a timeline based on a condition.
|
||||
|
||||
enum ConditionTypes {IF, ELIF, ELSE}
|
||||
|
||||
### Settings
|
||||
## condition type (see [ConditionTypes]). Defaults to if.
|
||||
var condition_type := ConditionTypes.IF
|
||||
## The condition as a string. Will be executed as an Expression.
|
||||
var condition := ""
|
||||
|
||||
|
||||
################################################################################
|
||||
## EXECUTE
|
||||
################################################################################
|
||||
|
||||
func _execute() -> void:
|
||||
if condition_type == ConditionTypes.ELSE:
|
||||
finish()
|
||||
return
|
||||
|
||||
if condition.is_empty(): condition = "true"
|
||||
|
||||
var result: bool = dialogic.Expressions.execute_condition(condition)
|
||||
if not result:
|
||||
var idx: int = dialogic.current_event_idx
|
||||
var ignore := 1
|
||||
while true:
|
||||
idx += 1
|
||||
if not dialogic.current_timeline.get_event(idx) or ignore == 0:
|
||||
break
|
||||
elif dialogic.current_timeline.get_event(idx).can_contain_events:
|
||||
ignore += 1
|
||||
elif dialogic.current_timeline.get_event(idx) is DialogicEndBranchEvent:
|
||||
ignore -= 1
|
||||
|
||||
dialogic.current_event_idx = idx-1
|
||||
finish()
|
||||
|
||||
|
||||
## only called if the previous event was an end-branch event
|
||||
## return true if this event should be executed if the previous event was an end-branch event
|
||||
func should_execute_this_branch() -> bool:
|
||||
return condition_type == ConditionTypes.IF
|
||||
|
||||
|
||||
################################################################################
|
||||
## INITIALIZE
|
||||
################################################################################
|
||||
|
||||
func _init() -> void:
|
||||
event_name = "Condition"
|
||||
set_default_color('Color3')
|
||||
event_category = "Flow"
|
||||
event_sorting_index = 1
|
||||
can_contain_events = true
|
||||
|
||||
|
||||
# return a control node that should show on the END BRANCH node
|
||||
func get_end_branch_control() -> Control:
|
||||
return load(get_script().resource_path.get_base_dir().path_join('ui_condition_end.tscn')).instantiate()
|
||||
|
||||
################################################################################
|
||||
## SAVING/LOADING
|
||||
################################################################################
|
||||
|
||||
func to_text() -> String:
|
||||
var result_string := ""
|
||||
|
||||
match condition_type:
|
||||
ConditionTypes.IF:
|
||||
result_string = 'if '+condition+':'
|
||||
ConditionTypes.ELIF:
|
||||
result_string = 'elif '+condition+':'
|
||||
ConditionTypes.ELSE:
|
||||
result_string = 'else:'
|
||||
|
||||
return result_string
|
||||
|
||||
|
||||
func from_text(string:String) -> void:
|
||||
if string.strip_edges().begins_with('if'):
|
||||
condition = string.strip_edges().trim_prefix('if ').trim_suffix(':').strip_edges()
|
||||
condition_type = ConditionTypes.IF
|
||||
elif string.strip_edges().begins_with('elif'):
|
||||
condition = string.strip_edges().trim_prefix('elif ').trim_suffix(':').strip_edges()
|
||||
condition_type = ConditionTypes.ELIF
|
||||
elif string.strip_edges().begins_with('else'):
|
||||
condition = ""
|
||||
condition_type = ConditionTypes.ELSE
|
||||
|
||||
|
||||
func is_valid_event(string:String) -> bool:
|
||||
if string.strip_edges() in ['if', 'elif', 'else'] or (string.strip_edges().begins_with('if ') or string.strip_edges().begins_with('elif ') or string.strip_edges().begins_with('else')):
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
################################################################################
|
||||
## EDITOR REPRESENTATION
|
||||
################################################################################
|
||||
|
||||
func build_event_editor() -> void:
|
||||
add_header_edit('condition_type', ValueType.FIXED_OPTIONS, {
|
||||
'options': [
|
||||
{
|
||||
'label': 'IF',
|
||||
'value': ConditionTypes.IF,
|
||||
},
|
||||
{
|
||||
'label': 'ELIF',
|
||||
'value': ConditionTypes.ELIF,
|
||||
},
|
||||
{
|
||||
'label': 'ELSE',
|
||||
'value': ConditionTypes.ELSE,
|
||||
}
|
||||
], 'disabled':true})
|
||||
add_header_edit('condition', ValueType.CONDITION, {}, 'condition_type != %s'%ConditionTypes.ELSE)
|
||||
|
||||
|
||||
####################### CODE COMPLETION ########################################
|
||||
################################################################################
|
||||
|
||||
func _get_code_completion(CodeCompletionHelper:Node, TextNode:TextEdit, line:String, _word:String, symbol:String) -> void:
|
||||
if (line.begins_with('if') or line.begins_with('elif')) and symbol == '{':
|
||||
CodeCompletionHelper.suggest_variables(TextNode)
|
||||
|
||||
|
||||
func _get_start_code_completion(_CodeCompletionHelper:Node, TextNode:TextEdit) -> void:
|
||||
TextNode.add_code_completion_option(CodeEdit.KIND_PLAIN_TEXT, 'if', 'if ', TextNode.syntax_highlighter.code_flow_color)
|
||||
TextNode.add_code_completion_option(CodeEdit.KIND_PLAIN_TEXT, 'elif', 'elif ', TextNode.syntax_highlighter.code_flow_color)
|
||||
TextNode.add_code_completion_option(CodeEdit.KIND_PLAIN_TEXT, 'else', 'else:\n ', TextNode.syntax_highlighter.code_flow_color)
|
||||
|
||||
|
||||
#################### SYNTAX HIGHLIGHTING #######################################
|
||||
################################################################################
|
||||
|
||||
|
||||
func _get_syntax_highlighting(Highlighter:SyntaxHighlighter, dict:Dictionary, line:String) -> Dictionary:
|
||||
var word := line.get_slice(' ', 0)
|
||||
dict[line.find(word)] = {"color":Highlighter.code_flow_color}
|
||||
dict[line.find(word)+len(word)] = {"color":Highlighter.normal_color}
|
||||
dict = Highlighter.color_condition(dict, line)
|
||||
return dict
|
||||
1
addons/dialogic/Modules/Condition/event_condition.gd.uid
Normal file
1
addons/dialogic/Modules/Condition/event_condition.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dt0wbs8koq0km
|
||||
12
addons/dialogic/Modules/Condition/icon.svg
Normal file
12
addons/dialogic/Modules/Condition/icon.svg
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg width="63.999996" height="63.999996" viewBox="0 0 16.933332 16.933332" version="1.1" id="svg5" inkscape:export-filename="condition-icon.svg" inkscape:export-xdpi="96" inkscape:export-ydpi="96" sodipodi:docname="icon.svg" inkscape:version="1.2.2 (732a01da63, 2022-12-09)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview id="namedview7" pagecolor="#ffffff" bordercolor="#000000" borderopacity="0.25" inkscape:showpageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:document-units="mm" showgrid="false" showguides="true" inkscape:zoom="1.6347657" inkscape:cx="-20.492233" inkscape:cy="-96.038226" inkscape:window-width="1920" inkscape:window-height="1017" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" inkscape:current-layer="svg5" />
|
||||
<defs id="defs2" />
|
||||
<path id="path22732" style="stroke-width:1.28593;stroke-dasharray:none;fill:#ffffff;color:#000000;fill-opacity:0.45;stroke-linecap:round;stroke-linejoin:round" d="m -71.974852,-11.59036 c -0.483439,0.03047 -0.990446,0.05427 -1.422078,0.09835 -4.072307,0.415892 -7.64202,1.269927 -10.422371,3.8196754 -2.780352,2.5497501 -3.858991,6.1377302 -4.31408,9.9545471 -0.255536,2.1431512 -0.348662,4.5365819 -0.388081,7.2300049 -1.4e-5,9.111e-4 1.3e-5,0.00175 0,0.00266 a 8.4415045,8.4415045 0 0 0 -3.710694,6.9509056 8.4415045,8.4415045 0 0 0 8.442094,8.442094 8.4415045,8.4415045 0 0 0 8.439436,-8.442094 8.4415045,8.4415045 0 0 0 -3.633609,-6.9349571 c 0.04202,-2.4939081 0.12555,-4.566242 0.310996,-6.1215813 0.335629,-2.81487882 0.851715,-3.6528496 1.29449,-4.05890348 0.44278,-0.40605392 1.724439,-1.03690872 4.949364,-1.36625832 1.306091,-0.1333859 2.944876,-0.2069313 4.779246,-0.2578347 -2.274077,-1.8226451 -7.703145,-6.1839349 -7.703145,-6.405997 0,-0.1168195 1.570967,-1.4331011 3.378432,-2.9106081 z m -11.81521,19.6167041 a 8.4415045,8.4415045 0 0 0 -1.305122,0.1142979 8.4415045,8.4415045 0 0 1 1.305122,-0.1142979 z m -2.190266,0.3216289 a 8.4415045,8.4415045 0 0 0 -0.358842,0.095691 8.4415045,8.4415045 0 0 1 0.358842,-0.095691 z m -1.35031,0.4917466 a 8.4415045,8.4415045 0 0 0 -0.164801,0.074427 8.4415045,8.4415045 0 0 1 0.164801,-0.074427 z" transform="matrix(0.1944119,0,0,0.1944119,19.699396,10.154114)" />
|
||||
<circle style="stroke-width:1.31524;stroke-dasharray:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" id="path22484" cx="-57.670414" cy="-33.437908" r="8.4415045" transform="matrix(0.1944119,0,0,0.1944119,19.699396,10.154114)" />
|
||||
<path id="path21748" style="stroke-width:1.28345;stroke-dasharray:none;fill:#ffffff;color:#000000;stroke-linecap:round;stroke-linejoin:round;-inkscape-stroke:none" d="m -57.93482,-33.437202 a 4.7632976,4.7632976 0 0 0 -4.712794,4.811143 l 0.09037,9.186359 c 2.239956,-1.935188 4.604724,-3.944606 4.779246,-3.944606 0.174522,0 2.53929,2.009418 4.779246,3.944606 l 0.09038,-9.186359 a 4.7632976,4.7632976 0 0 0 -4.715452,-4.811143 4.7632976,4.7632976 0 0 0 -0.154169,0.02392 4.7632976,4.7632976 0 0 0 -0.156827,-0.02392 z m 14.351028,21.844184 c 1.808699,1.478479 3.38109,2.796384 3.38109,2.9132662 0,0.2219874 -5.424909,4.5821407 -7.700486,6.405997 1.797768,0.050169 3.408936,0.1219386 4.696845,0.2525186 3.217204,0.32619 4.51554,0.9531571 4.973286,1.36891633 0.457749,0.41575927 0.975761,1.25405428 1.323729,4.06421967 0.347967,2.8101653 0.382765,7.1584092 0.382765,13.0538802 a 4.7632976,4.7632976 0 0 0 4.760639,4.765955 4.7632976,4.7632976 0 0 0 4.763297,-4.765955 c 0,-5.900707 0.02453,-10.3975383 -0.449217,-14.2234398 -0.473738,-3.8259015 -1.587699,-7.4123327 -4.377874,-9.9465729 -2.790176,-2.5342393 -6.355607,-3.3839673 -10.417055,-3.7957523 -0.406605,-0.04123 -0.884609,-0.06397 -1.337019,-0.09303 z" transform="matrix(0.1944119,0,0,0.1944119,19.699396,10.154114)" />
|
||||
<circle style="stroke-width:1.31524;stroke-dasharray:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" id="circle22488" cx="-31.835474" cy="16.466833" r="8.4415045" transform="matrix(0.1944119,0,0,0.1944119,19.699396,10.154114)" />
|
||||
<path sodipodi:type="star" style="stroke-width:9.5266;stroke-dasharray:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" id="path22546" inkscape:flatsided="false" sodipodi:sides="4" sodipodi:cx="6.6831412" sodipodi:cy="16.177292" sodipodi:r1="6.2749648" sodipodi:r2="8.9210739" sodipodi:arg1="0.78539816" sodipodi:arg2="1.5707963" inkscape:rounded="0.02640344" inkscape:randomized="0" d="m 11.120211,20.614362 c -0.117775,0.117775 -4.2705103,4.484004 -4.4370695,4.484004 -0.1665592,0 -4.3192953,-4.366229 -4.4370704,-4.484004 -0.1177752,-0.117775 -4.4840038,-4.270511 -4.4840038,-4.43707 0,-0.166559 4.3662286,-4.319295 4.4840037,-4.43707 0.1177752,-0.117775 4.2705108,-4.484004 4.43707,-4.484004 0.1665592,0 4.319295,4.366229 4.43707,4.484004 0.117776,0.117775 4.484004,4.27051 4.484004,4.43707 0,0.166559 -4.366228,4.319295 -4.484004,4.43707 z" transform="matrix(0.26708005,0,0,0.22344459,6.6817327,4.8519382)" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.3 KiB |
44
addons/dialogic/Modules/Condition/icon.svg.import
Normal file
44
addons/dialogic/Modules/Condition/icon.svg.import
Normal file
@@ -0,0 +1,44 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bco4t1ey0fkpm"
|
||||
path="res://.godot/imported/icon.svg-502d45c064cc30f576b7b105a01357ce.ctex"
|
||||
metadata={
|
||||
"has_editor_variant": true,
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/dialogic/Modules/Condition/icon.svg"
|
||||
dest_files=["res://.godot/imported/icon.svg-502d45c064cc30f576b7b105a01357ce.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
|
||||
6
addons/dialogic/Modules/Condition/index.gd
Normal file
6
addons/dialogic/Modules/Condition/index.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
@tool
|
||||
extends DialogicIndexer
|
||||
|
||||
|
||||
func _get_events() -> Array:
|
||||
return [this_folder.path_join('event_condition.gd')]
|
||||
1
addons/dialogic/Modules/Condition/index.gd.uid
Normal file
1
addons/dialogic/Modules/Condition/index.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://htb62ut51r8b
|
||||
51
addons/dialogic/Modules/Condition/ui_condition_end.gd
Normal file
51
addons/dialogic/Modules/Condition/ui_condition_end.gd
Normal file
@@ -0,0 +1,51 @@
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
var parent_resource: DialogicEvent = null
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$AddElif.button_up.connect(add_elif)
|
||||
$AddElse.button_up.connect(add_else)
|
||||
|
||||
|
||||
func refresh() -> void:
|
||||
if parent_resource is DialogicConditionEvent:
|
||||
# hide add elif and add else button on ELSE event
|
||||
$AddElif.visible = parent_resource.condition_type != DialogicConditionEvent.ConditionTypes.ELSE
|
||||
$AddElse.visible = parent_resource.condition_type != DialogicConditionEvent.ConditionTypes.ELSE
|
||||
$Label.text = "End of "+["IF", "ELIF", "ELSE"][parent_resource.condition_type]+" ("+parent_resource.condition+")"
|
||||
|
||||
# hide add add else button if followed by ELIF or ELSE event
|
||||
var timeline_editor := find_parent('VisualEditor')
|
||||
if timeline_editor:
|
||||
var next_event: DialogicEvent = null
|
||||
if timeline_editor.get_block_below(get_parent()):
|
||||
next_event = timeline_editor.get_block_below(get_parent()).resource
|
||||
if next_event is DialogicConditionEvent:
|
||||
if next_event.condition_type != DialogicConditionEvent.ConditionTypes.IF:
|
||||
$AddElse.hide()
|
||||
if parent_resource.condition_type == DialogicConditionEvent.ConditionTypes.ELSE:
|
||||
$Label.text = "End of ELSE"
|
||||
else:
|
||||
hide()
|
||||
|
||||
|
||||
func add_elif() -> void:
|
||||
var timeline := find_parent('VisualEditor')
|
||||
if timeline:
|
||||
var resource := DialogicConditionEvent.new()
|
||||
resource.condition_type = DialogicConditionEvent.ConditionTypes.ELIF
|
||||
timeline.add_event_undoable(resource, get_parent().get_index()+1)
|
||||
timeline.indent_events()
|
||||
timeline.something_changed()
|
||||
|
||||
|
||||
func add_else() -> void:
|
||||
var timeline := find_parent('VisualEditor')
|
||||
if timeline:
|
||||
var resource := DialogicConditionEvent.new()
|
||||
resource.condition_type = DialogicConditionEvent.ConditionTypes.ELSE
|
||||
timeline.add_event_undoable(resource, get_parent().get_index()+1)
|
||||
timeline.indent_events()
|
||||
timeline.something_changed()
|
||||
@@ -0,0 +1 @@
|
||||
uid://beewnj1mjs57h
|
||||
26
addons/dialogic/Modules/Condition/ui_condition_end.tscn
Normal file
26
addons/dialogic/Modules/Condition/ui_condition_end.tscn
Normal file
@@ -0,0 +1,26 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Modules/Condition/ui_condition_end.gd" id="1_sh52m"]
|
||||
|
||||
[node name="Condition_End" type="HBoxContainer"]
|
||||
offset_right = 90.0
|
||||
offset_bottom = 23.0
|
||||
script = ExtResource("1_sh52m")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
offset_top = 2.0
|
||||
offset_right = 141.0
|
||||
offset_bottom = 28.0
|
||||
text = "End of condition X"
|
||||
|
||||
[node name="AddElif" type="Button" parent="."]
|
||||
offset_left = 145.0
|
||||
offset_right = 212.0
|
||||
offset_bottom = 31.0
|
||||
text = "Add Elif"
|
||||
|
||||
[node name="AddElse" type="Button" parent="."]
|
||||
offset_left = 216.0
|
||||
offset_right = 290.0
|
||||
offset_bottom = 31.0
|
||||
text = "Add Else"
|
||||
Reference in New Issue
Block a user