Esempio n. 1
0
        public UIModDownloadItem(string displayName, string name, string version, string author, string modReferences, ModSide modSide, string modIconUrl, string downloadUrl, int downloads, int hot, string timeStamp, bool hasUpdate, bool updateIsDowngrade, LocalMod installed)
        {
            ModName     = name;
            DisplayName = displayName;
            DownloadUrl = downloadUrl;

            _version          = version;
            _author           = author;
            _modReferences    = modReferences;
            _modSide          = modSide;
            _modIconUrl       = modIconUrl;
            _downloads        = downloads;
            _hot              = hot;
            _timeStamp        = timeStamp;
            HasUpdate         = hasUpdate;
            UpdateIsDowngrade = updateIsDowngrade;
            Installed         = installed;

            BorderColor        = new Color(89, 116, 213) * 0.7f;
            _dividerTexture    = TextureManager.Load("Images/UI/Divider");
            _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            Height.Pixels      = 120;
            Width.Percent      = 1f;
            SetPadding(6f);

            float left = HasModIcon ? 85f : 0f;

            _modName = new UIText(displayName)
            {
                Left = new StyleDimension(left + 5, 0f),
                Top  = { Pixels = 5 }
            };
            Append(_modName);

            _authorText = new UIText(Language.GetTextValue("tModLoader.ModsByline", author))
            {
                Top = { Pixels = 83 }
            };
            Append(_authorText);

            if (_timeStamp != "0000-00-00 00:00:00")
            {
                try {
                    var    myDateTime = DateTime.Parse(_timeStamp);
                    string text       = TimeHelper.HumanTimeSpanString(myDateTime);
                    int    textWidth  = (int)Main.fontMouseText.MeasureString(text).X;
                    _authorText.Left.Set(125 + 5, 0f);
                }
                catch (Exception e) {
                    Logging.tML.Error(e.ToString());
                }
            }

            _moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo"))
            {
                Width  = { Pixels = 100 },
                Height = { Pixels = 36 },
                Left   = { Pixels = left },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();
            _moreInfoButton.PaddingTop    -= 2f;
            _moreInfoButton.PaddingBottom -= 2f;
            _moreInfoButton.OnClick       += RequestMoreInfo;
            Append(_moreInfoButton);

            if (hasUpdate || installed == null)
            {
                _updateButton = new UIAutoScaleTextTextPanel <string>(UpdateText).WithFadedMouseOver();
                _updateButton.CopyStyle(_moreInfoButton);
                _updateButton.Width.Pixels = 120;
                _updateButton.Left.Pixels  = _moreInfoButton.Width.Pixels + _moreInfoButton.Left.Pixels + 5f;
                _updateButton.OnClick     += DownloadMod;
                Append(_updateButton);

                if (_modReferences.Length > 0)
                {
                    _updateWithDepsButton = new UIAutoScaleTextTextPanel <string>(UpdateWithDepsText).WithFadedMouseOver();
                    _updateWithDepsButton.CopyStyle(_updateButton);
                    _updateWithDepsButton.Width.Pixels = 220;
                    _updateWithDepsButton.Left.Pixels  = _updateButton.Width.Pixels + _updateButton.Left.Pixels + 5f;
                    _updateWithDepsButton.OnClick     += DownloadWithDeps;
                    Append(_updateWithDepsButton);
                }
            }

            if (modReferences.Length > 0)
            {
                var icon             = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png"));
                var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.MBClickToViewDependencyMods", string.Join("\n", modReferences.Split(',').Select(x => x.Trim()))))
                {
                    Left = { Pixels = -icon.Width, Percent = 1f },
                    Top  = { Pixels = 83 }
                };
                modReferenceIcon.OnClick += (s, e) => {
                    var modListItem = (UIModDownloadItem)e.Parent;
                    Interface.modBrowser.SpecialModPackFilter      = modListItem._modReferences.Split(',').Select(x => x.Trim()).ToList();
                    Interface.modBrowser.SpecialModPackFilterTitle = Language.GetTextValue("tModLoader.MBFilterDependencies");                     // Toolong of \n" + modListItem.modName.Text;
                    Interface.modBrowser.FilterTextBox.Text        = "";
                    Interface.modBrowser.UpdateNeeded = true;
                    Main.PlaySound(SoundID.MenuOpen);
                };
                Append(modReferenceIcon);
            }

            OnDoubleClick += RequestMoreInfo;
        }
Esempio n. 2
0
        public UIModDownloadItem(string displayName, string name, string version, string author, string modReferences, ModSide modSide, string modIconUrl, string downloadUrl, int downloads, int hot, string timeStamp, bool hasUpdate, bool updateIsDowngrade, LocalMod installed, string modloaderversion)
        {
            ModName     = name;
            DisplayName = displayName;
            DownloadUrl = downloadUrl;

            _version          = version;
            _author           = author;
            _modReferences    = modReferences;
            _modSide          = modSide;
            _modIconUrl       = modIconUrl;
            _downloads        = downloads;
            _hot              = hot;
            _timeStamp        = timeStamp;
            HasUpdate         = hasUpdate;
            UpdateIsDowngrade = updateIsDowngrade;
            Installed         = installed;

            BorderColor        = new Color(89, 116, 213) * 0.7f;
            _dividerTexture    = TextureManager.Load("Images/UI/Divider");
            _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
            Height.Pixels      = 90;
            Width.Percent      = 1f;
            SetPadding(6f);

            float left = HasModIcon ? 85f : 0f;

            _modName = new UIText(displayName)
            {
                Left = new StyleDimension(left + 5, 0f),
                Top  = { Pixels = 5 }
            };
            Append(_modName);

            if (_timeStamp != "0000-00-00 00:00:00")
            {
                try {
                    var    myDateTime = DateTime.Parse(_timeStamp);
                    string text       = TimeHelper.HumanTimeSpanString(myDateTime);
                    int    textWidth  = (int)Main.fontMouseText.MeasureString(text).X;
                }
                catch (Exception e) {
                    Logging.tML.Error(e.ToString());
                }
            }

            _moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo"))
            {
                Width  = { Pixels = 100 },
                Height = { Pixels = 36 },
                Left   = { Pixels = left },
                Top    = { Pixels = 40 }
            }.WithFadedMouseOver();
            _moreInfoButton.PaddingTop    -= 2f;
            _moreInfoButton.PaddingBottom -= 2f;
            _moreInfoButton.OnClick       += RequestMoreInfo;
            Append(_moreInfoButton);

            if (modloaderversion != null)
            {
                tMLUpdateRequired = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MBRequiresTMLUpdate", modloaderversion)).WithFadedMouseOver(Color.Orange, Color.Orange * 0.7f);
                tMLUpdateRequired.BackgroundColor = Color.Orange * 0.7f;
                tMLUpdateRequired.CopyStyle(_moreInfoButton);
                tMLUpdateRequired.Width.Pixels = 340;
                tMLUpdateRequired.Left.Pixels  = _moreInfoButton.Width.Pixels + _moreInfoButton.Left.Pixels + 5f;
                tMLUpdateRequired.OnClick     += (a, b) => {
                    Process.Start("https://github.com/tModLoader/tModLoader/releases/latest");
                };
                Append(tMLUpdateRequired);
            }
            else if (hasUpdate || installed == null)
            {
                _updateButton            = new UIImage(UICommon.buttonDownloadTexture);
                _updateButton.Top.Pixels = 40;
                _updateButton.Left.Set(-166, 1f);
                _updateButton.OnClick += DownloadMod;
                Append(_updateButton);

                if (_modReferences.Length > 0)
                {
                    _updateButton.Left.Set(_updateButton.Left.Pixels - _updateButton.Width.Pixels - 6, 1f);
                    _updateWithDepsButton = new UIImage(UICommon.buttonDownloadMultipleTexture);
                    _updateWithDepsButton.CopyStyle(_updateButton);
                    _updateWithDepsButton.Left.Pixels = _updateButton.Width.Pixels + _updateButton.Left.Pixels + 5f;
                    _updateWithDepsButton.OnClick    += DownloadWithDeps;
                    Append(_updateWithDepsButton);
                }
            }

            if (modReferences.Length > 0)
            {
                var icon             = UICommon.buttonExclamationTexture;
                var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.MBClickToViewDependencyMods", string.Join("\n", modReferences.Split(',').Select(x => x.Trim()))))
                {
                    Left = { Pixels = -icon.Width, Percent = 1f }
                };
                modReferenceIcon.OnClick += (s, e) => {
                    var modListItem = (UIModDownloadItem)e.Parent;
                    Interface.modBrowser.SpecialModPackFilter      = modListItem._modReferences.Split(',').Select(x => x.Trim()).ToList();
                    Interface.modBrowser.SpecialModPackFilterTitle = Language.GetTextValue("tModLoader.MBFilterDependencies");                     // Toolong of \n" + modListItem.modName.Text;
                    Interface.modBrowser.FilterTextBox.Text        = "";
                    Interface.modBrowser.UpdateNeeded = true;
                    Main.PlaySound(SoundID.MenuOpen);
                };
                Append(modReferenceIcon);
            }

            OnDoubleClick += RequestMoreInfo;
        }