Files
2026-02-21 16:45:37 +08:00

101 lines
2.8 KiB
C#

using System;
using LapinerTools.uMyGUI;
using UnityEngine;
using UnityEngine.UI;
namespace LE_LevelEditor.UI
{
public class LE_PopupFileSelection : uMyGUI_PopupText
{
[SerializeField]
protected uMyGUI_TreeBrowser m_filePicker;
[SerializeField]
protected InputField m_saveInput;
public string examplesUrl = string.Empty;
public InputField SaveInput
{
get
{
return m_saveInput;
}
}
public override void Show()
{
base.Show();
if (m_saveInput != null)
{
m_saveInput.text = string.Empty;
}
}
public override void Hide()
{
base.Hide();
if (m_filePicker != null)
{
m_filePicker.Clear();
m_filePicker.OnLeafNodeClick = null;
m_filePicker.gameObject.SetActive(false);
}
}
public void DownloadExamples()
{
Utilities.OpenURL("http://steamcommunity.com/app/468920/discussions/10/1700541698680360050/");
}
public void OpenFolder()
{
Application.OpenURL(FisheryEditor_LoadSave.GetSaveFolderPath());
}
public virtual LE_PopupFileSelection SetFiles(string[] p_names, string[] p_iconPaths, Action<int> p_onSelectedCallback, Action<int> p_onDeleteCallback)
{
return SetFiles(p_names, p_iconPaths, p_onSelectedCallback, p_onDeleteCallback, true);
}
public virtual LE_PopupFileSelection SetFiles(string[] p_names, string[] p_iconPaths, Action<int> p_onSelectedCallback, Action<int> p_onDeleteCallback, bool p_isCloseOnClick)
{
if (m_filePicker != null)
{
m_filePicker.gameObject.SetActive(true);
uMyGUI_TreeBrowser.Node[] array = new uMyGUI_TreeBrowser.Node[p_names.Length];
for (int i = 0; i < p_names.Length; i++)
{
string p_text = p_names[i];
string p_iconPath = ((p_iconPaths.Length <= i) ? string.Empty : p_iconPaths[i]);
LE_LevelFileNode.SendMessageInitData nodeData = new LE_LevelFileNode.SendMessageInitData(i, p_text, p_iconPath, false);
if (p_onDeleteCallback != null)
{
nodeData.m_onDelete = delegate
{
p_onDeleteCallback(nodeData.m_id);
};
}
array[i] = new uMyGUI_TreeBrowser.Node(nodeData, null);
}
uMyGUI_TreeBrowser filePicker = m_filePicker;
filePicker.OnLeafNodeClick = (EventHandler<uMyGUI_TreeBrowser.NodeClickEventArgs>)Delegate.Combine(filePicker.OnLeafNodeClick, (EventHandler<uMyGUI_TreeBrowser.NodeClickEventArgs>)delegate(object p_object, uMyGUI_TreeBrowser.NodeClickEventArgs p_args)
{
LE_LevelFileNode.SendMessageInitData sendMessageInitData = (LE_LevelFileNode.SendMessageInitData)p_args.ClickedNode.SendMessageData;
p_onSelectedCallback(sendMessageInitData.m_id);
if (m_audioSources.Length > 0 && m_audioSources[0] != null)
{
m_audioSources[0].Play();
}
if (p_isCloseOnClick)
{
Hide();
}
});
m_filePicker.BuildTree(array);
}
return this;
}
}
}