コード例 #1
0
ファイル: MainMenu.cs プロジェクト: hochladen/Hacknet
        private void StartFullDLCTest()
        {
            this.ExitScreen();
            MainMenu.resetOS();
            if (!Settings.soundDisabled)
            {
                this.ScreenManager.playAlertSound();
            }
            OS     os       = new OS();
            string username = "******";

            SaveFileManager.AddUser(username, "test");
            string fileNameForUsername = SaveFileManager.GetSaveFileNameForUsername(username);

            os.IsDLCConventionDemo = true;
            os.Flags.AddFlag("TutorialComplete");
            Settings.EnableDLC         = true;
            Settings.initShowsTutorial = false;
            os.SaveGameUserName        = fileNameForUsername;
            os.SaveUserAccountName     = username;
            os.initShowsTutorial       = false;
            this.ScreenManager.AddScreen((GameScreen)os, new PlayerIndex?(this.ScreenManager.controllingPlayer));
            SessionAccelerator.AccelerateSessionToDLCStart((object)os);
            os.delayer.Post(ActionDelayer.Wait(0.15), (Action)(() => Game1.getSingleton().IsMouseVisible = true));
        }
コード例 #2
0
ファイル: MainMenu.cs プロジェクト: hochladen/Hacknet
 private void HookUpCreationEvents()
 {
     this.loginScreen.RequestGoBack += (Action)(() => this.State = MainMenu.MainMenuState.Normal);
     this.loginScreen.StartNewGameForUsernameAndPass += (Action <string, string>)((username, pass) =>
     {
         if (SaveFileManager.AddUser(username, pass))
         {
             string filePathForLogin = SaveFileManager.GetFilePathForLogin(username, pass);
             this.ExitScreen();
             MainMenu.resetOS();
             if (!Settings.soundDisabled)
             {
                 this.ScreenManager.playAlertSound();
             }
             try
             {
                 OS os = new OS();
                 os.SaveGameUserName    = filePathForLogin;
                 os.SaveUserAccountName = username;
                 if (this.NextStartedGameShouldBeDLCAccelerated)
                 {
                     os.IsDLCConventionDemo = true;
                     os.Flags.AddFlag("TutorialComplete");
                     Settings.EnableDLC         = true;
                     Settings.initShowsTutorial = false;
                     os.initShowsTutorial       = false;
                 }
                 this.ScreenManager.AddScreen((GameScreen)os, new PlayerIndex?(this.ScreenManager.controllingPlayer));
                 os.Flags.AddFlag("startVer:" + MainMenu.OSVersion);
                 if (!this.NextStartedGameShouldBeDLCAccelerated)
                 {
                     return;
                 }
                 SessionAccelerator.AccelerateSessionToDLCStart((object)os);
                 os.delayer.Post(ActionDelayer.Wait(0.15), (Action)(() => Game1.getSingleton().IsMouseVisible = true));
                 this.NextStartedGameShouldBeDLCAccelerated = false;
             }
             catch (Exception ex)
             {
                 this.UpdateUIForSaveCreationFailed(ex);
             }
         }
         else
         {
             this.loginScreen.ResetForNewAccount();
             this.loginScreen.WriteToHistory(" ERROR: Username invalid or already in use.");
         }
     });
     this.loginScreen.LoadGameForUserFileAndUsername += (Action <string, string>)((userFile, username) =>
     {
         this.ExitScreen();
         MainMenu.resetOS();
         if (SaveFileManager.StorageMethods[0].FileExists(userFile))
         {
             OS.WillLoadSave = true;
             OS os = new OS();
             os.SaveGameUserName    = userFile;
             os.SaveUserAccountName = username;
             try
             {
                 this.ScreenManager.AddScreen((GameScreen)os, new PlayerIndex?(this.ScreenManager.controllingPlayer));
             }
             catch (XmlException ex)
             {
                 this.UpdateUIForSaveCorruption(userFile, (Exception)ex);
             }
             catch (FormatException ex)
             {
                 this.UpdateUIForSaveCorruption(userFile, (Exception)ex);
             }
             catch (NullReferenceException ex)
             {
                 this.UpdateUIForSaveCorruption(userFile, (Exception)ex);
             }
             catch (FileNotFoundException ex)
             {
                 this.UpdateUIForSaveMissing(userFile, (Exception)ex);
             }
             catch (ContentLoadException ex1)
             {
                 string str = Utils.ReadEntireContentsOfStream(SaveFileManager.StorageMethods[0].GetFileReadStream(userFile));
                 if (str.Contains("DigiPets"))
                 {
                     string data = str.Replace("DigiPets", "Neopals").Replace("DigiPoints", "Neopoints");
                     for (int index = 0; index < 3; ++index)
                     {
                         try
                         {
                             Thread.Sleep(200);
                             SaveFileManager.StorageMethods[0].WriteFileData(userFile, data);
                             break;
                         }
                         catch (IOException ex2)
                         {
                         }
                         Thread.Sleep(500);
                     }
                     MainMenu.AccumErrors = "-- Savefile Automatically Upgraded - Try again! --";
                 }
                 else
                 {
                     this.UpdateUIForSaveCorruption(userFile, (Exception)ex1);
                 }
             }
         }
         else
         {
             OS.WillLoadSave = false;
             this.UpdateUIForSaveMissing(userFile, (Exception) new FileNotFoundException());
         }
     });
     this.attractModeScreen.Start += (Action)(() =>
     {
         try
         {
             this.ExitScreen();
             MainMenu.resetOS();
             if (!Settings.soundDisabled)
             {
                 this.ScreenManager.playAlertSound();
             }
             this.ScreenManager.AddScreen((GameScreen) new OS(), new PlayerIndex?(this.ScreenManager.controllingPlayer));
         }
         catch (Exception ex)
         {
             Utils.writeToFile("OS Load Error: " + ex.ToString() + "\n\n" + ex.StackTrace, "crashLog.txt");
         }
     });
     this.attractModeScreen.StartDLC += (Action)(() =>
     {
         try
         {
             this.ExitScreen();
             MainMenu.resetOS();
             Settings.EnableDLC = true;
             Settings.initShowsTutorial = false;
             if (!Settings.soundDisabled)
             {
                 this.ScreenManager.playAlertSound();
             }
             OS os = new OS();
             os.IsDLCConventionDemo = true;
             os.Flags.AddFlag("TutorialComplete");
             os.SaveGameUserName = "******" + Settings.ConventionLoginName + ".xml";
             os.SaveUserAccountName = Settings.ConventionLoginName;
             this.ScreenManager.AddScreen((GameScreen)os, new PlayerIndex?(this.ScreenManager.controllingPlayer));
             os.allFactions.setCurrentFaction("Bibliotheque", os);
             ThemeManager.setThemeOnComputer((object)os.thisComputer, "DLC/Themes/RiptideClassicTheme.xml");
             ThemeManager.switchTheme((object)os, "DLC/Themes/RiptideClassicTheme.xml");
             for (int index1 = 0; index1 < 60; ++index1)
             {
                 int index2;
                 do
                 {
                     index2 = Utils.random.Next(os.netMap.nodes.Count);
                 }while (os.netMap.nodes[index2].idName == "mainHub" || os.netMap.nodes[index2].idName == "entropy00" || os.netMap.nodes[index2].idName == "entropy01");
                 os.netMap.discoverNode(os.netMap.nodes[index2]);
             }
             os.delayer.Post(ActionDelayer.Wait(0.15), (Action)(() =>
             {
                 Game1.getSingleton().IsMouseVisible = true;
                 os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[22], "SSHCrack.exe"));
                 os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[21], "FTPBounce.exe"));
                 MissionFunctions.runCommand(7, "changeSong");
                 MusicManager.stop();
             }));
             os.delayer.Post(ActionDelayer.Wait(38.0), (Action)(() => ComputerLoader.loadMission("Content/DLC/Missions/Demo/DLCDemointroMission1.xml", false)));
         }
         catch (Exception ex)
         {
             Utils.writeToFile("OS Load Error: " + ex.ToString() + "\n\n" + ex.StackTrace, "crashLog.txt");
         }
     });
     this.extensionsScreen.ExitClicked += (Action)(() => this.State = MainMenu.MainMenuState.Normal);
     this.extensionsScreen.CreateNewAccountForExtension_UserAndPass += (Action <string, string>)((user, pass) => MainMenu.CreateNewAccountForExtensionAndStart(user, pass, this.ScreenManager, (GameScreen)this, this.extensionsScreen));
     this.extensionsScreen.LoadAccountForExtension_FileAndUsername  += (Action <string, string>)((userFile, username) =>
     {
         this.ExitScreen();
         MainMenu.resetOS();
         Settings.IsInExtensionMode = true;
         OS.WillLoadSave            = SaveFileManager.StorageMethods[0].FileExists(userFile);
         this.ScreenManager.AddScreen((GameScreen) new OS()
         {
             SaveGameUserName    = userFile,
             SaveUserAccountName = username
         }, new PlayerIndex?(this.ScreenManager.controllingPlayer));
     });
 }
