extremely rough savesystem

This commit is contained in:
FloppyDiskDrive 2017-11-23 11:20:53 -06:00
parent 1febbbd405
commit 8fff93eb7d
15 changed files with 125 additions and 15 deletions

View file

@ -1797,6 +1797,16 @@ namespace ShiftOS.Engine.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] UbuntuMono_R {
get {
object obj = ResourceManager.GetObject("UbuntuMono_R", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>

View file

@ -1114,4 +1114,7 @@
<data name="_3beepvirus" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="_3beepvirus" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\3beepvirus.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>..\Resources\3beepvirus.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="UbuntuMono_R" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\UbuntuMono-R.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root> </root>

Binary file not shown.

View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Engine
{
public class SaveSystem
{
public static string gameDir
{
get
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ShiftOS-Rewind");
}
}
public static string fontDir
{
get
{
return gameDir + "\\Fonts";
}
}
}
}

View file

@ -63,6 +63,7 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="SaveSystem.cs" />
<Compile Include="ShiftFS\FileGUI\FileOpener.cs"> <Compile Include="ShiftFS\FileGUI\FileOpener.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
@ -626,6 +627,7 @@
<None Include="Resources\typesound.wav" /> <None Include="Resources\typesound.wav" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\UbuntuMono-R.ttf" />
<None Include="Resources\uparrow.png" /> <None Include="Resources\uparrow.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -730,24 +730,25 @@ namespace ShiftOS.Main.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt; /// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
///
///&lt;grammar version=&quot;1.0&quot; xml:lang=&quot;en-US&quot; ///&lt;grammar version=&quot;1.0&quot; xml:lang=&quot;en-US&quot;
/// xmlns=&quot;http://www.w3.org/2001/06/grammar&quot; /// xmlns=&quot;http://www.w3.org/2001/06/grammar&quot;
/// tag-format=&quot;semantics/1.0&quot; root=&quot;Main&quot;&gt; /// tag-format=&quot;semantics/1.0&quot; root=&quot;Main&quot;&gt;
/// ///
/// &lt;!-- Catalyst Grammar File /// &lt;!-- Catalyst Grammar File
/// ///
/// This file gives Catalyst the ability to recognize /// This file gives Catalyst the ability to recognize
/// audio input and give a proper response. /// audio input and give a proper response.
/// ///
/// --&gt; /// --&gt;
/// ///
/// &lt;rule id=&quot;Main&quot;&gt; /// &lt;rule id=&quot;Main&quot;&gt;
/// &lt;item&gt; /// &lt;item&gt;
/// How much Code Points do I have? /// How much Code Points do I have?
/// &lt;/item&gt; /// &lt;/item&gt;
/// &lt;item&gt;Can you run &lt;ruleref uri=&quot;#programs&quot;/&gt;?&lt;/item&gt; /// &lt;item&gt;Can you run &lt;ruleref uri=&quot;#programs&quot; /&gt;?&lt;/item&gt;
/// &lt;item&gt;Can you mini [rest of string was truncated]&quot;;. /// &lt;item&gt;Can you minimi [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string CatalystGrammar { internal static string CatalystGrammar {
get { get {
@ -1796,6 +1797,16 @@ namespace ShiftOS.Main.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] UbuntuMono_R {
get {
object obj = ResourceManager.GetObject("UbuntuMono_R", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>

View file

@ -1114,4 +1114,7 @@
<data name="_3beepvirus" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="_3beepvirus" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\3beepvirus.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>..\Resources\3beepvirus.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="UbuntuMono_R" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\UbuntuMono-R.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root> </root>

Binary file not shown.

View file

@ -99,6 +99,7 @@
<Compile Include="ShiftOS\Desktop.Designer.cs"> <Compile Include="ShiftOS\Desktop.Designer.cs">
<DependentUpon>Desktop.cs</DependentUpon> <DependentUpon>Desktop.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Terminal\Commands\clear.cs" />
<Compile Include="Terminal\Commands\Hello.cs" /> <Compile Include="Terminal\Commands\Hello.cs" />
<Compile Include="Terminal\Commands\Help.cs" /> <Compile Include="Terminal\Commands\Help.cs" />
<Compile Include="Terminal\Commands\sftp.cs" /> <Compile Include="Terminal\Commands\sftp.cs" />
@ -592,6 +593,7 @@
<None Include="Resources\typesound.wav" /> <None Include="Resources\typesound.wav" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\UbuntuMono-R.ttf" />
<None Include="Resources\uparrow.png" /> <None Include="Resources\uparrow.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -4,6 +4,7 @@ using ShiftOS.Engine;
using ShiftOS.Main.Terminal; using ShiftOS.Main.Terminal;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing.Text;
namespace ShiftOS.Main.ShiftOS.Apps namespace ShiftOS.Main.ShiftOS.Apps
{ {
@ -17,6 +18,7 @@ namespace ShiftOS.Main.ShiftOS.Apps
public bool WaitingResponse = false; public bool WaitingResponse = false;
public string InputReturnText = ""; public string InputReturnText = "";
public Stack<string> c = TerminalBackend.commandBuffer; public Stack<string> c = TerminalBackend.commandBuffer;
private PrivateFontCollection fontCollection = new PrivateFontCollection();
// The below variables makes the terminal... a terminal! // The below variables makes the terminal... a terminal!
string OldText = ""; string OldText = "";
@ -30,6 +32,11 @@ namespace ShiftOS.Main.ShiftOS.Apps
termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox! termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox!
TerminalBackend.trm.Add(this); TerminalBackend.trm.Add(this);
fontCollection.AddFontFile(SaveSystem.fontDir + "\\termFont.ttf");
termmain.Font = new System.Drawing.Font(fontCollection.Families[0], 12F, System.Drawing.FontStyle.Regular);
} }
void Print() void Print()

View file

@ -1,22 +1,21 @@
using System; using System;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using ShiftOS.Engine.Misc;
using ShiftOS.Engine.WindowManager; using ShiftOS.Engine.WindowManager;
using ShiftOS.Main.Properties; using ShiftOS.Main.Properties;
using ShiftOS.Main.ShiftOS.Apps; using ShiftOS.Main.ShiftOS.Apps;
using System.Drawing; using System.IO;
using ShiftOS.Engine;
namespace ShiftOS.Main.ShiftOS namespace ShiftOS.Main.ShiftOS
{ {
// testing github because git hates me // testing github because git hates me
public partial class Desktop : Form public partial class Desktop : Form
{ {
public Desktop() public Desktop()
{ {
InitializeComponent(); InitializeComponent();
timer1.Start(); timer1.Start();
Setup();
Closed += (sender, args) => { Application.Exit(); }; Closed += (sender, args) => { Application.Exit(); };
} }
@ -54,5 +53,11 @@ namespace ShiftOS.Main.ShiftOS
{ {
lblClock.Text = DateTime.Now.ToString("hh:mm:ss"); lblClock.Text = DateTime.Now.ToString("hh:mm:ss");
} }
public void Setup()
{
if (!Directory.Exists(SaveSystem.gameDir)) Directory.CreateDirectory(SaveSystem.gameDir);
if (!Directory.Exists(SaveSystem.fontDir)) Directory.CreateDirectory(SaveSystem.fontDir);
if (!File.Exists(SaveSystem.fontDir + "\\termFont.ttf")) File.WriteAllBytes(SaveSystem.fontDir + "\\termFont.ttf", Resources.UbuntuMono_R);
}
} }
} }

View file

@ -25,13 +25,13 @@ namespace ShiftOS.Main.Terminal.Commands
if (t.Name == args[0]) if (t.Name == args[0])
{ {
solved = true; solved = true;
WriteLine($"{t.Name}: {t.Summary} \nusage: {t.Usage}"); WriteLine($"{t.Name}: {t.Summary} \n usage: {t.Usage}");
break; break;
} }
} }
if (!solved) if (!solved)
{ {
WriteLine("The command \"" + args[0] + "\" could not be found."); WriteLine($"sbash: invalid token: {args[0]}");
} }
} }
} }

