Ejemplo n.º 1
0
 private void Init(Computer c, OS os, string name, DatabaseDaemon.DatabasePermissions permissions, string DataTypeIdentifier, string Foldername, Color themeColor)
 {
     this.sideEffect         = new MovingBarsEffect();
     this.Permissions        = permissions;
     this.State              = DatabaseDaemon.DatabaseState.Welcome;
     this.DataTypeIdentifier = DataTypeIdentifier;
     this.DataType           = ObjectSerializer.GetTypeForName(DataTypeIdentifier);
     this.ScrollPanel        = new ScrollableSectionedPanel(26, GuiData.spriteBatch.GraphicsDevice);
     this.TextRegion         = new ScrollableTextRegion(GuiData.spriteBatch.GraphicsDevice);
     this.Foldername         = Foldername == null ? "Database" : Foldername;
     this.ThemeColor         = themeColor;
     if (DataTypeIdentifier.EndsWith("NeopalsAccount"))
     {
         this.WildcardAssets.Add((object)Neopal.PetType.Blundo, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Blundo"));
         this.WildcardAssets.Add((object)Neopal.PetType.Chisha, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Chisha"));
         this.WildcardAssets.Add((object)Neopal.PetType.Jubdub, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Jubdub"));
         this.WildcardAssets.Add((object)Neopal.PetType.Kachici, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Kachici"));
         this.WildcardAssets.Add((object)Neopal.PetType.Kyrill, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Kyrill"));
         this.WildcardAssets.Add((object)Neopal.PetType.Myncl, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Myncl"));
         this.WildcardAssets.Add((object)Neopal.PetType.Pageri, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Pageri"));
         this.WildcardAssets.Add((object)Neopal.PetType.Psybunny, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Psybunny"));
         this.WildcardAssets.Add((object)Neopal.PetType.Scorchum, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Scorchum"));
         this.WildcardAssets.Add((object)Neopal.PetType.Unisam, os.content.Load <Texture2D>("DLC/Sprites/Neopals/Unisam"));
     }
     this.PlaceholderSprite = os.content.Load <Texture2D>("Sprites/Chip");
     this.Triangle          = os.content.Load <Texture2D>("DLC/Sprites/Triangle");
 }
Ejemplo n.º 2
0
        private void DrawBrowse(Rectangle dest, SpriteBatch spriteBatch)
        {
            Rectangle drawRectForRow1 = this.GetDrawRectForRow(0, 12);
            bool      flag            = this.Permissions == DatabaseDaemon.DatabasePermissions.Public || this.comp.adminIP == this.os.thisComputer.ip;

            TextItem.doFontLabelToSize(drawRectForRow1, string.Format(LocaleTerms.Loc("{0} : Records"), (object)this.name), GuiData.font, Color.White, true, true);
            Rectangle drawRectForRow2 = this.GetDrawRectForRow(0, 0);

            PatternDrawer.draw(drawRectForRow2, 0.5f, Color.Transparent, this.ThemeColor * 0.2f, spriteBatch, PatternDrawer.thinStripe);
            Rectangle rectangle = new Rectangle(drawRectForRow2.X + 4, drawRectForRow2.Y + drawRectForRow2.Height / 2 + 12, drawRectForRow2.Width / 3, drawRectForRow2.Height / 2 - 15);

            if (Button.doButton(71118000, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, LocaleTerms.Loc("Back"), new Color?(Color.Gray)))
            {
                this.State = DatabaseDaemon.DatabaseState.Welcome;
            }
            if (this.DataType == (Type)null || string.IsNullOrWhiteSpace(this.DataTypeIdentifier) || this.DataTypeIdentifier.ToLower() == "none")
            {
                Rectangle drawRectForRow3 = this.GetDrawRectForRow(1, 2);
                drawRectForRow3.Height += (int)((double)this.blockSize * (double)(this.blocksHigh - 3));
                PatternDrawer.draw(drawRectForRow3, 0.4f, Color.Black * 0.3f, Utils.makeColorAddative(this.ThemeColor) * 0.25f, spriteBatch, PatternDrawer.binaryTile);
                TextItem.doCenteredFontLabel(this.GetDrawRectForRow(3, 8), " - " + LocaleTerms.Loc("API Access Enabled") + " - ", GuiData.smallfont, Color.White, false);
            }
            else
            {
                Rectangle ListDest = this.GetDrawRectForRow(1, 4);
                ListDest.Height += (int)((double)this.blockSize * ((double)this.blocksHigh - 2.5));
                this.ScrollPanel.NumberOfPanels = this.DatasetFolder.files.Count;
                this.ScrollPanel.Draw((Action <int, Rectangle, SpriteBatch>)((i, bounds, sb) =>
                {
                    FileEntry file = this.DatasetFolder.files[i];
                    string text    = "REC#" + i.ToString("000") + " : " + this.GetAnnounceNameForFileName(file.name);
                    int width      = Math.Max(160, bounds.Width / 3);
                    if (Button.doButton(71118100 + i, bounds.X, bounds.Y + 2, width, bounds.Height - 4, string.Format(LocaleTerms.Loc("View Record #{0}"), (object)i.ToString("000")), new Color?(this.ThemeColor)))
                    {
                        this.ActiveFile       = this.DatasetFolder.files[i];
                        this.State            = DatabaseDaemon.DatabaseState.EntryDisplay;
                        this.DeserializedFile = (object)null;
                    }
                    Vector2 vector2 = GuiData.smallfont.MeasureString(text);
                    Rectangle destinationRectangle = new Rectangle(bounds.X + bounds.Width / 3 + 6, bounds.Y + bounds.Height / 2 - 1, ListDest.Width - (width + (int)vector2.X + 26), 1);
                    sb.Draw(Utils.white, destinationRectangle, Color.White * 0.1f);
                    TextItem.doFontLabel(new Vector2((float)(destinationRectangle.X + destinationRectangle.Width) + 6f, (float)bounds.Y + 2f), text, GuiData.smallfont, new Color?(Color.White), (float)bounds.Width, (float)bounds.Height, false);
                }), spriteBatch, ListDest);
            }
        }
Ejemplo n.º 3
0
        private void DrawEntry(Rectangle dest, SpriteBatch spriteBatch)
        {
            if (this.DeserializedFile == null)
            {
                try
                {
                    this.DeserializedFile = ObjectSerializer.DeserializeObject(Utils.GenerateStreamFromString(this.DeCleanXMLForFile(this.ActiveFile.data)), this.DataType);
                }
                catch (Exception ex)
                {
                    this.State        = DatabaseDaemon.DatabaseState.Error;
                    this.errorMessage = LocaleTerms.Loc("Error De-serializing Entry") + " : " + this.ActiveFile.name + "\n" + Utils.GenerateReportFromException(ex).Replace("Hacknet", "Database");
                    return;
                }
            }
            Rectangle drawRectForRow = this.GetDrawRectForRow(0, 0);

            drawRectForRow.Height = drawRectForRow.Height / 2;
            TextItem.doFontLabelToSize(drawRectForRow, string.Format(LocaleTerms.Loc("Entry for {0}"), (object)this.GetAnnounceNameForFileName(this.ActiveFile.name)), GuiData.font, Color.White, true, true);
            drawRectForRow.Y += drawRectForRow.Height;
            if (Button.doButton(7301991, drawRectForRow.X, drawRectForRow.Y, drawRectForRow.Width / 2, drawRectForRow.Height, LocaleTerms.Loc("Back"), new Color?(Color.Gray)))
            {
                this.State            = DatabaseDaemon.DatabaseState.Browse;
                this.ActiveFile       = (FileEntry)null;
                this.DeserializedFile = (object)null;
            }
            else
            {
                Rectangle bounds = new Rectangle((int)this.BlockStartTopLeft.X, (int)this.BlockStartTopLeft.Y + (int)this.blockSize, (int)((double)this.blockSize * (double)(this.blocksWide - 1)), (int)((double)this.blockSize * (double)(this.blocksHigh - 2)));
                if (this.HasSpecialCaseDraw)
                {
                    ReflectiveRenderer.PreRenderForObject += (Action <Vector2, Type, string>)((pos, targetType, targetValue) => this.DrawSpecialCase(pos, bounds, targetType, targetValue, spriteBatch));
                }
                ReflectiveRenderer.RenderObject(this.DeserializedFile, bounds, spriteBatch, this.ScrollPanel, this.ThemeColor);
                if (this.HasSpecialCaseDraw)
                {
                    ReflectiveRenderer.PreRenderForObject = (Action <Vector2, Type, string>)null;
                }
            }
        }
Ejemplo n.º 4
0
        private void DrawError(Rectangle dest, SpriteBatch sb)
        {
            Rectangle drawRectForRow1 = this.GetDrawRectForRow(0, 12);
            bool      flag            = this.Permissions == DatabaseDaemon.DatabasePermissions.Public || this.comp.adminIP == this.os.thisComputer.ip;

            TextItem.doFontLabelToSize(drawRectForRow1, this.name, GuiData.font, Color.White, false, true);
            PatternDrawer.draw(new Rectangle(dest.X + 1, (int)this.BlockStartTopLeft.Y, dest.Width - 2, (int)((double)this.blockSize * 2.0)), 0.5f, Color.Transparent, Utils.AddativeRed * 0.2f, sb, flag ? PatternDrawer.thinStripe : PatternDrawer.errorTile);
            TextItem.doFontLabelToSize(this.GetDrawRectForRow(1, 12), LocaleTerms.Loc("ERROR"), GuiData.font, Utils.AddativeRed * 0.8f, true, true);
            Rectangle drawRectForRow2 = this.GetDrawRectForRow(2, 14);

            if (Button.doButton(73616101, (int)this.BlockStartTopLeft.X, drawRectForRow2.Y, dest.Width / 2, drawRectForRow2.Height, LocaleTerms.Loc("Back"), new Color?(this.ThemeColor)))
            {
                this.State = DatabaseDaemon.DatabaseState.Welcome;
            }
            Rectangle rectangle = this.GetDrawRectForRow(3, 14);

            rectangle.Height = (int)(((double)this.blocksHigh - 4.0) * (double)this.blockSize);
            rectangle        = Utils.InsetRectangle(rectangle, 2);
            string text = Utils.SuperSmartTwimForWidth(this.errorMessage, rectangle.Width, GuiData.smallfont);

            this.TextRegion.Draw(rectangle, text, sb, Utils.AddativeRed);
        }
Ejemplo n.º 5
0
        private void DrawWelcome(Rectangle dest, SpriteBatch sb)
        {
            this.TextRegion.UpdateScroll(0.0f);
            Rectangle drawRectForRow1 = this.GetDrawRectForRow(0, 12);
            bool      flag            = this.Permissions == DatabaseDaemon.DatabasePermissions.Public || this.comp.adminIP == this.os.thisComputer.ip;

            TextItem.doCenteredFontLabel(drawRectForRow1, this.name, GuiData.font, Color.White, true);
            PatternDrawer.draw(new Rectangle(dest.X + 1, (int)this.BlockStartTopLeft.Y, dest.Width - 2, (int)((double)this.blockSize * 2.0)), 0.5f, Color.Transparent, (flag ? this.ThemeColor : Utils.AddativeRed) * 0.2f, sb, flag ? PatternDrawer.thinStripe : PatternDrawer.errorTile);
            TextItem.doCenteredFontLabel(this.GetDrawRectForRow(1, 12), flag ? LocaleTerms.Loc("Access Granted") : LocaleTerms.Loc("Administrator Login Required"), GuiData.font, flag ? this.ThemeColor * 0.8f : Utils.AddativeRed * 0.8f, true);
            Rectangle drawRectForRow2 = this.GetDrawRectForRow(3, 14);

            if (flag && Button.doButton(73616101, (int)this.BlockStartTopLeft.X, drawRectForRow2.Y, dest.Width / 2, drawRectForRow2.Height, LocaleTerms.Loc("Browse Records"), new Color?(this.ThemeColor)))
            {
                this.State = DatabaseDaemon.DatabaseState.Browse;
            }
            drawRectForRow2.Y     += drawRectForRow2.Height + 10;
            drawRectForRow2.Height = drawRectForRow2.Height / 2;
            if (Button.doButton(73616102, (int)this.BlockStartTopLeft.X, drawRectForRow2.Y, dest.Width / 2, drawRectForRow2.Height, LocaleTerms.Loc("Login"), new Color?(this.ThemeColor)))
            {
                this.os.execute("login");
            }
            drawRectForRow2.Y += drawRectForRow2.Height + 6;
            Color color = Color.Lerp(Color.Black, this.ThemeColor, 0.5f);

            if (!string.IsNullOrWhiteSpace(this.adminResetPassEmailAccount) && Button.doButton(73616106, (int)this.BlockStartTopLeft.X, drawRectForRow2.Y, dest.Width / 2, drawRectForRow2.Height, this.AdminEmailResetHasHappened ? LocaleTerms.Loc("Password Reset In Cooldown") : (this.AdminEmailResetStarted ? LocaleTerms.Loc("Cancel") : LocaleTerms.Loc("Reset Access Password")), new Color?(this.AdminEmailResetStarted ? (this.AdminEmailResetHasHappened ? Color.Gray : Color.DarkRed) : color)))
            {
                this.AdminEmailResetStarted = !this.AdminEmailResetStarted;
            }
            if (this.AdminEmailResetStarted)
            {
                Rectangle rectangle = this.GetDrawRectForRow(3, 10);
                rectangle.X     += dest.Width / 2 + 10;
                rectangle.Width -= dest.Width / 2;
                rectangle.Height = Math.Max(300, (int)((double)this.blockSize * 3.0 - 30.0));
                rectangle.Width += 30;
                if (rectangle.Height == 300)
                {
                    rectangle.Y -= (int)this.blockSize;
                }
                Color backingColor = Color.Gray * 0.3f;
                sb.Draw(Utils.white, rectangle, Color.Black * 0.8f);
                rectangle = Utils.InsetRectangle(rectangle, 2);
                PatternDrawer.draw(rectangle, 0.5f, backingColor, backingColor * 0.4f, sb, PatternDrawer.thinStripe);
                int       num = 20;
                Rectangle destinationRectangle = new Rectangle(rectangle.X - num - 2, drawRectForRow2.Y + (drawRectForRow2.Height - num) / 2, num, num);
                sb.Draw(this.Triangle, destinationRectangle, Color.Black * 0.8f);
                Rectangle dest1 = new Rectangle(rectangle.X + 6, rectangle.Y, rectangle.Width - 12, rectangle.Height / 6);
                TextItem.doCenteredFontLabel(dest1, LocaleTerms.Loc("Reset Admin Password"), GuiData.font, Color.LightGray, true);
                Rectangle dest2 = new Rectangle(dest1.X, dest1.Y + dest1.Height + 4, dest1.Width + 9, rectangle.Height / 6 * 4);
                if (this.passwordResetHelperString == null)
                {
                    this.passwordResetHelperString = Utils.readEntireFile("Content/DLC/Docs/PasswordResetText.txt");
                }
                string data = this.passwordResetHelperString.Replace("[PASSWORD]", this.adminResetPassEmailAccount);
                if (this.AdminEmailResetHasHappened)
                {
                    data = this.passwordResetMessage;
                }
                string text = Utils.SuperSmartTwimForWidth(data, dest2.Width, GuiData.UITinyfont);
                TextItem.doFontLabelToSize(dest2, text, GuiData.tinyfont, Color.White, true, true);
                if (!this.AdminEmailResetHasHappened && Button.doButton(73606111, rectangle.X + 4, rectangle.Y + rectangle.Height - 28, rectangle.Width - 8, 26, LocaleTerms.Loc("Reset Password"), new Color?(Color.Red)))
                {
                    this.ResetAccessPassword();
                }
            }
            drawRectForRow2.Y += drawRectForRow2.Height + 6;
            if (!Button.doButton(73616129, (int)this.BlockStartTopLeft.X, drawRectForRow2.Y, dest.Width / 2, drawRectForRow2.Height, LocaleTerms.Loc("Exit"), new Color?(Color.Black)))
            {
                return;
            }
            this.os.display.command = "connect";
        }
Ejemplo n.º 6
0
 public override void navigatedTo()
 {
     base.navigatedTo();
     this.State = DatabaseDaemon.DatabaseState.Welcome;
     this.AdminEmailResetStarted = false;
 }