Beispiel #1
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Small;

            if (Widgets.ButtonText(new Rect(0, 15, 200, 20), Translator.Translate("CategoryFilter")))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (IconCategory c in Enum.GetValues(typeof(IconCategory)))
                {
                    list.Add(new FloatMenuOption(c.ToString(), delegate
                    {
                        category = c;
                        icons    = DefDatabase <IconDef> .AllDefs.Where(def => def.Category == category).ToList();
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }

            int  size               = icons.Count * 92;
            Rect scrollRectFact     = new Rect(0, 40, 190, 250);
            Rect scrollVertRectFact = new Rect(0, 0, scrollRectFact.x, size);

            Widgets.BeginScrollView(scrollRectFact, ref scrollPosition, scrollVertRectFact);
            int y = 0;

            foreach (IconDef icon in icons)
            {
                if (Widgets.ButtonImage(new Rect(0, y, 80, 80), icon.Texture))
                {
                    creator.CustomIcon = icon;
                }
                y += 90;
            }
            Widgets.EndScrollView();
        }
Beispiel #2
0
 /// <summary>
 /// 转换为图标分类数据传输对象
 /// </summary>
 /// <param name="entity">图标分类实体</param>
 public static IconCategoryDto ToDto(this IconCategory entity)
 {
     return(new IconCategoryDto {
         Id = entity.Id.ToString(),
         TenantId = entity.TenantId,
         Name = entity.Name,
         CreateTime = entity.CreateTime,
         SortId = entity.SortId,
         Version = entity.Version,
     });
 }
 public void Init()
 {
     _iconCategory = Create();
 }