public Console() { AddDefaultCommands(); Window = new SGroup { Visible = false, Background = new Color(0, 0f, 0f, 0.8f), OnUpdateStyle = elem => { elem.Fill(0); }, Children = { new SGroup { // OutputBox Background = new Color(0, 0, 0, 0), AutoLayout = (self) => self.AutoLayoutVertical, ScrollDirection = SGroup.EDirection.Vertical, OnUpdateStyle = (elem) => { elem.Fill(0); elem.Size -= new Vector2(0, elem.Backend.LineHeight); }, Children = { new SLabel($"ModUntitled v{ModUntitled.VERSION}") { Foreground = UnityUtil.NewColorRGB(0, 161, 231) } } }, new SGroup { // AutocompleteBox Background = new Color(0.2f, 0.2f, 0.2f, 0.9f), AutoLayout = (self) => self.AutoLayoutVertical, ScrollDirection = SGroup.EDirection.Vertical, OnUpdateStyle = (elem) => { elem.Size.x = elem.Parent.InnerSize.x; elem.Size.y = elem.Parent.InnerSize.y / 10; // 10% elem.Position.y = elem.Parent.InnerSize.y - elem.Parent[(int)WindowChild.InputBox].Size.y - elem.Size.y; }, Children = {}, Visible = false }, new STextField { // InputBox OverrideTab = true, OnUpdateStyle = (elem) => { elem.Size.x = elem.Parent.InnerSize.x; elem.Position.x = 0; elem.Position.y = elem.Parent.InnerSize.y - elem.Size.y; }, OnKey = (self, is_down, key) => { if (!is_down || key == KeyCode.Return || key == KeyCode.KeypadEnter) { return; } switch (key) { case KeyCode.Home: self.MoveCursor(0); break; case KeyCode.Escape: case KeyCode.F2: Hide(); break; case KeyCode.Tab: DoAutoComplete(); break; case KeyCode.UpArrow: History.MoveUp(); self.MoveCursor(History.Entry.Length); break; case KeyCode.DownArrow: History.MoveDown(); self.MoveCursor(History.Entry.Length); break; default: History.LastEntry = self.Text; History.CurrentIndex = History.LastIndex; break; } self.Text = History.Entry; }, OnSubmit = (elem, text) => { if (text.Trim().Length == 0) { return; } History.Push(); //if (Console.LuaMode) { // Console.ExecuteLuaAndPrintResult(text); //} else { ExecuteCommandAndPrintResult(text); //} }, } } }; // Console ctor code _Executor = new Parser.Executor((name, args, history_index) => { Command cmd = ResolveCommand(name); if (history_index == null && History.LastIndex > 0) { history_index = History.LastIndex - 1; } return(cmd.Run(args, history_index)); }); NormalHistory = new CommandHistory(_Executor, _Parser); //LuaHistory = new CommandHistory(_Executor, _Parser); Logger.Info($"Console initialized"); }