Example #1
0
        private Vector2 DrawFlashInString(string text, Vector2 pos, float offset, float transitionInTime = 0.2f, bool hasDots = false, float dotsDelayer = 0.2f)
        {
            Vector2 vector2 = new Vector2(40f, 0.0f);

            if ((double)this.timeThisState >= (double)offset)
            {
                float   point    = Math.Min((this.timeThisState - offset) / transitionInTime, 1f);
                Vector2 position = pos + vector2 * (1f - Utils.QuadraticOutCurve(point));
                string  str      = "";
                if (hasDots)
                {
                    for (float num = this.timeThisState - offset; (double)num > 0.0 && str.Length < 5; str += ".")
                    {
                        num -= dotsDelayer;
                    }
                }
                float scale = 0.5f;
                float num1  = 17f;
                if (LocaleActivator.ActiveLocaleIsCJK())
                {
                    scale = 0.7f;
                    num1  = 22f;
                }
                this.spriteBatch.DrawString(this.bodyFont, text + str, position, Color.White * point, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.4f);
                pos.Y += num1;
            }
            return(pos);
        }
Example #2
0
        public static string TestDLCLocalizations(ScreenManager screenMan, out int errorsAdded)
        {
            string str1         = "\r\n[";
            int    num          = 0;
            string activeLocale = Settings.ActiveLocale;

            for (int index = 0; index < LocaleActivator.SupportedLanguages.Count; ++index)
            {
                LocaleActivator.ActivateLocale(LocaleActivator.SupportedLanguages[index].Code, Game1.getSingleton().Content);
                int    errorsAdded1 = 0;
                string str2         = DLCLocalizationTests.LoadAndTestOS(screenMan, out errorsAdded1);
                num += errorsAdded1;
                string str3 = str2.Replace(".", "").Trim();
                if (string.IsNullOrWhiteSpace(str3))
                {
                    str1 += "==";
                }
                else
                {
                    str1 = str1 + "\r\n -- " + LocaleActivator.SupportedLanguages[index].Name + ": " + (string.IsNullOrWhiteSpace(str3) ? "Complete\r\n\r\n" : "\r\n" + str3 + "\r\n\r\n");
                }
            }
            LocaleActivator.ActivateLocale(activeLocale, Game1.getSingleton().Content);
            string str4 = str1 + "]\r\nComplete - " + (object)num + " load stopping errors found";

            errorsAdded = num;
            return(str4);
        }
Example #3
0
        public void doEmailViewerDisplay(Rectangle bounds, SpriteBatch sb)
        {
            Vector2 vector2 = new Vector2((float)(bounds.X + 2), (float)(bounds.Y + 20));

            if (Button.doButton(800007, (int)vector2.X, (int)vector2.Y, bounds.Width - 20 - this.corner.Width, 30, LocaleTerms.Loc("Return to Inbox"), new Color?(this.os.darkBackgroundColor)))
            {
                this.state = 3;
            }
            vector2.Y += 35f;
            Rectangle tmpRect = GuiData.tmpRect;

            tmpRect.X      = bounds.X + 1;
            tmpRect.Y      = (int)vector2.Y;
            tmpRect.Width  = bounds.Width - 2;
            tmpRect.Height = 38;
            sb.Draw(Utils.white, tmpRect, this.textColor);
            vector2.Y += 3f;
            sb.DrawString(GuiData.UITinyfont, "<" + this.emailData[1] + ">", vector2, Color.Black);
            vector2.Y += 18f;
            sb.DrawString(GuiData.UITinyfont, LocaleTerms.Loc("Subject") + ": " + LocalizedFileLoader.SafeFilterString(this.emailData[2]), vector2, Color.Black);
            vector2.Y += 25f;
            vector2.X += 20f;
            int       num1       = 25;
            int       num2       = (this.emailData.Length - 4 + 1) * num1;
            Rectangle textBounds = new Rectangle((int)vector2.X, (int)vector2.Y, bounds.Width - 22, (int)((double)bounds.Height - ((double)vector2.Y - (double)bounds.Y) - (double)num2));
            string    str1;

            if (LocaleActivator.ActiveLocaleIsCJK())
            {
                string str2 = "\t";
                str1 = Utils.SuperSmartTwimForWidth(LocalizedFileLoader.SafeFilterString(this.emailData[3].Replace("。\n", str2).Replace("\n", "").Replace(str2, "。\n").Replace(str2, "!\n").Replace(str2, "!\n")), bounds.Width - 50, GuiData.tinyfont).Replace("\r\n\r\n\r\n", "\r\n\r\n");
            }
            else
            {
                str1 = Utils.SmartTwimForWidth(LocalizedFileLoader.SafeFilterString(this.emailData[3]), bounds.Width - 50, GuiData.tinyfont);
            }
            vector2.Y += (float)this.DrawMailMessageText(textBounds, sb, str1.Split(Utils.newlineDelim));
            vector2.Y += (float)(num1 - 5);
            int startingButtonIndex = 0;

            for (int index = 4; index < this.emailData.Length; ++index)
            {
                if (AttachmentRenderer.RenderAttachment(this.emailData[index], (object)this.os, vector2, startingButtonIndex, MailServer.buttonSound))
                {
                    ++startingButtonIndex;
                    vector2.Y += (float)num1;
                }
            }
            vector2.Y = (float)(bounds.Y + bounds.Height - 35);
            if (!Button.doButton(90200, (int)vector2.X, (int)vector2.Y, 300, 30, LocaleTerms.Loc("Reply"), new Color?()))
            {
                return;
            }
            this.emailReplyStrings.Clear();
            this.addingNewReplyString   = false;
            this.missionIncompleteReply = false;
            this.state = 5;
        }
 private void ActivateExtensionPage(ExtensionInfo info)
 {
     LocaleActivator.ActivateLocale(info.Language, Game1.getSingleton().Content);
     this.ExtensionInfoToShow            = info;
     this.ReportOverride                 = (string)null;
     this.SaveScreen.ProjectName         = info.Name;
     Settings.IsInExtensionMode          = true;
     ExtensionLoader.ActiveExtensionInfo = info;
     SaveFileManager.Init(true);
     this.SaveScreen.ResetForNewAccount();
 }
Example #5
0
        public override void DoDraw()
        {
            int num  = (!ForceNoColorTag && Width > 65) ? 13 : 0;
            var rect = new Rectangle(X, Y, Width, Height);

            if (Texture.Equals(Utils.white))
            {
                if (!OnlyOutline)
                {
                    GuiData.spriteBatch.Draw(Utils.white, rect, (IsActive) ? ((IsHeldDown) ? GuiData.Default_Trans_Grey_Dark : GuiData.Default_Trans_Grey_Bright) : GuiData.Default_Trans_Grey);
                    rect.Width = num;
                    GuiData.spriteBatch.Draw(Utils.white, rect, Color);
                }
                Gui.RenderedRectangle.doRectangleOutline(X, Y, Width, Height, 1,
                                                         OnlyOutline ?
                                                         Color : GuiData.Default_Trans_Grey_Solid);
            }
            else
            {
                GuiData.spriteBatch.Draw(Texture, rect, (IsActive) ? ((IsHeldDown) ? GuiData.Default_Unselected_Color : GuiData.Default_Lit_Backing_Color) : Color);
            }
            SpriteFont spriteFont = SmallButton ? GuiData.detailfont : GuiData.tinyfont;
            var        scale      = spriteFont.MeasureString(Text);
            float      num2       = LocaleActivator.ActiveLocaleIsCJK() ? 4f : 0f;
            float      y2         = scale.Y;

            if (scale.X > Width - 4)
            {
                scale.X = (Width - (4 + num + 5)) / scale.X;
            }
            else
            {
                scale.X = 1f;
            }
            if (scale.Y > Height + num2 - 0f)
            {
                scale.Y = (Height + num2 - 0f) / scale.Y;
            }
            else
            {
                scale.Y = 1f;
            }
            scale.X = Math.Min(scale.X, scale.Y);
            scale.Y = scale.X;
            if (Utils.FloatEquals(1f, scale.Y))
            {
                scale = Vector2.One;
            }
            num += 4;
            float num3 = y2 * scale.Y;
            float num4 = Y + Height / 2f - num3 / 2f + 1f - num2 * scale.Y / 2f;

            GuiData.spriteBatch.DrawString(spriteFont, Text, new Vector2((int)(X + 2 + num + 0.5), (int)(num4 + 0.5)), Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f);
        }
Example #6
0
        private void doContractPreviewScreen(Rectangle bounds, SpriteBatch sb)
        {
            string stringForContractFile = this.getIDStringForContractFile(this.listingsFolder.files[this.selectedElementIndex]);

            if (!this.listingMissions.ContainsKey(stringForContractFile))
            {
                return;
            }
            ActiveMission listingMission = this.listingMissions[stringForContractFile];
            Vector2       vector2        = new Vector2((float)(bounds.X + 20), (float)(bounds.Y + 20));

            TextItem.doFontLabel(vector2 + new Vector2((float)this.getTransitionOffset(0), 0.0f), "CONTRACT:" + stringForContractFile, GuiData.titlefont, new Color?(), (float)(bounds.Width / 2), 40f, false);
            vector2.Y += 40f;
            TextItem.doFontLabel(vector2 + new Vector2((float)this.getTransitionOffset(1), 0.0f), listingMission.postingTitle.Replace("#", ""), GuiData.font, new Color?(), (float)(bounds.Width - 30), float.MaxValue, false);
            vector2.Y += 30f;
            string        str           = DisplayModule.cleanSplitForWidth(listingMission.postingBody, bounds.Width - 110);
            StringBuilder stringBuilder = new StringBuilder();
            int           num1          = (int)((double)(((float)bounds.Width - 20f) / GuiData.smallfont.MeasureString("-").X) / 2.0);

            for (int index = 1; index < num1 - 5; ++index)
            {
                stringBuilder.Append("-");
            }
            string text = str.Replace("###", stringBuilder.ToString());

            if (LocaleActivator.ActiveLocaleIsCJK())
            {
                text       = Utils.SuperSmartTwimForWidth(listingMission.postingBody, bounds.Width - 110, GuiData.smallfont);
                vector2.Y += 20f;
            }
            TextItem.doFontLabel(vector2 + new Vector2((float)this.getTransitionOffset(2), 0.0f), text, GuiData.smallfont, new Color?(), (float)(bounds.Width - 20), float.MaxValue, false);
            int num2 = Math.Max(135, bounds.Height / 6);

            if (Button.doButton(2171618, bounds.X + 20 + this.getTransitionOffset(3), bounds.Y + bounds.Height - num2, bounds.Width / 5, 30, LocaleTerms.Loc("Back"), new Color?()))
            {
                this.state            = MissionHubServer.HubState.Listing;
                this.screenTransition = 1f;
            }
            if (this.os.currentMission == null)
            {
                if (Button.doButton(2171615, bounds.X + 20 + this.getTransitionOffset(4), bounds.Y + bounds.Height - num2 - 40, bounds.Width / 5, 30, LocaleTerms.Loc("Accept"), new Color?(this.os.highlightColor)))
                {
                    this.acceptMission(listingMission, this.selectedElementIndex, stringForContractFile);
                    this.state            = MissionHubServer.HubState.Listing;
                    this.screenTransition = 1f;
                }
            }
            else
            {
                TextItem.doFontLabelToSize(new Rectangle(bounds.X + 20 + this.getTransitionOffset(4), bounds.Y + bounds.Height - num2 - 40, bounds.Width / 2, 30), LocaleTerms.Loc("Abort current contract to accept new ones."), GuiData.smallfont, Color.White, false, false);
            }
        }
