public MoneyEditor(DwarfGUI gui, GUIComponent parent, bool editable, float maxmoney, float currentMoney) : base(gui, parent) { MaxMoney = maxmoney; GridLayout layout = new GridLayout(GUI, this, 1, 5); Editor = new LineEdit(GUI, layout, "0") { TextMode = LineEdit.Mode.Numeric, Prefix = "$", IsEditable = editable }; CurrentMoney = currentMoney; Editor.OnTextModified += Editor_OnTextModified; layout.SetComponentPosition(Editor, 2, 0, 3, 1); Image = new ImagePanel(GUI, layout, new NamedImageFrame(ContentPaths.Entities.DwarfObjects.coinpiles, 32, 1, 0)) { KeepAspectRatio = true, ConstrainSize = true }; layout.SetComponentPosition(Image, 0, 0, 1, 1); Text = new Label(GUI, layout, "Money: ", GUI.SmallFont) { WordWrap = false, Truncate = false }; layout.SetComponentPosition(Text, 1, 0, 1, 1); }
private void SetupBuildItemTab() { BuildItemTab = new BuildTab { Tab = Selector.AddTab("Objects") }; BuildItemTab.SelectedResourceBoxes = new List <ComboBox>(); CreateBuildTab(BuildItemTab, BuildType.Item); BuildItemTab.BuildButton.OnClicked += BuildItemButton_OnClicked; List <CraftItem> items = CraftLibrary.CraftItems.Values.Where(item => item.Type == CraftItem.CraftType.Object).ToList(); int numItems = items.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildItemTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (CraftItem itemType in items) { CraftItem item = itemType; GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; if (i == 0) { ItemTabOnClicked(item); } itemLayout.OnClicked += () => ItemTabOnClicked(item); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, itemLayout, item.Image) { KeepAspectRatio = true, MinWidth = 32, MinHeight = 32 }; itemLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, itemLayout, item.Name, GUI.SmallFont) { ToolTip = item.Description }; itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public void SetupSpellTab() { KnownSpellTab = new MagicTab { Tab = SpellsTab }; CreateMagicTab(KnownSpellTab); //BuildItemTab.BuildButton.OnClicked += BuildItemButton_OnClicked; List <Spell> spells = Master.Spells.GetKnownSpells(); int numItems = spells.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, KnownSpellTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (Spell spell in spells) { Spell currSpell = spell; GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; itemLayout.OnClicked += () => ItemTabOnClicked(currSpell); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, itemLayout, spell.Image) { KeepAspectRatio = true, ConstrainSize = true, MinWidth = 32, MinHeight = 32 }; itemLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, itemLayout, spell.Name, GUI.SmallFont) { ToolTip = spell.Description }; itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public void SetupBuildRoomTab() { BuildRoomTab = new BuildTab() { Tab = Selector.AddTab("Rooms") }; CreateBuildTab(BuildRoomTab); BuildRoomTab.BuildButton.OnClicked += BuildRoomButton_OnClicked; List <string> roomTypes = RoomLibrary.GetRoomTypes().ToList(); int numRooms = roomTypes.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildRoomTab.Scroller, numRooms, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numRooms), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (string roomType in roomTypes) { RoomData room = RoomLibrary.GetData(roomType); GridLayout roomLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; roomLayout.OnClicked += () => RoomTabOnClicked(room); int i1 = i; roomLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(roomLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, roomLayout, room.Icon) { KeepAspectRatio = true }; roomLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, roomLayout, room.Name, GUI.SmallFont) { ToolTip = room.Description }; roomLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public void Initialize(List <SpriteSheet> sprites) { Images = new List <NamedImageFrame>(); foreach (SpriteSheet sprite in sprites) { Images.AddRange(sprite.GenerateFrames()); } if (Images.Count > 0) { DefaultTexture = Images.First(); } OnTextureSelected += TextureLoadDialog_OnTextureSelected; int rc = Math.Max((int)(Math.Round(Math.Sqrt(Images.Count) + 0.5f)), 2); if (SpriteLayout == null) { SpriteLayout = new GridLayout(GUI, Layout, rc, rc) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed }; } else { RemoveChild(SpriteLayout); SpriteLayout = new GridLayout(GUI, Layout, rc, rc) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed }; } Layout.SetComponentPosition(SpriteLayout, 0, 1, 4, 2); Layout.UpdateSizes(); for (int i = 0; i < Images.Count; i++) { ImagePanel img = new ImagePanel(GUI, SpriteLayout, Images[i]) { Highlight = true, KeepAspectRatio = true, AssetName = Images[i].AssetName, ConstrainSize = true }; int row = i / rc; int col = i % rc; NamedImageFrame texFile = Images[i]; img.OnClicked += () => img_OnClicked(texFile); SpriteLayout.SetComponentPosition(img, col, row, 1, 1); } }
public void Initialize(Texture2D image, string directory) { DefaultTexture = image; TextureLoader = new TextureLoader(directory, GUI.Graphics); Textures = TextureLoader.GetTextures(); TextureLoader.TextureFile defaultFile = new TextureLoader.TextureFile(DefaultTexture, "Default"); Textures.Insert(0, defaultFile); OnTextureSelected += TextureLoadDialog_OnTextureSelected; int rc = Math.Max((int)(Math.Sqrt(Textures.Count)), 2); if (Layout == null) { Layout = new GridLayout(GUI, this, rc + 1, rc); } else { RemoveChild(Layout); Layout = new GridLayout(GUI, this, rc + 1, rc); } if (DirLabel == null) { Label dirLabel = new Label(GUI, Layout, "Images from: " + TextureLoader.Folder, GUI.DefaultFont); DirLabel = dirLabel; } else { DirLabel.Text = "Images from: " + TextureLoader.Folder; Layout.AddChild(DirLabel); } Layout.SetComponentPosition(DirLabel, 0, 0, 1, 1); for (int i = 0; i < Textures.Count; i++) { ImagePanel img = new ImagePanel(GUI, Layout, Textures[i].Texture); img.Highlight = true; img.KeepAspectRatio = true; int row = i / rc; int col = i % rc; TextureLoader.TextureFile texFile = Textures[i]; img.OnClicked += delegate { img_OnClicked(texFile); }; Layout.SetComponentPosition(img, col, row + 1, 1, 1); } }
public void CreateResourcePanels() { Layout.ClearChildren(); int numItems = CurrentResources.Count; int wItems = LocalBounds.Width / PanelWidth - 1; int hItems = LocalBounds.Height / PanelHeight; Layout.Rows = hItems; Layout.Cols = wItems; int itemIndex = 0; for (int i = 0; i < numItems; i++) { ResourceAmount amount = CurrentResources[i]; if (amount.NumResources == 0) { continue; } int r = itemIndex / wItems; int c = itemIndex % wItems; ImagePanel panel = new ImagePanel(GUI, Layout, amount.ResourceType.Image) { KeepAspectRatio = true, ToolTip = amount.ResourceType.ResourceName + "\n" + amount.ResourceType.Description }; Layout.SetComponentPosition(panel, c, r, 1, 1); Label panelLabel = new Label(GUI, panel, amount.NumResources.ToString(CultureInfo.InvariantCulture), GUI.SmallFont) { Alignment = Drawer2D.Alignment.Bottom, LocalBounds = new Rectangle(0, 0, PanelWidth, PanelHeight), TextColor = Color.White }; itemIndex++; } }
public void Initialize(List<SpriteSheet> sprites) { Images = new List<NamedImageFrame>(); foreach (SpriteSheet sprite in sprites) { Images.AddRange(sprite.GenerateFrames()); } if (Images.Count > 0) { DefaultTexture = Images.First(); } OnTextureSelected += TextureLoadDialog_OnTextureSelected; int rc = Math.Max((int)(Math.Round(Math.Sqrt(Images.Count) + 0.5f)), 2); if (SpriteLayout == null) { SpriteLayout = new GridLayout(GUI, Layout, rc, rc) {WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed}; } else { RemoveChild(SpriteLayout); SpriteLayout = new GridLayout(GUI, Layout, rc, rc) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed }; } Layout.SetComponentPosition(SpriteLayout, 0, 1, 4, 2); Layout.UpdateSizes(); for (int i = 0; i < Images.Count; i++) { ImagePanel img = new ImagePanel(GUI, SpriteLayout, Images[i]) { Highlight = true, KeepAspectRatio = true, AssetName = Images[i].AssetName, ConstrainSize = true}; int row = i / rc; int col = i % rc; NamedImageFrame texFile = Images[i]; img.OnClicked += () => img_OnClicked(texFile); SpriteLayout.SetComponentPosition(img, col, row, 1, 1); } }
public GUIComponent CreateItem(Column columnType, GItem item, int row, int column) { string tooltip = item.ResourceType.Type + "\n" + item.ResourceType.Description + "\n" + item.ResourceType.GetTagDescription(" , "); if (item.ResourceType.FoodContent > 0) { tooltip += "\n" + item.ResourceType.FoodContent + " energy"; } switch (columnType) { case Column.Amount: Label amountLabel = new Label(GUI, Layout, item.CurrentAmount.ToString(), GUI.SmallFont) { ToolTip = "Total Amount", Alignment = Drawer2D.Alignment.Right }; Layout.SetComponentPosition(amountLabel, column, row, 1, 1); return(amountLabel); case Column.Image: ImagePanel image = new ImagePanel(GUI, Layout, item.Image) { KeepAspectRatio = true, ConstrainSize = true, Tint = item.Tint, ToolTip = tooltip, }; Layout.SetComponentPosition(image, column, row, 1, 1); return(image); case Column.Name: Label label = new Label(GUI, Layout, item.Name, GUI.SmallFont) { ToolTip = tooltip }; Layout.SetComponentPosition(label, column, row, 1, 1); return(label); case Column.PricePerItem: Label priceLabel = new Label(GUI, Layout, GetPrice(item).ToString("C"), GUI.SmallFont) { ToolTip = "Price per item", }; Layout.SetComponentPosition(priceLabel, column, row, 1, 1); return(priceLabel); case Column.TotalPrice: Label totalLabel = new Label(GUI, Layout, (GetPrice(item) * item.CurrentAmount).ToString("C"), GUI.SmallFont) { ToolTip = "Total price" }; Layout.SetComponentPosition(totalLabel, column, row, 1, 1); return(totalLabel); case Column.ArrowRight: ImagePanel panel = new ImagePanel(GUI, Layout, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowRight)) { KeepAspectRatio = true, ConstrainSize = true }; Layout.SetComponentPosition(panel, column, row, 1, 1); return(panel); case Column.ArrowLeft: ImagePanel panelLeft = new ImagePanel(GUI, Layout, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowLeft)) { KeepAspectRatio = true, ConstrainSize = true }; Layout.SetComponentPosition(panelLeft, column, row, 1, 1); return(panelLeft); } return(null); }
public void UpdateItem(Column columnType, int row, int column) { Rectangle key = new Rectangle(column, row, 1, 1); if (!Layout.ComponentPositions.ContainsKey(key)) { return; } GItem item = FilteredItems[row - 1]; GUIComponent component = Layout.ComponentPositions[key]; string tooltip = item.ResourceType.Type + "\n" + item.ResourceType.Description + "\n" + item.ResourceType.GetTagDescription(" , "); if (item.ResourceType.FoodContent > 0) { tooltip += "\n" + item.ResourceType.FoodContent + " energy"; } switch (columnType) { case Column.Amount: Label amountLabel = component as Label; if (amountLabel == null) { break; } amountLabel.Text = item.CurrentAmount.ToString(); break; case Column.Image: ImagePanel image = component as ImagePanel; if (image == null) { break; } image.Image = item.Image; image.Tint = item.Tint; image.ToolTip = tooltip; break; case Column.Name: Label label = component as Label; if (label == null) { break; } label.Text = item.Name; label.ToolTip = tooltip; break; case Column.PricePerItem: Label priceLabel = component as Label; if (priceLabel == null) { break; } float price = GetPrice(item); priceLabel.Text = price.ToString("C"); break; case Column.TotalPrice: Label totalpriceLabel = component as Label; if (totalpriceLabel == null) { break; } totalpriceLabel.Text = (item.CurrentAmount * GetPrice(item)).ToString("C"); break; } }
public void CreateResourcePanels() { Layout.ClearChildren(); int numItems = CurrentResources.Count; int wItems = LocalBounds.Width / PanelWidth - 1; int hItems = LocalBounds.Height / PanelHeight; Layout.Rows = hItems; Layout.Cols = wItems; List <ImagePanel> panels = new List <ImagePanel>(); List <int> counts = new List <int>(); List <Label> labels = new List <Label>(); int itemIndex = 0; for (int i = 0; i < numItems; i++) { ResourceAmount amount = CurrentResources[i]; if (amount.NumResources == 0) { continue; } bool exists = false; int k = 0; foreach (ImagePanel imgPanel in panels) { if (imgPanel.Image.Equals(amount.ResourceType.Image)) { imgPanel.ToolTip = imgPanel.ToolTip + "\n" + "* " + amount.NumResources.ToString() + " " + amount.ResourceType.ResourceName + "\n" + amount.ResourceType.Description + "\n Props: " + amount.ResourceType.GetTagDescription(", "); exists = true; counts[k] += amount.NumResources; labels[k].Text = counts[k].ToString(); break; } k++; } if (exists) { continue; } int r = itemIndex / wItems; int c = itemIndex % wItems; ImagePanel panel = new ImagePanel(GUI, Layout, amount.ResourceType.Image) { KeepAspectRatio = true, ToolTip = "* " + amount.NumResources.ToString() + " " + amount.ResourceType.ResourceName + "\n" + amount.ResourceType.Description + "\n Props: " + amount.ResourceType.GetTagDescription(", "), Tint = amount.ResourceType.Tint }; Layout.SetComponentPosition(panel, c, r, 1, 1); Label panelLabel = new Label(GUI, panel, amount.NumResources.ToString(CultureInfo.InvariantCulture), GUI.SmallFont) { Alignment = Drawer2D.Alignment.Bottom, LocalBounds = new Rectangle(0, 0, PanelWidth, PanelHeight), TextColor = Color.White }; panels.Add(panel); labels.Add(panelLabel); counts.Add(amount.NumResources); itemIndex++; } }
private void SetupBuildResourceTab() { bool hasCook = Build.HasFlag(BuildType.Cook); string name = Build.HasFlag(BuildType.Cook) ? "Food" : "Crafts"; BuildResourceTab = new BuildTab { Tab = Selector.AddTab(name), SelectedResourceBoxes = new List <ComboBox>() }; CreateBuildTab(BuildResourceTab, hasCook ? BuildType.Cook : BuildType.Craft); BuildResourceTab.BuildButton.OnClicked += BuildResource_OnClicked; List <CraftItem> items = CraftLibrary.CraftItems.Values.Where(item => item.Type == CraftItem.CraftType.Resource).ToList(); int numItems = items.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildResourceTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (CraftItem itemType in items) { CraftItem item = itemType; bool isEdible = ResourceLibrary.Resources.ContainsKey(item.ResourceCreated) && ResourceLibrary.Resources[item.ResourceCreated].Tags.Contains(Resource.ResourceTags.Edible); if (!hasCook && isEdible) { continue; } else if (hasCook && !isEdible) { continue; } GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; if (i == 0) { ResourceTabOnClicked(item); } itemLayout.OnClicked += () => ResourceTabOnClicked(item); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, itemLayout, item.Image) { KeepAspectRatio = true, MinWidth = 32, MinHeight = 32 }; itemLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, itemLayout, item.Name, GUI.SmallFont) { ToolTip = item.Description }; itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public GUIComponent CreateItem(Column columnType, GItem item, int row, int column) { switch (columnType) { case Column.Amount: Label amountLabel = new Label(GUI, Layout, item.CurrentAmount.ToString(), GUI.SmallFont) { ToolTip = "Total Amount" }; Layout.SetComponentPosition(amountLabel, column, row, 1, 1); return(amountLabel); case Column.Image: ImagePanel image = new ImagePanel(GUI, Layout, item.Image) { KeepAspectRatio = true, ConstrainSize = true }; Layout.SetComponentPosition(image, column, row, 1, 1); return(image); case Column.Name: Label label = new Label(GUI, Layout, item.Name, GUI.SmallFont); Layout.SetComponentPosition(label, column, row, 1, 1); return(label); case Column.PricePerItem: Label priceLabel = new Label(GUI, Layout, item.Price.ToString("C"), GUI.SmallFont) { ToolTip = "Price per item" }; Layout.SetComponentPosition(priceLabel, column, row, 1, 1); return(priceLabel); case Column.TotalPrice: Label totalLabel = new Label(GUI, Layout, (item.Price * item.CurrentAmount).ToString("C"), GUI.SmallFont) { ToolTip = "Total price" }; Layout.SetComponentPosition(totalLabel, column, row, 1, 1); return(totalLabel); case Column.ArrowRight: ImagePanel panel = new ImagePanel(GUI, Layout, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowRight)) { KeepAspectRatio = true, ConstrainSize = true }; Layout.SetComponentPosition(panel, column, row, 1, 1); return(panel); case Column.ArrowLeft: ImagePanel panelLeft = new ImagePanel(GUI, Layout, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowLeft)) { KeepAspectRatio = true, ConstrainSize = true }; Layout.SetComponentPosition(panelLeft, column, row, 1, 1); return(panelLeft); } return(null); }
public void UpdateItem(Column columnType, int row, int column) { Rectangle key = new Rectangle(column, row, 1, 1); if (!Layout.ComponentPositions.ContainsKey(key)) { return; } GItem item = Items[row - 1]; GUIComponent component = Layout.ComponentPositions[key]; switch (columnType) { case Column.Amount: Label amountLabel = component as Label; if (amountLabel == null) { break; } amountLabel.Text = item.CurrentAmount.ToString(); break; case Column.Image: ImagePanel image = component as ImagePanel; if (image == null) { break; } image.Image = item.Image; break; case Column.Name: Label label = component as Label; if (label == null) { break; } label.Text = item.Name; break; case Column.PricePerItem: Label priceLabel = component as Label; if (priceLabel == null) { break; } priceLabel.Text = item.Price.ToString("C"); break; case Column.TotalPrice: Label totalpriceLabel = component as Label; if (totalpriceLabel == null) { break; } totalpriceLabel.Text = (item.CurrentAmount * item.Price).ToString("C"); break; } }
private void SetupBuildItemTab() { BuildItemTab = new BuildTab { Tab = Selector.AddTab("Items") }; CreateBuildTab(BuildItemTab); BuildItemTab.BuildButton.OnClicked += BuildItemButton_OnClicked; List<CraftItem> items = CraftLibrary.CraftItems.Values.ToList(); int numItems = items.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildItemTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (CraftItem itemType in items) { CraftItem item = itemType; GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; itemLayout.OnClicked += () => ItemTabOnClicked(item); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, itemLayout, item.Image) { KeepAspectRatio = true }; itemLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, itemLayout, item.Name, GUI.SmallFont) { ToolTip = item.Description }; itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public void CreateResourcePanels() { Layout.ClearChildren(); int numItems = CurrentResources.Count; int wItems = LocalBounds.Width / PanelWidth - 1; int hItems = LocalBounds.Height / PanelHeight; Layout.Rows = hItems; Layout.Cols = wItems; int itemIndex = 0; for(int i = 0; i < numItems; i++) { ResourceAmount amount = CurrentResources[i]; if(amount.NumResources == 0) { continue; } int r = itemIndex / wItems; int c = itemIndex % wItems; ImagePanel panel = new ImagePanel(GUI, Layout, amount.ResourceType.Image) { KeepAspectRatio = true, ToolTip = amount.ResourceType.ResourceName + "\n" + amount.ResourceType.Description }; Layout.SetComponentPosition(panel, c, r, 1, 1); Label panelLabel = new Label(GUI, panel, amount.NumResources.ToString(CultureInfo.InvariantCulture), GUI.SmallFont) { Alignment = Drawer2D.Alignment.Bottom, LocalBounds = new Rectangle(0, 0, PanelWidth, PanelHeight), TextColor = Color.White }; itemIndex++; } }
public GUIComponent CreateItem(Column columnType, GItem item, int row, int column) { switch(columnType) { case Column.Amount: Label amountLabel = new Label(GUI, Layout, item.CurrentAmount.ToString(), GUI.SmallFont) { ToolTip = "Total Amount" }; Layout.SetComponentPosition(amountLabel, column, row, 1, 1); return amountLabel; case Column.Image: ImagePanel image = new ImagePanel(GUI, Layout, item.Image) { KeepAspectRatio = true, ConstrainSize = true }; Layout.SetComponentPosition(image, column, row, 1, 1); return image; case Column.Name: Label label = new Label(GUI, Layout, item.Name, GUI.SmallFont); Layout.SetComponentPosition(label, column, row, 1, 1); return label; case Column.PricePerItem: Label priceLabel = new Label(GUI, Layout, item.Price.ToString("C"), GUI.SmallFont) { ToolTip = "Price per item" }; Layout.SetComponentPosition(priceLabel, column, row, 1, 1); return priceLabel; case Column.TotalPrice: Label totalLabel = new Label(GUI, Layout, (item.Price * item.CurrentAmount).ToString("C"), GUI.SmallFont) { ToolTip = "Total price" }; Layout.SetComponentPosition(totalLabel, column, row, 1, 1); return totalLabel; case Column.ArrowRight: ImagePanel panel = new ImagePanel(GUI, Layout, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowRight)) { KeepAspectRatio = true, ConstrainSize = true }; Layout.SetComponentPosition(panel, column, row, 1, 1); return panel; case Column.ArrowLeft: ImagePanel panelLeft = new ImagePanel(GUI, Layout, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowLeft)) { KeepAspectRatio = true, ConstrainSize = true }; Layout.SetComponentPosition(panelLeft, column, row, 1, 1); return panelLeft; } return null; }
public void SetupSpellTab() { KnownSpellTab = new MagicTab { Tab = SpellsTab }; CreateMagicTab(KnownSpellTab); //BuildItemTab.BuildButton.OnClicked += BuildItemButton_OnClicked; List<Spell> spells = Master.Spells.GetKnownSpells(); int numItems = spells.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, KnownSpellTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (Spell spell in spells) { Spell currSpell = spell; GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; itemLayout.OnClicked += () => ItemTabOnClicked(currSpell); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, itemLayout, spell.Image) { KeepAspectRatio = true, ConstrainSize = true, MinWidth = 32, MinHeight = 32 }; itemLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, itemLayout, spell.Name, GUI.SmallFont) { ToolTip = spell.Description }; itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public void Initialize(Texture2D image, string directory) { DefaultTexture = image; TextureLoader = new TextureLoader(directory, GUI.Graphics); Textures = TextureLoader.GetTextures(); TextureLoader.TextureFile defaultFile = new TextureLoader.TextureFile(DefaultTexture, "Default"); Textures.Insert(0, defaultFile); OnTextureSelected += TextureLoadDialog_OnTextureSelected; int rc = Math.Max((int) (Math.Sqrt(Textures.Count)), 2); if(Layout == null) { Layout = new GridLayout(GUI, this, rc + 1, rc); } else { RemoveChild(Layout); Layout = new GridLayout(GUI, this, rc + 1, rc); } if(DirLabel == null) { Label dirLabel = new Label(GUI, Layout, "Images from: " + TextureLoader.Folder, GUI.DefaultFont); DirLabel = dirLabel; } else { DirLabel.Text = "Images from: " + TextureLoader.Folder; Layout.AddChild(DirLabel); } Layout.SetComponentPosition(DirLabel, 0, 0, 1, 1); for(int i = 0; i < Textures.Count; i++) { ImagePanel img = new ImagePanel(GUI, Layout, Textures[i].Texture); img.Highlight = true; img.KeepAspectRatio = true; int row = i / rc; int col = i % rc; TextureLoader.TextureFile texFile = Textures[i]; img.OnClicked += delegate { img_OnClicked(texFile); }; Layout.SetComponentPosition(img, col, row + 1, 1, 1); } }
public void SetupBuildRoomTab() { BuildRoomTab = new BuildTab() { Tab = Selector.AddTab("Rooms") }; CreateBuildTab(BuildRoomTab); BuildRoomTab.BuildButton.OnClicked += BuildRoomButton_OnClicked; List<string> roomTypes = RoomLibrary.GetRoomTypes().ToList(); int numRooms = roomTypes.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildRoomTab.Scroller, numRooms, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numRooms), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (string roomType in roomTypes) { RoomData room = RoomLibrary.GetData(roomType); GridLayout roomLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; roomLayout.OnClicked += () => RoomTabOnClicked(room); int i1 = i; roomLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(roomLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, roomLayout, room.Icon) { KeepAspectRatio = true }; roomLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, roomLayout, room.Name, GUI.SmallFont) { ToolTip = room.Description }; roomLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }