コード例 #1
0
ファイル: HubFaction.cs プロジェクト: hochladen/Hacknet
        private void SendNotification(object osIn, string contractName)
        {
            OS     os    = (OS)osIn;
            string email = MailServer.generateEmail(this.name + " " + LocaleTerms.Loc("Admins :: Flagged for Critical Contract"), string.Format(Utils.readEntireFile("Content/LocPost/CSEC_JunebugEmail.txt"), (object)this.name), this.name + " ReplyBot");

            ((MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(email, os.defaultUser.name);
        }
コード例 #2
0
        private static void DrawMain(DrawMainMenuEvent e)
        {
            Rectangle dest = new Rectangle(180, 120, 340, 100);

            ResetForLogin();
            SpriteFont titleFont  = (SpriteFont)e.MainMenu.GetType().GetField("titleFont", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(e.MainMenu);
            Color      titleColor = (Color)e.MainMenu.GetType().GetField("titleColor", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(e.MainMenu);

            Hacknet.Effects.FlickeringTextEffect.DrawLinedFlickeringText(dest, "HACK ON NET", 7f, 0.55f, titleFont, null, titleColor, 2);
            Hacknet.Gui.TextItem.doFontLabel(new Vector2(520f, 178f), "Hack On Net v0.1", GuiData.smallfont, new Color?(titleColor * 0.5f), 600f, 26f, false);

            logIn.Draw();

            if (Hacknet.Gui.Button.doButton(3, 180, 305, 450, 40, LocaleTerms.Loc("Settings"), Color.LightSkyBlue))
            {
                e.MainMenu.ScreenManager.AddScreen(new OptionsMenu(), new PlayerIndex?(e.MainMenu.ScreenManager.controllingPlayer));
            }

            if (Hacknet.Gui.Button.doButton(15, 180, 360, 450, 28, LocaleTerms.Loc("Back to Main Menu"), Color.Gray))
            {
                preset = RPHandler.State.OGMenu;
                RPCHandler.PresencePresetSet(preset);
                currentState = MenuState.OG_MENU;
            }
        }
コード例 #3
0
ファイル: IRCSystem.cs プロジェクト: hochladen/Hacknet
        private void DrawLog(Rectangle dest, SpriteBatch sb, Dictionary <string, Color> HighlightKeywords)
        {
            List <IRCSystem.IRCLogEntry> logsFromFile = this.GetLogsFromFile();
            int lineHeight     = (int)((double)GuiData.ActiveFontConfig.tinyFontCharHeight + 4.0);
            int num1           = 4;
            int linesRemaining = (int)((double)dest.Height / (double)lineHeight);
            int index          = logsFromFile.Count - 1;
            int num2           = 0;
            int y = dest.Y;

            this.DrawnButtonIndex = 1892;
            for (; linesRemaining > 0 && index >= 0 && dest.Height - num2 > lineHeight; --index)
            {
                bool needsNewMessagesLineDraw = this.messagesAddedSinceLastView > 0 && this.messagesAddedSinceLastView < logsFromFile.Count && logsFromFile.Count - index == this.messagesAddedSinceLastView;
                linesRemaining -= this.DrawLogEntry(logsFromFile[index], dest, sb, HighlightKeywords, lineHeight, linesRemaining, y, needsNewMessagesLineDraw, out dest);
                dest.Y         -= num1;
                num2           += num1;
            }
            if (index > -1 || linesRemaining <= 1)
            {
                return;
            }
            int        height    = lineHeight + 8;
            Rectangle  rectangle = new Rectangle(dest.X, dest.Y + dest.Height - height, dest.Width, height);
            SpriteFont tinyfont  = GuiData.tinyfont;
            string     text      = "--- " + LocaleTerms.Loc("Log Cleared by Administrator") + " ---";
            Vector2    vector2   = tinyfont.MeasureString(text);

            sb.DrawString(tinyfont, text, Utils.ClipVec2ForTextRendering(new Vector2((float)((double)rectangle.X + (double)rectangle.Width / 2.0 - (double)vector2.X / 2.0), (float)((double)rectangle.Y + (double)rectangle.Height / 2.0 - (double)vector2.Y / 2.0))), Color.Gray);
        }
コード例 #4
0
 public override void Draw(float t)
 {
     base.Draw(t);
     this.spriteBatch.Draw(Utils.white, this.infoBar, this.userScreen.indentBackgroundColor);
     this.infoBarUsedRam.Width = (int)((float)this.infoBar.Width * (1f - 800 - (OS.TOP_BAR_HEIGHT + 2) / (float)800 - (OS.TOP_BAR_HEIGHT + 2)));
     this.spriteBatch.Draw(Utils.white, this.infoBarUsedRam, RamModule.USED_RAM_COLOR);
     this.spriteBatch.DrawString(GuiData.detailfont, "hello", new Vector2((float)this.infoBar.X, (float)this.infoBar.Y), Color.White);
     if (this.OutOfMemoryFlashTime > 0f)
     {
         float scale        = System.Math.Min(1f, this.OutOfMemoryFlashTime);
         float amount       = System.Math.Max(0f, this.OutOfMemoryFlashTime - (RamModule.FLASH_TIME - 1f));
         Color patternColor = Color.Lerp(this.userScreen.lockedColor, Utils.AddativeRed, amount) * scale;
         PatternDrawer.draw(this.bounds, 0f, Color.Transparent, patternColor, this.spriteBatch, PatternDrawer.errorTile);
         int       num       = 40;
         Rectangle rectangle = new Rectangle(this.bounds.X, this.bounds.Y + this.bounds.Height - num - 1, this.bounds.Width, num);
         this.spriteBatch.Draw(Utils.white, Utils.InsetRectangle(rectangle, 4), Color.Black * 0.75f);
         rectangle.X--;
         string text = " ^ " + LocaleTerms.Loc("INSUFFICIENT MEMORY") + " ^ ";
         Hacknet.Gui.TextItem.doFontLabelToSize(rectangle, text, GuiData.font, Color.Black * scale, false, false);
         rectangle.X += 2;
         Hacknet.Gui.TextItem.doFontLabelToSize(rectangle, text, GuiData.font, Color.Black * scale, false, false);
         rectangle.X--;
         Hacknet.Gui.TextItem.doFontLabelToSize(rectangle, text, GuiData.font, Color.White * scale, false, false);
     }
 }
コード例 #5
0
        public static void RenderAltitudeIndicator(Rectangle dest, SpriteBatch sb, int currentAltitude, bool IsInCriticalDescenet, bool IconFlashIsVisible, int maxAltitude = 50000, int upperReccomended = 40000, int lowerReccomended = 30000, int warningArea = 14000, int criticalFailureArea = 3000)
        {
            if (AircraftAltitudeIndicator.WarningIcon == null)
            {
                AircraftAltitudeIndicator.Init(OS.currentInstance.content);
            }
            bool flag = currentAltitude <= 0;

            if (flag)
            {
                currentAltitude = maxAltitude;
            }
            int       width1 = Math.Min(dest.Width, 100);
            Rectangle destinationRectangle1 = new Rectangle(dest.X + dest.Width - width1, dest.Y, width1, dest.Height);
            int       width2    = 200;
            Rectangle dest1     = new Rectangle(dest.X + dest.Width - width2, destinationRectangle1.Y, width2, 21);
            Color     color     = IsInCriticalDescenet ? Utils.AddativeRed : OS.currentInstance.highlightColor;
            Rectangle rectangle = destinationRectangle1;

            rectangle.Width = width1 / 2;
            rectangle.X     = dest.X + dest.Width - rectangle.Width;
            sb.Draw(Utils.gradientLeftRight, rectangle, color * 0.2f);
            int heightForAltitude = AircraftAltitudeIndicator.GetHeightForAltitude(currentAltitude, maxAltitude, rectangle);

            destinationRectangle1.Y      += heightForAltitude;
            destinationRectangle1.Height -= heightForAltitude;
            sb.Draw(Utils.gradientLeftRight, destinationRectangle1, color);
            AircraftAltitudeIndicator.DrawIndicatorForAltitude(dest1, maxAltitude, LocaleTerms.Loc("Maximum Altitude"), maxAltitude, rectangle, sb, color, true, true);
            AircraftAltitudeIndicator.DrawIndicatorForAltitude(dest1, upperReccomended, LocaleTerms.Loc("Maximum Cruising Altitude"), maxAltitude, rectangle, sb, color, false, false);
            AircraftAltitudeIndicator.DrawIndicatorForAltitude(dest1, lowerReccomended, LocaleTerms.Loc("Minimum Cruising Altitude"), maxAltitude, rectangle, sb, color, false, false);
            AircraftAltitudeIndicator.DrawIndicatorForAltitude(dest1, warningArea, LocaleTerms.Loc("Unsafe Altitude Margin"), maxAltitude, rectangle, sb, color, false, false);
            dest1.Height *= 2;
            AircraftAltitudeIndicator.DrawIndicatorForAltitude(dest1, criticalFailureArea, LocaleTerms.Loc("Critical Failure Region") + "\n- " + LocaleTerms.Loc("POINT OF NO RETURN") + " -", maxAltitude, rectangle, sb, Utils.makeColorAddative(color), true, false);
            dest1 = new Rectangle(dest1.X - 20, dest1.Y, dest1.Width + 20, dest1.Height + 10);
            AircraftAltitudeIndicator.DrawIndicatorForAltitude(dest1, currentAltitude, flag ? LocaleTerms.Loc("CRITICAL ERROR") + "\n" + LocaleTerms.Loc("SIGNAL LOST") : LocaleTerms.Loc("Current Altitude") + "\n" + string.Format("{0}ft", (object)currentAltitude), maxAltitude, rectangle, sb, color, true, false);
            int       num  = dest1.Height - 4;
            Rectangle rect = new Rectangle(dest1.X - num - 4, dest1.Y + AircraftAltitudeIndicator.GetHeightForAltitude(currentAltitude, maxAltitude, rectangle), num, num);
            Rectangle destinationRectangle2 = new Rectangle(dest1.X - num - 4, rect.Y, num + 4, dest1.Height);

            if (currentAltitude < lowerReccomended)
            {
                PatternDrawer.draw(new Rectangle(destinationRectangle2.X, destinationRectangle2.Y, destinationRectangle2.Width + dest1.Width, destinationRectangle2.Height), 0.2f, Color.Transparent, Color.Red * 0.2f, sb);
            }
            sb.Draw(Utils.white, destinationRectangle2, Color.Black * 0.4f);
            destinationRectangle2.Height = 1;
            sb.Draw(Utils.white, destinationRectangle2, color);
            rect.Y += 2;
            rect.X += 2;
            Rectangle destinationRectangle3 = Utils.InsetRectangle(rect, 4);

            if (IsInCriticalDescenet)
            {
                sb.Draw(AircraftAltitudeIndicator.WarningIcon, destinationRectangle3, Color.Red * (IconFlashIsVisible ? 1f : 0.3f));
            }
            else
            {
                sb.Draw(AircraftAltitudeIndicator.PlaneIcon, destinationRectangle3, color);
            }
        }
コード例 #6
0
 private static void Advance(string answer)
 {
     ++promptIndex;
     Answers.Add(answer);
     if (true)
     {
         if (promptIndex == 1)
         {
             if (string.IsNullOrWhiteSpace(Answers[0]))
             {
                 History.Add(" -- " + LocaleTerms.Loc("Username cannot be blank. Try Again") + " -- ");
                 promptIndex = 0;
                 Answers.Clear();
             }
             else if (Utils.StringContainsInvalidFilenameChars(Answers[0]))
             {
                 History.Add(" -- " + LocaleTerms.Loc("Username contains invalid characters. Try Again") + " -- ");
                 promptIndex = 0;
                 Answers.Clear();
             }
         }
         if (promptIndex == 3)
         {
             if (string.IsNullOrWhiteSpace(answer))
             {
                 History.Add(" -- " + LocaleTerms.Loc("Password Cannot be Blank! Try Again") + " -- ");
                 promptIndex = 1;
                 string answer1 = Answers[0];
                 Answers.Clear();
                 Answers.Add(answer1);
             }
             else if (Answers[1] != answer)
             {
                 History.Add(" -- " + LocaleTerms.Loc("Password Mismatch! Try Again") + " -- ");
                 promptIndex = 1;
                 string answer1 = Answers[0];
                 Answers.Clear();
                 Answers.Add(answer1);
             }
         }
         InPasswordMode = promptIndex == 1 || promptIndex == 2;
     }
     if (promptIndex >= PromptSequence.Count)
     {
         if (true)
         {
             currentPrompt = LocaleTerms.Loc("READY - PRESS ENTER TO CONFIRM");
             IsReady       = true;
         }
     }
     else
     {
         currentPrompt = PromptSequence[promptIndex];
     }
 }
コード例 #7
0
        private void DrawWarningScreen()
        {
            if (this.warningScreenIsActivating)
            {
                this.spriteBatch.Draw(Utils.white, this.fullscreen, Color.White);
            }
            else
            {
                this.DrawFlashingRedBackground();
            }
            string  text      = "WARNING";
            Vector2 vector2_1 = this.titleFont.MeasureString(text);
            float   widthTo   = (float)this.fullscreen.Width * 0.65f;
            float   scale     = widthTo / vector2_1.X;
            Vector2 vector2_2 = new Vector2(20f, -10f);

            this.spriteBatch.DrawString(this.titleFont, text, vector2_2, Color.Black, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f);
            vector2_2.Y += (float)((double)vector2_1.Y * (double)scale - 55.0);
            TextItem.doFontLabel(vector2_2, LocaleTerms.Loc("COMPLETED TRACE DETECTED : EMERGENCY RECOVERY MODE ACTIVE"), Settings.ActiveLocale.StartsWith("en") ? this.titleFont : GuiData.font, new Color?(Color.Black), widthTo, float.MaxValue, false);
            vector2_2.Y += 40f;
            vector2_2    = this.DrawFlashInString(LocaleTerms.Loc("Unsyndicated foreign connection detected during active trace"), vector2_2, 0.0f, 0.2f, false, 0.2f);
            vector2_2    = this.DrawFlashInString(" :: " + LocaleTerms.Loc("Emergency recovery mode activated"), vector2_2, 0.1f, 0.2f, false, 0.2f);
            vector2_2    = this.DrawFlashInString("-----------------------------------------------------------------------", vector2_2, 0.2f, 0.2f, false, 0.2f);
            vector2_2    = this.DrawFlashInString(" ", vector2_2, 0.5f, 0.2f, false, 0.2f);
            vector2_2    = this.DrawFlashInString(LocaleTerms.Loc("Automated screening procedures will divert incoming connections temporarily"), vector2_2, 0.5f, 0.2f, false, 0.2f);
            vector2_2    = this.DrawFlashInString(LocaleTerms.Loc("This window is a final opportunity to regain anonymity."), vector2_2, 0.6f, 0.2f, false, 0.2f);
            vector2_2    = this.DrawFlashInString(LocaleTerms.Loc("As your current IP Address is known, it must be changed") + " -", vector2_2, 0.7f, 0.2f, false, 0.2f);
            vector2_2    = this.DrawFlashInString(LocaleTerms.Loc("This can only be done on your currently active ISP's routing server"), vector2_2, 0.8f, 0.2f, false, 0.2f);
            Computer computer = Programs.getComputer(this.os, "ispComp");

            vector2_2 = this.DrawFlashInString(string.Format(LocaleTerms.Loc("Reverse tracerouting has located this ISP server's IP address as {0}"), computer != null ? (object)computer.ip : (object)"68.144.93.18"), vector2_2, 0.9f, 0.2f, false, 0.2f);
            vector2_2 = this.DrawFlashInString(string.Format(LocaleTerms.Loc("Your local ip : {0}  must be tracked here and changed."), (object)this.os.thisComputer.ip), vector2_2, 1f, 0.2f, false, 0.2f);
            vector2_2 = this.DrawFlashInString(" ", vector2_2, 1.1f, 0.2f, false, 0.2f);
            vector2_2 = this.DrawFlashInString(LocaleTerms.Loc("Failure to complete this while active diversion holds will result in complete"), vector2_2, 1.1f, 0.2f, false, 0.2f);
            vector2_2 = this.DrawFlashInString(LocaleTerms.Loc("and permanent loss of all account data - THIS IS NOT REPEATABLE AND CANNOT BE DELAYED"), vector2_2, 1.2f, 0.2f, false, 0.2f);
            if (this.warningScreenIsActivating || ((double)this.timeThisState < 1.20000004768372 || !Button.doButton(789798001, 20, (int)((double)vector2_2.Y + 10.0), 400, 40, LocaleTerms.Loc("BEGIN"), new Color?(Color.Black))))
            {
                return;
            }
            this.timeThisState             = 0.0f;
            this.state                     = TraceDangerSequence.TraceDangerState.WarningScreenExiting;
            this.PreventOSRendering        = true;
            this.onBeatFlashTimer          = this.os.timer;
            this.warningScreenIsActivating = true;
            this.spinUpSound.Play(1f, 0.0f, 0.0f);
            this.os.terminal.inputLocked = false;
            this.os.delayer.Post(ActionDelayer.Wait(0.1), (Action)(() => this.spinUpSound.Play(1f, 0.0f, 0.0f)));
            this.os.delayer.Post(ActionDelayer.Wait(0.4), (Action)(() => this.spinUpSound.Play(0.4f, 0.0f, 0.0f)));
            this.os.delayer.Post(ActionDelayer.Wait(0.8), (Action)(() => this.spinUpSound.Play(0.2f, 0.1f, 0.0f)));
            this.os.delayer.Post(ActionDelayer.Wait(1.3), (Action)(() => this.spinUpSound.Play(0.1f, 0.2f, 0.0f)));
            this.os.delayer.Post(ActionDelayer.Wait(0.01), (Action)(() => MusicManager.playSongImmediatley("Music/Traced")));
        }
コード例 #8
0
        private void doConnectDisplay()
        {
            this.doConnectHeader();

            int num  = 0 + 6;
            int num2 = 40;
            int num3 = this.bounds.Height - (this.y - this.bounds.Y) - 20;

            num3 -= num * 5;
            if ((double)num3 / (double)num < (double)num2)
            {
                num2 = (int)((double)num3 / (double)num);
            }

            for (int i = 0; i < userScreen.activeSession.daemonButtons.Count; i++)
            {
                var daemonButton = userScreen.activeSession.daemonButtons[i];
                if (Hacknet.Gui.Button.doButton(29000 + i, this.x, this.y, 300, num2, daemonButton.Display, this.userScreen.highlightColor))
                {
                    this.userScreen.Execute(daemonButton.Command);
                }
                this.y += num2 + 5;
            }
            if (Hacknet.Gui.Button.doButton(300000, this.x, this.y, 300, num2, LocaleTerms.Loc("Login"), this.userScreen.highlightColor))
            {
                this.userScreen.Execute("login");
            }
            this.y += num2 + 5;

            /*if (Hacknet.Gui.Button.doButton(300002, this.x, this.y, 300, num2, LocaleTerms.Loc("Probe System"), new Color?(this.userScreen.highlightColor)))
             * {
             *  this.userScreen.Execute("probe");
             * }
             * this.y += num2 + 5;*/
            if (Hacknet.Gui.Button.doButton(300003, this.x, this.y, 300, num2, LocaleTerms.Loc("View Filesystem"), this.userScreen.highlightColor))
            {
                this.userScreen.Execute("ls");
            }
            this.y += num2 + 5;

            /*if (Hacknet.Gui.Button.doButton(300009, this.x, this.y, 300, num2, LocaleTerms.Loc("Scan Network"), this.userScreen.highlightColor))
             * {
             *  this.userScreen.Execute("scan");
             * }*/
            this.y = this.bounds.Y + this.bounds.Height - 30;
            if (Hacknet.Gui.Button.doButton(300012, this.x, this.y, 300, 20, LocaleTerms.Loc("Disconnect"), this.userScreen.lockedColor))
            {
                this.userScreen.Execute("dc");
                return;
            }
        }
コード例 #9
0
 public void ResetForLogin()
 {
     this.promptIndex = 0;
     this.IsReady     = false;
     this.PromptSequence.Clear();
     this.PromptSequence.Add(LocaleTerms.Loc("USERNAME") + " :");
     this.PromptSequence.Add(LocaleTerms.Loc("PASSWORD") + " :");
     this.History.Clear();
     this.History.Add("-- Login --");
     this.currentPrompt     = this.PromptSequence[this.promptIndex];
     this.IsNewAccountMode  = false;
     this.terminalString    = "";
     TextBox.cursorPosition = 0;
 }
コード例 #10
0
ファイル: HubFaction.cs プロジェクト: hochladen/Hacknet
        private void SendAssetAddedNotification(object osIn)
        {
            OS       os       = (OS)osIn;
            string   subject  = this.name + " " + LocaleTerms.Loc("Admins :: New asset added");
            string   body     = string.Format(Utils.readEntireFile("Content/LocPost/CSEC_ThemechangerEmail.txt"), (object)this.name);
            string   sender   = this.name + " ReplyBot";
            Computer computer = Programs.getComputer(os, "mainHubAssets");
            string   str      = "link#%#" + computer.name + "#%#" + computer.ip;
            string   email    = MailServer.generateEmail(subject, body, sender, new List <string>((IEnumerable <string>) new string[1] {
                str
            }));

            ((MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer))).addMail(email, os.defaultUser.name);
        }
コード例 #11
0
        private void doEmptyModule()
        {
            this.spriteBatch.Draw(Utils.white, this.bounds, this.userScreen.displayModuleExtraLayerBackingColor);
            var tmpRect = new Rectangle();

            tmpRect.X      = this.bounds.X + 2;
            tmpRect.Width  = this.bounds.Width - 4;
            tmpRect.Y      = this.bounds.Y + this.bounds.Height / 6 * 2;
            tmpRect.Height = this.bounds.Height / 3;
            this.spriteBatch.Draw(Utils.white, tmpRect, userScreen.indentBackgroundColor);
            Vector2 vector   = GuiData.font.MeasureString(LocaleTerms.Loc("No Active Session"));
            Vector2 position = new Vector2((float)(tmpRect.X + this.bounds.Width / 2) - vector.X / 2f, (float)(this.bounds.Y + this.bounds.Height / 2 - 10));

            this.spriteBatch.DrawString(GuiData.font, LocaleTerms.Loc("No Active Session"), position, userScreen.subtleTextColor);
        }
コード例 #12
0
 public void ResetForNewAccount()
 {
     this.promptIndex = 0;
     this.IsReady     = false;
     this.PromptSequence.Clear();
     this.PromptSequence.Add(LocaleTerms.Loc("USERNAME") + " :");
     this.PromptSequence.Add(LocaleTerms.Loc("PASSWORD") + " :");
     this.PromptSequence.Add(LocaleTerms.Loc("CONFIRM PASS") + " :");
     this.History.Clear();
     this.History.Add("-- " + LocaleTerms.Loc("New " + this.ProjectName + " User Registration") + " --");
     this.currentPrompt     = this.PromptSequence[this.promptIndex];
     this.IsNewAccountMode  = true;
     this.terminalString    = "";
     TextBox.cursorPosition = 0;
 }
コード例 #13
0
ファイル: MainMenu.cs プロジェクト: AwesomeSmilee/Hack-On-Net
 public static void ResetForLogin()
 {
     promptIndex = 0;
     IsReady     = false;
     PromptSequence.Clear();
     PromptSequence.Add(LocaleTerms.Loc("USERNAME") + " :");
     PromptSequence.Add(LocaleTerms.Loc("PASSWORD") + " :");
     History.Clear();
     History.Add("-- " + LocaleTerms.Loc("HackOnNet Login") + " --");
     currentPrompt    = PromptSequence[promptIndex];
     IsLoginMode      = true;
     PreventAdvancing = false;
     terminalString   = "";
     Hacknet.Gui.TextBox.cursorPosition = 0;
 }
コード例 #14
0
        private void DrawDisconnectedScreen()
        {
            this.spriteBatch.Draw(Utils.white, this.fullscreen, Color.Black);
            Rectangle destinationRectangle = new Rectangle();

            destinationRectangle.X      = this.fullscreen.X + 2;
            destinationRectangle.Width  = this.fullscreen.Width - 4;
            destinationRectangle.Y      = this.fullscreen.Y + this.fullscreen.Height / 6 * 2;
            destinationRectangle.Height = this.fullscreen.Height / 3;
            this.spriteBatch.Draw(Utils.white, destinationRectangle, this.os.indentBackgroundColor);
            Vector2 vector2  = GuiData.titlefont.MeasureString("DISCONNECTED");
            Vector2 position = new Vector2((float)(destinationRectangle.X + this.fullscreen.Width / 2) - vector2.X / 2f, (float)(this.fullscreen.Y + this.fullscreen.Height / 2 - 50));

            this.spriteBatch.DrawString(GuiData.titlefont, "DISCONNECTED", position, this.os.subtleTextColor);
            this.DrawFlashInString(LocaleTerms.Loc("Rebooting"), this.DrawFlashInString(LocaleTerms.Loc("Preparing for system reboot"), this.DrawFlashInString(LocaleTerms.Loc("Foreign trace averted"), this.DrawFlashInString(LocaleTerms.Loc("IP Address successfully reset"), new Vector2(200f, (float)(destinationRectangle.Y + destinationRectangle.Height + 20)), 4f, 0.2f, true, 0.2f), 5f, 0.2f, true, 0.2f), 6f, 0.2f, true, 0.8f), 9f, 0.2f, true, 0.2f);
        }
コード例 #15
0
ファイル: HubFaction.cs プロジェクト: hochladen/Hacknet
 public void ForceStartBitMissions(object os)
 {
     ((OS)os).Flags.AddFlag("bitPathStarted");
     ((OS)os).delayer.Post(ActionDelayer.Wait(1.6), (Action)(() => ComputerLoader.loadMission("Content/Missions/BitPath/BitAdv_Intro.xml", false)));
     Programs.getComputer((OS)os, "mainHubAssets").files.root.searchForFolder("bin").folders.Add(new Folder("Misc")
     {
         files =
         {
             new FileEntry(PortExploits.crackExeData[9],                           "Decypher.exe"),
             new FileEntry(PortExploits.crackExeData[10],                          "DECHead.exe"),
             new FileEntry(PortExploits.crackExeData[104],                         "KBT_PortTest.exe"),
             new FileEntry("Kellis BioTech medical port cycler - target 104-103.", "kbt_readme.txt")
         }
     });
     this.SendNotification(os, LocaleTerms.Loc("Agent") + ",\n" + LocaleTerms.Loc("Additional resources have been added to the CSEC members asset pool, for your free use.") + " " + LocaleTerms.Loc("Find them in the misc folder on the asset server.") + "\n\n" + LocaleTerms.Loc("Thankyou") + ",\n -" + this.name, this.name + " " + LocaleTerms.Loc("Admins :: Asset Uploads"));
 }
コード例 #16
0
 /// <summary>
 /// Retrieves the localized formatted (based on the extra arguments) string of the input along.
 /// </summary>
 /// <returns>The localized formatted string of the input, otherwise defaulting to LocaleTerms.Loc.</returns>
 /// <param name="input">The input string to search in the locale for.</param>
 /// <param name="extraArgs">Any extra formatting arguments.</param>
 public static string Get(string input, params object[] extraArgs)
 {
     if (StoredLocale.ContainsKey(input))
     {
         var result = StoredLocale[input];
         if (extraArgs != null && extraArgs.Length > 0)
         {
             try
             {
                 return(string.Format(result, extraArgs));
             }
             catch (FormatException) {}
         }
         return(result);
     }
     return(LocaleTerms.Loc(input));
 }
コード例 #17
0
 private Vector2 DrawExtensionList(Vector2 drawpos, Rectangle dest, SpriteBatch sb)
 {
     if (this.HasLoaded)
     {
         Rectangle fullscreen = Utils.GetFullscreen();
         for (int scrollStartIndex = this.ScrollStartIndex; scrollStartIndex <= this.Extensions.Count; ++scrollStartIndex)
         {
             if ((double)drawpos.Y + 120.0 + 20.0 >= (double)fullscreen.Height || this.ScrollStartIndex > 0 && scrollStartIndex == this.Extensions.Count)
             {
                 int height = 20;
                 int num    = (50 - height * 2) / 4;
                 if (Button.doButton(790001 + scrollStartIndex, (int)drawpos.X, (int)drawpos.Y + num, 450, height, "   ^   ", new Color?(this.ScrollStartIndex > 0 ? MainMenu.buttonColor : Color.Black)) && this.ScrollStartIndex > 0)
                 {
                     --this.ScrollStartIndex;
                 }
                 bool flag = scrollStartIndex <= this.Extensions.Count - 1;
                 if (Button.doButton(790101 + scrollStartIndex + 1, (int)drawpos.X, (int)drawpos.Y + height + num + num + 2, 450, height, "   v   ", new Color?(flag ? MainMenu.buttonColor : Color.Black)) && flag)
                 {
                     ++this.ScrollStartIndex;
                 }
                 drawpos.Y += 55f;
                 break;
             }
             if (scrollStartIndex < this.Extensions.Count)
             {
                 ExtensionInfo extension = this.Extensions[scrollStartIndex];
                 if (Button.doButton(780001 + scrollStartIndex, (int)drawpos.X, (int)drawpos.Y, 450, 50, extension.Name, new Color?(Color.White)))
                 {
                     this.ActivateExtensionPage(extension);
                 }
                 drawpos.Y += 55f;
             }
         }
     }
     else
     {
         TextItem.doFontLabel(drawpos, LocaleTerms.Loc("Loading..."), GuiData.font, new Color?(Color.White), (float)dest.Width, 20f, false);
         drawpos.Y += 55f;
     }
     if (!string.IsNullOrWhiteSpace(this.LoadErrors))
     {
         TextItem.doFontLabel(drawpos + new Vector2(0.0f, 30f), this.LoadErrors, GuiData.smallfont, new Color?(Color.Red), float.MaxValue, float.MaxValue, false);
     }
     return(drawpos);
 }
コード例 #18
0
 public static void OverridePortHack(ExecutablePortExecuteEvent e)
 {
     if (e[0].ToLower() == "porthack")
     {
         e.IsCancelled = true;
         var  os             = e.OS;
         var  cComp          = os.connectedComp;
         bool canRun         = false;
         bool firewallActive = false;
         if (cComp != null)
         {
             int num2 = 0;
             for (int i = 0; i < cComp.portsOpen.Count; i++)
             {
                 num2 += os.connectedComp.portsOpen[i];
             }
             foreach (var p in cComp.GetModdedPortList())
             {
                 num2 += p.Unlocked ? 1 : 0;
             }
             canRun |= num2 > cComp.portsNeededForCrack;
             if (cComp.firewall != null && !cComp.firewall.solved)
             {
                 firewallActive |= canRun;
                 canRun          = false;
             }
         }
         if (canRun)
         {
             os.addExe(new PortHackExe(e.Destination, os));
         }
         else if (firewallActive)
         {
             os.WriteLine("{0} -\n{1}",
                          LocaleTerms.Loc("Target Machine Rejecting Syndicated UDP Traffic"),
                          LocaleTerms.Loc("Bypass Firewall to allow unrestricted traffic"));
         }
         else
         {
             os.WriteLine("{0} - \n{1}\n",
                          LocaleTerms.Loc("Too Few Open Ports to Run"),
                          LocaleTerms.Loc("Open Additional Ports on Target Machine"));
         }
     }
 }
コード例 #19
0
 private void AddExtensionSafe(string folderpath)
 {
     if (!ExtensionInfo.ExtensionExists(folderpath))
     {
         return;
     }
     try
     {
         this.Extensions.Add(ExtensionInfo.ReadExtensionInfo(folderpath));
     }
     catch (Exception ex)
     {
         Console.WriteLine(Utils.GenerateReportFromException(ex));
         ExtensionsMenuScreen extensionsMenuScreen = this;
         string str = extensionsMenuScreen.LoadErrors + LocaleTerms.Loc("Error loading ExtensionInfo for") + " " + folderpath + "\n" + LocaleTerms.Loc("Error details written to") + " " + folderpath.Replace("\\", "/") + "/error_report.txt\n\n";
         extensionsMenuScreen.LoadErrors = str;
         Utils.writeToFile("Error loading ExtensionInfo for extension in folder:\n" + folderpath + "\nError details: \n" + Utils.GenerateReportFromException(ex), folderpath + "/error_report.txt");
     }
 }
コード例 #20
0
        private static void AddGameExecutable(this OS os, GameExecutable exe, Rectangle location, string[] args)
        {
            exe.Assign(location, os, args);
            var computer = os.connectedComp ?? os.thisComputer;

            try
            {
                if (exe.needsProxyAccess && computer.proxyActive)
                {
                    exe.OnProxyBypassFailure();
                    if (!exe.IgnoreProxyFailPrint)
                    {
                        os.write(LocaleTerms.Loc("Proxy Active -- Cannot Execute"));
                    }
                    return;
                }

                if (os.ramAvaliable >= exe.ramCost)
                {
                    exe.OnInitialize();
                    if (exe.CanAddToSystem)
                    {
                        os.exes.Add(exe);
                    }
                    return;
                }

                exe.OnNoAvailableRam();
                if (!exe.IgnoreMemoryBehaviorPrint)
                {
                    os.ram.FlashMemoryWarning();
                    os.write(LocaleTerms.Loc("Insufficient Memory"));
                }
            }
            catch (Exception e)
            {
                if (exe.CatchException(e))
                {
                    throw e;
                }
            }
        }
コード例 #21
0
        public static void DrawCountdownOverlay(SpriteFont titleFont, SpriteFont bodyFont, object osobj, string title = null, string l1 = null, string l2 = null, string l3 = null)
        {
            OS os = (OS)osobj;

            if (title == null)
            {
                title = "EMERGENCY TRACE AVERSION SEQUENCE";
            }
            if (l1 == null)
            {
                l1 = LocaleTerms.Loc("Reset Assigned Ip Address on ISP Mainframe");
            }
            Computer computer = Programs.getComputer(os, "ispComp");

            if (l2 == null)
            {
                l2 = string.Format(LocaleTerms.Loc("ISP Mainframe IP: {0}"), computer != null ? (object)computer.ip : (object)"68.144.93.18");
            }
            if (l3 == null)
            {
                l3 = string.Format(LocaleTerms.Loc("YOUR Assigned IP: {0}"), (object)os.thisComputer.ip);
            }
            Rectangle fullscreen           = Utils.GetFullscreen();
            int       height               = 110;
            Rectangle destinationRectangle = new Rectangle(0, fullscreen.Height - height - 20, 520, height);

            GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, Color.Lerp(TraceDangerSequence.DarkRed, Color.Transparent, Utils.randm(0.2f)));
            Vector2 pos = new Vector2((float)(destinationRectangle.X + 6), (float)(destinationRectangle.Y + 4));

            TextItem.doFontLabel(pos, title, titleFont, new Color?(Color.White), (float)(destinationRectangle.Width - 12), 35f, false);
            pos.Y += 32f;
            TextItem.doFontLabel(pos, l1, bodyFont, new Color?(Color.White), (float)(destinationRectangle.Width - 10), 20f, false);
            pos.Y += 16f;
            TextItem.doFontLabel(pos, l2, bodyFont, new Color?(Color.White), (float)(destinationRectangle.Width - 10), 20f, false);
            pos.Y += 16f;
            TextItem.doFontLabel(pos, l3, bodyFont, new Color?(Color.White), (float)(destinationRectangle.Width - 10), 20f, false);
        }
コード例 #22
0
        public void DrawUI(Rectangle dest, OS os)
        {
            int ButtonHeight = (int)((double)GuiData.ActiveFontConfig.tinyFontCharHeight + 10.0);

            if (this.panel.PanelHeight != ButtonHeight + 4)
            {
                this.panel = new ScrollableSectionedPanel(ButtonHeight + 4, GuiData.spriteBatch.GraphicsDevice);
            }
            List <DisplayModuleLSHelper.LSItem> items = this.BuildDirectoryDrawList(os.connectedComp == null ? os.thisComputer.files.root : os.connectedComp.files.root, 0, 0, os);

            this.panel.NumberOfPanels = items.Count;
            int width = dest.Width - 25;
            Action <int, Rectangle, SpriteBatch> DrawSection = (Action <int, Rectangle, SpriteBatch>)((index, bounds, sb) =>
            {
                DisplayModuleLSHelper.LSItem lsItem = items[index];
                if (lsItem.IsEmtyDisplay)
                {
                    TextItem.doFontLabel(new Vector2((float)(bounds.X + 5 + lsItem.indent), (float)(bounds.Y + 2)), "-" + LocaleTerms.Loc("Empty") + "-", GuiData.tinyfont, new Color?(), (float)width, (float)ButtonHeight, false);
                }
                else if (Button.doButton(300000 + index, bounds.X + 5 + lsItem.indent, bounds.Y + 2, width - lsItem.indent, ButtonHeight, lsItem.DisplayName, new Color?()))
                {
                    lsItem.Clicked();
                }
            });

            Button.DisableIfAnotherIsActive = true;
            this.panel.Draw(DrawSection, GuiData.spriteBatch, dest);
            Button.DisableIfAnotherIsActive = false;
        }
コード例 #23
0
        private static void DrawLogin(DrawMainMenuEvent e)
        {
            RequestGoBack += (Action)(() => ChangeState(MenuState.MAIN_MENU));
            Rectangle  dest      = new Rectangle(bMenu.ScreenManager.GraphicsDevice.Viewport.Width / 4, bMenu.ScreenManager.GraphicsDevice.Viewport.Height / 4, bMenu.ScreenManager.GraphicsDevice.Viewport.Width / 2, bMenu.ScreenManager.GraphicsDevice.Viewport.Height / 4);
            SpriteFont smallfont = GuiData.smallfont;
            int        y1        = dest.Y + dest.Height + 12;
            int        y2        = y1 + 10;
            int        num1      = (int)((double)smallfont.MeasureString(currentPrompt).X + 4.0);
            int        num2      = dest.Y + dest.Height - 18;
            int        num3      = y2 - 60;
            float      num4      = GuiData.ActiveFontConfig.tinyFontCharHeight + 8f;
            Vector2    position  = new Vector2((float)dest.X, false ? (float)y2 : (float)(dest.Y + dest.Height - 20) - num4);

            GuiData.spriteBatch.Draw(Utils.white, new Rectangle(dest.X, y1, dest.Width / 2, 1), Utils.SlightlyDarkGray);
            GuiData.spriteBatch.DrawString(GuiData.UISmallfont, loginMessage, new Vector2(position.X, position.Y + 125), MainMenu.CancelColor);
            GuiData.spriteBatch.DrawString(smallfont, currentPrompt, new Vector2((float)dest.X, (float)num2), Color.White);

            if (IsReady)
            {
                if (!GuiData.getKeyboadState().IsKeyDown(Keys.Enter))
                {
                    CanReturnEnter = true;
                }
                if ((!HasOverlayScreen && (!IsLoginMode || Hacknet.Gui.Button.doButton(16392804, dest.X, y2, dest.Width / 3, 28, LocaleTerms.Loc("CONFIRM"), new Color?(Color.White))) || CanReturnEnter && Utils.keyPressed(GuiData.lastInput, Keys.Enter, new PlayerIndex?())) && !PreventAdvancing)
                {
                    if (IsLoginMode)
                    {
                        if (Answers.Count < 2)
                        {
                            ResetForLogin();
                        }
                        else
                        {
                            string username = Answers[Answers.Count - 2];
                            string password = Answers[Answers.Count - 1];
                            Hacknet.Gui.TextBox.MaskingText = false;
                            StartGame(username, password);
                        }
                    }
                    else
                    {
                        Hacknet.Gui.TextBox.MaskingText = false;
                        Console.Write("An Error has occured! Fixing now");
                        History.Clear();
                        currentPrompt = "";
                        ResetForLogin();
                        IsLoginMode = true;
                    }
                    PreventAdvancing = true;
                }
                y2 += 36;
            }
            else
            {
                Hacknet.Gui.TextBox.MaskingText = InPasswordMode;
                terminalString = Hacknet.Gui.TextBox.doTerminalTextField(16392802, dest.X + num1, num2 - 2, dest.Width, 20, 1, terminalString, GuiData.UISmallfont);
            }

            if (!HasOverlayScreen && Hacknet.Gui.TextBox.BoxWasActivated)
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(currentPrompt);
                stringBuilder.Append(" ");
                string str1 = terminalString;
                if (InPasswordMode)
                {
                    string str2 = "";
                    for (int index = 0; index < str1.Length; ++index)
                    {
                        str2 += "*";
                    }
                    str1 = str2;
                }
                stringBuilder.Append(str1);
                History.Add(stringBuilder.ToString());
                Advance(terminalString);
                terminalString = "";
                Hacknet.Gui.TextBox.cursorPosition  = 0;
                Hacknet.Gui.TextBox.BoxWasActivated = false;
            }
            if (!HasOverlayScreen && Hacknet.Gui.Button.doButton(16392806, dest.X, y2, dest.Width / 3, 22, LocaleTerms.Loc("CANCEL"), new Color?(CancelColor)) && RequestGoBack != null)
            {
                InPasswordMode = false;
                Hacknet.Gui.TextBox.MaskingText = false;
                RequestGoBack();
            }

            for (int index = History.Count - 1; index >= 0; --index)
            {
                GuiData.spriteBatch.DrawString(GuiData.UISmallfont, History[index], position, Color.White);
                position.Y -= num4 * (1f);
            }
        }
コード例 #24
0
        public static bool onDrawMainMenuTitles(MainMenu self, out bool result, ref Rectangle dest)
        {
            if (defaultTitleFont == null)
            {
                defaultTitleFont = self.ScreenManager.Game.Content.Load <SpriteFont>("Kremlin");
            }
            Logger.Verbose("Redrawing Main Menu Titles");
            var version   = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            var mainTitle = "HACKNET";
            var subtitle  = "OS"
                            + (DLC1SessionUpgrader.HasDLC1Installed ? "+Labyrinths " : " ")
                            + MainMenu.OSVersion + " Pathfinder " + version;

            result = true;
            if (Settings.IsExpireLocked)
            {
                TimeSpan timeSpan = Settings.ExpireTime - DateTime.Now;
                string   text3;
                if (timeSpan.TotalSeconds < 1.0)
                {
                    text3  = LocaleTerms.Loc("TEST BUILD EXPIRED - EXECUTION DISABLED");
                    result = false;
                }
                else
                {
                    text3 = "Test Build : Expires in " + timeSpan.ToString();
                }
                TextItem.doFontLabel(new Vector2(180f, 105f), text3, GuiData.smallfont, Color.Red * 0.8f, 600f, 26f, false);
            }
            var main = new MainTitleData(mainTitle,
                                         defaultTitleColor,
                                         defaultTitleFont,
                                         dest
                                         );
            var sub = new SubTitleData(subtitle,
                                       main.Color * 0.5f,
                                       GuiData.smallfont,
                                       new Vector4(520, 178, 0, 0)
                                       );
            var drawMainMenuTitles = new Event.DrawMainMenuTitlesEvent(self, main, sub);

            drawMainMenuTitles.CallEvent();
            if (drawMainMenuTitles.IsCancelled)
            {
                return(true);
            }
            main = drawMainMenuTitles.Main;
            sub  = drawMainMenuTitles.Sub;
            FlickeringTextEffect.DrawLinedFlickeringText(
                dest = main.Destination,
                main.Title,
                7f,
                0.55f,
                main.Font,
                null,
                main.Color
                );
            TextItem.doFontLabel(sub.Destination, sub.Title, sub.Font, sub.Color, 600f, 26f);
            Logger.Verbose("Finished Redrawing Main Menu Titles");
            return(true);
        }
コード例 #25
0
        public static bool onOSDraw(OS self, ref GameTime time)
        {
            var osStartDrawEvent = new Event.OSStartDrawEvent(self, time);

            Event.OSEndDrawEvent osEndDrawEvent = null;
            try
            {
                if (self.lastGameTime == null)
                {
                    self.lastGameTime = time;
                }
                switch (osStartDrawEvent.DrawType)
                {
                case Event.OSDrawEvent.Type.Standard:
                    PostProcessor.begin();
                    GuiData.startDraw();
                    osStartDrawEvent.CallEvent();
                    if (osStartDrawEvent.IsCancelled)
                    {
                        break;
                    }
                    try
                    {
                        if (!self.TraceDangerSequence.PreventOSRendering)
                        {
                            self.drawBackground();
                            if (self.terminalOnlyMode)
                            {
                                self.terminal.Draw((float)time.ElapsedGameTime.TotalSeconds);
                            }
                            else
                            {
                                self.drawModules(time);
                            }
                            SFX.Draw(GuiData.spriteBatch);
                        }
                        if (self.TraceDangerSequence.IsActive)
                        {
                            self.TraceDangerSequence.Draw();
                        }
                    }
                    catch (Exception ex)
                    {
                        self.drawErrorCount++;
                        if (self.drawErrorCount < 5)
                        {
                            Utils.AppendToErrorFile(Utils.GenerateReportFromException(ex) + "\r\n\r\n");
                        }
                    }
                    break;

                case Event.OSDrawEvent.Type.BootingSequence:
                    osStartDrawEvent.IgnoreScanlines = true;
                    goto case Event.OSDrawEvent.Type.EndingSequence;

                case Event.OSDrawEvent.Type.BootAssistance:
                case Event.OSDrawEvent.Type.EndingSequence:
                    PostProcessor.begin();
                    osStartDrawEvent.CallEvent();
                    if (osStartDrawEvent.IsCancelled)
                    {
                        break;
                    }
                    self.ScreenManager.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
                    switch (osStartDrawEvent.DrawType)
                    {
                    case Event.OSDrawEvent.Type.BootAssistance:
                        self.BootAssitanceModule.Draw((float)time.ElapsedGameTime.TotalSeconds);
                        break;

                    case Event.OSDrawEvent.Type.BootingSequence:
                        if (self.thisComputer.disabled)
                        {
                            self.RequestRemovalOfAllPopups();
                            if (self.TraceDangerSequence.IsActive)
                            {
                                self.TraceDangerSequence.CancelTraceDangerSequence();
                            }
                            self.crashModule.Draw((float)time.ElapsedGameTime.TotalSeconds);
                        }
                        else
                        {
                            self.introTextModule.Draw((float)time.ElapsedGameTime.TotalSeconds);
                        }
                        break;

                    case Event.OSDrawEvent.Type.EndingSequence:
                        self.endingSequence.Draw((float)time.ElapsedGameTime.TotalSeconds);
                        break;
                    }
                    if (!osStartDrawEvent.IgnoreScanlines)
                    {
                        self.drawScanlines();
                    }
                    break;

                case Event.OSDrawEvent.Type.Loading:
                    GuiData.startDraw();
                    osStartDrawEvent.CallEvent();
                    if (osStartDrawEvent.IsCancelled)
                    {
                        break;
                    }
                    TextItem.doSmallLabel(new Vector2(0f, 700f), LocaleTerms.Loc("Loading..."), null);
                    break;

                case Event.OSDrawEvent.Type.Custom:
                    osStartDrawEvent.CallEvent();
                    if (osStartDrawEvent.IsCancelled)
                    {
                        return(true);
                    }
                    break;
                }
                osEndDrawEvent = new Event.OSEndDrawEvent(self, time, osStartDrawEvent.DrawType);
                switch (osEndDrawEvent.DrawType)
                {
                case Event.OSDrawEvent.Type.Standard:
                    GuiData.endDraw();
                    PostProcessor.end();
                    if (!osStartDrawEvent.IgnorePostFXDraw)
                    {
                        GuiData.startDraw();
                        if (self.postFXDrawActions != null)
                        {
                            self.postFXDrawActions.Invoke();
                            self.postFXDrawActions = null;
                        }
                        if (!osStartDrawEvent.IgnoreScanlines)
                        {
                            self.drawScanlines();
                        }
                        GuiData.endDraw();
                    }
                    break;

                case Event.OSDrawEvent.Type.BootAssistance:
                case Event.OSDrawEvent.Type.BootingSequence:
                case Event.OSDrawEvent.Type.EndingSequence:
                    self.ScreenManager.SpriteBatch.End();
                    PostProcessor.end();
                    break;

                case Event.OSDrawEvent.Type.Loading:
                    GuiData.endDraw();
                    break;

                default:
                    osEndDrawEvent.CallEvent();
                    break;
                }
            }
            catch (Exception ex)
            {
                osEndDrawEvent = new Event.OSEndDrawEvent(self, time, Event.OSDrawEvent.Type.Error);
                osEndDrawEvent.CallEvent();
                if (osEndDrawEvent.IsCancelled)
                {
                    return(true);
                }
                self.drawErrorCount++;
                if (self.drawErrorCount >= 3)
                {
                    self.handleDrawError();
                }
                else
                {
                    Utils.AppendToErrorFile(Utils.GenerateReportFromException(ex));
                }
            }
            return(true);
        }
コード例 #26
0
        public static string DrawGetStringControl(string prompt, Rectangle bounds, Action errorOccurs, Action cancelled, SpriteBatch sb, object os_obj, Color SearchButtonColor, Color CancelButtonColor, string upperPrompt = null, Color?BackingPanelColor = null)
        {
            OS os = (OS)os_obj;

            upperPrompt = upperPrompt == null ? prompt : upperPrompt;
            string  str  = "";
            int     x    = bounds.X + 6;
            int     y1   = bounds.Y + 2;
            Vector2 zero = Vector2.Zero;

            if (upperPrompt.Length > 0)
            {
                Vector2 vector2 = TextItem.doMeasuredSmallLabel(new Vector2((float)x, (float)y1), upperPrompt, new Color?());
                y1 += (int)vector2.Y + 10;
            }
            string[] separator = new string[1] {
                "#$#$#$$#$&$#$#$#$#"
            };
            string[] strArray = os.getStringCache.Split(separator, StringSplitOptions.None);
            if (strArray.Length > 1)
            {
                str = strArray[1];
                if (str.Equals(""))
                {
                    str = os.terminal.currentLine;
                }
            }
            Rectangle destinationRectangle = new Rectangle(x, y1, bounds.Width - 12, bounds.Height - 46);

            sb.Draw(Utils.white, destinationRectangle, BackingPanelColor.HasValue ? BackingPanelColor.Value : os.darkBackgroundColor);
            int     num              = y1 + 18;
            string  bracketedBit     = "";
            string  bracketedSection = Utils.ExtractBracketedSection(prompt, out bracketedBit);
            Vector2 vector2_1        = TextItem.doMeasuredSmallLabel(new Vector2((float)x, (float)num), bracketedSection + str, new Color?());

            TextItem.doSmallLabel(new Vector2((float)x, (float)((double)num + (double)vector2_1.Y + 2.0)), bracketedBit, new Color?());
            destinationRectangle.X      = x + (int)vector2_1.X + 2;
            destinationRectangle.Y      = num;
            destinationRectangle.Width  = 7;
            destinationRectangle.Height = 20;
            if ((double)os.timer % 1.0 < 0.300000011920929)
            {
                sb.Draw(Utils.white, destinationRectangle, os.outlineColor);
            }
            int y2 = num + (bounds.Height - 44);

            if (strArray.Length > 2 || Button.doButton(30, x, y2, 300, 22, LocaleTerms.Loc("Search"), new Color?(SearchButtonColor)))
            {
                if (strArray.Length <= 2)
                {
                    os.terminal.executeLine();
                }
                if (str.Length > 0)
                {
                    return(str);
                }
                errorOccurs();
                return((string)null);
            }
            if (Button.doButton(38, x, y2 + 24, 300, 22, LocaleTerms.Loc("Cancel"), new Color?(CancelButtonColor)))
            {
                cancelled();
                os.terminal.clearCurrentLine();
                os.terminal.executeLine();
            }
            return((string)null);
        }
コード例 #27
0
 public static void OverrideFirstTimeInit(CommandSentEvent e)
 {
     if (Extension.Handler.ActiveInfo != null &&
         e[0] == "FirstTimeInitdswhupwnemfdsiuoewnmdsmffdjsklanfeebfjkalnbmsdakj")
     {
         var os    = e.OS;
         var num   = Settings.isConventionDemo ? 80 : 200;
         var num2  = Settings.isConventionDemo ? 150 : 300;
         var doTut = e[1] == "StartTutorial";
         if (doTut)
         {
             os.display.visible    = false;
             os.ram.visible        = false;
             os.netMap.visible     = false;
             os.terminal.visible   = true;
             os.mailicon.isEnabled = false;
             if (os.hubServerAlertsIcon != null)
             {
                 os.hubServerAlertsIcon.IsEnabled = false;
             }
         }
         if (Settings.debugCommandsEnabled && GuiData.getKeyboadState().IsKeyDown(Keys.LeftAlt))
         {
             num2 = (num = 1);
         }
         Programs.typeOut("Initializing .", os, 50);
         Programs.doDots(7, num + 100, os);
         Programs.typeOut("Loading modules.", os, 50);
         Programs.doDots(5, num, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         Programs.typeOut("Loading nodes.", os, 50);
         Programs.doDots(5, num, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         Programs.typeOut("Reticulating splines.", os, 50);
         Programs.doDots(5, num - 50, os);
         os.writeSingle("Complete");
         Utility.HaltThread(num2);
         if (os.crashModule.BootLoadErrors.Length > 0)
         {
             Programs.typeOut("\n------ " + LocaleTerms.Loc("BOOT ERRORS DETECTED") + " ------", os, 50);
             Utility.HaltThread(200);
             var array = os.crashModule.BootLoadErrors.Split(Utils.newlineDelim, StringSplitOptions.RemoveEmptyEntries);
             for (int i = 0; i < array.Length; i++)
             {
                 Programs.typeOut(array[i], os, 50);
                 Utility.HaltThread(100, true);
             }
             Programs.typeOut("---------------------------------\n", os, 50);
             Utility.HaltThread(200, true);
         }
         Programs.typeOut("\n--Initialization Complete--\n", os, 50);
         GuiData.getFilteredKeys();
         os.inputEnabled = true;
         Utility.HaltThread(num2 + 100);
         if (!doTut)
         {
             Programs.typeOut(LocaleTerms.Loc("For A Command List, type \"help\""), os, 50);
             Utility.HaltThread(num2 + 100);
         }
         os.write("");
         Utility.HaltThread(num2);
         os.write("");
         Utility.HaltThread(num2);
         os.write("");
         Utility.HaltThread(num2);
         os.write("\n");
         if (doTut)
         {
             os.write(LocaleTerms.Loc("Launching Tutorial..."));
             os.launchExecutable("Tutorial.exe", PortExploits.crackExeData[1], -1, null, null);
             Settings.initShowsTutorial = false;
             AdvancedTutorial advancedTutorial = null;
             for (int i = 0; i < os.exes.Count; i++)
             {
                 advancedTutorial = (os.exes[i] as AdvancedTutorial);
                 if (advancedTutorial != null)
                 {
                     break;
                 }
             }
             if (advancedTutorial != null)
             {
                 advancedTutorial.CanActivateFirstStep = false;
             }
             int num3 = 100;
             for (int i = 0; i < num3; i++)
             {
                 double num4 = (double)i / num3;
                 if (Utils.random.NextDouble() < num4)
                 {
                     os.ram.visible      = true;
                     os.netMap.visible   = false;
                     os.terminal.visible = false;
                 }
                 else
                 {
                     os.ram.visible      = false;
                     os.netMap.visible   = false;
                     os.terminal.visible = true;
                 }
                 Utility.HaltThread(16, true);
             }
             os.ram.visible      = true;
             os.netMap.visible   = false;
             os.terminal.visible = false;
             if (advancedTutorial != null)
             {
                 advancedTutorial.CanActivateFirstStep = true;
             }
         }
         else
         {
             os.runCommand("connect " + os.thisComputer.ip);
             if (doTut && !OS.WillLoadSave && !os.Flags.HasFlag("ExtensionFirstBootComplete"))
             {
                 ExtensionLoader.SendStartingEmailForActiveExtensionNextFrame(os);
                 float num5 = 2.2f;
                 var   num3 = (int)(60f * num5);
                 for (int i = 0; i < num3; i++)
                 {
                     double num4 = (double)i / num3;
                     os.ram.visible     = (Utils.random.NextDouble() < num4);
                     os.netMap.visible  = (Utils.random.NextDouble() < num4);
                     os.display.visible = (Utils.random.NextDouble() < num4);
                     Utility.HaltThread(16, true);
                 }
                 os.terminal.visible    = true;
                 os.display.visible     = true;
                 os.netMap.visible      = true;
                 os.ram.visible         = true;
                 os.terminal.visible    = true;
                 os.display.inputLocked = false;
                 os.netMap.inputLocked  = false;
                 os.ram.inputLocked     = false;
                 os.Flags.AddFlag("ExtensionFirstBootComplete");
             }
         }
         Utility.HaltThread(500, true);
         if (wasRecursed)
         {
             os.ram.visible         = true;
             os.ram.inputLocked     = false;
             os.display.visible     = true;
             os.display.inputLocked = false;
             os.netMap.visible      = true;
             os.netMap.inputLocked  = false;
         }
         else if (doTut)
         {
             os.ram.visible         = true;
             os.ram.inputLocked     = false;
             os.display.visible     = true;
             os.display.inputLocked = false;
             os.netMap.visible      = true;
             os.netMap.inputLocked  = false;
         }
         else if (!os.ram.visible)
         {
             wasRecursed = true;
             OverrideFirstTimeInit(e);
         }
     }
 }
コード例 #28
0
        public void drawModules(GameTime gameTime)
        {
            Vector2 zero = Vector2.Zero;

            GuiData.spriteBatch.Draw(Utils.white, this.topBar, this.topBarColor);
            float t = (float)gameTime.ElapsedGameTime.TotalSeconds;

            try
            {
                Vector2 vector = GuiData.UITinyfont.MeasureString("Location: " + (activeSession == null ? "Not Connected" : activeSession.ip));
                zero.X  = (float)this.topBar.Width - vector.X /* - (float)this.mailicon.getWidth()*/;
                zero.Y -= 3f;
                GuiData.spriteBatch.DrawString(GuiData.UITinyfont, "Location: " + (activeSession == null ? "Not Connected" : activeSession.ip), zero, this.topBarTextColor);
                if (GuiData.ActiveFontConfig.tinyFontCharHeight * 2f <= (float)this.topBar.Height)
                {
                    string text = LocaleTerms.Loc("Home IP:") + " " + homeIP + " ";
                    zero.Y += (float)(this.topBar.Height / 2);
                    vector  = GuiData.UITinyfont.MeasureString(text);
                    zero.X  = (float)this.topBar.Width - vector.X /* - (float)this.mailicon.getWidth()*/;
                    GuiData.spriteBatch.DrawString(GuiData.UITinyfont, text, zero, this.topBarTextColor);
                }
                zero.Y = 0f;
            }
            catch (System.Exception)
            {
            }
            zero.X = 110f;
            if (Hacknet.Gui.Button.doButton(3827178, 3, 0, 20, this.topBar.Height - 1, "", new Color?(this.topBarIconsColor), this.cross))
            {
                this.ExitToMenuMessageBox = new MessageBoxScreen("Logout of your\nCurrent Session?" + "\n", false, true);
                this.ExitToMenuMessageBox.OverrideAcceptedText = LocaleTerms.Loc("Exit to Menu");
                this.ExitToMenuMessageBox.Accepted            += new System.EventHandler <PlayerIndexEventArgs>(this.quitGame);
                base.ScreenManager.AddScreen(this.ExitToMenuMessageBox);
            }
            else
            {
                zero.X = 2f;
            }
            zero.Y = 1f;
            string text2 = string.Concat((int)(1.0 / gameTime.ElapsedGameTime.TotalSeconds + 0.5));

            GuiData.spriteBatch.DrawString(GuiData.UITinyfont, text2, zero, this.topBarTextColor);
            zero.Y = 0f;

            //this.mailicon.Draw();

            /*int num = this.ram.bounds.Height + this.topBar.Height + 16;
             * if (num < this.fullscreen.Height && this.ram.visible)
             * {
             *  this.audioVisualizer.Draw(new Rectangle(this.ram.bounds.X, num + 1, this.ram.bounds.Width - 2, this.fullscreen.Height - num - 4), GuiData.spriteBatch);
             * }*/
            for (int i = 0; i < this.modules.Count; i++)
            {
                try
                {
                    if (this.modules[i].visible)
                    {
                        this.modules[i].PreDrawStep();
                        this.modules[i].Draw(t);
                        this.modules[i].PostDrawStep();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            /*if (this.ram.visible)
             * {
             *  for (int i = 0; i < this.exes.Count; i++)
             *  {
             *      this.exes[i].Draw(t);
             *  }
             * }*/
            //this.IncConnectionOverlay.Draw(this.fullscreen, GuiData.spriteBatch);
            //this.traceTracker.Draw(GuiData.spriteBatch);
        }
コード例 #29
0
        private void doIRCModule()
        {
            var       sb   = spriteBatch;
            Rectangle dest = Utils.InsetRectangle(bounds, 2);
            Rectangle destinationRectangle = new Rectangle(dest.X, dest.Y - 1, 18, dest.Height + 2);

            sb.Draw(Utils.white, destinationRectangle, userScreen.moduleColorSolid);
            destinationRectangle.X     += destinationRectangle.Width / 2;
            destinationRectangle.Width /= 2;
            sb.Draw(Utils.white, destinationRectangle, Color.Black * 0.2f);
            dest.X     += 20;
            dest.Width -= 25;
            Rectangle rectangle = new Rectangle(dest.X + 4, dest.Y, dest.Width, 35);

            Hacknet.Gui.TextItem.doFontLabelToSize(rectangle, "Interweb Remote Com", GuiData.font, Color.White, true, true);
            int num  = dest.Width / 4;
            int num2 = 22;

            if (Hacknet.Gui.Button.doButton(37849102, rectangle.X + rectangle.Width - 6 - num, rectangle.Y + rectangle.Height - rectangle.Height / 2 - num2 / 2, num, num2, LocaleTerms.Loc("Exit IRC"), userScreen.moduleColorSolid))
            {
                this.userScreen.Execute("daemon exit");
                this.state = DisplayState.SSH_SESSION;
            }
            rectangle.Y     += rectangle.Height;
            rectangle.X     -= 6;
            dest.Y          += rectangle.Height;
            dest.Height     -= rectangle.Height;
            rectangle.Height = 2;
            sb.Draw(Utils.white, rectangle, userScreen.moduleColorSolid);
            dest.Y      += rectangle.Height + 2;
            dest.Height -= rectangle.Height + 2;
            dest.Height -= 6;
            PatternDrawer.draw(dest, 0.22f, Color.Black * 0.5f, /*flag ?*/ (userScreen.moduleColorSolid * 0.12f) /*: (Utils.AddativeRed * 0.2f)*/, sb, /*flag ? */ PatternDrawer.thinStripe /*: PatternDrawer.warningStripe*/);
            dest.X      += 2;
            dest.Width  -= 4;
            dest.Height -= 4;
            //if (flag)
            //{
            var messages = ((IrcState)userScreen.activeSession.GetState()).GetMessages();

            int _num  = (int)(GuiData.ActiveFontConfig.tinyFontCharHeight + 4f);
            int _num2 = 4;
            int _num3 = (int)((float)dest.Height / (float)_num);
            int _num4 = _num3;
            int _num5 = messages.Count - 1;
            int _num6 = 0;
            int y     = dest.Y;

            while (_num4 > 0 && _num5 >= 0 && dest.Height - _num6 > _num)
            {
                //bool needsNewMessagesLineDraw = this.messagesAddedSinceLastView > 0 && this.messagesAddedSinceLastView < logsFromFile.Count && logsFromFile.Count - num5 == this.messagesAddedSinceLastView;
                _num4  -= this.DrawIRCMessage(messages[_num5], dest, _num, _num4, y /*, needsNewMessagesLineDraw,*/, out dest);
                dest.Y -= _num2;
                _num6  += _num2;
                _num5--;
            }
            if (_num5 <= -1 && _num4 > 1)
            {
                int        _num7      = _num + 8;
                Rectangle  _rectangle = new Rectangle(dest.X, dest.Y + dest.Height - _num7, dest.Width, _num7);
                SpriteFont tinyfont   = GuiData.tinyfont;
                //string text = "--- " + LocaleTerms.Loc("Log Cleared by Administrator") + " ---";
                //Vector2 vector = tinyfont.MeasureString(text);
                //sb.DrawString(tinyfont, text, Utils.ClipVec2ForTextRendering(new Vector2((float)rectangle.X + (float)rectangle.Width / 2f - vector.X / 2f, (float)rectangle.Y + (float)rectangle.Height / 2f - vector.Y / 2f)), Color.Gray);
            }
            //}

            /*else
             * {
             *  int num3 = dest.Height / 4;
             *  Rectangle rectangle2 = new Rectangle(dest.X - 4, dest.Y + dest.Height / 2 - num3 / 2, dest.Width + 6, num3);
             *  sb.Draw(Utils.white, rectangle2, this.userScreen.lockedColor);
             *  rectangle2.Height -= 35;
             *  Hacknet.Gui.TextItem.doCenteredFontLabel(rectangle2, LocaleTerms.Loc("Login To Server"), GuiData.font, Color.White, false);
             *  if (Hacknet.Gui.Button.doButton(84109551, rectangle2.X + rectangle2.Width / 2 - rectangle2.Width / 4, rectangle2.Y + rectangle2.Height - 32, rectangle2.Width / 2, 28, "Login", null))
             *  {
             *      this.userScreen.Execute("login");
             *  }
             * //}*/
        }
コード例 #30
0
        private void doLSModule()
        {
            this.x = 5;
            this.y = 5;
            int    num  = this.bounds.Width - 25;
            string text = this.userScreen.activeSession.serverName + " " + LocaleTerms.Loc("File System");

            Hacknet.Gui.TextItem.doFontLabel(new Vector2((float)(this.bounds.X + this.x), (float)(this.bounds.Y + this.y)), text, GuiData.font, new Color?(Color.White), (float)this.bounds.Width - 46f, 60f, false);
            if (Hacknet.Gui.Button.doButton(299999, this.bounds.X + (this.bounds.Width - 41), this.bounds.Y + 12, 27, 29, "<-", null))
            {
                Console.WriteLine(this.userScreen.activeSession.workingPath);
                if (this.userScreen.activeSession.workingPath != "/" && this.userScreen.activeSession.workingPath != "")
                {
                    this.userScreen.Execute("cd ..");
                    this.userScreen.Execute("ls");
                }
                else
                {
                    this.state = DisplayState.SSH_SESSION;
                }
            }
            this.y += 50;
            Rectangle dest = GuiData.tmpRect;

            dest.Width  = this.bounds.Width;
            dest.X      = this.bounds.X;
            dest.Y      = this.bounds.Y + 55;
            dest.Height = this.bounds.Height - 57;

            Hacknet.Gui.TextItem.doFontLabel(new Vector2(dest.X, dest.Y), "Working Directory : " + (userScreen.activeSession.workingPath == "" ? "/" : userScreen.activeSession.workingPath), GuiData.smallfont, new Color?(Color.White), (float)this.bounds.Width - 46f, 60f, false);

            int ButtonHeight = (int)(GuiData.ActiveFontConfig.tinyFontCharHeight + 10f);

            dest.Y += 25;

            int width        = dest.Width - 25;
            var sessionState = (LsState)userScreen.activeSession.GetState();

            for (int i = 0; i < sessionState.files.Count; i++)
            {
                if (sessionState.files[i].GetDisplayName() == "" || sessionState.files[i] == null)
                {
                    continue;
                }

                var activeFile = sessionState.files[i];

                //spriteBatch.Draw(Utils.white, new Rectangle((int)bounds.X+6, (int)dest.Y + 3 + (ButtonHeight + 5) * i, 5, (int)ButtonHeight), activeFile.hasWritePermission ? Color.White : Color.Black);
                if (Hacknet.Gui.Button.doButton(300000 + i, bounds.X + 5 + 5, dest.Y + 2 + (ButtonHeight + 5) * i, width - 5, ButtonHeight, activeFile.GetDisplayName(), null))
                {
                    if (activeFile.IsFolder())
                    {
                        this.userScreen.Execute("cd " + activeFile.GetActualName());
                        this.userScreen.Execute("ls");
                    }
                    else
                    {
                        this.userScreen.Execute("view " + activeFile.GetActualName());
                    }
                }
            }
            ;
            //Hacknet.Gui.Button.DisableIfAnotherIsActive = true;
            //Hacknet.Gui.Button.DisableIfAnotherIsActive = false;
        }