generated from mstar/godot-template
Code stuff
This commit is contained in:
parent
cf22890c16
commit
e58093b5a5
153 changed files with 11196 additions and 4 deletions
|
@ -0,0 +1,22 @@
|
|||
@tool
|
||||
extends "ValueConditionEditor.gd"
|
||||
|
||||
@onready var boolean_value = $MarginContainer/BooleanValue
|
||||
|
||||
func _ready():
|
||||
super._ready()
|
||||
|
||||
boolean_value.pressed.connect(_on_boolean_value_pressed)
|
||||
|
||||
|
||||
func _on_value_changed(new_value):
|
||||
if boolean_value.button_pressed != new_value:
|
||||
boolean_value.button_pressed = new_value
|
||||
|
||||
func _on_boolean_value_pressed():
|
||||
change_value_action(condition.value, boolean_value.button_pressed)
|
||||
|
||||
func _on_condition_changed(new_condition):
|
||||
super._on_condition_changed(new_condition)
|
||||
if new_condition:
|
||||
boolean_value.button_pressed = new_condition.value
|
|
@ -0,0 +1,35 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bmpwx6h3ckekr"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://blnscdhcxvpmk" path="res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/imjp94.yafsm/scenes/condition_editors/BoolConditionEditor.gd" id="2"]
|
||||
|
||||
[node name="BoolConditionEditor" instance=ExtResource("1")]
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Name" parent="." index="0"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Comparation" parent="." index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PopupMenu" parent="Comparation" index="0"]
|
||||
item_count = 2
|
||||
|
||||
[node name="MarginContainer" parent="." index="2"]
|
||||
layout_mode = 2
|
||||
offset_top = 3.0
|
||||
offset_right = 146.0
|
||||
offset_bottom = 27.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="BooleanValue" type="CheckButton" parent="MarginContainer" index="0"]
|
||||
layout_mode = 2
|
||||
offset_right = 44.0
|
||||
offset_bottom = 24.0
|
||||
size_flags_horizontal = 6
|
||||
|
||||
[node name="Remove" parent="." index="3"]
|
||||
layout_mode = 2
|
||||
offset_left = 150.0
|
||||
offset_right = 176.0
|
|
@ -0,0 +1,72 @@
|
|||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
@onready var name_edit = $Name
|
||||
@onready var remove = $Remove
|
||||
|
||||
var undo_redo
|
||||
|
||||
var condition:
|
||||
set = set_condition
|
||||
|
||||
|
||||
func _ready():
|
||||
name_edit.text_submitted.connect(_on_name_edit_text_submitted)
|
||||
name_edit.focus_entered.connect(_on_name_edit_focus_entered)
|
||||
name_edit.focus_exited.connect(_on_name_edit_focus_exited)
|
||||
name_edit.text_changed.connect(_on_name_edit_text_changed)
|
||||
set_process_input(false)
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton:
|
||||
if event.pressed:
|
||||
if get_viewport().gui_get_focus_owner() == name_edit:
|
||||
var local_event = name_edit.make_input_local(event)
|
||||
if not name_edit.get_rect().has_point(local_event.position):
|
||||
name_edit.release_focus()
|
||||
|
||||
func _on_name_edit_text_changed(new_text):
|
||||
# name_edit.release_focus()
|
||||
if condition.name == new_text: # Avoid infinite loop
|
||||
return
|
||||
|
||||
rename_edit_action(new_text)
|
||||
|
||||
func _on_name_edit_focus_entered():
|
||||
set_process_input(true)
|
||||
|
||||
func _on_name_edit_focus_exited():
|
||||
set_process_input(false)
|
||||
if condition.name == name_edit.text:
|
||||
return
|
||||
|
||||
rename_edit_action(name_edit.text)
|
||||
|
||||
func _on_name_edit_text_submitted(new_text):
|
||||
name_edit.tooltip_text = new_text
|
||||
|
||||
func change_name_edit(from, to):
|
||||
var transition = get_parent().get_parent().get_parent().transition # TODO: Better way to get Transition object
|
||||
if transition.change_condition_name(from, to):
|
||||
if name_edit.text != to: # Manually update name_edit.text, in case called from undo_redo
|
||||
name_edit.text = to
|
||||
else:
|
||||
name_edit.text = from
|
||||
push_warning("Change Condition name_edit from (%s) to (%s) failed, name_edit existed" % [from, to])
|
||||
|
||||
func rename_edit_action(new_name_edit):
|
||||
var old_name_edit = condition.name
|
||||
undo_redo.create_action("Rename_edit Condition")
|
||||
undo_redo.add_do_method(self, "change_name_edit", old_name_edit, new_name_edit)
|
||||
undo_redo.add_undo_method(self, "change_name_edit", new_name_edit, old_name_edit)
|
||||
undo_redo.commit_action()
|
||||
|
||||
func _on_condition_changed(new_condition):
|
||||
if new_condition:
|
||||
name_edit.text = new_condition.name
|
||||
name_edit.tooltip_text = name_edit.text
|
||||
|
||||
func set_condition(c):
|
||||
if condition != c:
|
||||
condition = c
|
||||
_on_condition_changed(c)
|
|
@ -0,0 +1,24 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cie8lb6ww58ck"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/imjp94.yafsm/scenes/condition_editors/ConditionEditor.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://l78bjwo7shm" path="res://addons/imjp94.yafsm/assets/icons/close-white-18dp.svg" id="2"]
|
||||
|
||||
[node name="ConditionEditor" type="HBoxContainer"]
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Name" type="LineEdit" parent="."]
|
||||
layout_mode = 2
|
||||
offset_right = 67.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
text = "Param"
|
||||
|
||||
[node name="Remove" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
offset_left = 71.0
|
||||
offset_right = 97.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 9
|
||||
icon = ExtResource("2")
|
||||
flat = true
|
|
@ -0,0 +1,44 @@
|
|||
@tool
|
||||
extends "ValueConditionEditor.gd"
|
||||
|
||||
@onready var float_value = $MarginContainer/FloatValue
|
||||
|
||||
var _old_value = 0.0
|
||||
|
||||
func _ready():
|
||||
super._ready()
|
||||
|
||||
float_value.text_submitted.connect(_on_float_value_text_submitted)
|
||||
float_value.focus_entered.connect(_on_float_value_focus_entered)
|
||||
float_value.focus_exited.connect(_on_float_value_focus_exited)
|
||||
set_process_input(false)
|
||||
|
||||
func _input(event):
|
||||
super._input(event)
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.pressed:
|
||||
if get_viewport().gui_get_focus_owner() == float_value:
|
||||
var local_event = float_value.make_input_local(event)
|
||||
if not float_value.get_rect().has_point(local_event.position):
|
||||
float_value.release_focus()
|
||||
|
||||
func _on_value_changed(new_value):
|
||||
float_value.text = str(snapped(new_value, 0.01)).pad_decimals(2)
|
||||
|
||||
func _on_float_value_text_submitted(new_text):
|
||||
change_value_action(_old_value, float(new_text))
|
||||
float_value.release_focus()
|
||||
|
||||
func _on_float_value_focus_entered():
|
||||
set_process_input(true)
|
||||
_old_value = float(float_value.text)
|
||||
|
||||
func _on_float_value_focus_exited():
|
||||
set_process_input(false)
|
||||
change_value_action(_old_value, float(float_value.text))
|
||||
|
||||
func _on_condition_changed(new_condition):
|
||||
super._on_condition_changed(new_condition)
|
||||
if new_condition:
|
||||
float_value.text = str(snapped(new_condition.value, 0.01)).pad_decimals(2)
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://doq6lkdh20j15"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://blnscdhcxvpmk" path="res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/imjp94.yafsm/scenes/condition_editors/FloatConditionEditor.gd" id="2"]
|
||||
|
||||
[node name="ValueConditionEditor" instance=ExtResource("1")]
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Comparation" parent="." index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" parent="." index="2"]
|
||||
layout_mode = 2
|
||||
offset_right = 169.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="FloatValue" type="LineEdit" parent="MarginContainer" index="0"]
|
||||
layout_mode = 2
|
||||
offset_right = 67.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Remove" parent="." index="3"]
|
||||
offset_left = 173.0
|
||||
offset_right = 199.0
|
|
@ -0,0 +1,45 @@
|
|||
@tool
|
||||
extends "ValueConditionEditor.gd"
|
||||
|
||||
@onready var integer_value = $MarginContainer/IntegerValue
|
||||
|
||||
var _old_value = 0
|
||||
|
||||
|
||||
func _ready():
|
||||
super._ready()
|
||||
|
||||
integer_value.text_submitted.connect(_on_integer_value_text_submitted)
|
||||
integer_value.focus_entered.connect(_on_integer_value_focus_entered)
|
||||
integer_value.focus_exited.connect(_on_integer_value_focus_exited)
|
||||
set_process_input(false)
|
||||
|
||||
func _input(event):
|
||||
super._input(event)
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.pressed:
|
||||
if get_viewport().gui_get_focus_owner() == integer_value:
|
||||
var local_event = integer_value.make_input_local(event)
|
||||
if not integer_value.get_rect().has_point(local_event.position):
|
||||
integer_value.release_focus()
|
||||
|
||||
func _on_value_changed(new_value):
|
||||
integer_value.text = str(new_value)
|
||||
|
||||
func _on_integer_value_text_submitted(new_text):
|
||||
change_value_action(_old_value, int(new_text))
|
||||
integer_value.release_focus()
|
||||
|
||||
func _on_integer_value_focus_entered():
|
||||
set_process_input(true)
|
||||
_old_value = int(integer_value.text)
|
||||
|
||||
func _on_integer_value_focus_exited():
|
||||
set_process_input(false)
|
||||
change_value_action(_old_value, int(integer_value.text))
|
||||
|
||||
func _on_condition_changed(new_condition):
|
||||
super._on_condition_changed(new_condition)
|
||||
if new_condition:
|
||||
integer_value.text = str(new_condition.value)
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://d1ib30424prpf"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://blnscdhcxvpmk" path="res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/imjp94.yafsm/scenes/condition_editors/IntegerConditionEditor.gd" id="2"]
|
||||
|
||||
[node name="IntegerConditionEditor" instance=ExtResource("1")]
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Comparation" parent="." index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" parent="." index="2"]
|
||||
layout_mode = 2
|
||||
offset_right = 169.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="IntegerValue" type="LineEdit" parent="MarginContainer" index="0"]
|
||||
layout_mode = 2
|
||||
offset_right = 67.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Remove" parent="." index="3"]
|
||||
offset_left = 173.0
|
||||
offset_right = 199.0
|
|
@ -0,0 +1,46 @@
|
|||
@tool
|
||||
extends "res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.gd"
|
||||
|
||||
|
||||
@onready var string_value = $MarginContainer/StringValue
|
||||
|
||||
var _old_value = 0
|
||||
|
||||
|
||||
func _ready():
|
||||
super._ready()
|
||||
|
||||
string_value.text_submitted.connect(_on_string_value_text_submitted)
|
||||
string_value.focus_entered.connect(_on_string_value_focus_entered)
|
||||
string_value.focus_exited.connect(_on_string_value_focus_exited)
|
||||
set_process_input(false)
|
||||
|
||||
func _input(event):
|
||||
super._input(event)
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.pressed:
|
||||
if get_viewport().gui_get_focus_owner() == string_value:
|
||||
var local_event = string_value.make_input_local(event)
|
||||
if not string_value.get_rect().has_point(local_event.position):
|
||||
string_value.release_focus()
|
||||
|
||||
func _on_value_changed(new_value):
|
||||
string_value.text = new_value
|
||||
|
||||
func _on_string_value_text_submitted(new_text):
|
||||
change_value_action(_old_value, new_text)
|
||||
string_value.release_focus()
|
||||
|
||||
func _on_string_value_focus_entered():
|
||||
set_process_input(true)
|
||||
_old_value = string_value.text
|
||||
|
||||
func _on_string_value_focus_exited():
|
||||
set_process_input(false)
|
||||
change_value_action(_old_value, string_value.text)
|
||||
|
||||
func _on_condition_changed(new_condition):
|
||||
super._on_condition_changed(new_condition)
|
||||
if new_condition:
|
||||
string_value.text = new_condition.value
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://qfw0snt5kss6"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://blnscdhcxvpmk" path="res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.tscn" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/imjp94.yafsm/scenes/condition_editors/StringConditionEditor.gd" id="2"]
|
||||
|
||||
[node name="StringConditionEditor" instance=ExtResource("1")]
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Comparation" parent="." index="1"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PopupMenu" parent="Comparation" index="0"]
|
||||
item_count = 2
|
||||
|
||||
[node name="MarginContainer" parent="." index="2"]
|
||||
layout_mode = 2
|
||||
offset_right = 169.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="StringValue" type="LineEdit" parent="MarginContainer" index="0"]
|
||||
layout_mode = 2
|
||||
offset_right = 67.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Remove" parent="." index="3"]
|
||||
offset_left = 173.0
|
||||
offset_right = 199.0
|
|
@ -0,0 +1,57 @@
|
|||
@tool
|
||||
extends "ConditionEditor.gd"
|
||||
const Utils = preload("../../scripts/Utils.gd")
|
||||
const Comparation = preload("../../src/conditions/ValueCondition.gd").Comparation
|
||||
|
||||
@onready var comparation_button = $Comparation
|
||||
@onready var comparation_popup_menu = $Comparation/PopupMenu
|
||||
|
||||
|
||||
func _ready():
|
||||
super._ready()
|
||||
|
||||
comparation_button.pressed.connect(_on_comparation_button_pressed)
|
||||
comparation_popup_menu.id_pressed.connect(_on_comparation_popup_menu_id_pressed)
|
||||
|
||||
func _on_comparation_button_pressed():
|
||||
Utils.popup_on_target(comparation_popup_menu, comparation_button)
|
||||
|
||||
func _on_comparation_popup_menu_id_pressed(id):
|
||||
change_comparation_action(id)
|
||||
|
||||
func _on_condition_changed(new_condition):
|
||||
super._on_condition_changed(new_condition)
|
||||
if new_condition:
|
||||
comparation_button.text = comparation_popup_menu.get_item_text(new_condition.comparation)
|
||||
|
||||
func _on_value_changed(new_value):
|
||||
pass
|
||||
|
||||
func change_comparation(id):
|
||||
if id > Comparation.size() - 1:
|
||||
push_error("Unexpected id(%d) from PopupMenu" % id)
|
||||
return
|
||||
condition.comparation = id
|
||||
comparation_button.text = comparation_popup_menu.get_item_text(id)
|
||||
|
||||
func change_comparation_action(id):
|
||||
var from = condition.comparation
|
||||
var to = id
|
||||
|
||||
undo_redo.create_action("Change Condition Comparation")
|
||||
undo_redo.add_do_method(self, "change_comparation", to)
|
||||
undo_redo.add_undo_method(self, "change_comparation", from)
|
||||
undo_redo.commit_action()
|
||||
|
||||
func set_value(v):
|
||||
if condition.value != v:
|
||||
condition.value = v
|
||||
_on_value_changed(v)
|
||||
|
||||
func change_value_action(from, to):
|
||||
if from == to:
|
||||
return
|
||||
undo_redo.create_action("Change Condition Value")
|
||||
undo_redo.add_do_method(self, "set_value", to)
|
||||
undo_redo.add_undo_method(self, "set_value", from)
|
||||
undo_redo.commit_action()
|
|
@ -0,0 +1,42 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://blnscdhcxvpmk"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cie8lb6ww58ck" path="res://addons/imjp94.yafsm/scenes/condition_editors/ConditionEditor.tscn" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/imjp94.yafsm/scenes/condition_editors/ValueConditionEditor.gd" id="2"]
|
||||
|
||||
[node name="ValueConditionEditor" instance=ExtResource("1")]
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="Comparation" type="Button" parent="." index="1"]
|
||||
layout_mode = 2
|
||||
offset_left = 71.0
|
||||
offset_right = 98.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 5
|
||||
size_flags_vertical = 4
|
||||
text = "=="
|
||||
|
||||
[node name="PopupMenu" type="PopupMenu" parent="Comparation" index="0"]
|
||||
item_count = 6
|
||||
item_0/text = "=="
|
||||
item_0/id = 0
|
||||
item_1/text = "!="
|
||||
item_1/id = 1
|
||||
item_2/text = ">"
|
||||
item_2/id = 2
|
||||
item_3/text = "<"
|
||||
item_3/id = 3
|
||||
item_4/text = "≥"
|
||||
item_4/id = 4
|
||||
item_5/text = "≤"
|
||||
item_5/id = 5
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="." index="2"]
|
||||
layout_mode = 2
|
||||
offset_left = 102.0
|
||||
offset_right = 102.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="Remove" parent="." index="3"]
|
||||
offset_left = 106.0
|
||||
offset_right = 132.0
|
||||
tooltip_text = "Remove Condition"
|
Loading…
Add table
Add a link
Reference in a new issue