コード例 #1
0
ファイル: TutorialExe.cs プロジェクト: hochladen/Hacknet
 public void getRenderText()
 {
     char[] chArray = new char[1] {
         '\n'
     };
     this.renderText = DisplayModule.cleanSplitForWidth(TutorialExe.feedbackSequence[this.state], 200).Split(chArray);
 }
コード例 #2
0
        public static string cleanSplitForWidth(string s, int width)
        {
            int num1 = 10;

            width /= num1;
            string str = "";

            char[] chArray = new char[1] {
                ' '
            };
            string[] strArray = s.Split(chArray);
            int      index1   = 0;

            if (strArray.Length == 1)
            {
                return(DisplayModule.splitForWidth(strArray[0], width * 8, true));
            }
            while (index1 < strArray.Length)
            {
                for (int index2 = 0; index2 < width && index1 < strArray.Length; ++index1)
                {
                    str     = str + strArray[index1] + " ";
                    index2 += strArray[index1].Length;
                    int num2 = strArray[index1].IndexOf('\n');
                    if (num2 >= 0)
                    {
                        index2 = strArray[index1].Length - (num2 + 1);
                    }
                }
                str += (string)(object)'\n';
            }
            return(str);
        }
コード例 #3
0
        public void getRenderText()
        {
            var chArray = new char[1]
            {
                '\n'
            };

            renderText = DisplayModule.cleanSplitForWidth(feedbackSequence[state], 200).Split(chArray);
        }
コード例 #4
0
ファイル: MissionHubServer.cs プロジェクト: hochladen/Hacknet
        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);
            }
        }
コード例 #5
0
        private void doContractPreviewScreen(Rectangle bounds, SpriteBatch sb)
        {
            var stringForContractFile = getIDStringForContractFile(listingsFolder.files[selectedElementIndex]);

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

            TextItem.doFontLabel(vector2 + new Vector2(getTransitionOffset(0), 0.0f),
                                 "CONTRACT:" + stringForContractFile, GuiData.titlefont, new Color?(), bounds.Width / 2, 40f);
            vector2.Y += 40f;
            TextItem.doFontLabel(vector2 + new Vector2(getTransitionOffset(1), 0.0f), mission.postingTitle, GuiData.font,
                                 new Color?(), bounds.Width - 30, float.MaxValue);
            vector2.Y += 30f;
            var text = DisplayModule.cleanSplitForWidth(mission.postingBody, bounds.Width - 110);

            TextItem.doFontLabel(vector2 + new Vector2(getTransitionOffset(2), 0.0f), text, GuiData.smallfont,
                                 new Color?(), bounds.Width - 20, float.MaxValue);
            var num = Math.Max(135, bounds.Height / 6);

            if (Button.doButton(2171618, bounds.X + 20 + getTransitionOffset(3), bounds.Y + bounds.Height - num,
                                bounds.Width / 5, 30, "Back", new Color?()))
            {
                state            = HubState.Listing;
                screenTransition = 1f;
            }
            if (os.currentMission == null)
            {
                if (
                    !Button.doButton(2171615, bounds.X + 20 + getTransitionOffset(4),
                                     bounds.Y + bounds.Height - num - 40, bounds.Width / 5, 30, "Accept", os.highlightColor))
                {
                    return;
                }
                acceptMission(mission, selectedElementIndex, stringForContractFile);
                state            = HubState.Listing;
                screenTransition = 1f;
            }
            else
            {
                TextItem.doFontLabelToSize(
                    new Rectangle(bounds.X + 20 + getTransitionOffset(4), bounds.Y + bounds.Height - num - 40,
                                  bounds.Width / 2, 30), "Abort current contract to accept new ones.", GuiData.smallfont,
                    Color.White);
            }
        }
コード例 #6
0
        public void getRenderText()
        {
            string data = AdvancedTutorial.feedbackSequence[this.state];

            char[] chArray = new char[1] {
                '\n'
            };
            string[] strArray = data.Split(this.hintButtonDelimiter, StringSplitOptions.RemoveEmptyEntries);
            if (strArray.Length > 1)
            {
                this.hintButtonText = DisplayModule.cleanSplitForWidth(strArray[1], 178).Split(chArray);
                data = strArray[0];
                this.hintTextFadeTimer = 0.0f;
            }
            else
            {
                this.hintButtonText = (string[])null;
            }
            this.renderText = Utils.SuperSmartTwimForWidth(LocalizedFileLoader.SafeFilterString(data), this.bounds.Width - 10, GuiData.tinyfont).Split(chArray);
        }
