Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
[DIVERGE] blendshape ui now tracks actual blendshape value
Browse files Browse the repository at this point in the history
  • Loading branch information
you-win committed Jan 23, 2023
1 parent 94ab981 commit 87d284b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 139 deletions.
41 changes: 0 additions & 41 deletions model/extensions/hotkey_provider.gd

This file was deleted.

6 changes: 0 additions & 6 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ _global_script_classes=[ {
"path": "res://model/globals.gd"
}, {
"base": "Reference",
"class": "HotkeyProvider",
"language": "GDScript",
"path": "res://model/extensions/hotkey_provider.gd"
}, {
"base": "Reference",
"class": "InterpolationData",
"language": "GDScript",
"path": "res://model/interpolation_data.gd"
Expand Down Expand Up @@ -240,7 +235,6 @@ _global_script_class_icons={
"ExtensionManager": "",
"FileUtil": "",
"Globals": "",
"HotkeyProvider": "",
"InterpolationData": "",
"JSONUtil": "",
"LogManager": "",
Expand Down
39 changes: 9 additions & 30 deletions screens/gui/blend-shapes/blend_shape_item.gd
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
extends VBoxContainer

const BlendShapeItemHotkey: PackedScene = preload(
"res://screens/gui/blend-shapes/blend_shape_item_hotkey.tscn")

const ReplaceTypes := {
"REPLACE": "DEFAULT_GUI_BLEND_SHAPE_ITEM_REPLACE_TYPE_OVERRIDE",
"ADD": "DEFAULT_GUI_BLEND_SHAPE_ITEM_REPLACE_TYPE_ADD",
"COMPLEX": "DEFAULT_GUI_BLEND_SHAPE_ITEM_REPLACE_TYPE_COMPLEX"
}

onready var replace_type := $ReplaceType as MenuButton
onready var hotkey_list := $Hotkeys/List as VBoxContainer

var logger: Logger

var mesh_instance: MeshInstance
var mesh_instance: MeshInstance = null
var blend_shape_name := ""
var blend_shape_value: float = 0.0

Expand All @@ -32,16 +26,17 @@ func _ready() -> void:
$BlendShapeName/Value.text = blend_shape_name
value_line_edit.text = str(blend_shape_value)
value_line_edit.connect("text_changed", self, "_on_value_line_edit_changed")

$Hotkeys/AddSequence.connect("pressed", self, "_on_add_sequence")

value_slider.value = blend_shape_value
value_slider.connect("value_changed", self, "_on_slider_value_changed")
# value_slider.connect("drag_started", self, "_on_slider_drag_started")
# value_slider.connect("drag_ended", self, "_on_slider_drag_ended")

AM.ps.subscribe(self, Globals.BLEND_SHAPES, "_on_blend_shape_modified")
AM.ps.subscribe(self, "action_pressed")

func _process(_delta: float) -> void:
var current_value: float = mesh_instance.get("blend_shapes/%s" % blend_shape_name)

value_line_edit.text = str(current_value)
value_slider.ratio = current_value

#-----------------------------------------------------------------------------#
# Connections #
Expand All @@ -56,29 +51,19 @@ func _on_event_published(payload: SignalPayload) -> void:
value_line_edit.caret_position = value_line_edit.text.length()

value_slider.ratio = payload.data
Globals.HOTKEY_ACTION_RECEIVED:
# TODO stub
pass
_:
logger.error("Unhandled signal payload %s" % payload.to_string())

func _on_add_sequence() -> void:
var hotkey_item: Control = BlendShapeItemHotkey.instance()
hotkey_item.logger = logger

hotkey_list.add_child(hotkey_item)
hotkey_item.blend_shape_name = blend_shape_name

func _on_value_line_edit_changed(text: String) -> void:
if not text.is_valid_float():
return
if text == value_line_edit.text: # Avoid infinite loop
return

AM.ps.publish(Globals.BLEND_SHAPES, text.to_float(), blend_shape_name)
mesh_instance.set("blend_shapes/%s" % blend_shape_name, text.to_float())

func _on_slider_value_changed(_value: float) -> void:
AM.ps.publish(Globals.BLEND_SHAPES, value_slider.ratio, blend_shape_name)
mesh_instance.set("blend_shapes/%s" % blend_shape_name, value_slider.ratio)

func _on_blend_shape_modified(payload: SignalPayload) -> void:
if payload.id != blend_shape_name:
Expand All @@ -87,12 +72,6 @@ func _on_blend_shape_modified(payload: SignalPayload) -> void:
value_line_edit.text = str(payload.data)
value_slider.value = payload.data

func _on_action_pressed(action_name: String) -> void:
if action_name != blend_shape_name:
return

# TODO implement hotkey support

#-----------------------------------------------------------------------------#
# Private functions #
#-----------------------------------------------------------------------------#
Expand Down
38 changes: 0 additions & 38 deletions screens/gui/blend-shapes/blend_shape_item.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -51,41 +51,3 @@ step = 0.01
scrollable = false
tick_count = 10
ticks_on_borders = true

[node name="ReplaceType" type="OptionButton" parent="."]
margin_top = 66.0
margin_right = 1600.0
margin_bottom = 86.0

[node name="Hotkeys" type="VBoxContainer" parent="."]
margin_top = 90.0
margin_right = 1600.0
margin_bottom = 148.0

[node name="Label" type="Label" parent="Hotkeys"]
margin_right = 1600.0
margin_bottom = 14.0
text = "DEFAULT_GUI_BLEND_SHAPE_ITEM_HOTKEY_SEQUENCE"
align = 1
valign = 1

[node name="HSeparator" type="HSeparator" parent="Hotkeys"]
margin_top = 18.0
margin_right = 1600.0
margin_bottom = 22.0

[node name="List" type="VBoxContainer" parent="Hotkeys"]
margin_top = 26.0
margin_right = 1600.0
margin_bottom = 26.0

[node name="HSeparator2" type="HSeparator" parent="Hotkeys"]
margin_top = 30.0
margin_right = 1600.0
margin_bottom = 34.0

[node name="AddSequence" type="Button" parent="Hotkeys"]
margin_top = 38.0
margin_right = 1600.0
margin_bottom = 58.0
text = "+"
24 changes: 0 additions & 24 deletions utils/app_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var nm: NotificationManager = null
var tcm: TempCacheManager = null
# Not girl, you weirdo
var grl = preload("res://addons/gdnative-runtime-loader/gdnative_runtime_loader.gd").new()
var hp: HotkeyProvider = null

#region Debounce

Expand Down Expand Up @@ -66,29 +65,6 @@ func _ready() -> void:

# Must be initialized AFTER ExtensionManager because it can load translation files for extensions
tm = TranslationManager.new()

#region HotkeyProvider

var hotkey_providers: Array = em.query_extensions_for_tag(
ExtensionManager.RecognizedTags.HOTKEY_PROVIDER)

if OS.is_debug_build() or environment == Env.Envs.DEBUG:
for i in hotkey_providers:
logger.debug("Found hotkey provider: %s" % i.extension_name)

if hotkey_providers.size() == 1:
var hotkey_ext: Extension.ExtensionResource = hotkey_providers.pop_back()
logger.debug("Using hotkey provider %s" % hotkey_ext.extension_name)
hp = load(hotkey_ext.entrypoint).new()
elif hotkey_providers.size() > 1:
logger.error("Too many hotkey providers found (%d), using dummy provider" %
hotkey_providers.size())
hp = DummyHotkeyProvider.new()
else: # No providers at all
logger.debug("No hotkey provider found, using dummy provider")
hp = DummyHotkeyProvider.new()

#endregion

# Idk, this could really be anywhere
nm = NotificationManager.new()
Expand Down

0 comments on commit 87d284b

Please sign in to comment.