public UIButtonSubpanel(TS1GameScreen game, UICatFunc[] funcs) : base(game) { for (int i = 0; i < funcs.Length; i++) { var func = funcs[i]; var label = new UILabel(); label.Caption = func.Name; label.Alignment = TextAlignment.Middle | TextAlignment.Center; label.Wrapped = true; label.Position = new Vector2(-77, 106); label.Size = new Vector2(120, 1); label.CaptionStyle = label.CaptionStyle.Clone(); label.CaptionStyle.Size = 12; label.CaptionStyle.Color = UIStyle.Current.Text; Add(label); var subbutton = new UICatButton(Content.Get().CustomUI.Get(func.IconName).Get(GameFacade.GraphicsDevice)); subbutton.OnButtonClick += (btn) => { func.Func(); }; subbutton.Position = new Vector2(-50, 16); Add(subbutton); GameFacade.Screens.Tween.To(label, 0.5f, new Dictionary <string, float>() { { "X", 50 + i * 120f - 27 } }, TweenQuad.EaseOut); GameFacade.Screens.Tween.To(subbutton, 0.5f, new Dictionary <string, float>() { { "X", 50 + i * 120f } }, TweenQuad.EaseOut); GameFacade.Screens.Tween.To(this, 0.5f, new Dictionary <string, float>() { { "InitShow", 1f } }, TweenQuad.EaseOut); } InitShow = InitShow; }
public UIPickupPanel() { TitleLabel = new UILabel(); TitleLabel.Position = new Vector2(450, 14); TitleLabel.CaptionStyle = TitleLabel.CaptionStyle.Clone(); TitleLabel.CaptionStyle.Size = 19; TitleLabel.CaptionStyle.Color = UIStyle.Current.SecondaryText; Add(TitleLabel); SubtextLabel = new UILabel(); SubtextLabel.Position = new Vector2(450, 44); SubtextLabel.CaptionStyle = SubtextLabel.CaptionStyle.Clone(); SubtextLabel.CaptionStyle.Size = 12; SubtextLabel.CaptionStyle.Color = UIStyle.Current.Text; Add(SubtextLabel); CancelButton = new UICatButton(Content.Get().CustomUI.Get("cat_cancel.png").Get(GameFacade.GraphicsDevice)); CancelButton.Position = new Vector2(174, 31); CancelButton.OnButtonClick += CancelButton_OnButtonClick; Add(CancelButton); ClickHandler = ListenForMouse(new Rectangle(0, 0, 400, 128), new UIMouseEvent(OnMouseEvent)); }
public void InitCategory(sbyte category, bool build) { //start by populating with entries from the catalog if (!build) { ((UIMainPanel)Parent)?.Switcher?.MainButton?.RestoreImage(); } var catalog = Content.Get().WorldCatalog; var items = catalog.GetItemsByCategory(category); FullCategory = items.Select(x => new UICatalogElement() { Item = x, CalcPrice = (int)x.Price }).ToList(); //pull from other categories if (category == 15) { AddWallpapers(); } if (category == 14 || category == 16) { AddFloors(category); } if (category == 17) { AddRoofs(); } if (category == 18) { AddTerrainTools(); } FullCategory = FullCategory.OrderBy(x => (int)x.Item.Price).ToList(); if (category == 13) { AddWallStyles(); } //if we're not build mode, init the subcategory selection if (build) { return; } foreach (var btn in SelButtons) { Remove(btn); } foreach (var label in SelLabels) { Remove(label); } SelButtons.Clear(); SelLabels.Clear(); ChoosingSub = true; List <UICatalogSubcat> cats; if (Mode == UICatalogMode.Build) { cats = BuildCategories[category]; } else if (Mode != UICatalogMode.Normal) { cats = DTCategories[Mode]; if (cats.Count == 4) //haven't added other or all subcats yet { cats.Add(new UICatalogSubcat() { StrTable = 210, MaskBit = 7, StrInd = 1, //other }); cats.Add(new UICatalogSubcat() { StrTable = 210, MaskBit = 8, StrInd = 2, //all }); } } else { cats = Categories[category]; } var boff = CatContainer.Size.X / (cats.Count + 0.5f) / 2f; for (int i = 0; i < cats.Count; i++) { var cat = cats[i]; var str = GameFacade.Strings.GetString(cat.StrTable.ToString(), cat.StrInd.ToString()); var label = new UILabel(); label.Caption = str; label.Alignment = TextAlignment.Middle | TextAlignment.Center; label.Wrapped = true; label.Position = new Vector2(boff * (1.5f + i * 2) - (120 / 2), 106); label.Size = new Vector2(120, 1); label.CaptionStyle = label.CaptionStyle.Clone(); label.CaptionStyle.Size = 12; label.CaptionStyle.Color = UIStyle.Current.Text; SelLabels.Add(label); Add(label); var name = ""; if (Mode == UICatalogMode.Build) { name = BuildIcons[category][i]; } else if (Mode != UICatalogMode.Normal) { if (cat.MaskBit == 7) { name = "other"; } else if (cat.MaskBit == 8) { name = "all"; } else { name = DTIcons[Mode][cat.MaskBit]; } } else { if (cat.MaskBit == 7) { name = "other"; } else if (cat.MaskBit == 8) { name = "all"; } else { name = CatIcons[category][cat.MaskBit]; } } cat.IconName = name; var subbutton = new UICatButton(Content.Get().CustomUI.Get("cat_" + name + ".png").Get(GameFacade.GraphicsDevice)); subbutton.OnButtonClick += (btn) => { InitSubcategory(cat); }; subbutton.Position = new Vector2(boff * (1.5f + i * 2) - (65 / 2), 16); subbutton.Disabled = SubcatIsEmpty(cat); SelButtons.Add(subbutton); Add(subbutton); } //InitSubcategory(0); }