diff options
| -rw-r--r-- | ShiftOS.Frontend/Apps/ChatClient.cs | 2 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Apps/Installer.cs | 14 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Commands.cs | 28 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Properties/Resources.Designer.cs | 43 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Properties/Resources.resx | 6 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Resources/LootInfo.txt | 12 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Resources/banana.cow.stp.txt | 6 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Resources/fire hydrant.cow.stp.txt | 6 | ||||
| -rw-r--r-- | ShiftOS.Frontend/ShiftOS.Frontend.csproj | 3 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/CommandParser.cs | 44 |
10 files changed, 137 insertions, 27 deletions
diff --git a/ShiftOS.Frontend/Apps/ChatClient.cs b/ShiftOS.Frontend/Apps/ChatClient.cs index acb6b6f..1f685dc 100644 --- a/ShiftOS.Frontend/Apps/ChatClient.cs +++ b/ShiftOS.Frontend/Apps/ChatClient.cs @@ -92,6 +92,7 @@ namespace ShiftOS.Frontend.Apps _input.Text = ""; //Let's try the AI stuff... :P + var rmsg = _messages[rnd.Next(_messages.Count)].Message; if (!messagecache.Contains(_messages.Last().Message)) { messagecache.Add(_messages.Last().Message); @@ -99,7 +100,6 @@ namespace ShiftOS.Frontend.Apps SaveCache(); #endif } - var rmsg = messagecache[rnd.Next(messagecache.Count)]; var split = new List<string>(rmsg.Split(' ')); List<string> nmsg = new List<string>(); if (split.Count > 2) diff --git a/ShiftOS.Frontend/Apps/Installer.cs b/ShiftOS.Frontend/Apps/Installer.cs index 86045e1..816e9b5 100644 --- a/ShiftOS.Frontend/Apps/Installer.cs +++ b/ShiftOS.Frontend/Apps/Installer.cs @@ -67,6 +67,17 @@ namespace ShiftOS.Frontend.Apps Engine.Infobox.Show("Upgrade installed.", "The upgrade \"" + _setup.Source + "\" has been installed and is now ready to be used!"); break; + case SetupSource.CowFile: + string cow = _setup.Source; + string[] split = cow.Split('\t'); + string fname = split[0] + ".cow"; + string ascii = split[1]; + string csCowfiles = Paths.GetPath("data") + "/cows"; + if (!DirectoryExists(csCowfiles)) + CreateDirectory(csCowfiles); + WriteAllText(csCowfiles + "/" + fname, ascii); + Engine.Infobox.Show("Cowsay", "New cowfile installed! Have fun with your talking " + split[0] + "!"); + break; } } @@ -126,6 +137,7 @@ namespace ShiftOS.Frontend.Apps public enum SetupSource { - ShiftoriumUpgrade + ShiftoriumUpgrade, + CowFile } } diff --git a/ShiftOS.Frontend/Commands.cs b/ShiftOS.Frontend/Commands.cs index a4b70b0..7218802 100644 --- a/ShiftOS.Frontend/Commands.cs +++ b/ShiftOS.Frontend/Commands.cs @@ -52,6 +52,7 @@ namespace ShiftOS.Frontend { var builder = new List<string>(); int speechlen = (args.ContainsKey("width")) ? Convert.ToInt32(args["width"].ToString()) : 50; + string cowfile = (args.ContainsKey("file")) ? args["file"].ToString() : null; string speech = args["id"].ToString(); AnimalMode _mode = AnimalMode.Normal; if (args.ContainsKey("mode")) @@ -72,7 +73,7 @@ namespace ShiftOS.Frontend } DrawSpeechBubble(ref builder, speechlen, speech); - DrawCow(ref builder, _mode); + DrawCow(ref builder, _mode, cowfile); Console.WriteLine(string.Join(Environment.NewLine, builder.ToArray())); } @@ -150,7 +151,7 @@ namespace ShiftOS.Frontend Youthful } - private static void DrawCow(ref List<string> Builder, AnimalMode AnimalMode) + private static void DrawCow(ref List<string> Builder, AnimalMode AnimalMode, string cowfile) { var startingLinePadding = Builder.First().Length / 4; @@ -194,12 +195,23 @@ namespace ShiftOS.Frontend break; } - - Builder.Add($"{' '.RepeatChar(startingLinePadding)}\\ ^__^"); - Builder.Add($"{' '.RepeatChar(startingLinePadding)} \\ ({eyeChar.RepeatChar(2)})\\_______"); - Builder.Add($"{' '.RepeatChar(startingLinePadding)} (__)\\ )\\/\\"); - Builder.Add($"{' '.RepeatChar(startingLinePadding)} {tongueChar.RepeatChar(1)} ||----w |"); - Builder.Add($"{' '.RepeatChar(startingLinePadding)} || ||"); + string cowpath = Paths.GetPath("data") + "/cows/" + cowfile + ".cow"; + if (string.IsNullOrWhiteSpace(cowfile) || !Utils.FileExists(cowpath)) + { + Builder.Add($"{' '.RepeatChar(startingLinePadding)}\\ ^__^"); + Builder.Add($"{' '.RepeatChar(startingLinePadding)} \\ ({eyeChar.RepeatChar(2)})\\_______"); + Builder.Add($"{' '.RepeatChar(startingLinePadding)} (__)\\ )\\/\\"); + Builder.Add($"{' '.RepeatChar(startingLinePadding)} {tongueChar.RepeatChar(1)} ||----w |"); + Builder.Add($"{' '.RepeatChar(startingLinePadding)} || ||"); + } + else + { + string[] lines = Utils.ReadAllText(cowpath).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + foreach(var line in lines) + { + Builder.Add($"{' '.RepeatChar(startingLinePadding)}{line.Replace("#", eyeChar.ToString())}"); + } + } } } diff --git a/ShiftOS.Frontend/Properties/Resources.Designer.cs b/ShiftOS.Frontend/Properties/Resources.Designer.cs index 0092c49..550ab28 100644 --- a/ShiftOS.Frontend/Properties/Resources.Designer.cs +++ b/ShiftOS.Frontend/Properties/Resources.Designer.cs @@ -61,6 +61,20 @@ namespace ShiftOS.Frontend.Properties { } /// <summary> + /// Looks up a localized string similar to { + /// Name: "Cowsay Banana Cowfile", + /// Description: "It's fun to play with food. Especially in the form of a cowfile. This install file adds a Banana to Cowsay's cowfile list. To use it, simply do \"cowsay --id Hello --file banana\".", + /// SourceType: "CowFile", + /// Source: "banana\t\"-..___ __.='>\r\n`. \"\"\"\"\" ,'\r\n \"-..__ _.-\"\r\n \"\"\"" + ///}. + /// </summary> + public static string banana_cow_stp { + get { + return ResourceManager.GetString("banana.cow.stp", resourceCulture); + } + } + + /// <summary> /// Looks up a localized resource of type System.Drawing.Bitmap. /// </summary> public static System.Drawing.Bitmap cursor_9x_pointer { @@ -98,6 +112,19 @@ namespace ShiftOS.Frontend.Properties { } /// <summary> + /// Looks up a localized string similar to { + /// Name: "Cowsay Fire Hydrant Cowfile", + /// Description: "Ever been so thirsty that you wanted to open a fire hydrant and just take a giant drink of water? Well, you can't do that with this install file, but you can at least get a neat cowfile firehydrant so you can make one talk!", + /// SourceType: "CowFile", + /// Source:"fire hydrant\t \\ !\r\n \\ .:::.\r\n ///|\\\\\\\r\n {=-#-#-=}\r\n .-||||/..\\\r\n c[I ||||\\''/\r\n '-||||||| \r\n |||||||\r\n |||||||\r\n |||||||\r\n [rest of string was truncated]";. + /// </summary> + public static string fire_hydrant_cow_stp { + get { + return ResourceManager.GetString("fire hydrant.cow.stp", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to /* ShiftOS hackables data file /// * /// * This file contains information about all hackable systems in the game's campaign. @@ -152,13 +179,16 @@ namespace ShiftOS.Frontend.Properties { /// ID: "sploitset_keepalive" /// }, /// { + /// FriendlyName: "Banana Cow", + /// LootName: "banana.cow.stp", + /// Rarity: 1, + /// PointTo: "banana_cow_stp", + /// }, + /// { /// FriendlyName: "SSHardline", /// LootName: "sploitset_sshardline.stp", /// Rarity: 1, - /// PointTo: "sploitset_sshardline", - /// ID: "sploitset_keepalive" - /// } - ///]. + /// PointTo: "sploitset_ssh [rest of string was truncated]";. /// </summary> public static string LootInfo { get { @@ -260,6 +290,11 @@ namespace ShiftOS.Frontend.Properties { /// Cost: 1000000000, /// Description: "lolyouarentsupposedtobeabletobuythis", /// Dependencies: "thisupgradeshouldneverexistever", + /// }, + /// { + /// Name: "Pong", + /// Cost: 0, + /// Dependencies: "pong", /// } ///]. /// </summary> diff --git a/ShiftOS.Frontend/Properties/Resources.resx b/ShiftOS.Frontend/Properties/Resources.resx index 0298116..9f9582e 100644 --- a/ShiftOS.Frontend/Properties/Resources.resx +++ b/ShiftOS.Frontend/Properties/Resources.resx @@ -157,4 +157,10 @@ <data name="sploitset_keepalive" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\sploitset_keepalive.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value> </data> + <data name="banana.cow.stp" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\banana.cow.stp.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value> + </data> + <data name="fire hydrant.cow.stp" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\fire hydrant.cow.stp.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value> + </data> </root>
\ No newline at end of file diff --git a/ShiftOS.Frontend/Resources/LootInfo.txt b/ShiftOS.Frontend/Resources/LootInfo.txt index 188eb7c..dc0c109 100644 --- a/ShiftOS.Frontend/Resources/LootInfo.txt +++ b/ShiftOS.Frontend/Resources/LootInfo.txt @@ -13,6 +13,18 @@ ID: "sploitset_keepalive" }, { + FriendlyName: "Banana Cow", + LootName: "banana.cow.stp", + Rarity: 1, + PointTo: "banana_cow_stp", + }, + { + FriendlyName: "Fire Hydrant Cow", + LootName: "fire hydrant.cow.stp", + Rarity: 1, + PointTo: "fire_hydrant_cow_stp", + }, + { FriendlyName: "SSHardline", LootName: "sploitset_sshardline.stp", Rarity: 1, diff --git a/ShiftOS.Frontend/Resources/banana.cow.stp.txt b/ShiftOS.Frontend/Resources/banana.cow.stp.txt new file mode 100644 index 0000000..0147faf --- /dev/null +++ b/ShiftOS.Frontend/Resources/banana.cow.stp.txt @@ -0,0 +1,6 @@ +{ + Name: "Cowsay Banana Cowfile", + Description: "It's fun to play with food. Especially in the form of a cowfile. This install file adds a Banana to Cowsay's cowfile list. To use it, simply do \"cowsay --id Hello --file banana\".", + SourceType: "CowFile", + Source: "banana\t\"-..___ __.='>\r\n`. \"\"\"\"\" ,'\r\n \"-..__ _.-\"\r\n \"\"\"" +}
\ No newline at end of file diff --git a/ShiftOS.Frontend/Resources/fire hydrant.cow.stp.txt b/ShiftOS.Frontend/Resources/fire hydrant.cow.stp.txt new file mode 100644 index 0000000..f25803c --- /dev/null +++ b/ShiftOS.Frontend/Resources/fire hydrant.cow.stp.txt @@ -0,0 +1,6 @@ +{ + Name: "Cowsay Fire Hydrant Cowfile", + Description: "Ever been so thirsty that you wanted to open a fire hydrant and just take a giant drink of water? Well, you can't do that with this install file, but you can at least get a neat cowfile firehydrant so you can make one talk!", + SourceType: "CowFile", + Source:"fire hydrant\t \\ !\r\n \\ .:::.\r\n ///|\\\\\\\r\n {=-#-#-=}\r\n .-||||/..\\\r\n c[I ||||\\''/\r\n '-||||||| \r\n |||||||\r\n |||||||\r\n |||||||\r\n [=======]\r\n" +}
\ No newline at end of file diff --git a/ShiftOS.Frontend/ShiftOS.Frontend.csproj b/ShiftOS.Frontend/ShiftOS.Frontend.csproj index c029107..cfc1132 100644 --- a/ShiftOS.Frontend/ShiftOS.Frontend.csproj +++ b/ShiftOS.Frontend/ShiftOS.Frontend.csproj @@ -107,6 +107,7 @@ <EmbeddedResource Include="Icon.bmp" /> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>PublicResXFileCodeGenerator</Generator> + <SubType>Designer</SubType> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> </ItemGroup> @@ -196,6 +197,8 @@ </ItemGroup> <ItemGroup> <None Include="Resources\pong.txt" /> + <None Include="Resources\banana.cow.stp.txt" /> + <None Include="Resources\fire hydrant.cow.stp.txt" /> <Content Include="Resources\Ports.txt" /> <Content Include="Resources\Payloads.txt" /> <Content Include="Resources\Exploits.txt" /> diff --git a/ShiftOS_TheReturn/CommandParser.cs b/ShiftOS_TheReturn/CommandParser.cs index 7568b98..f234aca 100644 --- a/ShiftOS_TheReturn/CommandParser.cs +++ b/ShiftOS_TheReturn/CommandParser.cs @@ -85,16 +85,22 @@ namespace ShiftOS.Engine int commandPos; int firstValuePos = -1; int lastValuePos = -1; - + int firstTextPart = -1; for (int ii = 0; ii < parts.Count; ii++) { CommandFormat part = parts[ii]; + if(part is CommandFormatText) + { + if(firstTextPart < 0) + firstTextPart = ii; + } if (part is CommandFormatMarker) { if (part is CommandFormatCommand) { commandPos = ii; } + else if (part is CommandFormatValue) { if (firstValuePos > -1) @@ -110,32 +116,44 @@ namespace ShiftOS.Engine int help = -1; bool id_found = false; string id_text = ""; - while (position < text.Length) { if (i >= parts.Count) { - position = text.Length; - command = "+FALSE+"; - i = 0; + i = 1; } - CommandFormat part = parts[i]; - string inp = text.Substring(position); + var part = parts[i]; + string inp = text.Substring(position); + string res = part.CheckValidity(inp); - if(part is CommandFormatText) + if (part is CommandFormatText) { - if(res == "+FALSE+") + if (res == "+FALSE+") { - if(id_found == false) + if (id_found == false) { id_found = true; - id_text = inp.Remove(0,1); - res = ""; - arguments.Add("id", id_text); + currentArgument = "id"; + if (!arguments.ContainsKey("id")) + { + arguments.Add("id", ""); + i = firstValuePos; + position++; + continue; + } + else + { + Console.WriteLine("Duplicate command-line argument detected: id"); + command = "+FALSE+"; + position = text.Length; + + } + } } + } // ok so: |