Example #7
0
        public static string RunTestSuite(ScreenManager screenMan, bool IsQuickTestMode = false)
        {
            bool soundDisabled = Settings.soundDisabled;

            Settings.soundDisabled = true;
            string activeLocale = Settings.ActiveLocale;

            LocaleActivator.ActivateLocale("en-us", Game1.getSingleton().Content);
            Settings.ActiveLocale = "en-us";
            string str = TestSuite.TestSaveLoadOnFile(screenMan, IsQuickTestMode);

            LocaleActivator.ActivateLocale(activeLocale, Game1.getSingleton().Content);
            Settings.ActiveLocale  = activeLocale;
            Settings.soundDisabled = soundDisabled;
            return(str);
        }
Example #8
0
        private static void drawModernButton(int myID, int x, int y, int width, int height, string text, Color?selectedColor, Texture2D tex)
        {
            int num1 = Button.ForceNoColorTag || width <= 65 ? 0 : 13;

            if (!selectedColor.HasValue)
            {
                selectedColor = new Color?(GuiData.Default_Trans_Grey_Strong);
            }
            Rectangle tmpRect = GuiData.tmpRect;

            tmpRect.X      = x;
            tmpRect.Y      = y;
            tmpRect.Width  = width;
            tmpRect.Height = height;
            if (tex.Equals((object)Utils.white))
            {
                if (!Button.outlineOnly)
                {
                    GuiData.spriteBatch.Draw(Utils.white, tmpRect, GuiData.hot == myID ? (GuiData.active == myID ? GuiData.Default_Trans_Grey_Dark : GuiData.Default_Trans_Grey_Bright) : GuiData.Default_Trans_Grey);
                    tmpRect.Width = num1;
                    GuiData.spriteBatch.Draw(Utils.white, tmpRect, selectedColor.Value);
                }
                RenderedRectangle.doRectangleOutline(x, y, width, height, 1, Button.outlineOnly ? selectedColor : new Color?(GuiData.Default_Trans_Grey_Solid));
            }
            else
            {
                GuiData.spriteBatch.Draw(tex, tmpRect, GuiData.hot == myID ? (GuiData.active == myID ? GuiData.Default_Unselected_Color : GuiData.Default_Lit_Backing_Color) : selectedColor.Value);
            }
            SpriteFont spriteFont = Button.smallButtonDraw ? GuiData.detailfont : GuiData.tinyfont;
            Vector2    scale      = spriteFont.MeasureString(text);
            float      num2       = LocaleActivator.ActiveLocaleIsCJK() ? 4f : 0.0f;
            float      y1         = scale.Y;

            scale.X = (double)scale.X <= (double)(width - 4) ? 1f : (float)(width - (4 + num1 + 5)) / scale.X;
            scale.Y = (double)scale.Y <= (double)height + (double)num2 - 0.0 ? 1f : (float)((double)height + (double)num2 - 0.0) / scale.Y;
            scale.X = Math.Min(scale.X, scale.Y);
            scale.Y = scale.X;
            if (Utils.FloatEquals(1f, scale.Y))
            {
                scale = Vector2.One;
            }
            int   num3 = num1 + 4;
            float num4 = y1 * scale.Y;
            float num5 = (float)((double)y + (double)height / 2.0 - (double)num4 / 2.0 + 1.0 - (double)num2 * (double)scale.Y / 2.0);

            GuiData.spriteBatch.DrawString(spriteFont, text, new Vector2((float)(int)((double)(x + 2 + num3) + 0.5), (float)(int)((double)num5 + 0.5)), Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f);
        }
Example #9
0
        public static void CaptureMultiLanguageScreen(object os_obj)
        {
            OS       os           = (OS)os_obj;
            GameTime gameTime     = new GameTime(os.lastGameTime.TotalGameTime, TimeSpan.Zero, false);
            string   str1         = "Screenshots/";
            string   activeLocale = Settings.ActiveLocale;

            for (int index = 0; index < LocaleActivator.SupportedLanguages.Count; ++index)
            {
                string code = LocaleActivator.SupportedLanguages[index].Code;
                LocaleActivator.ActivateLocale(code, os.content);
                Texture2D texture2D = (Texture2D)null;
                if (!Directory.Exists(str1 + code))
                {
                    Directory.CreateDirectory(str1 + code);
                }
                string str2 = Guid.NewGuid().ToString() + ".png";
                using (FileStream fileStream = File.Create(str1 + code + "/" + str2))
                    texture2D.SaveAsPng((Stream)fileStream, texture2D.Width, texture2D.Height);
            }
            LocaleActivator.ActivateLocale(activeLocale, os.content);
        }
Example #10
0
 protected void LoadInitialScreens()
 {
     if (Settings.ForceEnglish)
     {
         LocaleActivator.ActivateLocale(Settings.ActiveLocale, this.Content);
     }
     if (Game1.AutoLoadExtensionPath != null)
     {
         ExtensionLoader.ActiveExtensionInfo = ExtensionInfo.ReadExtensionInfo(Game1.AutoLoadExtensionPath);
         SaveFileManager.Init(true);
         SaveFileManager.DeleteUser("test");
         MainMenu.CreateNewAccountForExtensionAndStart("test", "test", this.sman, (GameScreen)null, (ExtensionsMenuScreen)null);
     }
     else if (Settings.MenuStartup)
     {
         this.sman.AddScreen((GameScreen) new MainMenu(), new PlayerIndex?(this.sman.controllingPlayer));
     }
     else
     {
         this.sman.AddScreen((GameScreen) new OS(), new PlayerIndex?(this.sman.controllingPlayer));
     }
 }
