private void VoidIcon(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_DrawSelf orig, UIWorldListItem self, SpriteBatch spriteBatch)
        {
            orig(self, spriteBatch);
            Vector2 pos = self.GetDimensions().ToRectangle().TopRight();

            float chungosity = 0;

            if (worldDataCache.TryGetValue(self, out var tag3) && tag3 != null)
            {
                chungosity = tag3.GetFloat("Chungus");
            }

            Texture2D tex  = ModContent.GetTexture("StarlightRiver/Assets/GUI/ChungusMeter");
            Texture2D tex2 = ModContent.GetTexture("StarlightRiver/Assets/GUI/ChungusMeterFill");

            spriteBatch.Draw(tex, pos + new Vector2(-122, 6), Color.White);
            spriteBatch.Draw(tex2, pos + new Vector2(-108, 10), new Rectangle(0, 0, (int)(tex2.Width * chungosity), tex2.Height), Color.White);
            spriteBatch.Draw(Main.magicPixel, new Rectangle((int)pos.X - 108 + (int)(tex2.Width * chungosity), (int)pos.Y + 10, 2, 10), Color.White);

            Rectangle rect = new Rectangle((int)pos.X - 122, (int)pos.Y + 6, tex.Width, tex.Height);

            if (rect.Contains(Main.MouseScreen.ToPoint()))
            {
                Utils.DrawBorderString(spriteBatch, "Chungosity: " + (int)(chungosity * 100) + "%", self.GetDimensions().Position() + new Vector2(110, 70), Color.White);
            }
        }
        private static void Menu_UICWorldListItem(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_DrawSelf orig, UIWorldListItem self, SpriteBatch spriteBatch)
        {
            orig(self, spriteBatch);
            int floors = -1;

            if (SGAmodData.TryGetValue(self, out var tag3) && tag3 != null)
            {
                Vector2 pos  = self.GetDimensions().ToRectangle().TopRight();
                Vector2 pos2 = self.GetDimensions().ToRectangle().BottomRight();

                bool darknessUnlocked = false;
                bool cheat            = false;

                if (tag3.ContainsKey("highestDimDungeonFloor"))
                {
                    floors = tag3.GetByte("highestDimDungeonFloor");
                }
                if (tag3.ContainsKey("darknessVision"))
                {
                    darknessUnlocked = tag3.GetBool("darknessVision");
                }
                if (tag3.ContainsKey("cheating"))
                {
                    cheat = tag3.GetBool("cheating");
                }

                Vector2 lenn = Vector2.Zero;

                if (floors > 0)
                {
                    string text = "Floors completed: " + (floors < 0 ? "None" : "" + (int)floors);
                    lenn = new Vector2(-Main.fontMouseText.MeasureString(text).X - 8, 5);
                    Utils.DrawBorderString(spriteBatch, text, pos + new Vector2(-Main.fontMouseText.MeasureString(text).X - 8, 5), Color.DeepSkyBlue);
                }

                if (cheat)
                {
                    Utils.DrawBorderString(spriteBatch, "CHEAT", pos + new Vector2(-Main.fontMouseText.MeasureString("CHEAT").X - 8, 5) + new Vector2(lenn.X, 0), Color.Red);
                }

                if (darknessUnlocked)
                {
                    Texture2D DarknessText = ModContent.GetTexture("SGAmod/Items/WatchersOfNull");
                    spriteBatch.Draw(DarknessText, pos2 - new Vector2(self.IsFavorite ? 24 : 48, 16), new Rectangle(0, 0, DarknessText.Width, DarknessText.Height / 13), Color.White, 0, new Vector2(DarknessText.Width, DarknessText.Height / 13) / 2f, 1f, SpriteEffects.None, 0f);
                }
            }
        }
