Example #1
0
        public override int CompareTo(object obj)
        {
            UIWorldListItem uIWorldListItem = obj as UIWorldListItem;

            if (uIWorldListItem != null)
            {
                return(_orderInList.CompareTo(uIWorldListItem._orderInList));
            }
            return(base.CompareTo(obj));
        }
Example #2
0
        public override int CompareTo(object obj)
        {
            UIWorldListItem uIWorldListItem = obj as UIWorldListItem;

            if (uIWorldListItem != null)
            {
                if (IsFavorite && !uIWorldListItem.IsFavorite)
                {
                    return(-1);
                }
                if (!IsFavorite && uIWorldListItem.IsFavorite)
                {
                    return(1);
                }
                return(_data.Name.CompareTo(uIWorldListItem._data.Name));
            }
            return(base.CompareTo(obj));
        }
Example #3
0
        public override int CompareTo(object obj)
        {
            UIWorldListItem uiWorldListItem = obj as UIWorldListItem;

            if (uiWorldListItem == null)
            {
                return(base.CompareTo(obj));
            }
            if (this.IsFavorite && !uiWorldListItem.IsFavorite)
            {
                return(-1);
            }
            if (!this.IsFavorite && uiWorldListItem.IsFavorite)
            {
                return(1);
            }
            if (this._data.Name.CompareTo(uiWorldListItem._data.Name) != 0)
            {
                return(this._data.Name.CompareTo(uiWorldListItem._data.Name));
            }
            return(this._data.GetFileName(true).CompareTo(uiWorldListItem._data.GetFileName(true)));
        }
Example #4
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;
        }
Example #5
0
 private static void UIWorldListItemOnctor(On.Terraria.GameContent.UI.Elements.UIWorldListItem.orig_ctor orig, Terraria.GameContent.UI.Elements.UIWorldListItem self, WorldFileData data, int snappointindex)
 {
     orig(self, data, snappointindex);
     try
     {
         string path = Path.ChangeExtension(data.Path, ".twld");
         if (File.Exists(path))
         {
             var buf  = FileUtilities.ReadAllBytes(path, data.IsCloudSave);
             var tag  = TagIO.FromStream(new MemoryStream(buf));
             var list = tag.GetList <TagCompound>("modData").FirstOrDefault((TagCompound m) =>
                                                                            m.Get <string>("mod") == "TUA" && m.Get <string>("name") == "TUAWorld");
             if (list != null)
             {
                 TUAWorldData.Add(data.UniqueId, tag.GetList <TagCompound>("modData").FirstOrDefault((TagCompound m) =>
                                                                                                     m.Get <string>("mod") == "TUA" && m.Get <string>("name") == "TUAWorld"));
             }
         }
     }
     catch (Exception e)
     {
         ErrorLogger.Log(e.Message);
     }
 }