Esempio n. 1
0
        ////////////////

        private void SubmitIssue()
        {
            if (this.CurrentModListItem == null)
            {
                return;
            }
            if (!ModMetaDataManager.HasGithub(this.CurrentModListItem.Mod))
            {
                return;
            }

            UIControlPanel self        = this;
            string         issue_title = this.IssueTitleInput.Text;
            string         issue_body  = this.IssueBodyInput.Text;

            if (string.IsNullOrEmpty(issue_title) || string.IsNullOrEmpty(issue_body))
            {
                return;
            }

            this.AwaitingReport = true;
            this.DisableIssueInput();

            self.Logic.ReportIssue(self.CurrentModListItem.Mod, issue_title, issue_body, delegate {
                self.AwaitingReport   = false;
                self.ResetIssueInput  = true;
                self.SetDialogToClose = true;
            });
        }
Esempio n. 2
0
        ////////////////

        public UIModData CreateModListItem(int i, Mod mod)
        {
            UIControlPanel self = this;
            var            elem = new UIModData(this.Theme, i, mod, false);

            this.Theme.ApplyListItem(elem);

            elem.OnMouseOver += delegate(UIMouseEvent evt, UIElement from_elem) {
                if (!(from_elem is UIModData))
                {
                    return;
                }

                if (self.Logic.CurrentMod != null && elem.Mod.Name == self.Logic.CurrentMod.Name)
                {
                    return;
                }

                self.Theme.ApplyListItemLit(elem);
            };
            elem.OnMouseOut += delegate(UIMouseEvent evt, UIElement from_elem) {
                if (!(from_elem is UIModData))
                {
                    return;
                }
                if (self.Logic.CurrentMod != null && elem.Mod.Name == self.Logic.CurrentMod.Name)
                {
                    return;
                }

                self.Theme.ApplyListItem(elem);
            };

            elem.OnClick += delegate(UIMouseEvent evt, UIElement from_elem) {
                if (!(from_elem is UIModData))
                {
                    return;
                }
                if (self.Logic.CurrentMod != null && elem.Mod.Name == self.Logic.CurrentMod.Name)
                {
                    return;
                }
                if (self.AwaitingReport)
                {
                    return;
                }

                self.SelectModFromList(elem);
            };

            return(elem);
        }
