本地化

This commit is contained in:
2025-05-19 22:20:03 +08:00
parent edef6fa96a
commit 0645adf5b8
16 changed files with 843 additions and 1145 deletions
+1
View File
@@ -7,6 +7,7 @@ namespace AibisDream
public class EndPanel : MonoBehaviour, IUIPanel
{
public bool IsOpen => gameObject.activeSelf;
public bool IsCloseable => false;
#region
+1
View File
@@ -6,6 +6,7 @@ namespace AibisDream
public class MainPanel : MonoBehaviour, IUIPanel
{
public bool IsOpen => gameObject.activeSelf;
public bool IsCloseable => false;
#region
+1
View File
@@ -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;
+3 -2
View File
@@ -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();
}
+1
View File
@@ -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";
+1 -1
View File
@@ -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()
+1
View File
@@ -7,6 +7,7 @@ namespace AibisDream
public class StartPanel : MonoBehaviour, IUIPanel
{
public bool IsOpen => gameObject.activeSelf;
public bool IsCloseable => false;
#region
+1
View File
@@ -115,6 +115,7 @@ namespace AibisDream
#region
public bool IsOpen { get; private set;}
public bool IsCloseable => false;
public void Show()
{
+33
View File
@@ -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))
+1
View File
@@ -7,5 +7,6 @@ namespace AibisDream
public virtual void Show() { }
public virtual void Hide() { }
public bool IsOpen { get; }
public bool IsCloseable { get; }
}
}