private void AddWorldData(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex)
        {
            orig(self, data, snapPointIndex);

            string path = data.Path.Replace(".wld", ".twld");

            TagCompound tag;

            try
            {
                byte[] buf = FileUtilities.ReadAllBytes(path, data.IsCloudSave);
                tag = TagIO.FromStream(new MemoryStream(buf), true);
            }
            catch
            {
                tag = null;
            }

            TagCompound tag2 = tag?.GetList <TagCompound>("modData").FirstOrDefault(k => k.GetString("mod") == "StarlightRiver" && k.GetString("name") == "StarlightWorld");
            TagCompound tag3 = tag2?.Get <TagCompound>("data");

            worldDataCache.Add(self, tag3);
        }
        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);
            }
        }
示例#3
0
        private static void MouseOverBlack(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_MouseOver orig, UIWorldListItem self, UIMouseEvent evt)
        {
            orig(self, evt);

            if (File.Exists(Path.ChangeExtension(((WorldFileData)FanIdeasMod.TMLAssembly.GetType("Terraria.GameContent.UI.Elements.UIWorldListItem").GetField("_data", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self)).Path, ".fwim")))
            {
                self.BackgroundColor = new Color(35, 35, 35);
                self.BorderColor     = new Color(60, 60, 60);
            }
        }
示例#4
0
        private static void ConstructorBlack(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex)
        {
            orig(self, data, snapPointIndex);

            if (File.Exists(Path.ChangeExtension(data.Path, ".fwim")))
            {
                self.BackgroundColor = new Color(25, 25, 25);
                self.BorderColor     = new Color(50, 50, 50);
            }
        }
        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);
                }
            }
        }
        private static void CtorModWorlData(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, UIWorldListItem self, WorldFileData data, int snapPointIndex)
        {
            orig(self, data, snapPointIndex);

            if (!SGAConfigClient.Instance.PlayerWorldData)
            {
                return;
            }

            string      path = data.Path.Replace(".wld", ".twld");
            TagCompound tag;

            try
            {
                byte[] buffer = FileUtilities.ReadAllBytes(path, data.IsCloudSave);
                tag = TagIO.FromStream(new MemoryStream(buffer), true);
            }
            catch
            {
                tag = null;
            }

            TagCompound tag2 = tag?.GetList <TagCompound>("modData").FirstOrDefault(testby => testby.GetString("mod") == "SGAmod" && testby.GetString("name") == "SGAWorld");
            TagCompound tag3 = tag2?.Get <TagCompound>("data");

            SGAmodData.Add(self, tag3);
        }