Various bugfixes.

This commit is contained in:
Michael 2017-04-02 14:26:25 -04:00
parent 83dd55d028
commit f89cd09283
6 changed files with 129 additions and 20 deletions

View file

@ -47,6 +47,14 @@ namespace ShiftOS.WinForms.Controls
catch { }
}
protected override void Dispose(bool disposing)
{
if (disposing == true)
if(AppearanceManager.ConsoleOut == this)
AppearanceManager.ConsoleOut = null;
base.Dispose(disposing);
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);

View file

@ -419,7 +419,7 @@ namespace ShiftOS.WinForms
Clear();
textgeninput = lblhackwords;
Clear();
this.Invoke(new Action(() =>
{
textgeninput.Font = SkinEngine.LoadedSkin.TerminalFont;
@ -450,7 +450,7 @@ namespace ShiftOS.WinForms
TextType("In ShiftOS, the Terminal is your main control centre for the operating system. You can see system status, check Codepoints, open other programs, buy upgrades, and more.");
Thread.Sleep(500);
TextType("Go ahead and type 'sos.help' to see a list of commands.");
while(TutorialProgress == 0)
while (TutorialProgress == 0)
{
}
@ -459,7 +459,7 @@ namespace ShiftOS.WinForms
TextType("You can run any command, by typing in their Namespace, followed by a period (.), followed by their Command Name.");
Thread.Sleep(500);
TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does.");
while(TutorialProgress == 1)
while (TutorialProgress == 1)
{
}
@ -476,7 +476,7 @@ namespace ShiftOS.WinForms
TextType("You can easily get upgrades using the Shiftorium - a repository of approved ShiftOS upgrades.");
Thread.Sleep(500);
TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades.");
while(TutorialProgress == 2)
while (TutorialProgress == 2)
{
}
@ -500,17 +500,17 @@ namespace ShiftOS.WinForms
TextType("If you want to escape a backslash inside a string, simply type two backslashes instead of one - for example key:\"Back\\\\slash.\"");
Thread.Sleep(500);
TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID.");
while(TutorialProgress == 3)
while (TutorialProgress == 3)
{
}
}
TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!");
Thread.Sleep(500);
TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!");
while (!Shiftorium.UpgradeInstalled("mud_fundamentals"))
{
}
}
TextType("Hooray! You now have the MUD Fundamentals upgrade.");
Thread.Sleep(500);
TextType("You can also earn more Codepoints by playing Pong. To open Pong, you can use the win.open command.");
@ -518,20 +518,20 @@ namespace ShiftOS.WinForms
TextType("If you run win.open without arguments, you can see a list of applications that you can open.");
Thread.Sleep(500);
TextType("Just run win.open without arguments, and this tutorial will be completed!");
while(TutorialProgress == 4)
while (TutorialProgress == 4)
{
}
TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world.");
Thread.Sleep(2000);
this.Invoke(new Action(() =>
Desktop.InvokeOnWorkerThread(() =>
{
OnComplete?.Invoke(this, EventArgs.Empty);
this.Close();
SaveSystem.CurrentSave.StoryPosition = 2;
SaveSystem.SaveGame();
AppearanceManager.SetupWindow(new Applications.Terminal());
}));
});
});
t.IsBackground = true;
t.Start();

View file

@ -664,7 +664,10 @@ namespace ShiftOS.WinForms
/// <param name="act">Act.</param>
public void InvokeOnWorkerThread(Action act)
{
this.Invoke(act);
this.Invoke(new Action(()=>
{
act?.Invoke();
}));
}
public void OpenAppLauncher(Point loc)

View file

