You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
#nullable enable
|
|
using Godot;
|
|
|
|
namespace Babushka.scripts.CSharp.Common.Quest;
|
|
|
|
public partial class QuestLog : Control
|
|
{
|
|
[Signal]
|
|
public delegate void DetailQuestChangedEventHandler(QuestLog questLog);
|
|
|
|
[Export] private Vector2 _closedPos;
|
|
|
|
[Export] private Vector2 _openedPos;
|
|
|
|
private bool _isClosed = true;
|
|
private Tween? _closeOpenTween;
|
|
|
|
public QuestResource? currentDetailQuest
|
|
{
|
|
get => QuestManager.Instance!.GetActiveQuest();
|
|
set
|
|
{
|
|
QuestManager.Instance!.SetActiveQuest(value); // TODO: fix setup
|
|
EmitSignalDetailQuestChanged(this);
|
|
}
|
|
}
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
QuestManager.Instance!.QuestsChanged += OnQuestsChanged;
|
|
}
|
|
|
|
public override void _ExitTree()
|
|
{
|
|
QuestManager.Instance!.QuestsChanged -= OnQuestsChanged;
|
|
}
|
|
|
|
private void OnQuestsChanged()
|
|
{
|
|
EmitSignalDetailQuestChanged(this);
|
|
}
|
|
|
|
public override void _Input(InputEvent inputEvent)
|
|
{
|
|
if (inputEvent.IsActionPressed("ui_inventory_journal_open_close"))
|
|
{
|
|
if (_closeOpenTween != null)
|
|
_closeOpenTween.Kill();
|
|
|
|
_isClosed = !_isClosed;
|
|
|
|
_closeOpenTween = GetTree().CreateTween();
|
|
_closeOpenTween
|
|
.TweenProperty(this, "position", _isClosed ? _closedPos : _openedPos, 0.5)
|
|
.SetEase(Tween.EaseType.Out)
|
|
.SetTrans(Tween.TransitionType.Cubic);
|
|
}
|
|
}
|
|
} |