public void SubmitTags()
        {
            if (string.IsNullOrEmpty(this.CurrentModName))
            {
                UIState prevMenuUI = MenuContextService.GetPreviousMenuUI();
                UIState currMenuUI = MenuContextService.GetCurrentMenuUI();
                this.CurrentModName = ModMenuHelpers.GetModName(prevMenuUI, currMenuUI) ?? "";

                if (string.IsNullOrEmpty(this.CurrentModName))
                {
                    throw new ModHelpersException("Invalid mod name.");
                }
            }

            Action <Exception, string> onError = (e, output) => {
                this.SetInfoText("Error: " + (string.IsNullOrEmpty(output) ? e.Message : output), Color.Red);
                LogHelpers.Log(e.ToString());
            };

            ISet <string> newTags = this.GetTagsWithGivenState(1);

            // Update snapshot of tags for the given mod (locally)
            if (this.AllModTagsSnapshot != null)
            {
                this.AllModTagsSnapshot[this.CurrentModName] = newTags;
            }

            PostModInfo.SubmitModInfo(this.CurrentModName, newTags, onError, this.PostSubmitTags);

            ModTagsManager.RecentTaggedMods.Add(this.CurrentModName);
        }
Пример #2
0
        ////////////////

        private void PopulateList(string modName)
        {
            string currModName = ModMenuHelpers.GetModName(MenuContextService.GetPreviousMenuUI(),
                                                           this.MyUI ?? MenuContextService.GetCurrentMenuUI());

            if (modName != currModName)
            {
                return;
            }

            this.RecommendsList.Clear();

            string err = "";
            IList <Tuple <string, string> > recommends = this.GetRecommendsFromActiveMod(modName) ??
                                                         this.GetRecommendsFromUI(modName, ref err);

            if (string.IsNullOrEmpty(err))
            {
                this.RecommendsList.AddModEntriesAsync(modName, recommends.Take(ModRecommendsMenuContext.Limit));
            }
            else
            {
                LogHelpers.Log("!ModHelpers.ModRecommendsMenuContext.PopulateList - " + err);
            }
        }
Пример #3
0
        ////////////////

        private void ShowGeneral(UIState ui)
        {
            string modName = ModMenuHelpers.GetModName(MenuContextService.GetCurrentMenuUI(), ui);

            this.InfoDisplay.SetDefaultText("");

            if (modName == null)
            {
                LogHelpers.Warn("Could not load mod tags; no mod found");
            }
            else
            {
                this.ResetUIState(modName);
                this.SetCurrentMod(ui, modName);
                this.RecalculateMenuObjects();
            }


            UIElement elem;

            if (ReflectionHelpers.Get(ui, "uIElement", out elem))
            {
                elem.Left.Pixels += UITagButton.ColumnWidth;
                elem.Recalculate();
            }
        }
        internal void SubmitTags()
        {
            if (string.IsNullOrEmpty(this.CurrentModName))
            {
                this.CurrentModName = ModMenuHelpers.GetModName(MenuContextService.GetPreviousMenuUI(), MenuContextService.GetCurrentMenuUI())
                                      ?? "";
                if (string.IsNullOrEmpty(this.CurrentModName))
                {
                    throw new HamstarException("Invalid mod name.");
                }
            }

            Action <string> onSuccess = delegate(string output) {
                this.InfoDisplay?.SetText(output, Color.Lime);
                ErrorLogger.Log("Mod info submit result: " + output);
            };

            Action <Exception, string> onFail = (e, output) => {
                this.InfoDisplay?.SetText("Error: " + (string.IsNullOrEmpty(output)?e.Message:output), Color.Red);
                LogHelpers.Log(e.ToString());
            };

            ISet <string> newTags = this.GetTagsOfState(1);

            // Update snapshot of tags for the given mod (locally)
            if (this.AllModTagsSnapshot != null)
            {
                this.AllModTagsSnapshot[this.CurrentModName] = newTags;
            }

            PostModInfo.SubmitModInfo(this.CurrentModName, newTags, onSuccess, onFail);

            this.FinishButton.Lock();
            this.ResetButton.Lock();
        }
Пример #5
0
        ////////////////

        public void AddModEntriesAsync(string forModName, IEnumerable <Tuple <string, string> > recomMods)
        {
            foreach (var recomMod in recomMods)
            {
                string recomModName       = recomMod.Item1;
                string recommendedBecause = recomMod.Item2;

                Mod mod = ModLoader.GetMod(recomModName);

                this.AddRawModEntry(mod?.DisplayName, recomModName, recommendedBecause);
            }

            Promises.AddValidatedPromise <ModInfoListPromiseArguments>(GetModInfo.ModInfoListPromiseValidator, (args) => {
                string currModName = ModMenuHelpers.GetModName(MenuContextService.GetPreviousMenuUI(),
                                                               this.MenuContext.MyUI ?? MenuContextService.GetCurrentMenuUI());

                // Validate we're in the same UI
                if (this.MenuContext.MyUI.GetType().Name != "UIModInfo")
                {
                    return(false);
                }
                // Validate we're viewing the mod we started with
                if (forModName != currModName)
                {
                    return(false);
                }

                this.List.RemoveAllChildren();
                this.ModNameList.Clear();

                foreach (var recomMod in recomMods)
                {
                    string recomModName       = recomMod.Item1;
                    string recommendedBecause = recomMod.Item2;

                    if (args.ModInfo.ContainsKey(recomModName))
                    {
                        this.AddModEntry(args.ModInfo[recomModName].DisplayName, recomModName, recommendedBecause);
                    }
                    else
                    {
                        this.AddRawModEntry(null, recomModName, recommendedBecause);
                    }
                }

                return(false);
            });

            this.EmptyText.Remove();
            this.Recalculate();
        }
Пример #6
0
        ////////////////

        public override void Show(UIState ui)
        {
            base.Show(ui);

            string modName = ModMenuHelpers.GetModName(MenuContextService.GetCurrentMenuUI(), ui);

            if (modName == null)
            {
                LogHelpers.Log("Could not load mod recommendations; no mod found.");
                return;
            }

            this.PopulateList(modName);
        }
        public override void Show(UIState ui)
        {
            base.Show(ui);

            UIState prevUi = MenuContextService.GetCurrentMenuUI();

            if (prevUi == ui)
            {
                prevUi = MenuContextService.GetPreviousMenuUI();
            }

            string modName = ModMenuHelpers.GetModName(prevUi, ui);

            this.InfoDisplay.SetDefaultText("");
            this.MyManager.MyTagsUI.ResetTagButtonOnStates(true);

            if (modName == null)
            {
                LogHelpers.Warn("Could not load mod tags; no mod found");
                return;
            }

            this.MyManager.SetCurrentModAsync(modName);
        }