@ -36,6 +36,24 @@ namespace ShiftOS.WinForms
{
internal class WinformsWindowManager : WindowManager
{
public int DesktopHeight
{
get
{
return Desktop.Size.Height - ((Shiftorium.UpgradeInstalled("desktop_panel") == true) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0);
}
}
public int TopLocation
{
get
{
if (!Shiftorium.UpgradeInstalled("desktop_panel"))
return 0;
return ((SkinEngine.LoadedSkin.DesktopPanelPosition == 0) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0);
}
}
public override void Close(IShiftOSWindow win)
{
(win as UserControl).Close();
@ -160,9 +178,11 @@ namespace ShiftOS.WinForms
{
List<WindowBorder> formstoclose = new List<WindowBorder>();
foreach (WindowBorder frm in AppearanceManager.OpenForms)
for (int i = 0; i < maxWindows && i < AppearanceManager.OpenForms.Count; i++)
{
formstoclose.Add(frm);
var frm = AppearanceManager.OpenForms[i] as WindowBorder;
if(!frm.IsDialog)
formstoclose.Add(frm);
}
@ -177,7 +197,85 @@ namespace ShiftOS.WinForms
var wb = new WindowBorder(form as UserControl);
ControlManager.SetupWindows();
SetupWindows();
}
public void SetupWindows()
{
var windows = new List<WindowBorder>();
foreach(var win in AppearanceManager.OpenForms)
{
if (win is WindowBorder)
if ((win as WindowBorder).IsDialog == false)
windows.Add(win as WindowBorder);
}
if (Shiftorium.UpgradeInstalled("wm_free_placement"))
return;
else if (windows.Count == 4)
{
var w1 = windows[0];
var w2 = windows[1];
var w3 = windows[2];
var w4 = windows[3];
w1.Location = new Point(0, TopLocation);
w1.Width = Desktop.Size.Width / 2;
w1.Height = DesktopHeight / 2;
w2.Left = w1.Width;
w2.Width = w1.Width;
w2.Height = w1.Height;
w2.Top = w1.Top;
w3.Top = w2.Height;
w3.Height = w1.Height;
w3.Left = 0;
w3.Width = w1.Width;
w4.Width = w3.Width;
w4.Top = w3.Top;
w4.Left = w3.Width;
w4.Height = w3.Height;
}
else if(windows.Count == 3)
{
var w1 = windows[0];
var w2 = windows[1];
var w3 = windows[2];
w1.Location = new Point(0, TopLocation);
w1.Width = Desktop.Size.Width / 2;
w1.Height = DesktopHeight / 2;
w2.Left = w1.Width;
w2.Width = w1.Width;
w2.Height = w1.Height;
w2.Top = w1.Top;
w3.Top = w2.Height;
w3.Height = w1.Height;
w3.Left = 0;
w3.Width = w1.Width + w2.Width;
}
else if (windows.Count == 2)
{
var w1 = windows[0];
var w2 = windows[1];
w1.Location = new Point(0, TopLocation);
w1.Width = Desktop.Size.Width / 2;
w1.Height = DesktopHeight;
w2.Left = w1.Width;
w2.Width = w1.Width;
w2.Height = w1.Height;
w2.Top = w1.Top;
}
else if(windows.Count == 1)
{
var win = windows.FirstOrDefault();
if(win != null)
{
win.Size = new Size(Desktop.Size.Width, DesktopHeight);
win.Location = new Point(0, this.TopLocation);
}
}
}
}
}

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
//#define NOSOUND
#define NOSOUND
using System;
using System.Collections.Generic;

View file

@ -58,7 +58,7 @@ namespace ShiftOS.Engine
{
Desktop.InvokeOnWorkerThread(new Action(() =>
{
UnderlyingControl.SelectBottom();
UnderlyingControl?.SelectBottom();
}));
}
@ -76,7 +76,7 @@ namespace ShiftOS.Engine
{
Desktop.InvokeOnWorkerThread(new Action(() =>
{
UnderlyingControl.Write(value.ToString());
UnderlyingControl?.Write(value.ToString());
select();
}));
}
@ -96,7 +96,7 @@ namespace ShiftOS.Engine
Desktop.InvokeOnWorkerThread(new Action(() =>
{
UnderlyingControl.WriteLine(value);
UnderlyingControl?.WriteLine(value);
select();
}));
}
@ -120,7 +120,7 @@ namespace ShiftOS.Engine
Desktop.InvokeOnWorkerThread(new Action(() =>
{
UnderlyingControl.Write(value.ToString());
UnderlyingControl?.Write(value.ToString());
select();
}));
}