Files
Babushka/scripts/CSharp/Common/Quest/QuestLog.cs
T

59 lines
1.5 KiB
C#
Raw Normal View History

2025-07-07 04:40:40 +02:00
#nullable enable
using Godot;
2025-08-13 03:23:45 +02:00
namespace Babushka.scripts.CSharp.Common.Quest;
2025-07-07 04:40:40 +02:00
public partial class QuestLog : Control
{
[Signal]
public delegate void DetailQuestChangedEventHandler(QuestLog questLog);
2025-07-07 04:41:03 +02:00
2025-08-13 03:23:45 +02:00
[Export] private Vector2 _closedPos;
[Export] private Vector2 _openedPos;
2025-07-07 04:41:14 +02:00
private bool _isClosed = true;
private Tween? _closeOpenTween;
2025-07-07 04:40:40 +02:00
public QuestResource? currentDetailQuest
{
2025-07-07 04:41:03 +02:00
get => QuestManager.Instance!.GetFollowQuest();
2025-07-07 04:40:40 +02:00
set
{
2025-07-07 04:41:03 +02:00
QuestManager.Instance!.SetFollowQuest(value); // TODO: fix setup
2025-07-07 04:40:40 +02:00
EmitSignalDetailQuestChanged(this);
}
}
2025-07-07 04:41:03 +02:00
public override void _EnterTree()
{
2025-08-13 03:23:45 +02:00
QuestManager.Instance!.QuestsChanged += OnQuestsChanged;
}
public override void _ExitTree()
{
QuestManager.Instance!.QuestsChanged -= OnQuestsChanged;
}
private void OnQuestsChanged()
{
EmitSignalDetailQuestChanged(this);
2025-07-07 04:41:03 +02:00
}
2025-07-07 04:41:14 +02:00
public override void _Input(InputEvent inputEvent)
{
if (inputEvent.IsActionPressed("ui_inventory_journal_open_close"))
{
2025-08-13 03:23:45 +02:00
if (_closeOpenTween != null)
2025-07-07 04:41:14 +02:00
_closeOpenTween.Kill();
2025-08-13 03:23:45 +02:00
2025-07-07 04:41:14 +02:00
_isClosed = !_isClosed;
_closeOpenTween = GetTree().CreateTween();
_closeOpenTween
.TweenProperty(this, "position", _isClosed ? _closedPos : _openedPos, 0.5)
.SetEase(Tween.EaseType.Out)
.SetTrans(Tween.TransitionType.Cubic);
}
}
2025-08-13 03:23:45 +02:00
}