Skip to content

Commit

Permalink
Fix preview and jump for EventFlowNodeMessageBalloon
Browse files Browse the repository at this point in the history
  • Loading branch information
Amethyst-szs committed Feb 14, 2025
1 parent ead2bd7 commit 723eb2e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Godot;

using MoonFlow.Project;
using MoonFlow.Scene.EditorMsbt;
using MoonFlow.Scene.EditorWorld;

using Nindot;
Expand All @@ -15,9 +16,13 @@ namespace MoonFlow.Scene.EditorEvent;
public partial class EventFlowNodeMessageBalloon : EventFlowNodeCommon
{
[Export, ExportGroup("Internal References")]
private TextEdit TextMessagePreview;
private MsbtPageEditor TextMessagePreview;
[Export]
private Label LabelTextSource;
[Export]
protected Button ButtonMessageEdit;
[Export]
protected Button ButtonMessageRefresh;

[Export]
private VBoxContainer MessageResolverConfig;
Expand Down Expand Up @@ -161,6 +166,21 @@ private void OnNewTextSourceSelectedFromPopup(string arc, string file, string la
SetNodeModified();
}

protected void OnTextPreviewEditCurrent()
{
if (!Content.TryGetParam("Text", out NodeMessageResolverData msg))
return;

if (!IsContainMessageResolver())
return;

_ = AppSceneServer.CreateOrOpenMsbtLabel(msg);
}
protected void OnTextPreviewRefreshCurrent()
{
SetLabelDisplayTextSource();
}

#endregion

#region Utilities
Expand Down Expand Up @@ -210,6 +230,9 @@ private void SetLabelDisplayTextSource()
{
LabelTextSource.Modulate = Colors.Crimson;
LabelTextSource.Text = Tr("EVENT_FLOW_NODE_MESSAGE_TALK_SOURCE_PLACEHOLDER");

ButtonMessageEdit.Disabled = true;
ButtonMessageRefresh.Disabled = true;
return;
}

Expand All @@ -226,8 +249,23 @@ private void SetLabelDisplayTextSource()
SarcFile arc = holder.GetArchiveByFileName(msg.MessageArchive);
var msbt = arc.GetFileMSBT(msg.MessageFile + ".msbt", new MsbtElementFactoryProjectSmo());

var txt = msbt.GetEntry(msg.LabelName);
TextMessagePreview.Text = txt.GetRawText(true);
var entry = msbt.GetEntry(msg.LabelName);

switch(entry.Pages.Count)
{
case 0:
TextMessagePreview.Text = "";
break;
case 1:
TextMessagePreview.Init(null, entry.Pages[0]);
break;
default:
TextMessagePreview.Init(null, entry.Pages[0]);
break;
}

ButtonMessageEdit.Disabled = false;
ButtonMessageRefresh.Disabled = false;
}

private bool IsSupportMessageResolver()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
font_size = 11
font_color = Color(1, 1, 1, 0.827451)

[node name="EventFlowNodeMessageBalloon" node_paths=PackedStringArray("TextMessagePreview", "LabelTextSource", "MessageResolverConfig", "OptionBalloon", "OptionSource", "IsMultiDivide") instance=ExtResource("1_rdu8i")]
[node name="EventFlowNodeMessageBalloon" node_paths=PackedStringArray("TextMessagePreview", "LabelTextSource", "ButtonMessageEdit", "ButtonMessageRefresh", "MessageResolverConfig", "OptionBalloon", "OptionSource", "IsMultiDivide") instance=ExtResource("1_rdu8i")]
script = ExtResource("2_tsyva")
TextMessagePreview = NodePath("Content/Display/BalloonText/MessageResolverConfig/HBox_Preview/Text_Preview")
LabelTextSource = NodePath("Content/Display/BalloonText/MessageResolverConfig/Label_TargetSource")
ButtonMessageEdit = NodePath("Content/Display/BalloonText/MessageResolverConfig/HBox_Preview/VBox_Tools/Button_Edit")
ButtonMessageRefresh = NodePath("Content/Display/BalloonText/MessageResolverConfig/HBox_Preview/VBox_Tools/Button_Refresh")
MessageResolverConfig = NodePath("Content/Display/BalloonText/MessageResolverConfig")
OptionBalloon = NodePath("Content/Display/BalloonText/Option_BalloonType")
OptionSource = NodePath("Content/Display/BalloonText/Option_SourceType")
Expand Down Expand Up @@ -74,5 +76,7 @@ theme_override_constants/separation = 32
[connection signal="OptionSelected" from="Content/Display/BalloonText/Option_SourceType" to="." method="OnBalloonTypeOrSourceModified"]
[connection signal="toggled" from="Content/Display/BalloonText/Check_IsMultiDevide" to="." method="OnToggleMultiDivide"]
[connection signal="pressed" from="Content/Display/BalloonText/MessageResolverConfig/Button_SelectSource" to="." method="OnSelectNewTextSource"]
[connection signal="pressed" from="Content/Display/BalloonText/MessageResolverConfig/HBox_Preview/VBox_Tools/Button_Edit" to="." method="OnTextPreviewEditCurrent"]
[connection signal="pressed" from="Content/Display/BalloonText/MessageResolverConfig/HBox_Preview/VBox_Tools/Button_Refresh" to="." method="OnTextPreviewRefreshCurrent"]

[editable path="Content/Display/BalloonText/MessageResolverConfig"]

0 comments on commit 723eb2e

Please sign in to comment.