Exemple #1
0
        private static string getFilteredStringInput(string s, KeyboardState input, KeyboardState lastInput)
        {
            foreach (char filteredKey in GuiData.getFilteredKeys())
            {
                s = s.Substring(0, TextBox.cursorPosition) + (object)filteredKey + s.Substring(TextBox.cursorPosition);
                ++TextBox.cursorPosition;
            }
            Keys[] pressedKeys = input.GetPressedKeys();
            if (pressedKeys.Length == 1 && lastInput.IsKeyDown(pressedKeys[0]))
            {
                if (pressedKeys[0] == TextBox.lastHeldKey && TextBox.IsSpecialKey(pressedKeys[0]))
                {
                    TextBox.keyRepeatDelay -= GuiData.lastTimeStep;
                    if ((double)TextBox.keyRepeatDelay <= 0.0)
                    {
                        s = TextBox.forceHandleKeyPress(s, pressedKeys[0], input, lastInput);
                        TextBox.keyRepeatDelay = 0.04f;
                    }
                }
                else
                {
                    TextBox.lastHeldKey    = pressedKeys[0];
                    TextBox.keyRepeatDelay = 0.44f;
                }
            }
            else
            {
                for (int index = 0; index < pressedKeys.Length; ++index)
                {
                    if (!lastInput.IsKeyDown(pressedKeys[index]) && TextBox.IsSpecialKey(pressedKeys[index]))
                    {
                        switch (pressedKeys[index])
                        {
                        case Keys.Back:
                        case Keys.OemClear:
                            if (s.Length > 0 && TextBox.cursorPosition > 0)
                            {
                                s = s.Substring(0, TextBox.cursorPosition - 1) + s.Substring(TextBox.cursorPosition);
                                --TextBox.cursorPosition;
                                break;
                            }
                            break;

                        case Keys.Tab:
                            TextBox.TabWasPresed = true;
                            break;

                        case Keys.End:
                            TextBox.cursorPosition = TextBox.cursorPosition = s.Length;
                            break;

                        case Keys.Home:
                            TextBox.cursorPosition = 0;
                            break;

                        case Keys.Left:
                            --TextBox.cursorPosition;
                            if (TextBox.cursorPosition < 0)
                            {
                                TextBox.cursorPosition = 0;
                                break;
                            }
                            break;

                        case Keys.Up:
                            TextBox.UpWasPresed = true;
                            break;

                        case Keys.Right:
                            ++TextBox.cursorPosition;
                            if (TextBox.cursorPosition > s.Length)
                            {
                                TextBox.cursorPosition = s.Length;
                                break;
                            }
                            break;

                        case Keys.Down:
                            TextBox.DownWasPresed = true;
                            break;

                        case Keys.Delete:
                            if (s.Length > 0 && TextBox.cursorPosition < s.Length)
                            {
                                s = s.Substring(0, TextBox.cursorPosition) + s.Substring(TextBox.cursorPosition + 1);
                                break;
                            }
                            break;
                        }
                    }
                }
            }
            return(s);
        }
Exemple #2
0
 public void ClearTextBox()
 {
     GuiData.getFilteredKeys();
     this.terminalString    = "";
     TextBox.cursorPosition = 0;
 }
