mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-04 04:22:53 +08:00
Cleanup CSConsole, add start of Options and Log panels
This commit is contained in:
@ -276,45 +276,36 @@ The following helper methods are available:
|
|||||||
int endIdx = Input.Text.Length - 1;
|
int endIdx = Input.Text.Length - 1;
|
||||||
int topLine = 0;
|
int topLine = 0;
|
||||||
|
|
||||||
try
|
// Calculate visible text if necessary
|
||||||
|
if (Input.Rect.rect.height > Panel.InputScroll.ViewportRect.rect.height)
|
||||||
{
|
{
|
||||||
// Calculate visible text if necessary
|
topLine = -1;
|
||||||
if (Input.Rect.rect.height > Panel.InputScroll.ViewportRect.rect.height)
|
int bottomLine = -1;
|
||||||
|
|
||||||
|
// the top and bottom position of the viewport in relation to the text height
|
||||||
|
// they need the half-height adjustment to normalize against the 'line.topY' value.
|
||||||
|
var viewportMin = Input.Rect.rect.height - Input.Rect.anchoredPosition.y - (Input.Rect.rect.height * 0.5f);
|
||||||
|
var viewportMax = viewportMin - Panel.InputScroll.ViewportRect.rect.height;
|
||||||
|
|
||||||
|
for (int i = 0; i < Input.TextGenerator.lineCount; i++)
|
||||||
{
|
{
|
||||||
topLine = -1;
|
var line = Input.TextGenerator.lines[i];
|
||||||
int bottomLine = -1;
|
// if not set the top line yet, and top of line is below the viewport top
|
||||||
|
if (topLine == -1 && line.topY <= viewportMin)
|
||||||
// the top and bottom position of the viewport in relation to the text height
|
topLine = i;
|
||||||
// they need the half-height adjustment to normalize against the 'line.topY' value.
|
// if bottom of line is below the viewport bottom
|
||||||
var viewportMin = Input.Rect.rect.height - Input.Rect.anchoredPosition.y - (Input.Rect.rect.height * 0.5f);
|
if ((line.topY - line.height) >= viewportMax)
|
||||||
var viewportMax = viewportMin - Panel.InputScroll.ViewportRect.rect.height;
|
bottomLine = i;
|
||||||
|
|
||||||
for (int i = 0; i < Input.TextGenerator.lineCount; i++)
|
|
||||||
{
|
|
||||||
var line = Input.TextGenerator.lines[i];
|
|
||||||
// if not set the top line yet, and top of line is below the viewport top
|
|
||||||
if (topLine == -1 && line.topY <= viewportMin)
|
|
||||||
topLine = i;
|
|
||||||
// if bottom of line is below the viewport bottom
|
|
||||||
if ((line.topY - line.height) >= viewportMax)
|
|
||||||
bottomLine = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
topLine = Math.Max(0, topLine - 1);
|
|
||||||
bottomLine = Math.Min(Input.TextGenerator.lineCount - 1, bottomLine + 1);
|
|
||||||
|
|
||||||
startIdx = Input.TextGenerator.lines[topLine].startCharIdx;
|
|
||||||
endIdx = (bottomLine >= Input.TextGenerator.lineCount - 1)
|
|
||||||
? Input.Text.Length - 1
|
|
||||||
: (Input.TextGenerator.lines[bottomLine + 1].startCharIdx - 1);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ExplorerCore.Log("Exception on HighlightVisibleText: " + ex.GetType().Name + ", " + ex.Message);
|
|
||||||
|
|
||||||
}
|
topLine = Math.Max(0, topLine - 1);
|
||||||
|
bottomLine = Math.Min(Input.TextGenerator.lineCount - 1, bottomLine + 1);
|
||||||
|
|
||||||
|
startIdx = Input.TextGenerator.lines[topLine].startCharIdx;
|
||||||
|
endIdx = (bottomLine >= Input.TextGenerator.lineCount - 1)
|
||||||
|
? Input.Text.Length - 1
|
||||||
|
: (Input.TextGenerator.lines[bottomLine + 1].startCharIdx - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Highlight the visible text with the LexerBuilder
|
// Highlight the visible text with the LexerBuilder
|
||||||
Panel.HighlightText.text = Lexer.BuildHighlightedString(Input.Text, startIdx, endIdx, topLine);
|
Panel.HighlightText.text = Lexer.BuildHighlightedString(Input.Text, startIdx, endIdx, topLine);
|
||||||
|
36
src/UI/Panels/ConsoleLogPanel.cs
Normal file
36
src/UI/Panels/ConsoleLogPanel.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace UnityExplorer.UI.Panels
|
||||||
|
{
|
||||||
|
public class ConsoleLogPanel : UIPanel
|
||||||
|
{
|
||||||
|
public override string Name => "Console Log";
|
||||||
|
public override UIManager.Panels PanelType => UIManager.Panels.ConsoleLog;
|
||||||
|
|
||||||
|
public override int MinWidth => 300;
|
||||||
|
public override int MinHeight => 75;
|
||||||
|
|
||||||
|
public override void ConstructPanelContent()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DoSaveToConfigElement()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetSaveData()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected internal override void DoSetDefaultPosAndAnchors()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
src/UI/Panels/OptionsPanel.cs
Normal file
36
src/UI/Panels/OptionsPanel.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace UnityExplorer.UI.Panels
|
||||||
|
{
|
||||||
|
public class OptionsPanel : UIPanel
|
||||||
|
{
|
||||||
|
public override string Name => "Options";
|
||||||
|
public override UIManager.Panels PanelType => UIManager.Panels.Options;
|
||||||
|
|
||||||
|
public override int MinWidth => 400;
|
||||||
|
public override int MinHeight => 200;
|
||||||
|
|
||||||
|
public override void ConstructPanelContent()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DoSaveToConfigElement()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetSaveData()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected internal override void DoSetDefaultPosAndAnchors()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -39,10 +39,12 @@ namespace UnityExplorer.UI
|
|||||||
|
|
||||||
// panels
|
// panels
|
||||||
internal static GameObject PanelHolder { get; private set; }
|
internal static GameObject PanelHolder { get; private set; }
|
||||||
|
|
||||||
public static ObjectExplorerPanel Explorer { get; private set; }
|
public static ObjectExplorerPanel Explorer { get; private set; }
|
||||||
public static InspectorPanel Inspector { get; private set; }
|
public static InspectorPanel Inspector { get; private set; }
|
||||||
public static CSConsolePanel CSharpConsole { get; private set; }
|
public static CSConsolePanel CSharpConsole { get; private set; }
|
||||||
|
public static OptionsPanel Options { get; private set; }
|
||||||
|
public static ConsoleLogPanel ConsoleLog { get; private set; }
|
||||||
|
|
||||||
public static AutoCompleteModal AutoCompleter { get; private set; }
|
public static AutoCompleteModal AutoCompleter { get; private set; }
|
||||||
|
|
||||||
@ -180,6 +182,12 @@ namespace UnityExplorer.UI
|
|||||||
CSharpConsole.ConstructUI();
|
CSharpConsole.ConstructUI();
|
||||||
ConsoleController.Init();
|
ConsoleController.Init();
|
||||||
|
|
||||||
|
Options = new OptionsPanel();
|
||||||
|
Options.ConstructUI();
|
||||||
|
|
||||||
|
ConsoleLog = new ConsoleLogPanel();
|
||||||
|
ConsoleLog.ConstructUI();
|
||||||
|
|
||||||
ShowMenu = !ConfigManager.Hide_On_Startup.Value;
|
ShowMenu = !ConfigManager.Hide_On_Startup.Value;
|
||||||
|
|
||||||
ExplorerCore.Log("UI initialized.");
|
ExplorerCore.Log("UI initialized.");
|
||||||
|
@ -262,8 +262,10 @@
|
|||||||
<Compile Include="UI\Models\InputFieldRef.cs" />
|
<Compile Include="UI\Models\InputFieldRef.cs" />
|
||||||
<Compile Include="UI\ObjectPool\IPooledObject.cs" />
|
<Compile Include="UI\ObjectPool\IPooledObject.cs" />
|
||||||
<Compile Include="UI\ObjectPool\Pool.cs" />
|
<Compile Include="UI\ObjectPool\Pool.cs" />
|
||||||
|
<Compile Include="UI\Panels\ConsoleLogPanel.cs" />
|
||||||
<Compile Include="UI\Panels\CSConsolePanel.cs" />
|
<Compile Include="UI\Panels\CSConsolePanel.cs" />
|
||||||
<Compile Include="Core\Utility\IOUtility.cs" />
|
<Compile Include="Core\Utility\IOUtility.cs" />
|
||||||
|
<Compile Include="UI\Panels\OptionsPanel.cs" />
|
||||||
<Compile Include="UI\Widgets\AutoComplete\ISuggestionProvider.cs" />
|
<Compile Include="UI\Widgets\AutoComplete\ISuggestionProvider.cs" />
|
||||||
<Compile Include="UI\Widgets\AutoComplete\Suggestion.cs" />
|
<Compile Include="UI\Widgets\AutoComplete\Suggestion.cs" />
|
||||||
<Compile Include="Core\Config\ConfigElement.cs" />
|
<Compile Include="Core\Config\ConfigElement.cs" />
|
||||||
|
Reference in New Issue
Block a user