Esempio n. 3
0
        ////////////////

        private void InitializeComponents()
        {
            UIControlPanel    self  = this;
            ControlPanelLogic logic = this.Logic;
            var   mymod             = HamstarHelpersMod.Instance;
            float top = 0;

            this.OuterContainer = new UIElement();
            this.OuterContainer.Width.Set(UIControlPanel.ContainerWidth, 0f);
            this.OuterContainer.Height.Set(UIControlPanel.ContainerHeight, 0f);
            this.OuterContainer.MaxWidth.Set(UIControlPanel.ContainerWidth, 0f);
            this.OuterContainer.MaxHeight.Set(UIControlPanel.ContainerHeight, 0f);
            this.OuterContainer.HAlign = 0f;
            //this.MainElement.BackgroundColor = ControlPanelUI.MainBgColor;
            //this.MainElement.BorderColor = ControlPanelUI.MainEdgeColor;
            this.Append(this.OuterContainer);

            this.RecalculateContainer();

            this.InnerContainer = new UIPanel();
            this.InnerContainer.Width.Set(0f, 1f);
            this.InnerContainer.Height.Set(0f, 1f);
            this.OuterContainer.Append((UIElement)this.InnerContainer);

            this.Theme.ApplyPanel(this.InnerContainer);


            ////////

            this.DialogClose = new UITextPanelButton(this.Theme, "X");
            this.DialogClose.Top.Set(-8f, 0f);
            this.DialogClose.Left.Set(-16f, 1f);
            this.DialogClose.Width.Set(24f, 0f);
            this.DialogClose.Height.Set(24f, 0f);
            this.DialogClose.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) {
                self.Close();
                Main.PlaySound(SoundID.MenuClose);
            };
            this.DialogClose.OnMouseOver += delegate(UIMouseEvent evt, UIElement listening_element) {
                self.Theme.ApplyButtonLit(self.DialogClose);
            };
            this.DialogClose.OnMouseOut += delegate(UIMouseEvent evt, UIElement listening_element) {
                self.Theme.ApplyButton(self.DialogClose);
            };
            this.InnerContainer.Append(this.DialogClose);

            ////

            var tip = new UIText("To enable issue reports for your mod, ");

            this.InnerContainer.Append((UIElement)tip);

            var tip_url = new UIWebUrl(this.Theme, "read this.",
                                       "https://forums.terraria.org/index.php?threads/mod-helpers-a-modders-mod-for-mods-and-modding.63670/#modders",
                                       true, 1f);

            tip_url.Left.Set(tip.GetInnerDimensions().Width, 0f);
            tip_url.Top.Set(-2f, 0f);
            this.InnerContainer.Append((UIElement)tip_url);

            top += 24f;

            ////

            var mod_list_panel = new UIPanel();

            {
                mod_list_panel.Top.Set(top, 0f);
                mod_list_panel.Width.Set(0f, 1f);
                mod_list_panel.Height.Set(UIControlPanel.ModListHeight, 0f);
                mod_list_panel.HAlign = 0f;
                mod_list_panel.SetPadding(4f);
                mod_list_panel.PaddingTop      = 0.0f;
                mod_list_panel.BackgroundColor = this.Theme.ListBgColor;
                mod_list_panel.BorderColor     = this.Theme.ListEdgeColor;
                this.InnerContainer.Append((UIElement)mod_list_panel);

                this.ModListElem = new UIList();
                {
                    this.ModListElem.Width.Set(-25, 1f);
                    this.ModListElem.Height.Set(0f, 1f);
                    this.ModListElem.HAlign      = 0f;
                    this.ModListElem.ListPadding = 4f;
                    this.ModListElem.SetPadding(0f);
                    mod_list_panel.Append((UIElement)this.ModListElem);

                    top += UIControlPanel.ModListHeight + this.InnerContainer.PaddingTop;

                    UIScrollbar scrollbar = new UIScrollbar();
                    {
                        scrollbar.Top.Set(8f, 0f);
                        scrollbar.Height.Set(-16f, 1f);
                        scrollbar.SetView(100f, 1000f);
                        scrollbar.HAlign = 1f;
                        mod_list_panel.Append((UIElement)scrollbar);
                        this.ModListElem.SetScrollbar(scrollbar);
                    }
                }
            }

            ////

            this.IssueTitleInput = new UITextArea(this.Theme, "Enter title of mod issue", 128);
            this.IssueTitleInput.Top.Set(top, 0f);
            this.IssueTitleInput.Width.Set(0f, 1f);
            this.IssueTitleInput.Height.Pixels = 36f;
            this.IssueTitleInput.HAlign        = 0f;
            this.IssueTitleInput.SetPadding(8f);
            this.IssueTitleInput.Disable();
            this.IssueTitleInput.OnPreChange += delegate(StringBuilder new_text) {
                self.RefreshIssueSubmitButton();
            };
            this.InnerContainer.Append((UIElement)this.IssueTitleInput);

            top += 40f;

            this.IssueBodyInput = new UITextArea(this.Theme, "Describe mod issue");
            this.IssueBodyInput.Top.Set(top, 0f);
            this.IssueBodyInput.Width.Set(0f, 1f);
            this.IssueBodyInput.Height.Pixels = 36f;
            this.IssueBodyInput.HAlign        = 0f;
            this.IssueBodyInput.SetPadding(8f);
            this.IssueBodyInput.Disable();
            this.IssueBodyInput.OnPreChange += delegate(StringBuilder new_text) {
                self.RefreshIssueSubmitButton();
            };
            this.InnerContainer.Append((UIElement)this.IssueBodyInput);

            top += 40f;

            ////

            this.IssueSubmitButton = new UITextPanelButton(this.Theme, "Submit Issue");
            this.IssueSubmitButton.Top.Set(top, 0f);
            this.IssueSubmitButton.Left.Set(0f, 0f);
            this.IssueSubmitButton.Width.Set(200f, 0f);
            this.IssueSubmitButton.Disable();
            this.IssueSubmitButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) {
                if (self.AwaitingReport || !self.IssueSubmitButton.IsEnabled)
                {
                    return;
                }
                self.SubmitIssue();
            };
            this.InnerContainer.Append(this.IssueSubmitButton);

            this.ApplyConfigButton = new UITextPanelButton(this.Theme, "Apply Config Changes");
            this.ApplyConfigButton.Top.Set(top, 0f);
            this.ApplyConfigButton.Left.Set(0f, 0f);
            this.ApplyConfigButton.Width.Set(200f, 0f);
            this.ApplyConfigButton.HAlign = 1f;
            if (Main.netMode != 0)
            {
                this.ApplyConfigButton.Disable();
            }
            this.ApplyConfigButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) {
                if (!self.ApplyConfigButton.IsEnabled)
                {
                    return;
                }
                self.ApplyConfigChanges(HamstarHelpersMod.Instance);
            };
            this.InnerContainer.Append(this.ApplyConfigButton);

            top += 30f;

            this.ModLockButton = new UITextPanelButton(this.Theme, UIControlPanel.ModLockTitle);
            this.ModLockButton.Top.Set(top, 0f);
            this.ModLockButton.Left.Set(0f, 0f);
            this.ModLockButton.Width.Set(0f, 1f);
            if (Main.netMode != 0 || !mymod.Config.WorldModLockEnable)
            {
                this.ModLockButton.Disable();
            }
            this.ModLockButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) {
                if (!self.ModLockButton.IsEnabled)
                {
                    return;
                }
                self.ToggleModLock(HamstarHelpersMod.Instance);
                Main.PlaySound(SoundID.Unlock);
            };
            this.InnerContainer.Append(this.ModLockButton);

            this.RefreshModLockButton(mymod);

            top += 36f;

            ////

            var modrec_url = new UIWebUrl(this.Theme, "Need mods?", "https://sites.google.com/site/terrariamodsuggestions/");

            modrec_url.Top.Set(top, 0f);
            modrec_url.Left.Set(0f, 0f);
            this.InnerContainer.Append(modrec_url);

            var serverbrowser_url = new UIWebUrl(this.Theme, "Lonely?", "https://forums.terraria.org/index.php?threads/server-browser-early-beta.68346/");

            serverbrowser_url.Top.Set(top, 0f);
            this.InnerContainer.Append(serverbrowser_url);
            serverbrowser_url.Left.Set(-serverbrowser_url.GetDimensions().Width * 0.5f, 0.5f);

            var support_url = new UIWebUrl(this.Theme, "Support my mods!", "https://www.patreon.com/hamstar0");

            support_url.Top.Set(top, 0f);
            this.InnerContainer.Append(support_url);
            support_url.Left.Set(-support_url.GetDimensions().Width, 1f);
        }