本地化
This commit is contained in:
@@ -7,6 +7,7 @@ namespace AibisDream
|
||||
public class EndPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => false;
|
||||
|
||||
#region 打开和关闭
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace AibisDream
|
||||
public class MainPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => false;
|
||||
|
||||
#region 面板控制
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace AibisDream
|
||||
public class PlayToolPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => false;
|
||||
|
||||
[Header("Obj尺寸参数")] public float objWidth;
|
||||
public float objHeight;
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace AibisDream
|
||||
public class RecordPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => true;
|
||||
|
||||
public readonly StringBuilder recordStr = new();
|
||||
|
||||
@@ -17,7 +18,7 @@ namespace AibisDream
|
||||
GameManager.Instance.PauseGame();
|
||||
gameObject.SetActive(true);
|
||||
|
||||
var btn = transform.Find("Title").Find("Return").GetComponent<Button>();
|
||||
var btn = transform.Find("Return").GetComponent<Button>();
|
||||
btn.onClick.AddListener(ReturnGame);
|
||||
}
|
||||
|
||||
@@ -27,7 +28,7 @@ namespace AibisDream
|
||||
GameManager.Instance.ContinueGame();
|
||||
// 关闭时停止渲染
|
||||
ClearText();
|
||||
var btn = transform.Find("Title").Find("Return").GetComponent<Button>();
|
||||
var btn = transform.Find("Return").GetComponent<Button>();
|
||||
btn.onClick.RemoveAllListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace AibisDream
|
||||
public class SavesPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => true;
|
||||
|
||||
private static readonly string SaveFilePath = Application.streamingAssetsPath + "/SaveFiles";
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace AibisDream
|
||||
public class SettingPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => true;
|
||||
|
||||
#region 打开和关闭
|
||||
|
||||
@@ -62,7 +63,6 @@ namespace AibisDream
|
||||
{
|
||||
// 关闭Setting面板
|
||||
UIManager.Instance.HidePanel<SettingPanel>();
|
||||
// TODO 解除暂停
|
||||
}
|
||||
|
||||
private void BackToMain()
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace AibisDream
|
||||
public class StartPanel : MonoBehaviour, IUIPanel
|
||||
{
|
||||
public bool IsOpen => gameObject.activeSelf;
|
||||
public bool IsCloseable => false;
|
||||
|
||||
#region 开启和关闭
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace AibisDream
|
||||
#region 打开和关闭
|
||||
|
||||
public bool IsOpen { get; private set;}
|
||||
public bool IsCloseable => false;
|
||||
|
||||
public void Show()
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace AibisDream
|
||||
#region 索引
|
||||
|
||||
private Dictionary<Type, IUIPanel> _panelPool;
|
||||
private readonly Stack<IUIPanel> _panelStack = new();
|
||||
|
||||
public RectTransform Canvas { get; private set; }
|
||||
public Vector2 Resolution { get; set; }
|
||||
@@ -21,6 +22,22 @@ namespace AibisDream
|
||||
InitRefs();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
if (_panelStack.Count > 0)
|
||||
{
|
||||
var lastPanel = _panelStack.Peek();
|
||||
HidePanel(lastPanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowPanel<SettingPanel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitRefs()
|
||||
{
|
||||
// 获取Canvas
|
||||
@@ -70,6 +87,7 @@ namespace AibisDream
|
||||
if (_panelPool.TryGetValue(type, out var panel))
|
||||
{
|
||||
if (panel.IsOpen) return;
|
||||
if (panel.IsCloseable) _panelStack.Push(panel);
|
||||
panel.Show();
|
||||
call?.Invoke(panel as T);
|
||||
}
|
||||
@@ -86,6 +104,7 @@ namespace AibisDream
|
||||
if (_panelPool.TryGetValue(type, out var panel))
|
||||
{
|
||||
if (!panel.IsOpen) return;
|
||||
if (panel.IsCloseable) _panelStack.Pop();
|
||||
panel.Hide();
|
||||
}
|
||||
else
|
||||
@@ -94,6 +113,20 @@ namespace AibisDream
|
||||
}
|
||||
}
|
||||
|
||||
private void HidePanel<T>(T panel) where T : IUIPanel
|
||||
{
|
||||
if (_panelPool.ContainsValue(panel))
|
||||
{
|
||||
if (!panel.IsOpen) return;
|
||||
if (panel.IsCloseable) _panelStack.Pop();
|
||||
panel.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"panel {typeof(T)} 未注册");
|
||||
}
|
||||
}
|
||||
|
||||
public T GetPanel<T>() where T : class, IUIPanel
|
||||
{
|
||||
if (_panelPool.TryGetValue(typeof(T), out var panel))
|
||||
|
||||
@@ -7,5 +7,6 @@ namespace AibisDream
|
||||
public virtual void Show() { }
|
||||
public virtual void Hide() { }
|
||||
public bool IsOpen { get; }
|
||||
public bool IsCloseable { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user