protected override void LoadContent() { Console.Log("Loading Content..."); try { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here // load the fonts FontManager.Load(Content); FontManager.DefaultSize = 16; CursorManager.Load(Content); CursorManager.Enabled = false; // load the UI Style bool success; string errormsg; UIStyle = UIStyle.Load(DefaultUIStyleLocation, FontManager, out success, out errormsg); if (!success) { UIStyle.Save(DefaultUIStyleLocation, UIStyle, out errormsg); } CursorManager.SetCursor(UIStyle.CursorStyle, UIStyle.CursorColor); // load the cursor, create the input manager InputManager = new InputManager(CursorManager); HotkeyManager = new HotkeyManager((s) => { Console.Error(s); }); List <HotkeySave> hotkeys = HotkeyManager.Load(DefaultHotkeysLocation); if (hotkeys == null) { hotkeys = new List <HotkeySave>(); } //Console.AddHandle("Hotkey", new ConsoleHandleHotkeyManager(HotkeyManager)); // create the profile manager ProfileManager = new ProfileManager <SampleProfile>(DefaultProfilesLocation, MakeDefaultProfile, (s) => { Console.Error(s); }); // load specific hotkeys List <HotkeySave> profHotkeys = ProfileManager.CurrentProfile.Hotkeys; HotkeyManager.LoadProfile(HotkeyManager.MergeHotkeySaves(hotkeys, profHotkeys)); // Add the startup UI //UIBoss.Add(new TestUI(UIStyle)); UIBoss = new UIBoss(UIStyle, HotkeyManager); TestUI testui = new TestUI(UIStyle, GraphicsDevice); UIBoss.Add(testui); UIBoss.Add(new ConsoleUI(UIBoss, UIStyle, GraphicsDevice, Console, GraphicsDevice.PresentationParameters.BackBufferWidth, 300)); UIBoss.Add(new FrameRateUI(UIStyle, GraphicsDevice)); //Console.AddHandle("UIStyle", new ConsoleHandleUIStyle(UIBoss)); } catch (Exception e) { Console.Error("FAILED: " + e.Message); Console.Error("Could not load content. Aborting."); Crash(e); return; } Console.Log("Content Loaded."); }
public ConsoleUI(UIBoss boss, UIStyle style, GraphicsDevice g, IConsole console, int width, int height, int logstoload = 30, string font = "NotoMono-Regular", int?fontsize = 16) { Boss = boss; Console = console; UISystem = new UISystem(g); LogsToLoad = logstoload; int hperlog = 16; int innerHeight = (hperlog + 4) * LogsToLoad; LogList = new UIAutoList(eUIOrientation.VERTICAL, width - 16 - 4, innerHeight, fixedindexwidth: width - 16 - 4, fixedindexheight: hperlog, alternatesBackground: true); LogList.HasBorder = false; LogList.HasOuterBorder = false; LogList.MarginY = 2; for (int i = 0; i < LogsToLoad; i++) { UILabel lab = new UILabel(0, 0, width - 16, hperlog, "", font: font, fontsize: fontsize) { TextOneLineOnly = true }; Labels.Add(lab); LogList.AddAuto(lab); } LogPanel = new UIPanel(0, 0, width, height, true, "Console", hasscrolling: true, scrollh: innerHeight); LogPanel.AutoScrollHeight = true; LogPanel.AddAuto(LogList); LogPanel.Visible = false; ScrapLabel = new UILabel(0, 0, width - 32, hperlog, ""); ScrapLabel.Visible = false; LogPanel.Add(ScrapLabel); InputField = new UITextField(0, 0, width - 24, hperlog, "", font: font, fontsize: fontsize, placeholdertext: "Input..."); InputField.EventEnterPressed += (sender, e) => { string inputtext = InputField.Text; UITextField.EventEnterPressedHandlerArgs eargs = (e as UITextField.EventEnterPressedHandlerArgs); InputField.ClearText(eargs.ElapsedMS, eargs.Input); InputField.CaretPosition = 0; Console.Input(inputtext); }; LogPanel.AddAuto(InputField); UISystem.Add(LogPanel); UISystem.Init(style); LogPanel.SnapScrollToBottom(); /*UILabel firstLabel = (LogList.Components[0] as UILabel); * firstLabel.EventPostInit += (sender, args) => * { * MaxLength = (LogPanel.Width - 32) / firstLabel.FontSettings.MonospaceSize; * };*/ }