mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
Finished scene explorer, lots of cleanups. Inspector and Search left now.
This commit is contained in:
parent
7328610252
commit
ff684d4d4b
@ -3,9 +3,9 @@
|
|||||||
//using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
//using System.Linq;
|
//using System.Linq;
|
||||||
//using System.Text;
|
//using System.Text;
|
||||||
//using Explorer.UI;
|
//using ExplorerBeta.UI;
|
||||||
|
|
||||||
//namespace Explorer.CacheObject
|
//namespace ExplorerBeta.CacheObject
|
||||||
//{
|
//{
|
||||||
// public class CacheEnumerated : CacheObjectBase
|
// public class CacheEnumerated : CacheObjectBase
|
||||||
// {
|
// {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//using System;
|
//using System;
|
||||||
//using System.Reflection;
|
//using System.Reflection;
|
||||||
//using Explorer.CacheObject;
|
//using ExplorerBeta.CacheObject;
|
||||||
//using UnityEngine;
|
//using UnityEngine;
|
||||||
//using Explorer.Helpers;
|
//using ExplorerBeta.Helpers;
|
||||||
|
|
||||||
//namespace Explorer
|
//namespace Explorer
|
||||||
//{
|
//{
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
//using System.Linq;
|
//using System.Linq;
|
||||||
//using System.Text;
|
//using System.Text;
|
||||||
//using System.Reflection;
|
//using System.Reflection;
|
||||||
//using Explorer.UI;
|
//using ExplorerBeta.UI;
|
||||||
//using Explorer.Helpers;
|
//using ExplorerBeta.Helpers;
|
||||||
|
|
||||||
//namespace Explorer.CacheObject
|
//namespace ExplorerBeta.CacheObject
|
||||||
//{
|
//{
|
||||||
// public class CacheField : CacheMember
|
// public class CacheField : CacheMember
|
||||||
// {
|
// {
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
//using System.Linq;
|
//using System.Linq;
|
||||||
//using System.Reflection;
|
//using System.Reflection;
|
||||||
//using UnityEngine;
|
//using UnityEngine;
|
||||||
//using Explorer.UI;
|
//using ExplorerBeta.UI;
|
||||||
//using Explorer.UI.Shared;
|
//using ExplorerBeta.UI.Shared;
|
||||||
|
|
||||||
//namespace Explorer.CacheObject
|
//namespace ExplorerBeta.CacheObject
|
||||||
//{
|
//{
|
||||||
// public class CacheMember : CacheObjectBase
|
// public class CacheMember : CacheObjectBase
|
||||||
// {
|
// {
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
//using System.Linq;
|
//using System.Linq;
|
||||||
//using System.Reflection;
|
//using System.Reflection;
|
||||||
//using UnityEngine;
|
//using UnityEngine;
|
||||||
//using Explorer.UI.Shared;
|
//using ExplorerBeta.UI.Shared;
|
||||||
//using Explorer.Helpers;
|
//using ExplorerBeta.Helpers;
|
||||||
|
|
||||||
//namespace Explorer.CacheObject
|
//namespace ExplorerBeta.CacheObject
|
||||||
//{
|
//{
|
||||||
// public class CacheMethod : CacheMember
|
// public class CacheMethod : CacheMember
|
||||||
// {
|
// {
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
//using System.Linq;
|
//using System.Linq;
|
||||||
//using System.Reflection;
|
//using System.Reflection;
|
||||||
//using UnityEngine;
|
//using UnityEngine;
|
||||||
//using Explorer.UI;
|
//using ExplorerBeta.UI;
|
||||||
//using Explorer.UI.Shared;
|
//using ExplorerBeta.UI.Shared;
|
||||||
//using Explorer.Helpers;
|
//using ExplorerBeta.Helpers;
|
||||||
|
|
||||||
//namespace Explorer.CacheObject
|
//namespace ExplorerBeta.CacheObject
|
||||||
//{
|
//{
|
||||||
// public class CacheObjectBase
|
// public class CacheObjectBase
|
||||||
// {
|
// {
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
//using System.Linq;
|
//using System.Linq;
|
||||||
//using System.Text;
|
//using System.Text;
|
||||||
//using System.Reflection;
|
//using System.Reflection;
|
||||||
//using Explorer.UI;
|
//using ExplorerBeta.UI;
|
||||||
//using Explorer.Helpers;
|
//using ExplorerBeta.Helpers;
|
||||||
|
|
||||||
//namespace Explorer.CacheObject
|
//namespace ExplorerBeta.CacheObject
|
||||||
//{
|
//{
|
||||||
// public class CacheProperty : CacheMember
|
// public class CacheProperty : CacheMember
|
||||||
// {
|
// {
|
||||||
|
@ -14,21 +14,20 @@ namespace ExplorerBeta.Config
|
|||||||
[XmlIgnore] public static ModConfig Instance;
|
[XmlIgnore] public static ModConfig Instance;
|
||||||
|
|
||||||
// Actual configs
|
// Actual configs
|
||||||
public KeyCode Main_Menu_Toggle = KeyCode.F7;
|
public KeyCode Main_Menu_Toggle = KeyCode.F7;
|
||||||
public Vector2 Default_Window_Size = new Vector2(550, 700);
|
public Vector2 Default_Window_Size = new Vector2(550, 700);
|
||||||
public int Default_Page_Limit = 20;
|
public int Default_Page_Limit = 20;
|
||||||
public bool Bitwise_Support = false;
|
public bool Bitwise_Support = false;
|
||||||
public bool Tab_View = true;
|
public bool Tab_View = true;
|
||||||
public string Default_Output_Path = @"Mods\Explorer";
|
public string Default_Output_Path = @"Mods\Explorer";
|
||||||
|
|
||||||
public static void OnLoad()
|
public static void OnLoad()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(EXPLORER_FOLDER))
|
if (!Directory.Exists(EXPLORER_FOLDER))
|
||||||
{
|
|
||||||
Directory.CreateDirectory(EXPLORER_FOLDER);
|
Directory.CreateDirectory(EXPLORER_FOLDER);
|
||||||
}
|
|
||||||
|
|
||||||
if (LoadSettings()) return;
|
if (LoadSettings())
|
||||||
|
return;
|
||||||
|
|
||||||
Instance = new ModConfig();
|
Instance = new ModConfig();
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
@ -38,7 +37,9 @@ namespace ExplorerBeta.Config
|
|||||||
public static bool LoadSettings()
|
public static bool LoadSettings()
|
||||||
{
|
{
|
||||||
if (!File.Exists(SETTINGS_PATH))
|
if (!File.Exists(SETTINGS_PATH))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -58,7 +59,9 @@ namespace ExplorerBeta.Config
|
|||||||
public static void SaveSettings()
|
public static void SaveSettings()
|
||||||
{
|
{
|
||||||
if (File.Exists(SETTINGS_PATH))
|
if (File.Exists(SETTINGS_PATH))
|
||||||
|
{
|
||||||
File.Delete(SETTINGS_PATH);
|
File.Delete(SETTINGS_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
using (var file = File.Create(SETTINGS_PATH))
|
using (var file = File.Create(SETTINGS_PATH))
|
||||||
{
|
{
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
<OutputPath>..\Release\Explorer.MelonLoader.Il2Cpp\</OutputPath>
|
<OutputPath>..\Release\Explorer.MelonLoader.Il2Cpp\</OutputPath>
|
||||||
<DefineConstants></DefineConstants>
|
<DefineConstants>
|
||||||
<IsCpp>true</IsCpp>
|
</DefineConstants>
|
||||||
<IsMelonLoader>true</IsMelonLoader>
|
<IsCpp>false</IsCpp>
|
||||||
|
<IsMelonLoader>false</IsMelonLoader>
|
||||||
<DebugSymbols>false</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@ -22,7 +23,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<RootNamespace>Explorer</RootNamespace>
|
<RootNamespace>ExplorerBeta</RootNamespace>
|
||||||
<AssemblyName>ExplorerBeta</AssemblyName>
|
<AssemblyName>ExplorerBeta</AssemblyName>
|
||||||
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
|
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
|
||||||
<MLCppGameFolder>D:\Steam\steamapps\common\VRChat</MLCppGameFolder>
|
<MLCppGameFolder>D:\Steam\steamapps\common\VRChat</MLCppGameFolder>
|
||||||
@ -85,8 +86,8 @@
|
|||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<!-- Universal Mono UnityEngine.dll ref (v5.3) -->
|
||||||
<!-- Universal Mono UnityEngine.dll ref (v5.3) --><!--
|
<!--
|
||||||
<ItemGroup Condition="'$(IsCpp)'=='false'">
|
<ItemGroup Condition="'$(IsCpp)'=='false'">
|
||||||
<Reference Include="UnityEngine">
|
<Reference Include="UnityEngine">
|
||||||
<HintPath>..\lib\UnityEngine.dll</HintPath>
|
<HintPath>..\lib\UnityEngine.dll</HintPath>
|
||||||
@ -101,7 +102,6 @@
|
|||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>-->
|
</ItemGroup>-->
|
||||||
|
|
||||||
<!-- MelonLoader Mono refs -->
|
<!-- MelonLoader Mono refs -->
|
||||||
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='true|false'">
|
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='true|false'">
|
||||||
<Reference Include="MelonLoader.ModHandler">
|
<Reference Include="MelonLoader.ModHandler">
|
||||||
@ -149,7 +149,6 @@
|
|||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- BepInEx Mono refs -->
|
<!-- BepInEx Mono refs -->
|
||||||
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='false|false'">
|
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='false|false'">
|
||||||
<Reference Include="BepInEx">
|
<Reference Include="BepInEx">
|
||||||
@ -201,7 +200,6 @@
|
|||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- MelonLoader Il2Cpp refs -->
|
<!-- MelonLoader Il2Cpp refs -->
|
||||||
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='true|true'">
|
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='true|true'">
|
||||||
<Reference Include="MelonLoader.ModHandler">
|
<Reference Include="MelonLoader.ModHandler">
|
||||||
@ -257,7 +255,6 @@
|
|||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- BepInEx Il2Cpp refs -->
|
<!-- BepInEx Il2Cpp refs -->
|
||||||
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='false|true'">
|
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='false|true'">
|
||||||
<Reference Include="BepInEx">
|
<Reference Include="BepInEx">
|
||||||
@ -346,26 +343,31 @@
|
|||||||
<Compile Include="Input\LegacyInput.cs" />
|
<Compile Include="Input\LegacyInput.cs" />
|
||||||
<Compile Include="Input\NoInput.cs" />
|
<Compile Include="Input\NoInput.cs" />
|
||||||
<Compile Include="UI\Main\DebugConsole.cs" />
|
<Compile Include="UI\Main\DebugConsole.cs" />
|
||||||
|
<Compile Include="UI\Main\InspectorManager.cs" />
|
||||||
<Compile Include="UI\Main\MainMenu.cs" />
|
<Compile Include="UI\Main\MainMenu.cs" />
|
||||||
<Compile Include="UI\Main\Pages\BaseMenuPage.cs" />
|
<Compile Include="UI\Main\ConsolePage.cs" />
|
||||||
<Compile Include="UI\Main\Pages\ConsolePage.cs" />
|
<Compile Include="UI\Main\Console\AutoCompleter.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\AutoCompleter.cs" />
|
<Compile Include="UI\Main\Console\CodeEditor.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\CodeEditor.cs" />
|
<Compile Include="UI\Main\Console\CSharpLexer.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\CSharpLexer.cs" />
|
<Compile Include="UI\Main\Console\Lexer\CommentMatch.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\Lexer\CommentMatch.cs" />
|
<Compile Include="UI\Main\Console\Lexer\ILexer.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\Lexer\ILexer.cs" />
|
<Compile Include="UI\Main\Console\Lexer\InputLexer.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\Lexer\InputLexer.cs" />
|
<Compile Include="UI\Main\Console\Lexer\KeywordMatch.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\Lexer\KeywordMatch.cs" />
|
<Compile Include="UI\Main\Console\Lexer\StringMatch.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\Lexer\StringMatch.cs" />
|
<Compile Include="UI\Main\Console\Lexer\MatchLexer.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\Lexer\MatchLexer.cs" />
|
<Compile Include="UI\Main\Console\Lexer\NumberMatch.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\Lexer\NumberMatch.cs" />
|
<Compile Include="UI\Main\Console\Lexer\SymbolMatch.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\Editor\Lexer\SymbolMatch.cs" />
|
<Compile Include="UI\Main\Console\Suggestion.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\ScriptEvaluator\AutoComplete.cs" />
|
<Compile Include="UI\Main\Console\ScriptEvaluator.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\ScriptEvaluator\ScriptEvaluator.cs" />
|
<Compile Include="UI\Main\Console\ScriptInteraction.cs" />
|
||||||
<Compile Include="UI\Main\Pages\Console\ScriptEvaluator\ScriptInteraction.cs" />
|
<Compile Include="UI\Main\HomePage.cs" />
|
||||||
<Compile Include="UI\Main\Pages\HomePage.cs" />
|
<Compile Include="UI\Main\Inspectors\GameObjectInspector.cs" />
|
||||||
<Compile Include="UI\Main\Pages\OptionsPage.cs" />
|
<Compile Include="UI\Main\Inspectors\InspectorBase.cs" />
|
||||||
<Compile Include="UI\Main\Pages\SearchPage.cs" />
|
<Compile Include="UI\Main\Inspectors\InstanceInspector.cs" />
|
||||||
|
<Compile Include="UI\Main\Inspectors\StaticInspector.cs" />
|
||||||
|
<Compile Include="UI\Main\OptionsPage.cs" />
|
||||||
|
<Compile Include="UI\Main\SceneExplorer.cs" />
|
||||||
|
<Compile Include="UI\Main\SearchPage.cs" />
|
||||||
<Compile Include="UI\Main\PanelDragger.cs" />
|
<Compile Include="UI\Main\PanelDragger.cs" />
|
||||||
<Compile Include="UI\InteractiveValue\InteractiveValue.cs" />
|
<Compile Include="UI\InteractiveValue\InteractiveValue.cs" />
|
||||||
<Compile Include="UI\Shared\PageHandler.cs" />
|
<Compile Include="UI\Shared\PageHandler.cs" />
|
||||||
@ -384,7 +386,9 @@
|
|||||||
<None Include="ILRepack.targets" />
|
<None Include="ILRepack.targets" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Folder Include="UI\MouseInspector\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets" Condition="Exists('packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" />
|
<Import Project="packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets" Condition="Exists('packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Linq;
|
|
||||||
using ExplorerBeta.Config;
|
using ExplorerBeta.Config;
|
||||||
using ExplorerBeta.Input;
|
using ExplorerBeta.Input;
|
||||||
using ExplorerBeta.UI;
|
using ExplorerBeta.UI;
|
||||||
using ExplorerBeta.UI.Main;
|
using ExplorerBeta.UI.Main;
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ExplorerBeta
|
namespace ExplorerBeta
|
||||||
{
|
{
|
||||||
public class ExplorerCore
|
public class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
|
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
|
||||||
public const string VERSION = "3.0.0b";
|
public const string VERSION = "3.0.0b";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.explorer";
|
public const string GUID = "com.sinai.explorer";
|
||||||
|
|
||||||
public const string PLATFORM =
|
public const string PLATFORM =
|
||||||
#if CPP
|
#if CPP
|
||||||
@ -77,13 +74,9 @@ namespace ExplorerBeta
|
|||||||
UIManager.CanvasRoot.SetActive(show);
|
UIManager.CanvasRoot.SetActive(show);
|
||||||
|
|
||||||
if (show)
|
if (show)
|
||||||
{
|
|
||||||
ForceUnlockCursor.SetEventSystem();
|
ForceUnlockCursor.SetEventSystem();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ForceUnlockCursor.ReleaseEventSystem();
|
ForceUnlockCursor.ReleaseEventSystem();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ForceUnlockCursor.UpdateCursorControl();
|
ForceUnlockCursor.UpdateCursorControl();
|
||||||
@ -91,24 +84,11 @@ namespace ExplorerBeta
|
|||||||
|
|
||||||
public static void Update()
|
public static void Update()
|
||||||
{
|
{
|
||||||
// Temporary delay before UIManager.Init
|
|
||||||
if (!m_doneUIInit)
|
if (!m_doneUIInit)
|
||||||
{
|
CheckUIInit();
|
||||||
m_timeSinceStartup += Time.deltaTime;
|
|
||||||
|
|
||||||
if (m_timeSinceStartup > 0.1f)
|
|
||||||
{
|
|
||||||
UIManager.Init();
|
|
||||||
|
|
||||||
Log("Initialized Explorer UI.");
|
|
||||||
m_doneUIInit = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InputManager.GetKeyDown(ModConfig.Instance.Main_Menu_Toggle))
|
if (InputManager.GetKeyDown(ModConfig.Instance.Main_Menu_Toggle))
|
||||||
{
|
|
||||||
ShowMenu = !ShowMenu;
|
ShowMenu = !ShowMenu;
|
||||||
}
|
|
||||||
|
|
||||||
if (ShowMenu)
|
if (ShowMenu)
|
||||||
{
|
{
|
||||||
@ -117,6 +97,25 @@ namespace ExplorerBeta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CheckUIInit()
|
||||||
|
{
|
||||||
|
m_timeSinceStartup += Time.deltaTime;
|
||||||
|
|
||||||
|
if (m_timeSinceStartup > 0.1f)
|
||||||
|
{
|
||||||
|
m_doneUIInit = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
UIManager.Init();
|
||||||
|
Log("Initialized Explorer UI.");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LogWarning($"Exception setting up UI: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void OnSceneChange()
|
public static void OnSceneChange()
|
||||||
{
|
{
|
||||||
UIManager.OnSceneChange();
|
UIManager.OnSceneChange();
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
#if ML
|
#if ML
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
|
|
||||||
namespace ExplorerBeta
|
namespace ExplorerBeta
|
||||||
|
@ -4,20 +4,16 @@ namespace ExplorerBeta
|
|||||||
{
|
{
|
||||||
public static class UnityExtensions
|
public static class UnityExtensions
|
||||||
{
|
{
|
||||||
public static string GetGameObjectPath(this Transform _transform)
|
public static string GetTransformPath(this Transform _transform)
|
||||||
{
|
{
|
||||||
return GetGameObjectPath(_transform, true);
|
string path = _transform.name;
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetGameObjectPath(this Transform _transform, bool _includeThisName)
|
while (_transform.parent != null)
|
||||||
{
|
|
||||||
string path = _includeThisName ? ("/" + _transform.name) : "";
|
|
||||||
GameObject gameObject = _transform.gameObject;
|
|
||||||
while (gameObject.transform.parent != null)
|
|
||||||
{
|
{
|
||||||
gameObject = gameObject.transform.parent.gameObject;
|
_transform = _transform.parent;
|
||||||
path = "/" + gameObject.name + path;
|
path = _transform.name + "/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
#if CPP
|
#if CPP
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace ExplorerBeta.Helpers
|
namespace ExplorerBeta.Helpers
|
||||||
{
|
{
|
||||||
@ -17,18 +14,16 @@ namespace ExplorerBeta.Helpers
|
|||||||
public static T GetICall<T>(string iCallName) where T : Delegate
|
public static T GetICall<T>(string iCallName) where T : Delegate
|
||||||
{
|
{
|
||||||
if (iCallCache.ContainsKey(iCallName))
|
if (iCallCache.ContainsKey(iCallName))
|
||||||
{
|
|
||||||
return (T)iCallCache[iCallName];
|
return (T)iCallCache[iCallName];
|
||||||
}
|
|
||||||
|
|
||||||
var ptr = il2cpp_resolve_icall(iCallName);
|
IntPtr ptr = il2cpp_resolve_icall(iCallName);
|
||||||
|
|
||||||
if (ptr == IntPtr.Zero)
|
if (ptr == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new MissingMethodException($"Could not resolve internal call by name '{iCallName}'!");
|
throw new MissingMethodException($"Could not resolve internal call by name '{iCallName}'!");
|
||||||
}
|
}
|
||||||
|
|
||||||
var iCall = Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
|
Delegate iCall = Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
|
||||||
iCallCache.Add(iCallName, iCall);
|
iCallCache.Add(iCallName, iCall);
|
||||||
|
|
||||||
return (T)iCall;
|
return (T)iCall;
|
||||||
|
@ -22,10 +22,10 @@ namespace ExplorerBeta.Helpers
|
|||||||
|
|
||||||
#if CPP
|
#if CPP
|
||||||
public static ILType GameObjectType => Il2CppType.Of<GameObject>();
|
public static ILType GameObjectType => Il2CppType.Of<GameObject>();
|
||||||
public static ILType TransformType => Il2CppType.Of<Transform>();
|
public static ILType TransformType => Il2CppType.Of<Transform>();
|
||||||
public static ILType ObjectType => Il2CppType.Of<UnityEngine.Object>();
|
public static ILType ObjectType => Il2CppType.Of<UnityEngine.Object>();
|
||||||
public static ILType ComponentType => Il2CppType.Of<Component>();
|
public static ILType ComponentType => Il2CppType.Of<Component>();
|
||||||
public static ILType BehaviourType => Il2CppType.Of<Behaviour>();
|
public static ILType BehaviourType => Il2CppType.Of<Behaviour>();
|
||||||
#else
|
#else
|
||||||
public static Type GameObjectType => typeof(GameObject);
|
public static Type GameObjectType => typeof(GameObject);
|
||||||
public static Type TransformType => typeof(Transform);
|
public static Type TransformType => typeof(Transform);
|
||||||
@ -40,10 +40,14 @@ namespace ExplorerBeta.Helpers
|
|||||||
public static object Il2CppCast(object obj, Type castTo)
|
public static object Il2CppCast(object obj, Type castTo)
|
||||||
{
|
{
|
||||||
if (!(obj is Il2CppSystem.Object ilObj))
|
if (!(obj is Il2CppSystem.Object ilObj))
|
||||||
|
{
|
||||||
return obj;
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
if (!typeof(Il2CppSystem.Object).IsAssignableFrom(castTo))
|
if (!typeof(Il2CppSystem.Object).IsAssignableFrom(castTo))
|
||||||
|
{
|
||||||
return obj;
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
IntPtr castToPtr;
|
IntPtr castToPtr;
|
||||||
if (!ClassPointers.ContainsKey(castTo))
|
if (!ClassPointers.ContainsKey(castTo))
|
||||||
@ -61,9 +65,11 @@ namespace ExplorerBeta.Helpers
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (castToPtr == IntPtr.Zero)
|
if (castToPtr == IntPtr.Zero)
|
||||||
|
{
|
||||||
return obj;
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
var classPtr = il2cpp_object_get_class(ilObj.Pointer);
|
IntPtr classPtr = il2cpp_object_get_class(ilObj.Pointer);
|
||||||
|
|
||||||
if (!il2cpp_class_is_assignable_from(castToPtr, classPtr))
|
if (!il2cpp_class_is_assignable_from(castToPtr, classPtr))
|
||||||
return obj;
|
return obj;
|
||||||
@ -100,7 +106,8 @@ namespace ExplorerBeta.Helpers
|
|||||||
|
|
||||||
public static Type GetActualType(object obj)
|
public static Type GetActualType(object obj)
|
||||||
{
|
{
|
||||||
if (obj == null) return null;
|
if (obj == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
#if CPP
|
#if CPP
|
||||||
// Need to use GetIl2CppType for Il2CppSystem Objects
|
// Need to use GetIl2CppType for Il2CppSystem Objects
|
||||||
@ -124,7 +131,7 @@ namespace ExplorerBeta.Helpers
|
|||||||
|
|
||||||
public static Type[] GetAllBaseTypes(Type type)
|
public static Type[] GetAllBaseTypes(Type type)
|
||||||
{
|
{
|
||||||
var list = new List<Type>();
|
List<Type> list = new List<Type>();
|
||||||
|
|
||||||
while (type != null)
|
while (type != null)
|
||||||
{
|
{
|
||||||
@ -139,11 +146,14 @@ namespace ExplorerBeta.Helpers
|
|||||||
{
|
{
|
||||||
#if CPP
|
#if CPP
|
||||||
#if ML
|
#if ML
|
||||||
var path = $@"MelonLoader\Managed\{module}.dll";
|
string path = $@"MelonLoader\Managed\{module}.dll";
|
||||||
#else
|
#else
|
||||||
var path = $@"BepInEx\unhollowed\{module}.dll";
|
var path = $@"BepInEx\unhollowed\{module}.dll";
|
||||||
#endif
|
#endif
|
||||||
if (!File.Exists(path)) return false;
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
|
||||||
#if CPP
|
#if CPP
|
||||||
using ExplorerBeta.Unstrip.ImageConversion;
|
using ExplorerBeta.Unstrip.ImageConversion;
|
||||||
#endif
|
#endif
|
||||||
@ -61,9 +57,7 @@ namespace ExplorerBeta.Helpers
|
|||||||
Color[] pixels;
|
Color[] pixels;
|
||||||
|
|
||||||
if (!orig.IsReadable())
|
if (!orig.IsReadable())
|
||||||
{
|
|
||||||
orig = ForceReadTexture(orig);
|
orig = ForceReadTexture(orig);
|
||||||
}
|
|
||||||
|
|
||||||
pixels = orig.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
pixels = orig.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
||||||
|
|
||||||
@ -77,7 +71,7 @@ namespace ExplorerBeta.Helpers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var origFilter = tex.filterMode;
|
FilterMode origFilter = tex.filterMode;
|
||||||
tex.filterMode = FilterMode.Point;
|
tex.filterMode = FilterMode.Point;
|
||||||
|
|
||||||
var rt = RenderTexture.GetTemporary(tex.width, tex.height, 0, RenderTextureFormat.ARGB32);
|
var rt = RenderTexture.GetTemporary(tex.width, tex.height, 0, RenderTextureFormat.ARGB32);
|
||||||
@ -105,12 +99,10 @@ namespace ExplorerBeta.Helpers
|
|||||||
public static void SaveTextureAsPNG(Texture2D tex, string dir, string name, bool isDTXnmNormal = false)
|
public static void SaveTextureAsPNG(Texture2D tex, string dir, string name, bool isDTXnmNormal = false)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(dir))
|
if (!Directory.Exists(dir))
|
||||||
{
|
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
}
|
|
||||||
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
var savepath = dir + @"\" + name + ".png";
|
string savepath = dir + @"\" + name + ".png";
|
||||||
|
|
||||||
// Make sure we can EncodeToPNG it.
|
// Make sure we can EncodeToPNG it.
|
||||||
if (tex.format != TextureFormat.ARGB32 || !tex.IsReadable())
|
if (tex.format != TextureFormat.ARGB32 || !tex.IsReadable())
|
||||||
@ -154,12 +146,12 @@ namespace ExplorerBeta.Helpers
|
|||||||
|
|
||||||
for (int i = 0; i < colors.Length; i++)
|
for (int i = 0; i < colors.Length; i++)
|
||||||
{
|
{
|
||||||
Color c = colors[i];
|
var c = colors[i];
|
||||||
|
|
||||||
c.r = c.a * 2 - 1; // red <- alpha
|
c.r = c.a * 2 - 1; // red <- alpha
|
||||||
c.g = c.g * 2 - 1; // green is always the same
|
c.g = c.g * 2 - 1; // green is always the same
|
||||||
|
|
||||||
Vector2 rg = new Vector2(c.r, c.g); //this is the red-green vector
|
var rg = new Vector2(c.r, c.g); //this is the red-green vector
|
||||||
c.b = Mathf.Sqrt(1 - Mathf.Clamp01(Vector2.Dot(rg, rg))); //recalculate the blue channel
|
c.b = Mathf.Sqrt(1 - Mathf.Clamp01(Vector2.Dot(rg, rg))); //recalculate the blue channel
|
||||||
|
|
||||||
colors[i] = new Color(
|
colors[i] = new Color(
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
using System;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace ExplorerBeta.Input
|
namespace ExplorerBeta.Input
|
||||||
{
|
{
|
||||||
public interface IAbstractInput
|
public interface IHandleInput
|
||||||
{
|
{
|
||||||
void Init();
|
void Init();
|
||||||
|
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using ExplorerBeta.Input;
|
|
||||||
using ExplorerBeta.Helpers;
|
using ExplorerBeta.Helpers;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
#if CPP
|
#if CPP
|
||||||
@ -13,7 +11,7 @@ namespace ExplorerBeta.Input
|
|||||||
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Unity style")]
|
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Unity style")]
|
||||||
public static class InputManager
|
public static class InputManager
|
||||||
{
|
{
|
||||||
private static IAbstractInput m_inputModule;
|
private static IHandleInput m_inputModule;
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using ExplorerBeta.Helpers;
|
using ExplorerBeta.Helpers;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ExplorerBeta.Input
|
namespace ExplorerBeta.Input
|
||||||
{
|
{
|
||||||
public class InputSystem : IAbstractInput
|
public class InputSystem : IHandleInput
|
||||||
{
|
{
|
||||||
public static Type TKeyboard => m_tKeyboard ?? (m_tKeyboard = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
|
public static Type TKeyboard => m_tKeyboard ?? (m_tKeyboard = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
|
||||||
private static Type m_tKeyboard;
|
private static Type m_tKeyboard;
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using ExplorerBeta.Helpers;
|
using ExplorerBeta.Helpers;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ExplorerBeta.Input
|
namespace ExplorerBeta.Input
|
||||||
{
|
{
|
||||||
public class LegacyInput : IAbstractInput
|
public class LegacyInput : IHandleInput
|
||||||
{
|
{
|
||||||
public static Type TInput => m_tInput ?? (m_tInput = ReflectionHelpers.GetTypeByName("UnityEngine.Input"));
|
public static Type TInput => m_tInput ?? (m_tInput = ReflectionHelpers.GetTypeByName("UnityEngine.Input"));
|
||||||
private static Type m_tInput;
|
private static Type m_tInput;
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
using System;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace ExplorerBeta.Input
|
namespace ExplorerBeta.Input
|
||||||
{
|
{
|
||||||
// Just a stub for games where no Input module was able to load at all.
|
// Just a stub for games where no Input module was able to load at all.
|
||||||
|
|
||||||
public class NoInput : IAbstractInput
|
public class NoInput : IHandleInput
|
||||||
{
|
{
|
||||||
public Vector2 MousePosition => Vector2.zero;
|
public Vector2 MousePosition => Vector2.zero;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using ExplorerBeta;
|
using ExplorerBeta;
|
||||||
|
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using ExplorerBeta.UI.Shared;
|
|
||||||
using ExplorerBeta.UI;
|
using ExplorerBeta.UI;
|
||||||
|
using UnityEngine;
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnhollowerBaseLib;
|
|
||||||
using UnityEngine.SceneManagement;
|
|
||||||
using ExplorerBeta.Unstrip.ImageConversion;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ExplorerBeta.Tests
|
namespace ExplorerBeta.Tests
|
||||||
@ -57,10 +50,10 @@ namespace ExplorerBeta.Tests
|
|||||||
#if CPP
|
#if CPP
|
||||||
TestTexture.name = "TestTexture";
|
TestTexture.name = "TestTexture";
|
||||||
|
|
||||||
var r = new Rect(0, 0, TestTexture.width, TestTexture.height);
|
//var r = new Rect(0, 0, TestTexture.width, TestTexture.height);
|
||||||
var v2 = Vector2.zero;
|
//var v2 = Vector2.zero;
|
||||||
var v4 = Vector4.zero;
|
//var v4 = Vector4.zero;
|
||||||
TestSprite = Sprite.CreateSprite_Injected(TestTexture, ref r, ref v2, 100f, 0u, SpriteMeshType.Tight, ref v4, false);
|
//TestSprite = Sprite.CreateSprite_Injected(TestTexture, ref r, ref v2, 100f, 0u, SpriteMeshType.Tight, ref v4, false);
|
||||||
|
|
||||||
GameObject.DontDestroyOnLoad(TestTexture);
|
GameObject.DontDestroyOnLoad(TestTexture);
|
||||||
GameObject.DontDestroyOnLoad(TestSprite);
|
GameObject.DontDestroyOnLoad(TestSprite);
|
@ -2,7 +2,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using ExplorerBeta.Helpers;
|
using ExplorerBeta.Helpers;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using ExplorerBeta.UI;
|
|
||||||
using ExplorerBeta.Input;
|
using ExplorerBeta.Input;
|
||||||
using BF = System.Reflection.BindingFlags;
|
using BF = System.Reflection.BindingFlags;
|
||||||
#if ML
|
#if ML
|
||||||
@ -83,7 +82,7 @@ namespace ExplorerBeta.UI
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var harmony =
|
HarmonyInstance harmony =
|
||||||
#if ML
|
#if ML
|
||||||
ExplorerMelonMod.Instance.harmonyInstance;
|
ExplorerMelonMod.Instance.harmonyInstance;
|
||||||
#else
|
#else
|
||||||
@ -91,7 +90,7 @@ namespace ExplorerBeta.UI
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
var prop = type.GetProperty(property);
|
System.Reflection.PropertyInfo prop = type.GetProperty(property);
|
||||||
|
|
||||||
if (setter)
|
if (setter)
|
||||||
{
|
{
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
//using System.Linq;
|
//using System.Linq;
|
||||||
//using System.Reflection;
|
//using System.Reflection;
|
||||||
//using UnityEngine;
|
//using UnityEngine;
|
||||||
//using Explorer.CacheObject;
|
//using ExplorerBeta.CacheObject;
|
||||||
//using Explorer.Helpers;
|
//using ExplorerBeta.Helpers;
|
||||||
//using Explorer.UI.Shared;
|
//using ExplorerBeta.UI.Shared;
|
||||||
|
|
||||||
//namespace Explorer.UI
|
//namespace ExplorerBeta.UI
|
||||||
//{
|
//{
|
||||||
// public class InteractiveValue
|
// public class InteractiveValue
|
||||||
// {
|
// {
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ExplorerBeta;
|
|
||||||
using ExplorerBeta.Input;
|
|
||||||
using ExplorerBeta.UI;
|
|
||||||
using ExplorerBeta.UI.Main;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnhollowerRuntimeLib;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console
|
namespace ExplorerBeta.UI.Main.Console
|
||||||
{
|
{
|
||||||
public class AutoCompleter
|
public class AutoCompleter
|
||||||
{
|
{
|
||||||
@ -31,7 +24,7 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
private static readonly List<Text> m_hiddenSuggestionTexts = new List<Text>();
|
private static readonly List<Text> m_hiddenSuggestionTexts = new List<Text>();
|
||||||
|
|
||||||
private static bool m_suggestionsDirty;
|
private static bool m_suggestionsDirty;
|
||||||
private static AutoComplete[] m_suggestions = new AutoComplete[0];
|
private static Suggestion[] m_suggestions = new Suggestion[0];
|
||||||
private static int m_lastBatchIndex;
|
private static int m_lastBatchIndex;
|
||||||
|
|
||||||
private static string m_prevInput = "NULL";
|
private static string m_prevInput = "NULL";
|
||||||
@ -47,12 +40,16 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
public static void Update()
|
public static void Update()
|
||||||
{
|
{
|
||||||
if (!m_mainObj)
|
if (!m_mainObj)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ConsolePage.EnableSuggestions)
|
if (!ConsolePage.EnableSuggestions)
|
||||||
{
|
{
|
||||||
if (m_mainObj.activeSelf)
|
if (m_mainObj.activeSelf)
|
||||||
|
{
|
||||||
m_mainObj.SetActive(false);
|
m_mainObj.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -62,7 +59,7 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetSuggestions(AutoComplete[] suggestions)
|
public static void SetSuggestions(Suggestion[] suggestions)
|
||||||
{
|
{
|
||||||
m_suggestions = suggestions;
|
m_suggestions = suggestions;
|
||||||
|
|
||||||
@ -73,12 +70,16 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
private static void RefreshButtons()
|
private static void RefreshButtons()
|
||||||
{
|
{
|
||||||
if (!m_suggestionsDirty)
|
if (!m_suggestionsDirty)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_suggestions.Length < 1)
|
if (m_suggestions.Length < 1)
|
||||||
{
|
{
|
||||||
if (m_mainObj.activeSelf)
|
if (m_mainObj.activeSelf)
|
||||||
|
{
|
||||||
m_mainObj?.SetActive(false);
|
m_mainObj?.SetActive(false);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,12 +100,16 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
if (i >= m_suggestions.Length)
|
if (i >= m_suggestions.Length)
|
||||||
{
|
{
|
||||||
if (m_suggestionButtons[i].activeSelf)
|
if (m_suggestionButtons[i].activeSelf)
|
||||||
|
{
|
||||||
m_suggestionButtons[i].SetActive(false);
|
m_suggestionButtons[i].SetActive(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!m_suggestionButtons[i].activeSelf)
|
if (!m_suggestionButtons[i].activeSelf)
|
||||||
|
{
|
||||||
m_suggestionButtons[i].SetActive(true);
|
m_suggestionButtons[i].SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
var suggestion = m_suggestions[i];
|
var suggestion = m_suggestions[i];
|
||||||
var label = m_suggestionTexts[i];
|
var label = m_suggestionTexts[i];
|
||||||
@ -113,14 +118,7 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
label.text = suggestion.Full;
|
label.text = suggestion.Full;
|
||||||
hiddenLabel.text = suggestion.Addition;
|
hiddenLabel.text = suggestion.Addition;
|
||||||
|
|
||||||
if (suggestion.Context == AutoComplete.Contexts.Namespace)
|
label.color = suggestion.TextColor;
|
||||||
{
|
|
||||||
label.color = new Color(0.75f, 0.75f, 0.75f, 1.0f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
label.color = Color.white;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastBatchIndex = i;
|
m_lastBatchIndex = i;
|
||||||
@ -134,14 +132,20 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
var editor = ConsolePage.Instance.m_codeEditor;
|
var editor = ConsolePage.Instance.m_codeEditor;
|
||||||
|
|
||||||
if (editor.InputField.text.Length < 1)
|
if (editor.InputField.text.Length < 1)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var caretPos = editor.InputField.caretPosition;
|
int caretPos = editor.InputField.caretPosition;
|
||||||
while (caretPos >= editor.inputText.textInfo.characterInfo.Length)
|
while (caretPos >= editor.inputText.textInfo.characterInfo.Length)
|
||||||
|
{
|
||||||
caretPos--;
|
caretPos--;
|
||||||
|
}
|
||||||
|
|
||||||
if (caretPos == m_lastCaretPos)
|
if (caretPos == m_lastCaretPos)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_lastCaretPos = caretPos;
|
m_lastCaretPos = caretPos;
|
||||||
|
|
||||||
@ -149,9 +153,9 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
{
|
{
|
||||||
var pos = editor.inputText.textInfo.characterInfo[caretPos].bottomLeft;
|
var pos = editor.inputText.textInfo.characterInfo[caretPos].bottomLeft;
|
||||||
|
|
||||||
pos = MainMenu.Instance.MainPanel.transform.TransformPoint(pos);
|
pos = editor.InputField.transform.TransformPoint(pos);
|
||||||
|
|
||||||
m_mainObj.transform.position = new Vector3(pos.x + m_thisRect.rect.width / 2, pos.y - 12, 0);
|
m_mainObj.transform.position = new Vector3(pos.x, pos.y - 3, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,14 +164,14 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
public static void CheckAutocomplete()
|
public static void CheckAutocomplete()
|
||||||
{
|
{
|
||||||
var m_codeEditor = ConsolePage.Instance.m_codeEditor;
|
var m_codeEditor = ConsolePage.Instance.m_codeEditor;
|
||||||
var input = m_codeEditor.InputField.text;
|
string input = m_codeEditor.InputField.text;
|
||||||
var caretIndex = m_codeEditor.InputField.caretPosition;
|
int caretIndex = m_codeEditor.InputField.caretPosition;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(input))
|
if (!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var start = caretIndex <= 0 ? 0 : input.LastIndexOfAny(splitChars, caretIndex - 1) + 1;
|
int start = caretIndex <= 0 ? 0 : input.LastIndexOfAny(splitChars, caretIndex - 1) + 1;
|
||||||
input = input.Substring(start, caretIndex - start).Trim();
|
input = input.Substring(start, caretIndex - start).Trim();
|
||||||
}
|
}
|
||||||
catch (ArgumentException) { }
|
catch (ArgumentException) { }
|
||||||
@ -199,39 +203,52 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
{
|
{
|
||||||
// Credit ManylMarco
|
// Credit ManylMarco
|
||||||
ConsolePage.AutoCompletes.Clear();
|
ConsolePage.AutoCompletes.Clear();
|
||||||
var completions = ConsolePage.Instance.m_evaluator.GetCompletions(input, out string prefix);
|
string[] completions = ConsolePage.Instance.m_evaluator.GetCompletions(input, out string prefix);
|
||||||
if (completions != null)
|
if (completions != null)
|
||||||
{
|
{
|
||||||
if (prefix == null)
|
if (prefix == null)
|
||||||
|
{
|
||||||
prefix = input;
|
prefix = input;
|
||||||
|
}
|
||||||
|
|
||||||
ConsolePage.AutoCompletes.AddRange(completions
|
ConsolePage.AutoCompletes.AddRange(completions
|
||||||
.Where(x => !string.IsNullOrEmpty(x))
|
.Where(x => !string.IsNullOrEmpty(x))
|
||||||
.Select(x => new AutoComplete(x, prefix, AutoComplete.Contexts.Other))
|
.Select(x => new Suggestion(x, prefix, Suggestion.Contexts.Other))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var trimmed = input.Trim();
|
string trimmed = input.Trim();
|
||||||
if (trimmed.StartsWith("using"))
|
if (trimmed.StartsWith("using"))
|
||||||
|
{
|
||||||
trimmed = trimmed.Remove(0, 5).Trim();
|
trimmed = trimmed.Remove(0, 5).Trim();
|
||||||
|
}
|
||||||
|
|
||||||
var namespaces = AutoCompleteHelpers.Namespaces
|
IEnumerable<Suggestion> namespaces = Suggestion.Namespaces
|
||||||
.Where(x => x.StartsWith(trimmed) && x.Length > trimmed.Length)
|
.Where(x => x.StartsWith(trimmed) && x.Length > trimmed.Length)
|
||||||
.Select(x => new AutoComplete(
|
.Select(x => new Suggestion(
|
||||||
x.Substring(trimmed.Length),
|
x.Substring(trimmed.Length),
|
||||||
x.Substring(0, trimmed.Length),
|
x.Substring(0, trimmed.Length),
|
||||||
AutoComplete.Contexts.Namespace));
|
Suggestion.Contexts.Namespace));
|
||||||
|
|
||||||
ConsolePage.AutoCompletes.AddRange(namespaces);
|
ConsolePage.AutoCompletes.AddRange(namespaces);
|
||||||
|
|
||||||
|
IEnumerable<Suggestion> keywords = Suggestion.Keywords
|
||||||
|
.Where(x => x.StartsWith(trimmed) && x.Length > trimmed.Length)
|
||||||
|
.Select(x => new Suggestion(
|
||||||
|
x.Substring(trimmed.Length),
|
||||||
|
x.Substring(0, trimmed.Length),
|
||||||
|
Suggestion.Contexts.Keyword));
|
||||||
|
|
||||||
|
ConsolePage.AutoCompletes.AddRange(keywords);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ExplorerCore.Log("C# Console error:\r\n" + ex);
|
ExplorerCore.Log("Autocomplete error:\r\n" + ex.ToString());
|
||||||
ClearAutocompletes();
|
ClearAutocompletes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region UI Construction
|
#region UI Construction
|
||||||
|
|
||||||
private static void ConstructUI()
|
private static void ConstructUI()
|
||||||
{
|
{
|
||||||
@ -243,7 +260,7 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
|
|
||||||
var mainRect = obj.GetComponent<RectTransform>();
|
var mainRect = obj.GetComponent<RectTransform>();
|
||||||
m_thisRect = mainRect;
|
m_thisRect = mainRect;
|
||||||
mainRect.pivot = new Vector2(0.5f, 0.5f);
|
mainRect.pivot = new Vector2(0f, 1f);
|
||||||
mainRect.anchorMin = new Vector2(0.45f, 0.45f);
|
mainRect.anchorMin = new Vector2(0.45f, 0.45f);
|
||||||
mainRect.anchorMax = new Vector2(0.65f, 0.6f);
|
mainRect.anchorMax = new Vector2(0.65f, 0.6f);
|
||||||
mainRect.offsetMin = Vector2.zero;
|
mainRect.offsetMin = Vector2.zero;
|
||||||
@ -258,10 +275,10 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
for (int i = 0; i < MAX_LABELS; i++)
|
for (int i = 0; i < MAX_LABELS; i++)
|
||||||
{
|
{
|
||||||
var buttonObj = UIFactory.CreateButton(content);
|
var buttonObj = UIFactory.CreateButton(content);
|
||||||
var btn = buttonObj.GetComponent<Button>();
|
Button btn = buttonObj.GetComponent<Button>();
|
||||||
var btnColors = btn.colors;
|
ColorBlock btnColors = btn.colors;
|
||||||
btnColors.normalColor = new Color(0f, 0f, 0f, 0f);
|
btnColors.normalColor = new Color(0f, 0f, 0f, 0f);
|
||||||
btnColors.highlightedColor = new Color(0.5f, 0.5f, 0.5f, 1.0f);
|
btnColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1.0f);
|
||||||
btn.colors = btnColors;
|
btn.colors = btnColors;
|
||||||
|
|
||||||
var nav = btn.navigation;
|
var nav = btn.navigation;
|
||||||
@ -298,6 +315,6 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,9 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using ExplorerBeta.UI.Main.Console.Lexer;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Explorer.UI.Main.Pages.Console.Lexer;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console
|
namespace ExplorerBeta.UI.Main.Console
|
||||||
{
|
{
|
||||||
public static class CSharpLexer
|
public static class CSharpLexer
|
||||||
{
|
{
|
||||||
@ -29,7 +27,7 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
else equals false finally float for foreach from global goto group
|
else equals false finally float for foreach from global goto group
|
||||||
if in int into is join let lock long new null object on orderby out
|
if in int into is join let lock long new null object on orderby out
|
||||||
ref remove return sbyte select short sizeof stackalloc string
|
ref remove return sbyte select short sizeof stackalloc string
|
||||||
struct switch throw true try typeof uint ulong ushort
|
switch throw true try typeof uint ulong ushort
|
||||||
value var where while yield"
|
value var where while yield"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -38,7 +36,7 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
highlightColor = new Color(0.95f, 0.10f, 0.10f, 1.0f),
|
highlightColor = new Color(0.95f, 0.10f, 0.10f, 1.0f),
|
||||||
keywords = @"abstract async base class delegate enum explicit extern fixed get
|
keywords = @"abstract async base class delegate enum explicit extern fixed get
|
||||||
implicit interface internal namespace operator override params private protected public
|
implicit interface internal namespace operator override params private protected public
|
||||||
using partial readonly sealed set static this unchecked unsafe virtual volatile void"
|
using partial readonly sealed set static struct this unchecked unsafe virtual volatile void"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static char[] delimiterSymbolCache = null;
|
private static char[] delimiterSymbolCache = null;
|
||||||
@ -53,8 +51,12 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < symbols.Length; i++)
|
for (int i = 0; i < symbols.Length; i++)
|
||||||
|
{
|
||||||
if (symbols[i].Length == 1)
|
if (symbols[i].Length == 1)
|
||||||
|
{
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delimiterSymbolCache = new char[count];
|
delimiterSymbolCache = new char[count];
|
||||||
|
|
||||||
@ -113,7 +115,9 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
{
|
{
|
||||||
indentBuilder.Append('\n');
|
indentBuilder.Append('\n');
|
||||||
for (int j = 0; j < indent; j++)
|
for (int j = 0; j < indent; j++)
|
||||||
|
{
|
||||||
indentBuilder.Append("\t");
|
indentBuilder.Append("\t");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (input[i] == '\t')
|
else if (input[i] == '\t')
|
||||||
{
|
{
|
||||||
@ -142,7 +146,9 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
for (int i = formattedSection.Length - 1; i >= 0; i--)
|
for (int i = formattedSection.Length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (formattedSection[i] == '\n')
|
if (formattedSection[i] == '\n')
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
caretPosition = i;
|
caretPosition = i;
|
||||||
break;
|
break;
|
||||||
@ -158,11 +164,15 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
for (int i = startIndex; i < endIndex; i++)
|
for (int i = startIndex; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
if (inputString[i] == '\t')
|
if (inputString[i] == '\t')
|
||||||
|
{
|
||||||
indent++;
|
indent++;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for end line or other characters
|
// Check for end line or other characters
|
||||||
if (inputString[i] == '\n' || inputString[i] != ' ')
|
if (inputString[i] == '\n' || inputString[i] != ' ')
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return indent;
|
return indent;
|
@ -1,16 +1,14 @@
|
|||||||
using UnityEngine;
|
using System;
|
||||||
using UnityEngine.UI;
|
|
||||||
using TMPro;
|
|
||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using System.Reflection;
|
|
||||||
using ExplorerBeta.Input;
|
|
||||||
using Explorer.UI.Main.Pages.Console.Lexer;
|
|
||||||
using ExplorerBeta;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using ExplorerBeta.Input;
|
||||||
|
using ExplorerBeta.UI.Main.Console.Lexer;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console
|
namespace ExplorerBeta.UI.Main.Console
|
||||||
{
|
{
|
||||||
public class CodeEditor
|
public class CodeEditor
|
||||||
{
|
{
|
||||||
@ -69,7 +67,7 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
public CodeEditor(TMP_InputField inputField, TextMeshProUGUI inputText, TextMeshProUGUI inputHighlightText, TextMeshProUGUI lineText,
|
public CodeEditor(TMP_InputField inputField, TextMeshProUGUI inputText, TextMeshProUGUI inputHighlightText, TextMeshProUGUI lineText,
|
||||||
Image background, Image lineHighlight, Image lineNumberBackground, Image scrollbar)
|
Image background, Image lineHighlight, Image lineNumberBackground, Image scrollbar)
|
||||||
{
|
{
|
||||||
this.InputField = inputField;
|
InputField = inputField;
|
||||||
this.inputText = inputText;
|
this.inputText = inputText;
|
||||||
this.inputHighlightText = inputHighlightText;
|
this.inputHighlightText = inputHighlightText;
|
||||||
this.lineText = lineText;
|
this.lineText = lineText;
|
||||||
@ -83,15 +81,15 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
throw new Exception("References are missing!");
|
throw new Exception("References are missing!");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inputTextTransform = inputText.GetComponent<RectTransform>();
|
inputTextTransform = inputText.GetComponent<RectTransform>();
|
||||||
this.lineHighlightTransform = lineHighlight.GetComponent<RectTransform>();
|
lineHighlightTransform = lineHighlight.GetComponent<RectTransform>();
|
||||||
|
|
||||||
ApplyTheme();
|
ApplyTheme();
|
||||||
inputLexer.UseMatchers(CSharpLexer.DelimiterSymbols, CSharpLexer.Matchers);
|
inputLexer.UseMatchers(CSharpLexer.DelimiterSymbols, CSharpLexer.Matchers);
|
||||||
|
|
||||||
// subscribe to text input changing
|
// subscribe to text input changing
|
||||||
#if CPP
|
#if CPP
|
||||||
this.InputField.onValueChanged.AddListener(new Action<string>((string s) => { OnInputChanged(); }));
|
InputField.onValueChanged.AddListener(new Action<string>((string s) => { OnInputChanged(); }));
|
||||||
#else
|
#else
|
||||||
this.InputField.onValueChanged.AddListener((string s) => { OnInputChanged(); });
|
this.InputField.onValueChanged.AddListener((string s) => { OnInputChanged(); });
|
||||||
#endif
|
#endif
|
||||||
@ -130,7 +128,7 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
|
|
||||||
public void OnInputChanged(bool forceUpdate = false)
|
public void OnInputChanged(bool forceUpdate = false)
|
||||||
{
|
{
|
||||||
var newText = InputField.text;
|
string newText = InputField.text;
|
||||||
|
|
||||||
UpdateIndent();
|
UpdateIndent();
|
||||||
|
|
||||||
@ -152,11 +150,13 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
public void SetLineHighlight(int lineNumber, bool lockLineHighlight)
|
public void SetLineHighlight(int lineNumber, bool lockLineHighlight)
|
||||||
{
|
{
|
||||||
if (lineNumber < 1 || lineNumber > LineCount)
|
if (lineNumber < 1 || lineNumber > LineCount)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lineHighlightTransform.anchoredPosition = new Vector2(5,
|
lineHighlightTransform.anchoredPosition = new Vector2(5,
|
||||||
(inputText.textInfo.lineInfo[inputText.textInfo.characterInfo[0].lineNumber].lineHeight *
|
(inputText.textInfo.lineInfo[inputText.textInfo.characterInfo[0].lineNumber].lineHeight *
|
||||||
-(lineNumber - 1)) - 4f +
|
-(lineNumber - 1)) - 4f +
|
||||||
inputTextTransform.anchoredPosition.y);
|
inputTextTransform.anchoredPosition.y);
|
||||||
|
|
||||||
lineHighlightLocked = lockLineHighlight;
|
lineHighlightLocked = lockLineHighlight;
|
||||||
@ -222,7 +222,9 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
if (caret < 0 || caret >= inputText.textInfo.characterInfo.Length)
|
if (caret < 0 || caret >= inputText.textInfo.characterInfo.Length)
|
||||||
{
|
{
|
||||||
while (caret >= 0 && caret >= inputText.textInfo.characterInfo.Length)
|
while (caret >= 0 && caret >= inputText.textInfo.characterInfo.Length)
|
||||||
|
{
|
||||||
caret--;
|
caret--;
|
||||||
|
}
|
||||||
|
|
||||||
if (caret < 0 || caret >= inputText.textInfo.characterInfo.Length)
|
if (caret < 0 || caret >= inputText.textInfo.characterInfo.Length)
|
||||||
{
|
{
|
||||||
@ -234,7 +236,9 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
|
|
||||||
int charCount = 0;
|
int charCount = 0;
|
||||||
for (int i = 0; i < CurrentLine; i++)
|
for (int i = 0; i < CurrentLine; i++)
|
||||||
|
{
|
||||||
charCount += inputText.textInfo.lineInfo[i].characterCount;
|
charCount += inputText.textInfo.lineInfo[i].characterCount;
|
||||||
|
}
|
||||||
|
|
||||||
CurrentColumn = caret - charCount;
|
CurrentColumn = caret - charCount;
|
||||||
CurrentIndent = 0;
|
CurrentIndent = 0;
|
||||||
@ -244,28 +248,36 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
char character = InputField.text[i];
|
char character = InputField.text[i];
|
||||||
|
|
||||||
if (character == CSharpLexer.indentIncreaseCharacter)
|
if (character == CSharpLexer.indentIncreaseCharacter)
|
||||||
|
{
|
||||||
CurrentIndent++;
|
CurrentIndent++;
|
||||||
|
}
|
||||||
|
|
||||||
if (character == CSharpLexer.indentDecreaseCharacter)
|
if (character == CSharpLexer.indentDecreaseCharacter)
|
||||||
|
{
|
||||||
CurrentIndent--;
|
CurrentIndent--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentIndent < 0)
|
if (CurrentIndent < 0)
|
||||||
|
{
|
||||||
CurrentIndent = 0;
|
CurrentIndent = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateHighlight()
|
private void UpdateHighlight()
|
||||||
{
|
{
|
||||||
if (lineHighlightLocked)
|
if (lineHighlightLocked)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int caret = InputField.caretPosition - 1;
|
int caret = InputField.caretPosition - 1;
|
||||||
|
|
||||||
var lineHeight = inputText.textInfo.lineInfo[inputText.textInfo.characterInfo[0].lineNumber].lineHeight;
|
float lineHeight = inputText.textInfo.lineInfo[inputText.textInfo.characterInfo[0].lineNumber].lineHeight;
|
||||||
var lineNumber = inputText.textInfo.characterInfo[caret].lineNumber;
|
int lineNumber = inputText.textInfo.characterInfo[caret].lineNumber;
|
||||||
var offset = lineNumber + inputTextTransform.anchoredPosition.y;
|
float offset = lineNumber + inputTextTransform.anchoredPosition.y;
|
||||||
|
|
||||||
lineHighlightTransform.anchoredPosition = new Vector2(5, -(offset * lineHeight));
|
lineHighlightTransform.anchoredPosition = new Vector2(5, -(offset * lineHeight));
|
||||||
}
|
}
|
||||||
@ -283,15 +295,19 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
|
|
||||||
highlightedBuilder.Length = 0;
|
highlightedBuilder.Length = 0;
|
||||||
|
|
||||||
foreach (var match in inputLexer.LexInputString(inputText))
|
foreach (LexerMatchInfo match in inputLexer.LexInputString(inputText))
|
||||||
{
|
{
|
||||||
for (int i = offset; i < match.startIndex; i++)
|
for (int i = offset; i < match.startIndex; i++)
|
||||||
|
{
|
||||||
highlightedBuilder.Append(inputText[i]);
|
highlightedBuilder.Append(inputText[i]);
|
||||||
|
}
|
||||||
|
|
||||||
highlightedBuilder.Append(match.htmlColor);
|
highlightedBuilder.Append(match.htmlColor);
|
||||||
|
|
||||||
for (int i = match.startIndex; i < match.endIndex; i++)
|
for (int i = match.startIndex; i < match.endIndex; i++)
|
||||||
|
{
|
||||||
highlightedBuilder.Append(inputText[i]);
|
highlightedBuilder.Append(inputText[i]);
|
||||||
|
}
|
||||||
|
|
||||||
highlightedBuilder.Append(CLOSE_COLOR_TAG);
|
highlightedBuilder.Append(CLOSE_COLOR_TAG);
|
||||||
|
|
||||||
@ -299,7 +315,9 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = offset; i < inputText.Length; i++)
|
for (int i = offset; i < inputText.Length; i++)
|
||||||
|
{
|
||||||
highlightedBuilder.Append(inputText[i]);
|
highlightedBuilder.Append(inputText[i]);
|
||||||
|
}
|
||||||
|
|
||||||
inputText = highlightedBuilder.ToString();
|
inputText = highlightedBuilder.ToString();
|
||||||
|
|
||||||
@ -310,23 +328,23 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
{
|
{
|
||||||
if (CurrentIndent > 0)
|
if (CurrentIndent > 0)
|
||||||
{
|
{
|
||||||
var indent = GetAutoIndentTab(CurrentIndent);
|
string indent = GetAutoIndentTab(CurrentIndent);
|
||||||
|
|
||||||
if (indent.Length > 0)
|
if (indent.Length > 0)
|
||||||
{
|
{
|
||||||
var caretPos = InputField.caretPosition;
|
int caretPos = InputField.caretPosition;
|
||||||
|
|
||||||
var indentMinusOne = indent.Substring(0, indent.Length - 1);
|
string indentMinusOne = indent.Substring(0, indent.Length - 1);
|
||||||
|
|
||||||
// get last index of {
|
// get last index of {
|
||||||
// chuck it on the next line if its not already
|
// chuck it on the next line if its not already
|
||||||
var text = InputField.text;
|
string text = InputField.text;
|
||||||
var sub = InputField.text.Substring(0, InputField.caretPosition);
|
string sub = InputField.text.Substring(0, InputField.caretPosition);
|
||||||
var lastIndex = sub.LastIndexOf("{");
|
int lastIndex = sub.LastIndexOf("{");
|
||||||
var offset = lastIndex - 1;
|
int offset = lastIndex - 1;
|
||||||
if (offset >= 0 && text[offset] != '\n' && text[offset] != '\t')
|
if (offset >= 0 && text[offset] != '\n' && text[offset] != '\t')
|
||||||
{
|
{
|
||||||
var open = "\n" + indentMinusOne;
|
string open = "\n" + indentMinusOne;
|
||||||
|
|
||||||
InputField.text = text.Insert(offset + 1, open);
|
InputField.text = text.Insert(offset + 1, open);
|
||||||
|
|
||||||
@ -368,7 +386,9 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
string tab = string.Empty;
|
string tab = string.Empty;
|
||||||
|
|
||||||
for (int i = 0; i < amount; i++)
|
for (int i = 0; i < amount; i++)
|
||||||
|
{
|
||||||
tab += "\t";
|
tab += "\t";
|
||||||
|
}
|
||||||
|
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Explorer.Unstrip.ColorUtility;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console.Lexer
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||||
{
|
{
|
||||||
public sealed class CommentMatch : MatchLexer
|
public sealed class CommentMatch : MatchLexer
|
||||||
{
|
{
|
||||||
@ -35,7 +33,11 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
if (match)
|
if (match)
|
||||||
{
|
{
|
||||||
// Read until end
|
// Read until end
|
||||||
while (!IsEndLineOrEndFile(lexer, lexer.ReadNext())) ;
|
while (!IsEndLineOrEndFile(lexer, lexer.ReadNext()))
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console.Lexer
|
|
||||||
{
|
{
|
||||||
public enum SpecialCharacterPosition
|
public enum SpecialCharacterPosition
|
||||||
{
|
{
|
@ -1,10 +1,6 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console.Lexer
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||||
{
|
{
|
||||||
internal struct LexerMatchInfo
|
internal struct LexerMatchInfo
|
||||||
{
|
{
|
||||||
@ -42,10 +38,14 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
foreach (char character in delimiters)
|
foreach (char character in delimiters)
|
||||||
{
|
{
|
||||||
if (!specialStartSymbols.Contains(character))
|
if (!specialStartSymbols.Contains(character))
|
||||||
|
{
|
||||||
specialStartSymbols.Add(character);
|
specialStartSymbols.Add(character);
|
||||||
|
}
|
||||||
|
|
||||||
if (!specialEndSymbols.Contains(character))
|
if (!specialEndSymbols.Contains(character))
|
||||||
|
{
|
||||||
specialEndSymbols.Add(character);
|
specialEndSymbols.Add(character);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,12 +54,20 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
foreach (MatchLexer lexer in matchers)
|
foreach (MatchLexer lexer in matchers)
|
||||||
{
|
{
|
||||||
foreach (char special in lexer.StartChars)
|
foreach (char special in lexer.StartChars)
|
||||||
|
{
|
||||||
if (!specialStartSymbols.Contains(special))
|
if (!specialStartSymbols.Contains(special))
|
||||||
|
{
|
||||||
specialStartSymbols.Add(special);
|
specialStartSymbols.Add(special);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (char special in lexer.EndChars)
|
foreach (char special in lexer.EndChars)
|
||||||
|
{
|
||||||
if (!specialEndSymbols.Contains(special))
|
if (!specialEndSymbols.Contains(special))
|
||||||
|
{
|
||||||
specialEndSymbols.Add(special);
|
specialEndSymbols.Add(special);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,13 +75,15 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
public IEnumerable<LexerMatchInfo> LexInputString(string input)
|
public IEnumerable<LexerMatchInfo> LexInputString(string input)
|
||||||
{
|
{
|
||||||
if (input == null || matchers == null || matchers.Length == 0)
|
if (input == null || matchers == null || matchers.Length == 0)
|
||||||
|
{
|
||||||
yield break;
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
this.inputString = input;
|
inputString = input;
|
||||||
this.current = ' ';
|
current = ' ';
|
||||||
this.Previous = ' ';
|
Previous = ' ';
|
||||||
this.currentIndex = 0;
|
currentIndex = 0;
|
||||||
this.currentLookaheadIndex = 0;
|
currentLookaheadIndex = 0;
|
||||||
|
|
||||||
while (!EndOfStream)
|
while (!EndOfStream)
|
||||||
{
|
{
|
||||||
@ -115,7 +125,9 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
public char ReadNext()
|
public char ReadNext()
|
||||||
{
|
{
|
||||||
if (EndOfStream)
|
if (EndOfStream)
|
||||||
|
{
|
||||||
return '\0';
|
return '\0';
|
||||||
|
}
|
||||||
|
|
||||||
Previous = current;
|
Previous = current;
|
||||||
|
|
||||||
@ -134,17 +146,25 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (currentLookaheadIndex > currentIndex)
|
if (currentLookaheadIndex > currentIndex)
|
||||||
|
{
|
||||||
currentLookaheadIndex -= amount;
|
currentLookaheadIndex -= amount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int previousIndex = currentLookaheadIndex - 1;
|
int previousIndex = currentLookaheadIndex - 1;
|
||||||
|
|
||||||
if (previousIndex >= inputString.Length)
|
if (previousIndex >= inputString.Length)
|
||||||
|
{
|
||||||
Previous = inputString[inputString.Length - 1];
|
Previous = inputString[inputString.Length - 1];
|
||||||
|
}
|
||||||
else if (previousIndex >= 0)
|
else if (previousIndex >= 0)
|
||||||
|
{
|
||||||
Previous = inputString[previousIndex];
|
Previous = inputString[previousIndex];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Previous = ' ';
|
Previous = ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Commit()
|
public void Commit()
|
||||||
@ -155,7 +175,9 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
public bool IsSpecialSymbol(char character, SpecialCharacterPosition position = SpecialCharacterPosition.Start)
|
public bool IsSpecialSymbol(char character, SpecialCharacterPosition position = SpecialCharacterPosition.Start)
|
||||||
{
|
{
|
||||||
if (position == SpecialCharacterPosition.Start)
|
if (position == SpecialCharacterPosition.Start)
|
||||||
|
{
|
||||||
return specialStartSymbols.Contains(character);
|
return specialStartSymbols.Contains(character);
|
||||||
|
}
|
||||||
|
|
||||||
return specialEndSymbols.Contains(character);
|
return specialEndSymbols.Contains(character);
|
||||||
}
|
}
|
@ -1,19 +1,13 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Explorer.Unstrip.ColorUtility;
|
|
||||||
using ExplorerBeta;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console.Lexer
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||||
{
|
{
|
||||||
public sealed class KeywordMatch : MatchLexer
|
public sealed class KeywordMatch : MatchLexer
|
||||||
{
|
{
|
||||||
public string keywords;
|
public string keywords;
|
||||||
|
|
||||||
public override Color HighlightColor => this.highlightColor;
|
public override Color HighlightColor => highlightColor;
|
||||||
public Color highlightColor;
|
public Color highlightColor;
|
||||||
|
|
||||||
private readonly HashSet<string> shortlist = new HashSet<string>();
|
private readonly HashSet<string> shortlist = new HashSet<string>();
|
||||||
@ -26,7 +20,9 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
|
|
||||||
if (!char.IsWhiteSpace(lexer.Previous) &&
|
if (!char.IsWhiteSpace(lexer.Previous) &&
|
||||||
!lexer.IsSpecialSymbol(lexer.Previous, SpecialCharacterPosition.End))
|
!lexer.IsSpecialSymbol(lexer.Previous, SpecialCharacterPosition.End))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
shortlist.Clear();
|
shortlist.Clear();
|
||||||
|
|
||||||
@ -34,11 +30,17 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
char currentChar = lexer.ReadNext();
|
char currentChar = lexer.ReadNext();
|
||||||
|
|
||||||
for (int i = 0; i < keywordCache.Length; i++)
|
for (int i = 0; i < keywordCache.Length; i++)
|
||||||
|
{
|
||||||
if (keywordCache[i][0] == currentChar)
|
if (keywordCache[i][0] == currentChar)
|
||||||
|
{
|
||||||
shortlist.Add(keywordCache[i]);
|
shortlist.Add(keywordCache[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (shortlist.Count == 0)
|
if (shortlist.Count == 0)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -68,7 +70,9 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (removeList.Count > 0)
|
while (removeList.Count > 0)
|
||||||
|
{
|
||||||
shortlist.Remove(removeList.Pop());
|
shortlist.Remove(removeList.Pop());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (shortlist.Count > 0);
|
while (shortlist.Count > 0);
|
||||||
|
|
||||||
@ -78,21 +82,27 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
private void RemoveLongStrings(int length)
|
private void RemoveLongStrings(int length)
|
||||||
{
|
{
|
||||||
foreach (string keyword in shortlist)
|
foreach (string keyword in shortlist)
|
||||||
|
{
|
||||||
if (keyword.Length > length)
|
if (keyword.Length > length)
|
||||||
|
{
|
||||||
removeList.Push(keyword);
|
removeList.Push(keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (removeList.Count > 0)
|
while (removeList.Count > 0)
|
||||||
|
{
|
||||||
shortlist.Remove(removeList.Pop());
|
shortlist.Remove(removeList.Pop());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildKeywordCache()
|
private void BuildKeywordCache()
|
||||||
{
|
{
|
||||||
if (keywordCache == null)
|
if (keywordCache == null)
|
||||||
{
|
{
|
||||||
var kwSplit = keywords.Split(' ');
|
string[] kwSplit = keywords.Split(' ');
|
||||||
|
|
||||||
var list = new List<string>();
|
List<string> list = new List<string>();
|
||||||
foreach (var kw in kwSplit)
|
foreach (string kw in kwSplit)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(kw) && kw.Length > 0)
|
if (!string.IsNullOrEmpty(kw) && kw.Length > 0)
|
||||||
{
|
{
|
@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
using ExplorerBeta.Unstrip.ColorUtility;
|
||||||
using Explorer.Unstrip.ColorUtility;
|
|
||||||
using ExplorerBeta;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console.Lexer
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||||
{
|
{
|
||||||
public abstract class MatchLexer
|
public abstract class MatchLexer
|
||||||
{
|
{
|
@ -1,11 +1,6 @@
|
|||||||
using System;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using Explorer.Unstrip.ColorUtility;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console.Lexer
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||||
{
|
{
|
||||||
public sealed class NumberMatch : MatchLexer
|
public sealed class NumberMatch : MatchLexer
|
||||||
{
|
{
|
@ -1,11 +1,7 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Explorer.Unstrip.ColorUtility;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console.Lexer
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||||
{
|
{
|
||||||
public sealed class StringMatch : MatchLexer
|
public sealed class StringMatch : MatchLexer
|
||||||
{
|
{
|
||||||
@ -18,7 +14,11 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
{
|
{
|
||||||
if (lexer.ReadNext() == '"')
|
if (lexer.ReadNext() == '"')
|
||||||
{
|
{
|
||||||
while (!IsClosingQuoteOrEndFile(lexer, lexer.ReadNext())) ;
|
while (!IsClosingQuoteOrEndFile(lexer, lexer.ReadNext()))
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
@ -1,12 +1,8 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using Explorer.Unstrip.ColorUtility;
|
|
||||||
using ExplorerBeta;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console.Lexer
|
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||||
{
|
{
|
||||||
public sealed class SymbolMatch : MatchLexer
|
public sealed class SymbolMatch : MatchLexer
|
||||||
{
|
{
|
||||||
@ -25,7 +21,9 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
{
|
{
|
||||||
BuildSymbolCache();
|
BuildSymbolCache();
|
||||||
foreach (string symbol in symbolCache.Where(x => x.Length > 0))
|
foreach (string symbol in symbolCache.Where(x => x.Length > 0))
|
||||||
|
{
|
||||||
yield return symbol[0];
|
yield return symbol[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,14 +33,18 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
{
|
{
|
||||||
BuildSymbolCache();
|
BuildSymbolCache();
|
||||||
foreach (string symbol in symbolCache.Where(x => x.Length > 0))
|
foreach (string symbol in symbolCache.Where(x => x.Length > 0))
|
||||||
|
{
|
||||||
yield return symbol[0];
|
yield return symbol[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsImplicitMatch(ILexer lexer)
|
public override bool IsImplicitMatch(ILexer lexer)
|
||||||
{
|
{
|
||||||
if (lexer == null)
|
if (lexer == null)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
BuildSymbolCache();
|
BuildSymbolCache();
|
||||||
|
|
||||||
@ -50,7 +52,9 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
!char.IsLetter(lexer.Previous) &&
|
!char.IsLetter(lexer.Previous) &&
|
||||||
!char.IsDigit(lexer.Previous) &&
|
!char.IsDigit(lexer.Previous) &&
|
||||||
!lexer.IsSpecialSymbol(lexer.Previous, SpecialCharacterPosition.End))
|
!lexer.IsSpecialSymbol(lexer.Previous, SpecialCharacterPosition.End))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
shortlist.Clear();
|
shortlist.Clear();
|
||||||
|
|
||||||
@ -60,11 +64,15 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
for (int i = symbolCache.Length - 1; i >= 0; i--)
|
for (int i = symbolCache.Length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (symbolCache[i][0] == currentChar)
|
if (symbolCache[i][0] == currentChar)
|
||||||
|
{
|
||||||
shortlist.Add(symbolCache[i]);
|
shortlist.Add(symbolCache[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shortlist.Count == 0)
|
if (shortlist.Count == 0)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -96,7 +104,9 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (removeList.Count > 0)
|
while (removeList.Count > 0)
|
||||||
|
{
|
||||||
shortlist.Remove(removeList.Pop());
|
shortlist.Remove(removeList.Pop());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (shortlist.Count > 0);
|
while (shortlist.Count > 0);
|
||||||
|
|
||||||
@ -114,17 +124,21 @@ namespace Explorer.UI.Main.Pages.Console.Lexer
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (removeList.Count > 0)
|
while (removeList.Count > 0)
|
||||||
|
{
|
||||||
shortlist.Remove(removeList.Pop());
|
shortlist.Remove(removeList.Pop());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildSymbolCache()
|
private void BuildSymbolCache()
|
||||||
{
|
{
|
||||||
if (symbolCache != null)
|
if (symbolCache != null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var symSplit = Symbols.Split(' ');
|
string[] symSplit = Symbols.Split(' ');
|
||||||
var list = new List<string>();
|
List<string> list = new List<string>();
|
||||||
foreach (var sym in symSplit)
|
foreach (string sym in symSplit)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(sym) && sym.Length > 0)
|
if (!string.IsNullOrEmpty(sym) && sym.Length > 0)
|
||||||
{
|
{
|
@ -6,7 +6,7 @@ using Mono.CSharp;
|
|||||||
|
|
||||||
// Thanks to ManlyMarco for this
|
// Thanks to ManlyMarco for this
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console
|
namespace ExplorerBeta.UI.Main.Console
|
||||||
{
|
{
|
||||||
public class ScriptEvaluator : Evaluator, IDisposable
|
public class ScriptEvaluator : Evaluator, IDisposable
|
||||||
{
|
{
|
||||||
@ -35,7 +35,10 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
{
|
{
|
||||||
string name = args.LoadedAssembly.GetName().Name;
|
string name = args.LoadedAssembly.GetName().Name;
|
||||||
if (StdLib.Contains(name))
|
if (StdLib.Contains(name))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ReferenceAssembly(args.LoadedAssembly);
|
ReferenceAssembly(args.LoadedAssembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,11 +61,14 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
|
|
||||||
private static void ImportAppdomainAssemblies(Action<Assembly> import)
|
private static void ImportAppdomainAssemblies(Action<Assembly> import)
|
||||||
{
|
{
|
||||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
string name = assembly.GetName().Name;
|
string name = assembly.GetName().Name;
|
||||||
if (StdLib.Contains(name))
|
if (StdLib.Contains(name))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
import(assembly);
|
import(assembly);
|
||||||
}
|
}
|
||||||
}
|
}
|
92
src/UI/Main/Console/ScriptInteraction.cs
Normal file
92
src/UI/Main/Console/ScriptInteraction.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
using System;
|
||||||
|
using Mono.CSharp;
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main.Console
|
||||||
|
{
|
||||||
|
public class ScriptInteraction : InteractiveBase
|
||||||
|
{
|
||||||
|
public static void Log(object message)
|
||||||
|
{
|
||||||
|
ExplorerCore.Log(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddUsing(string directive)
|
||||||
|
{
|
||||||
|
ConsolePage.Instance.AddUsing(directive);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void GetUsing()
|
||||||
|
{
|
||||||
|
ExplorerCore.Log(ConsolePage.Instance.m_evaluator.GetUsing());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Reset()
|
||||||
|
{
|
||||||
|
ConsolePage.Instance.ResetConsole();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object CurrentTarget()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object[] AllTargets()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Inspect(object obj)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Inspect(Type type)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static void Help()
|
||||||
|
// {
|
||||||
|
// ExplorerCore.Log(@"
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// C# Console Help
|
||||||
|
|
||||||
|
//The following helper methods are available:
|
||||||
|
|
||||||
|
//void Log(object message)
|
||||||
|
// prints a message to the console window and debug log
|
||||||
|
// usage: Log(""hello world"");
|
||||||
|
|
||||||
|
//void AddUsing(string directive)
|
||||||
|
// adds a using directive to the console.
|
||||||
|
// usage: AddUsing(""UnityEngine.UI"");
|
||||||
|
|
||||||
|
//void GetUsing()
|
||||||
|
// logs the current using directives to the debug console
|
||||||
|
// usage: GetUsing();
|
||||||
|
|
||||||
|
//void Reset()
|
||||||
|
// resets the C# console, clearing all variables and using directives.
|
||||||
|
// usage: Reset();
|
||||||
|
//");
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
|
||||||
|
//ExplorerCore.Log("object CurrentTarget()");
|
||||||
|
//ExplorerCore.Log(" returns the target object of the current tab (in tab view mode only)");
|
||||||
|
//ExplorerCore.Log(" usage: var target = CurrentTarget();");
|
||||||
|
//ExplorerCore.Log("");
|
||||||
|
//ExplorerCore.Log("object[] AllTargets()");
|
||||||
|
//ExplorerCore.Log(" returns an object[] array containing all currently inspected objects");
|
||||||
|
//ExplorerCore.Log(" usage: var targets = AllTargets();");
|
||||||
|
//ExplorerCore.Log("");
|
||||||
|
//ExplorerCore.Log("void Inspect(object obj)");
|
||||||
|
//ExplorerCore.Log(" inspects the provided object in a new window.");
|
||||||
|
//ExplorerCore.Log(" usage: Inspect(Camera.main);");
|
||||||
|
//ExplorerCore.Log("");
|
||||||
|
//ExplorerCore.Log("void Inspect(Type type)");
|
||||||
|
//ExplorerCore.Log(" attempts to inspect the provided type with static-only reflection.");
|
||||||
|
//ExplorerCore.Log(" usage: Inspect(typeof(Camera));");
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
81
src/UI/Main/Console/Suggestion.cs
Normal file
81
src/UI/Main/Console/Suggestion.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main.Console
|
||||||
|
{
|
||||||
|
public struct Suggestion
|
||||||
|
{
|
||||||
|
public string Full => Prefix + Addition;
|
||||||
|
|
||||||
|
public readonly string Prefix;
|
||||||
|
public readonly string Addition;
|
||||||
|
public readonly Contexts Context;
|
||||||
|
|
||||||
|
public Color TextColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (Context)
|
||||||
|
{
|
||||||
|
case Contexts.Namespace: return Color.grey;
|
||||||
|
case Contexts.Keyword: return systemBlue;
|
||||||
|
default: return Color.white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static readonly Color systemBlue = new Color(80f / 255f, 150f / 255f, 215f / 255f);
|
||||||
|
|
||||||
|
public Suggestion(string addition, string prefix, Contexts type)
|
||||||
|
{
|
||||||
|
Addition = addition;
|
||||||
|
Prefix = prefix;
|
||||||
|
Context = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Contexts
|
||||||
|
{
|
||||||
|
Namespace,
|
||||||
|
Keyword,
|
||||||
|
Other
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashSet<string> Namespaces => m_namspaces ?? GetNamespaces();
|
||||||
|
private static HashSet<string> m_namspaces;
|
||||||
|
|
||||||
|
private static HashSet<string> GetNamespaces()
|
||||||
|
{
|
||||||
|
HashSet<string> set = new HashSet<string>(
|
||||||
|
AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.SelectMany(GetTypes)
|
||||||
|
.Where(x => x.IsPublic && !string.IsNullOrEmpty(x.Namespace))
|
||||||
|
.Select(x => x.Namespace));
|
||||||
|
|
||||||
|
return m_namspaces = set;
|
||||||
|
|
||||||
|
IEnumerable<Type> GetTypes(Assembly asm) => asm.TryGetTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashSet<string> Keywords => m_keywords ?? GetKeywords();
|
||||||
|
private static HashSet<string> m_keywords;
|
||||||
|
|
||||||
|
private static HashSet<string> GetKeywords()
|
||||||
|
{
|
||||||
|
if (CSharpLexer.validKeywordMatcher.keywordCache == null)
|
||||||
|
{
|
||||||
|
return new HashSet<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet<string> set = new HashSet<string>();
|
||||||
|
|
||||||
|
foreach (string keyword in CSharpLexer.validKeywordMatcher.keywordCache)
|
||||||
|
{
|
||||||
|
set.Add(keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_keywords = set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Explorer.UI.Main.Pages.Console;
|
using ExplorerBeta.UI.Main.Console;
|
||||||
using ExplorerBeta;
|
|
||||||
using ExplorerBeta.UI;
|
|
||||||
using ExplorerBeta.UI.Main;
|
|
||||||
using ExplorerBeta.Unstrip.Resources;
|
using ExplorerBeta.Unstrip.Resources;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -16,12 +11,9 @@ using UnityEngine.UI;
|
|||||||
using UnhollowerRuntimeLib;
|
using UnhollowerRuntimeLib;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages
|
namespace ExplorerBeta.UI.Main
|
||||||
{
|
{
|
||||||
// TODO: Maybe add interface for managing the Using directives of the console.
|
public class ConsolePage : MainMenu.Page
|
||||||
// Otherwise it's pretty much done.
|
|
||||||
|
|
||||||
public class ConsolePage : BaseMenuPage
|
|
||||||
{
|
{
|
||||||
public override string Name => "C# Console";
|
public override string Name => "C# Console";
|
||||||
|
|
||||||
@ -33,7 +25,7 @@ namespace Explorer.UI.Main.Pages
|
|||||||
public CodeEditor m_codeEditor;
|
public CodeEditor m_codeEditor;
|
||||||
public ScriptEvaluator m_evaluator;
|
public ScriptEvaluator m_evaluator;
|
||||||
|
|
||||||
public static List<AutoComplete> AutoCompletes = new List<AutoComplete>();
|
public static List<Suggestion> AutoCompletes = new List<Suggestion>();
|
||||||
public static List<string> UsingDirectives;
|
public static List<string> UsingDirectives;
|
||||||
|
|
||||||
public static readonly string[] DefaultUsing = new string[]
|
public static readonly string[] DefaultUsing = new string[]
|
||||||
@ -54,7 +46,7 @@ namespace Explorer.UI.Main.Pages
|
|||||||
{
|
{
|
||||||
ResetConsole();
|
ResetConsole();
|
||||||
|
|
||||||
foreach (var use in DefaultUsing)
|
foreach (string use in DefaultUsing)
|
||||||
{
|
{
|
||||||
AddUsing(use);
|
AddUsing(use);
|
||||||
}
|
}
|
||||||
@ -66,7 +58,7 @@ namespace Explorer.UI.Main.Pages
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ExplorerCore.LogWarning($"Error setting up console!\r\nMessage: {e.Message}");
|
ExplorerCore.LogWarning($"Error setting up console!\r\nMessage: {e.Message}");
|
||||||
// TODO
|
// TODO remove page button from menu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,32 +69,31 @@ namespace Explorer.UI.Main.Pages
|
|||||||
AutoCompleter.Update();
|
AutoCompleter.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string AsmToUsing(string asm) => $"using {asm};";
|
|
||||||
|
|
||||||
public void AddUsing(string asm)
|
public void AddUsing(string asm)
|
||||||
{
|
{
|
||||||
if (!UsingDirectives.Contains(asm))
|
if (!UsingDirectives.Contains(asm))
|
||||||
{
|
{
|
||||||
UsingDirectives.Add(asm);
|
UsingDirectives.Add(asm);
|
||||||
Evaluate(AsmToUsing(asm), true);
|
Evaluate($"using {asm};", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Evaluate(string str, bool suppressWarning = false)
|
public void Evaluate(string str, bool suppressWarning = false)
|
||||||
{
|
{
|
||||||
object ret = VoidType.Value;
|
m_evaluator.Compile(str, out Mono.CSharp.CompiledMethod compiled);
|
||||||
|
|
||||||
m_evaluator.Compile(str, out var compiled);
|
|
||||||
|
|
||||||
if (compiled == null)
|
if (compiled == null)
|
||||||
{
|
{
|
||||||
if (!suppressWarning)
|
if (!suppressWarning)
|
||||||
|
{
|
||||||
ExplorerCore.LogWarning("Unable to compile the code!");
|
ExplorerCore.LogWarning("Unable to compile the code!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
object ret = VoidType.Value;
|
||||||
compiled.Invoke(ref ret);
|
compiled.Invoke(ref ret);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -110,8 +101,6 @@ namespace Explorer.UI.Main.Pages
|
|||||||
ExplorerCore.LogWarning($"Exception executing code: {e.GetType()}, {e.Message}\r\n{e.StackTrace}");
|
ExplorerCore.LogWarning($"Exception executing code: {e.GetType()}, {e.Message}\r\n{e.StackTrace}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetConsole()
|
public void ResetConsole()
|
||||||
@ -133,11 +122,10 @@ namespace Explorer.UI.Main.Pages
|
|||||||
AutoCompleter.SetSuggestions(AutoCompletes.ToArray());
|
AutoCompleter.SetSuggestions(AutoCompletes.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void UseAutocomplete(string suggestion)
|
public void UseAutocomplete(string suggestion)
|
||||||
{
|
{
|
||||||
int cursorIndex = m_codeEditor.InputField.caretPosition;
|
int cursorIndex = m_codeEditor.InputField.caretPosition;
|
||||||
var input = m_codeEditor.InputField.text;
|
string input = m_codeEditor.InputField.text;
|
||||||
input = input.Insert(cursorIndex, suggestion);
|
input = input.Insert(cursorIndex, suggestion);
|
||||||
m_codeEditor.InputField.text = input;
|
m_codeEditor.InputField.text = input;
|
||||||
m_codeEditor.InputField.caretPosition += suggestion.Length;
|
m_codeEditor.InputField.caretPosition += suggestion.Length;
|
||||||
@ -145,15 +133,15 @@ namespace Explorer.UI.Main.Pages
|
|||||||
AutoCompleter.ClearAutocompletes();
|
AutoCompleter.ClearAutocompletes();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region UI Construction
|
#region UI Construction
|
||||||
|
|
||||||
public void ConstructUI()
|
public void ConstructUI()
|
||||||
{
|
{
|
||||||
Content = UIFactory.CreateUIObject("C# Console", MainMenu.Instance.PageViewport);
|
Content = UIFactory.CreateUIObject("C# Console", MainMenu.Instance.PageViewport);
|
||||||
|
|
||||||
var mainLayout = Content.AddComponent<LayoutElement>();
|
var mainLayout = Content.AddComponent<LayoutElement>();
|
||||||
mainLayout.preferredHeight = 300;
|
mainLayout.preferredHeight = 9900;
|
||||||
mainLayout.flexibleHeight = 4;
|
mainLayout.flexibleHeight = 9000;
|
||||||
|
|
||||||
var mainGroup = Content.AddComponent<VerticalLayoutGroup>();
|
var mainGroup = Content.AddComponent<VerticalLayoutGroup>();
|
||||||
mainGroup.childControlHeight = true;
|
mainGroup.childControlHeight = true;
|
||||||
@ -161,12 +149,12 @@ namespace Explorer.UI.Main.Pages
|
|||||||
mainGroup.childForceExpandHeight = true;
|
mainGroup.childForceExpandHeight = true;
|
||||||
mainGroup.childForceExpandWidth = true;
|
mainGroup.childForceExpandWidth = true;
|
||||||
|
|
||||||
#region TOP BAR
|
#region TOP BAR
|
||||||
|
|
||||||
// Main group object
|
// Main group object
|
||||||
|
|
||||||
var topBarObj = UIFactory.CreateHorizontalGroup(Content);
|
var topBarObj = UIFactory.CreateHorizontalGroup(Content);
|
||||||
var topBarLayout = topBarObj.AddComponent<LayoutElement>();
|
LayoutElement topBarLayout = topBarObj.AddComponent<LayoutElement>();
|
||||||
topBarLayout.minHeight = 50;
|
topBarLayout.minHeight = 50;
|
||||||
topBarLayout.flexibleHeight = 0;
|
topBarLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
@ -247,9 +235,9 @@ namespace Explorer.UI.Main.Pages
|
|||||||
suggestPos.y = -14;
|
suggestPos.y = -14;
|
||||||
autoIndentRect.localPosition = suggestPos;
|
autoIndentRect.localPosition = suggestPos;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region CONSOLE INPUT
|
#region CONSOLE INPUT
|
||||||
|
|
||||||
var consoleBase = UIFactory.CreateUIObject("CodeEditor", Content);
|
var consoleBase = UIFactory.CreateUIObject("CodeEditor", Content);
|
||||||
|
|
||||||
@ -287,7 +275,9 @@ namespace Explorer.UI.Main.Pages
|
|||||||
|
|
||||||
var lineHighlightImage = lineHighlight.GetComponent<Image>();
|
var lineHighlightImage = lineHighlight.GetComponent<Image>();
|
||||||
if (!lineHighlightImage)
|
if (!lineHighlightImage)
|
||||||
|
{
|
||||||
lineHighlightImage = lineHighlight.AddComponent<Image>();
|
lineHighlightImage = lineHighlight.AddComponent<Image>();
|
||||||
|
}
|
||||||
|
|
||||||
var linesBg = UIFactory.CreateUIObject("LinesBackground", consoleBase);
|
var linesBg = UIFactory.CreateUIObject("LinesBackground", consoleBase);
|
||||||
var linesBgRect = linesBg.GetComponent<RectTransform>();
|
var linesBgRect = linesBg.GetComponent<RectTransform>();
|
||||||
@ -330,9 +320,21 @@ namespace Explorer.UI.Main.Pages
|
|||||||
mainTextInput.fontSize = 18;
|
mainTextInput.fontSize = 18;
|
||||||
|
|
||||||
var placeHolderText = textAreaObj.transform.Find("Placeholder").GetComponent<TextMeshProUGUI>();
|
var placeHolderText = textAreaObj.transform.Find("Placeholder").GetComponent<TextMeshProUGUI>();
|
||||||
placeHolderText.text = @"Welcome to the Explorer C# Console!
|
placeHolderText.text = @"Welcome to the Explorer C# Console.
|
||||||
|
|
||||||
Use the <color=#c74e26>Help();</color> command for a list of available helper methods, or <color=#c74e26>Log(""[message]"");</color> to print something to console.";
|
The following helper methods are available:
|
||||||
|
|
||||||
|
* <color=#c74e26>Log(""message"");</color> logs a message to the debug console
|
||||||
|
* <color=#c74e26>AddUsing(""SomeNamespace"");</color> adds a using directive to the C# console
|
||||||
|
* <color=#c74e26>GetUsing();</color> logs the current using directives to the debug console
|
||||||
|
* <color=#c74e26>Reset();</color> resets all using directives and variables
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
* <color=#c74e26>CurrentTarget();</color> returns the currently inspected target on the Home page
|
||||||
|
* <color=#c74e26>AllTargets();</color> returns an object[] array containing all inspected instances
|
||||||
|
* <color=#c74e26>Inspect(someObject)</color> to inspect an instance, eg. Inspect(Camera.main);
|
||||||
|
* <color=#c74e26>Inspect(typeof(SomeClass))</color> to inspect a Class with static reflection
|
||||||
|
";
|
||||||
|
|
||||||
var linesTextObj = UIFactory.CreateUIObject("LinesText", mainTextObj.gameObject);
|
var linesTextObj = UIFactory.CreateUIObject("LinesText", mainTextObj.gameObject);
|
||||||
var linesTextRect = linesTextObj.GetComponent<RectTransform>();
|
var linesTextRect = linesTextObj.GetComponent<RectTransform>();
|
||||||
@ -381,9 +383,9 @@ Use the <color=#c74e26>Help();</color> command for a list of available helper me
|
|||||||
tmpInput.GetComponentInChildren<RectMask2D>().enabled = false;
|
tmpInput.GetComponentInChildren<RectMask2D>().enabled = false;
|
||||||
inputObj.GetComponent<Image>().enabled = false;
|
inputObj.GetComponent<Image>().enabled = false;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region COMPILE BUTTON
|
#region COMPILE BUTTON
|
||||||
|
|
||||||
var compileBtnObj = UIFactory.CreateButton(Content);
|
var compileBtnObj = UIFactory.CreateButton(Content);
|
||||||
var compileBtnLayout = compileBtnObj.AddComponent<LayoutElement>();
|
var compileBtnLayout = compileBtnObj.AddComponent<LayoutElement>();
|
||||||
@ -427,10 +429,10 @@ Use the <color=#c74e26>Help();</color> command for a list of available helper me
|
|||||||
|
|
||||||
TMP_FontAsset fontToUse = null;
|
TMP_FontAsset fontToUse = null;
|
||||||
#if CPP
|
#if CPP
|
||||||
var fonts = ResourcesUnstrip.FindObjectsOfTypeAll(Il2CppType.Of<TMP_FontAsset>());
|
UnityEngine.Object[] fonts = ResourcesUnstrip.FindObjectsOfTypeAll(Il2CppType.Of<TMP_FontAsset>());
|
||||||
foreach (var font in fonts)
|
foreach (UnityEngine.Object font in fonts)
|
||||||
{
|
{
|
||||||
var fontCast = font.Il2CppCast(typeof(TMP_FontAsset)) as TMP_FontAsset;
|
TMP_FontAsset fontCast = font.Il2CppCast(typeof(TMP_FontAsset)) as TMP_FontAsset;
|
||||||
|
|
||||||
if (fontCast.name.Contains("LiberationSans"))
|
if (fontCast.name.Contains("LiberationSans"))
|
||||||
{
|
{
|
||||||
@ -451,7 +453,7 @@ Use the <color=#c74e26>Help();</color> command for a list of available helper me
|
|||||||
#endif
|
#endif
|
||||||
if (fontToUse != null)
|
if (fontToUse != null)
|
||||||
{
|
{
|
||||||
var faceInfo = fontToUse.faceInfo;
|
UnityEngine.TextCore.FaceInfo faceInfo = fontToUse.faceInfo;
|
||||||
fontToUse.tabSize = 10;
|
fontToUse.tabSize = 10;
|
||||||
faceInfo.tabWidth = 10;
|
faceInfo.tabWidth = 10;
|
||||||
#if CPP
|
#if CPP
|
||||||
@ -467,7 +469,7 @@ Use the <color=#c74e26>Help();</color> command for a list of available helper me
|
|||||||
highlightTextInput.font = fontToUse;
|
highlightTextInput.font = fontToUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -480,7 +482,7 @@ Use the <color=#c74e26>Help();</color> command for a list of available helper me
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private class VoidType
|
private class VoidType
|
||||||
{
|
{
|
@ -1,16 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using ExplorerBeta.Unstrip.ColorUtility;
|
||||||
using System.Text;
|
|
||||||
using Explorer.Unstrip.ColorUtility;
|
|
||||||
using ExplorerBeta.Input;
|
|
||||||
using ExplorerBeta.Unstrip.Resources;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnhollowerRuntimeLib;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ExplorerBeta.UI.Main
|
namespace ExplorerBeta.UI.Main
|
||||||
@ -21,8 +15,6 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
public static bool LogUnity { get; set; } = true;
|
public static bool LogUnity { get; set; } = true;
|
||||||
|
|
||||||
public static GameObject CanvasRoot;
|
|
||||||
|
|
||||||
public readonly List<string> AllMessages;
|
public readonly List<string> AllMessages;
|
||||||
public readonly List<Text> MessageHolders;
|
public readonly List<Text> MessageHolders;
|
||||||
|
|
||||||
@ -44,12 +36,42 @@ namespace ExplorerBeta.UI.Main
|
|||||||
ExplorerCore.Log(e);
|
ExplorerCore.Log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void Log(string message)
|
||||||
|
{
|
||||||
|
Log(message, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Log(string message, Color color)
|
||||||
|
{
|
||||||
|
Log(message, color.ToHex());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Log(string message, string hexColor)
|
||||||
|
{
|
||||||
|
if (Instance == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance.AllMessages.Add(message);
|
||||||
|
|
||||||
|
if (Instance.m_textInput)
|
||||||
|
{
|
||||||
|
if (hexColor != null)
|
||||||
|
{
|
||||||
|
message = $"<color=#{hexColor}>{message}</color>";
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance.m_textInput.text = $"{message}\n{Instance.m_textInput.text}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// todo: get scrollbar working with inputfield somehow
|
// todo: get scrollbar working with inputfield somehow
|
||||||
|
|
||||||
public void ConstructUI(GameObject parent)
|
public void ConstructUI(GameObject parent)
|
||||||
{
|
{
|
||||||
var mainObj = UIFactory.CreateVerticalGroup(parent, new Color(0.1f, 0.1f, 0.1f, 1.0f));
|
var mainObj = UIFactory.CreateVerticalGroup(parent, new Color(0.1f, 0.1f, 0.1f, 1.0f));
|
||||||
|
|
||||||
var mainGroup = mainObj.GetComponent<VerticalLayoutGroup>();
|
var mainGroup = mainObj.GetComponent<VerticalLayoutGroup>();
|
||||||
mainGroup.childControlHeight = true;
|
mainGroup.childControlHeight = true;
|
||||||
mainGroup.childControlWidth = true;
|
mainGroup.childControlWidth = true;
|
||||||
@ -63,11 +85,10 @@ namespace ExplorerBeta.UI.Main
|
|||||||
mask.showMaskGraphic = true;
|
mask.showMaskGraphic = true;
|
||||||
|
|
||||||
var mainLayout = mainObj.AddComponent<LayoutElement>();
|
var mainLayout = mainObj.AddComponent<LayoutElement>();
|
||||||
mainLayout.minHeight = 40;
|
mainLayout.minHeight = 190;
|
||||||
mainLayout.preferredHeight = 230;
|
|
||||||
mainLayout.flexibleHeight = 0;
|
mainLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
#region LOG AREA
|
#region LOG AREA
|
||||||
var logAreaObj = UIFactory.CreateHorizontalGroup(mainObj);
|
var logAreaObj = UIFactory.CreateHorizontalGroup(mainObj);
|
||||||
var logAreaGroup = logAreaObj.GetComponent<HorizontalLayoutGroup>();
|
var logAreaGroup = logAreaObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
logAreaGroup.childControlHeight = true;
|
logAreaGroup.childControlHeight = true;
|
||||||
@ -76,8 +97,8 @@ namespace ExplorerBeta.UI.Main
|
|||||||
logAreaGroup.childForceExpandWidth = true;
|
logAreaGroup.childForceExpandWidth = true;
|
||||||
|
|
||||||
var logAreaLayout = logAreaObj.AddComponent<LayoutElement>();
|
var logAreaLayout = logAreaObj.AddComponent<LayoutElement>();
|
||||||
logAreaLayout.preferredHeight = 300;
|
logAreaLayout.preferredHeight = 190;
|
||||||
logAreaLayout.flexibleHeight = 50;
|
logAreaLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
var inputObj = UIFactory.CreateTMPInput(logAreaObj);
|
var inputObj = UIFactory.CreateTMPInput(logAreaObj);
|
||||||
|
|
||||||
@ -114,12 +135,12 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
m_textInput = inputObj.GetComponent<TMP_InputField>();
|
m_textInput = inputObj.GetComponent<TMP_InputField>();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region BOTTOM BAR
|
#region BOTTOM BAR
|
||||||
|
|
||||||
var bottomBarObj = UIFactory.CreateHorizontalGroup(mainObj);
|
var bottomBarObj = UIFactory.CreateHorizontalGroup(mainObj);
|
||||||
var topBarLayout = bottomBarObj.AddComponent<LayoutElement>();
|
LayoutElement topBarLayout = bottomBarObj.AddComponent<LayoutElement>();
|
||||||
topBarLayout.minHeight = 40;
|
topBarLayout.minHeight = 40;
|
||||||
topBarLayout.flexibleHeight = 0;
|
topBarLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
@ -165,13 +186,13 @@ namespace ExplorerBeta.UI.Main
|
|||||||
{
|
{
|
||||||
logAreaObj.SetActive(false);
|
logAreaObj.SetActive(false);
|
||||||
hideBtnText.text = "Show";
|
hideBtnText.text = "Show";
|
||||||
mainLayout.preferredHeight = 40;
|
mainLayout.minHeight = 40;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logAreaObj.SetActive(true);
|
logAreaObj.SetActive(true);
|
||||||
hideBtnText.text = "Hide";
|
hideBtnText.text = "Hide";
|
||||||
mainLayout.preferredHeight = 230;
|
mainLayout.minHeight = 190;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,16 +235,10 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
var unityToggleObj = UIFactory.CreateToggle(bottomBarObj, out Toggle unityToggle, out Text unityToggleText);
|
var unityToggleObj = UIFactory.CreateToggle(bottomBarObj, out Toggle unityToggle, out Text unityToggleText);
|
||||||
#if CPP
|
#if CPP
|
||||||
unityToggle.onValueChanged.AddListener(new Action<bool>(ToggleCallback));
|
unityToggle.onValueChanged.AddListener(new Action<bool>((bool val) => { LogUnity = val; }));
|
||||||
#else
|
#else
|
||||||
unityToggle.onValueChanged.AddListener(ToggleCallback);
|
unityToggle.onValueChanged.AddListener((bool val) => { LogUnity = val; }));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ToggleCallback(bool val)
|
|
||||||
{
|
|
||||||
LogUnity = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
unityToggleText.text = "Print Unity Debug?";
|
unityToggleText.text = "Print Unity Debug?";
|
||||||
unityToggleText.alignment = TextAnchor.MiddleLeft;
|
unityToggleText.alignment = TextAnchor.MiddleLeft;
|
||||||
|
|
||||||
@ -236,33 +251,9 @@ namespace ExplorerBeta.UI.Main
|
|||||||
pos.y = -8;
|
pos.y = -8;
|
||||||
unityToggleRect.localPosition = pos;
|
unityToggleRect.localPosition = pos;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Log(string message)
|
|
||||||
{
|
|
||||||
Log(message, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Log(string message, Color color)
|
|
||||||
{
|
|
||||||
Log(message, color.ToHex());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Log(string message, string hexColor)
|
|
||||||
{
|
|
||||||
if (Instance == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Instance.AllMessages.Add(message);
|
|
||||||
|
|
||||||
if (Instance.m_textInput)
|
|
||||||
{
|
|
||||||
if (hexColor != null)
|
|
||||||
message = $"<color=#{hexColor}>{message}</color>";
|
|
||||||
|
|
||||||
Instance.m_textInput.text = $"{message}\n{Instance.m_textInput.text}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
53
src/UI/Main/HomePage.cs
Normal file
53
src/UI/Main/HomePage.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main
|
||||||
|
{
|
||||||
|
public class HomePage : MainMenu.Page
|
||||||
|
{
|
||||||
|
public override string Name => "Home";
|
||||||
|
|
||||||
|
public static HomePage Instance { get; internal set; }
|
||||||
|
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
|
||||||
|
ConstructMenu();
|
||||||
|
|
||||||
|
SceneExplorer.Instance.Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
SceneExplorer.Instance.Update();
|
||||||
|
InspectorManager.Instance.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConstructMenu()
|
||||||
|
{
|
||||||
|
GameObject parent = MainMenu.Instance.PageViewport;
|
||||||
|
|
||||||
|
Content = UIFactory.CreateHorizontalGroup(parent);
|
||||||
|
var mainGroup = Content.GetComponent<HorizontalLayoutGroup>();
|
||||||
|
mainGroup.padding.left = 3;
|
||||||
|
mainGroup.padding.right = 3;
|
||||||
|
mainGroup.padding.top = 3;
|
||||||
|
mainGroup.padding.bottom = 3;
|
||||||
|
mainGroup.spacing = 5;
|
||||||
|
mainGroup.childForceExpandHeight = true;
|
||||||
|
mainGroup.childForceExpandWidth = true;
|
||||||
|
mainGroup.childControlHeight = true;
|
||||||
|
mainGroup.childControlWidth = true;
|
||||||
|
|
||||||
|
new SceneExplorer();
|
||||||
|
SceneExplorer.Instance.ConstructScenePane();
|
||||||
|
|
||||||
|
new InspectorManager();
|
||||||
|
InspectorManager.Instance.ConstructInspectorPane();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
177
src/UI/Main/InspectorManager.cs
Normal file
177
src/UI/Main/InspectorManager.cs
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using ExplorerBeta.Helpers;
|
||||||
|
using ExplorerBeta.UI.Main.Inspectors;
|
||||||
|
using ExplorerBeta.UI.Shared;
|
||||||
|
using ExplorerBeta.Unstrip.Scenes;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main
|
||||||
|
{
|
||||||
|
public class InspectorManager
|
||||||
|
{
|
||||||
|
public static InspectorManager Instance { get; private set; }
|
||||||
|
|
||||||
|
public InspectorManager() { Instance = this; }
|
||||||
|
|
||||||
|
public InspectorBase m_activeInspector;
|
||||||
|
public readonly List<InspectorBase> m_currentInspectors = new List<InspectorBase>();
|
||||||
|
public GameObject m_tabBarContent;
|
||||||
|
public GameObject m_rightPaneContent;
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
foreach (InspectorBase tab in m_currentInspectors)
|
||||||
|
{
|
||||||
|
tab.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Inspect(object obj)
|
||||||
|
{
|
||||||
|
#if CPP
|
||||||
|
obj = obj.Il2CppCast(ReflectionHelpers.GetActualType(obj));
|
||||||
|
#endif
|
||||||
|
UnityEngine.Object unityObj = obj as UnityEngine.Object;
|
||||||
|
|
||||||
|
if (InspectorBase.ObjectNullOrDestroyed(obj, unityObj))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MainMenu.Instance.SetPage(HomePage.Instance);
|
||||||
|
|
||||||
|
// check if currently inspecting this object
|
||||||
|
foreach (InspectorBase tab in m_currentInspectors)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(obj, tab.Target))
|
||||||
|
{
|
||||||
|
SetInspectorTab(tab);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if CPP
|
||||||
|
else if (unityObj && tab.Target is UnityEngine.Object uTabObj)
|
||||||
|
{
|
||||||
|
if (unityObj.m_CachedPtr == uTabObj.m_CachedPtr)
|
||||||
|
{
|
||||||
|
SetInspectorTab(tab);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
InspectorBase inspector;
|
||||||
|
if (obj is GameObject go)
|
||||||
|
{
|
||||||
|
inspector = new GameObjectInspector(go);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inspector = new InstanceInspector(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentInspectors.Add(inspector);
|
||||||
|
inspector.inspectorContent?.SetActive(false);
|
||||||
|
|
||||||
|
SetInspectorTab(inspector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Inspect(Type type)
|
||||||
|
{
|
||||||
|
// TODO static type inspection
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetInspectorTab(InspectorBase inspector)
|
||||||
|
{
|
||||||
|
UnsetInspectorTab();
|
||||||
|
|
||||||
|
m_activeInspector = inspector;
|
||||||
|
|
||||||
|
m_activeInspector.inspectorContent?.SetActive(true);
|
||||||
|
|
||||||
|
Color activeColor = new Color(0, 0.25f, 0, 1);
|
||||||
|
ColorBlock colors = inspector.tabButton.colors;
|
||||||
|
colors.normalColor = activeColor;
|
||||||
|
colors.highlightedColor = activeColor;
|
||||||
|
inspector.tabButton.colors = colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnsetInspectorTab()
|
||||||
|
{
|
||||||
|
if (m_activeInspector == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_activeInspector.inspectorContent?.SetActive(false);
|
||||||
|
|
||||||
|
ColorBlock colors = m_activeInspector.tabButton.colors;
|
||||||
|
colors.normalColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
||||||
|
colors.highlightedColor = new Color(0.1f, 0.3f, 0.1f, 1);
|
||||||
|
m_activeInspector.tabButton.colors = colors;
|
||||||
|
|
||||||
|
m_activeInspector = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region INSPECTOR PANE
|
||||||
|
|
||||||
|
public void ConstructInspectorPane()
|
||||||
|
{
|
||||||
|
m_rightPaneContent = UIFactory.CreateVerticalGroup(HomePage.Instance.Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
||||||
|
LayoutElement rightLayout = m_rightPaneContent.AddComponent<LayoutElement>();
|
||||||
|
rightLayout.flexibleWidth = 999999;
|
||||||
|
|
||||||
|
VerticalLayoutGroup rightGroup = m_rightPaneContent.GetComponent<VerticalLayoutGroup>();
|
||||||
|
rightGroup.childForceExpandHeight = true;
|
||||||
|
rightGroup.childForceExpandWidth = true;
|
||||||
|
rightGroup.childControlHeight = true;
|
||||||
|
rightGroup.childControlWidth = true;
|
||||||
|
rightGroup.spacing = 10;
|
||||||
|
rightGroup.padding.left = 8;
|
||||||
|
rightGroup.padding.right = 8;
|
||||||
|
rightGroup.padding.top = 8;
|
||||||
|
rightGroup.padding.bottom = 8;
|
||||||
|
|
||||||
|
GameObject inspectorTitle = UIFactory.CreateLabel(m_rightPaneContent, TextAnchor.UpperLeft);
|
||||||
|
Text title = inspectorTitle.GetComponent<Text>();
|
||||||
|
title.text = "Inspector";
|
||||||
|
title.fontSize = 20;
|
||||||
|
LayoutElement titleLayout = inspectorTitle.AddComponent<LayoutElement>();
|
||||||
|
titleLayout.minHeight = 30;
|
||||||
|
titleLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
|
m_tabBarContent = UIFactory.CreateGridGroup(m_rightPaneContent, new Vector2(185, 20), new Vector2(5, 2), new Color(0.1f, 0.1f, 0.1f, 1));
|
||||||
|
|
||||||
|
GridLayoutGroup gridGroup = m_tabBarContent.GetComponent<GridLayoutGroup>();
|
||||||
|
gridGroup.padding.top = 4;
|
||||||
|
gridGroup.padding.left = 4;
|
||||||
|
gridGroup.padding.right = 4;
|
||||||
|
gridGroup.padding.bottom = 4;
|
||||||
|
|
||||||
|
// TEMP DUMMY INSPECTOR
|
||||||
|
|
||||||
|
GameObject dummyInspectorObj = UIFactory.CreateVerticalGroup(m_rightPaneContent, new Color(0.1f, 0.1f, 0.1f, 1.0f));
|
||||||
|
|
||||||
|
VerticalLayoutGroup dummyGroup = dummyInspectorObj.GetComponent<VerticalLayoutGroup>();
|
||||||
|
dummyGroup.childForceExpandHeight = true;
|
||||||
|
dummyGroup.childForceExpandWidth = true;
|
||||||
|
dummyGroup.childControlHeight = true;
|
||||||
|
dummyGroup.childControlWidth = true;
|
||||||
|
dummyGroup.spacing = 5;
|
||||||
|
dummyGroup.padding.top = 5;
|
||||||
|
dummyGroup.padding.left = 5;
|
||||||
|
dummyGroup.padding.right = 5;
|
||||||
|
dummyGroup.padding.bottom = 5;
|
||||||
|
|
||||||
|
LayoutElement dummyLayout = dummyInspectorObj.AddComponent<LayoutElement>();
|
||||||
|
dummyLayout.preferredHeight = 900;
|
||||||
|
dummyLayout.flexibleHeight = 10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
42
src/UI/Main/Inspectors/GameObjectInspector.cs
Normal file
42
src/UI/Main/Inspectors/GameObjectInspector.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main.Inspectors
|
||||||
|
{
|
||||||
|
public class GameObjectInspector : InspectorBase
|
||||||
|
{
|
||||||
|
public override string TabLabel => $" [G] {TargetGO?.name}";
|
||||||
|
|
||||||
|
// just to help with casting in il2cpp
|
||||||
|
public GameObject TargetGO;
|
||||||
|
|
||||||
|
public GameObjectInspector(GameObject target) : base(target)
|
||||||
|
{
|
||||||
|
TargetGO = target;
|
||||||
|
|
||||||
|
ConstructUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (m_pendingDestroy || InspectorManager.Instance.m_activeInspector != this)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO refresh children and components
|
||||||
|
}
|
||||||
|
|
||||||
|
#region UI CONSTRUCTION
|
||||||
|
|
||||||
|
private void ConstructUI()
|
||||||
|
{
|
||||||
|
// todo create gameobject inspector pane
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
143
src/UI/Main/Inspectors/InspectorBase.cs
Normal file
143
src/UI/Main/Inspectors/InspectorBase.cs
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main.Inspectors
|
||||||
|
{
|
||||||
|
public abstract class InspectorBase
|
||||||
|
{
|
||||||
|
public object Target;
|
||||||
|
// just to cache a cast
|
||||||
|
public UnityEngine.Object UnityTarget;
|
||||||
|
|
||||||
|
public abstract string TabLabel { get; }
|
||||||
|
|
||||||
|
public GameObject inspectorContent;
|
||||||
|
public Button tabButton;
|
||||||
|
public Text tabText;
|
||||||
|
|
||||||
|
internal bool m_pendingDestroy;
|
||||||
|
|
||||||
|
public InspectorBase(object target)
|
||||||
|
{
|
||||||
|
Target = target;
|
||||||
|
UnityTarget = target as UnityEngine.Object;
|
||||||
|
|
||||||
|
if (ObjectNullOrDestroyed(Target, UnityTarget))
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddInspectorTab();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Update()
|
||||||
|
{
|
||||||
|
if (ObjectNullOrDestroyed(Target, UnityTarget))
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tabText.text = TabLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Destroy()
|
||||||
|
{
|
||||||
|
m_pendingDestroy = true;
|
||||||
|
|
||||||
|
GameObject tabGroup = tabButton?.transform.parent.gameObject;
|
||||||
|
|
||||||
|
if (tabGroup)
|
||||||
|
{
|
||||||
|
GameObject.Destroy(tabGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inspectorContent)
|
||||||
|
{
|
||||||
|
GameObject.Destroy(inspectorContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ReferenceEquals(InspectorManager.Instance.m_activeInspector, this))
|
||||||
|
{
|
||||||
|
InspectorManager.Instance.UnsetInspectorTab();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (InspectorManager.Instance.m_currentInspectors.Contains(this))
|
||||||
|
{
|
||||||
|
InspectorManager.Instance.m_currentInspectors.Remove(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ObjectNullOrDestroyed(object obj, UnityEngine.Object unityObj, bool suppressWarning = false)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
if (!suppressWarning)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning("The target instance is null!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (obj is UnityEngine.Object)
|
||||||
|
{
|
||||||
|
if (!unityObj)
|
||||||
|
{
|
||||||
|
if (!suppressWarning)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning("The target UnityEngine.Object was destroyed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region UI CONSTRUCTION
|
||||||
|
|
||||||
|
public void AddInspectorTab()
|
||||||
|
{
|
||||||
|
var tabContent = InspectorManager.Instance.m_tabBarContent;
|
||||||
|
|
||||||
|
var tabGroupObj = UIFactory.CreateHorizontalGroup(tabContent);
|
||||||
|
var tabGroup = tabGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
|
tabGroup.childForceExpandWidth = true;
|
||||||
|
tabGroup.childControlWidth = true;
|
||||||
|
var tabLayout = tabGroupObj.AddComponent<LayoutElement>();
|
||||||
|
tabLayout.minWidth = 185;
|
||||||
|
tabLayout.flexibleWidth = 0;
|
||||||
|
tabGroupObj.AddComponent<Mask>();
|
||||||
|
|
||||||
|
var targetButtonObj = UIFactory.CreateButton(tabGroupObj);
|
||||||
|
var targetButtonLayout = targetButtonObj.AddComponent<LayoutElement>();
|
||||||
|
targetButtonLayout.minWidth = 165;
|
||||||
|
targetButtonLayout.flexibleWidth = 0;
|
||||||
|
|
||||||
|
tabText = targetButtonObj.GetComponentInChildren<Text>();
|
||||||
|
tabText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||||
|
tabText.alignment = TextAnchor.MiddleLeft;
|
||||||
|
|
||||||
|
tabButton = targetButtonObj.GetComponent<Button>();
|
||||||
|
tabButton.onClick.AddListener(new Action(() => { InspectorManager.Instance.SetInspectorTab(this); }));
|
||||||
|
|
||||||
|
var closeBtnObj = UIFactory.CreateButton(tabGroupObj);
|
||||||
|
var closeBtnLayout = closeBtnObj.AddComponent<LayoutElement>();
|
||||||
|
closeBtnLayout.minWidth = 20;
|
||||||
|
closeBtnLayout.flexibleWidth = 0;
|
||||||
|
var closeBtnText = closeBtnObj.GetComponentInChildren<Text>();
|
||||||
|
closeBtnText.text = "X";
|
||||||
|
closeBtnText.color = new Color(1, 0, 0, 1);
|
||||||
|
|
||||||
|
var closeBtn = closeBtnObj.GetComponent<Button>();
|
||||||
|
closeBtn.onClick.AddListener(new Action(() => { Destroy(); }));
|
||||||
|
var closeColors = closeBtn.colors;
|
||||||
|
closeColors.normalColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
||||||
|
closeBtn.colors = closeColors;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
40
src/UI/Main/Inspectors/InstanceInspector.cs
Normal file
40
src/UI/Main/Inspectors/InstanceInspector.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using ExplorerBeta.Helpers;
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main.Inspectors
|
||||||
|
{
|
||||||
|
public class InstanceInspector : InspectorBase
|
||||||
|
{
|
||||||
|
// todo
|
||||||
|
public override string TabLabel => $" [R] {m_targetTypeShortName}";
|
||||||
|
private readonly string m_targetTypeShortName;
|
||||||
|
|
||||||
|
public InstanceInspector(object target) : base(target)
|
||||||
|
{
|
||||||
|
// todo
|
||||||
|
|
||||||
|
Type type = ReflectionHelpers.GetActualType(target);
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_targetTypeShortName = type.Name;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (m_pendingDestroy || InspectorManager.Instance.m_activeInspector != this)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
src/UI/Main/Inspectors/StaticInspector.cs
Normal file
26
src/UI/Main/Inspectors/StaticInspector.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main.Inspectors
|
||||||
|
{
|
||||||
|
public class StaticInspector : InspectorBase
|
||||||
|
{
|
||||||
|
public override string TabLabel => " [S] TODO";
|
||||||
|
|
||||||
|
public StaticInspector(Type type) : base(type)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (m_pendingDestroy || InspectorManager.Instance.m_activeInspector != this)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,31 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using ExplorerBeta.UI.Main.Console;
|
||||||
using System.Text;
|
|
||||||
using ExplorerBeta.UI;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using ExplorerBeta.UI.Shared;
|
|
||||||
using Explorer.UI.Main.Pages;
|
|
||||||
using Explorer.UI.Main.Pages.Console;
|
|
||||||
|
|
||||||
namespace ExplorerBeta.UI.Main
|
namespace ExplorerBeta.UI.Main
|
||||||
{
|
{
|
||||||
public class MainMenu
|
public class MainMenu
|
||||||
{
|
{
|
||||||
|
public abstract class Page
|
||||||
|
{
|
||||||
|
public abstract string Name { get; }
|
||||||
|
|
||||||
|
public GameObject Content;
|
||||||
|
public Button RefNavbarButton { get; set; }
|
||||||
|
|
||||||
|
public bool Enabled
|
||||||
|
{
|
||||||
|
get => Content?.activeSelf ?? false;
|
||||||
|
set => Content?.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void Init();
|
||||||
|
public abstract void Update();
|
||||||
|
}
|
||||||
|
|
||||||
public static MainMenu Instance { get; set; }
|
public static MainMenu Instance { get; set; }
|
||||||
|
|
||||||
public PanelDragger Dragger { get; private set; }
|
public PanelDragger Dragger { get; private set; }
|
||||||
@ -21,14 +33,14 @@ namespace ExplorerBeta.UI.Main
|
|||||||
public GameObject MainPanel { get; private set; }
|
public GameObject MainPanel { get; private set; }
|
||||||
public GameObject PageViewport { get; private set; }
|
public GameObject PageViewport { get; private set; }
|
||||||
|
|
||||||
public readonly List<BaseMenuPage> Pages = new List<BaseMenuPage>();
|
public readonly List<Page> Pages = new List<Page>();
|
||||||
private BaseMenuPage m_activePage;
|
private Page m_activePage;
|
||||||
|
|
||||||
// Navbar buttons
|
// Navbar buttons
|
||||||
private Button m_lastNavButtonPressed;
|
private Button m_lastNavButtonPressed;
|
||||||
private readonly Color m_navButtonNormal = new Color(65f/255f, 66f/255f, 66f/255f);
|
private readonly Color m_navButtonNormal = new Color(65f / 255f, 66f / 255f, 66f / 255f);
|
||||||
private readonly Color m_navButtonHighlight = new Color(50f/255f, 195f/255f, 50f/255f);
|
private readonly Color m_navButtonHighlight = new Color(50f / 255f, 195f / 255f, 50f / 255f);
|
||||||
private readonly Color m_navButtonSelected = new Color(60f/255f, 120f/255f, 60f/255f);
|
private readonly Color m_navButtonSelected = new Color(60f / 255f, 120f / 255f, 60f / 255f);
|
||||||
|
|
||||||
public MainMenu()
|
public MainMenu()
|
||||||
{
|
{
|
||||||
@ -48,7 +60,7 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
ConstructMenu();
|
ConstructMenu();
|
||||||
|
|
||||||
foreach (var page in Pages)
|
foreach (Page page in Pages)
|
||||||
{
|
{
|
||||||
page.Init();
|
page.Init();
|
||||||
page.Content?.SetActive(false);
|
page.Content?.SetActive(false);
|
||||||
@ -62,10 +74,12 @@ namespace ExplorerBeta.UI.Main
|
|||||||
m_activePage?.Update();
|
m_activePage?.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPage(BaseMenuPage page)
|
public void SetPage(Page page)
|
||||||
{
|
{
|
||||||
if (m_activePage == page || page == null)
|
if (m_activePage == page || page == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_activePage?.Content?.SetActive(false);
|
m_activePage?.Content?.SetActive(false);
|
||||||
if (m_activePage is ConsolePage)
|
if (m_activePage is ConsolePage)
|
||||||
@ -77,16 +91,16 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
m_activePage.Content?.SetActive(true);
|
m_activePage.Content?.SetActive(true);
|
||||||
|
|
||||||
var button = page.RefNavbarButton;
|
Button button = page.RefNavbarButton;
|
||||||
|
|
||||||
var colors = button.colors;
|
ColorBlock colors = button.colors;
|
||||||
colors.normalColor = m_navButtonSelected;
|
colors.normalColor = m_navButtonSelected;
|
||||||
//try { colors.selectedColor = m_navButtonSelected; } catch { }
|
//try { colors.selectedColor = m_navButtonSelected; } catch { }
|
||||||
button.colors = colors;
|
button.colors = colors;
|
||||||
|
|
||||||
if (m_lastNavButtonPressed && m_lastNavButtonPressed != button)
|
if (m_lastNavButtonPressed && m_lastNavButtonPressed != button)
|
||||||
{
|
{
|
||||||
var oldColors = m_lastNavButtonPressed.colors;
|
ColorBlock oldColors = m_lastNavButtonPressed.colors;
|
||||||
oldColors.normalColor = m_navButtonNormal;
|
oldColors.normalColor = m_navButtonNormal;
|
||||||
//try { oldColors.selectedColor = m_navButtonNormal; } catch { }
|
//try { oldColors.selectedColor = m_navButtonNormal; } catch { }
|
||||||
m_lastNavButtonPressed.colors = oldColors;
|
m_lastNavButtonPressed.colors = oldColors;
|
||||||
@ -107,7 +121,7 @@ namespace ExplorerBeta.UI.Main
|
|||||||
{
|
{
|
||||||
MainPanel = UIFactory.CreatePanel(UIManager.CanvasRoot, "MainMenu", out GameObject content);
|
MainPanel = UIFactory.CreatePanel(UIManager.CanvasRoot, "MainMenu", out GameObject content);
|
||||||
|
|
||||||
var panelRect = MainPanel.GetComponent<RectTransform>();
|
RectTransform panelRect = MainPanel.GetComponent<RectTransform>();
|
||||||
panelRect.anchorMin = new Vector2(0.25f, 0.1f);
|
panelRect.anchorMin = new Vector2(0.25f, 0.1f);
|
||||||
panelRect.anchorMax = new Vector2(0.75f, 0.95f);
|
panelRect.anchorMax = new Vector2(0.75f, 0.95f);
|
||||||
|
|
||||||
@ -129,9 +143,9 @@ namespace ExplorerBeta.UI.Main
|
|||||||
{
|
{
|
||||||
// Core title bar holder
|
// Core title bar holder
|
||||||
|
|
||||||
var titleBar = UIFactory.CreateHorizontalGroup(content);
|
GameObject titleBar = UIFactory.CreateHorizontalGroup(content);
|
||||||
|
|
||||||
var titleGroup = titleBar.GetComponent<HorizontalLayoutGroup>();
|
HorizontalLayoutGroup titleGroup = titleBar.GetComponent<HorizontalLayoutGroup>();
|
||||||
titleGroup.childControlHeight = true;
|
titleGroup.childControlHeight = true;
|
||||||
titleGroup.childControlWidth = true;
|
titleGroup.childControlWidth = true;
|
||||||
titleGroup.childForceExpandHeight = true;
|
titleGroup.childForceExpandHeight = true;
|
||||||
@ -141,21 +155,21 @@ namespace ExplorerBeta.UI.Main
|
|||||||
titleGroup.padding.top = 3;
|
titleGroup.padding.top = 3;
|
||||||
titleGroup.padding.bottom = 3;
|
titleGroup.padding.bottom = 3;
|
||||||
|
|
||||||
var titleLayout = titleBar.AddComponent<LayoutElement>();
|
LayoutElement titleLayout = titleBar.AddComponent<LayoutElement>();
|
||||||
titleLayout.minHeight = 35;
|
titleLayout.minHeight = 35;
|
||||||
titleLayout.flexibleHeight = 0;
|
titleLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
// Explorer label
|
// Explorer label
|
||||||
|
|
||||||
var textObj = UIFactory.CreateLabel(titleBar, TextAnchor.MiddleLeft);
|
GameObject textObj = UIFactory.CreateLabel(titleBar, TextAnchor.MiddleLeft);
|
||||||
|
|
||||||
var text = textObj.GetComponent<Text>();
|
Text text = textObj.GetComponent<Text>();
|
||||||
text.text = $"<b>Explorer</b> <i>v{ExplorerCore.VERSION}</i>";
|
text.text = $"<b>Explorer</b> <i>v{ExplorerCore.VERSION}</i>";
|
||||||
text.resizeTextForBestFit = true;
|
text.resizeTextForBestFit = true;
|
||||||
text.resizeTextMinSize = 12;
|
text.resizeTextMinSize = 12;
|
||||||
text.resizeTextMaxSize = 20;
|
text.resizeTextMaxSize = 20;
|
||||||
|
|
||||||
var textLayout = textObj.AddComponent<LayoutElement>();
|
LayoutElement textLayout = textObj.AddComponent<LayoutElement>();
|
||||||
textLayout.flexibleWidth = 50;
|
textLayout.flexibleWidth = 50;
|
||||||
|
|
||||||
// Add PanelDragger using the label object
|
// Add PanelDragger using the label object
|
||||||
@ -164,25 +178,25 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
// Hide button
|
// Hide button
|
||||||
|
|
||||||
var hideBtnObj = UIFactory.CreateButton(titleBar);
|
GameObject hideBtnObj = UIFactory.CreateButton(titleBar);
|
||||||
|
|
||||||
var hideBtn = hideBtnObj.GetComponent<Button>();
|
Button hideBtn = hideBtnObj.GetComponent<Button>();
|
||||||
#if CPP
|
#if CPP
|
||||||
hideBtn.onClick.AddListener(new Action(() => { ExplorerCore.ShowMenu = false; }));
|
hideBtn.onClick.AddListener(new Action(() => { ExplorerCore.ShowMenu = false; }));
|
||||||
#else
|
#else
|
||||||
hideBtn.onClick.AddListener(() => { ExplorerCore.ShowMenu = false; });
|
hideBtn.onClick.AddListener(() => { ExplorerCore.ShowMenu = false; });
|
||||||
#endif
|
#endif
|
||||||
var colorBlock = hideBtn.colors;
|
ColorBlock colorBlock = hideBtn.colors;
|
||||||
colorBlock.normalColor = new Color(65f/255f, 23f/255f, 23f/255f);
|
colorBlock.normalColor = new Color(65f / 255f, 23f / 255f, 23f / 255f);
|
||||||
colorBlock.pressedColor = new Color(35f/255f, 10f/255f, 10f/255f);
|
colorBlock.pressedColor = new Color(35f / 255f, 10f / 255f, 10f / 255f);
|
||||||
colorBlock.highlightedColor = new Color(156f/255f, 0f, 0f);
|
colorBlock.highlightedColor = new Color(156f / 255f, 0f, 0f);
|
||||||
hideBtn.colors = colorBlock;
|
hideBtn.colors = colorBlock;
|
||||||
|
|
||||||
var btnLayout = hideBtnObj.AddComponent<LayoutElement>();
|
LayoutElement btnLayout = hideBtnObj.AddComponent<LayoutElement>();
|
||||||
btnLayout.minWidth = 90;
|
btnLayout.minWidth = 90;
|
||||||
btnLayout.flexibleWidth = 2;
|
btnLayout.flexibleWidth = 2;
|
||||||
|
|
||||||
var hideText = hideBtnObj.GetComponentInChildren<Text>();
|
Text hideText = hideBtnObj.GetComponentInChildren<Text>();
|
||||||
// Todo use actual keycode from mod config, update on OnSettingsChanged or whatever
|
// Todo use actual keycode from mod config, update on OnSettingsChanged or whatever
|
||||||
hideText.text = "Hide (F7)";
|
hideText.text = "Hide (F7)";
|
||||||
hideText.color = Color.white;
|
hideText.color = Color.white;
|
||||||
@ -193,9 +207,9 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
private void ConstructNavbar(GameObject content)
|
private void ConstructNavbar(GameObject content)
|
||||||
{
|
{
|
||||||
var navbarObj = UIFactory.CreateHorizontalGroup(content);
|
GameObject navbarObj = UIFactory.CreateHorizontalGroup(content);
|
||||||
|
|
||||||
var navGroup = navbarObj.GetComponent<HorizontalLayoutGroup>();
|
HorizontalLayoutGroup navGroup = navbarObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
navGroup.padding.left = 3;
|
navGroup.padding.left = 3;
|
||||||
navGroup.padding.right = 3;
|
navGroup.padding.right = 3;
|
||||||
navGroup.padding.top = 3;
|
navGroup.padding.top = 3;
|
||||||
@ -206,14 +220,14 @@ namespace ExplorerBeta.UI.Main
|
|||||||
navGroup.childForceExpandHeight = true;
|
navGroup.childForceExpandHeight = true;
|
||||||
navGroup.childForceExpandWidth = true;
|
navGroup.childForceExpandWidth = true;
|
||||||
|
|
||||||
var navLayout = navbarObj.AddComponent<LayoutElement>();
|
LayoutElement navLayout = navbarObj.AddComponent<LayoutElement>();
|
||||||
navLayout.minHeight = 35;
|
navLayout.minHeight = 35;
|
||||||
navLayout.flexibleHeight = 0;
|
navLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
foreach (var page in Pages)
|
foreach (Page page in Pages)
|
||||||
{
|
{
|
||||||
var btnObj = UIFactory.CreateButton(navbarObj);
|
GameObject btnObj = UIFactory.CreateButton(navbarObj);
|
||||||
var btn = btnObj.GetComponent<Button>();
|
Button btn = btnObj.GetComponent<Button>();
|
||||||
|
|
||||||
page.RefNavbarButton = btn;
|
page.RefNavbarButton = btn;
|
||||||
|
|
||||||
@ -223,11 +237,11 @@ namespace ExplorerBeta.UI.Main
|
|||||||
btn.onClick.AddListener(() => { SetPage(page); });
|
btn.onClick.AddListener(() => { SetPage(page); });
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var text = btnObj.GetComponentInChildren<Text>();
|
Text text = btnObj.GetComponentInChildren<Text>();
|
||||||
text.text = page.Name;
|
text.text = page.Name;
|
||||||
|
|
||||||
// Set button colors
|
// Set button colors
|
||||||
var colorBlock = btn.colors;
|
ColorBlock colorBlock = btn.colors;
|
||||||
colorBlock.normalColor = m_navButtonNormal;
|
colorBlock.normalColor = m_navButtonNormal;
|
||||||
//try { colorBlock.selectedColor = colorBlock.normalColor; } catch { }
|
//try { colorBlock.selectedColor = colorBlock.normalColor; } catch { }
|
||||||
colorBlock.highlightedColor = m_navButtonHighlight;
|
colorBlock.highlightedColor = m_navButtonHighlight;
|
||||||
@ -238,8 +252,8 @@ namespace ExplorerBeta.UI.Main
|
|||||||
|
|
||||||
private void ConstructMainViewport(GameObject content)
|
private void ConstructMainViewport(GameObject content)
|
||||||
{
|
{
|
||||||
var mainObj = UIFactory.CreateHorizontalGroup(content);
|
GameObject mainObj = UIFactory.CreateHorizontalGroup(content);
|
||||||
var mainGroup = mainObj.GetComponent<HorizontalLayoutGroup>();
|
HorizontalLayoutGroup mainGroup = mainObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
mainGroup.childControlHeight = true;
|
mainGroup.childControlHeight = true;
|
||||||
mainGroup.childControlWidth = true;
|
mainGroup.childControlWidth = true;
|
||||||
mainGroup.childForceExpandHeight = true;
|
mainGroup.childForceExpandHeight = true;
|
||||||
@ -248,6 +262,6 @@ namespace ExplorerBeta.UI.Main
|
|||||||
PageViewport = mainObj;
|
PageViewport = mainObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
using System;
|
namespace ExplorerBeta.UI.Main
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages
|
|
||||||
{
|
{
|
||||||
public class OptionsPage : BaseMenuPage
|
public class OptionsPage : MainMenu.Page
|
||||||
{
|
{
|
||||||
public override string Name => "Options / Misc";
|
public override string Name => "Options / Misc";
|
||||||
|
|
@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages
|
|
||||||
{
|
|
||||||
public abstract class BaseMenuPage
|
|
||||||
{
|
|
||||||
public abstract string Name { get; }
|
|
||||||
|
|
||||||
public GameObject Content;
|
|
||||||
public Button RefNavbarButton { get; set; }
|
|
||||||
|
|
||||||
public bool Enabled
|
|
||||||
{
|
|
||||||
get => Content?.activeSelf ?? false;
|
|
||||||
set => Content?.SetActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public abstract void Init();
|
|
||||||
public abstract void Update();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using ExplorerBeta;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
// Thanks to ManlyMarco for this
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages.Console
|
|
||||||
{
|
|
||||||
public struct AutoComplete
|
|
||||||
{
|
|
||||||
public string Full => Prefix + Addition;
|
|
||||||
|
|
||||||
public readonly string Prefix;
|
|
||||||
public readonly string Addition;
|
|
||||||
public readonly Contexts Context;
|
|
||||||
|
|
||||||
public Color TextColor => Context == Contexts.Namespace
|
|
||||||
? Color.gray
|
|
||||||
: Color.white;
|
|
||||||
|
|
||||||
public AutoComplete(string addition, string prefix, Contexts type)
|
|
||||||
{
|
|
||||||
Addition = addition;
|
|
||||||
Prefix = prefix;
|
|
||||||
Context = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Contexts
|
|
||||||
{
|
|
||||||
Namespace,
|
|
||||||
Other
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class AutoCompleteHelpers
|
|
||||||
{
|
|
||||||
public static HashSet<string> Namespaces => _namespaces ?? GetNamespaces();
|
|
||||||
private static HashSet<string> _namespaces;
|
|
||||||
|
|
||||||
private static HashSet<string> GetNamespaces()
|
|
||||||
{
|
|
||||||
var set = new HashSet<string>(
|
|
||||||
AppDomain.CurrentDomain.GetAssemblies()
|
|
||||||
.SelectMany(GetTypes)
|
|
||||||
.Where(x => x.IsPublic && !string.IsNullOrEmpty(x.Namespace))
|
|
||||||
.Select(x => x.Namespace));
|
|
||||||
|
|
||||||
return _namespaces = set;
|
|
||||||
|
|
||||||
IEnumerable<Type> GetTypes(Assembly asm) => asm.TryGetTypes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Mono.CSharp;
|
|
||||||
using UnityEngine;
|
|
||||||
using ExplorerBeta;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main
|
|
||||||
{
|
|
||||||
public class ScriptInteraction : InteractiveBase
|
|
||||||
{
|
|
||||||
public static void Log(object message)
|
|
||||||
{
|
|
||||||
ExplorerCore.Log(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static object CurrentTarget()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("TODO");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static object[] AllTargets()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("TODO");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Inspect(object obj)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("TODO");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Inspect(Type type)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException("TODO");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Help()
|
|
||||||
{
|
|
||||||
var msg = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n";
|
|
||||||
msg += " C# Console Help \r\n";
|
|
||||||
msg += "\r\n";
|
|
||||||
msg += "The following helper methods are available:\r\n";
|
|
||||||
msg += "\r\n";
|
|
||||||
msg += "void Log(object message)\r\n";
|
|
||||||
msg += " prints a message to the console window and debug log\r\n";
|
|
||||||
msg += " usage: Log(\"hello world\");\r\n";
|
|
||||||
msg += "\r\n";
|
|
||||||
|
|
||||||
ExplorerCore.Log(msg);
|
|
||||||
|
|
||||||
//ExplorerCore.Log("object CurrentTarget()");
|
|
||||||
//ExplorerCore.Log(" returns the target object of the current tab (in tab view mode only)");
|
|
||||||
//ExplorerCore.Log(" usage: var target = CurrentTarget();");
|
|
||||||
//ExplorerCore.Log("");
|
|
||||||
//ExplorerCore.Log("object[] AllTargets()");
|
|
||||||
//ExplorerCore.Log(" returns an object[] array containing all currently inspected objects");
|
|
||||||
//ExplorerCore.Log(" usage: var targets = AllTargets();");
|
|
||||||
//ExplorerCore.Log("");
|
|
||||||
//ExplorerCore.Log("void Inspect(object obj)");
|
|
||||||
//ExplorerCore.Log(" inspects the provided object in a new window.");
|
|
||||||
//ExplorerCore.Log(" usage: Inspect(Camera.main);");
|
|
||||||
//ExplorerCore.Log("");
|
|
||||||
//ExplorerCore.Log("void Inspect(Type type)");
|
|
||||||
//ExplorerCore.Log(" attempts to inspect the provided type with static-only reflection.");
|
|
||||||
//ExplorerCore.Log(" usage: Inspect(typeof(Camera));");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,311 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using ExplorerBeta;
|
|
||||||
using ExplorerBeta.UI;
|
|
||||||
using ExplorerBeta.UI.Main;
|
|
||||||
using ExplorerBeta.UI.Shared;
|
|
||||||
using ExplorerBeta.Unstrip.Resources;
|
|
||||||
using ExplorerBeta.Unstrip.Scenes;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.SceneManagement;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages
|
|
||||||
{
|
|
||||||
public class HomePage : BaseMenuPage
|
|
||||||
{
|
|
||||||
public override string Name => "Home";
|
|
||||||
|
|
||||||
private const float UPDATE_INTERVAL = 1f;
|
|
||||||
private float m_timeOfLastUpdate;
|
|
||||||
|
|
||||||
// ~~ Scene pane ~~
|
|
||||||
|
|
||||||
private Dropdown m_sceneDropdown;
|
|
||||||
|
|
||||||
private int m_currentSceneHandle;
|
|
||||||
private readonly Dictionary<string, int> m_sceneHandles = new Dictionary<string, int>();
|
|
||||||
|
|
||||||
private List<GameObject> m_currentObjectList = new List<GameObject>();
|
|
||||||
private int m_lastMaxIndex;
|
|
||||||
// todo
|
|
||||||
private GameObject m_selectedSceneObject;
|
|
||||||
|
|
||||||
private GameObject m_sceneListContent;
|
|
||||||
private readonly List<Text> m_sceneListTexts = new List<Text>();
|
|
||||||
|
|
||||||
// ~~ Inspector pane ~~ TODO
|
|
||||||
|
|
||||||
public override void Init()
|
|
||||||
{
|
|
||||||
ConstructMenu();
|
|
||||||
|
|
||||||
// Get DontDestroyOnLoad scene handle. I think it's always -12, but best to be safe.
|
|
||||||
var test = new GameObject();
|
|
||||||
GameObject.DontDestroyOnLoad(test);
|
|
||||||
StoreScenehandle(test.scene);
|
|
||||||
GameObject.Destroy(test);
|
|
||||||
|
|
||||||
RefreshActiveScenes();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void Update()
|
|
||||||
{
|
|
||||||
// TODO update inspector tabs
|
|
||||||
|
|
||||||
|
|
||||||
// update scene pane
|
|
||||||
|
|
||||||
if (Time.realtimeSinceStartup - m_timeOfLastUpdate < UPDATE_INTERVAL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_timeOfLastUpdate = Time.realtimeSinceStartup;
|
|
||||||
|
|
||||||
RefreshActiveScenes();
|
|
||||||
|
|
||||||
if (!m_selectedSceneObject)
|
|
||||||
{
|
|
||||||
SetSceneObjectList(SceneUnstrip.GetRootGameObjects(m_currentSceneHandle));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO refresh objects from inspected transform
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int StoreScenehandle(Scene scene)
|
|
||||||
{
|
|
||||||
if (!m_sceneHandles.ContainsKey(scene.name))
|
|
||||||
{
|
|
||||||
m_sceneHandles.Add(scene.name, scene.handle);
|
|
||||||
}
|
|
||||||
return scene.handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int GetSceneHandle(string sceneName)
|
|
||||||
{
|
|
||||||
if (!m_sceneHandles.ContainsKey(sceneName))
|
|
||||||
return -1;
|
|
||||||
else
|
|
||||||
return m_sceneHandles[sceneName];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetScene(string name)
|
|
||||||
{
|
|
||||||
var handle = GetSceneHandle(name);
|
|
||||||
|
|
||||||
if (handle == -1)
|
|
||||||
{
|
|
||||||
ExplorerCore.LogWarning($"Error: Could not get handle for scene '{name}'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_currentSceneHandle = handle;
|
|
||||||
|
|
||||||
var rootObjs = SceneUnstrip.GetRootGameObjects(handle);
|
|
||||||
|
|
||||||
SetSceneObjectList(rootObjs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool m_doneFirstSceneRefresh;
|
|
||||||
|
|
||||||
private void RefreshActiveScenes()
|
|
||||||
{
|
|
||||||
var activeScene = SceneManager.GetActiveScene().name;
|
|
||||||
var otherScenes = new List<string>();
|
|
||||||
|
|
||||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
|
||||||
{
|
|
||||||
var scene = SceneManager.GetSceneAt(i);
|
|
||||||
StoreScenehandle(scene);
|
|
||||||
|
|
||||||
if (m_doneFirstSceneRefresh || scene.name != activeScene)
|
|
||||||
otherScenes.Add(scene.name);
|
|
||||||
}
|
|
||||||
otherScenes.Add("DontDestroyOnLoad");
|
|
||||||
|
|
||||||
m_sceneDropdown.options.Clear();
|
|
||||||
|
|
||||||
if (!m_doneFirstSceneRefresh)
|
|
||||||
{
|
|
||||||
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
|
||||||
{
|
|
||||||
text = activeScene
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var scene in otherScenes)
|
|
||||||
{
|
|
||||||
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
|
||||||
{
|
|
||||||
text = scene
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_doneFirstSceneRefresh)
|
|
||||||
SetScene(activeScene);
|
|
||||||
|
|
||||||
m_doneFirstSceneRefresh = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SceneButtonClicked(int index)
|
|
||||||
{
|
|
||||||
var obj = m_currentObjectList[index];
|
|
||||||
|
|
||||||
ExplorerCore.Log("Clicked " + obj.name);
|
|
||||||
m_selectedSceneObject = obj;
|
|
||||||
|
|
||||||
// TODO ?
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetSceneObjectList(IEnumerable<GameObject> objects)
|
|
||||||
{
|
|
||||||
m_currentObjectList.Clear();
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
foreach (var obj in objects)
|
|
||||||
{
|
|
||||||
m_currentObjectList.Add(obj);
|
|
||||||
|
|
||||||
if (index >= m_sceneListTexts.Count)
|
|
||||||
{
|
|
||||||
AddSceneButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sceneListTexts[index].text = obj.name;
|
|
||||||
|
|
||||||
var parent = m_sceneListTexts[index].transform.parent.gameObject;
|
|
||||||
if (!parent.activeSelf)
|
|
||||||
parent.SetActive(true);
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
var origIndex = index;
|
|
||||||
while (index < m_sceneListTexts.Count && index < m_lastMaxIndex)
|
|
||||||
{
|
|
||||||
var obj = m_sceneListTexts[index].transform.parent.gameObject;
|
|
||||||
|
|
||||||
if (obj.activeSelf)
|
|
||||||
obj.SetActive(false);
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
m_lastMaxIndex = origIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region UI Construction
|
|
||||||
|
|
||||||
private void ConstructMenu()
|
|
||||||
{
|
|
||||||
var parent = MainMenu.Instance.PageViewport;
|
|
||||||
|
|
||||||
Content = UIFactory.CreateHorizontalGroup(parent);
|
|
||||||
var mainGroup = Content.GetComponent<HorizontalLayoutGroup>();
|
|
||||||
mainGroup.padding.left = 3;
|
|
||||||
mainGroup.padding.right = 3;
|
|
||||||
mainGroup.padding.top = 3;
|
|
||||||
mainGroup.padding.bottom = 3;
|
|
||||||
mainGroup.spacing = 5;
|
|
||||||
mainGroup.childForceExpandHeight = true;
|
|
||||||
mainGroup.childForceExpandWidth = true;
|
|
||||||
mainGroup.childControlHeight = true;
|
|
||||||
mainGroup.childControlWidth = true;
|
|
||||||
|
|
||||||
var leftPaneObj = UIFactory.CreateVerticalGroup(Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
|
||||||
var leftLayout = leftPaneObj.AddComponent<LayoutElement>();
|
|
||||||
leftLayout.minWidth = 350;
|
|
||||||
leftLayout.flexibleWidth = 0;
|
|
||||||
|
|
||||||
var leftGroup = leftPaneObj.GetComponent<VerticalLayoutGroup>();
|
|
||||||
leftGroup.padding.left = 8;
|
|
||||||
leftGroup.padding.right = 8;
|
|
||||||
leftGroup.padding.top = 8;
|
|
||||||
leftGroup.padding.bottom = 8;
|
|
||||||
leftGroup.spacing = 5;
|
|
||||||
leftGroup.childControlWidth = true;
|
|
||||||
leftGroup.childControlHeight = true;
|
|
||||||
leftGroup.childForceExpandWidth = false;
|
|
||||||
leftGroup.childForceExpandHeight = true;
|
|
||||||
|
|
||||||
var rightPaneObj = UIFactory.CreateVerticalGroup(Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
|
||||||
var rightLayout = rightPaneObj.AddComponent<LayoutElement>();
|
|
||||||
rightLayout.flexibleWidth = 999999;
|
|
||||||
|
|
||||||
var rightGroup = rightPaneObj.GetComponent<VerticalLayoutGroup>();
|
|
||||||
rightGroup.childForceExpandHeight = true;
|
|
||||||
rightGroup.childForceExpandWidth = true;
|
|
||||||
rightGroup.childControlHeight = true;
|
|
||||||
rightGroup.childControlWidth = true;
|
|
||||||
|
|
||||||
ConstructScenePane(leftPaneObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ConstructScenePane(GameObject leftPane)
|
|
||||||
{
|
|
||||||
var activeSceneLabelObj = UIFactory.CreateLabel(leftPane, TextAnchor.UpperLeft);
|
|
||||||
var activeSceneLabel = activeSceneLabelObj.GetComponent<Text>();
|
|
||||||
activeSceneLabel.text = "Scene Explorer";
|
|
||||||
activeSceneLabel.fontSize = 25;
|
|
||||||
var activeSceneLayout = activeSceneLabelObj.AddComponent<LayoutElement>();
|
|
||||||
activeSceneLayout.minHeight = 30;
|
|
||||||
activeSceneLayout.flexibleHeight = 0;
|
|
||||||
|
|
||||||
var sceneDropdownObj = UIFactory.CreateDropdown(leftPane, out m_sceneDropdown);
|
|
||||||
var dropdownLayout = sceneDropdownObj.AddComponent<LayoutElement>();
|
|
||||||
dropdownLayout.minHeight = 40;
|
|
||||||
dropdownLayout.flexibleHeight = 0;
|
|
||||||
dropdownLayout.minWidth = 320;
|
|
||||||
dropdownLayout.flexibleWidth = 2;
|
|
||||||
|
|
||||||
#if CPP
|
|
||||||
m_sceneDropdown.onValueChanged.AddListener(new Action<int>((int val) => { SetSceneFromDropdown(val); }));
|
|
||||||
#else
|
|
||||||
m_sceneDropdown.onValueChanged.AddListener((int val) => { SetSceneFromDropdown(val); });
|
|
||||||
#endif
|
|
||||||
void SetSceneFromDropdown(int val)
|
|
||||||
{
|
|
||||||
var scene = m_sceneDropdown.options[val].text;
|
|
||||||
SetScene(scene);
|
|
||||||
}
|
|
||||||
|
|
||||||
var scrollTest = UIFactory.CreateScrollView(leftPane, out m_sceneListContent, new Color(0.15f, 0.15f, 0.15f, 1));
|
|
||||||
for (int i = 0; i < 50; i++)
|
|
||||||
{
|
|
||||||
AddSceneButton();
|
|
||||||
}
|
|
||||||
m_lastMaxIndex = 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddSceneButton()
|
|
||||||
{
|
|
||||||
var obj = UIFactory.CreateButton(m_sceneListContent);
|
|
||||||
|
|
||||||
var btn = obj.GetComponent<Button>();
|
|
||||||
var colors = btn.colors;
|
|
||||||
colors.normalColor = new Color(0.15f, 0.15f, 0.15f, 1);
|
|
||||||
btn.colors = colors;
|
|
||||||
|
|
||||||
int thisIndex = m_sceneListTexts.Count();
|
|
||||||
|
|
||||||
#if CPP
|
|
||||||
btn.onClick.AddListener(new Action(() => { SceneButtonClicked(thisIndex); }));
|
|
||||||
#else
|
|
||||||
btn.onClick.AddListener(() => { SceneButtonClicked(thisIndex); });
|
|
||||||
#endif
|
|
||||||
|
|
||||||
var text = obj.GetComponentInChildren<Text>();
|
|
||||||
text.text = "button " + thisIndex;
|
|
||||||
text.alignment = TextAnchor.MiddleLeft;
|
|
||||||
|
|
||||||
m_sceneListTexts.Add(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo construct inspector pane
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using ExplorerBeta.Input;
|
using ExplorerBeta.Input;
|
||||||
using ExplorerBeta.Helpers;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
#if CPP
|
#if CPP
|
||||||
using ExplorerBeta.Unstrip.ImageConversion;
|
using ExplorerBeta.Unstrip.ImageConversion;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ExplorerBeta.UI
|
namespace ExplorerBeta.UI.Main
|
||||||
{
|
{
|
||||||
// Handles dragging and resizing for the main explorer window.
|
// Handles dragging and resizing for the main explorer window.
|
||||||
|
|
||||||
@ -42,11 +38,11 @@ namespace ExplorerBeta.UI
|
|||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
var rawMousePos = InputManager.MousePosition;
|
Vector3 rawMousePos = InputManager.MousePosition;
|
||||||
|
|
||||||
ResizeTypes type;
|
ResizeTypes type;
|
||||||
var resizePos = Panel.InverseTransformPoint(rawMousePos);
|
Vector3 resizePos = Panel.InverseTransformPoint(rawMousePos);
|
||||||
var dragPos = DragableArea.InverseTransformPoint(rawMousePos);
|
Vector3 dragPos = DragableArea.InverseTransformPoint(rawMousePos);
|
||||||
|
|
||||||
if (WasHoveringResize)
|
if (WasHoveringResize)
|
||||||
{
|
{
|
||||||
@ -65,7 +61,9 @@ namespace ExplorerBeta.UI
|
|||||||
{
|
{
|
||||||
type = GetResizeType(resizePos);
|
type = GetResizeType(resizePos);
|
||||||
if (type != ResizeTypes.NONE)
|
if (type != ResizeTypes.NONE)
|
||||||
|
{
|
||||||
OnBeginResize(type);
|
OnBeginResize(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If mouse still pressed from last frame
|
// If mouse still pressed from last frame
|
||||||
@ -104,7 +102,7 @@ namespace ExplorerBeta.UI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region DRAGGING
|
#region DRAGGING
|
||||||
|
|
||||||
public RectTransform DragableArea { get; set; }
|
public RectTransform DragableArea { get; set; }
|
||||||
public bool WasDragging { get; set; }
|
public bool WasDragging { get; set; }
|
||||||
@ -118,11 +116,11 @@ namespace ExplorerBeta.UI
|
|||||||
|
|
||||||
public void OnDrag()
|
public void OnDrag()
|
||||||
{
|
{
|
||||||
var diff = InputManager.MousePosition - m_lastDragPosition;
|
Vector3 diff = InputManager.MousePosition - m_lastDragPosition;
|
||||||
m_lastDragPosition = InputManager.MousePosition;
|
m_lastDragPosition = InputManager.MousePosition;
|
||||||
|
|
||||||
var pos = Panel.localPosition;
|
Vector3 pos = Panel.localPosition;
|
||||||
var z = pos.z;
|
float z = pos.z;
|
||||||
pos += diff;
|
pos += diff;
|
||||||
pos.z = z;
|
pos.z = z;
|
||||||
Panel.localPosition = pos;
|
Panel.localPosition = pos;
|
||||||
@ -134,9 +132,9 @@ namespace ExplorerBeta.UI
|
|||||||
UpdateResizeCache();
|
UpdateResizeCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region RESIZE
|
#region RESIZE
|
||||||
|
|
||||||
private const int RESIZE_THICKNESS = 10;
|
private const int RESIZE_THICKNESS = 10;
|
||||||
|
|
||||||
@ -161,14 +159,14 @@ namespace ExplorerBeta.UI
|
|||||||
[Flags]
|
[Flags]
|
||||||
public enum ResizeTypes
|
public enum ResizeTypes
|
||||||
{
|
{
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
Top = 1,
|
Top = 1,
|
||||||
Left = 2,
|
Left = 2,
|
||||||
Right = 4,
|
Right = 4,
|
||||||
Bottom = 8,
|
Bottom = 8,
|
||||||
TopLeft = Top | Left,
|
TopLeft = Top | Left,
|
||||||
TopRight = Top | Right,
|
TopRight = Top | Right,
|
||||||
BottomLeft = Bottom | Left,
|
BottomLeft = Bottom | Left,
|
||||||
BottomRight = Bottom | Right,
|
BottomRight = Bottom | Right,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +180,7 @@ namespace ExplorerBeta.UI
|
|||||||
// to give a bit of buffer and make it easier to use.
|
// to give a bit of buffer and make it easier to use.
|
||||||
|
|
||||||
// outer rect is the outer-most bounds of our resize area
|
// outer rect is the outer-most bounds of our resize area
|
||||||
var outer = new Rect(Panel.rect.x - halfThick,
|
Rect outer = new Rect(Panel.rect.x - halfThick,
|
||||||
Panel.rect.y - halfThick,
|
Panel.rect.y - halfThick,
|
||||||
Panel.rect.width + dblThick,
|
Panel.rect.width + dblThick,
|
||||||
Panel.rect.height + dblThick);
|
Panel.rect.height + dblThick);
|
||||||
@ -213,14 +211,22 @@ namespace ExplorerBeta.UI
|
|||||||
int mask = 0;
|
int mask = 0;
|
||||||
|
|
||||||
if (m_resizeMask[ResizeTypes.Top].Contains(mousePos))
|
if (m_resizeMask[ResizeTypes.Top].Contains(mousePos))
|
||||||
|
{
|
||||||
mask |= (int)ResizeTypes.Top;
|
mask |= (int)ResizeTypes.Top;
|
||||||
|
}
|
||||||
else if (m_resizeMask[ResizeTypes.Bottom].Contains(mousePos))
|
else if (m_resizeMask[ResizeTypes.Bottom].Contains(mousePos))
|
||||||
|
{
|
||||||
mask |= (int)ResizeTypes.Bottom;
|
mask |= (int)ResizeTypes.Bottom;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_resizeMask[ResizeTypes.Left].Contains(mousePos))
|
if (m_resizeMask[ResizeTypes.Left].Contains(mousePos))
|
||||||
|
{
|
||||||
mask |= (int)ResizeTypes.Left;
|
mask |= (int)ResizeTypes.Left;
|
||||||
|
}
|
||||||
else if (m_resizeMask[ResizeTypes.Right].Contains(mousePos))
|
else if (m_resizeMask[ResizeTypes.Right].Contains(mousePos))
|
||||||
|
{
|
||||||
mask |= (int)ResizeTypes.Right;
|
mask |= (int)ResizeTypes.Right;
|
||||||
|
}
|
||||||
|
|
||||||
return (ResizeTypes)mask;
|
return (ResizeTypes)mask;
|
||||||
}
|
}
|
||||||
@ -228,7 +234,9 @@ namespace ExplorerBeta.UI
|
|||||||
public void OnHoverResize(ResizeTypes resizeType)
|
public void OnHoverResize(ResizeTypes resizeType)
|
||||||
{
|
{
|
||||||
if (WasHoveringResize && m_lastResizeHoverType == resizeType)
|
if (WasHoveringResize && m_lastResizeHoverType == resizeType)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// we are entering resize, or the resize type has changed.
|
// we are entering resize, or the resize type has changed.
|
||||||
|
|
||||||
@ -252,7 +260,7 @@ namespace ExplorerBeta.UI
|
|||||||
iconRotation = 135f; break;
|
iconRotation = 135f; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rot = m_resizeCursorImage.transform.rotation;
|
Quaternion rot = m_resizeCursorImage.transform.rotation;
|
||||||
rot.eulerAngles = new Vector3(0, 0, iconRotation);
|
rot.eulerAngles = new Vector3(0, 0, iconRotation);
|
||||||
m_resizeCursorImage.transform.rotation = rot;
|
m_resizeCursorImage.transform.rotation = rot;
|
||||||
|
|
||||||
@ -263,9 +271,11 @@ namespace ExplorerBeta.UI
|
|||||||
private void UpdateHoverImagePos()
|
private void UpdateHoverImagePos()
|
||||||
{
|
{
|
||||||
if (!m_resizeCursorImage)
|
if (!m_resizeCursorImage)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var t = UIManager.CanvasRoot.GetComponent<RectTransform>();
|
RectTransform t = UIManager.CanvasRoot.GetComponent<RectTransform>();
|
||||||
m_resizeCursorImage.transform.localPosition = t.InverseTransformPoint(InputManager.MousePosition);
|
m_resizeCursorImage.transform.localPosition = t.InverseTransformPoint(InputManager.MousePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,35 +294,35 @@ namespace ExplorerBeta.UI
|
|||||||
|
|
||||||
public void OnResize()
|
public void OnResize()
|
||||||
{
|
{
|
||||||
var mousePos = InputManager.MousePosition;
|
Vector3 mousePos = InputManager.MousePosition;
|
||||||
var diff = m_lastResizePos - (Vector2)mousePos;
|
Vector2 diff = m_lastResizePos - (Vector2)mousePos;
|
||||||
m_lastResizePos = mousePos;
|
m_lastResizePos = mousePos;
|
||||||
|
|
||||||
var diffX = (float)((decimal)diff.x / Screen.width);
|
float diffX = (float)((decimal)diff.x / Screen.width);
|
||||||
var diffY = (float)((decimal)diff.y / Screen.height);
|
float diffY = (float)((decimal)diff.y / Screen.height);
|
||||||
|
|
||||||
if (m_currentResizeType.HasFlag(ResizeTypes.Left))
|
if (m_currentResizeType.HasFlag(ResizeTypes.Left))
|
||||||
{
|
{
|
||||||
var anch = Panel.anchorMin;
|
Vector2 anch = Panel.anchorMin;
|
||||||
anch.x -= diffX;
|
anch.x -= diffX;
|
||||||
Panel.anchorMin = anch;
|
Panel.anchorMin = anch;
|
||||||
}
|
}
|
||||||
else if (m_currentResizeType.HasFlag(ResizeTypes.Right))
|
else if (m_currentResizeType.HasFlag(ResizeTypes.Right))
|
||||||
{
|
{
|
||||||
var anch = Panel.anchorMax;
|
Vector2 anch = Panel.anchorMax;
|
||||||
anch.x -= diffX;
|
anch.x -= diffX;
|
||||||
Panel.anchorMax = anch;
|
Panel.anchorMax = anch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_currentResizeType.HasFlag(ResizeTypes.Top))
|
if (m_currentResizeType.HasFlag(ResizeTypes.Top))
|
||||||
{
|
{
|
||||||
var anch = Panel.anchorMax;
|
Vector2 anch = Panel.anchorMax;
|
||||||
anch.y -= diffY;
|
anch.y -= diffY;
|
||||||
Panel.anchorMax = anch;
|
Panel.anchorMax = anch;
|
||||||
}
|
}
|
||||||
else if (m_currentResizeType.HasFlag(ResizeTypes.Bottom))
|
else if (m_currentResizeType.HasFlag(ResizeTypes.Bottom))
|
||||||
{
|
{
|
||||||
var anch = Panel.anchorMin;
|
Vector2 anch = Panel.anchorMin;
|
||||||
anch.y -= diffY;
|
anch.y -= diffY;
|
||||||
Panel.anchorMin = anch;
|
Panel.anchorMin = anch;
|
||||||
}
|
}
|
||||||
@ -326,28 +336,28 @@ namespace ExplorerBeta.UI
|
|||||||
|
|
||||||
private void LoadCursorImage()
|
private void LoadCursorImage()
|
||||||
{
|
{
|
||||||
var path = @"Mods\Explorer\cursor.png";
|
string path = @"Mods\Explorer\cursor.png";
|
||||||
var data = File.ReadAllBytes(path);
|
byte[] data = File.ReadAllBytes(path);
|
||||||
|
|
||||||
var tex = new Texture2D(32, 32);
|
Texture2D tex = new Texture2D(32, 32);
|
||||||
tex.LoadImage(data, false);
|
tex.LoadImage(data, false);
|
||||||
UnityEngine.Object.DontDestroyOnLoad(tex);
|
UnityEngine.Object.DontDestroyOnLoad(tex);
|
||||||
|
|
||||||
var sprite = UIManager.CreateSprite(tex);
|
Sprite sprite = UIManager.CreateSprite(tex);
|
||||||
UnityEngine.Object.DontDestroyOnLoad(sprite);
|
UnityEngine.Object.DontDestroyOnLoad(sprite);
|
||||||
|
|
||||||
m_resizeCursorImage = new GameObject("ResizeCursorImage");
|
m_resizeCursorImage = new GameObject("ResizeCursorImage");
|
||||||
m_resizeCursorImage.transform.SetParent(UIManager.CanvasRoot.transform);
|
m_resizeCursorImage.transform.SetParent(UIManager.CanvasRoot.transform);
|
||||||
|
|
||||||
var image = m_resizeCursorImage.AddComponent<Image>();
|
Image image = m_resizeCursorImage.AddComponent<Image>();
|
||||||
image.sprite = sprite;
|
image.sprite = sprite;
|
||||||
var rect = image.transform.GetComponent<RectTransform>();
|
RectTransform rect = image.transform.GetComponent<RectTransform>();
|
||||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 32);
|
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 32);
|
||||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 32);
|
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 32);
|
||||||
|
|
||||||
m_resizeCursorImage.SetActive(false);
|
m_resizeCursorImage.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
478
src/UI/Main/SceneExplorer.cs
Normal file
478
src/UI/Main/SceneExplorer.cs
Normal file
@ -0,0 +1,478 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using ExplorerBeta.Helpers;
|
||||||
|
using ExplorerBeta.UI.Main.Inspectors;
|
||||||
|
using ExplorerBeta.UI.Shared;
|
||||||
|
using ExplorerBeta.Unstrip.Scenes;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
|
||||||
|
namespace ExplorerBeta.UI.Main
|
||||||
|
{
|
||||||
|
public class SceneExplorer
|
||||||
|
{
|
||||||
|
public static SceneExplorer Instance;
|
||||||
|
|
||||||
|
public SceneExplorer() { Instance = this; }
|
||||||
|
|
||||||
|
private const float UPDATE_INTERVAL = 1f;
|
||||||
|
private float m_timeOfLastSceneUpdate;
|
||||||
|
|
||||||
|
private bool m_doneFirstSceneRefresh;
|
||||||
|
private GameObject m_selectedSceneObject;
|
||||||
|
private int m_currentSceneHandle;
|
||||||
|
private int m_lastCount;
|
||||||
|
|
||||||
|
public PageHandler m_sceneListPageHandler;
|
||||||
|
|
||||||
|
private GameObject[] m_allSceneListObjects = new GameObject[0];
|
||||||
|
private readonly List<GameObject> m_sceneShortList = new List<GameObject>();
|
||||||
|
private readonly List<Text> m_sceneListTexts = new List<Text>();
|
||||||
|
private readonly List<bool> m_sceneListActiveStates = new List<bool>();
|
||||||
|
|
||||||
|
private GameObject m_sceneListCanvas;
|
||||||
|
private Dropdown m_sceneDropdown;
|
||||||
|
private Text m_scenePathText;
|
||||||
|
private GameObject m_mainInspectBtn;
|
||||||
|
private GameObject m_backButtonObj;
|
||||||
|
|
||||||
|
private readonly Dictionary<string, int> m_sceneHandles = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
// Get DontDestroyOnLoad scene handle. I think it's always -12, but best to be safe.
|
||||||
|
GameObject test = new GameObject();
|
||||||
|
GameObject.DontDestroyOnLoad(test);
|
||||||
|
StoreScenehandle(test.scene);
|
||||||
|
GameObject.Destroy(test);
|
||||||
|
|
||||||
|
RefreshActiveScenes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (Time.realtimeSinceStartup - m_timeOfLastSceneUpdate < UPDATE_INTERVAL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshActiveScenes();
|
||||||
|
|
||||||
|
if (!m_selectedSceneObject)
|
||||||
|
{
|
||||||
|
if (m_currentSceneHandle != -1)
|
||||||
|
{
|
||||||
|
SetSceneObjectList(SceneUnstrip.GetRootGameObjects(m_currentSceneHandle));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RefreshSelectedSceneObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int StoreScenehandle(Scene scene)
|
||||||
|
{
|
||||||
|
if (!m_sceneHandles.ContainsKey(scene.name))
|
||||||
|
{
|
||||||
|
m_sceneHandles.Add(scene.name, scene.handle);
|
||||||
|
}
|
||||||
|
return scene.handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetSceneHandle(string sceneName)
|
||||||
|
{
|
||||||
|
if (!m_sceneHandles.ContainsKey(sceneName))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_sceneHandles[sceneName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void OnSceneChange()
|
||||||
|
{
|
||||||
|
m_doneFirstSceneRefresh = false;
|
||||||
|
RefreshActiveScenes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshActiveScenes()
|
||||||
|
{
|
||||||
|
string mainActiveScene = SceneManager.GetActiveScene().name;
|
||||||
|
List<string> otherScenes = new List<string>();
|
||||||
|
List<int> validHandles = new List<int>();
|
||||||
|
|
||||||
|
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||||
|
{
|
||||||
|
Scene scene = SceneManager.GetSceneAt(i);
|
||||||
|
|
||||||
|
if (scene == null || string.IsNullOrEmpty(scene.name))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
StoreScenehandle(scene);
|
||||||
|
validHandles.Add(scene.handle);
|
||||||
|
|
||||||
|
if (m_doneFirstSceneRefresh || scene.name != mainActiveScene)
|
||||||
|
{
|
||||||
|
otherScenes.Add(scene.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
otherScenes.Add("DontDestroyOnLoad");
|
||||||
|
validHandles.Add(GetSceneHandle("DontDestroyOnLoad"));
|
||||||
|
|
||||||
|
m_sceneDropdown.options.Clear();
|
||||||
|
|
||||||
|
if (!m_doneFirstSceneRefresh)
|
||||||
|
{
|
||||||
|
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
||||||
|
{
|
||||||
|
text = mainActiveScene
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string scene in otherScenes)
|
||||||
|
{
|
||||||
|
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
||||||
|
{
|
||||||
|
text = scene
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_doneFirstSceneRefresh || !validHandles.Contains(m_currentSceneHandle))
|
||||||
|
{
|
||||||
|
SetScene(mainActiveScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_doneFirstSceneRefresh = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetScene(string name) => SetScene(GetSceneHandle(name));
|
||||||
|
|
||||||
|
public void SetScene(int handle)
|
||||||
|
{
|
||||||
|
if (handle == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentSceneHandle = handle;
|
||||||
|
|
||||||
|
GameObject[] rootObjs = SceneUnstrip.GetRootGameObjects(handle);
|
||||||
|
SetSceneObjectList(rootObjs);
|
||||||
|
|
||||||
|
m_selectedSceneObject = null;
|
||||||
|
|
||||||
|
if (m_backButtonObj.activeSelf)
|
||||||
|
{
|
||||||
|
m_backButtonObj.SetActive(false);
|
||||||
|
m_mainInspectBtn.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_scenePathText.text = "Scene root:";
|
||||||
|
//m_scenePathText.ForceMeshUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSceneListObject(GameObject obj)
|
||||||
|
{
|
||||||
|
m_scenePathText.text = obj.name;
|
||||||
|
//m_scenePathText.ForceMeshUpdate();
|
||||||
|
|
||||||
|
m_selectedSceneObject = obj;
|
||||||
|
|
||||||
|
RefreshSelectedSceneObject();
|
||||||
|
|
||||||
|
if (!m_backButtonObj.activeSelf)
|
||||||
|
{
|
||||||
|
m_backButtonObj.SetActive(true);
|
||||||
|
m_mainInspectBtn.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SceneListObjectClicked(int index)
|
||||||
|
{
|
||||||
|
if (index >= m_sceneShortList.Count || !m_sceneShortList[index])
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetSceneListObject(m_sceneShortList[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSceneListPageTurn()
|
||||||
|
{
|
||||||
|
SetSceneObjectList(m_allSceneListObjects);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshSelectedSceneObject()
|
||||||
|
{
|
||||||
|
GameObject[] list = new GameObject[m_selectedSceneObject.transform.childCount];
|
||||||
|
for (int i = 0; i < m_selectedSceneObject.transform.childCount; i++)
|
||||||
|
{
|
||||||
|
list[i] = m_selectedSceneObject.transform.GetChild(i).gameObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetSceneObjectList(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetSceneObjectList(GameObject[] objects)
|
||||||
|
{
|
||||||
|
m_timeOfLastSceneUpdate = Time.realtimeSinceStartup;
|
||||||
|
|
||||||
|
m_allSceneListObjects = objects;
|
||||||
|
m_sceneListPageHandler.ListCount = objects.Length;
|
||||||
|
|
||||||
|
int startIndex = m_sceneListPageHandler.IndexOffset;
|
||||||
|
|
||||||
|
int newCount = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < m_sceneListPageHandler.ItemsPerPage; i++)
|
||||||
|
{
|
||||||
|
newCount++;
|
||||||
|
|
||||||
|
// still updating from gameobject list.
|
||||||
|
// check first if the reference has changed for this index.
|
||||||
|
|
||||||
|
if (i + startIndex >= objects.Length)
|
||||||
|
{
|
||||||
|
// execeeded actual list, but not yet reached previous limit.
|
||||||
|
// disable remaining buttons.
|
||||||
|
|
||||||
|
if (i > m_lastCount || i >= m_sceneListTexts.Count)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject obj = m_sceneListTexts[i].transform.parent.parent.gameObject;
|
||||||
|
if (obj.activeSelf)
|
||||||
|
{
|
||||||
|
obj.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GameObject obj = objects[i + startIndex];
|
||||||
|
|
||||||
|
if (i >= m_sceneShortList.Count)
|
||||||
|
{
|
||||||
|
m_sceneShortList.Add(obj);
|
||||||
|
if (i >= m_sceneListTexts.Count)
|
||||||
|
{
|
||||||
|
AddSceneButton();
|
||||||
|
m_sceneListActiveStates.Add(obj.activeSelf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_sceneShortList[i] = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sceneListTexts[i].text = obj.name;
|
||||||
|
m_sceneListTexts[i].color = obj.activeSelf ? Color.green : Color.red;
|
||||||
|
|
||||||
|
GameObject parent = m_sceneListTexts[i].transform.parent.parent.gameObject;
|
||||||
|
if (!parent.activeSelf)
|
||||||
|
{
|
||||||
|
parent.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_lastCount = newCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region SCENE PANE
|
||||||
|
|
||||||
|
public void ConstructScenePane()
|
||||||
|
{
|
||||||
|
GameObject leftPane = UIFactory.CreateVerticalGroup(HomePage.Instance.Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
||||||
|
LayoutElement leftLayout = leftPane.AddComponent<LayoutElement>();
|
||||||
|
leftLayout.minWidth = 350;
|
||||||
|
leftLayout.flexibleWidth = 0;
|
||||||
|
|
||||||
|
VerticalLayoutGroup leftGroup = leftPane.GetComponent<VerticalLayoutGroup>();
|
||||||
|
leftGroup.padding.left = 8;
|
||||||
|
leftGroup.padding.right = 8;
|
||||||
|
leftGroup.padding.top = 8;
|
||||||
|
leftGroup.padding.bottom = 8;
|
||||||
|
leftGroup.spacing = 5;
|
||||||
|
leftGroup.childControlWidth = true;
|
||||||
|
leftGroup.childControlHeight = true;
|
||||||
|
leftGroup.childForceExpandWidth = true;
|
||||||
|
leftGroup.childForceExpandHeight = true;
|
||||||
|
|
||||||
|
GameObject titleObj = UIFactory.CreateLabel(leftPane, TextAnchor.UpperLeft);
|
||||||
|
Text titleLabel = titleObj.GetComponent<Text>();
|
||||||
|
titleLabel.text = "Scene Explorer";
|
||||||
|
titleLabel.fontSize = 20;
|
||||||
|
LayoutElement titleLayout = titleObj.AddComponent<LayoutElement>();
|
||||||
|
titleLayout.minHeight = 30;
|
||||||
|
titleLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
|
GameObject sceneDropdownObj = UIFactory.CreateDropdown(leftPane, out m_sceneDropdown);
|
||||||
|
LayoutElement dropdownLayout = sceneDropdownObj.AddComponent<LayoutElement>();
|
||||||
|
dropdownLayout.minHeight = 40;
|
||||||
|
dropdownLayout.flexibleHeight = 0;
|
||||||
|
dropdownLayout.minWidth = 320;
|
||||||
|
dropdownLayout.flexibleWidth = 2;
|
||||||
|
|
||||||
|
#if CPP
|
||||||
|
m_sceneDropdown.onValueChanged.AddListener(new Action<int>((int val) => { SetSceneFromDropdown(val); }));
|
||||||
|
#else
|
||||||
|
m_sceneDropdown.onValueChanged.AddListener((int val) => { SetSceneFromDropdown(val); });
|
||||||
|
#endif
|
||||||
|
void SetSceneFromDropdown(int val)
|
||||||
|
{
|
||||||
|
string scene = m_sceneDropdown.options[val].text;
|
||||||
|
SetScene(scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject scenePathGroupObj = UIFactory.CreateHorizontalGroup(leftPane, new Color(1, 1, 1, 0f));
|
||||||
|
HorizontalLayoutGroup scenePathGroup = scenePathGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
|
scenePathGroup.childControlHeight = true;
|
||||||
|
scenePathGroup.childControlWidth = true;
|
||||||
|
scenePathGroup.childForceExpandHeight = true;
|
||||||
|
scenePathGroup.childForceExpandWidth = true;
|
||||||
|
scenePathGroup.spacing = 5;
|
||||||
|
LayoutElement scenePathLayout = scenePathGroupObj.AddComponent<LayoutElement>();
|
||||||
|
scenePathLayout.minHeight = 20;
|
||||||
|
scenePathLayout.minWidth = 335;
|
||||||
|
scenePathLayout.flexibleWidth = 0;
|
||||||
|
|
||||||
|
m_backButtonObj = UIFactory.CreateButton(scenePathGroupObj);
|
||||||
|
Text backButtonText = m_backButtonObj.GetComponentInChildren<Text>();
|
||||||
|
backButtonText.text = "<";
|
||||||
|
LayoutElement backButtonLayout = m_backButtonObj.AddComponent<LayoutElement>();
|
||||||
|
backButtonLayout.minWidth = 40;
|
||||||
|
backButtonLayout.flexibleWidth = 0;
|
||||||
|
Button backButton = m_backButtonObj.GetComponent<Button>();
|
||||||
|
#if CPP
|
||||||
|
backButton.onClick.AddListener(new Action(() => { SetSceneObjectParent(); }));
|
||||||
|
#else
|
||||||
|
backButton.onClick.AddListener(() => { SetSceneObjectParent(); });
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void SetSceneObjectParent()
|
||||||
|
{
|
||||||
|
if (!m_selectedSceneObject || !m_selectedSceneObject.transform.parent)
|
||||||
|
{
|
||||||
|
m_selectedSceneObject = null;
|
||||||
|
SetScene(m_currentSceneHandle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetSceneListObject(m_selectedSceneObject.transform.parent.gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject scenePathLabel = UIFactory.CreateHorizontalGroup(scenePathGroupObj);
|
||||||
|
Image image = scenePathLabel.GetComponent<Image>();
|
||||||
|
image.color = Color.white;
|
||||||
|
|
||||||
|
LayoutElement scenePathLabelLayout = scenePathLabel.AddComponent<LayoutElement>();
|
||||||
|
scenePathLabelLayout.minWidth = 210;
|
||||||
|
scenePathLabelLayout.minHeight = 20;
|
||||||
|
scenePathLabelLayout.flexibleHeight = 0;
|
||||||
|
scenePathLabelLayout.flexibleWidth = 120;
|
||||||
|
|
||||||
|
scenePathLabel.AddComponent<Mask>().showMaskGraphic = false;
|
||||||
|
|
||||||
|
GameObject scenePathLabelText = UIFactory.CreateLabel(scenePathLabel, TextAnchor.MiddleLeft);
|
||||||
|
m_scenePathText = scenePathLabelText.GetComponent<Text>();
|
||||||
|
m_scenePathText.text = "Scene root:";
|
||||||
|
m_scenePathText.fontSize = 15;
|
||||||
|
m_scenePathText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||||
|
|
||||||
|
LayoutElement textLayout = scenePathLabelText.gameObject.AddComponent<LayoutElement>();
|
||||||
|
textLayout.minWidth = 210;
|
||||||
|
textLayout.flexibleWidth = 120;
|
||||||
|
textLayout.minHeight = 20;
|
||||||
|
textLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
|
m_mainInspectBtn = UIFactory.CreateButton(scenePathGroupObj);
|
||||||
|
Text inspectButtonText = m_mainInspectBtn.GetComponentInChildren<Text>();
|
||||||
|
inspectButtonText.text = "Inspect";
|
||||||
|
LayoutElement inspectButtonLayout = m_mainInspectBtn.AddComponent<LayoutElement>();
|
||||||
|
inspectButtonLayout.minWidth = 65;
|
||||||
|
inspectButtonLayout.flexibleWidth = 0;
|
||||||
|
Button inspectButton = m_mainInspectBtn.GetComponent<Button>();
|
||||||
|
inspectButton.onClick.AddListener(new Action(() => { InspectorManager.Instance.Inspect(m_selectedSceneObject); }));
|
||||||
|
|
||||||
|
GameObject scrollObj = UIFactory.CreateScrollView(leftPane, out m_sceneListCanvas, new Color(0.15f, 0.15f, 0.15f, 1));
|
||||||
|
Scrollbar scroll = scrollObj.transform.Find("Scrollbar Vertical").GetComponent<Scrollbar>();
|
||||||
|
ColorBlock colors = scroll.colors;
|
||||||
|
colors.normalColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
|
||||||
|
scroll.colors = colors;
|
||||||
|
|
||||||
|
VerticalLayoutGroup sceneGroup = m_sceneListCanvas.GetComponent<VerticalLayoutGroup>();
|
||||||
|
sceneGroup.childControlHeight = true;
|
||||||
|
sceneGroup.spacing = 2;
|
||||||
|
|
||||||
|
m_sceneListPageHandler = new PageHandler();
|
||||||
|
m_sceneListPageHandler.ConstructUI(leftPane);
|
||||||
|
m_sceneListPageHandler.OnPageChanged += OnSceneListPageTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddSceneButton()
|
||||||
|
{
|
||||||
|
int thisIndex = m_sceneListTexts.Count();
|
||||||
|
|
||||||
|
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_sceneListCanvas, new Color(0.15f, 0.15f, 0.15f));
|
||||||
|
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||||
|
btnGroup.childForceExpandWidth = true;
|
||||||
|
btnGroup.childControlWidth = true;
|
||||||
|
btnGroup.childForceExpandHeight = false;
|
||||||
|
btnGroup.childControlHeight = true;
|
||||||
|
LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>();
|
||||||
|
btnLayout.flexibleWidth = 320;
|
||||||
|
btnLayout.minHeight = 25;
|
||||||
|
btnLayout.flexibleHeight = 0;
|
||||||
|
btnGroupObj.AddComponent<Mask>();
|
||||||
|
|
||||||
|
GameObject mainButtonObj = UIFactory.CreateButton(btnGroupObj);
|
||||||
|
LayoutElement mainBtnLayout = mainButtonObj.AddComponent<LayoutElement>();
|
||||||
|
mainBtnLayout.minHeight = 25;
|
||||||
|
mainBtnLayout.flexibleHeight = 0;
|
||||||
|
mainBtnLayout.minWidth = 240;
|
||||||
|
mainBtnLayout.flexibleWidth = 0;
|
||||||
|
Button mainBtn = mainButtonObj.GetComponent<Button>();
|
||||||
|
ColorBlock mainColors = mainBtn.colors;
|
||||||
|
mainColors.normalColor = new Color(0, 0, 0, 0);
|
||||||
|
mainColors.highlightedColor = new Color(0.3f, 0.3f, 0.3f, 1);
|
||||||
|
mainBtn.colors = mainColors;
|
||||||
|
#if CPP
|
||||||
|
mainBtn.onClick.AddListener(new Action(() => { SceneListObjectClicked(thisIndex); }));
|
||||||
|
#else
|
||||||
|
btn.onClick.AddListener(() => { SceneButtonClicked(thisIndex); });
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Text mainText = mainButtonObj.GetComponentInChildren<Text>();
|
||||||
|
mainText.alignment = TextAnchor.MiddleLeft;
|
||||||
|
m_sceneListTexts.Add(mainText);
|
||||||
|
|
||||||
|
GameObject inspectBtnObj = UIFactory.CreateButton(btnGroupObj);
|
||||||
|
LayoutElement inspectBtnLayout = inspectBtnObj.AddComponent<LayoutElement>();
|
||||||
|
inspectBtnLayout.minWidth = 60;
|
||||||
|
inspectBtnLayout.flexibleWidth = 0;
|
||||||
|
inspectBtnLayout.minHeight = 25;
|
||||||
|
inspectBtnLayout.flexibleHeight = 0;
|
||||||
|
Text inspectText = inspectBtnObj.GetComponentInChildren<Text>();
|
||||||
|
inspectText.text = "Inspect";
|
||||||
|
inspectText.color = Color.white;
|
||||||
|
|
||||||
|
Button inspectBtn = inspectBtnObj.GetComponent<Button>();
|
||||||
|
ColorBlock inspectColors = inspectBtn.colors;
|
||||||
|
inspectColors.normalColor = new Color(1, 1, 1, 0.05f);
|
||||||
|
inspectBtn.colors = inspectColors;
|
||||||
|
inspectBtn.onClick.AddListener(new Action(() => { InspectorManager.Instance.Inspect(m_sceneShortList[thisIndex]); }));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,6 @@
|
|||||||
using System;
|
namespace ExplorerBeta.UI.Main
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Explorer.UI.Main.Pages
|
|
||||||
{
|
{
|
||||||
public class SearchPage : BaseMenuPage
|
public class SearchPage : MainMenu.Page
|
||||||
{
|
{
|
||||||
public override string Name => "Search";
|
public override string Name => "Search";
|
||||||
|
|
@ -1,11 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using ExplorerBeta.Config;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using ExplorerBeta.Config;
|
|
||||||
|
|
||||||
namespace ExplorerBeta.UI.Shared
|
namespace ExplorerBeta.UI.Shared
|
||||||
{
|
{
|
||||||
@ -17,24 +13,45 @@ namespace ExplorerBeta.UI.Shared
|
|||||||
|
|
||||||
public class PageHandler
|
public class PageHandler
|
||||||
{
|
{
|
||||||
public PageHandler(int listCount)
|
public PageHandler()
|
||||||
{
|
{
|
||||||
ListCount = listCount;
|
|
||||||
m_itemsPerPage = ModConfig.Instance?.Default_Page_Limit ?? 20;
|
m_itemsPerPage = ModConfig.Instance?.Default_Page_Limit ?? 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
// callback for when the page is turned
|
|
||||||
public event Action OnPageChanged;
|
public event Action OnPageChanged;
|
||||||
|
|
||||||
// set and maintained by owner of list
|
|
||||||
public int ListCount { get; set; }
|
|
||||||
|
|
||||||
// For now this is just set when the PageHandler is created, based on config.
|
// For now this is just set when the PageHandler is created, based on config.
|
||||||
// At some point I might make it possible to change this after creation again.
|
// At some point I might make it possible to change this after creation again.
|
||||||
private readonly int m_itemsPerPage;
|
public int ItemsPerPage => m_itemsPerPage;
|
||||||
|
private int m_itemsPerPage;
|
||||||
|
|
||||||
private int m_currentPage;
|
private int m_currentPage;
|
||||||
|
|
||||||
|
private GameObject m_pageUIHolder;
|
||||||
|
private Text m_currentPageLabel;
|
||||||
|
|
||||||
|
// set and maintained by owner of list
|
||||||
|
private int m_listCount;
|
||||||
|
public int ListCount
|
||||||
|
{
|
||||||
|
get => m_listCount;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_listCount = value;
|
||||||
|
|
||||||
|
if (LastPage <= 0 && m_pageUIHolder.activeSelf)
|
||||||
|
{
|
||||||
|
m_pageUIHolder.SetActive(false);
|
||||||
|
}
|
||||||
|
else if (LastPage > 0 && !m_pageUIHolder.activeSelf)
|
||||||
|
{
|
||||||
|
m_pageUIHolder.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// the last page index (not using "index" to avoid confusion with next property)
|
// the last page index (not using "index" to avoid confusion with next property)
|
||||||
public int LastPage => (int)Math.Ceiling(ListCount / (decimal)m_itemsPerPage) - 1;
|
public int LastPage => (int)Math.Ceiling(ListCount / (decimal)m_itemsPerPage) - 1;
|
||||||
|
|
||||||
@ -79,83 +96,74 @@ namespace ExplorerBeta.UI.Shared
|
|||||||
|
|
||||||
#region UI
|
#region UI
|
||||||
|
|
||||||
private GameObject m_pageUIHolder;
|
|
||||||
private Text m_currentPageLabel;
|
|
||||||
|
|
||||||
public void Show() => m_pageUIHolder?.SetActive(true);
|
public void Show() => m_pageUIHolder?.SetActive(true);
|
||||||
|
|
||||||
public void Hide() => m_pageUIHolder?.SetActive(false);
|
public void Hide() => m_pageUIHolder?.SetActive(false);
|
||||||
|
|
||||||
public void ConstructUI(GameObject parent)
|
|
||||||
{
|
|
||||||
m_pageUIHolder = UIFactory.CreateHorizontalGroup(parent);
|
|
||||||
|
|
||||||
var image = m_pageUIHolder.GetComponent<Image>();
|
|
||||||
image.color = new Color(0f, 0f, 0f, 0f);
|
|
||||||
|
|
||||||
var parentGroup = m_pageUIHolder.GetComponent<HorizontalLayoutGroup>();
|
|
||||||
parentGroup.childForceExpandHeight = true;
|
|
||||||
parentGroup.childForceExpandWidth = false;
|
|
||||||
parentGroup.childControlWidth = true;
|
|
||||||
parentGroup.childControlHeight = true;
|
|
||||||
|
|
||||||
var parentLayout = m_pageUIHolder.AddComponent<LayoutElement>();
|
|
||||||
parentLayout.minHeight = 45;
|
|
||||||
parentLayout.preferredHeight = 45;
|
|
||||||
parentLayout.flexibleHeight = 3;
|
|
||||||
parentLayout.minWidth = 300;
|
|
||||||
parentLayout.preferredWidth = 300;
|
|
||||||
parentLayout.flexibleWidth = 0;
|
|
||||||
|
|
||||||
var leftBtnObj = UIFactory.CreateButton(m_pageUIHolder);
|
|
||||||
var leftBtn = leftBtnObj.GetComponent<Button>();
|
|
||||||
#if CPP
|
|
||||||
leftBtn.onClick.AddListener(new Action(() => { TurnPage(Turn.Left); }));
|
|
||||||
#else
|
|
||||||
leftBtn.onClick.AddListener(() => { TurnPage(Turn.Left); });
|
|
||||||
#endif
|
|
||||||
var leftBtnText = leftBtnObj.GetComponentInChildren<Text>();
|
|
||||||
leftBtnText.text = "<";
|
|
||||||
var leftBtnLayout = leftBtnObj.AddComponent<LayoutElement>();
|
|
||||||
leftBtnLayout.flexibleHeight = 0;
|
|
||||||
leftBtnLayout.flexibleWidth = 0;
|
|
||||||
leftBtnLayout.minWidth = 30;
|
|
||||||
leftBtnLayout.preferredWidth = 30;
|
|
||||||
leftBtnLayout.minHeight = 30;
|
|
||||||
leftBtnLayout.preferredHeight = 30;
|
|
||||||
|
|
||||||
var labelObj = UIFactory.CreateLabel(m_pageUIHolder, TextAnchor.MiddleCenter);
|
|
||||||
m_currentPageLabel = labelObj.GetComponent<Text>();
|
|
||||||
m_currentPageLabel.text = "Page 1 / TODO";
|
|
||||||
var textLayout = labelObj.AddComponent<LayoutElement>();
|
|
||||||
textLayout.flexibleWidth = 1.5f;
|
|
||||||
textLayout.preferredWidth = 200;
|
|
||||||
|
|
||||||
var rightBtnObj = UIFactory.CreateButton(m_pageUIHolder);
|
|
||||||
var rightBtn = rightBtnObj.GetComponent<Button>();
|
|
||||||
#if CPP
|
|
||||||
rightBtn.onClick.AddListener(new Action(() => { TurnPage(Turn.Right); }));
|
|
||||||
#else
|
|
||||||
rightBtn.onClick.AddListener(() => { TurnPage(Turn.Right); });
|
|
||||||
#endif
|
|
||||||
var rightBtnText = rightBtnObj.GetComponentInChildren<Text>();
|
|
||||||
rightBtnText.text = ">";
|
|
||||||
var rightBtnLayout = rightBtnObj.AddComponent<LayoutElement>();
|
|
||||||
rightBtnLayout.flexibleHeight = 0;
|
|
||||||
rightBtnLayout.flexibleWidth = 0;
|
|
||||||
rightBtnLayout.preferredWidth = 30;
|
|
||||||
rightBtnLayout.minWidth = 30;
|
|
||||||
rightBtnLayout.minHeight = 30;
|
|
||||||
rightBtnLayout.preferredHeight = 30;
|
|
||||||
|
|
||||||
RefreshUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RefreshUI()
|
public void RefreshUI()
|
||||||
{
|
{
|
||||||
m_currentPageLabel.text = $"Page {m_currentPage + 1} / {LastPage + 1}";
|
m_currentPageLabel.text = $"Page {m_currentPage + 1} / {LastPage + 1}";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
public void ConstructUI(GameObject parent)
|
||||||
|
{
|
||||||
|
m_pageUIHolder = UIFactory.CreateHorizontalGroup(parent);
|
||||||
|
|
||||||
|
Image image = m_pageUIHolder.GetComponent<Image>();
|
||||||
|
image.color = new Color(0f, 0f, 0f, 0f);
|
||||||
|
|
||||||
|
HorizontalLayoutGroup parentGroup = m_pageUIHolder.GetComponent<HorizontalLayoutGroup>();
|
||||||
|
parentGroup.childForceExpandHeight = true;
|
||||||
|
parentGroup.childForceExpandWidth = false;
|
||||||
|
parentGroup.childControlWidth = true;
|
||||||
|
parentGroup.childControlHeight = true;
|
||||||
|
|
||||||
|
LayoutElement parentLayout = m_pageUIHolder.AddComponent<LayoutElement>();
|
||||||
|
parentLayout.minHeight = 20;
|
||||||
|
parentLayout.flexibleHeight = 0;
|
||||||
|
parentLayout.minWidth = 290;
|
||||||
|
parentLayout.flexibleWidth = 30;
|
||||||
|
|
||||||
|
GameObject leftBtnObj = UIFactory.CreateButton(m_pageUIHolder);
|
||||||
|
Button leftBtn = leftBtnObj.GetComponent<Button>();
|
||||||
|
#if CPP
|
||||||
|
leftBtn.onClick.AddListener(new Action(() => { TurnPage(Turn.Left); }));
|
||||||
|
#else
|
||||||
|
leftBtn.onClick.AddListener(() => { TurnPage(Turn.Left); });
|
||||||
|
#endif
|
||||||
|
Text leftBtnText = leftBtnObj.GetComponentInChildren<Text>();
|
||||||
|
leftBtnText.text = "<";
|
||||||
|
LayoutElement leftBtnLayout = leftBtnObj.AddComponent<LayoutElement>();
|
||||||
|
leftBtnLayout.flexibleHeight = 0;
|
||||||
|
leftBtnLayout.flexibleWidth = 0;
|
||||||
|
leftBtnLayout.minWidth = 50;
|
||||||
|
leftBtnLayout.minHeight = 20;
|
||||||
|
|
||||||
|
GameObject labelObj = UIFactory.CreateLabel(m_pageUIHolder, TextAnchor.MiddleCenter);
|
||||||
|
m_currentPageLabel = labelObj.GetComponent<Text>();
|
||||||
|
m_currentPageLabel.text = "Page 1 / TODO";
|
||||||
|
LayoutElement textLayout = labelObj.AddComponent<LayoutElement>();
|
||||||
|
textLayout.flexibleWidth = 1.5f;
|
||||||
|
textLayout.preferredWidth = 200;
|
||||||
|
|
||||||
|
GameObject rightBtnObj = UIFactory.CreateButton(m_pageUIHolder);
|
||||||
|
Button rightBtn = rightBtnObj.GetComponent<Button>();
|
||||||
|
#if CPP
|
||||||
|
rightBtn.onClick.AddListener(new Action(() => { TurnPage(Turn.Right); }));
|
||||||
|
#else
|
||||||
|
rightBtn.onClick.AddListener(() => { TurnPage(Turn.Right); });
|
||||||
|
#endif
|
||||||
|
Text rightBtnText = rightBtnObj.GetComponentInChildren<Text>();
|
||||||
|
rightBtnText.text = ">";
|
||||||
|
LayoutElement rightBtnLayout = rightBtnObj.AddComponent<LayoutElement>();
|
||||||
|
rightBtnLayout.flexibleHeight = 0;
|
||||||
|
rightBtnLayout.flexibleWidth = 0;
|
||||||
|
rightBtnLayout.minWidth = 50;
|
||||||
|
rightBtnLayout.minHeight = 20;
|
||||||
|
|
||||||
|
ListCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
namespace ExplorerBeta.UI.Shared
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ExplorerBeta.UI.Shared
|
|
||||||
{
|
{
|
||||||
public class Syntax
|
public class Syntax
|
||||||
{
|
{
|
||||||
|
1053
src/UI/UIFactory.cs
1053
src/UI/UIFactory.cs
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,4 @@
|
|||||||
using System;
|
using ExplorerBeta.UI.Main;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using ExplorerBeta.Input;
|
|
||||||
using ExplorerBeta.UI.Main;
|
|
||||||
using ExplorerBeta.UI.Shared;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -25,7 +19,7 @@ namespace ExplorerBeta.UI
|
|||||||
// Create submodules
|
// Create submodules
|
||||||
new MainMenu();
|
new MainMenu();
|
||||||
|
|
||||||
// Force refresh of anchors (?)
|
// Force refresh of anchors
|
||||||
Canvas.ForceUpdateCanvases();
|
Canvas.ForceUpdateCanvases();
|
||||||
|
|
||||||
CanvasRoot.SetActive(false);
|
CanvasRoot.SetActive(false);
|
||||||
@ -40,7 +34,7 @@ namespace ExplorerBeta.UI
|
|||||||
|
|
||||||
private static GameObject CreateRootCanvas()
|
private static GameObject CreateRootCanvas()
|
||||||
{
|
{
|
||||||
var rootObj = new GameObject("ExplorerCanvas");
|
GameObject rootObj = new GameObject("ExplorerCanvas");
|
||||||
UnityEngine.Object.DontDestroyOnLoad(rootObj);
|
UnityEngine.Object.DontDestroyOnLoad(rootObj);
|
||||||
rootObj.layer = 5;
|
rootObj.layer = 5;
|
||||||
|
|
||||||
@ -51,12 +45,13 @@ namespace ExplorerBeta.UI
|
|||||||
InputModule = rootObj.AddComponent<StandaloneInputModule>();
|
InputModule = rootObj.AddComponent<StandaloneInputModule>();
|
||||||
InputModule.ActivateModule();
|
InputModule.ActivateModule();
|
||||||
|
|
||||||
var canvas = rootObj.AddComponent<Canvas>();
|
Canvas canvas = rootObj.AddComponent<Canvas>();
|
||||||
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||||
canvas.referencePixelsPerUnit = 100;
|
canvas.referencePixelsPerUnit = 100;
|
||||||
canvas.sortingOrder = 999;
|
canvas.sortingOrder = 999;
|
||||||
|
canvas.pixelPerfect = false;
|
||||||
|
|
||||||
var scaler = rootObj.AddComponent<CanvasScaler>();
|
CanvasScaler scaler = rootObj.AddComponent<CanvasScaler>();
|
||||||
scaler.referenceResolution = new Vector2(1920, 1080);
|
scaler.referenceResolution = new Vector2(1920, 1080);
|
||||||
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand;
|
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand;
|
||||||
|
|
||||||
@ -81,7 +76,7 @@ namespace ExplorerBeta.UI
|
|||||||
#if CPP
|
#if CPP
|
||||||
if (InputModule.m_InputPointerEvent != null)
|
if (InputModule.m_InputPointerEvent != null)
|
||||||
{
|
{
|
||||||
var evt = InputModule.m_InputPointerEvent;
|
PointerEventData evt = InputModule.m_InputPointerEvent;
|
||||||
if (!evt.eligibleForClick && evt.selectedObject)
|
if (!evt.eligibleForClick && evt.selectedObject)
|
||||||
{
|
{
|
||||||
evt.eligibleForClick = true;
|
evt.eligibleForClick = true;
|
||||||
@ -99,16 +94,19 @@ namespace ExplorerBeta.UI
|
|||||||
public static void OnSceneChange()
|
public static void OnSceneChange()
|
||||||
{
|
{
|
||||||
// todo
|
// todo
|
||||||
|
SceneExplorer.Instance?.OnSceneChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Sprite CreateSprite(Texture2D tex, Rect size = default)
|
public static Sprite CreateSprite(Texture2D tex, Rect size = default)
|
||||||
{
|
{
|
||||||
#if CPP
|
#if CPP
|
||||||
var pivot = Vector2.zero;
|
Vector2 pivot = Vector2.zero;
|
||||||
var border = Vector4.zero;
|
Vector4 border = Vector4.zero;
|
||||||
|
|
||||||
if (size == default)
|
if (size == default)
|
||||||
|
{
|
||||||
size = new Rect(0, 0, tex.width, tex.height);
|
size = new Rect(0, 0, tex.width, tex.height);
|
||||||
|
}
|
||||||
|
|
||||||
return Sprite.CreateSprite_Injected(tex, ref size, ref pivot, 100f, 0u, SpriteMeshType.Tight, ref border, false);
|
return Sprite.CreateSprite_Injected(tex, ref size, ref pivot, 100f, 0u, SpriteMeshType.Tight, ref border, false);
|
||||||
#else
|
#else
|
||||||
@ -118,13 +116,13 @@ namespace ExplorerBeta.UI
|
|||||||
|
|
||||||
public static Texture2D MakeSolidTexture(Color color, int width, int height)
|
public static Texture2D MakeSolidTexture(Color color, int width, int height)
|
||||||
{
|
{
|
||||||
var pixels = new Color[width * height];
|
Color[] pixels = new Color[width * height];
|
||||||
for (int i = 0; i < pixels.Length; i++)
|
for (int i = 0; i < pixels.Length; i++)
|
||||||
{
|
{
|
||||||
pixels[i] = color;
|
pixels[i] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tex = new Texture2D(width, height);
|
Texture2D tex = new Texture2D(width, height);
|
||||||
tex.SetPixels(pixels);
|
tex.SetPixels(pixels);
|
||||||
tex.Apply();
|
tex.Apply();
|
||||||
|
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
using System;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Explorer.Unstrip.ColorUtility
|
namespace ExplorerBeta.Unstrip.ColorUtility
|
||||||
{
|
{
|
||||||
public static class ColorUtilityUnstrip
|
public static class ColorUtilityUnstrip
|
||||||
{
|
{
|
||||||
public static string ToHex(this Color color)
|
public static string ToHex(this Color color)
|
||||||
{
|
{
|
||||||
var r = (byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255);
|
byte r = (byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255);
|
||||||
var g = (byte)Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255);
|
byte g = (byte)Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255);
|
||||||
var b = (byte)Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255);
|
byte b = (byte)Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255);
|
||||||
|
|
||||||
return $"{r:X2}{g:X2}{b:X2}";
|
return $"{r:X2}{g:X2}{b:X2}";
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
#if CPP
|
#if CPP
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnhollowerBaseLib;
|
|
||||||
using UnityEngine;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using ExplorerBeta.Helpers;
|
using ExplorerBeta.Helpers;
|
||||||
using System.Runtime.InteropServices;
|
using UnhollowerBaseLib;
|
||||||
using Unity.Collections;
|
using UnityEngine;
|
||||||
using Unity.Collections.LowLevel.Unsafe;
|
|
||||||
|
|
||||||
namespace ExplorerBeta.Unstrip.ImageConversion
|
namespace ExplorerBeta.Unstrip.ImageConversion
|
||||||
{
|
{
|
||||||
@ -21,7 +15,7 @@ namespace ExplorerBeta.Unstrip.ImageConversion
|
|||||||
|
|
||||||
public static byte[] EncodeToPNG(this Texture2D tex)
|
public static byte[] EncodeToPNG(this Texture2D tex)
|
||||||
{
|
{
|
||||||
var data = ICallHelper.GetICall<d_EncodeToPNG>("UnityEngine.ImageConversion::EncodeToPNG")
|
byte[] data = ICallHelper.GetICall<d_EncodeToPNG>("UnityEngine.ImageConversion::EncodeToPNG")
|
||||||
.Invoke(tex.Pointer);
|
.Invoke(tex.Pointer);
|
||||||
|
|
||||||
// The Il2Cpp EncodeToPNG() method does return System.Byte[],
|
// The Il2Cpp EncodeToPNG() method does return System.Byte[],
|
||||||
@ -43,13 +37,13 @@ namespace ExplorerBeta.Unstrip.ImageConversion
|
|||||||
|
|
||||||
public static bool LoadImage(this Texture2D tex, byte[] data, bool markNonReadable)
|
public static bool LoadImage(this Texture2D tex, byte[] data, bool markNonReadable)
|
||||||
{
|
{
|
||||||
var il2cppArray = new Il2CppStructArray<byte>(data.Length);
|
Il2CppStructArray<byte> il2cppArray = new Il2CppStructArray<byte>(data.Length);
|
||||||
for (int i = 0; i < data.Length; i++)
|
for (int i = 0; i < data.Length; i++)
|
||||||
{
|
{
|
||||||
il2cppArray[i] = data[i];
|
il2cppArray[i] = data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret = ICallHelper.GetICall<d_LoadImage>("UnityEngine.ImageConversion::LoadImage")
|
bool ret = ICallHelper.GetICall<d_LoadImage>("UnityEngine.ImageConversion::LoadImage")
|
||||||
.Invoke(tex.Pointer, il2cppArray.Pointer, markNonReadable);
|
.Invoke(tex.Pointer, il2cppArray.Pointer, markNonReadable);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -64,7 +58,7 @@ namespace ExplorerBeta.Unstrip.ImageConversion
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = File.ReadAllBytes(filePath);
|
byte[] data = File.ReadAllBytes(filePath);
|
||||||
return tex.LoadImage(data, markNonReadable);
|
return tex.LoadImage(data, markNonReadable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using ExplorerBeta.Helpers;
|
using ExplorerBeta.Helpers;
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnhollowerBaseLib;
|
using UnhollowerBaseLib;
|
||||||
@ -17,7 +13,7 @@ namespace ExplorerBeta.Unstrip.LayerMasks
|
|||||||
|
|
||||||
public static string LayerToName(int layer)
|
public static string LayerToName(int layer)
|
||||||
{
|
{
|
||||||
var iCall = ICallHelper.GetICall<d_LayerToName>("UnityEngine.LayerMask::LayerToName");
|
d_LayerToName iCall = ICallHelper.GetICall<d_LayerToName>("UnityEngine.LayerMask::LayerToName");
|
||||||
return IL2CPP.Il2CppStringToManaged(iCall.Invoke(layer));
|
return IL2CPP.Il2CppStringToManaged(iCall.Invoke(layer));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using ExplorerBeta.Helpers;
|
using ExplorerBeta.Helpers;
|
||||||
using UnityEngine;
|
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnhollowerBaseLib;
|
using UnhollowerBaseLib;
|
||||||
#endif
|
#endif
|
||||||
@ -17,12 +13,12 @@ namespace ExplorerBeta.Unstrip.Resources
|
|||||||
|
|
||||||
public static UnityEngine.Object[] FindObjectsOfTypeAll(Il2CppSystem.Type type)
|
public static UnityEngine.Object[] FindObjectsOfTypeAll(Il2CppSystem.Type type)
|
||||||
{
|
{
|
||||||
var arrayPtr = ICallHelper.GetICall<d_FindObjectsOfTypeAll>("UnityEngine.Resources::FindObjectsOfTypeAll")
|
IntPtr arrayPtr = ICallHelper.GetICall<d_FindObjectsOfTypeAll>("UnityEngine.Resources::FindObjectsOfTypeAll")
|
||||||
.Invoke(type.Pointer);
|
.Invoke(type.Pointer);
|
||||||
|
|
||||||
var array = new Il2CppReferenceArray<UnityEngine.Object>(arrayPtr);
|
Il2CppReferenceArray<UnityEngine.Object> array = new Il2CppReferenceArray<UnityEngine.Object>(arrayPtr);
|
||||||
|
|
||||||
var ret = new UnityEngine.Object[array.Length];
|
UnityEngine.Object[] ret = new UnityEngine.Object[array.Length];
|
||||||
|
|
||||||
for (int i = 0; i < array.Length; i++)
|
for (int i = 0; i < array.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
#if CPP
|
#if CPP
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using ExplorerBeta.Helpers;
|
using ExplorerBeta.Helpers;
|
||||||
using UnhollowerBaseLib;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
@ -21,11 +17,13 @@ namespace ExplorerBeta.Unstrip.Scenes
|
|||||||
public static GameObject[] GetRootGameObjects(int handle)
|
public static GameObject[] GetRootGameObjects(int handle)
|
||||||
{
|
{
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
|
{
|
||||||
return new GameObject[0];
|
return new GameObject[0];
|
||||||
|
}
|
||||||
|
|
||||||
var list = new Il2CppSystem.Collections.Generic.List<GameObject>(GetRootCount(handle));
|
Il2CppSystem.Collections.Generic.List<GameObject> list = new Il2CppSystem.Collections.Generic.List<GameObject>(GetRootCount(handle));
|
||||||
|
|
||||||
var iCall = ICallHelper.GetICall<d_GetRootGameObjects>("UnityEngine.SceneManagement.Scene::GetRootGameObjectsInternal");
|
d_GetRootGameObjects iCall = ICallHelper.GetICall<d_GetRootGameObjects>("UnityEngine.SceneManagement.Scene::GetRootGameObjectsInternal");
|
||||||
|
|
||||||
iCall.Invoke(handle, list.Pointer);
|
iCall.Invoke(handle, list.Pointer);
|
||||||
|
|
||||||
@ -40,7 +38,7 @@ namespace ExplorerBeta.Unstrip.Scenes
|
|||||||
|
|
||||||
public static int GetRootCount(int handle)
|
public static int GetRootCount(int handle)
|
||||||
{
|
{
|
||||||
var iCall = ICallHelper.GetICall<GetRootCountInternal_delegate>("UnityEngine.SceneManagement.Scene::GetRootCountInternal");
|
GetRootCountInternal_delegate iCall = ICallHelper.GetICall<GetRootCountInternal_delegate>("UnityEngine.SceneManagement.Scene::GetRootCountInternal");
|
||||||
return iCall.Invoke(handle);
|
return iCall.Invoke(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user