mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
Cleanup CSConsole, add start of Options and Log panels
This commit is contained in:
parent
70d66f93a5
commit
3e44317861
@ -276,45 +276,36 @@ The following helper methods are available:
|
||||
int endIdx = Input.Text.Length - 1;
|
||||
int topLine = 0;
|
||||
|
||||
try
|
||||
// Calculate visible text if necessary
|
||||
if (Input.Rect.rect.height > Panel.InputScroll.ViewportRect.rect.height)
|
||||
{
|
||||
// Calculate visible text if necessary
|
||||
if (Input.Rect.rect.height > Panel.InputScroll.ViewportRect.rect.height)
|
||||
topLine = -1;
|
||||
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;
|
||||
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++)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
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
|
||||
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
|
||||
internal static GameObject PanelHolder { get; private set; }
|
||||
|
||||
|
||||
public static ObjectExplorerPanel Explorer { get; private set; }
|
||||
public static InspectorPanel Inspector { 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; }
|
||||
|
||||
@ -180,6 +182,12 @@ namespace UnityExplorer.UI
|
||||
CSharpConsole.ConstructUI();
|
||||
ConsoleController.Init();
|
||||
|
||||
Options = new OptionsPanel();
|
||||
Options.ConstructUI();
|
||||
|
||||
ConsoleLog = new ConsoleLogPanel();
|
||||
ConsoleLog.ConstructUI();
|
||||
|
||||
ShowMenu = !ConfigManager.Hide_On_Startup.Value;
|
||||
|
||||
ExplorerCore.Log("UI initialized.");
|
||||
|
@ -262,8 +262,10 @@
|
||||
<Compile Include="UI\Models\InputFieldRef.cs" />
|
||||
<Compile Include="UI\ObjectPool\IPooledObject.cs" />
|
||||
<Compile Include="UI\ObjectPool\Pool.cs" />
|
||||
<Compile Include="UI\Panels\ConsoleLogPanel.cs" />
|
||||
<Compile Include="UI\Panels\CSConsolePanel.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\Suggestion.cs" />
|
||||
<Compile Include="Core\Config\ConfigElement.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user