コード例 #7
0
        public void getRenderText()
        {
            var data    = feedbackSequence[state];
            var chArray = new char[1]
            {
                '\n'
            };
            var strArray = data.Split(hintButtonDelimiter, StringSplitOptions.RemoveEmptyEntries);

            if (strArray.Length > 1)
            {
                hintButtonText    = DisplayModule.cleanSplitForWidth(strArray[1], 178).Split(chArray);
                data              = strArray[0];
                hintTextFadeTimer = 0.0f;
            }
            else
            {
                hintButtonText = null;
            }
            renderText = Utils.SuperSmartTwimForWidth(data, bounds.Width - 10, GuiData.tinyfont).Split(chArray);
        }
コード例 #8
0
 public void doGui()
 {
     PatternDrawer.draw(new Rectangle(180, 160, 500, 85), 1f, darkgrey, dark_ish_gray, GuiData.spriteBatch);
     TextItem.doSmallLabel(new Vector2(200f, 170f), "IP To Connect to:", new Color?());
     destination = TextBox.doTextBox(100, 200, 200, 300, 1, destination, GuiData.smallfont);
     if (Button.doButton(123, 510, 201, 120, 23, "Connect", new Color?()) || TextBox.BoxWasActivated)
     {
         ConnectToServer(destination);
     }
     else
     {
         if (isConnecting)
         {
             drawConnectingGui();
         }
         TextItem.doLabel(new Vector2(200f, 300f), "Local IPs: " + myIP, new Color?());
         var y = 340f;
         for (var index = 0; index < allLocalIPs.Count - 1; ++index)
         {
             TextItem.doLabel(new Vector2(351f, y), allLocalIPs[index], new Color?());
             y += 40f;
         }
         TextItem.doLabel(new Vector2(200f, y + 40f), "Extrn IP: " + externalIP, new Color?());
         var pos = new Vector2(610f, 280f);
         TextItem.doLabel(pos, "Info:", new Color?());
         pos.Y += 40f;
         var text =
             DisplayModule.cleanSplitForWidth(
                 "To Begin a multiplayer session, type in the IP of the computer you want to connect to and press enter or connect. Both players must be on this screen. To connect over the internet, use the extern IP address and ensure port 3030 is open.",
                 400);
         TextItem.doFontLabel(pos, text, GuiData.tinyfont, Color.DarkGray, float.MaxValue, float.MaxValue);
         if (!Button.doButton(999, 10, 10, 200, 30, "<- Back to Menu", Color.Gray))
         {
             return;
         }
         ExitScreen();
         ScreenManager.AddScreen(new MainMenu(), ScreenManager.controllingPlayer);
     }
 }
