iFactory.Godot/BITKit/Scripts/UX/UXPanel.cs

59 lines
1.2 KiB
C#
Raw Normal View History

2023-06-19 00:41:44 +08:00
using Godot;
using System;
2023-09-15 23:02:46 +08:00
namespace BITKit.UX;
2023-06-19 00:41:44 +08:00
public partial class UXPanel : Control, IUXPanel
{
[Export] private bool isAnimate;
[Export] private bool allowCursor;
[Export] private bool allowInput;
[Export] private bool isStartPanel;
public bool IsAnimate => isAnimate;
2023-09-15 23:02:46 +08:00
public bool IsValid { get; set; }
2023-06-29 01:01:52 +08:00
public string Index => _index;
2023-06-19 00:41:44 +08:00
public bool AllowCursor => allowCursor;
public bool AllowInput => allowInput;
2023-06-29 01:01:52 +08:00
private string _index;
2023-06-19 00:41:44 +08:00
public virtual void Entry()
{
Show();
2023-09-15 23:02:46 +08:00
//OnEntry();
2023-06-19 00:41:44 +08:00
}
public virtual void Exit()
{
Hide();
2023-09-15 23:02:46 +08:00
//OnExit();
2023-06-19 00:41:44 +08:00
}
2023-09-15 23:02:46 +08:00
public event Action OnEntry;
public event Action OnExit;
//public virtual void OnExit(){}
2023-06-19 00:41:44 +08:00
public override void _Ready()
{
2023-09-15 23:02:46 +08:00
IsValid = true;
2023-06-29 01:01:52 +08:00
_index = GetType().FullName == typeof(UXPanel).FullName ? Name : GetType().FullName;
2023-06-19 00:41:44 +08:00
UXService.Register(this);
if (isStartPanel)
{
UXService.Open(this as IUXPanel);
}
}
private void Open()
{
UXService.Open(this as IUXPanel);
}
2023-06-29 01:01:52 +08:00
public override void _ExitTree()
2023-06-19 00:41:44 +08:00
{
UXService.UnRegister(this);
2023-09-15 23:02:46 +08:00
IsValid = false;
2023-06-19 00:41:44 +08:00
}
}