Example #11
0
        static SaveLoader()
        {
            EventManager.onPluginUnload += OnPluginUnload;

            executor.RegisterExecutor("HacknetSave", (exec, info) =>
            {
                MissionGenerator.generationCount = info.Attributes.GetInt("generatedMissionCount", 100);
                os.username          = os.defaultUser.name = info.Attributes.GetString("Username");
                os.LanguageCreatedIn = info.Attributes.GetString("Language", "en-us");
                os.IsInDLCMode       = info.Attributes.GetBool("DLCMode") && Settings.EnableDLC;
                os.DisableEmailIcon  = info.Attributes.GetBool("DisableMailIcon") && Settings.EnableDLC;

                if (os.LanguageCreatedIn != Settings.ActiveLocale)
                {
                    LocaleActivator.ActivateLocale(os.LanguageCreatedIn, os.content);
                    Settings.ActiveLocale = os.LanguageCreatedIn;
                }
            });
            executor.RegisterExecutor("HacknetSave.DLC", (exec, info) =>
            {
                os.IsDLCSave = true;

                os.IsInDLCMode         = info.Attributes.GetBool("Active");
                os.HasLoadedDLCContent = info.Attributes.GetBool("LoadedContent");

                if (os.HasLoadedDLCContent && !DLC1SessionUpgrader.HasDLC1Installed)
                {
                    MainMenu.AccumErrors = "LOAD ERROR: Save " + os.SaveGameUserName +
                                           " is configured for Labyrinths DLC, but it is not installed on this computer.\n\n\n";
                    os.ExitScreen();
                    os.IsExiting = true;
                }
            });
            executor.RegisterExecutor("HacknetSave.DLC.Flags",
                                      (exec, info) => os.PreDLCFaction = info.Attributes.GetString("OriginalFaction"));
            executor.RegisterExecutor("HacknetSave.DLC.OriginalVisibleNodes",
                                      (exec, info) => os.PreDLCVisibleNodesCache = info.Content ?? "",
                                      ParseOption.ParseInterior);
            executor.RegisterExecutor("HacknetSave.DLC.ConditionalActions",
                                      (exec, info) => os.ConditionalActions = ActionsLoader.LoadActionSets(info),
                                      ParseOption.ParseInterior);
            executor.RegisterExecutor("HacknetSave.Flags", (exec, info) =>
            {
                os.Flags.Flags.Clear();

                foreach (var flag in info.Content?.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) ?? new string[0])
                {
                    os.Flags.Flags.Add(flag
                                       .Replace("[%%COMMAREPLACED%%]", ",")
                                       .Replace("décrypté", "decypher"));
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("HacknetSave.NetworkMap",
                                      (exec, info) => { Enum.TryParse(info.Attributes.GetString("sort"), out os.netMap.SortingAlgorithm); });
            executor.RegisterExecutor("HacknetSave.NetworkMap", (exec, info) =>
            {
                foreach (var daemon in os.netMap.nodes.SelectMany(x => x.daemons))
                {
                    daemon.loadInit();
                }

                os.netMap.loadAssignGameNodes();
            }, ParseOption.FireOnEnd);
            executor.RegisterExecutor("HacknetSave.NetworkMap.network.computer", (exec, info) =>
            {
                var comp = LoadComputer(info, os);
                if (comp != null)
                {
                    os.netMap.nodes.Add(comp);
                }
            },
                                      ParseOption.ParseInterior);
            executor.RegisterExecutor("HacknetSave.NetworkMap.visible", (exec, info) =>
            {
                foreach (var node in info.Content.Split((char[])null, StringSplitOptions.RemoveEmptyEntries))
                {
                    os.netMap.visibleNodes.Add(int.Parse(node));
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("HacknetSave.mission", (exec, info) => os.currentMission = LoadMission(info));
            executor.RegisterExecutor("HacknetSave.AllFactions", (exec, info) =>
            {
                os.allFactions = new AllFactions
                {
                    currentFaction = info.Attributes.GetString("current", null)
                };

                foreach (var factionInfo in info.Children)
                {
                    var faction = ReplacementsCommon.LoadFaction(factionInfo);
                    os.allFactions.factions.Add(faction.idName, faction);
                }

                if (os.allFactions.currentFaction != null)
                {
                    os.allFactions.setCurrentFaction(os.allFactions.currentFaction, os);
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("HacknetSave.other", (exec, info) =>
            {
                MusicManager.playSongImmediatley(info.Attributes.GetString("music", null));
                os.homeNodeID        = info.Attributes.GetString("homeNode", os.homeNodeID);
                os.homeAssetServerID = info.Attributes.GetString("homeAssetsNode", os.homeAssetServerID);
            });
        }
Example #12
0
        public static string doTerminalTextField(int myID, int x, int y, int width, int selectionHeight, int lines, string str, SpriteFont font)
        {
            string s = str;

            if (font == null)
            {
                font = GuiData.smallfont;
            }
            TextBox.BoxWasActivated = false;
            TextBox.UpWasPresed     = false;
            TextBox.DownWasPresed   = false;
            TextBox.TabWasPresed    = false;
            Rectangle tmpRect = GuiData.tmpRect;

            tmpRect.X      = x;
            tmpRect.Y      = y;
            tmpRect.Width  = width;
            tmpRect.Height = 0;
            if (tmpRect.Contains(GuiData.getMousePoint()))
            {
                GuiData.hot = myID;
            }
            else if (GuiData.hot == myID)
            {
                GuiData.hot = -1;
            }
            if (GuiData.mouseWasPressed())
            {
                if (GuiData.hot == myID)
                {
                    if (GuiData.active == myID)
                    {
                        int  num  = GuiData.mouse.X - x;
                        bool flag = false;
                        for (int length = 1; length <= str.Length; ++length)
                        {
                            if ((double)font.MeasureString(str.Substring(0, length)).X > (double)num)
                            {
                                TextBox.cursorPosition = length - 1;
                                break;
                            }
                            if (!flag)
                            {
                                TextBox.cursorPosition = str.Length;
                            }
                        }
                    }
                    else
                    {
                        GuiData.active         = myID;
                        TextBox.cursorPosition = str.Length;
                    }
                }
                else if (GuiData.active == myID)
                {
                    GuiData.active = -1;
                }
            }
            int           active1             = GuiData.active;
            bool          flag1               = false;
            string        filteredStringInput = TextBox.getFilteredStringInput(s, GuiData.getKeyboadState(), GuiData.getLastKeyboadState());
            KeyboardState keyboardState       = GuiData.getKeyboadState();
            int           num1;

            if (keyboardState.IsKeyDown(Keys.Enter))
            {
                keyboardState = GuiData.getLastKeyboadState();
                num1          = keyboardState.IsKeyDown(Keys.Enter) ? 1 : 0;
            }
            else
            {
                num1 = 1;
            }
            if (num1 == 0)
            {
                TextBox.BoxWasActivated        = true;
                TextBox.cursorPosition         = 0;
                TextBox.textDrawOffsetPosition = 0;
            }
            tmpRect.Height = lines * TextBox.LINE_HEIGHT;
            ++TextBox.FramesSelected;
            tmpRect.X       = x;
            tmpRect.Y       = y;
            tmpRect.Width   = width;
            tmpRect.Height  = 10;
            tmpRect.X      += 2;
            tmpRect.Y      += 2;
            tmpRect.Width  -= 4;
            tmpRect.Height -= 4;
            float  num2       = (float)(((double)TextBox.LINE_HEIGHT - (double)font.MeasureString(filteredStringInput).Y) / 2.0);
            string str1       = filteredStringInput;
            int    num3       = 0;
            int    startIndex = 0;
            int    length1;

            for (string text = str1; (double)font.MeasureString(text).X > (double)(width - 5); text = str1.Substring(startIndex, length1))
            {
                ++num3;
                length1 = str1.Length - startIndex - (num3 - startIndex);
                if (length1 < 0)
                {
                    break;
                }
            }
            if (TextBox.cursorPosition < TextBox.textDrawOffsetPosition)
            {
                TextBox.textDrawOffsetPosition = Math.Max(0, TextBox.textDrawOffsetPosition - 1);
            }
            while (TextBox.cursorPosition > TextBox.textDrawOffsetPosition + (str1.Length - num3))
            {
                ++TextBox.textDrawOffsetPosition;
            }
            if (str1.Length <= num3 || TextBox.textDrawOffsetPosition < 0)
            {
                TextBox.textDrawOffsetPosition = TextBox.textDrawOffsetPosition > str1.Length - num3 ? 0 : str1.Length - num3;
            }
            else if (TextBox.textDrawOffsetPosition > num3)
            {
                num3 = TextBox.textDrawOffsetPosition;
            }
            if (num3 > str1.Length)
            {
                num3 = str1.Length - 1;
            }
            if (TextBox.textDrawOffsetPosition >= str1.Length)
            {
                TextBox.textDrawOffsetPosition = 0;
            }
            string text1 = str1.Substring(TextBox.textDrawOffsetPosition, str1.Length - num3);

            if (TextBox.MaskingText)
            {
                string str2 = "";
                for (int index = 0; index < filteredStringInput.Length; ++index)
                {
                    str2 += "*";
                }
                text1 = str2;
            }
            GuiData.spriteBatch.DrawString(font, text1, Utils.ClipVec2ForTextRendering(new Vector2((float)(x + 2), (float)y + num2)), Color.White);
            int active2 = GuiData.active;

            flag1 = false;
            if (filteredStringInput != "")
            {
                int length2 = Math.Min(TextBox.cursorPosition - TextBox.textDrawOffsetPosition, text1.Length);
                if (length2 <= 0)
                {
                    length2 = 1;
                }
                tmpRect.X = text1.Length != 0 ? (int)((double)x + (double)font.MeasureString(text1.Substring(0, length2)).X) + 3 : x;
            }
            else
            {
                tmpRect.X = x + 3;
            }
            tmpRect.Y      = y + 2;
            tmpRect.Width  = 1;
            tmpRect.Height = TextBox.LINE_HEIGHT - 4;
            if (LocaleActivator.ActiveLocaleIsCJK())
            {
                tmpRect.Y += 4;
            }
            GuiData.spriteBatch.Draw(Utils.white, tmpRect, TextBox.FramesSelected % 60 < 40 ? Color.White : Color.Gray);
            return(filteredStringInput);
        }
        public void Draw(Rectangle dest, SpriteBatch sb)
        {
            int       width1  = (int)((double)dest.Width * 0.5);
            int       val2    = (int)((double)dest.Height * 0.400000005960464);
            int       val1    = 400;
            bool      flag    = val1 > val2;
            int       height1 = Math.Max(val1, val2);
            Rectangle dest1   = new Rectangle(dest.Width / 2 - width1 / 2, (int)((double)dest.Y + (double)dest.Height / 2.5 - (double)(height1 / 2)), width1, height1);
            Rectangle destinationRectangle1 = new Rectangle(dest.X, dest1.Y + 115 + (flag ? 7 : 0), dest.Width, dest1.Height - 245);

            sb.Draw(Utils.white, destinationRectangle1, Color.Lerp(new Color(115, 0, 0), new Color(122, 0, 0), 0.0f + Utils.randm((float)(1.0 - (double)Utils.randm(1f) * (double)Utils.randm(1f)))));
            dest1.Y += 12;
            TextItem.doFontLabelToSize(dest1, Utils.FlipRandomChars("HACKNET", 0.028), GuiData.titlefont, Color.White * 0.12f, false, false);
            FlickeringTextEffect.DrawLinedFlickeringText(dest1, Utils.FlipRandomChars("HACKNET", 0.003), 11f, 0.7f, GuiData.titlefont, (object)null, Color.White, 5);
            int       y       = destinationRectangle1.Y + dest1.Height - 80;
            int       width2  = dest.Width / 4;
            int       num1    = 20;
            int       num2    = (width2 - num1) / 2;
            int       height2 = 42;
            Rectangle destinationRectangle2 = new Rectangle(dest.X + dest.Width / 2 - width2 / 2, y, width2, height2);

            if (Settings.MultiLingualDemo)
            {
                sb.Draw(Utils.white, destinationRectangle2, Color.Black * 0.8f);
                if (Button.doButton(18273302, destinationRectangle2.X, destinationRectangle2.Y, destinationRectangle2.Width, destinationRectangle2.Height, LocaleTerms.Loc("New Session"), new Color?(new Color(124, 137, 149))))
                {
                    LocaleActivator.ActivateLocale("ko-kr", Game1.getSingleton().Content);
                    if (this.Start != null)
                    {
                        this.Start();
                    }
                }
                destinationRectangle2.Y += destinationRectangle2.Height + 12;
                sb.Draw(Utils.white, destinationRectangle2, Color.Black * 0.8f);
                if (Button.doButton(18273304, destinationRectangle2.X, destinationRectangle2.Y, destinationRectangle2.Width, destinationRectangle2.Height, "Hacknet Veterans", new Color?(new Color(124, 137, 149))))
                {
                    LocaleActivator.ActivateLocale("en-us", Game1.getSingleton().Content);
                    if (this.StartDLC != null)
                    {
                        this.StartDLC();
                    }
                }
                destinationRectangle2.Y += destinationRectangle2.Height + 12;
                sb.Draw(Utils.white, destinationRectangle2, Color.Black * 0.8f);
                if (!Button.doButton(18273306, destinationRectangle2.X, destinationRectangle2.Y, destinationRectangle2.Width, destinationRectangle2.Height, "New Session", new Color?(new Color(124, 137, 149))))
                {
                    return;
                }
                LocaleActivator.ActivateLocale("en-us", Game1.getSingleton().Content);
                if (this.Start != null)
                {
                    this.Start();
                }
            }
            else
            {
                sb.Draw(Utils.white, destinationRectangle2, Color.Black * 0.8f);
                if (Button.doButton(18273302, destinationRectangle2.X, destinationRectangle2.Y, destinationRectangle2.Width, destinationRectangle2.Height, LocaleTerms.Loc("New Session"), new Color?(new Color(124, 137, 149))) && this.Start != null)
                {
                    this.Start();
                }
                destinationRectangle2.Y += destinationRectangle2.Height + 12;
                if (Settings.DLCEnabledDemo)
                {
                    sb.Draw(Utils.white, destinationRectangle2, Color.Black * 0.8f);
                    if (Button.doButton(18273303, destinationRectangle2.X, destinationRectangle2.Y, destinationRectangle2.Width, destinationRectangle2.Height, LocaleTerms.Loc("Labyrinths (Hacknet Veterans)"), new Color?(new Color(184, 137, 149))) && this.StartDLC != null)
                    {
                        this.StartDLC();
                    }
                }
            }
        }
Example #14
0
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            PostProcessor.begin();
            this.ScreenManager.FadeBackBufferToBlack((int)byte.MaxValue);
            GuiData.startDraw();
            int      x        = 0;
            int      y        = 0;
            Viewport viewport = this.ScreenManager.GraphicsDevice.Viewport;
            int      width    = viewport.Width;

            viewport = this.ScreenManager.GraphicsDevice.Viewport;
            int height = viewport.Height;

            PatternDrawer.draw(new Rectangle(x, y, width, height), 0.5f, Color.Black, new Color(2, 2, 2), GuiData.spriteBatch);
            if (Button.doButton(999, 10, 10, 220, 30, "<- " + LocaleTerms.Loc("Back"), new Color?(Color.Gray)))
            {
                SettingsLoader.writeStatusFile();
                this.ExitScreen();
            }
            if (Button.doButton(9907, 10, 44, 220, 20, LocaleTerms.Loc("Apply Changes"), new Color?(Color.LightBlue)))
            {
                this.needsApply = true;
            }
            int num1 = 100;

            TextItem.doLabel(new Vector2(400f, (float)num1), LocaleTerms.Loc("Resolutions"), new Color?(), 200f);
            int currentResIndex = this.currentResIndex;

            this.currentResIndex = SelectableTextList.doFancyList(10, 400, num1 + 36, 200, 450, this.resolutions, this.currentResIndex, new Color?(), false);
            if (!this.mouseHasBeenReleasedOnThisScreen)
            {
                this.currentResIndex = currentResIndex;
            }
            else if (SelectableTextList.wasActivated)
            {
                this.resolutionChanged = true;
            }
            if (!this.startedFromGameContext)
            {
                TextItem.doLabel(new Vector2(620f, (float)num1), LocaleTerms.Loc("Language"), new Color?(), 200f);
                int currentLocaleIndex = this.currentLocaleIndex;
                this.currentLocaleIndex = SelectableTextList.doFancyList(1013, 620, num1 + 36, 200, 450, this.localeNames, this.currentLocaleIndex, new Color?(), false);
                if (!this.mouseHasBeenReleasedOnThisScreen)
                {
                    this.currentLocaleIndex = currentLocaleIndex;
                }
                else if (SelectableTextList.wasActivated)
                {
                    LocaleActivator.ActivateLocale(LocaleActivator.SupportedLanguages[this.currentLocaleIndex].Code, Game1.getSingleton().Content);
                    Settings.ActiveLocale = LocaleActivator.SupportedLanguages[this.currentLocaleIndex].Code;
                }
            }
            int   num2     = 64;
            float MaxWidth = 280f;
            int   num3;

            TextItem.doLabel(new Vector2(100f, (float)(num3 = num2 + 36)), LocaleTerms.Loc("Fullscreen"), new Color?(), MaxWidth);
            int num4;

            this.windowed = CheckBox.doCheckBox(20, 100, num4 = num3 + 34, this.windowed, new Color?());
            int num5;

            TextItem.doLabel(new Vector2(100f, (float)(num5 = num4 + 32)), LocaleTerms.Loc("Bloom"), new Color?(), MaxWidth);
            int num6;

            PostProcessor.bloomEnabled = CheckBox.doCheckBox(21, 100, num6 = num5 + 34, PostProcessor.bloomEnabled, new Color?());
            int num7;

            TextItem.doLabel(new Vector2(100f, (float)(num7 = num6 + 32)), LocaleTerms.Loc("Scanlines"), new Color?(), MaxWidth);
            int num8;

            PostProcessor.scanlinesEnabled = CheckBox.doCheckBox(22, 100, num8 = num7 + 34, PostProcessor.scanlinesEnabled, new Color?());
            int num9;

            TextItem.doLabel(new Vector2(100f, (float)(num9 = num8 + 32)), LocaleTerms.Loc("Multisampling"), new Color?(), MaxWidth);
            bool shouldMultisample = SettingsLoader.ShouldMultisample;
            int  num10;

            SettingsLoader.ShouldMultisample = CheckBox.doCheckBox(221, 100, num10 = num9 + 34, SettingsLoader.ShouldMultisample, new Color?());
            if (shouldMultisample != SettingsLoader.ShouldMultisample)
            {
                this.resolutionChanged = true;
            }
            int num11;

            TextItem.doLabel(new Vector2(100f, (float)(num11 = num10 + 32)), LocaleTerms.Loc("Audio Visualiser"), new Color?(), MaxWidth);
            int num12;

            SettingsLoader.ShouldDrawMusicVis = CheckBox.doCheckBox(223, 100, num12 = num11 + 34, SettingsLoader.ShouldDrawMusicVis, new Color?());
            int num13;

            TextItem.doLabel(new Vector2(100f, (float)(num13 = num12 + 32)), LocaleTerms.Loc("Sound Enabled"), new Color?(), MaxWidth);
            int num14;

            MusicManager.setIsMuted(!CheckBox.doCheckBox(23, 100, num14 = num13 + 34, !MusicManager.isMuted, new Color?()));
            int num15;

            TextItem.doLabel(new Vector2(100f, (float)(num15 = num14 + 32)), LocaleTerms.Loc("Music Volume"), new Color?(), MaxWidth);
            int num16;

            MusicManager.setVolume(SliderBar.doSliderBar(24, 100, num16 = num15 + 34, 210, 30, 1f, 0.0f, MusicManager.getVolume(), 1f / 1000f));
            int num17;

            TextItem.doLabel(new Vector2(100f, (float)(num17 = num16 + 32)), LocaleTerms.Loc("Text Size"), new Color?(), MaxWidth);
            int currentFontIndex = this.currentFontIndex;
            int num18;

            this.currentFontIndex = SelectableTextList.doFancyList(25, 100, num18 = num17 + 34, 200, 160, this.fontConfigs, this.currentFontIndex, new Color?(), false);
            if (this.currentFontIndex != currentFontIndex && this.startedFromGameContext)
            {
                try
                {
                    if (OS.currentInstance != null)
                    {
                        OS.currentInstance.terminal.reset();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine((object)ex);
                    Utils.AppendToErrorFile(Utils.GenerateReportFromException(ex));
                }
            }
            if (Button.doButton(990, 10, num18 + 150, 220, 30, LocaleTerms.Loc("Apply Changes"), new Color?(Color.LightBlue)))
            {
                this.needsApply = true;
            }
            GuiData.endDraw();
            PostProcessor.end();
        }
Example #15
0
        public static int doFancyList(int myID, int x, int y, int width, int height, string[] text, int lastSelectedIndex, Color?selectedColor, bool HasDraggableScrollbar = false)
        {
            if (!selectedColor.HasValue)
            {
                selectedColor = new Color?(GuiData.Default_Selected_Color);
            }
            int num1 = -1;

            SelectableTextList.wasActivated = false;
            int num2 = lastSelectedIndex;

            SelectableTextList.selectionWasChanged = false;
            Vector2   mousePos = GuiData.getMousePos();
            Rectangle tmpRect  = GuiData.tmpRect;

            tmpRect.X      = x;
            tmpRect.Y      = y;
            tmpRect.Width  = width;
            tmpRect.Height = height;
            if (tmpRect.Contains(GuiData.getMousePoint()))
            {
                GuiData.hot = myID;
                SelectableTextList.scrollOffset += (int)GuiData.getMouseWheelScroll();
                SelectableTextList.scrollOffset  = Math.Max(0, Math.Min(SelectableTextList.scrollOffset, text.Length - (int)((double)height / 18.0)));
            }
            else if (GuiData.hot == myID)
            {
                GuiData.hot = -1;
            }
            int   num3 = Math.Max(0, Math.Min(SelectableTextList.scrollOffset, text.Length - (int)((double)height / 18.0)));
            float num4 = HasDraggableScrollbar ? 4f : 2f;

            if (GuiData.hot == myID && (!HasDraggableScrollbar || (double)mousePos.X < (double)(x + width) - 2.0 * (double)num4))
            {
                for (int index = 0; index < text.Length; ++index)
                {
                    if ((double)mousePos.Y >= (double)y + (double)index * 18.0 && (double)mousePos.Y <= (double)y + (double)(index + 1) * 18.0 && (double)mousePos.Y < (double)(y + height))
                    {
                        num1 = index + num3;
                    }
                }
            }
            if (num1 != -1 && num1 != lastSelectedIndex && GuiData.mouseLeftUp())
            {
                lastSelectedIndex = num1;
                SelectableTextList.wasActivated = true;
            }
            tmpRect.X      += 2;
            tmpRect.Width  -= 4;
            tmpRect.Y      += 2;
            tmpRect.Height -= 4;
            Vector2 input = new Vector2((float)tmpRect.X, (float)tmpRect.Y);

            tmpRect.Height = 18;
            for (int index = num3; index < text.Length; ++index)
            {
                GuiData.spriteBatch.Draw(Utils.white, tmpRect, lastSelectedIndex == index ? selectedColor.Value : (num1 == index ? selectedColor.Value * 0.45f : GuiData.Default_Dark_Neutral_Color));
                Vector2 scale = GuiData.UITinyfont.MeasureString(text[index]);
                scale.X = (double)scale.X <= (double)(width - 4) ? 1f : (float)(width - 4) / scale.X;
                scale.Y = (double)scale.Y <= 18.0 ? 1f : 18f / scale.Y;
                scale.X = Math.Min(scale.X, scale.Y);
                scale.Y = Math.Min(scale.X, scale.Y);
                bool flag = !LocaleActivator.ActiveLocaleIsCJK() && Settings.ActiveLocale != "en-us";
                if (flag)
                {
                    input.Y += 3f;
                }
                GuiData.spriteBatch.DrawString(GuiData.UITinyfont, text[index], Utils.ClipVec2ForTextRendering(input), lastSelectedIndex == index ? Color.Black : Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f);
                if (flag)
                {
                    input.Y -= 3f;
                }
                input.Y   += 18f;
                tmpRect.Y += 18;
                if ((double)input.Y > (double)(y + height - 4))
                {
                    break;
                }
            }
            if ((double)text.Length * 18.0 > (double)height)
            {
                float num5 = num4;
                float num6 = (float)height / ((float)text.Length * 18f) * (float)height;
                height -= 4;
                float num7 = (float)-height + (float)(((double)height - (double)num6) * ((double)num3 / (((double)text.Length * 18.0 - (double)height) / 18.0)));
                tmpRect.X      = (int)((double)input.X + (double)width - (HasDraggableScrollbar ? 2.0 : 3.0) * (double)num5 - 2.0);
                tmpRect.Y      = (int)((double)input.Y + (double)num7 + 2.0);
                tmpRect.Height = (int)num6;
                tmpRect.Width  = (int)num5;
                if (!HasDraggableScrollbar)
                {
                    GuiData.spriteBatch.Draw(Utils.white, tmpRect, SelectableTextList.scrollBarColor);
                }
                else
                {
                    SelectableTextList.scrollOffset = (int)((double)ScrollBar.doVerticalScrollBar(myID + 101, tmpRect.X, y, tmpRect.Width, height, (int)((double)text.Length * 18.0), (float)num3 * 18f) / 18.0);
                }
            }
            if (lastSelectedIndex != num2)
            {
                SelectableTextList.selectionWasChanged = true;
            }
            return(lastSelectedIndex);
        }
Example #16
0
        private void doConnectHeader()
        {
            Computer comp = this.os.connectedComp != null ? this.os.connectedComp : this.os.thisComputer;

            this.x += 20;
            this.y += 5;
            this.spriteBatch.Draw(this.GetComputerImage(comp), new Vector2((float)this.x, (float)this.y), Color.White);
            this.spriteBatch.DrawString(GuiData.font, LocaleTerms.Loc("Connected to") + " ", new Vector2((float)(this.x + 160), (float)this.y), Color.White);
            this.y += 40;
            TextItem.doFontLabel(new Vector2((float)(this.x + 160), (float)this.y), this.os.connectedComp == null ? this.os.thisComputer.name : this.os.connectedComp.name, GuiData.font, new Color?(Color.White), (float)this.bounds.Width - 190f, 60f, false);
            this.y += 33;
            string str  = this.os.connectedComp == null ? this.os.thisComputer.ip : this.os.connectedComp.ip;
            float  num1 = LocaleActivator.ActiveLocaleIsCJK() ? 4f : 0.0f;

            this.spriteBatch.DrawString(GuiData.smallfont, "@  " + str, new Vector2((float)(this.x + 160), (float)this.y + num1), Color.White);
            this.y += 60;
            if (this.os.hasConnectionPermission(true))
            {
                this.y -= 20;
                Rectangle empty = Rectangle.Empty;
                empty.X      = this.bounds.X + 1;
                empty.Y      = this.y;
                empty.Width  = this.bounds.Width - 2;
                empty.Height = 20;
                this.spriteBatch.Draw(Utils.white, empty, this.os.highlightColor);
                string  text    = LocaleTerms.Loc("You are the Administrator of this System");
                Vector2 vector2 = GuiData.UISmallfont.MeasureString(text);
                Vector2 pos     = new Vector2((float)(empty.X + empty.Width / 2) - vector2.X / 2f, (float)empty.Y);
                if (LocaleActivator.ActiveLocaleIsCJK())
                {
                    pos.Y -= 2f;
                }
                this.os.postFXDrawActions += (Action)(() => this.spriteBatch.DrawString(GuiData.UISmallfont, text, pos, Color.Black));
                if (this.bounds.Height > 500)
                {
                    this.y += 40;
                }
                else
                {
                    this.y += 12;
                }
            }
            if (comp.portsNeededForCrack > 100)
            {
                this.y += 10;
                Rectangle rectangle = new Rectangle(this.bounds.X + 2, this.y, this.bounds.Width - 4, 20);
                string    text      = "INVIOLABILITY DETECTED";
                Vector2   vector2   = GuiData.titlefont.MeasureString(text);
                float     num2      = vector2.X / vector2.Y;
                int       num3      = 10;
                int       width     = (int)((double)rectangle.Height * (double)num2);
                vector2.Y /= vector2.Y / 20f;
                int       num4 = (int)((double)(rectangle.Width - width) / 2.0);
                Rectangle destinationRectangle = new Rectangle(rectangle.X, rectangle.Y, num4 - num3, rectangle.Height);
                Rectangle dest = new Rectangle(destinationRectangle.X + destinationRectangle.Width + num3, destinationRectangle.Y, width, rectangle.Height);
                destinationRectangle.Y      += 4;
                destinationRectangle.Height -= 8;
                this.spriteBatch.Draw(Utils.white, destinationRectangle, Color.Red);
                FlickeringTextEffect.DrawLinedFlickeringText(dest, text, 3f, 0.1f, GuiData.titlefont, (object)this.os, Utils.AddativeWhite, 2);
                destinationRectangle.X = rectangle.X + rectangle.Width - (destinationRectangle.Width + num3) + num3;
                this.spriteBatch.Draw(Utils.white, destinationRectangle, Color.Red);
                this.y += 40;
            }
            else
            {
                if (!this.os.hasConnectionPermission(true))
                {
                    return;
                }
                this.y += 40;
            }
        }
Example #17
0
        public override void Update(float t)
        {
            base.Update(t);
            double timer = (double)this.timer;

            this.timer += t;
            float num1 = Settings.isDemoMode ? IntroTextModule.DEMO_DELAY_FROM_START_MUSIC_TIMER : IntroTextModule.DELAY_FROM_START_MUSIC_TIMER;

            if (Settings.IsInExtensionMode)
            {
                num1 = ExtensionLoader.ActiveExtensionInfo.IntroStartupSongDelay;
            }
            if (timer < (double)num1 && (double)this.timer >= (double)num1)
            {
                MusicManager.playSong();
            }
            float num2 = 1f;

            if (LocaleActivator.ActiveLocaleIsCJK())
            {
                num2 = 0.6f;
            }
            if (this.finishedText)
            {
                if ((double)this.timer <= (double)IntroTextModule.STAY_ONSCREEN_TIME || (double)this.timer <= (double)IntroTextModule.STAY_ONSCREEN_TIME + (double)IntroTextModule.MODULE_FLASH_TIME)
                {
                    return;
                }
                this.complete = true;
            }
            else if ((double)this.timer > (double)IntroTextModule.FLASH_TIME)
            {
                this.charTimer += t * num2;
                if ((double)this.charTimer < (double)IntroTextModule.CHAR_TIME)
                {
                    return;
                }
                KeyboardState keyboadState;
                double        num3;
                if (!Settings.isConventionDemo)
                {
                    num3 = 0.0;
                }
                else
                {
                    double charTime = (double)IntroTextModule.CHAR_TIME;
                    keyboadState = GuiData.getKeyboadState();
                    double num4 = keyboadState.IsKeyDown(Keys.LeftShift) ? 0.990000009536743 : 0.5;
                    num3 = charTime * num4;
                }
                this.charTimer = (float)num3;
                ++this.charIndex;
                if (this.charIndex >= this.text[this.textIndex].Length)
                {
                    this.charTimer  = IntroTextModule.CHAR_TIME;
                    this.charIndex  = this.text[this.textIndex].Length - 1;
                    this.lineTimer += t;
                    if ((double)this.lineTimer >= (double)IntroTextModule.LINE_TIME)
                    {
                        double num4;
                        if (!Settings.isConventionDemo)
                        {
                            num4 = 0.0;
                        }
                        else
                        {
                            double lineTime = (double)IntroTextModule.LINE_TIME;
                            keyboadState = GuiData.getKeyboadState();
                            double num5 = keyboadState.IsKeyDown(Keys.LeftShift) ? 0.990000009536743 : 0.200000002980232;
                            num4 = lineTime * num5;
                        }
                        this.lineTimer = (float)num4;
                        ++this.textIndex;
                        this.charIndex = 0;
                        if (this.textIndex >= this.text.Length)
                        {
                            if (!MusicManager.isPlaying)
                            {
                                MusicManager.playSong();
                            }
                            this.finishedText = true;
                            this.timer        = 0.0f;
                        }
                    }
                }
            }
            else if (Settings.isConventionDemo && GuiData.getKeyboadState().IsKeyDown(Keys.LeftShift))
            {
                this.timer += t + t;
            }
        }
Example #18
0
        protected override void LoadContent()
        {
            if (!this.CanLoadContent)
            {
                return;
            }
            PortExploits.populate();
            this.sman.controllingPlayer = PlayerIndex.One;
            if (Settings.isConventionDemo)
            {
                this.setWindowPosition(new Vector2(200f, 200f));
            }
            this.LoadGraphicsContent();
            this.LoadRegenSafeContent();
            ContentManager content = this.Content;

            GuiData.font        = content.Load <SpriteFont>("Font23");
            GuiData.titlefont   = content.Load <SpriteFont>("Kremlin");
            GuiData.smallfont   = this.Content.Load <SpriteFont>("Font12");
            GuiData.UISmallfont = GuiData.smallfont;
            GuiData.tinyfont    = this.Content.Load <SpriteFont>("Font10");
            GuiData.UITinyfont  = this.Content.Load <SpriteFont>("Font10");
            GuiData.detailfont  = this.Content.Load <SpriteFont>("Font7");
            GuiData.spriteBatch = this.sman.SpriteBatch;
            GuiData.InitFontOptions(this.Content);
            GuiData.init(this.Window);
            DLC1SessionUpgrader.CheckForDLCFiles();
            VehicleInfo.init();
            WorldLocationLoader.init();
            ThemeManager.init(content);
            MissionGenerationParser.init();
            MissionGenerator.init(content);
            UsernameGenerator.init();
            MusicManager.init(content);
            SFX.init(content);
            OldSystemSaveFileManifest.Load();
            try
            {
                SaveFileManager.Init(true);
            }
            catch (UnauthorizedAccessException ex)
            {
                MainMenu.AccumErrors += " ---- WARNING ---\nHacknet cannot access the Save File Folder (Path Below) to read/write save files.\nNO PROGRESS WILL BE SAVED.\n";
                MainMenu.AccumErrors += "Check folder permissions, run Hacknet.exe as Administrator, and try again.\n";
                MainMenu.AccumErrors += "If Errors Persist, search for \"Hacknet Workaround\" for a steam forums thread with more options.\n";
                MainMenu.AccumErrors  = MainMenu.AccumErrors + ":: Error Details ::\n" + Utils.GenerateReportFromException((Exception)ex);
            }
            if (this.NeedsSettingsLocaleActivation)
            {
                if (!Settings.ForceEnglish)
                {
                    string forActiveLanguage = PlatformAPISettings.GetCodeForActiveLanguage(LocaleActivator.SupportedLanguages);
                    LocaleActivator.ActivateLocale(forActiveLanguage, this.Content);
                    Settings.ActiveLocale = forActiveLanguage;
                }
            }
            else if (SettingsLoader.didLoad && Settings.ActiveLocale != "en-us")
            {
                LocaleActivator.ActivateLocale(Settings.ActiveLocale, this.Content);
            }
            Helpfile.init();
            FileEntry.init(this.Content);
            this.HasLoadedContent = true;
            this.LoadInitialScreens();
            if (!WebRenderer.Enabled)
            {
                return;
            }
            XNAWebRenderer.XNAWR_Initialize("file:///nope.html", WebRenderer.textureUpdated, 512, 512);
            WebRenderer.setSize(512, 512);
        }
Example #19
0
        public override void Draw(float t)
        {
            base.Draw(t);
            this.spriteBatch.Draw(Utils.white, this.bounds, this.os.darkBackgroundColor);
            Vector2   pos = new Vector2((float)this.bounds.X + 10f, (float)(this.bounds.Y + this.bounds.Height) - (GuiData.ActiveFontConfig.tinyFontCharHeight + 16f));
            Rectangle destinationRectangle = new Rectangle((int)pos.X, (int)pos.Y, 10, 14);

            this.spriteBatch.Draw(Utils.white, destinationRectangle, (double)this.os.timer % 0.300000011920929 < 0.150000005960464 ? Color.White : Color.White * 0.05f);
            List <string> stringList = new List <string>();
            Color         c          = Color.Lerp(Utils.AddativeWhite, Utils.makeColor((byte)204, byte.MaxValue, (byte)249, (byte)0), 0.5f);
            float         num1       = this.blocksComplete < 11 ? -8.3f : 0.0f;

            pos.Y -= 6f;
            if (this.AwaitingInput)
            {
                pos.Y -= 46f;
                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    if (Button.doButton(464191001, (int)pos.X, (int)pos.Y - 4, 220, 30, LocaleTerms.Loc("Proceed"), new Color?(Color.White)))
                    {
                        HostileHackerBreakinSequence.CopyHelpFile();
                        HostileHackerBreakinSequence.OpenWindowsHelpDocument();
                        HostileHackerBreakinSequence.OpenTerminal();
                        HostileHackerBreakinSequence.CrashProgram();
                    }
                }
                else
                {
                    if (Button.doButton(464191002, (int)pos.X, (int)pos.Y - 4, 220, 30, LocaleTerms.Loc("README"), new Color?(Color.White)))
                    {
                        this.SequenceBlocks.Add("");
                        this.SequenceBlocks.Add("");
                        this.SequenceBlocks.Add("");
                        this.SequenceBlocks.Add(HostileHackerBreakinSequence.GetHelpText());
                        this.SequenceBlocks.Add("");
                        this.blocksComplete = this.SequenceBlocks.Count - 1;
                    }
                    if (Button.doButton(464191003, (int)pos.X + 230, (int)pos.Y - 4, 220, 30, LocaleTerms.Loc("Terminal"), new Color?(Color.White)))
                    {
                        this.SequenceBlocks.Add("---------------------------------------");
                        this.SequenceBlocks.Add("TERMINAL SHOULD BE OPEN ON YOUR SYSTEM.");
                        this.SequenceBlocks.Add("");
                        this.SequenceBlocks.Add("IF NOT, OPEN A TERMINAL TO");
                        this.SequenceBlocks.Add(HostileHackerBreakinSequence.OpenTerminal());
                        this.SequenceBlocks.Add("---------------------------------------");
                        this.SequenceBlocks.Add("");
                        this.blocksComplete = this.SequenceBlocks.Count - 1;
                    }
                    if (Button.doButton(464191001, (int)pos.X + 460, (int)pos.Y - 4, 220, 30, LocaleTerms.Loc("Crash VM"), new Color?(Color.White)))
                    {
                        HostileHackerBreakinSequence.CopyHelpFile();
                        HostileHackerBreakinSequence.CrashProgram();
                    }
                }
            }
            if (this.blocksComplete + 1 < this.SequenceBlocks.Count)
            {
                string[] strArray = this.SequenceBlocks[this.blocksComplete + 1].Split(Utils.robustNewlineDelim, StringSplitOptions.None);
                int      num2     = (int)(Math.Min(1f, this.elapsedTime / (num1 + 9.2f)) * (float)(strArray.Length - 1));
                for (int index = num2; index >= 0; --index)
                {
                    string str = strArray[index];
                    if (index == num2 && this.blocksComplete + 1 >= 11)
                    {
                        float val1   = (num1 + 9.2f) / (float)Math.Max(1, strArray.Length - 1);
                        float num3   = Math.Min(val1, this.elapsedTime - (float)num2 * val1);
                        int   length = (int)((double)str.Length * ((double)num3 / (double)val1));
                        str = str.Substring(0, length);
                    }
                    stringList.Add(str);
                }
            }
            for (int blocksComplete = this.blocksComplete; blocksComplete >= 0; --blocksComplete)
            {
                string[] strArray = this.SequenceBlocks[blocksComplete].Split(Utils.robustNewlineDelim, StringSplitOptions.None);
                for (int index = strArray.Length - 1; index >= 0; --index)
                {
                    stringList.Add(strArray[index]);
                }
            }
            for (int index = 0; index < stringList.Count; ++index)
            {
                pos.Y -= GuiData.ActiveFontConfig.tinyFontCharHeight + 6f;
                this.DrawMonospace(stringList[index], GuiData.smallfont, pos, c, LocaleActivator.ActiveLocaleIsCJK() ? 13f : 10f);
            }
        }
Example #20
0
        public static bool ExecuteProgram(object os_object, string[] arguments)
        {
            OS os = (OS)os_object;

            string[] strArray = arguments;
            bool     flag1    = true;

            if (strArray[0].ToLower().Equals("connect"))
            {
                Programs.connect(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("disconnect") || strArray[0].Equals("dc"))
            {
                Programs.disconnect(strArray, os);
            }
            else if (strArray[0].Equals("ls") || strArray[0].Equals("dir"))
            {
                Programs.ls(strArray, os);
            }
            else if (strArray[0].Equals("cd"))
            {
                Programs.cd(strArray, os);
            }
            else if (strArray[0].Equals("cd.."))
            {
                strArray = new string[2] {
                    "cd", ".."
                };
                Programs.cd(strArray, os);
            }
            else if (strArray[0].Equals("cat") || strArray[0].Equals("more") || strArray[0].Equals("less"))
            {
                Programs.cat(strArray, os);
            }
            else if (strArray[0].Equals("exe"))
            {
                Programs.execute(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("probe") || strArray[0].Equals("nmap"))
            {
                Programs.probe(strArray, os);
            }
            else if (strArray[0].Equals("scp"))
            {
                Programs.scp(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("scan"))
            {
                Programs.scan(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("rm") || strArray[0].Equals("del"))
            {
                Programs.rm(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("mv"))
            {
                Programs.mv(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("ps"))
            {
                Programs.ps(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("kill") || strArray[0].Equals("pkill"))
            {
                Programs.kill(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("reboot"))
            {
                Programs.reboot(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("opencdtray"))
            {
                Programs.opCDTray(strArray, os, true);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("closecdtray"))
            {
                Programs.opCDTray(strArray, os, false);
                flag1 = false;
            }
            else if (strArray[0].Equals("replace"))
            {
                Programs.replace2(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("analyze"))
            {
                Programs.analyze(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("solve"))
            {
                Programs.solve(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("clear"))
            {
                Programs.clear(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("upload") || strArray[0].Equals("up"))
            {
                Programs.upload(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("login"))
            {
                Programs.login(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("addnote"))
            {
                Programs.addNote(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals(":(){:|:&};:"))
            {
                ProgramRunner.ExecuteProgram((object)os, new string[1]
                {
                    "forkbomb"
                });
            }
            else if (strArray[0].ToLower().Equals("append"))
            {
                flag1 = false;
                string[] quoteSeperatedArgs = Utils.GetQuoteSeperatedArgs(strArray);
                Folder   currentFolder      = Programs.getCurrentFolder(os);
                if (quoteSeperatedArgs.Length > 1)
                {
                    FileEntry fileEntry1 = currentFolder.searchForFile(quoteSeperatedArgs[1]);
                    int       num        = 2;
                    if (fileEntry1 == null)
                    {
                        fileEntry1 = currentFolder.searchForFile(os.display.commandArgs[1]);
                        if (fileEntry1 == null)
                        {
                            os.write("Usage: append [FILENAME] [LINE TO APPEND]");
                            return(flag1);
                        }
                        os.write("No filename provided");
                        os.write("Assuming active flag file \"" + fileEntry1.name + "\" For editing");
                        if (strArray.Length == 1)
                        {
                            strArray = new string[2]
                            {
                                "append",
                                fileEntry1.name
                            }
                        }
                        ;
                        else
                        {
                            strArray[1] = fileEntry1.name;
                        }
                        num = 1;
                    }
                    if (fileEntry1 != null)
                    {
                        string str1 = "";
                        for (int index = num; index < quoteSeperatedArgs.Length; ++index)
                        {
                            str1 = str1 + quoteSeperatedArgs[index] + " ";
                        }
                        FileEntry fileEntry2 = fileEntry1;
                        string    str2       = fileEntry2.data + "\n" + str1;
                        fileEntry2.data = str2;
                        flag1           = true;
                        strArray[0]     = "cat";
                        strArray[1]     = fileEntry1.name;
                        for (int index = 2; index < strArray.Length; ++index)
                        {
                            strArray[index] = "";
                        }
                        Programs.cat(strArray, os);
                    }
                }
                else
                {
                    os.write("Usage: append [FILENAME] [LINE TO APPEND]");
                    return(flag1);
                }
            }
            else if (strArray[0].Equals("remline"))
            {
                FileEntry fileEntry = Programs.getCurrentFolder(os).searchForFile(strArray[1]);
                if (fileEntry != null)
                {
                    int length = fileEntry.data.LastIndexOf('\n');
                    if (length < 0)
                    {
                        length = 0;
                    }
                    fileEntry.data = fileEntry.data.Substring(0, length);
                    flag1          = true;
                    strArray[0]    = "cat";
                    for (int index = 2; index < strArray.Length; ++index)
                    {
                        strArray[index] = "";
                    }
                    Programs.cat(strArray, os);
                }
            }
            else if (strArray[0].Equals("getString"))
            {
                Programs.getString(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("reloadtheme"))
            {
                FileEntry fileEntry = os.thisComputer.files.root.searchForFolder("sys").searchForFile("x-server.sys");
                if (fileEntry != null)
                {
                    OSTheme themeForDataString = ThemeManager.getThemeForDataString(fileEntry.data);
                    ThemeManager.switchTheme((object)os, themeForDataString);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("FirstTimeInitdswhupwnemfdsiuoewnmdsmffdjsklanfeebfjkalnbmsdakj"))
            {
                Programs.firstTimeInit(strArray, os, false);
                flag1 = false;
            }
            else if (strArray[0].Equals("chat"))
            {
                string message = "chat " + os.username + " ";
                for (int index = 1; index < strArray.Length; ++index)
                {
                    message = message + strArray[index] + " ";
                }
                if (os.multiplayer)
                {
                    os.sendMessage(message);
                }
                flag1 = false;
            }
            else if ((strArray[0].Equals("exitdemo") || strArray[0].Equals("resetdemo")) && Settings.isDemoMode)
            {
                MusicManager.transitionToSong("Music/Ambient/AmbientDrone_Clipped");
                MainMenu mainMenu = new MainMenu();
                os.ScreenManager.AddScreen((GameScreen)mainMenu);
                MainMenu.resetOS();
                os.ExitScreen();
                OS.currentInstance = (OS)null;
                flag1 = false;
                if (Settings.MultiLingualDemo)
                {
                    LocaleActivator.ActivateLocale("zh-cn", Game1.getSingleton().Content);
                }
            }
            else if (strArray[0].Equals("fh") && OS.DEBUG_COMMANDS)
            {
                Programs.fastHack(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("ra") && OS.DEBUG_COMMANDS)
            {
                Programs.revealAll(strArray, os);
                flag1 = false;
            }
            else if (strArray[0].Equals("deathseq") && OS.DEBUG_COMMANDS)
            {
                os.TraceDangerSequence.BeginTraceDangerSequence();
                flag1 = false;
            }
            else if (strArray[0].Equals("testcredits") && OS.DEBUG_COMMANDS)
            {
                os.endingSequence.IsActive = true;
                flag1 = false;
            }
            else if (strArray[0].Equals("addflag") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length < 2)
                {
                    os.write("\nFlag to add required\n");
                }
                os.Flags.AddFlag(strArray[1]);
                flag1 = false;
            }
            else if (strArray[0].Equals("addTestEmails") && OS.DEBUG_COMMANDS)
            {
                for (int index = 0; index < 4; ++index)
                {
                    ((MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(MailServer.generateEmail("testEmail " + (object)index + " " + Utils.getRandomByte().ToString(), "test", "test"), os.defaultUser.name);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("dscan") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length < 2)
                {
                    os.write("\nNode ID Required\n");
                }
                bool flag2 = false;
                for (int index = 0; index < os.netMap.nodes.Count; ++index)
                {
                    if (os.netMap.nodes[index].idName.ToLower().StartsWith(strArray[1].ToLower()))
                    {
                        os.netMap.discoverNode(os.netMap.nodes[index]);
                        os.netMap.nodes[index].highlightFlashTime = 1f;
                        flag2 = true;
                        break;
                    }
                }
                if (!flag2)
                {
                    os.write("Node ID Not found");
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("revmany") && OS.DEBUG_COMMANDS)
            {
                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.netMap.lastAddedNode = os.thisComputer;
                os.homeAssetServerID    = "dhsDrop";
                os.homeNodeID           = "dhs";
                os.netMap.discoverNode(Programs.getComputer(os, "dhs"));
                os.netMap.discoverNode(Programs.getComputer(os, "dhsDrop"));
                flag1 = false;
            }
            else if (strArray[0].ToLower().Equals("reloadext") && OS.DEBUG_COMMANDS)
            {
                if (Settings.IsInExtensionMode)
                {
                    ExtensionLoader.ReloadExtensionNodes((object)os);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("testsave") && OS.DEBUG_COMMANDS || strArray[0].Equals("save!(SJN!*SNL8vAewew57WewJdwl89(*4;;;&!)@&(ak'^&#@J3KH@!*"))
            {
                os.threadedSaveExecute(false);
                SettingsLoader.writeStatusFile();
                flag1 = false;
            }
            else if (strArray[0].Equals("testload") && OS.DEBUG_COMMANDS)
            {
                flag1 = false;
            }
            else if (strArray[0].Equals("teststrikerhack") && OS.DEBUG_COMMANDS)
            {
                os.delayer.Post(ActionDelayer.Wait(3.0), (Action)(() => MissionFunctions.runCommand(1, "triggerDLCHackRevenge")));
                flag1 = false;
            }
            else if (strArray[0].Equals("linkToCSECPostDLC") && OS.DEBUG_COMMANDS)
            {
                os.execute("dscan mainhub");
                os.allFactions.setCurrentFaction("hub", os);
                os.currentFaction.playerValue = 2;
                os.Flags.AddFlag("dlc_complete");
                os.Flags.AddFlag("dlc_csec_end_facval:0");
                MissionFunctions.runCommand(1, "addRank");
                flag1 = false;
            }
            else if (strArray[0].Equals("debug") && OS.DEBUG_COMMANDS)
            {
                int num = PortExploits.services.Count;
                if (strArray.Length > 1)
                {
                    try
                    {
                        num = Convert.ToInt32(strArray[1]);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                for (int index = 0; index < PortExploits.services.Count && index <= num; ++index)
                {
                    os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[PortExploits.portNums[index]], PortExploits.cracks[PortExploits.portNums[index]]));
                }
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[9], PortExploits.cracks[9]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[10], PortExploits.cracks[10]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[11], PortExploits.cracks[11]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[12], PortExploits.cracks[12]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[13], PortExploits.cracks[13]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[14], PortExploits.cracks[14]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[15], PortExploits.cracks[15]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[16], PortExploits.cracks[16]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[17], PortExploits.cracks[17]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[31], PortExploits.cracks[31]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[33], PortExploits.cracks[33]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[34], PortExploits.cracks[34]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[35], PortExploits.cracks[35]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[36], PortExploits.cracks[36]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[37], PortExploits.cracks[37]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[38], PortExploits.cracks[38]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[39], PortExploits.cracks[39]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[41], PortExploits.cracks[41]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[554], PortExploits.cracks[554]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.crackExeData[40], PortExploits.cracks[40]));
                os.thisComputer.files.root.folders[2].files.Add(new FileEntry(PortExploits.DangerousPacemakerFirmware, "KBT_TestFirmware.dll"));
                os.Flags.AddFlag("dechead");
                os.Flags.AddFlag("decypher");
                os.Flags.AddFlag("csecBitSet01Complete");
                os.Flags.AddFlag("csecRankingS2Pass");
                os.Flags.AddFlag("CSEC_Member");
                os.Flags.AddFlag("bitPathStarted");
                flag1 = false;
                for (int index = 0; index < 4; ++index)
                {
                    Computer c = new Computer("DebugShell" + (object)index, NetworkMap.generateRandomIP(), os.netMap.getRandomPosition(), 0, (byte)2, os);
                    c.adminIP = os.thisComputer.adminIP;
                    os.netMap.nodes.Add(c);
                    os.netMap.discoverNode(c);
                }
                os.netMap.discoverNode("practiceServer");
                os.netMap.discoverNode("entropy00");
            }
            else if (strArray[0].Equals("flash") && OS.DEBUG_COMMANDS)
            {
                os.traceTracker.start(40f);
                os.warningFlash();
                flag1 = false;
                os.IncConnectionOverlay.Activate();
            }
            else if (strArray[0].Equals("cycletheme") && OS.DEBUG_COMMANDS)
            {
                Action <OSTheme> ctheme = (Action <OSTheme>)(theme => ThemeManager.switchTheme((object)os, theme));
                int    next             = 1;
                double delay            = 1.2;
                Action cthemeAct        = (Action)(() =>
                {
                    ctheme((OSTheme)next);
                    next = (next + 1) % 7;
                });
                cthemeAct += (Action)(() => os.delayer.Post(ActionDelayer.Wait(delay), cthemeAct));
                cthemeAct();
            }
            else if (strArray[0].Equals("testdlc") && OS.DEBUG_COMMANDS)
            {
                MissionFunctions.runCommand(0, "demoFinalMissionEndDLC");
                flag1 = false;
            }
            else if (strArray[0].Equals("testircentries") && OS.DEBUG_COMMANDS)
            {
                DLCHubServer daemon = Programs.getComputer(os, "dhs").getDaemon(typeof(DLCHubServer)) as DLCHubServer;
                for (int index = 0; index < 100; ++index)
                {
                    daemon.IRCSystem.AddLog("Test", "Test Message\nMultiline\nMessage", (string)null);
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("testirc") && OS.DEBUG_COMMANDS)
            {
                DLCHubServer daemon = Programs.getComputer(os, "dhs").getDaemon(typeof(DLCHubServer)) as DLCHubServer;
                daemon.IRCSystem.AddLog("Test", "Test Message", (string)null);
                daemon.IRCSystem.AddLog("Channel", "Test Message\nfrom channel", (string)null);
                flag1 = false;
            }
            else if (strArray[0].Equals("flashtest") && OS.DEBUG_COMMANDS)
            {
                if (!PostProcessor.dangerModeEnabled)
                {
                    PostProcessor.dangerModeEnabled         = true;
                    PostProcessor.dangerModePercentComplete = 0.5f;
                }
                else
                {
                    PostProcessor.dangerModeEnabled         = false;
                    PostProcessor.dangerModePercentComplete = 0.0f;
                }
                flag1 = false;
            }
            else if (strArray[0].Equals("dectest") && OS.DEBUG_COMMANDS)
            {
                string str1 = "this is a test message for the encrypter";
                string str2 = FileEncrypter.EncryptString(str1, "header message", "1.2.3.4.5", "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongpass", (string)null);
                os.write(str1);
                os.write("  ");
                os.write("  ");
                os.write(str2);
                os.write("  ");
                os.write("  ");
                os.write(FileEncrypter.MakeReplacementsForDisplay(FileEncrypter.DecryptString(str2, "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongpass")[2]));
                os.write("  ");
                os.write(FileEncrypter.MakeReplacementsForDisplay(FileEncrypter.DecryptString(str2, "wrongPass")[2] == null ? "NULL" : "CORRECT"));
                os.write("  ");
            }
            else if (strArray[0].Equals("test") && OS.DEBUG_COMMANDS)
            {
                ((DLCHubServer)Programs.getComputer(os, "dhs").getDaemon(typeof(DLCHubServer))).AddMission((ActiveMission)ComputerLoader.readMission("Content/DLC/Missions/Attack/AttackMission.xml"), (string)null, false);
            }
            else if (strArray[0].Equals("testtrace") && OS.DEBUG_COMMANDS)
            {
                MissionFunctions.runCommand(1, "triggerDLCHackRevenge");
            }
            else if (strArray[0].Equals("testboot") && OS.DEBUG_COMMANDS)
            {
                os.BootAssitanceModule.IsActive = true;
                os.bootingUp     = false;
                os.canRunContent = false;
                MusicManager.stop();
            }
            else if (strArray[0].Equals("testhhbs") && OS.DEBUG_COMMANDS)
            {
                os.write(HostileHackerBreakinSequence.IsInBlockingHostileFileState((object)os) ? "BLOCKED" : "SAFE");
            }
            else if (strArray[0].Equals("printflags") && OS.DEBUG_COMMANDS)
            {
                os.write(os.Flags.GetSaveString());
            }
            else if (strArray[0].Equals("loseadmin") && OS.DEBUG_COMMANDS)
            {
                os.connectedComp.adminIP = os.connectedComp.ip;
                flag1 = false;
            }
            else if (strArray[0].Equals("runcmd") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length > 1)
                {
                    string name = strArray[1];
                    int    num  = 0;
                    if (strArray.Length > 2)
                    {
                        num = Convert.ToInt32(strArray[1]);
                    }
                    MissionFunctions.runCommand(num, name);
                }
            }
            else if (strArray[0].ToLower().Equals("runhackscript") && OS.DEBUG_COMMANDS)
            {
                if (strArray.Length > 1)
                {
                    string scriptName = strArray[1];
                    try
                    {
                        HackerScriptExecuter.runScript(scriptName, (object)os, os.thisComputer.ip, os.thisComputer.ip);
                    }
                    catch (Exception ex)
                    {
                        os.write("Error launching script " + scriptName);
                        os.write(Utils.GenerateReportFromExceptionCompact(ex));
                    }
                }
            }
            else if (strArray[0].Equals("MotIsTheBest") && OS.DEBUG_COMMANDS)
            {
                os.runCommand("probe");
                os.runCommand("exe WebServerWorm 80");
                os.runCommand("exe SSHcrack 22");
                os.runCommand("exe SMTPoverflow 25");
                os.runCommand("exe FTPBounce 21");
            }
            else if (strArray[0].Equals("help") || strArray[0].Equals("Help") || strArray[0].Equals("?") || strArray[0].Equals("man"))
            {
                int page = 0;
                if (strArray.Length > 1)
                {
                    try
                    {
                        page = Convert.ToInt32(strArray[1]);
                        if (page > Helpfile.getNumberOfPages())
                        {
                            os.write("Invalid Page Number - Displaying First Page");
                            page = 0;
                        }
                    }
                    catch (FormatException ex)
                    {
                        os.write("Invalid Page Number");
                    }
                    catch (OverflowException ex)
                    {
                        os.write("Invalid Page Number");
                    }
                }
                Helpfile.writeHelp(os, page);
                flag1 = false;
            }
            else
            {
                if (strArray[0] != "")
                {
                    int num = ProgramRunner.AttemptExeProgramExecution(os, strArray);
                    if (num == 0)
                    {
                        os.write("Execution failed");
                    }
                    else if (num < 0)
                    {
                        os.write("No Command " + strArray[0] + " - Check Syntax\n");
                    }
                }
                flag1 = false;
            }
            if (flag1)
            {
                if (!os.commandInvalid)
                {
                    os.display.command     = strArray[0];
                    os.display.commandArgs = strArray;
                    os.display.typeChanged();
                }
                else
                {
                    os.commandInvalid = false;
                }
            }
            return(flag1);
        }
Example #21
0
        public void doGui()
        {
            SpriteFont tinyfont           = GuiData.tinyfont;
            float      tinyFontCharHeight = GuiData.ActiveFontConfig.tinyFontCharHeight;
            int        num1 = -4;
            int        num2 = (int)((double)(this.bounds.Y + this.bounds.Height - 16) - (double)tinyFontCharHeight - (double)num1);
            int        x    = (int)tinyfont.MeasureString(this.prompt).X;

            if (this.bounds.Width > 0)
            {
                for (; x >= (int)((double)this.bounds.Width * 0.7); x = (int)tinyfont.MeasureString(this.prompt).X)
                {
                    this.prompt = this.prompt.Substring(1);
                }
            }
            this.spriteBatch.DrawString(tinyfont, this.prompt, new Vector2((float)(this.bounds.X + 3), (float)num2), this.currentTextColor);
            if (LocaleActivator.ActiveLocaleIsCJK())
            {
                num1 -= 4;
            }
            int y = num2 + num1;

            if (!this.os.inputEnabled || this.inputLocked)
            {
                return;
            }
            TextBox.LINE_HEIGHT = (int)((double)tinyFontCharHeight + 15.0);
            this.currentLine    = TextBox.doTerminalTextField(7001, this.bounds.X + 3 + (int)Terminal.PROMPT_OFFSET + (int)tinyfont.MeasureString(this.prompt).X, y, this.bounds.Width - x - 4, this.bounds.Height, 1, this.currentLine, tinyfont);
            if (TextBox.BoxWasActivated)
            {
                this.executeLine();
            }
            if (TextBox.UpWasPresed && this.runCommands.Count > 0)
            {
                ++this.commandHistoryOffset;
                if (this.commandHistoryOffset > this.runCommands.Count)
                {
                    this.commandHistoryOffset = this.runCommands.Count;
                }
                this.currentLine       = this.runCommands[this.runCommands.Count - this.commandHistoryOffset];
                TextBox.cursorPosition = this.currentLine.Length;
            }
            if (TextBox.DownWasPresed && this.commandHistoryOffset > 0)
            {
                --this.commandHistoryOffset;
                if (this.commandHistoryOffset < 0)
                {
                    this.commandHistoryOffset = 0;
                }
                this.currentLine       = this.commandHistoryOffset > 0 ? this.runCommands[this.runCommands.Count - this.commandHistoryOffset] : "";
                TextBox.cursorPosition = this.currentLine.Length;
            }
            if (TextBox.TabWasPresed)
            {
                if (this.usingTabExecution)
                {
                    this.executeLine();
                }
                else
                {
                    this.doTabComplete();
                }
            }
        }
Example #22
0
        public static void LoadNewExtensionSession(ExtensionInfo info, object os_obj)
        {
            LocaleActivator.ActivateLocale(info.Language, Game1.getSingleton().Content);
            OS os = (OS)os_obj;

            People.ReInitPeopleForExtension();
            if (Directory.Exists(info.FolderPath + "/Nodes"))
            {
                Utils.ActOnAllFilesRevursivley(info.FolderPath + "/Nodes", (Action <string>)(filename =>
                {
                    if (!filename.EndsWith(".xml"))
                    {
                        return;
                    }
                    if (OS.TestingPassOnly)
                    {
                        try
                        {
                            Computer c = Computer.loadFromFile(filename);
                            if (c != null)
                            {
                                ExtensionLoader.CheckAndAssignCoreServer(c, os);
                            }
                        }
                        catch (Exception ex)
                        {
                            string format       = "COMPUTER LOAD ERROR:\nError loading computer \"{0}\"";
                            Exception exception = ex;
                            string message      = string.Format(format, (object)filename);
                            for (; exception != null; exception = exception.InnerException)
                            {
                                string str = string.Format("\r\nError: {0} - {1}", (object)exception.GetType().Name, (object)exception.Message);
                                message   += str;
                            }
                            throw new FormatException(message, ex);
                        }
                    }
                    else
                    {
                        Computer c = Computer.loadFromFile(filename);
                        if (c != null)
                        {
                            ExtensionLoader.CheckAndAssignCoreServer(c, os);
                        }
                    }
                }));
            }
            if (ComputerLoader.postAllLoadedActions != null)
            {
                ComputerLoader.postAllLoadedActions();
            }
            if (Programs.getComputer(os, "jmail") == null)
            {
                Computer c = new Computer("JMail Email Server", NetworkMap.generateRandomIP(), new Vector2(0.8f, 0.2f), 6, (byte)1, os);
                c.idName = "jmail";
                c.daemons.Add((Daemon) new MailServer(c, "JMail", os));
                MailServer.shouldGenerateJunk = false;
                c.users.Add(new UserDetail(os.defaultUser.name, "mailpassword", (byte)2));
                c.initDaemons();
                os.netMap.mailServer = c;
                os.netMap.nodes.Add(c);
            }
            for (int index = 0; index < info.StartingVisibleNodes.Length; ++index)
            {
                Computer computer = Programs.getComputer(os, info.StartingVisibleNodes[index]);
                if (computer != null)
                {
                    os.netMap.discoverNode(computer);
                }
            }
            for (int index = 0; index < info.FactionDescriptorPaths.Count; ++index)
            {
                string path = info.FolderPath + "/" + info.FactionDescriptorPaths[index];
                using (FileStream fileStream = File.OpenRead(path))
                {
                    try
                    {
                        Faction faction = Faction.loadFromSave(XmlReader.Create((Stream)fileStream));
                        os.allFactions.factions.Add(faction.idName, faction);
                    }
                    catch (Exception ex)
                    {
                        throw new FormatException("Error loading Faction: " + path, ex);
                    }
                }
            }
            OSTheme theme = OSTheme.Custom;
            bool    flag  = false;

            foreach (object obj in Enum.GetValues(typeof(OSTheme)))
            {
                if (obj.ToString().ToLower() == info.Theme)
                {
                    theme = (OSTheme)obj;
                    flag  = true;
                }
            }
            if (!flag)
            {
                if (File.Exists(info.FolderPath + "/" + info.Theme))
                {
                    ThemeManager.setThemeOnComputer((object)os.thisComputer, info.Theme);
                    ThemeManager.switchTheme((object)os, info.Theme);
                }
            }
            else
            {
                ThemeManager.setThemeOnComputer((object)os.thisComputer, theme);
                ThemeManager.switchTheme((object)os, theme);
            }
            ExtensionLoader.LoadExtensionStartTrackAsCurrentSong(info);
            if (info.StartingActionsPath != null)
            {
                RunnableConditionalActions.LoadIntoOS(info.StartingActionsPath, (object)os);
            }
            if (info.StartingMissionPath == null || info.StartsWithTutorial || info.HasIntroStartup)
            {
                return;
            }
            ExtensionLoader.SendStartingEmailForActiveExtensionNextFrame((object)os);
        }