From fe4121c5411f39b4ccf702700d7681184adb538f Mon Sep 17 00:00:00 2001 From: MichaelTheShifter Date: Fri, 22 Jul 2016 12:23:28 -0400 Subject: Shifter UI rewrite, fix shiftnet and spkg paths. --- source/WindowsFormsApplication1/Apps/Terminal.cs | 1625 ++++++++++++---------- 1 file changed, 879 insertions(+), 746 deletions(-) (limited to 'source/WindowsFormsApplication1/Apps/Terminal.cs') diff --git a/source/WindowsFormsApplication1/Apps/Terminal.cs b/source/WindowsFormsApplication1/Apps/Terminal.cs index f95025d..356e3de 100644 --- a/source/WindowsFormsApplication1/Apps/Terminal.cs +++ b/source/WindowsFormsApplication1/Apps/Terminal.cs @@ -14,6 +14,8 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using ShiftUI; +using ShiftOS.FinalMission; +using ShiftOS; namespace ShiftOS { @@ -1383,894 +1385,1025 @@ Password: z7fjsd3"); public void DoCommand() { - API.LastRanCommand = command; - string[] args = command.ToLower().Split(' '); - switch (args[0]) + //Grab the type of this class using Reflection. + var terminal = this.GetType(); + string[] cmdargs = command.Split(' '); + var method_info = terminal.GetMethod("cmd_" + cmdargs[0].ToLower()); + if(method_info != null) { - case "ls": - case "dir": - if(API.Upgrades["fileskimmer"]) + method_info.Invoke(this, new object[] { cmdargs }); + } + else + { + terminal.GetMethod("cmd_default").Invoke(this, new object[] { cmdargs }); + } + } + + #region Terminal command methods + + /* + * Adding terminal commands has been changed. + * + * It's now done in a way that doesn't require hardcoding. + * + * Simply add a new method here with a prefix 'cmd_', for example 'cmd_05tray', and + * one argument of type 'string[]'. Then, put all the stuff you want your command to + * do in that method, and try running your command (without the 'cmd_' prefix) in the + * Terminal and it should work just fine. + * + * Thanks to @carverh for inspiring this by making all commands their own function. + */ + + public void cmd_dir(String[] args) + { + if (API.Upgrades["fileskimmer"]) + { + foreach (var d in Directory.GetDirectories(current_dir)) + { + WriteLine($"[DIR] {new DirectoryInfo(d).Name}"); + } + foreach (var d in Directory.GetFiles(current_dir)) + { + WriteLine($"{new FileInfo(d).Name}"); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_cd(String[] args) + { + try + { + if (API.Upgrades["fileskimmer"]) + { + if (args[1] == "..") { - foreach(var d in Directory.GetDirectories(current_dir)) + if (GetPath(current_dir) != "/") { - WriteLine($"[DIR] {new DirectoryInfo(d).Name}"); + current_dir = GetParent(current_dir); + SetPrefix($"{API.Username}@{API.OSName} in {GetPath(current_dir)} $> "); } - foreach (var d in Directory.GetFiles(current_dir)) + else { - WriteLine($"{new FileInfo(d).Name}"); + WriteLine("cd: Can't go up past the root."); } } else { - wrongcommand(); - } - break; - case "cd": - if (API.Upgrades["fileskimmer"]) - { - if (args[1] == "..") + string newdir = current_dir + OSInfo.DirectorySeparator; + foreach (var dir in Directory.GetDirectories(current_dir)) { - if (GetPath(current_dir) != "/") - { - current_dir = GetParent(current_dir); - SetPrefix($"{API.Username}@{API.OSName} in {GetPath(current_dir)} $> "); - } - else - { - WriteLine("cd: Can't go up past the root."); - } - } - else - { - string newdir = current_dir + OSInfo.DirectorySeparator; - foreach (var dir in Directory.GetDirectories(current_dir)) - { - if (new DirectoryInfo(dir).Name.ToLower() == args[1]) - newdir = dir; - } - current_dir = newdir; - SetPrefix($"{API.Username}@{API.OSName} in {GetPath(current_dir)} $> "); + if (new DirectoryInfo(dir).Name.ToLower() == args[1]) + newdir = dir; } + current_dir = newdir; + SetPrefix($"{API.Username}@{API.OSName} in {GetPath(current_dir)} $> "); } - break; - case "upg": - if(API.DeveloperMode) - { - try - { - switch(args[1]) - { - case "get": - WriteLine(API.Upgrades[args[2]].ToString()); - break; - } - } - catch - { + } + } + catch (Exception e) + { + WriteLine("cd: " + e); + } + } - } - } - else - { - wrongcommand(); - } - break; - case "endgame_test": - if (API.DeveloperMode) + + public void cmd_upg(String[] args) + { + if (API.DeveloperMode) + { + try + { + switch (args[1]) { - try - { - switch (args[1]) - { - case "choice_screen": - var cscreen = new ShiftOS.FinalMission.ChooseYourApproach(); - cscreen.WindowState = FormWindowState.Maximized; - //cscreen.TopMost = true; - cscreen.Show(); - break; - case "limitedmode": - API.LimitedMode = !API.LimitedMode; - WriteLine($"Limited mode set to {API.LimitedMode}."); - break; - } - } - catch - { - WriteLine("Invalid arguments."); - } + case "get": + WriteLine(API.Upgrades[args[2]].ToString()); + break; } - else + } + catch + { + + } + } + else + { + wrongcommand(); + } + } + + public void cmd_endgame_test(String[] args) + { + if (API.DeveloperMode) + { + try + { + switch (args[1]) { - wrongcommand(); + case "choice_screen": + var cscreen = new ShiftOS.FinalMission.ChooseYourApproach(); + cscreen.WindowState = FormWindowState.Maximized; + //cscreen.TopMost = true; + cscreen.Show(); + break; + case "limitedmode": + API.LimitedMode = !API.LimitedMode; + WriteLine($"Limited mode set to {API.LimitedMode}."); + break; } - break; - case "htutorial": - ShiftOS.Hacking.StartBattleTutorial(); - break; - case "fake_buy": - if (API.DeveloperMode) + } + catch + { + WriteLine("Invalid arguments."); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_htutorial(String[] args) + { + ShiftOS.Hacking.StartBattleTutorial(); + } + + public void cmd_fake_buy(String[] args) + { + if (API.DeveloperMode) + { + try + { + if (API.Upgrades.ContainsKey(args[1])) { - try - { - if (API.Upgrades.ContainsKey(args[1])) - { - API.Upgrades[args[1]] = true; - WriteLine($"Bought upgrade {args[1]}."); - API.CurrentSession.SetupAppLauncher(); - API.UpdateWindows(); - SaveSystem.Utilities.saveGame(); - } - else - { - WriteLine("Upgrade not found."); - } - } - catch - { - WriteLine("fake_buy: Bad arguments."); - } + API.Upgrades[args[1]] = true; + WriteLine($"Bought upgrade {args[1]}."); + API.CurrentSession.SetupAppLauncher(); + API.UpdateWindows(); + SaveSystem.Utilities.saveGame(); } else { - wrongcommand(); + WriteLine("Upgrade not found."); } - break; - case "connections": - try - { - switch(args[1]) - { - case "list": - foreach(var client in Package_Grabber.clients) - { - WriteLine($"Hostname: {client.Key}, Port: {client.Value.RemotePort}, Online: {client.Value.IsConnected}"); - } - break; - case "gui": - API.CreateForm(new ConnectionManager(), "Connections", API.GetIcon("Connections")); - break; - case "drop": - foreach(var client in Package_Grabber.clients) - { - Package_Grabber.Disconnect(client.Key); - } - break; - case "add": - string host = args[2]; - int port = 0; - int.TryParse(args[3], out port); - if (!Package_Grabber.clients.ContainsKey(host)) - { - Package_Grabber.ConnectToServer(host, port); - WriteLine("Connection to host established successfully."); - } - else - { - var c = Package_Grabber.clients[host]; - if (c.IsConnected == false) - { - c.Connect(host, port); - WriteLine("Re-established connection with host."); - } - else { - WriteLine("This host has been connected to already."); - } - } - break; - } - } - catch - { - WriteLine("connections: Missing arguments."); - } - break; - case "story": - if(API.DeveloperMode == true && API.Upgrades["shiftnet"]) - { - try + } + catch + { + WriteLine("fake_buy: Bad arguments."); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_connections(String[] args) + { + try + { + switch (args[1]) + { + case "list": + foreach (var client in Package_Grabber.clients) { - switch(args[1]) - { - case "aidennirh": - StartAidenNirhStory(); - break; - case "devxfurious": - StartDevXFuriousStory(); - break; - case "battletut": - StartHackerBattleIntro(); - break; - case "otherplayer": - StartDevXFuriousStory(); - break; - case "hacker101": - StartHacker101Story(); - break; - } + WriteLine($"Hostname: {client.Key}, Port: {client.Value.RemotePort}, Online: {client.Value.IsConnected}"); } - catch + break; + case "gui": + API.CreateForm(new ConnectionManager(), "Connections", API.GetIcon("Connections")); + break; + case "drop": + foreach (var client in Package_Grabber.clients) { - WriteLine("Missing arguments."); + Package_Grabber.Disconnect(client.Key); } - } - else { wrongcommand(); } - break; - case "make": - try - { - string path = command.Replace("make ", ""); - string realpath = $"{Paths.SaveRoot}{path.Replace("/", OSInfo.DirectorySeparator)}"; - if (File.Exists(realpath + OSInfo.DirectorySeparator + "main.lua")) + break; + case "add": + string host = args[2]; + int port = 0; + int.TryParse(args[3], out port); + if (!Package_Grabber.clients.ContainsKey(host)) { - WriteLine("Compiling to " + path + ".saa"); - ZipFile.CreateFromDirectory(realpath, realpath + ".saa"); + Package_Grabber.ConnectToServer(host, port); + WriteLine("Connection to host established successfully."); } else { - WriteLine($"make: *** No rule to make target \"{realpath}\". Stop."); - } - } - catch - { - WriteLine("make: Invalid arguments."); - } - break; - case "linux": - if(API.DeveloperMode) - { - WriteLine("Upgrading your system..."); - foreach(var upg in Shiftorium.Utilities.GetAvailable()) - { - API.Upgrades[upg.id] = true; - WriteLine("Installed upgrade \"" + upg.Name + "\"..."); - } - API.UpdateWindows(); - API.CurrentSession.SetupDesktop(); - } - else - { - wrongcommand(); - } - break; - case "netgen": - WriteLine("Starting netgen..."); - API.CreateForm(new NetGen(), "Network Generator", API.GetIcon("Terminal")); - break; - case "lua": - if(API.DeveloperMode == true) - { - try - { - string f = args[1]; - WriteLine(f); - f = command.Remove(0, 4); - WriteLine(f); - string real = $"{Paths.SaveRoot}{f.Replace("/", OSInfo.DirectorySeparator)}"; - WriteLine(real); - if (File.Exists(real)) + var c = Package_Grabber.clients[host]; + if (c.IsConnected == false) { - WriteLine("Running Lua script at " + f + "."); - var l = new LuaInterpreter(real); + c.Connect(host, port); + WriteLine("Re-established connection with host."); } else { - WriteLine("Lua script file not found."); + WriteLine("This host has been connected to already."); } } - catch - { - this.LuaMode = true; - this.Interpreter = new LuaInterpreter(); - this.Interpreter.mod.print = new Action((text) => WriteLine(text)); - this.Interpreter.mod.exit = new Action(() => - { - this.LuaMode = false; - this.Interpreter = null; - WriteLine($"{API.CurrentSave.username}@{API.CurrentSave.osname} $> "); - }); - WriteLine("ShiftOS Lua Interpreter - v1.0"); - WriteLine("Created by Michael VanOverbeek"); - WriteLine(Environment.NewLine + "How to use: Simply type some Lua code and watch it come to life. Code can be executed on one line, and unlike most interpreters, you can access code from one line in another."); - WriteLine(Environment.NewLine + "When you're done, simply press the Enter key to execute the code." + Environment.NewLine); - } - } - else + break; + } + } + catch + { + WriteLine("connections: Missing arguments."); + } + } + + public void cmd_story(String[] args) + { + if (API.DeveloperMode == true && API.Upgrades["shiftnet"]) + { + try + { + switch (args[1]) { - wrongcommand(); + case "aidennirh": + StartAidenNirhStory(); + break; + case "devxfurious": + StartDevXFuriousStory(); + break; + case "battletut": + StartHackerBattleIntro(); + break; + case "otherplayer": + StartDevXFuriousStory(); + break; + case "hacker101": + StartHacker101Story(); + break; } - break; - case "hack": - if(API.Upgrades["hacking"] == true) + } + catch + { + WriteLine("Missing arguments."); + } + } + else { wrongcommand(); } + } + + public void cmd_make(String[] args) + { + try + { + string path = command.Replace("make ", ""); + string realpath = $"{Paths.SaveRoot}{path.Replace("/", OSInfo.DirectorySeparator)}"; + if (File.Exists(realpath + OSInfo.DirectorySeparator + "main.lua")) + { + WriteLine("Compiling to " + path + ".saa"); + ZipFile.CreateFromDirectory(realpath, realpath + ".saa"); + } + else + { + WriteLine($"make: *** No rule to make target \"{realpath}\". Stop."); + } + } + catch + { + WriteLine("make: Invalid arguments."); + } + } + + public void cmd_devupg(String[] args) + { + if (API.DeveloperMode) + { + WriteLine("Upgrading your system..."); + foreach (var upg in Shiftorium.Utilities.GetAvailable()) + { + API.Upgrades[upg.id] = true; + WriteLine("Installed upgrade \"" + upg.Name + "\"..."); + } + API.UpdateWindows(); + API.CurrentSession.SetupDesktop(); + } + else + { + wrongcommand(); + } + } + + public void cmd_netgen(String[] args) + { + WriteLine("Starting netgen..."); + API.CreateForm(new NetGen(), "Network Generator", API.GetIcon("Terminal")); + } + + public void cmd_lua(String[] args) + { + if (API.DeveloperMode == true) + { + try + { + string f = args[1]; + WriteLine(f); + f = command.Remove(0, 4); + WriteLine(f); + string real = $"{Paths.SaveRoot}{f.Replace("/", OSInfo.DirectorySeparator)}"; + WriteLine(real); + if (File.Exists(real)) { - StartHackingSession("random"); + WriteLine("Running Lua script at " + f + "."); + var l = new LuaInterpreter(real); } else { - wrongcommand(); + WriteLine("Lua script file not found."); } - break; - case "virusscanner": - case "vscan": - if(API.Upgrades["virusscanner"] == true) + } + catch + { + this.LuaMode = true; + this.Interpreter = new LuaInterpreter(); + this.Interpreter.mod.print = new Action((text) => WriteLine(text)); + this.Interpreter.mod.exit = new Action(() => + { + this.LuaMode = false; + this.Interpreter = null; + WriteLine($"{API.CurrentSave.username}@{API.CurrentSave.osname} $> "); + }); + WriteLine("ShiftOS Lua Interpreter - v1.0"); + WriteLine("Created by Michael VanOverbeek"); + WriteLine(Environment.NewLine + "How to use: Simply type some Lua code and watch it come to life. Code can be executed on one line, and unlike most interpreters, you can access code from one line in another."); + WriteLine(Environment.NewLine + "When you're done, simply press the Enter key to execute the code." + Environment.NewLine); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_hack(String[] args) + { + if (API.Upgrades["hacking"] == true) + { + StartHackingSession("random"); + } + else + { + wrongcommand(); + } + } + + public void cmd_vscan(String[] args) + { + if (API.Upgrades["virusscanner"] == true) + { + WriteLine("Scanning for infected files..."); + var goodList = new Dictionary(); + foreach (KeyValuePair kv in Viruses.Infections) + { + if (kv.Value.Contains(";")) { - WriteLine("Scanning for infected files..."); - var goodList = new Dictionary(); - foreach (KeyValuePair kv in Viruses.Infections) + foreach (string file in kv.Value.Split(';')) { - if(kv.Value.Contains(";")) + if (goodList.ContainsKey(file)) { - foreach(string file in kv.Value.Split(';')) - { - if (goodList.ContainsKey(file)) - { - goodList[file] += ", " + kv.Key; - } - else { - goodList.Add(file, kv.Key); - } - } + goodList[file] += ", " + kv.Key; } else { - if (goodList.ContainsKey(kv.Value)) - { - goodList[kv.Value] += ", " + kv.Key; - } - else { - goodList.Add(kv.Value, kv.Key); - } + goodList.Add(file, kv.Key); } } - WriteLine("Scan complete."); - if (goodList.Count > 0) - { - foreach (KeyValuePair kv in goodList) - { - WriteLine("File " + kv.Key + " is infected with " + kv.Value + ". Disinfecting..."); - Viruses.DisInfect(kv.Key); - } - WriteLine("Disinfection complete."); - } - else - { - WriteLine("No infections found. You are safe."); - } - } - break; - case "infections": - if (API.DeveloperMode == true) - { - foreach (KeyValuePair kv in Viruses.Infections) - { - WriteLine(kv.Key + " @ " + kv.Value); - } - } - else - { - wrongcommand(); - } - break; - case "binarywater": - if (API.DeveloperMode) - { - ShiftOS.Hacking.AddCharacter(new Character("Philip Adams", "Hello, and welcome to another episode of OSFirstTimer.", 100, 100, 0)); - WriteLine("Philip Adams is now in the list of hirable hackers."); } else { - WriteLine("I see you went in the ShiftOS source code... ummm yeah... this isn't a developer mode release so I can't just give you a full-skilled hacker even if you beg."); - } - break; - case "color": - try - { - if(API.Upgrades["setterminalcolors"] == true) + if (goodList.ContainsKey(kv.Value)) { - - Color bcol = SetColor(args[1]); - Color tcol = SetColor(args[2]); - API.CurrentSkin.TerminalTextColor = tcol; - API.CurrentSkin.TerminalBackColor = bcol; - - } - } - catch(Exception) - { - WriteLine("color: Missing arguments."); - } - break; - case "encrypt": - if (API.DeveloperMode == true) - { - string messageToEncrypt = command.Replace("encrypt ", ""); - string encryptedMessage = API.Encryption.Encrypt(messageToEncrypt); - WriteLine("Encrypted Message: " + encryptedMessage); - } - else - { - wrongcommand(); - } - break; - case "font": - if(API.Upgrades["setterminalfont"] == true) - { - var fname = command.Replace("font ", ""); - if(GetFonts().Contains(fname)) - { - API.CurrentSkin.TerminalFontStyle = fname; + goodList[kv.Value] += ", " + kv.Key; } else { - WriteLine("font: Unrecognized font name \"" + fname + "\". Note: Font names are case sensitive."); + goodList.Add(kv.Value, kv.Key); } } - else - { - wrongcommand(); - } - break; - case "colorlist": - if(API.Upgrades["setterminalcolors"] == true) - { - foreach(string itm in GetColorList()) - { - WriteLine(itm); - } - } - else + } + WriteLine("Scan complete."); + if (goodList.Count > 0) + { + foreach (KeyValuePair kv in goodList) { - wrongcommand(); + WriteLine("File " + kv.Key + " is infected with " + kv.Value + ". Disinfecting..."); + Viruses.DisInfect(kv.Key); } - break; - case "spkg": - if (!API.LimitedMode) + WriteLine("Disinfection complete."); + } + else + { + WriteLine("No infections found. You are safe."); + } + } + } + + public void cmd_infections(String[] args) + { + if (API.DeveloperMode == true) + { + foreach (KeyValuePair kv in Viruses.Infections) + { + WriteLine(kv.Key + " @ " + kv.Value); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_binarywater(String[] args) + { + if (API.DeveloperMode) + { + ShiftOS.Hacking.AddCharacter(new Character("Philip Adams", "Hello, and welcome to another episode of OSFirstTimer.", 100, 100, 0)); + WriteLine("Philip Adams is now in the list of hirable hackers."); + WriteLine("\" I Don't Think This is Canon \" -Carver"); + } + else + { + WriteLine("I see you went in the ShiftOS source code... ummm yeah... this isn't a developer mode release so I can't just give you a full-skilled hacker even if you beg."); + } + } + + public void cmd_color(String[] args) + { + try + { + if (API.Upgrades["setterminalcolors"] == true) + { + + Color bcol = SetColor(args[1]); + Color tcol = SetColor(args[2]); + API.CurrentSkin.TerminalTextColor = tcol; + API.CurrentSkin.TerminalBackColor = bcol; + + } + } + catch (Exception) + { + WriteLine("color: Missing arguments."); + } + } + + public void cmd_encrypt(String[] args) + { + if (API.DeveloperMode == true) + { + string messageToEncrypt = command.Replace("encrypt ", ""); + string encryptedMessage = API.Encryption.Encrypt(messageToEncrypt); + WriteLine("Encrypted Message: " + encryptedMessage); + } + else + { + wrongcommand(); + } + } + + public void cmd_font(String[] args) + { + if (API.Upgrades["setterminalfont"] == true) + { + var fname = command.Replace("font ", ""); + if (GetFonts().Contains(fname)) + { + API.CurrentSkin.TerminalFontStyle = fname; + } + else + { + WriteLine("font: Unrecognized font name \"" + fname + "\". Note: Font names are case sensitive."); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_colorlist(String[] args) + { + if (API.Upgrades["setterminalcolors"] == true) + { + foreach (string itm in GetColorList()) + { + WriteLine(itm); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_spkg(String[] args) + { + if (!API.LimitedMode) + { + if (API.Upgrades["shiftnet"] == true) + { + try { - if (API.Upgrades["shiftnet"] == true) + switch (args[1].ToLower()) { - try - { - switch (args[1].ToLower()) + case "install": + if (args[2] != null && args[2] != "") { - case "install": - if (args[2] != null && args[2] != "") + string pkgname = args[2].ToLower().Replace(".pkg", ""); + if (Package_Grabber.GetPackage(pkgname) == true) + { + WriteLine("Downloaded package '" + pkgname + "' from shiftnet://main/spkg/ successfully. Installing now."); + string r = Package_Grabber.ExtractPackage(); + if (r == "fail") + { + WriteLine("[FATAL] Could not install package."); + WriteLine("spkg: Killed."); + } + else { - string pkgname = args[2].ToLower().Replace(".pkg", ""); - if (Package_Grabber.GetPackage(pkgname) == true) + WriteLine("Extracted " + pkgname + " to " + r + "..."); + var res2 = Package_Grabber.InstallPackage(r + "\\"); + if (res2 != "success") { - WriteLine("Downloaded package '" + pkgname + "' from shiftnet://main/spkg/ successfully. Installing now."); - string r = Package_Grabber.ExtractPackage(); - if (r == "fail") - { - WriteLine("[FATAL] Could not install package."); - WriteLine("spkg: Killed."); - } - else - { - WriteLine("Extracted " + pkgname + " to " + r + "..."); - var res2 = Package_Grabber.InstallPackage(r + "\\"); - if (res2 != "success") - { - WriteLine("[FATAL] Could not install package. " + res2); - WriteLine("spkg: Killed."); - } - else - { - WriteLine("[DONE] Package installed."); - } - } + WriteLine("[FATAL] Could not install package. " + res2); + WriteLine("spkg: Killed."); } else { - WriteLine("spkg: Package '" + args[2] + "' not found."); + WriteLine("[DONE] Package installed."); } } - break; - default: - WriteLine("spkg: Invalid argument: " + args[1]); - break; - } - } - catch (Exception ex) - { - WriteLine("spkg: " + ex.Message); - } - } - else - { - wrongcommand(); - } - } - else - { - try - { - if(args[2] == "god_utils") - { - if(FinalMission.EndGameHandler.GodModeInstallEnabled == true) - { - var t = new Thread(new ThreadStart(new Action(() => + } + else { - WriteLine("Downloading package 'god_utils'... Please wait."); - Thread.Sleep(10000); - WriteLine("Download complete."); - Thread.Sleep(100); - WriteLine("Beginning installation."); - Thread.Sleep(1000); - WriteLine(@" == GOD MODE == - -God Mode gives you FULL control of ShiftOS. You can add/remove Codepoints, buy or unbuy Shiftorium upgrades, and can do whatever you want. - -Installing core applications..."); - Thread.Sleep(250); - WriteLine("Installing subpackage 'json_edit'..."); - Thread.Sleep(250); - WriteLine("Installing subpackage 'upgrade_mod'..."); - Thread.Sleep(100); - WriteLine("Installing subpackage 'hijacker'..."); - Thread.Sleep(500); - WriteLine(@" == HIJACKER by DevX == - -HIJACKER is a utility that allows you to hijack any system and install ShiftOS on it during a hacker battle."); - Thread.Sleep(100); - WriteLine("[hijacker] Injecting HIJACKER code into hbattleui.sft..."); - Thread.Sleep(150); - WriteLine("[hijacker] Done."); - this.Invoke(new Action(() => - { - StartChoice1EndStory(); - })); - }))); - t.Start(); - } - else - { - WriteLine("spkg: Package '" + args[2] + "' not found."); - } - } - else - { - WriteLine("spkg: Package '" + args[2] + "' not found."); - } - } - catch - { - WriteLine("spkg: Missing arguments."); - } - } - break; - case "alias": - try - { - switch(args[1]) - { - case "-?": - case "--help": - WriteLine("Aliases Help" + Environment.NewLine); - WriteLine("Alias is a command that lets you create aliases for other commands. You could make a command 'upgrade' alias 'shiftorium' if you wanted." + Environment.NewLine); - WriteLine("Arguments:"); - WriteLine(" -h, --help: Displays this screen."); - WriteLine("-a, --add : Adds a new alias."); - WriteLine("-d, --delete : Deletes an alias."); - WriteLine("-l, --list: Shows all available aliases."); - break; - case "--add": - case "-a": - if(API.AddAlias(args[2], command.Replace("alias " + args[1] + " " + args[2] + " ", ""))) - { - WriteLine("Alias added successfully."); - API.SaveAliases(); - } - else - { - WriteLine("That alias already exists."); - } - break; - case "--delete": - case "-d": - if(API.RemoveAlias(args[2]) == true) - { - WriteLine("Alias \"" + args[2] + "\" removed successfully."); - API.SaveAliases(); - } - else - { - WriteLine("That alias doesn't exist."); - } - break; - case "-l": - case "--list": - WriteLine("Aliases:"); - foreach(KeyValuePair kv in API.CommandAliases) - { - WriteLine(kv.Key + " => " + kv.Value); + WriteLine("spkg: Package '" + args[2] + "' not found."); + } } break; default: - WriteLine("alias: Invalid argument. Try alias --help for help with the Alias command."); + WriteLine("spkg: Invalid argument: " + args[1]); break; } } - catch + catch (Exception ex) { - WriteLine("alias: Missing arguments. Try alias --help for help with the Alias command."); + WriteLine("spkg: " + ex.Message); } - break; - case "username": - if(API.Upgrades["customusername"] == true) + } + else + { + wrongcommand(); + } + } + else + { + try + { + if (args[2] == "god_utils") { - try + if (FinalMission.EndGameHandler.GodModeInstallEnabled == true) { - API.CurrentSave.username = args[1]; + var t = new Thread(new ThreadStart(new Action(() => + { + WriteLine("Downloading package 'god_utils'... Please wait."); + Thread.Sleep(10000); + WriteLine("Download complete."); + Thread.Sleep(100); + WriteLine("Beginning installation."); + Thread.Sleep(1000); + WriteLine(@" == GOD MODE == +God Mode gives you FULL control of ShiftOS. You can add/remove Codepoints, buy or unbuy Shiftorium upgrades, and can do whatever you want. +Installing core applications..."); + Thread.Sleep(250); + WriteLine("Installing subpackage 'json_edit'..."); + Thread.Sleep(250); + WriteLine("Installing subpackage 'upgrade_mod'..."); + Thread.Sleep(100); + WriteLine("Installing subpackage 'hijacker'..."); + Thread.Sleep(500); + WriteLine(@" == HIJACKER by DevX == +HIJACKER is a utility that allows you to hijack any system and install ShiftOS on it during a hacker battle."); + Thread.Sleep(100); + WriteLine("[hijacker] Injecting HIJACKER code into hbattleui.sft..."); + Thread.Sleep(150); + WriteLine("[hijacker] Done."); + this.Invoke(new Action(() => + { + StartChoice1EndStory(); + })); + }))); + t.Start(); } - catch + else { - WriteLine("username: Missing arguments."); + WriteLine("spkg: Package '" + args[2] + "' not found."); } } else { - wrongcommand(); + WriteLine("spkg: Package '" + args[2] + "' not found."); } - break; - case "osname": - if (API.Upgrades["customusername"] == true) - { - try + } + catch + { + WriteLine("spkg: Missing arguments."); + } + } + } + + /// + /// Command Functions, to Be Used For ShiftBatch + /// + /// String[] args + public void cmd_alias(String[] args) + { + try + { + switch (args[1]) + { + case "-?": + case "--help": + WriteLine("Aliases Help" + Environment.NewLine); + WriteLine("Alias is a command that lets you create aliases for other commands. You could make a command 'upgrade' alias 'shiftorium' if you wanted." + Environment.NewLine); + WriteLine("Arguments:"); + WriteLine(" -h, --help: Displays this screen."); + WriteLine("-a, --add : Adds a new alias."); + WriteLine("-d, --delete : Deletes an alias."); + WriteLine("-l, --list: Shows all available aliases."); + break; + case "--add": + case "-a": + if (API.AddAlias(args[2], command.Replace("alias " + args[1] + " " + args[2] + " ", ""))) + { + WriteLine("Alias added successfully."); + API.SaveAliases(); + } + else { - API.CurrentSave.osname = args[1]; + WriteLine("That alias already exists."); } - catch + break; + case "--delete": + case "-d": + if (API.RemoveAlias(args[2]) == true) { - WriteLine("osname: Missing arguments."); + WriteLine("Alias \"" + args[2] + "\" removed successfully."); + API.SaveAliases(); } - } - else - { - wrongcommand(); - } - break; - - case "unity": - if (API.Upgrades["unitymode"] == true) - { - API.CurrentSession.SetUnityMode(); - API.CurrentSession.SetupDesktop(); - txtterm.Focus(); - } else - { - wrongcommand(); - } - break; - case "time": - if (API.Upgrades["pmandam"] == false) - { - if (API.Upgrades["hourssincemidnight"] == false) + else { - if (API.Upgrades["minutessincemidnight"] == false) - { - if (API.Upgrades["secondssincemidnight"] == true) { - WriteLine("Since midnight, " + API.GetTime() + " seconds have passed."); - } else { - wrongcommand(); - } - } else - { - WriteLine("Since midnight, " + API.GetTime() + " minutes have passed."); - } + WriteLine("That alias doesn't exist."); } - else + break; + case "-l": + case "--list": + WriteLine("Aliases:"); + foreach (KeyValuePair kv in API.CommandAliases) { - WriteLine("Since Midnight, " + API.GetTime() + " hours have passed."); + WriteLine(kv.Key + " => " + kv.Value); } - } else + break; + default: + WriteLine("alias: Invalid argument. Try alias --help for help with the Alias command."); + break; + } + } + catch + { + WriteLine("alias: Missing arguments. Try alias --help for help with the Alias command."); + } + } + + public void cmd_username(String[] args) + { + if (API.Upgrades["customusername"] == true) + { + try + { + API.CurrentSave.username = args[1]; + } + catch + { + WriteLine("username: Missing arguments."); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_osname(String[] args) + { + if (API.Upgrades["customusername"] == true) + { + try + { + API.CurrentSave.osname = args[1]; + } + catch + { + WriteLine("osname: Missing arguments."); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_unity(String[] args) + { + if (API.Upgrades["unitymode"] == true) + { + API.CurrentSession.SetUnityMode(); + API.CurrentSession.SetupDesktop(); + txtterm.Focus(); + } + else + { + wrongcommand(); + } + } + + public void cmd_time(String[] args) + { + if (API.Upgrades["pmandam"] == false) + { + if (API.Upgrades["hourssincemidnight"] == false) + { + if (API.Upgrades["minutessincemidnight"] == false) { - WriteLine("Current time: " + API.GetTime()); - } - break; - case "saa": - if (API.Upgrades["shiftnet"]) { - var f = command.Replace("saa ", ""); - if (f.StartsWith("/")) + if (API.Upgrades["secondssincemidnight"] == true) { - var withoutslash = f.Remove(0, 1); - var dirsep = OSInfo.DirectorySeparator; - var rightdir = $"{Paths.SaveRoot}{dirsep}{f.Replace("/", dirsep)}"; - if (File.Exists(rightdir)) - { - var finf = new FileInfo(rightdir); - if (finf.Extension == ".saa") - { - API.LaunchMod(finf.FullName); - } - else - { - WriteLine("saa: Cannot launch the file '" + finf.FullName + " because it isn't a valid stand-alone app."); - } - } - else - { - WriteLine("saa: Cannot launch the file '" + f + "' because it doesn't exist."); - } + WriteLine("Since midnight, " + API.GetTime() + " seconds have passed."); } else { - WriteLine("saa: Cannot launch the file '" + f + "' because it doesn't exist."); + wrongcommand(); } } else { - wrongcommand(); - } - break; - case "help": - try - { - showhelp(args[1]); - } - catch - { - showhelp(); + WriteLine("Since midnight, " + API.GetTime() + " minutes have passed."); } - break; - case "codepoints": - case "cp": - WriteLine("You have " + API.Codepoints.ToString() + " Codepoints."); - break; - case "shutdown": - API.ShutDownShiftOS(); - break; - case "clear": - txtterm.Text = ""; - break; - case "close": - if (command.Contains("close ")) + } + else + { + WriteLine("Since Midnight, " + API.GetTime() + " hours have passed."); + } + } + else + { + WriteLine("Current time: " + API.GetTime()); + } + } + + public void cmd_saa(String[] args) + { + if (API.Upgrades["shiftnet"]) + { + var f = command.Replace("saa ", ""); + if (f.StartsWith("/")) + { + var withoutslash = f.Remove(0, 1); + var dirsep = OSInfo.DirectorySeparator; + var rightdir = $"{Paths.SaveRoot}{dirsep}{f.Replace("/", dirsep)}"; + if (File.Exists(rightdir)) { - var pid = command.Replace("close ", ""); - if (API.CloseProgram(pid) == true) + var finf = new FileInfo(rightdir); + if (finf.Extension == ".saa") { - WriteLine("Closed all running " + pid + "s."); + API.LaunchMod(finf.FullName); } else { - WriteLine("No processes with id '" + pid + "' were found!"); + WriteLine("saa: Cannot launch the file '" + finf.FullName + " because it isn't a valid stand-alone app."); } } else { - WriteLine("Insufficient arguments."); + WriteLine("saa: Cannot launch the file '" + f + "' because it doesn't exist."); } - break; - case "05tray": - if (API.DeveloperMode == true) + } + else + { + WriteLine("saa: Cannot launch the file '" + f + "' because it doesn't exist."); + } + } + else + { + wrongcommand(); + } + } + + public void cmd_help(String[] args) + { + try + { + showhelp(args[1]); + } + catch + { + showhelp(); + } + } + + public void cmd_cp(String[] args) + { + WriteLine("You have " + API.Codepoints.ToString() + " Codepoints."); + } + + public void cmd_shutdown(String[] args) + { + API.ShutDownShiftOS(); + } + + public void cmd_clear(String[] args) + { + txtterm.Text = ""; + } + + public void cmd_close(String[] args) + { + if (command.Contains("close ")) + { + var pid = command.Replace("close ", ""); + if (API.CloseProgram(pid) == true) + { + WriteLine("Closed all running " + pid + "s."); + } + else + { + WriteLine("No processes with id '" + pid + "' were found!"); + } + } + else + { + WriteLine("Insufficient arguments."); + } + } + + public void cmd_05tray(String[] args) + { + if (API.DeveloperMode == true) + { + API.AddCodepoints(500); + WriteLine("You've been granted 500 Codepoints."); + } + else + { + wrongcommand(); + } + } + + public void cmd_debug(String[] args) + { + if (API.DeveloperMode == true) + { + try + { + switch (args[1].ToLower()) { - API.AddCodepoints(500); - WriteLine("You've been granted 500 Codepoints."); - } else + case "shiftnet-story": + WriteLine("Debugging Shiftnet Story..."); + StartShiftnetStory(); + break; + case "devmode": + API.DeveloperMode = false; + WriteLine("Turned off developer mode. Use the passcode to turn it back on."); + break; + default: + WriteLine("Invalid argument: " + args[1] + ". Debug can only debug the following: 'shiftnet-story'."); + break; + } + + } + catch (Exception ex) + { + WriteLine("debug: " + ex.Message); + } + } + else + { + try + { + switch (args[1].ToLower()) { - wrongcommand(); + case "developers123": + WriteLine("Turned Developer Mode on!"); + API.DeveloperMode = true; + break; + default: + WriteLine("debug: lp0 is on fire"); // Keeps Cheaters from Flooding The Fourms With "The Debug Mode Doesn't Work" + break; } + } + catch + { + WriteLine("debug: lp0 is on fire"); // Keeps Cheaters from Flooding The Fourms With "The Debug Mode Doesn't Work" + } + } + } - break; - case "debug": - if (API.DeveloperMode == true) + public void cmd_echo(String[] args) + { + if (command.Contains("echo ")) + { + WriteLine(command.Replace("echo ", "")); + } + else + { + WriteLine("echo: Insufficient Parameters."); + } + } + + public void cmd_default(String[] args) + { + if (API.OpenProgram(args[0]) == false) + { + if (API.Upgrades["trmfiles"] == false) + { + bool done = false; + foreach (KeyValuePair kv in API.CommandAliases) { - try + if (kv.Key == command) { - switch (args[1].ToLower()) - { - case "shiftnet-story": - WriteLine("Debugging Shiftnet Story..."); - StartShiftnetStory(); - break; - case "devmode": - API.DeveloperMode = false; - WriteLine("Turned off developer mode. Use the passcode to turn it back on."); - break; - default: - WriteLine("Invalid argument: " + args[1] + ". Debug can only debug the following: 'shiftnet-story'."); - break; - } - + command = kv.Value; + done = true; + DoCommand(); } - catch (Exception ex) + + } + if (done == false) + { + wrongcommand(); + } + } + else + { + var f = command.Replace("\\", "/"); + if (f.StartsWith("/")) + { + var withoutslash = f.Remove(0, 1); + var dirsep = OSInfo.DirectorySeparator; + var proper = $"{Paths.SaveRoot}{dirsep}{withoutslash.Replace("/", dirsep)}"; + if (File.Exists(proper)) { - WriteLine("debug: " + ex.Message); + runterminalfile(proper); } - } else { - try - { - switch (args[1].ToLower()) - { - case "developers123": - WriteLine("Turned Developer Mode on!"); - API.DeveloperMode = true; - break; - default: - wrongcommand(); - break; - } - } catch + else { - wrongcommand(); //Debug command pretends to be an invalid command if an exception is thrown. + wrongcommand(); } } - break; - case "echo": - if(command.Contains("echo ")) - { - WriteLine(command.Replace("echo ", "")); - } else { - WriteLine("echo: Insufficient Parameters."); - } - break; - case "syncsave": - WriteLine("Command removed."); - break; - - default: - if (API.OpenProgram(args[0]) == false) - { - if (API.Upgrades["trmfiles"] == false) + bool done = false; + foreach (KeyValuePair kv in API.CommandAliases) { - bool done = false; - foreach(KeyValuePair kv in API.CommandAliases) - { - if(kv.Key == command) - { - command = kv.Value; - done = true; - DoCommand(); - } - - } - if(done == false) + if (kv.Key == command) { - wrongcommand(); + command = kv.Value; + done = true; + DoCommand(); } + } - else + if (done == false) { - var f = command.Replace("\\", "/"); - if (f.StartsWith("/")) - { - var withoutslash = f.Remove(0, 1); - var dirsep = OSInfo.DirectorySeparator; - var proper = $"{Paths.SaveRoot}{dirsep}{withoutslash.Replace("/", dirsep)}"; - if (File.Exists(proper)) - { - runterminalfile(proper); - } - else - { - wrongcommand(); - } - } - else - { - bool done = false; - foreach (KeyValuePair kv in API.CommandAliases) - { - if (kv.Key == command) - { - command = kv.Value; - done = true; - DoCommand(); - } - - } - if (done == false) - { - wrongcommand(); - } - } + wrongcommand(); } } - break; + } } } + /// + /// About Box, Created By Carver Harrison + /// + /// String[] args + public void cmd_about(String[] args) + { + API.CreateInfoboxSession("About ShiftOS", "ShiftOS Version " + ProductVersion + "\n Copyright 2014-2016 ShiftOS Dev Team \n Type 'credits' in Terminal to Show Credits", infobox.InfoboxMode.Info); + } + + // HISTACOM REFERENCES, DO NOT REMOVE, CRUCIAL FOR SECRET STORY ARC + public void cmd_histacom_year(String[] args) + { + WriteLine("Year: 2002"); + } + + public void cmd_histacom_timedistorter(String[] args) + { + WriteLine("Install 'timedistorter' by going to shiftnet://12padams"); + } + + #endregion + private void StartChoice1EndStory() { var t = new ShiftUI.Timer(); -- cgit v1.2.3