public AIDebugger(DwarfGUI gui, GameMaster master) { MainPanel = new Panel(gui, gui.RootComponent); Layout = new GridLayout(gui, MainPanel, 13, 1); DwarfSelector = new ComboBox(gui, Layout); DwarfSelector.OnSelectionModified += DwarfSelector_OnSelectionModified; GoalLabel = new Label(gui, Layout, "Script: null", gui.DefaultFont); PlanLabel = new Label(gui, Layout, "Plan: null", gui.DefaultFont); AStarPathLabel = new Label(gui, Layout, "Astar Path: null", gui.DefaultFont); LastMessages = new Label(gui, Layout, "Messages: ", gui.DefaultFont); ScrollView btDisplayHolder = new ScrollView(gui, Layout); BTDisplay = new ActDisplay(gui, btDisplayHolder); Layout.SetComponentPosition(DwarfSelector, 0, 0, 1, 1); Layout.SetComponentPosition(GoalLabel, 0, 1, 1, 1); Layout.SetComponentPosition(PlanLabel, 0, 2, 1, 1); Layout.SetComponentPosition(AStarPathLabel, 0, 3, 1, 1); Layout.SetComponentPosition(LastMessages, 0, 4, 1, 2); Layout.SetComponentPosition(btDisplayHolder, 0, 6, 1, 6); Visible = false; int i = 0; foreach(CreatureAI component in master.Faction.Minions) { DwarfSelector.AddValue("Minion " + i); i++; } Master = master; MainPanel.LocalBounds = new Rectangle(100, 120, 500, 600); }
public StockTicker(DwarfGUI gui, GUIComponent parent, Economy economy) : base(gui, parent) { Icons = new List<StockIcon>(); Economy = economy; Window = 30; TickColor = Color.Brown; Layout = new GridLayout(gui, this, 10, 4); Label displayLabel = new Label(gui, Layout, "Display: ", GUI.DefaultFont); Layout.SetComponentPosition(displayLabel, 0, 0, 1, 1); IndustryBox = new ComboBox(gui, Layout); IndustryBox.AddValue("Our Company"); IndustryBox.AddValue("All"); IndustryBox.AddValue("Average"); IndustryBox.AddValue("Exploration"); IndustryBox.AddValue("Military"); IndustryBox.AddValue("Manufacturing"); IndustryBox.AddValue("Magic"); IndustryBox.AddValue("Finance"); IndustryBox.CurrentIndex = 0; IndustryBox.CurrentValue = "Our Company"; IndustryBox.OnSelectionModified += IndustryBox_OnSelectionModified; Layout.SetComponentPosition(IndustryBox, 1, 0, 1, 1); DrawSurface = new GUIComponent(gui, Layout); Layout.SetComponentPosition(DrawSurface, 0, 1, 4, 9); IndustryBox_OnSelectionModified("Our Company"); }
public MiniBar(DwarfGUI gui, GUIComponent parent, float v, string label) : base(gui, parent) { Value = v; BackgroundColor = Color.Transparent; ForegroundColor = Color.Black; FillColor = new Color(10, 10, 10); Text = new Label(GUI, this, label, GUI.SmallFont) { LocalBounds = new Rectangle(0, 0, label.Length * 8, 32) }; }
public GodModeTool(DwarfGUI gui, GameMaster master) { GUI = gui; Player = master; SelectorPanel = new Window(GUI, gui.RootComponent) { LocalBounds = new Rectangle(200, 100, 300, 100) }; Label label = new Label(GUI, SelectorPanel, "Cheat Mode!", GUI.DefaultFont) { LocalBounds = new Rectangle(10, 10, 250, 32) }; SelectorBox = new ComboBox(GUI, SelectorPanel) { LocalBounds = new Rectangle(10, 64, 250, 32), WidthSizeMode = GUIComponent.SizeMode.Fit }; IsActive = false; Chunks = PlayState.ChunkManager; foreach(string s in RoomLibrary.GetRoomTypes()) { SelectorBox.AddValue("Build " + s); } List<string> strings = EntityFactory.EntityFuncs.Keys.ToList(); strings.Sort(); foreach (string s in strings) { SelectorBox.AddValue(s); } foreach(VoxelType type in VoxelLibrary.PrimitiveMap.Keys.Where(type => type.Name != "empty" && type.Name != "water")) { SelectorBox.AddValue("Place " + type.Name); } SelectorBox.AddValue("Delete Block"); SelectorBox.AddValue("Kill Block"); SelectorBox.AddValue("Kill Things"); SelectorBox.AddValue("Fill Water"); SelectorBox.AddValue("Fill Lava"); SelectorBox.AddValue("Fire"); SelectorBox.OnSelectionModified += SelectorBox_OnSelectionModified; SelectorPanel.IsVisible = false; }
public CapitalPanel(DwarfGUI gui, GUIComponent parent, Faction faction) : base(gui, parent) { Faction = faction; GridLayout layout = new GridLayout(gui, this, 4, 4); CurrentMoneyLabel = new Label(gui, layout, "Treasury: ", GUI.TitleFont); layout.SetComponentPosition(CurrentMoneyLabel, 0, 0, 2, 1); CurrentMoneyLabel.OnUpdate += CurrentMoneyLabel_OnUpdate; TotalPayLabel = new Label(gui, layout, "Employee pay: ", GUI.DefaultFont); layout.SetComponentPosition(TotalPayLabel, 2, 0, 2, 1); Stocks = new StockTicker(gui, layout, Faction.Economy); layout.SetComponentPosition(Stocks, 0, 1, 4, 3); }
public GoodsPanel(DwarfGUI gui, GUIComponent parent, Faction faction) : base(gui, parent) { LocalBounds = parent.GlobalBounds; Faction = faction; GridLayout layout = new GridLayout(GUI, this, 8, 4); Tabs = new TabSelector(GUI, layout, 4) { WidthSizeMode = SizeMode.Fit }; layout.SetComponentPosition(Tabs, 0, 0, 4, 8); TotalMoney = new Label(GUI, layout, "Total Money: " + Faction.Economy.CurrentMoney.ToString("C"), GUI.DefaultFont) { ToolTip = "Total amount of money in our treasury", WordWrap = true }; TotalMoney.OnUpdate += TotalMoney_OnUpdate; layout.SetComponentPosition(TotalMoney, 3, 0, 1, 1); SpaceLabel = new Label(GUI, layout, "Space: " + Faction.ComputeStockpileSpace() + "/" + Faction.ComputeStockpileCapacity(), GUI.DefaultFont) { ToolTip = "Space left in our stockpiles", WordWrap = true }; layout.SetComponentPosition(SpaceLabel, 2, 0, 1, 1); SpaceLabel.OnUpdate += SpaceLabel_OnUpdate; layout.UpdateSizes(); CreateBuyTab(); CreateSellTab(); Tabs.SetTab("Buy"); }
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 TradePanel(DwarfGUI gui, GUIComponent parent, Faction faction, Faction otherFaction) : base(gui, parent) { GoodsSent = new List<ResourceAmount>(); GoodsReceived = new List<ResourceAmount>(); LocalBounds = parent.GlobalBounds; Faction = faction; OtherFaction = otherFaction; Layout = new GridLayout(GUI, this, 10, 4); SpaceLabel = new Label(GUI, Layout, "Space: " + Faction.ComputeStockpileSpace() + "/" + Faction.ComputeStockpileCapacity(), GUI.DefaultFont) { ToolTip = "Space left in our stockpiles", WordWrap = true }; Layout.SetComponentPosition(SpaceLabel, 2, 9, 1, 1); SpaceLabel.OnUpdate += SpaceLabel_OnUpdate; Layout.UpdateSizes(); CreateSelector(); }
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 override void Initialize(Dialog.ButtonType buttons, string title, string message) { WasSomeoneHired = false; GenerateApplicants(); IsModal = true; OnClicked += HireDialog_OnClicked; OnClosed += HireDialog_OnClosed; int w = LocalBounds.Width; int h = LocalBounds.Height; int rows = h / 64; int cols = 8; GridLayout layout = new GridLayout(GUI, this, rows, cols); Title = new Label(GUI, layout, title, GUI.TitleFont); layout.SetComponentPosition(Title, 0, 0, 2, 1); GroupBox applicantSelectorBox = new GroupBox(GUI, layout, ""); layout.SetComponentPosition(applicantSelectorBox, 0, 1, rows / 2 - 1, cols - 1); GridLayout selectorLayout = new GridLayout(GUI, applicantSelectorBox, 1, 1); ScrollView view = new ScrollView(GUI, selectorLayout); ApplicantSelector = new ListSelector(GUI, view) { Label = "-Applicants-" }; selectorLayout.SetComponentPosition(view, 0, 0, 1, 1); foreach (Applicant applicant in Applicants) { ApplicantSelector.AddItem(applicant.Level.Name + " - " + applicant.Name); } ApplicantSelector.DrawPanel = false; ApplicantSelector.LocalBounds = new Rectangle(0, 0, 128, Applicants.Count * 24); ApplicantSelector.OnItemSelected += ApplicantSelector_OnItemSelected; CurrentApplicant = Applicants[0]; GroupBox applicantPanel = new GroupBox(GUI, layout, ""); layout.SetComponentPosition(applicantPanel, rows / 2 - 1, 1, rows / 2 - 1, cols - 1); GridLayout applicantLayout = new GridLayout(GUI, applicantPanel, 1, 1); ApplicantPanel = new ApplicationPanel(applicantLayout); applicantLayout.SetComponentPosition(ApplicantPanel, 0, 0, 1, 1); ApplicantPanel.SetApplicant(CurrentApplicant); bool createOK = false; bool createCancel = false; switch (buttons) { case ButtonType.None: break; case ButtonType.OkAndCancel: createOK = true; createCancel = true; break; case ButtonType.OK: createOK = true; break; case ButtonType.Cancel: createCancel = true; break; } if (createOK) { Button okButton = new Button(GUI, layout, "OK", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check)); layout.SetComponentPosition(okButton, cols - 2, rows - 1 , 2, 1); okButton.OnClicked += okButton_OnClicked; } if (createCancel) { Button cancelButton = new Button(GUI, layout, "Cancel", GUI.DefaultFont, Button.ButtonMode.PushButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Ex)); layout.SetComponentPosition(cancelButton, cols - 4, rows - 1, 2, 1); cancelButton.OnClicked += cancelButton_OnClicked; } HireButton = new Button(GUI, layout, "Hire", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn)); layout.SetComponentPosition(HireButton, cols - 1, rows - 2, 1, 1); HireButton.OnClicked += HireButton_OnClicked; }
public void CreateGUI() { Settings = new WorldSettings() { Width = 512, Height = 512, Name = GetRandomWorldName(), NumCivilizations = 5, NumFaults = 3, NumRains = 1000, NumVolcanoes = 3, RainfallScale = 1.0f, SeaLevel = 0.17f, TemperatureScale = 1.0f }; Input = new InputManager(); GUI = new DwarfGUI(Game, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input); MainPanel = new Panel(GUI, GUI.RootComponent) { LocalBounds = new Rectangle(128, 64, Game.GraphicsDevice.Viewport.Width - 256, Game.GraphicsDevice.Viewport.Height - 128) }; Layout = new GridLayout(GUI, MainPanel, 8, 6) { HeightSizeMode = GUIComponent.SizeMode.Fit, WidthSizeMode = GUIComponent.SizeMode.Fit }; NameLabel = new Label(GUI, Layout, "World Name: ", GUI.DefaultFont); Layout.SetComponentPosition(NameLabel, 0, 0, 1, 1); NameEdit = new LineEdit(GUI, Layout, Settings.Name); Layout.SetComponentPosition(NameEdit, 1, 0, 4, 1); NameEdit.OnTextModified += NameEdit_OnTextModified; NameRandomButton = new Button(GUI, Layout, "Random", GUI.DefaultFont, Button.ButtonMode.PushButton, null); Layout.SetComponentPosition(NameRandomButton, 5, 0, 1, 1); NameRandomButton.OnClicked += NameRandomButton_OnClicked; OptionsView = new ScrollView(GUI, Layout) { DrawBorder = true }; Layout.SetComponentPosition(OptionsView, 0, 1, 6, 6); OptionsLayout = new FormLayout(GUI, OptionsView) { WidthSizeMode = GUIComponent.SizeMode.Fit, HeightSizeMode = GUIComponent.SizeMode.Fit }; ComboBox sizeBox = CreateOptionsBox("World Size", "Size of the world to generate", OptionsLayout); sizeBox.OnSelectionModified += sizeBox_OnSelectionModified; sizeBox.InvokeSelectionModified(); ComboBox nativeBox = CreateOptionsBox("Natives", "Number of native civilizations", OptionsLayout); nativeBox.OnSelectionModified += nativeBox_OnSelectionModified; nativeBox.InvokeSelectionModified(); ComboBox faultBox = CreateOptionsBox("Faults", "Number of straights, seas, etc.", OptionsLayout); faultBox.OnSelectionModified += faultBox_OnSelectionModified; faultBox.InvokeSelectionModified(); ComboBox rainBox = CreateOptionsBox("Rainfall", "Amount of moisture in the world.", OptionsLayout); rainBox.OnSelectionModified += rainBox_OnSelectionModified; rainBox.InvokeSelectionModified(); ComboBox erosionBox = CreateOptionsBox("Erosion", "More or less eroded landscape.", OptionsLayout); erosionBox.OnSelectionModified += erosionBox_OnSelectionModified; erosionBox.InvokeSelectionModified(); ComboBox seaBox = CreateOptionsBox("Sea Level", "Height of the sea.", OptionsLayout); seaBox.OnSelectionModified += seaBox_OnSelectionModified; seaBox.InvokeSelectionModified(); ComboBox temp = CreateOptionsBox("Temperature", "Average temperature.", OptionsLayout); temp.OnSelectionModified += temp_OnSelectionModified; temp.InvokeSelectionModified(); BackButton = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow)) { ToolTip = "Back to the main menu." }; Layout.SetComponentPosition(BackButton, 0, 7, 1, 1); BackButton.OnClicked += BackButton_OnClicked; AcceptButton = new Button(GUI, Layout, "Next", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.RightArrow)) { ToolTip = "Generate a world with these settings" }; AcceptButton.OnClicked += AcceptButton_OnClicked; Layout.SetComponentPosition(AcceptButton, 5, 7, 1, 1); }
public void Initialize() { GridLayout layout = new GridLayout(GUI, this, 6, 4); NameLabel = new Label(GUI, layout, "", GUI.TitleFont) { WordWrap = true }; PositionLabel = new Label(GUI, layout, "", GUI.DefaultFont) { WordWrap = true }; PayLabel = new Label(GUI, layout, "", GUI.DefaultFont) { WordWrap = true }; BonusLabel = new Label(GUI, layout, "", GUI.DefaultFont) { WordWrap = true }; LetterLabel = new Label(GUI, layout, "", GUI.DefaultFont) { WordWrap = true }; FormerPositionLabel = new Label(GUI, layout, "", GUI.SmallFont); HomeTownLabel = new Label(GUI, layout, "", GUI.SmallFont); layout.SetComponentPosition(NameLabel, 0, 0, 2, 1); layout.SetComponentPosition(PositionLabel, 0, 1, 1, 1); layout.SetComponentPosition(FormerPositionLabel, 0, 5, 2, 1); layout.SetComponentPosition(HomeTownLabel, 2, 5, 2, 1); layout.SetComponentPosition(PayLabel , 0, 2, 1, 1); layout.SetComponentPosition(BonusLabel, 2, 2, 1, 1); layout.SetComponentPosition(LetterLabel, 0, 3, 3, 2); }
private Label CreateStatsLabel(string name, string shortName, GridLayout layout) { StatLabels[name] = new Label(GUI, layout, shortName, GUI.SmallFont) { ToolTip = name + " stat" }; return StatLabels[name]; }
public void CreateSellTab() { TabSelector.Tab sellTab = Tabs.AddTab("Sell"); GridLayout sellBoxLayout = new GridLayout(GUI, sellTab, 10, 4); SellSelector = new ItemSelector(GUI, sellBoxLayout, "Items") { Columns = new List<ItemSelector.Column>() { ItemSelector.Column.Image, ItemSelector.Column.Name, ItemSelector.Column.Amount, ItemSelector.Column.TotalPrice, ItemSelector.Column.ArrowRight }, NoItemsMessage = "No goods in our stockpiles", ToolTip = "Click items to put them in the sell order" }; sellBoxLayout.SetComponentPosition(SellSelector, 0, 0, 2, 10); SellSelector.Items.AddRange(GetResources(Faction.ListResources().Values.ToList())); SellSelector.ReCreateItems(); SellCart = new ItemSelector(GUI, sellBoxLayout, "Order") { Columns = new List<ItemSelector.Column>() { ItemSelector.Column.ArrowLeft, ItemSelector.Column.Image, ItemSelector.Column.Name, ItemSelector.Column.Amount, ItemSelector.Column.TotalPrice }, NoItemsMessage = "No items selected", ToolTip = "Click items to remove them from the sell order" }; SellCart.ReCreateItems(); sellBoxLayout.SetComponentPosition(SellCart, 2, 0, 2, 9); SellSelector.OnItemRemoved += SellCart.AddItem; SellCart.OnItemRemoved += SellSelector.AddItem; Button sellButton = new Button(GUI, sellBoxLayout, "Sell", GUI.DefaultFont, Button.ButtonMode.PushButton, null) { ToolTip = "Click to sell items in the order" }; sellBoxLayout.SetComponentPosition(sellButton, 3, 9, 1, 2); sellButton.OnClicked += sellButton_OnClicked; SellTotal = new Label(GUI, sellBoxLayout, "Order Total: $0.00", GUI.DefaultFont) { WordWrap = true, ToolTip = "Order total" }; sellBoxLayout.SetComponentPosition(SellTotal, 2, 9, 1, 2); SellCart.OnItemChanged += SellCart_OnItemChanged; }
public virtual void Initialize(ButtonType buttons, string title, string message) { IsModal = true; OnClicked += Dialog_OnClicked; OnClosed += Dialog_OnClosed; Layout = new GridLayout(GUI, this, 4, 4); Title = new Label(GUI, Layout, title, GUI.DefaultFont); Layout.SetComponentPosition(Title, 0, 0, 1, 1); Message = new Label(GUI, Layout, message, GUI.DefaultFont) { WordWrap = true }; Layout.SetComponentPosition(Message, 0, 1, 4, 2); bool createOK = false; bool createCancel = false; switch (buttons) { case ButtonType.None: break; case ButtonType.OkAndCancel: createOK = true; createCancel = true; break; case ButtonType.OK: createOK = true; break; case ButtonType.Cancel: createCancel = true; break; } if (createOK) { Button okButton = new Button(GUI, Layout, "OK", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check)); Layout.SetComponentPosition(okButton, 2, 3, 2, 1); okButton.OnClicked += OKButton_OnClicked; } if (createCancel) { Button cancelButton = new Button(GUI, Layout, "Cancel", GUI.DefaultFont, Button.ButtonMode.PushButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Ex)); Layout.SetComponentPosition(cancelButton, 0, 3, 2, 1); cancelButton.OnClicked += cancelButton_OnClicked; } }
public void CreateSelector() { TheirGoods = new ItemSelector(GUI, Layout, "Their Items") { Columns = new List<ItemSelector.Column>() { ItemSelector.Column.Image, ItemSelector.Column.Name, ItemSelector.Column.PricePerItem, ItemSelector.Column.ArrowRight }, NoItemsMessage = "Nothing to buy", ToolTip = "Click items to trade for them." }; Layout.SetComponentPosition(TheirGoods, 0, 0, 2, 9); TheirGoods.Items.AddRange(GetResources(1.0f)); TheirGoods.ReCreateItems(); MyGoods = new ItemSelector(GUI, Layout, "Our Items") { Columns = new List<ItemSelector.Column>() { ItemSelector.Column.ArrowLeft, ItemSelector.Column.Image, ItemSelector.Column.Name, ItemSelector.Column.Amount, ItemSelector.Column.TotalPrice }, NoItemsMessage = "No items selected", ToolTip = "Click items to offer them for trade.", PerItemCost = 1.00f }; MyGoods.Items.AddRange(GetResources(PlayState.PlayerFaction.ListResources().Values.ToList())); MyGoods.ReCreateItems(); Layout.SetComponentPosition(MyGoods, 2, 0, 2, 9); TheirGoods.OnItemRemoved += MyGoods.AddItem; MyGoods.OnItemRemoved += TheirGoods.AddItem; MyGoods.OnItemChanged += shoppingCart_OnItemChanged; MyGoods.OnItemRemoved += TheirGoods_OnItemAdded; TheirGoods.OnItemRemoved += MyGoods_OnItemAdded; Button buyButton = new Button(GUI, Layout, "Offer Trade", GUI.DefaultFont, Button.ButtonMode.PushButton, null) { ToolTip = "Click to offer up a trade." }; Layout.SetComponentPosition(buyButton, 3, 9, 1, 2); BuyTotal = new Label(GUI, Layout, "Profit: $0.00", GUI.DefaultFont) { WordWrap = true, ToolTip = "Their profit from the trade." }; Layout.SetComponentPosition(BuyTotal, 0, 9, 1, 2); buyButton.OnClicked += buyButton_OnClicked; }
public SpeakerComponent(DwarfGUI gui, GUIComponent parent, Animation animation) : base(gui, parent) { ActorSize = 256; Actor = new AnimatedImagePanel(GUI, this, animation) { KeepAspectRatio = true }; SpeechBubble = new Panel(GUI, this) { Mode = Panel.PanelMode.SpeechBubble }; SpeechLabel = new Label(GUI, SpeechBubble, "", GUI.DefaultFont) { Alignment = Drawer2D.Alignment.Center, WordWrap = true }; }
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(); }
private void SetupBuildWallTab() { BuildWallTab = new BuildTab { Tab = Selector.AddTab("Walls") }; CreateBuildTab(BuildWallTab); BuildWallTab.BuildButton.OnClicked += WallButton_OnClicked; List<VoxelType> wallTypes = VoxelLibrary.GetTypes().Where(voxel => voxel.IsBuildable).ToList(); int numItems = wallTypes.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildWallTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (VoxelType wallType in wallTypes) { VoxelType wall = wallType; GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; itemLayout.OnClicked += () => WallTabOnClicked(wall); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); Label description = new Label(GUI, itemLayout, wall.Name + " Wall", GUI.SmallFont); itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
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 CreateBuyTab() { TabSelector.Tab buyTab = Tabs.AddTab("Buy"); GridLayout buyBoxLayout = new GridLayout(GUI, buyTab, 10, 4); BuySelector = new ItemSelector(GUI, buyBoxLayout, "Items") { Columns = new List<ItemSelector.Column>() { ItemSelector.Column.Image, ItemSelector.Column.Name, ItemSelector.Column.PricePerItem, ItemSelector.Column.ArrowRight }, NoItemsMessage = "Nothing to buy", ToolTip = "Click items to add them to the shopping cart" }; buyBoxLayout.SetComponentPosition(BuySelector, 0, 0, 2, 10); BuySelector.Items.AddRange(GetResources(1.0f)); BuySelector.ReCreateItems(); ShoppingCart = new ItemSelector(GUI, buyBoxLayout, "Order") { Columns = new List<ItemSelector.Column>() { ItemSelector.Column.ArrowLeft, ItemSelector.Column.Image, ItemSelector.Column.Name, ItemSelector.Column.Amount, ItemSelector.Column.TotalPrice }, NoItemsMessage = "No items selected", ToolTip = "Click items to remove them from the shopping cart", PerItemCost = 1.00f }; ShoppingCart.ReCreateItems(); buyBoxLayout.SetComponentPosition(ShoppingCart, 2, 0, 2, 9); BuySelector.OnItemRemoved += ShoppingCart.AddItem; ShoppingCart.OnItemRemoved += BuySelector.AddItem; ShoppingCart.OnItemChanged += shoppingCart_OnItemChanged; Button buyButton = new Button(GUI, buyBoxLayout, "Buy", GUI.DefaultFont, Button.ButtonMode.PushButton, null) { ToolTip = "Click to order items in the shopping cart" }; buyBoxLayout.SetComponentPosition(buyButton, 3, 9, 1, 2); BuyTotal = new Label(GUI, buyBoxLayout, "Order Total: $0.00", GUI.DefaultFont) { WordWrap = true, ToolTip = "Order total" }; buyBoxLayout.SetComponentPosition(BuyTotal, 2, 9, 1, 2); buyButton.OnClicked += buyButton_OnClicked; }
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 ReCreateItems() { RemoveChild(Layout); List<GItem> toDisplay = Items; if(Items.Count == 0) { ScrollArea.RemoveChild(Layout); Layout = new GridLayout(GUI, ScrollArea, 1, 1); Label label = new Label(GUI, Layout, NoItemsMessage, GUI.DefaultFont); Layout.SetComponentPosition(label, 0, 0, 1, 1); return; } int rows = Math.Max(toDisplay.Count, 6); ScrollArea.RemoveChild(Layout); ScrollArea.ResetScroll(); Layout = new GridLayout(GUI, ScrollArea, rows + 1, 6) { LocalBounds = new Rectangle(0, 0, Math.Max(ScrollArea.LocalBounds.Width, 512), rows * 64), WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed }; for(int i = 0; i < toDisplay.Count; i++) { GItem currentResource = toDisplay[i]; int j = 0; foreach(Column column in Columns) { GUIComponent item = CreateItem(column, toDisplay[i], i + 1, j); item.OnClicked += () => ItemClicked(currentResource); int row = i; item.OnHover += () => HighlightRow(row + 1); j++; } } }
public void InitializePanel() { StatLabels = new Dictionary<string, Label>(); StatusBars = new Dictionary<string, MiniBar>(); GridLayout layout = new GridLayout(GUI, this, 10, 8); CreateStatsLabel("Dexterity", "DEX:", layout); CreateStatsLabel("Strength", "STR:", layout); CreateStatsLabel("Wisdom", "WIS:", layout); CreateStatsLabel("Constitution", "CON:", layout); CreateStatsLabel("Intelligence", "INT:", layout); CreateStatsLabel("Size", "SIZ:", layout); int i = 0; int nx = 3; int ny = 2; foreach(KeyValuePair<string, Label> label in StatLabels) { layout.SetComponentPosition(label.Value, (i % nx), (((i - i % nx) / nx) % ny), 1, 1); i++; } CreateStatusBar("Hunger", layout); CreateStatusBar("Energy", layout); CreateStatusBar("Happiness", layout); CreateStatusBar("Health", layout); i = 0; nx = 2; ny = 3; foreach (KeyValuePair<string, MiniBar> label in StatusBars) { layout.SetComponentPosition(label.Value, (i % nx) * 2, (((i - i % nx) / nx) % ny) * 2 + 2, 2, 2); i++; } Portrait = new AnimatedImagePanel(GUI, layout, new ImageFrame()) { KeepAspectRatio = true }; layout.SetComponentPosition(Portrait, 5, 0, 4, 4); ClassLabel = new Label(GUI, layout, "Level", GUI.DefaultFont) { WordWrap = true }; layout.SetComponentPosition(ClassLabel, 5, 4, 4, 2); XpLabel = new Label(GUI, layout, "XP", GUI.SmallFont) { WordWrap = true }; layout.SetComponentPosition(XpLabel, 5, 7, 2, 1); PayLabel = new Label(GUI, layout, "Pay", GUI.SmallFont); layout.SetComponentPosition(PayLabel, 5, 8, 2, 1); LevelUpButton = new Button(GUI, layout, "Promote", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.SmallArrowUp)); layout.SetComponentPosition(LevelUpButton, 5, 9, 2, 1); LevelUpButton.OnClicked += LevelUpButton_OnClicked; FireButton = new Button(GUI, layout, "Fire", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomOut)) { ToolTip = "Let this employee go." }; layout.SetComponentPosition(FireButton, 0, 9, 2, 1); FireButton.OnClicked +=FireButton_OnClicked; }
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 KeyEditor(DwarfGUI gui, GUIComponent parent, KeyManager keyManager, int numRows, int numColumns) : base(gui, parent) { Keys[] reserved = { Keys.Up, Keys.Left, Keys.Right, Keys.Down, Keys.LeftControl, Keys.LeftShift, Keys.RightShift, Keys.LeftAlt, Keys.RightAlt, Keys.RightControl, Keys.Escape }; ReservedKeys = new List<Keys>(); ReservedKeys.AddRange(reserved); KeyManager = keyManager; Layout = new GridLayout(gui, this, numRows, numColumns * 2); int r = 0; int c = 0; foreach(KeyValuePair<string, Keys> button in KeyManager.Buttons) { if(r == numRows) { r = 0; c++; } Label keyLabel = new Label(gui, Layout, button.Key, gui.DefaultFont); KeyEdit editor = new KeyEdit(gui, Layout, button.Value); Layout.SetComponentPosition(keyLabel, c * 2, r, 1, 1); Layout.SetComponentPosition(editor, c * 2 + 1, r, 1, 1); string name = button.Key; editor.OnKeyModified += (prevKey, arg, keyedit) => editor_OnKeyModified(name, prevKey, arg, keyedit); r++; } }