////////////////

        public override int CompareTo(object obj)
        {
            if (this.Mod.Name == HamstarHelpersMod.Instance.Name)
            {
                return(-1);
            }

            if (obj != null && obj is UIModData)
            {
                var other = (UIModData)obj;

                try {
                    if (ModMetaDataManager.HasGithub(this.Mod) && !ModMetaDataManager.HasGithub(other.Mod))
                    {
                        return(-1);
                    }
                    if (ModMetaDataManager.HasConfig(this.Mod) && !ModMetaDataManager.HasConfig(other.Mod))
                    {
                        return(-1);
                    }
                } catch (Exception) { }

                return(string.Compare(this.Mod.Name, other.Mod.Name));
            }

            return(-1);
        }
Beispiel #2
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;
            });
        }
        public static void ReportIssue(Mod mod, string issue_title, string issue_body, Action <string> on_success, Action <Exception, string> on_error, Action on_completion = null)
        {
            if (!ModMetaDataManager.HasGithub(mod))
            {
                throw new Exception("Mod is not eligable for submitting issues.");
            }

            int max_lines = HamstarHelpersMod.Instance.Config.ModIssueReportErrorLogMaxLines;

            IEnumerable <Mod> mods        = ModHelpers.GetAllMods();
            string            body_info   = string.Join("\n \n", InfoHelpers.GetGameData(mods).ToArray());
            string            body_errors = string.Join("\n", InfoHelpers.GetErrorLog(max_lines).ToArray());

            string url   = "http://hamstar.pw/hamstarhelpers/issue_submit/";
            string title = "In-game: " + issue_title;
            string body  = body_info;

            body += "\n \n \n \n" + "Recent error logs:\n```\n" + body_errors + "\n```";
            body += "\n \n" + issue_body;

            var json = new GithubModIssueReportData {
                githubuser    = ModMetaDataManager.GetGithubUserName(mod),
                githubproject = ModMetaDataManager.GetGithubProjectName(mod),
                title         = title,
                body          = body
            };
            string json_str = JsonConvert.SerializeObject(json, Formatting.Indented);

            byte[] json_bytes = Encoding.UTF8.GetBytes(json_str);

            Action <String> on_response = (output) => {
                JObject resp_json = JObject.Parse(output);
                //JToken data = resp_json.SelectToken( "Data.html_url" );
                JToken msg = resp_json.SelectToken("Msg");

                /*if( data != null ) {
                 *      string post_at_url = data.ToObject<string>();
                 *      if( !string.IsNullOrEmpty( post_at_url ) ) {
                 *              SystemHelpers.Start( post_at_url );
                 *      }
                 * }*/

                if (msg == null)
                {
                    on_success("Failure.");
                }
                else
                {
                    on_success(msg.ToObject <string>());
                }
            };

            NetHelpers.NetHelpers.MakePostRequestAsync(url, json_bytes, on_response, on_error, on_completion);
        }
Beispiel #4
0
        ////////////////

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (!this.IsOpen)
            {
                return;
            }

            if (Main.playerInventory || Main.npcChatText != "")
            {
                this.Close();
                return;
            }

            if (this.OuterContainer.IsMouseHovering)
            {
                Main.LocalPlayer.mouseInterface = true;
            }

            if (this.AwaitingReport || this.CurrentModListItem == null || !ModMetaDataManager.HasGithub(this.CurrentModListItem.Mod))
            {
                this.DisableIssueInput();
            }
            else
            {
                this.EnableIssueInput();
            }

            if (this.ResetIssueInput)
            {
                this.ResetIssueInput = false;
                this.IssueTitleInput.SetText("");
                this.IssueBodyInput.SetText("");
            }

            if (this.SetDialogToClose)
            {
                this.SetDialogToClose = false;
                this.Close();
                return;
            }

            this.UpdateElements(HamstarHelpersMod.Instance);
        }
Beispiel #5
0
        ////////////////

        private void SelectModFromList(UIModData list_item)
        {
            Mod mod = list_item.Mod;

            if (this.CurrentModListItem != null)
            {
                this.Theme.ApplyListItem(this.CurrentModListItem);
            }
            this.Theme.ApplyListItemSelected(list_item);
            this.CurrentModListItem = list_item;

            this.Logic.SetCurrentMod(mod);

            if (!ModMetaDataManager.HasGithub(mod))
            {
                this.DisableIssueInput();
            }
            else
            {
                this.EnableIssueInput();
            }
        }