Пример #1
0
        public static bool HandleCrossPromotions(ref Rect canvas, ModMetaData mod)
        {
            if (!_enabled)
            {
                return(false);
            }

            if (!ModManager.Settings.ShowPromotions || !Manifest.For(mod).showCrossPromotions)
            {
                return(false);
            }

            if (mod.GetPublishedFileId() == PublishedFileId_t.Invalid)
            {
                return(false);
            }

            var author = AuthorForMod(mod.GetPublishedFileId());

            if (author == null)
            {
                return(false);
            }

            var promotions = ModsForAuthor(author.Value)?.Where(p => p.ShouldShow);

            if (promotions == null || !promotions.Any())
            {
                return(false);
            }

            if (Widgets.ButtonImage(
                    new Rect(canvas.xMax - SmallIconSize, canvas.yMin, SmallIconSize, SmallIconSize), Gear, Color.grey,
                    GenUI.MouseoverColor))
            {
                Utilities.OpenSettingsFor(ModManager.Instance);
            }
            Utilities.DoLabel(ref canvas, I18n.PromotionsFor(mod.Author));
            DrawCrossPromotions(ref canvas, promotions);
            return(true);
        }