movement stuff

This commit is contained in:
GoaLitiuM
2021-04-08 19:31:01 +03:00
parent ae8983a90e
commit 1234dd9393
11 changed files with 248 additions and 141 deletions

View File

@@ -97,9 +97,7 @@ namespace Cabrito
if (font == null)
return (int)Height;
int h = (int)Mathf.Round(LineSpacing * (font.Height / Platform.DpiScale) * Scale.Y);
Console.Print("height: " + LineSpacing.ToString());
return h;
return (int)Mathf.Round(LineSpacing * (font.Height / Platform.DpiScale) * Scale.Y);
}
private int GetHeightInLines()

View File

@@ -182,7 +182,6 @@ namespace Cabrito
}
Console.RegisterConsoleScript(this);
RefreshLayout();
#if false
//for (int i = 0; i < 10; i++)
@@ -263,6 +262,12 @@ namespace Cabrito
Console.OnOpen += () => { Screen.CursorVisible = true; Screen.CursorLock = CursorLockMode.None; };
Console.OnClose += () => { Screen.CursorVisible = false; Screen.CursorLock = CursorLockMode.Locked; };
// hide console by default, and close it instantly
Console.Close();
var rootlocation = rootControl.Control.Location;
rootlocation.Y = -rootControl.Control.Height;
rootControl.Control.Location = rootlocation;
}
private void OnSendLog(LogType level, string msg, FlaxEngine.Object obj, string stackTrace)
@@ -287,36 +292,6 @@ namespace Cabrito
Debug.Logger.LogHandler.SendExceptionLog -= OnSendExceptionLog;
}
public void RefreshLayout()
{
if (consoleBox == null || consoleInputBox == null)
return;
//consoleBox.SetAnchorPreset(AnchorPresets.StretchAll, true);
//consoleBox.AnchorMax = new Vector2(1.0f, ConsoleHeight);
Vector2 screenSize = Screen.Size;
Vector2 consoleSize = new Vector2(screenSize.X, screenSize.Y * ConsoleHeight);
//consoleBox.Height = consoleSize.Y - consoleBox.GetFontHeight();
//consoleInputBox.SetAnchorPreset(AnchorPresets.HorizontalStretchTop, true);
//consoleInputBox.Location = new Vector2(0, consoleBox.Bottom);
//Font fontRaw = consoleBox.Font.GetFont();
//consoleBox.Height -= fontRaw.Height;
/*float fontHeight = consoleBox.GetFontHeight();
Vector2 screenSize = Screen.Size;
Vector2 consoleSize = new Vector2(screenSize.X, screenSize.Y * ConsoleHeight);
consoleBox.Height = consoleSize.Y - fontHeight;
consoleInputBox.Location = new Vector2(0, consoleBox.Height);
consoleInputBox.Height = fontHeight;
consoleInputBox.ScrollToCaret();*/
}
private void OnConsoleInputEvent()
{
string currentInput = Input.InputText;
@@ -363,23 +338,10 @@ namespace Cabrito
Parent.As<UICanvas>().ReceivesEvents = false;
}
bool firstUpdate = true;
public override void OnUpdate()
{
base.OnUpdate();
// HACK: workaround for cursor not getting hidden in editor after entering play mode
if (firstUpdate)
{
firstUpdate = false;
Console.Close();
// hide console by default
var rootlocation = rootControl.Control.Location;
rootlocation.Y = -rootControl.Control.Height;
rootControl.Control.Location = rootlocation;
}
float targetY;
if (!Console.IsOpen)
targetY = -rootControl.Control.Height;