Exemple #3
0
 public static void OverrideFirstTimeInit(CommandSentEvent e)
 {
     if (Extension.Handler.ActiveInfo != null &&
         e[0] == "FirstTimeInitdswhupwnemfdsiuoewnmdsmffdjsklanfeebfjkalnbmsdakj")
     {
         var os    = e.OS;
         var num   = Settings.isConventionDemo ? 80 : 200;
         var num2  = Settings.isConventionDemo ? 150 : 300;
         var doTut = e[1] == "StartTutorial";
         if (doTut)
         {
             os.display.visible    = false;
             os.ram.visible        = false;
             os.netMap.visible     = false;
             os.terminal.visible   = true;
             os.mailicon.isEnabled = false;
             if (os.hubServerAlertsIcon != null)
             {
                 os.hubServerAlertsIcon.IsEnabled = false;
             }
         }
         if (Settings.debugCommandsEnabled && GuiData.getKeyboadState().IsKeyDown(Keys.LeftAlt))
         {
             num2 = (num = 1);
         }
         Programs.typeOut("Initializing .", os, 50);
         Programs.doDots(7, num + 100, os);
         Programs.typeOut("Loading modules.", os, 50);
         Programs.doDots(5, num, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         Programs.typeOut("Loading nodes.", os, 50);
         Programs.doDots(5, num, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         Programs.typeOut("Reticulating splines.", os, 50);
         Programs.doDots(5, num - 50, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         if (os.crashModule.BootLoadErrors.Length > 0)
         {
             Programs.typeOut("\n------ " + LocaleTerms.Loc("BOOT ERRORS DETECTED") + " ------", os, 50);
             Utility.HaltThread(200);
             var array = os.crashModule.BootLoadErrors.Split(Utils.newlineDelim, StringSplitOptions.RemoveEmptyEntries);
             for (int i = 0; i < array.Length; i++)
             {
                 Programs.typeOut(array[i], os, 50);
                 Utility.HaltThread(100, true);
             }
             Programs.typeOut("---------------------------------\n", os, 50);
             Utility.HaltThread(200, true);
         }
         Programs.typeOut("\n--Initialization Complete--\n", os, 50);
         GuiData.getFilteredKeys();
         os.inputEnabled = true;
         Utility.HaltThread(num2 + 100);
         if (!doTut)
         {
             Programs.typeOut(LocaleTerms.Loc("For A Command List, type \"help\""), os, 50);
             Utility.HaltThread(num2 + 100);
         }
         os.write("");
         Utility.HaltThread(num2);
         os.write("");
         Utility.HaltThread(num2);
         os.write("");
         Utility.HaltThread(num2);
         os.write("\n");
         if (doTut)
         {
             os.write(LocaleTerms.Loc("Launching Tutorial..."));
             os.launchExecutable("Tutorial.exe", PortExploits.crackExeData[1], -1, null, null);
             Settings.initShowsTutorial = false;
             AdvancedTutorial advancedTutorial = null;
             for (int i = 0; i < os.exes.Count; i++)
             {
                 advancedTutorial = (os.exes[i] as AdvancedTutorial);
                 if (advancedTutorial != null)
                 {
                     break;
                 }
             }
             if (advancedTutorial != null)
             {
                 advancedTutorial.CanActivateFirstStep = false;
             }
             int num3 = 100;
             for (int i = 0; i < num3; i++)
             {
                 double num4 = (double)i / num3;
                 if (Utils.random.NextDouble() < num4)
                 {
                     os.ram.visible      = true;
                     os.netMap.visible   = false;
                     os.terminal.visible = false;
                 }
                 else
                 {
                     os.ram.visible      = false;
                     os.netMap.visible   = false;
                     os.terminal.visible = true;
                 }
                 Utility.HaltThread(16, true);
             }
             os.ram.visible      = true;
             os.netMap.visible   = false;
             os.terminal.visible = false;
             if (advancedTutorial != null)
             {
                 advancedTutorial.CanActivateFirstStep = true;
             }
         }
         else
         {
             os.runCommand("connect " + os.thisComputer.ip);
             if (doTut && !OS.WillLoadSave && !os.Flags.HasFlag("ExtensionFirstBootComplete"))
             {
                 ExtensionLoader.SendStartingEmailForActiveExtensionNextFrame(os);
                 float num5 = 2.2f;
                 var   num3 = (int)(60f * num5);
                 for (int i = 0; i < num3; i++)
                 {
                     double num4 = (double)i / num3;
                     os.ram.visible     = (Utils.random.NextDouble() < num4);
                     os.netMap.visible  = (Utils.random.NextDouble() < num4);
                     os.display.visible = (Utils.random.NextDouble() < num4);
                     Utility.HaltThread(16, true);
                 }
                 os.terminal.visible    = true;
                 os.display.visible     = true;
                 os.netMap.visible      = true;
                 os.ram.visible         = true;
                 os.terminal.visible    = true;
                 os.display.inputLocked = false;
                 os.netMap.inputLocked  = false;
                 os.ram.inputLocked     = false;
                 os.Flags.AddFlag("ExtensionFirstBootComplete");
             }
         }
         Utility.HaltThread(500, true);
         if (wasRecursed)
         {
             os.ram.visible         = true;
             os.ram.inputLocked     = false;
             os.display.visible     = true;
             os.display.inputLocked = false;
             os.netMap.visible      = true;
             os.netMap.inputLocked  = false;
         }
         else if (doTut)
         {
             os.ram.visible         = true;
             os.ram.inputLocked     = false;
             os.display.visible     = true;
             os.display.inputLocked = false;
             os.netMap.visible      = true;
             os.netMap.inputLocked  = false;
         }
         else if (!os.ram.visible)
         {
             wasRecursed = true;
             OverrideFirstTimeInit(e);
         }
     }
 }
Exemple #4
0
        private static string getFilteredStringInput(string s, KeyboardState input, KeyboardState lastInput)
        {
            foreach (var ch in GuiData.getFilteredKeys())
            {
                s = s.Substring(0, cursorPosition) + ch + s.Substring(cursorPosition);
                ++cursorPosition;
            }
            var pressedKeys = input.GetPressedKeys();

            if (pressedKeys.Length == 1 && lastInput.IsKeyDown(pressedKeys[0]))
            {
                if (pressedKeys[0] == lastHeldKey && IsSpecialKey(pressedKeys[0]))
                {
                    keyRepeatDelay -= GuiData.lastTimeStep;
                    if (keyRepeatDelay <= 0.0)
                    {
                        s = forceHandleKeyPress(s, pressedKeys[0], input, lastInput);
                        keyRepeatDelay = 0.04f;
                    }
                }
                else
                {
                    lastHeldKey    = pressedKeys[0];
                    keyRepeatDelay = 0.44f;
                }
            }
            else
            {
                for (var index = 0; index < pressedKeys.Length; ++index)
                {
                    if (!lastInput.IsKeyDown(pressedKeys[index]) && IsSpecialKey(pressedKeys[index]))
                    {
                        switch (pressedKeys[index])
                        {
                        case Keys.Back:
                        case Keys.OemClear:
                            if (s.Length > 0 && cursorPosition > 0)
                            {
                                s = s.Substring(0, cursorPosition - 1) + s.Substring(cursorPosition);
                                --cursorPosition;
                            }
                            continue;

                        case Keys.Tab:
                            TabWasPresed = true;
                            continue;

                        case Keys.End:
                            cursorPosition = cursorPosition = s.Length;
                            continue;

                        case Keys.Home:
                            cursorPosition = 0;
                            continue;

                        case Keys.Left:
                            --cursorPosition;
                            if (cursorPosition < 0)
                            {
                                cursorPosition = 0;
                            }
                            continue;

                        case Keys.Up:
                            UpWasPresed = true;
                            continue;

                        case Keys.Right:
                            ++cursorPosition;
                            if (cursorPosition > s.Length)
                            {
                                cursorPosition = s.Length;
                            }
                            continue;

                        case Keys.Down:
                            DownWasPresed = true;
                            continue;

                        case Keys.Delete:
                            if (s.Length > 0 && cursorPosition < s.Length)
                            {
                                s = s.Substring(0, cursorPosition) + s.Substring(cursorPosition + 1);
                            }
                            continue;

                        default:
                            continue;
                        }
                    }
                }
            }
            return(s);
        }