Ejemplo 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, string modloaderversion)
        {
            ModName     = name;
            DisplayName = displayName;
            DownloadUrl = downloadUrl;

            _author        = author;
            _modReferences = modReferences;
            _modSide       = modSide;
            _modIconUrl    = modIconUrl;
            if (UIModBrowser.AvoidImgur)
            {
                _modIconUrl = null;
            }
            _downloads        = downloads;
            _hot              = hot;
            _timeStamp        = timeStamp;
            HasUpdate         = hasUpdate;
            UpdateIsDowngrade = updateIsDowngrade;
            Installed         = installed;

            BorderColor        = new Color(89, 116, 213) * 0.7f;
            _dividerTexture    = UICommon.DividerTexture;
            _innerPanelTexture = UICommon.InnerPanelTexture;
            Height.Pixels      = 90;
            Width.Percent      = 1f;
            SetPadding(6f);

            float leftOffset = HasModIcon ? ModIconAdjust : 0f;

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

            _moreInfoButton = new UIImage(UICommon.ButtonModInfoTexture)
            {
                Width  = { Pixels = 36 },
                Height = { Pixels = 36 },
                Left   = { Pixels = leftOffset },
                Top    = { Pixels = 40 }
            };
            _moreInfoButton.OnClick += ViewModInfo;
            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 += 36 + PADDING;
                tMLUpdateRequired.OnClick     += (a, b) => {
                    Process.Start("https://github.com/tModLoader/tModLoader/releases/latest");
                };
                Append(tMLUpdateRequired);
            }
            else if (hasUpdate || installed == null)
            {
                _updateButton = new UIImage(UpdateIsDowngrade ? UICommon.ButtonDowngradeTexture : UICommon.ButtonDownloadTexture);
                _updateButton.CopyStyle(_moreInfoButton);
                _updateButton.Left.Pixels += 36 + PADDING;
                _updateButton.OnClick     += DownloadMod;
                Append(_updateButton);

                if (_modReferences.Length > 0)
                {
                    _updateWithDepsButton = new UIImage(UICommon.ButtonDownloadMultipleTexture);
                    _updateWithDepsButton.CopyStyle(_updateButton);
                    _updateWithDepsButton.Left.Pixels += 36 + PADDING;
                    _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 - PADDING, Percent = 1f }
                };
                modReferenceIcon.OnClick += ShowModDependencies;
                Append(modReferenceIcon);
            }

            OnDoubleClick += ViewModInfo;
        }
Ejemplo 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;
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
        public UIModDownloadItem(string displayname, string name, string version, string author, string modreferences, ModSide modside, string modIconURL, string download, int downloads, int hot, string timeStamp, bool update, bool updateIsDowngrade, LocalMod installed)
        {
            this.displayname       = displayname;
            this.mod               = name;
            this.version           = version;
            this.author            = author;
            this.modreferences     = modreferences;
            this.modside           = modside;
            this.modIconURL        = modIconURL;
            this.download          = download;
            this.downloads         = downloads;
            this.hot               = hot;
            this.timeStamp         = timeStamp;
            this.update            = update;
            this.updateIsDowngrade = updateIsDowngrade;
            this.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);

            left = HasModIcon ? 85f : 0f;
            string text = displayname + " " + version;

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

            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 (update || installed == null)
            {
                updateButton = new UIAutoScaleTextTextPanel <string>(this.update ? (updateIsDowngrade ? Language.GetTextValue("tModLoader.MBDowngrade") : Language.GetTextValue("tModLoader.MBUpdate")) : Language.GetTextValue("tModLoader.MBDownload"), 1f,
                                                                     false);
                updateButton.CopyStyle(moreInfoButton);
                updateButton.Width.Pixels = HasModIcon ? 120 : 200;
                updateButton.Left.Pixels  = moreInfoButton.Width.Pixels + moreInfoButton.Left.Pixels + 5f;
                updateButton.WithFadedMouseOver();
                updateButton.OnClick += DownloadMod;
                Append(updateButton);
            }
            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 = -149, Percent = 1f },
                    Top  = { Pixels = 48 }
                };
                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;
        }