Beispiel #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;
        }
Beispiel #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;
        }