2020-08-13 00:06:39 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Harmony;
|
|
|
|
|
using MelonLoader;
|
|
|
|
|
using UnhollowerBaseLib;
|
|
|
|
|
using UnhollowerRuntimeLib;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Explorer
|
|
|
|
|
{
|
|
|
|
|
public abstract class UIWindow
|
|
|
|
|
{
|
2020-08-30 01:08:48 +10:00
|
|
|
|
public abstract string Title { get; }
|
2020-08-13 00:06:39 +10:00
|
|
|
|
|
|
|
|
|
public object Target;
|
|
|
|
|
|
|
|
|
|
public int windowID;
|
2020-09-10 20:31:09 +10:00
|
|
|
|
public Rect m_rect = new Rect(Vector2.zero, ModConfig.Instance.Default_Window_Size);
|
2020-08-13 00:06:39 +10:00
|
|
|
|
|
|
|
|
|
public Vector2 scroll = Vector2.zero;
|
|
|
|
|
|
2020-08-30 01:08:48 +10:00
|
|
|
|
public virtual bool IsTabViewWindow => false;
|
|
|
|
|
|
2020-08-22 00:16:05 +10:00
|
|
|
|
public abstract void Init();
|
|
|
|
|
public abstract void WindowFunction(int windowID);
|
|
|
|
|
public abstract void Update();
|
|
|
|
|
|
2020-08-13 00:06:39 +10:00
|
|
|
|
public static UIWindow CreateWindow<T>(object target) where T : UIWindow
|
|
|
|
|
{
|
|
|
|
|
var window = Activator.CreateInstance<T>();
|
|
|
|
|
|
|
|
|
|
window.Target = target;
|
|
|
|
|
window.windowID = WindowManager.NextWindowID();
|
|
|
|
|
window.m_rect = WindowManager.GetNewWindowRect();
|
|
|
|
|
|
|
|
|
|
WindowManager.Windows.Add(window);
|
|
|
|
|
|
|
|
|
|
window.Init();
|
|
|
|
|
|
|
|
|
|
return window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DestroyWindow()
|
|
|
|
|
{
|
2020-08-30 07:01:13 +10:00
|
|
|
|
WindowManager.DestroyWindow(this);
|
2020-08-13 00:06:39 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnGUI()
|
|
|
|
|
{
|
|
|
|
|
if (CppExplorer.ShowMenu)
|
|
|
|
|
{
|
|
|
|
|
var origSkin = GUI.skin;
|
|
|
|
|
|
|
|
|
|
GUI.skin = UIStyles.WindowSkin;
|
2020-08-30 01:08:48 +10:00
|
|
|
|
m_rect = GUI.Window(windowID, m_rect, (GUI.WindowFunction)WindowFunction, Title);
|
2020-08-13 00:06:39 +10:00
|
|
|
|
|
|
|
|
|
GUI.skin = origSkin;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Header()
|
|
|
|
|
{
|
2020-08-30 01:08:48 +10:00
|
|
|
|
if (!WindowManager.TabView)
|
2020-08-13 00:06:39 +10:00
|
|
|
|
{
|
2020-08-30 07:01:13 +10:00
|
|
|
|
GUI.DragWindow(new Rect(0, 0, m_rect.width - 90, 20));
|
|
|
|
|
|
2020-08-30 01:08:48 +10:00
|
|
|
|
if (GUI.Button(new Rect(m_rect.width - 90, 2, 80, 20), "<color=red><b>X</b></color>"))
|
|
|
|
|
{
|
|
|
|
|
DestroyWindow();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-13 00:06:39 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|