コード例 #3
0
ファイル: MainMenu.cs プロジェクト: hochladen/Hacknet
        private void drawTestingMainMenuButtons(bool canRun)
        {
            SpriteFont tinyfont = GuiData.tinyfont;
            string     text     = "FONT:";

            for (int index = 0; index < tinyfont.Characters.Count; ++index)
            {
                text += (string)(object)tinyfont.Characters[index];
                if (index % 20 == 0)
                {
                    text += "\n";
                }
            }
            if (true)
            {
                text = "Labyrinths Testers:\nPress \"Start Full DLC Test\" to begin\n\n" + text;
            }
            GuiData.spriteBatch.DrawString(tinyfont, text, new Vector2(867f, 200f), Color.White);
            if (Button.doButton(8801, 634, 200, 225, 23, "New Test Session", new Color?(MainMenu.buttonColor)) && canRun && canRun)
            {
                this.ExitScreen();
                MainMenu.resetOS();
                if (!Settings.soundDisabled)
                {
                    this.ScreenManager.playAlertSound();
                }
                OS os = new OS();
                os.SaveGameUserName    = "******";
                os.SaveUserAccountName = "__test";
                this.ScreenManager.AddScreen((GameScreen)os, new PlayerIndex?(this.ScreenManager.controllingPlayer));
                os.Flags.AddFlag("TutorialComplete");
                os.delayer.RunAllDelayedActions();
                os.threadedSaveExecute(false);
                this.ScreenManager.RemoveScreen((GameScreen)os);
                OS.WillLoadSave = true;
                MainMenu.resetOS();
                os = new OS();
                os.SaveGameUserName    = "******";
                os.SaveUserAccountName = "__test";
                this.ScreenManager.AddScreen((GameScreen)os, new PlayerIndex?(this.ScreenManager.controllingPlayer));
                os.delayer.Post(ActionDelayer.Wait(0.1), (Action)(() => Game1.getSingleton().IsMouseVisible = true));
                os.delayer.Post(ActionDelayer.Wait(0.4), (Action)(() =>
                {
                    os.runCommand("debug");
                    ComputerLoader.loadMission("Content/Missions/MainHub/Intro/Intro01.xml", false);
                }));
                if (!Settings.EnableDLC)
                {
                    ComputerLoader.loadMission("Content/Missions/BitMission0.xml", false);
                }
            }
            if (Button.doButton(8803, 634, 225, 225, 23, "New DLC Test Session", new Color?(Settings.EnableDLC ? Color.Gray : MainMenu.buttonColor)) && canRun && canRun)
            {
                this.ExitScreen();
                MainMenu.resetOS();
                if (!Settings.soundDisabled)
                {
                    this.ScreenManager.playAlertSound();
                }
                OS os1 = new OS();
                os1.SaveGameUserName    = "******";
                os1.SaveUserAccountName = "__test";
                this.ScreenManager.AddScreen((GameScreen)os1, new PlayerIndex?(this.ScreenManager.controllingPlayer));
                SessionAccelerator.AccelerateSessionToDLCHA((object)os1);
                os1.threadedSaveExecute(false);
                this.ScreenManager.RemoveScreen((GameScreen)os1);
                OS.WillLoadSave = true;
                MainMenu.resetOS();
                Settings.initShowsTutorial = false;
                OS os2 = new OS();
                os2.SaveGameUserName    = "******";
                os2.SaveUserAccountName = "__test";
                this.ScreenManager.AddScreen((GameScreen)os2, new PlayerIndex?(this.ScreenManager.controllingPlayer));
                os2.delayer.Post(ActionDelayer.Wait(0.15), (Action)(() => Game1.getSingleton().IsMouseVisible = true));
            }
            if (Button.doButton(8806, 634, 250, 225, 23, "Run Test Suite", new Color?(MainMenu.buttonColor)))
            {
                this.testSuiteResult = TestSuite.RunTestSuite(this.ScreenManager, false);
            }
            if (Button.doButton(8809, 634, 275, 225, 23, "Run Quick Tests", new Color?(MainMenu.buttonColor)))
            {
                this.testSuiteResult = TestSuite.RunTestSuite(this.ScreenManager, true);
            }
            else
            {
                if (Button.doButton(8812, 634, 300, 225, 23, "Start Full DLC Test", new Color?(MainMenu.buttonColor)) && canRun)
                {
                    this.StartFullDLCTest();
                }
                if (this.testSuiteResult == null)
                {
                    return;
                }
                TextItem.doFontLabel(new Vector2(635f, 325f), Utils.SuperSmartTwimForWidth(this.testSuiteResult, 600, GuiData.tinyfont), GuiData.tinyfont, new Color?(this.testSuiteResult.Length > 950 ? Utils.AddativeRed : Utils.AddativeWhite), float.MaxValue, float.MaxValue, false);
            }
        }