fix dialogue balloon not refocusing after choice
parent
58ad2382fe
commit
3c6fd6088f
|
@ -59,7 +59,6 @@ public partial class Balloon : CanvasLayer
|
|||
|
||||
balloon.GuiInput += (inputEvent) =>
|
||||
{
|
||||
|
||||
if (!isWaitingForInput) return;
|
||||
if (GetResponses().Count > 0) return;
|
||||
|
||||
|
@ -69,7 +68,7 @@ public partial class Balloon : CanvasLayer
|
|||
{
|
||||
Next(dialogueLine.NextId);
|
||||
}
|
||||
else if (inputEvent.IsActionPressed("ui_accept") && GetViewport().GuiGetFocusOwner() == balloon)
|
||||
else if (inputEvent.IsActionPressed("ui_accept"))
|
||||
{
|
||||
Next(dialogueLine.NextId);
|
||||
}
|
||||
|
@ -160,10 +159,14 @@ public partial class Balloon : CanvasLayer
|
|||
|
||||
if (inputEvent is InputEventMouseButton && inputEvent.IsPressed() && (inputEvent as InputEventMouseButton).ButtonIndex == MouseButton.Left)
|
||||
{
|
||||
balloon.FocusMode = Control.FocusModeEnum.All;
|
||||
balloon.GrabFocus();
|
||||
Next(dialogueLine.Responses[item.GetIndex()].NextId);
|
||||
}
|
||||
else if (inputEvent.IsActionPressed("ui_accept") && GetResponses().Contains(item))
|
||||
{
|
||||
balloon.FocusMode = Control.FocusModeEnum.All;
|
||||
balloon.GrabFocus();
|
||||
Next(dialogueLine.Responses[item.GetIndex()].NextId);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -86,6 +86,3 @@ scroll_active = false
|
|||
shortcut_keys_enabled = false
|
||||
meta_underlined = false
|
||||
hint_underlined = false
|
||||
|
||||
[connection signal="gui_input" from="Balloon" to="." method="_on_balloon_gui_input"]
|
||||
[connection signal="resized" from="Balloon/Margin" to="." method="_on_margin_resized"]
|
||||
|
|
|
@ -26,7 +26,32 @@ public partial class World : Node
|
|||
public AudioStreamPlayer MusicPlayer { get; set; }
|
||||
|
||||
[Export]
|
||||
public Dialogue.Balloon DialogueBalloon { get; set; }
|
||||
public Dialogue.Balloon DialogueBalloon
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dialogueBalloon is null || !IsInstanceValid(_dialogueBalloon))
|
||||
{
|
||||
var scene = GD.Load<PackedScene>("res://Dialogue/balloon.tscn");
|
||||
_dialogueBalloon = scene.Instantiate<Dialogue.Balloon>();
|
||||
//_uiViewport.AddChild(_dialogueBalloon);
|
||||
_uiViewport.AddChild(_dialogueBalloon);
|
||||
}
|
||||
return _dialogueBalloon;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_dialogueBalloon != value && _dialogueBalloon is not null)
|
||||
{
|
||||
_dialogueBalloon.QueueFree();
|
||||
}
|
||||
_dialogueBalloon = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Dialogue.Balloon _dialogueBalloon;
|
||||
|
||||
private SubViewport _uiViewport;
|
||||
|
||||
public State.Global.GlobalState GlobalState { get; set; }
|
||||
|
||||
|
@ -66,6 +91,8 @@ public partial class World : Node
|
|||
|
||||
Godot.RenderingServer.SetDefaultClearColor(Godot.Colors.Black);
|
||||
|
||||
_uiViewport = GetNode<SubViewport>("CanvasLayer/SubViewportContainer/UIViewport");
|
||||
|
||||
// create a player (currently unparented)
|
||||
CreatePlayer();
|
||||
|
||||
|
|
Loading…
Reference in New Issue