コード例 #9
0
 public static void parseInputMessage(string message, OS os)
 {
     if (message.Equals(""))
     {
         return;
     }
     string[] strArray1 = message.Split(Multiplayer.delims);
     if (strArray1.Length == 0)
     {
         return;
     }
     if (os.thisComputer != null && os.thisComputer.ip.Equals(strArray1[1]))
     {
         os.warningFlash();
     }
     if (strArray1[0].Equals("init"))
     {
         int int32 = Convert.ToInt32(strArray1[1]);
         Utils.random     = new Random(int32);
         os.canRunContent = true;
         os.LoadContent();
         os.write("Seed Established :" + (object)int32);
     }
     else if (strArray1[0].Equals("chat"))
     {
         string s = "";
         for (int index = 2; index < strArray1.Length; ++index)
         {
             s = s + strArray1[index] + " ";
         }
         os.write(strArray1[1] + ": " + DisplayModule.splitForWidth(s, 350));
     }
     else if (strArray1[0].Equals("clientConnect"))
     {
         os.write("Connection Established");
     }
     else if (strArray1[0].Equals("cConnection"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         if (comp == null)
         {
             os.write("Error in Message : " + message);
         }
         else
         {
             comp.silent = true;
             comp.connect(strArray1[2]);
             comp.silent         = false;
             os.opponentLocation = strArray1[1];
         }
     }
     else if (strArray1[0].Equals("cDisconnect"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         comp.disconnecting(strArray1[2], true);
         comp.silent         = false;
         os.opponentLocation = "";
     }
     else if (strArray1[0].Equals("cAdmin"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         comp.giveAdmin(strArray1[2]);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cPortOpen"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         comp.openPort(Convert.ToInt32(strArray1[3]), strArray1[2]);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cPortClose"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         comp.closePort(Convert.ToInt32(strArray1[3]), strArray1[2]);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cFile"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         FileEntry f = new FileEntry("", strArray1[3]);
         comp.canReadFile(strArray1[2], f, Convert.ToInt32(strArray1[4]));
         comp.silent = false;
     }
     else if (strArray1[0].Equals("newComp"))
     {
         string[] strArray2    = message.Split(Multiplayer.specSplitDelims);
         Vector2  compLocation = new Vector2((float)Convert.ToInt32(strArray2[2]), (float)Convert.ToInt32(strArray2[3]));
         Computer computer     = new Computer(strArray2[5], strArray2[1], compLocation, Convert.ToInt32(strArray2[4]), (byte)1, os);
         computer.idName = "opponent#" + (object)Multiplayer.generatedComputerCount;
         ++Multiplayer.generatedComputerCount;
         computer.addMultiplayerTargetFile();
         os.netMap.nodes.Add(computer);
         os.opponentComputer = computer;
     }
     else if (strArray1[0].Equals("cDelete"))
     {
         string[]   strArray2  = message.Split(Multiplayer.specSplitDelims);
         Computer   comp       = Multiplayer.getComp(strArray2[1], os);
         List <int> folderPath = new List <int>();
         for (int index = 4; index < strArray2.Length; ++index)
         {
             if (strArray2[index] != "")
             {
                 folderPath.Add(Convert.ToInt32(strArray2[index]));
             }
         }
         comp.silent = true;
         comp.deleteFile(strArray2[2], strArray2[3], folderPath);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cMake"))
     {
         string[]   strArray2  = message.Split(Multiplayer.specSplitDelims);
         Computer   comp       = Multiplayer.getComp(strArray2[1], os);
         List <int> folderPath = new List <int>();
         for (int index = 4; index < strArray2.Length; ++index)
         {
             if (strArray2[index] != "")
             {
                 folderPath.Add(Convert.ToInt32(strArray2[index]));
             }
         }
         comp.silent = true;
         comp.makeFile(strArray2[2], strArray2[3], strArray2[4], folderPath, false);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cMove"))
     {
         string[] strArray2 = message.Split(Multiplayer.specSplitDelims);
         Computer comp      = Multiplayer.getComp(strArray2[1], os);
         char[]   separator = new char[1] {
             '%'
         };
         List <int> folderPath = new List <int>();
         string[]   strArray3  = strArray2[5].Split(separator, 500, StringSplitOptions.RemoveEmptyEntries);
         for (int index = 0; index < strArray3.Length; ++index)
         {
             if (strArray2[index] != "")
             {
                 folderPath.Add(Convert.ToInt32(strArray2[index]));
             }
         }
         List <int> destFolderPath = new List <int>();
         string[]   strArray4      = strArray2[6].Split(separator, 500, StringSplitOptions.RemoveEmptyEntries);
         for (int index = 0; index < strArray4.Length; ++index)
         {
             if (strArray2[index] != "")
             {
                 destFolderPath.Add(Convert.ToInt32(strArray2[index]));
             }
         }
         comp.silent = true;
         comp.moveFile(strArray2[2], strArray2[3], strArray2[4], folderPath, destFolderPath);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cMkDir"))
     {
         string[]   strArray2  = message.Split(Multiplayer.specSplitDelims);
         Computer   comp       = Multiplayer.getComp(strArray2[1], os);
         List <int> folderPath = new List <int>();
         for (int index = 4; index < strArray2.Length; ++index)
         {
             if (strArray2[index] != "")
             {
                 folderPath.Add(Convert.ToInt32(strArray2[index]));
             }
         }
         comp.silent = true;
         comp.makeFolder(strArray2[2], strArray2[3], folderPath);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cAddUser"))
     {
         string[] strArray2 = message.Split(Multiplayer.specSplitDelims);
         Computer comp      = Multiplayer.getComp(strArray2[1], os);
         string   name      = strArray2[3];
         string   pass      = strArray2[4];
         byte     type      = Convert.ToByte(strArray2[5]);
         comp.silent = true;
         comp.addNewUser(strArray2[2], name, pass, type);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cCopy"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         comp.canCopyFile(strArray1[2], strArray1[3]);
         comp.silent = false;
         FileEntry fileEntry1 = (FileEntry)null;
         for (int index = 0; index < comp.files.root.folders[2].files.Count; ++index)
         {
             if (comp.files.root.folders[2].files[index].name.Equals(strArray1[3]))
             {
                 fileEntry1 = comp.files.root.folders[2].files[index];
             }
         }
         FileEntry fileEntry2 = new FileEntry(fileEntry1.data, fileEntry1.name);
         Multiplayer.getComp(strArray1[2], os).files.root.folders[2].files.Add(fileEntry2);
     }
     else if (strArray1[0].Equals("cCDDrive"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         if (strArray1[2].Equals("open"))
         {
             comp.openCDTray(strArray1[1]);
         }
         else
         {
             comp.closeCDTray(strArray1[1]);
         }
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cCrash"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         comp.crash(strArray1[2]);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cReboot"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         comp.silent = true;
         comp.reboot(strArray1[2]);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("cFBClients"))
     {
         Computer comp = Multiplayer.getComp(strArray1[1], os);
         if (os.connectedComp != null && os.connectedComp.ip.Equals(strArray1[1]))
         {
             os.exes.Add((ExeModule) new ForkBombExe(os.getExeBounds(), os));
         }
         comp.silent = true;
         comp.forkBombClients(strArray1[2]);
         comp.silent = false;
     }
     else if (strArray1[0].Equals("eForkBomb"))
     {
         if (!os.thisComputer.ip.Equals(strArray1[1]))
         {
             return;
         }
         ForkBombExe forkBombExe = new ForkBombExe(os.getExeBounds(), os);
         forkBombExe.LoadContent();
         os.exes.Add((ExeModule)forkBombExe);
     }
     else if (strArray1[0].Equals("mpOpponentWin"))
     {
         os.endMultiplayerMatch(false);
     }
     else
     {
         if (strArray1[0].Equals("stayAlive"))
         {
             return;
         }
         os.write("MSG: " + message);
     }
 }
コード例 #10
0
        public override void draw(Rectangle bounds, SpriteBatch sb)
        {
            this.drawSideBar(bounds, sb);
            int num1 = (int)((double)bounds.Width / 5.0);

            bounds.Width -= num1;
            bounds.X     += num1;
            this.drawTitle(bounds, sb);
            bounds.Y      += 30;
            bounds.Height -= 30;
            switch (this.state)
            {
            case AcademicDatabaseDaemon.ADDState.Welcome:
                bool      flag = this.comp.adminIP == this.os.thisComputer.ip;
                Rectangle destinationRectangle = bounds;
                destinationRectangle.Y      = bounds.Y + 60 - 20;
                destinationRectangle.Height = 22;
                sb.Draw(Utils.white, destinationRectangle, flag ? this.themeColor : this.darkThemeColor);
                string text1 = LocaleTerms.Loc("Valid Administrator Account Detected");
                if (!flag)
                {
                    text1 = LocaleTerms.Loc("Non-Admin Account Active");
                }
                Vector2 vector2   = GuiData.smallfont.MeasureString(text1);
                Vector2 position1 = new Vector2((float)(destinationRectangle.X + destinationRectangle.Width / 2) - vector2.X / 2f, (float)destinationRectangle.Y);
                sb.DrawString(GuiData.smallfont, text1, position1, Color.Black);
                if (Button.doButton(456011, bounds.X + 30, bounds.Y + bounds.Height / 2 - 15, bounds.Width / 2, 40, LocaleTerms.Loc("About This Server"), new Color?(this.themeColor)))
                {
                    this.state = AcademicDatabaseDaemon.ADDState.InfoPanel;
                }
                if (Button.doButton(456001, bounds.X + 30, bounds.Y + bounds.Height / 2 - 15 + 50, bounds.Width / 2, 40, LocaleTerms.Loc("Search Entries"), new Color?(this.themeColor)))
                {
                    this.state = AcademicDatabaseDaemon.ADDState.Seach;
                    this.os.execute("getString Name");
                }
                if (!Button.doButton(456005, bounds.X + 30, bounds.Y + bounds.Height / 2 - 15 + 100, bounds.Width / 2, 40, LocaleTerms.Loc("Exit"), new Color?(this.themeColor)))
                {
                    break;
                }
                this.os.display.command = "connect";
                break;

            case AcademicDatabaseDaemon.ADDState.Seach:
                this.drawSearchState(bounds, sb);
                break;

            case AcademicDatabaseDaemon.ADDState.MultiMatchSearch:
            case AcademicDatabaseDaemon.ADDState.PendingResult:
                if (Button.doButton(456010, bounds.X + 2, bounds.Y + 2, 160, 30, LocaleTerms.Loc("Back"), new Color?(this.darkThemeColor)))
                {
                    this.state = AcademicDatabaseDaemon.ADDState.Welcome;
                }
                Vector2 position2 = new Vector2((float)(bounds.X + bounds.Width / 2), (float)(bounds.Y + bounds.Height / 2));
                Vector2 origin    = new Vector2((float)(this.loadingCircle.Width / 2), (float)(this.loadingCircle.Height / 2));
                sb.Draw(this.loadingCircle, position2, new Rectangle?(), Color.White, (float)((double)this.os.timer % Math.PI * 3.0), origin, Vector2.One, SpriteEffects.None, 0.5f);
                float num2 = this.os.timer - this.searchStartTime;
                if ((this.state != AcademicDatabaseDaemon.ADDState.PendingResult || (double)num2 <= 3.59999990463257) && (this.state != AcademicDatabaseDaemon.ADDState.MultiMatchSearch || (double)num2 <= 0.699999988079071))
                {
                    break;
                }
                this.state = AcademicDatabaseDaemon.ADDState.Entry;
                this.needsDeletionConfirmation = true;
                this.doPreEntryViewSearch();
                break;

            case AcademicDatabaseDaemon.ADDState.Entry:
            case AcademicDatabaseDaemon.ADDState.EditPerson:
                this.drawEntryState(bounds, sb);
                break;

            case AcademicDatabaseDaemon.ADDState.EntryNotFound:
                if (Button.doButton(456010, bounds.X + 2, bounds.Y + 20, 160, 30, LocaleTerms.Loc("Back"), new Color?(this.darkThemeColor)))
                {
                    this.state = AcademicDatabaseDaemon.ADDState.Welcome;
                }
                if (Button.doButton(456015, bounds.X + 2, bounds.Y + 55, 160, 30, LocaleTerms.Loc("Search Again"), new Color?(this.darkThemeColor)))
                {
                    this.state = AcademicDatabaseDaemon.ADDState.Seach;
                    this.os.execute("getString Name");
                }
                TextItem.doFontLabel(new Vector2((float)(bounds.X + 2), (float)(bounds.Y + 90)), LocaleTerms.Loc("No Entries Found"), GuiData.font, new Color?(), float.MaxValue, float.MaxValue, false);
                break;

            case AcademicDatabaseDaemon.ADDState.MultipleEntriesFound:
                this.drawMultipleEntriesState(bounds, sb);
                break;

            case AcademicDatabaseDaemon.ADDState.InfoPanel:
                if (Button.doButton(456010, bounds.X + 2, bounds.Y + 30, 160, 30, LocaleTerms.Loc("Back"), new Color?(this.darkThemeColor)))
                {
                    this.state = AcademicDatabaseDaemon.ADDState.Welcome;
                }
                Vector2 pos = new Vector2((float)(bounds.X + 20), (float)(bounds.Y + 70));
                TextItem.doFontLabel(pos, LocaleTerms.Loc("Information"), GuiData.font, new Color?(), float.MaxValue, float.MaxValue, false);
                pos.Y += 40f;
                FileEntry fileEntry = this.root.searchForFile("info.txt");
                string    text2     = "ERROR: Unhandled System.IO.FileNotFoundException\nFile \"info.txt\" was not found";
                if (fileEntry != null)
                {
                    text2 = DisplayModule.cleanSplitForWidth(fileEntry.data, bounds.Width - 80);
                }
                TextItem.DrawShadow = false;
                TextItem.doFontLabel(pos, text2, GuiData.smallfont, new Color?(), (float)(bounds.Width - 40), float.MaxValue, false);
                break;

            case AcademicDatabaseDaemon.ADDState.EditEntry:
                this.drawEditDegreeState(bounds, sb);
                break;
            }
        }
コード例 #11
0
        public override void draw(Rectangle bounds, SpriteBatch sb)
        {
            drawSideBar(bounds, sb);
            var num1 = (int)(bounds.Width / 5.0);

            bounds.Width -= num1;
            bounds.X     += num1;
            drawTitle(bounds, sb);
            bounds.Y      += 30;
            bounds.Height -= 30;
            switch (state)
            {
            case ADDState.Welcome:
                var flag = comp.adminIP == os.thisComputer.ip;
                var destinationRectangle = bounds;
                destinationRectangle.Y      = bounds.Y + 60 - 20;
                destinationRectangle.Height = 22;
                sb.Draw(Utils.white, destinationRectangle, flag ? themeColor : darkThemeColor);
                var text1 = "Valid Administrator Account Detected";
                if (!flag)
                {
                    text1 = "Non-Admin Account Active";
                }
                var vector2   = GuiData.smallfont.MeasureString(text1);
                var position1 = new Vector2(destinationRectangle.X + destinationRectangle.Width / 2 - vector2.X / 2f,
                                            destinationRectangle.Y);
                sb.DrawString(GuiData.smallfont, text1, position1, Color.Black);
                if (Button.doButton(456011, bounds.X + 30, bounds.Y + bounds.Height / 2 - 15, bounds.Width / 2, 40,
                                    "About This Server", themeColor))
                {
                    state = ADDState.InfoPanel;
                }
                if (Button.doButton(456001, bounds.X + 30, bounds.Y + bounds.Height / 2 - 15 + 50, bounds.Width / 2, 40,
                                    "Search Entries", themeColor))
                {
                    state = ADDState.Seach;
                    os.execute("getString Name");
                }
                if (
                    !Button.doButton(456005, bounds.X + 30, bounds.Y + bounds.Height / 2 - 15 + 100, bounds.Width / 2,
                                     40, "Exit", themeColor))
                {
                    break;
                }
                os.display.command = "connect";
                break;

            case ADDState.Seach:
                drawSearchState(bounds, sb);
                break;

            case ADDState.MultiMatchSearch:
            case ADDState.PendingResult:
                if (Button.doButton(456010, bounds.X + 2, bounds.Y + 2, 160, 30, "Back", darkThemeColor))
                {
                    state = ADDState.Welcome;
                }
                var position2 = new Vector2(bounds.X + bounds.Width / 2, bounds.Y = bounds.Height / 2);
                var origin    = new Vector2(loadingCircle.Width / 2, loadingCircle.Height / 2);
                sb.Draw(loadingCircle, position2, new Rectangle?(), Color.White, (float)(os.timer % Math.PI * 3.0),
                        origin, Vector2.One, SpriteEffects.None, 0.5f);
                var num2 = os.timer - searchStartTime;
                if ((state != ADDState.PendingResult || num2 <= 3.59999990463257) &&
                    (state != ADDState.MultiMatchSearch || num2 <= 0.699999988079071))
                {
                    break;
                }
                state = ADDState.Entry;
                needsDeletionConfirmation = true;
                doPreEntryViewSearch();
                break;

            case ADDState.Entry:
            case ADDState.EditPerson:
                drawEntryState(bounds, sb);
                break;

            case ADDState.EntryNotFound:
                if (Button.doButton(456010, bounds.X + 2, bounds.Y + 20, 160, 30, "Back", darkThemeColor))
                {
                    state = ADDState.Welcome;
                }
                if (Button.doButton(456015, bounds.X + 2, bounds.Y + 55, 160, 30, "Search Again", darkThemeColor))
                {
                    state = ADDState.Seach;
                    os.execute("getString Name");
                }
                TextItem.doFontLabel(new Vector2(bounds.X + 2, bounds.Y + 90), "No Entries Found", GuiData.font,
                                     new Color?(), float.MaxValue, float.MaxValue);
                break;

            case ADDState.MultipleEntriesFound:
                drawMultipleEntriesState(bounds, sb);
                break;

            case ADDState.InfoPanel:
                if (Button.doButton(456010, bounds.X + 2, bounds.Y + 30, 160, 30, "Back", darkThemeColor))
                {
                    state = ADDState.Welcome;
                }
                var pos = new Vector2(bounds.X + 20, bounds.Y + 70);
                TextItem.doFontLabel(pos, "Information", GuiData.font, new Color?(), float.MaxValue, float.MaxValue);
                pos.Y += 40f;
                var fileEntry = root.searchForFile("info.txt");
                var text2     = "ERROR: Unhandled System.IO.FileNotFoundException\nFile \"info.txt\" was not found";
                if (fileEntry != null)
                {
                    text2 = DisplayModule.cleanSplitForWidth(fileEntry.data, bounds.Width - 80);
                }
                TextItem.DrawShadow = false;
                TextItem.doFontLabel(pos, text2, GuiData.smallfont, new Color?(), bounds.Width - 40, float.MaxValue);
                break;

            case ADDState.EditEntry:
                drawEditDegreeState(bounds, sb);
                break;
            }
        }
コード例 #12
0
ファイル: OS.cs プロジェクト: strangea/OpenHacknet
 public override void LoadContent()
 {
     if (canRunContent)
     {
         delayer = new ActionDelayer();
         ComputerLoader.init(this);
         content = ScreenManager.Game.Content;
         username = SaveUserAccountName == null
             ? (Settings.isConventionDemo ? Settings.ConventionLoginName : Environment.UserName)
             : SaveUserAccountName;
         username = FileSanitiser.purifyStringForDisplay(username);
         var compLocation = new Vector2(0.1f, 0.5f);
         if (multiplayer && !isServer)
             compLocation = new Vector2(0.8f, 0.8f);
         ramAvaliable = totalRam;
         var str = !multiplayer || !isServer ? NetworkMap.generateRandomIP() : NetworkMap.generateRandomIP();
         thisComputer = new Computer(username + " PC", NetworkMap.generateRandomIP(), compLocation, 5, 4, this);
         thisComputer.adminIP = thisComputer.ip;
         thisComputer.idName = "playerComp";
         var folder = thisComputer.files.root.searchForFolder("home");
         folder.folders.Add(new Folder("stash"));
         folder.folders.Add(new Folder("misc"));
         var userDetail = thisComputer.users[0];
         userDetail.known = true;
         thisComputer.users[0] = userDetail;
         defaultUser = new UserDetail(username, "password", 1);
         defaultUser.known = true;
         var theme = OSTheme.HacknetBlue;
         if (Settings.isConventionDemo)
         {
             var num = Utils.random.NextDouble();
             if (num < 0.33)
                 theme = OSTheme.HacknetMint;
             else if (num < 0.66)
                 theme = OSTheme.HackerGreen;
         }
         ThemeManager.setThemeOnComputer(thisComputer, theme);
         if (multiplayer)
         {
             thisComputer.addMultiplayerTargetFile();
             sendMessage("newComp #" + thisComputer.ip + "#" + compLocation.X + "#" + compLocation.Y +
                         "#" + 5 + "#" + thisComputer.name);
             multiplayerMissionLoaded = false;
         }
         if (!WillLoadSave)
             People.init();
         modules = new List<Module>();
         exes = new List<ExeModule>();
         shells = new List<ShellExe>();
         shellIPs = new List<string>();
         var viewport = ScreenManager.GraphicsDevice.Viewport;
         var width1 = RamModule.MODULE_WIDTH;
         var height1 = 205;
         var width2 = (int) ((viewport.Width - width1 - 6)*0.4442);
         var num1 = (int) ((viewport.Width - width1 - 6)*0.5558);
         var height2 = viewport.Height - height1 - TOP_BAR_HEIGHT - 6;
         terminal =
             new Terminal(
                 new Rectangle(viewport.Width - 2 - width2, TOP_BAR_HEIGHT, width2,
                     viewport.Height - TOP_BAR_HEIGHT - 2), this);
         terminal.name = "TERMINAL";
         modules.Add(terminal);
         netMap = new NetworkMap(new Rectangle(width1 + 4, viewport.Height - height1 - 2, num1 - 1, height1),
             this);
         netMap.name = "netMap v1.7";
         modules.Add(netMap);
         display = new DisplayModule(new Rectangle(width1 + 4, TOP_BAR_HEIGHT, num1 - 2, height2), this);
         display.name = "DISPLAY";
         modules.Add(display);
         ram =
             new RamModule(
                 new Rectangle(2, TOP_BAR_HEIGHT, width1, ramAvaliable + RamModule.contentStartOffset), this);
         ram.name = "RAM";
         modules.Add(ram);
         for (var index = 0; index < modules.Count; ++index)
             modules[index].LoadContent();
         for (var index = 0; index < 2; ++index)
         {
             if (isServer || !multiplayer)
                 thisComputer.links.Add(index);
             else
                 thisComputer.links.Add(netMap.nodes.Count - 1 - index);
         }
         var flag1 = false;
         if (!WillLoadSave)
         {
             netMap.nodes.Insert(0, thisComputer);
             netMap.visibleNodes.Add(0);
             MusicManager.loadAsCurrentSong("Music\\Revolve");
         }
         else
         {
             loadSaveFile();
             flag1 = true;
             Settings.initShowsTutorial = false;
         }
         if (!multiplayer && !flag1)
         {
             MailServer.shouldGenerateJunk = false;
             netMap.mailServer.addNewUser(thisComputer.ip, defaultUser);
         }
         mailicon = new MailIcon(this, new Vector2(0.0f, 0.0f));
         mailicon.pos.X = viewport.Width - mailicon.getWidth() - 2;
         topBar = new Rectangle(0, 0, viewport.Width, TOP_BAR_HEIGHT - 1);
         crashModule =
             new CrashModule(
                 new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width,
                     ScreenManager.GraphicsDevice.Viewport.Height), this);
         crashModule.LoadContent();
         introTextModule =
             new IntroTextModule(
                 new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width,
                     ScreenManager.GraphicsDevice.Viewport.Height), this);
         introTextModule.LoadContent();
         traceTracker = new TraceTracker(this);
         IncConnectionOverlay = new IncomingConnectionOverlay(this);
         if (allFactions == null)
         {
             allFactions = new AllFactions();
             allFactions.init();
         }
         currentFaction = allFactions.factions[allFactions.currentFaction];
         scanLines = content.Load<Texture2D>("ScanLines");
         cross = content.Load<Texture2D>("Cross");
         cog = content.Load<Texture2D>("Cog");
         saveIcon = content.Load<Texture2D>("SaveIcon");
         beepSound = content.Load<SoundEffect>("SFX/beep");
         if (!multiplayer & !flag1)
             loadMissionNodes();
         if (!flag1)
             MusicManager.playSong();
         if (flag1 || !Settings.slowOSStartup)
         {
             initShowsTutorial = false;
             introTextModule.complete = true;
         }
         inputEnabled = true;
         isLoaded = true;
         fullscreen = new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width,
             ScreenManager.GraphicsDevice.Viewport.Height);
         TraceDangerSequence = new TraceDangerSequence(content, ScreenManager.SpriteBatch, fullscreen, this);
         endingSequence = new EndingSequenceModule(fullscreen, this);
         var flag2 = Settings.slowOSStartup && !flag1;
         var flag3 = Settings.osStartsWithTutorial && (!flag1 || !Flags.HasFlag("TutorialComplete"));
         if (flag2)
         {
             rebootThisComputer();
             if (!Settings.initShowsTutorial)
                 return;
             display.visible = false;
             ram.visible = false;
             netMap.visible = false;
             terminal.visible = true;
         }
         else if (flag3)
         {
             display.visible = false;
             ram.visible = false;
             netMap.visible = false;
             terminal.visible = true;
             terminal.reset();
             Settings.initShowsTutorial = true;
             initShowsTutorial = true;
             if (TestingPassOnly)
                 return;
             execute("FirstTimeInitdswhupwnemfdsiuoewnmdsmffdjsklanfeebfjkalnbmsdakj Init");
         }
         else
         {
             if (!TestingPassOnly)
                 runCommand("connect " + thisComputer.ip);
             if (thisComputer.files.root.searchForFolder("sys").searchForFile("Notes_Reopener.bat") == null)
                 return;
             runCommand("notes");
         }
     }
     else
     {
         if (!multiplayer)
             return;
         initializeNetwork();
     }
 }