From b8da7357b00c9fb11c48ed697972f284d182feae Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 31 Jul 2017 22:48:17 -0400 Subject: adjust textcache purge --- ShiftOS.Frontend/Apps/Terminal.cs | 24 ++++++++- ShiftOS.Frontend/Desktop/Desktop.cs | 4 ++ ShiftOS.Frontend/Desktop/WindowManager.cs | 41 ++++++++------ ShiftOS.Frontend/ShiftOS.Frontend.csproj | 1 + ShiftOS.Frontend/ShiftOS.cs | 2 +- ShiftOS.Frontend/Stories/BeginTutorials.cs | 86 ++++++++++++++++++++++++++++++ 6 files changed, 139 insertions(+), 19 deletions(-) create mode 100644 ShiftOS.Frontend/Stories/BeginTutorials.cs (limited to 'ShiftOS.Frontend') diff --git a/ShiftOS.Frontend/Apps/Terminal.cs b/ShiftOS.Frontend/Apps/Terminal.cs index 5cf899f..a3c5eac 100644 --- a/ShiftOS.Frontend/Apps/Terminal.cs +++ b/ShiftOS.Frontend/Apps/Terminal.cs @@ -23,6 +23,13 @@ namespace ShiftOS.Frontend.Apps { private TerminalControl _terminal = null; + public TerminalControl TerminalControl + { + get + { + return _terminal; + } + } public Terminal() { @@ -139,6 +146,19 @@ namespace ShiftOS.Frontend.Apps protected void RecalculateLayout() { + using(var gfx = Graphics.FromImage(new Bitmap(1, 1))) + { + var cloc = GetPointAtIndex(gfx); + var csize = gfx.MeasureString("#", new Font(LoadedSkin.TerminalFont.Name, LoadedSkin.TerminalFont.Size * _zoomFactor, LoadedSkin.TerminalFont.Style)); + if(cloc.Y - _vertOffset < 0) + { + _vertOffset += cloc.Y - _vertOffset; + } + while((cloc.Y + csize.Height) - _vertOffset > Height) + { + _vertOffset += csize.Height; + } + } } private bool blinkStatus = false; @@ -376,12 +396,12 @@ namespace ShiftOS.Frontend.Apps cursorPos.X = lineMeasure.X; } - gfx.DrawRectangle((int)cursorPos.X, (int)cursorPos.Y, (int)cursorSize.X, (int)cursorSize.Y, LoadedSkin.TerminalForeColorCC.ToColor().ToMonoColor()); + gfx.DrawRectangle((int)cursorPos.X, (int)(cursorPos.Y - _vertOffset), (int)cursorSize.X, (int)cursorSize.Y, LoadedSkin.TerminalForeColorCC.ToColor().ToMonoColor()); } //Draw the text - gfx.DrawString(Text, 2, 2, LoadedSkin.TerminalForeColorCC.ToColor().ToMonoColor(), font, Width - 4); + gfx.DrawString(Text, 0, (int)(0 - _vertOffset), LoadedSkin.TerminalForeColorCC.ToColor().ToMonoColor(), font, Width - 4); } } diff --git a/ShiftOS.Frontend/Desktop/Desktop.cs b/ShiftOS.Frontend/Desktop/Desktop.cs index 7bd5d3c..1bca3f8 100644 --- a/ShiftOS.Frontend/Desktop/Desktop.cs +++ b/ShiftOS.Frontend/Desktop/Desktop.cs @@ -25,6 +25,10 @@ namespace ShiftOS.Frontend.Desktop { Show(); SetupDesktop(); + if (!Shiftorium.UpgradeInstalled("tutorial1")) + { + Story.Start("tutorial1"); + } }; MouseMove += (loc) => diff --git a/ShiftOS.Frontend/Desktop/WindowManager.cs b/ShiftOS.Frontend/Desktop/WindowManager.cs index f1ca59b..fbd42f4 100644 --- a/ShiftOS.Frontend/Desktop/WindowManager.cs +++ b/ShiftOS.Frontend/Desktop/WindowManager.cs @@ -136,26 +136,35 @@ namespace ShiftOS.Frontend.Desktop public void TileWindows() { - - if (AppearanceManager.OpenForms.Count == 0) - return; - int start = 0; - var brdr = AppearanceManager.OpenForms.FirstOrDefault(x => x.IsSidePanel()) as WindowBorder; - if (brdr != null) + try { - brdr.X = 0; - brdr.Y = DesktopStart; - brdr.ResizeWindow(UIManager.Viewport.Width / 4, UIManager.Viewport.Height - LoadedSkin.DesktopPanelHeight); - start = UIManager.Viewport.Width / 4; - } + if (AppearanceManager.OpenForms.Count == 0) + return; + int start = 0; + var brdr = AppearanceManager.OpenForms.FirstOrDefault(x => x.IsSidePanel()) as WindowBorder; + if (brdr != null) + { + brdr.X = 0; + brdr.Y = DesktopStart; + brdr.ResizeWindow(UIManager.Viewport.Width / 4, UIManager.Viewport.Height - LoadedSkin.DesktopPanelHeight); + start = UIManager.Viewport.Width / 4; + } - var wb = (WindowBorder)AppearanceManager.OpenForms.FirstOrDefault(x => !x.IsSidePanel()); - if (wb != null) + var wb = (WindowBorder)AppearanceManager.OpenForms.FirstOrDefault(x => !x.IsSidePanel()); + if (wb != null) + { + wb.X = start; + wb.Y = DesktopStart; + wb.ResizeWindow(UIManager.Viewport.Width - start, UIManager.Viewport.Height - LoadedSkin.DesktopPanelHeight); + } + } + catch(Exception ex) { - wb.X = start; - wb.Y = DesktopStart; - wb.ResizeWindow(UIManager.Viewport.Width - start, UIManager.Viewport.Height - LoadedSkin.DesktopPanelHeight); +#if DEBUG + Debug.WriteLine(" [WARN] Window management fucked up."); + Debug.WriteLine(" [WARN] " + ex.ToString()); +#endif } } } diff --git a/ShiftOS.Frontend/ShiftOS.Frontend.csproj b/ShiftOS.Frontend/ShiftOS.Frontend.csproj index 8decbc6..cb06b3d 100644 --- a/ShiftOS.Frontend/ShiftOS.Frontend.csproj +++ b/ShiftOS.Frontend/ShiftOS.Frontend.csproj @@ -80,6 +80,7 @@ + diff --git a/ShiftOS.Frontend/ShiftOS.cs b/ShiftOS.Frontend/ShiftOS.cs index 866f7f5..faebd50 100644 --- a/ShiftOS.Frontend/ShiftOS.cs +++ b/ShiftOS.Frontend/ShiftOS.cs @@ -235,7 +235,7 @@ namespace ShiftOS.Frontend timeSinceLastPurge += gameTime.ElapsedGameTime.TotalSeconds; - if(timeSinceLastPurge > 30) + if(timeSinceLastPurge > 5) { GraphicsContext.StringCaches.Clear(); timeSinceLastPurge = 0; diff --git a/ShiftOS.Frontend/Stories/BeginTutorials.cs b/ShiftOS.Frontend/Stories/BeginTutorials.cs new file mode 100644 index 0000000..2356a1d --- /dev/null +++ b/ShiftOS.Frontend/Stories/BeginTutorials.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using ShiftOS.Engine; +using ShiftOS.Frontend.GraphicsSubsystem; +namespace ShiftOS.Frontend.Stories +{ + public static class BeginTutorials + { + [Story("tutorial1")] + public static void SystemTutorial() + { + while(AppearanceManager.OpenForms.Count > 0) + { + var frm = AppearanceManager.OpenForms[0]; + AppearanceManager.Close(frm.ParentWindow); + } + int position = 0; + Action keylistener = (e) => + { + switch (position) + { + case 0: + if(e.Key == Microsoft.Xna.Framework.Input.Keys.Enter) + { + position = 1; + } + break; + } + }; + + Action> commandListener = (text, args) => + { + Thread.Sleep(25); + switch (position) + { + case 1: + if(text == "help") + { + position++; + } + break; + } + }; + TerminalBackend.CommandFinished += commandListener; + + Engine.Story.Context.AutoComplete = false; + TerminalBackend.PrefixEnabled = false; + TerminalBackend.InStory = true; + var term = new Apps.Terminal(); + AppearanceManager.SetupWindow(term); + var ctl = term.TerminalControl; + ctl.KeyEvent += keylistener; + ctl.WriteLine(" System installation completed successfully."); + ctl.WriteLine(" Starting system tutorial..."); + Thread.Sleep(500); + ctl.WriteLine(""); + ctl.WriteLine(""); + ctl.WriteLine("Hey there, and welcome to ShiftOS. You are now running the system usage tutorial."); + ctl.WriteLine("This tutorial will guide you through the bare minimum basics of using ShiftOS."); + ctl.WriteLine("When you are ready, strike the [ENTER] key."); + ctl.WriteLine(""); + while (position == 0) + Thread.Sleep(10); + ctl.WriteLine("Enter keypress detected."); + Thread.Sleep(244); + ctl.WriteLine(""); + ctl.WriteLine(" Starting command shell on tty0."); + Thread.Sleep(100); + ctl.WriteLine("The below prompt is a Command Shell. This shell allows you to input commands into ShiftOS to tell it what to do."); + ctl.WriteLine("To get a list of usable ShiftOS commands, type the \"help\" command."); + TerminalBackend.InStory = false; + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + while (position == 1) + Thread.Sleep(10); + + ctl.WriteLine(""); + ctl.WriteLine("Any time you are unsure of a command to run, type the help command."); + ctl.WriteLine("Now, try typing the \"status\" command to see your current system status."); + } + } +} -- cgit v1.2.3