View file

@ -0,0 +1,24 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Main.Terminal.Commands
{
public class clear : TerminalCommand
{
public override string Name { get; } = "clear";
public override string Summary { get; } = "Clears all text from the terminal.";
public override string Usage { get; } = "clear";
public override bool Unlocked { get; set; } = false;
public static List<ShiftOS.Apps.Terminal> trm = TerminalBackend.trm;
public override void Run(params string[] parameters)
{
ShiftOS.Apps.Terminal trm = Array.Find(TerminalBackend.trm.ToArray(), w => w.TerminalID == TermID);
trm.Clear();
}
}
}

View file

@ -10,8 +10,8 @@ namespace ShiftOS.Main.Terminal.Commands
public class tcpip : TerminalCommand public class tcpip : TerminalCommand
{ {
public override string Name { get; } = "tcpip"; public override string Name { get; } = "tcpip";
public override string Summary { get; } = "Shows a list of incoming or outgoing commands."; public override string Summary { get; } = "Shows a list of incoming or outgoing connections.";
public override string Usage { get; } = "tcpip <incoming/outcoming>"; public override string Usage { get; } = "tcpip <incoming/outgoing>";
public override bool Unlocked { get; set; } = false; public override bool Unlocked { get; set; } = false;
public override void Run(params string[] args) public override void Run(params string[] args)
@ -29,10 +29,16 @@ namespace ShiftOS.Main.Terminal.Commands
WriteLine("tcpip: syntax error"); WriteLine("tcpip: syntax error");
break; break;
case "incoming": case "incoming":
WriteLine($"Incoming connections from localhost:"); WriteLine("Incoming connections from localhost:");
WriteLine($"IP ADDRESS v4 COMPUTER NAME"); WriteLine($"IP ADDRESS v4 COMPUTER NAME");
WriteLine($"{r.Next(0, 255)}.{r.Next(0, 255)}.{r.Next(0, 255)}.{r.Next(255)} {gen}"); WriteLine($"{r.Next(0, 255)}.{r.Next(0, 255)}.{r.Next(0, 255)}.{r.Next(255)} {gen}");
break; break;
case "outgoing":
WriteLine("Outgoing connections from localhost:");
WriteLine($"IP ADDRESS v4 COMPUTER NAME");
WriteLine($"{r.Next(0, 255)}.{r.Next(0, 255)}.{r.Next(0, 255)}.{r.Next(255)} {gen}");
WriteLine($"[1] outgoing connection(s) is using {r.Next(0, 16)} MiBs of bandwith.");
break;
} }
} }
public string Generate(int amountToGenerate) public string Generate(int amountToGenerate)

View file

@ -88,5 +88,15 @@ namespace ShiftOS.Main.Terminal
// Input.Start(); // Input.Start();
// return Input; // return Input;
//} //}
/// <summary>
/// Clears all text from the terminal.
/// </summary>
public virtual void Clear()
{
ShiftOS.Apps.Terminal trm = Array.Find(TerminalBackend.trm.ToArray(), w => w.TerminalID == TermID);
trm.Clear();
}
} }
} }