adjust textcache purge
This commit is contained in:
parent
1c9767380f
commit
b8da7357b0
7 changed files with 146 additions and 30 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ namespace ShiftOS.Frontend.Desktop
|
|||
{
|
||||
Show();
|
||||
SetupDesktop();
|
||||
if (!Shiftorium.UpgradeInstalled("tutorial1"))
|
||||
{
|
||||
Story.Start("tutorial1");
|
||||
}
|
||||
};
|
||||
|
||||
MouseMove += (loc) =>
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
wb.X = start;
|
||||
wb.Y = DesktopStart;
|
||||
wb.ResizeWindow(UIManager.Viewport.Width - start, UIManager.Viewport.Height - LoadedSkin.DesktopPanelHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var wb = (WindowBorder)AppearanceManager.OpenForms.FirstOrDefault(x => !x.IsSidePanel());
|
||||
if (wb != null)
|
||||
catch(Exception ex)
|
||||
{
|
||||
wb.X = start;
|
||||
wb.Y = DesktopStart;
|
||||
wb.ResizeWindow(UIManager.Viewport.Width - start, UIManager.Viewport.Height - LoadedSkin.DesktopPanelHeight);
|
||||
#if DEBUG
|
||||
Debug.WriteLine("<engine> [WARN] Window management fucked up.");
|
||||
Debug.WriteLine("<engine> [WARN] " + ex.ToString());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
<Compile Include="ShiftOS.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Stories\BeginTutorials.cs" />
|
||||
<Compile Include="Window.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -235,7 +235,7 @@ namespace ShiftOS.Frontend
|
|||
|
||||
timeSinceLastPurge += gameTime.ElapsedGameTime.TotalSeconds;
|
||||
|
||||
if(timeSinceLastPurge > 30)
|
||||
if(timeSinceLastPurge > 5)
|
||||
{
|
||||
GraphicsContext.StringCaches.Clear();
|
||||
timeSinceLastPurge = 0;
|
||||
|
|
86
ShiftOS.Frontend/Stories/BeginTutorials.cs
Normal file
86
ShiftOS.Frontend/Stories/BeginTutorials.cs
Normal file
|
@ -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<KeyEvent> keylistener = (e) =>
|
||||
{
|
||||
switch (position)
|
||||
{
|
||||
case 0:
|
||||
if(e.Key == Microsoft.Xna.Framework.Input.Keys.Enter)
|
||||
{
|
||||
position = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
Action<string, Dictionary<string, object>> 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("<kernel> System installation completed successfully.");
|
||||
ctl.WriteLine("<cinemgr> 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("<shd> 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.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -231,11 +231,13 @@ namespace ShiftOS.Engine
|
|||
try
|
||||
{
|
||||
CommandHandler.Invoke(null, new[] { args });
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
CommandHandler.Invoke(null, null);
|
||||
}
|
||||
CommandFinished?.Invoke(Localization.Parse(this.CommandInfo.name), args);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,6 +272,8 @@ namespace ShiftOS.Engine
|
|||
|
||||
}
|
||||
|
||||
public static event Action<string, Dictionary<string, object>> CommandFinished;
|
||||
|
||||
public class MemoryTextWriter : System.IO.TextWriter
|
||||
{
|
||||
public override Encoding Encoding
|
||||
|
@ -402,14 +406,12 @@ namespace ShiftOS.Engine
|
|||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return;
|
||||
var tw = new MemoryTextWriter();
|
||||
Console.SetOut(tw);
|
||||
var args = GetArgs(ref text);
|
||||
var oargs = JsonConvert.DeserializeObject<Dictionary<string, object>>(GetSentArgs(args));
|
||||
try
|
||||
{
|
||||
var args = GetArgs(ref text);
|
||||
|
||||
bool commandWasClient = RunClient(text, args, isRemote);
|
||||
|
||||
if (!commandWasClient)
|
||||
{
|
||||
Console.WriteLine("Error: Command not found.");
|
||||
|
@ -423,12 +425,6 @@ namespace ShiftOS.Engine
|
|||
PrefixEnabled = true;
|
||||
|
||||
}
|
||||
string buffer = tw.ToString();
|
||||
LastCommandBuffer = buffer;
|
||||
Console.SetOut(new TerminalTextWriter());
|
||||
if(!isRemote)
|
||||
Console.Write(buffer);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Reference in a new issue