222 lines
5.8 KiB
C#
222 lines
5.8 KiB
C#
using AFeijia.UI;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class MiniCanvasManager : PanelBasic
|
||
{
|
||
public static MiniCanvasManager Instance;
|
||
|
||
public Button max_button;
|
||
public Button min_button;
|
||
public Toggle topping_button;
|
||
//public Toggle api_button;
|
||
//public Toggle task_button;
|
||
//public Toggle spark_button;
|
||
|
||
//工具按钮
|
||
public ToolItem api_button;
|
||
public ToolItem task_button;
|
||
public ToolItem spark_button;
|
||
|
||
/// <summary>
|
||
/// 当前打开的工具
|
||
/// </summary>
|
||
public ToolItem selected_tool_item;
|
||
|
||
/// <summary>
|
||
/// 是否为展开面板(mini展开)
|
||
/// </summary>
|
||
public bool is_middle;//公共属性导致不同界面切换异常
|
||
|
||
#region Panels
|
||
/// <summary>
|
||
/// API
|
||
/// </summary>
|
||
public ApiPanel api_panel;
|
||
public ApiDetailPanel api_detail_panel;
|
||
/// <summary>
|
||
/// 任务面板
|
||
/// </summary>
|
||
public TaskPanel task_panel;
|
||
/// <summary>
|
||
/// 星火大模型
|
||
/// </summary>
|
||
public SparkModelPanel spark_panel;
|
||
//public static
|
||
#endregion
|
||
|
||
public PanelBasic selected_panel;
|
||
protected override void Awake()
|
||
{
|
||
base.Awake();
|
||
Instance = this;
|
||
}
|
||
|
||
protected override void OnEnable()
|
||
{
|
||
base.OnEnable();
|
||
if (topping_button && WindowManager.Instance)
|
||
topping_button.SetIsOnWithoutNotify(WindowManager.Instance.is_topping);
|
||
}
|
||
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
max_button.onClick.AddListener(OnMax);
|
||
min_button.onClick.AddListener(OnMin);
|
||
topping_button.onValueChanged.AddListener(OnTopping);
|
||
|
||
api_button.toggle.onValueChanged.AddListener(OnApi);
|
||
task_button.toggle.onValueChanged.AddListener(OnTask);
|
||
spark_button.toggle.onValueChanged.AddListener(OnSpark);
|
||
|
||
//task_panel.score_text.text = "分数:" + ScoreManager.Instance.total_score.ToString();
|
||
//toggle group ,切换时会先关闭上次选中再打开本次选中,
|
||
|
||
|
||
api_panel.Init(api_detail_panel);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 切换大窗口模式
|
||
/// </summary>
|
||
public void OnMax()
|
||
{
|
||
WindowManager.Instance.SwitchResolution(WindowManager.ScreenResolution.MAX_SCREEN);
|
||
//切换回大窗口后取消置顶状态
|
||
WindowManager.Instance.Topping(false);
|
||
}
|
||
|
||
public void OnMin()
|
||
{
|
||
WindowManager.Instance.MinWindow();
|
||
}
|
||
|
||
private void OnTopping(bool _ison)
|
||
{
|
||
WindowManager.Instance.Topping(_ison);
|
||
}
|
||
|
||
public void OnApi(bool _ison)
|
||
{
|
||
if (_ison)
|
||
{
|
||
if (selected_tool_item == null)
|
||
{
|
||
WindowManager.Instance.SwitchResolution(api_button.resolution);
|
||
}
|
||
else
|
||
{
|
||
selected_tool_item.toggle.SetIsOnWithoutNotify(false);
|
||
if (selected_tool_item.resolution != api_button.resolution)
|
||
{
|
||
WindowManager.Instance.SwitchResolution(api_button.resolution);
|
||
}
|
||
}
|
||
|
||
selected_tool_item = api_button;
|
||
|
||
if (selected_panel != null)
|
||
selected_panel.OnNagetive();
|
||
|
||
api_panel.OnActive();
|
||
selected_panel = api_panel;
|
||
}
|
||
else
|
||
{
|
||
if (selected_tool_item == api_button)
|
||
{
|
||
selected_tool_item = null;
|
||
WindowManager.Instance.SwitchResolution(WindowManager.ScreenResolution.MINI_SCREEN);
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
selected_panel = null;
|
||
api_panel.OnNagetive();
|
||
}
|
||
}
|
||
|
||
public void OnTask(bool _ison)
|
||
{
|
||
if (_ison)
|
||
{
|
||
if (selected_tool_item == null)
|
||
{
|
||
WindowManager.Instance.SwitchResolution(task_button.resolution);
|
||
}
|
||
else
|
||
{
|
||
selected_tool_item.toggle.SetIsOnWithoutNotify(false);
|
||
if (selected_tool_item.resolution != task_button.resolution)
|
||
{
|
||
WindowManager.Instance.SwitchResolution(task_button.resolution);
|
||
}
|
||
}
|
||
|
||
selected_tool_item = task_button;
|
||
|
||
if (selected_panel != null)
|
||
selected_panel.OnNagetive();
|
||
|
||
task_panel.OnActive();
|
||
selected_panel = task_panel;
|
||
}
|
||
else
|
||
{
|
||
if (selected_tool_item == task_button)
|
||
{
|
||
selected_tool_item = null;
|
||
WindowManager.Instance.SwitchResolution(WindowManager.ScreenResolution.MINI_SCREEN);
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
selected_panel = null;
|
||
task_panel.OnNagetive();
|
||
}
|
||
}
|
||
|
||
public void OnSpark(bool _ison)
|
||
{
|
||
if (_ison)
|
||
{
|
||
if (selected_tool_item == null)
|
||
{
|
||
WindowManager.Instance.SwitchResolution(spark_button.resolution);
|
||
}
|
||
else
|
||
{
|
||
selected_tool_item.toggle.SetIsOnWithoutNotify(false);
|
||
if (selected_tool_item.resolution != spark_button.resolution)
|
||
{
|
||
WindowManager.Instance.SwitchResolution(spark_button.resolution);
|
||
}
|
||
}
|
||
selected_tool_item = spark_button;
|
||
|
||
if (selected_panel != null)
|
||
selected_panel.OnNagetive();
|
||
selected_panel = spark_panel;
|
||
spark_panel.OnActive();
|
||
}
|
||
else
|
||
{
|
||
if (selected_tool_item == spark_button)
|
||
{
|
||
selected_tool_item = null;
|
||
WindowManager.Instance.SwitchResolution(WindowManager.ScreenResolution.MINI_SCREEN);
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
spark_panel.OnNagetive();
|
||
}
|
||
}
|
||
}
|