Пример #3
0
        private void ProfessionalText(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_DrawSelf orig, Terraria.GameContent.UI.Elements.UIWorldListItem self, SpriteBatch spriteBatch)
        {
            orig(self, spriteBatch);

            FieldInfo     dataInfo      = self.GetType().GetField("_data", BindingFlags.NonPublic | BindingFlags.Instance);
            FieldInfo     worldIconInfo = self.GetType().GetField("_worldIcon", BindingFlags.NonPublic | BindingFlags.Instance);
            WorldFileData fileData      = (WorldFileData)dataInfo.GetValue(self);
            UIImage       worldIcon     = (UIImage)worldIconInfo.GetValue(self);

            string filePath = fileData.Path.Replace(".wld", ".twld"); //remember .wld exists ahh

            TagCompound tagCompound1;

            try
            {
                byte[] bytes = FileUtilities.ReadAllBytes(filePath, fileData.IsCloudSave);
                tagCompound1 = TagIO.FromStream(new MemoryStream(bytes), true);
            }
            catch
            {
                tagCompound1 = null;
            }

            TagCompound tagCompound2 = tagCompound1?.GetList <TagCompound>("modData").FirstOrDefault(i => i.GetString("mod") == "SpectraMod" && i.GetString("name") == "SpectraWorld"); //allow null
            TagCompound tagCompound3 = tagCompound2?.Get <TagCompound>("data");

            CalculatedStyle innerDimensions = self.GetInnerDimensions();
            CalculatedStyle dimensions      = worldIcon.GetDimensions();
            float           num7            = dimensions.X + dimensions.Width;
            Color           color           = fileData.IsValid ? Color.White : Color.Red;

            Utils.DrawBorderString(spriteBatch, fileData.Name, new Vector2(num7 + 6f, dimensions.Y - 2f), color);
            spriteBatch.Draw(TextureManager.Load("Images/UI/Divider"), new Vector2(num7, innerDimensions.Y + 21f), null, Color.White, 0f, Vector2.Zero, new Vector2((self.GetDimensions().X + self.GetDimensions().Width - num7) / 8f, 1f), SpriteEffects.None, 0f);
            Vector2 vector = new Vector2(num7 + 6f, innerDimensions.Y + 29f);
            float   num6   = 100f;

            DrawPanel(spriteBatch, vector, num6);

            bool?IsProfessionalMode = tagCompound3?.GetBool("IsProfessionalMode");

            if (IsProfessionalMode == null)
            {
                IsProfessionalMode = false;
            }

            string text;

            if ((bool)IsProfessionalMode)
            {
                text = "Professional";
            }
            else if (fileData.IsExpertMode && (bool)!IsProfessionalMode)
            {
                text = Language.GetTextValue("UI.Expert");
            }
            else
            {
                text = Language.GetTextValue("UI.Normal");
            }

            float x11 = Main.fontMouseText.MeasureString(text).X;
            float x10 = num6 * 0.5f - x11 * 0.5f;

            if ((bool)IsProfessionalMode)
            {
                text = "Professional";
            }
            else if (fileData.IsExpertMode && (bool)!IsProfessionalMode)
            {
                text = Language.GetTextValue("UI.Expert");
            }
            else
            {
                text = Language.GetTextValue("UI.Normal");
            }

            Color difficultyColor;

            if ((bool)IsProfessionalMode)
            {
                difficultyColor = new Color(255, 0, 0);
            }
            else if (fileData.IsExpertMode && (bool)!IsProfessionalMode)
            {
                difficultyColor = new Color(217, 143, 244);
            }
            else
            {
                difficultyColor = Color.White;
            }

            Utils.DrawBorderString(spriteBatch, text, vector + new Vector2(x10, 3f), difficultyColor);

            vector.X += num6 + 5f;

            float num5 = 150f;

            if (!GameCulture.English.IsActive)
            {
                num5 += 40f;
            }

            DrawPanel(spriteBatch, vector, num5);

            string textValue3 = Language.GetTextValue("UI.WorldSizeFormat", fileData.WorldSizeName);
            float  x9         = Main.fontMouseText.MeasureString(textValue3).X;
            float  x8         = num5 * 0.5f - x9 * 0.5f;

            Utils.DrawBorderString(spriteBatch, textValue3, vector + new Vector2(x8, 3f), Color.White);

            vector.X += num5 + 5f;
            float num4 = innerDimensions.X + innerDimensions.Width - vector.X;

            DrawPanel(spriteBatch, vector, num4);

            string arg        = (!GameCulture.English.IsActive) ? fileData.CreationTime.ToShortDateString() : fileData.CreationTime.ToString("d MMMM yyyy");
            string textValue2 = Language.GetTextValue("UI.WorldCreatedFormat", arg);
            float  x7         = Main.fontMouseText.MeasureString(textValue2).X;
            float  x6         = num4 * 0.5f - x7 * 0.5f;

            Utils.DrawBorderString(spriteBatch, textValue2, vector + new Vector2(x6, 3f), Color.White);

            vector.X += num4 + 5f;
        }