public SpinBox(DwarfGUI gui, GUIComponent parent, string label, float value, float minValue, float maxValue, SpinMode mode) : base(gui, parent) { Increment = 1.0f; SpinValue = value; MinValue = minValue; MaxValue = maxValue; Mode = mode; Layout = new GridLayout(GUI, this, 1, 4); PlusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn)) { KeepAspectRatio = true, DontMakeSmaller = true }; MinusButton = new Button(GUI, Layout, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomOut)) { KeepAspectRatio = true, DontMakeSmaller = true }; ValueBox = new LineEdit(GUI, Layout, value.ToString()) { IsEditable = false }; Layout.SetComponentPosition(ValueBox, 0, 0, 2, 1); Layout.SetComponentPosition(PlusButton, 3, 0, 1, 1); Layout.SetComponentPosition(MinusButton, 2, 0, 1, 1); PlusButton.OnClicked += PlusButton_OnClicked; MinusButton.OnClicked += MinusButton_OnClicked; OnValueChanged += SpinBox_OnValueChanged; }
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 MasterControls(DwarfGUI gui, GUIComponent parent, GameMaster master, Texture2D icons, GraphicsDevice device, SpriteFont font) : base(gui, parent) { Master = master; Icons = icons; IconSize = 32; CurrentMode = master.CurrentToolMode; ToolButtons = new Dictionary<GameMaster.ToolMode, Button>(); GridLayout layout = new GridLayout(GUI, this, 1, 8) { EdgePadding = 0 }; CreateButton(layout, GameMaster.ToolMode.SelectUnits, "Select", "Click and drag to select dwarves.", 5, 0); CreateButton(layout, GameMaster.ToolMode.Dig, "Mine", "Click and drag to designate mines.\nRight click to erase.", 0, 0); CreateButton(layout, GameMaster.ToolMode.Build, "Build", "Click to open build menu.", 2, 0); CreateButton(layout, GameMaster.ToolMode.Magic, "Magic", "Click to open the magic menu.", 6, 1); CreateButton(layout, GameMaster.ToolMode.Gather, "Gather", "Click on resources to designate them\nfor gathering. Right click to erase.", 6, 0); CreateButton(layout, GameMaster.ToolMode.Chop, "Chop", "Click on trees to designate them\nfor chopping. Right click to erase.", 1, 0); CreateButton(layout, GameMaster.ToolMode.Guard, "Guard", "Click and drag to designate guard areas.\nRight click to erase.", 4, 0); CreateButton(layout, GameMaster.ToolMode.Attack, "Attack", "Click and drag to attack entities.\nRight click to cancel.", 3, 0); //CreateButton(layout, GameMaster.ToolMode.CreateStockpiles, "Stock", "Click and drag to designate stockpiles.\nRight click to erase.", 7, 0); int i = 0; foreach(Button b in ToolButtons.Values) { layout.SetComponentPosition(b, i, 0, 1, 1); i++; } }
public ItemSelector(DwarfGUI gui, GUIComponent parent, string title) : base(gui, parent, title) { Columns = new List<Column>() { Column.Image, Column.Name, Column.PricePerItem }; Items = new List<GItem>(); GridLayout layout = new GridLayout(GUI, this, 1, 1); ScrollArea = new ScrollView(GUI, layout) { DrawBorder = false, WidthSizeMode = SizeMode.Fit }; layout.UpdateSizes(); layout.SetComponentPosition(ScrollArea, 0, 0, 1, 1); Layout = new GridLayout(gui, ScrollArea, 14, 5); OnItemChanged += ItemSelector_OnItemChanged; OnItemRemoved += ItemSelector_OnItemRemoved; OnItemAdded += ItemSelector_OnItemAdded; Behavior = ClickBehavior.RemoveItem; AllowShiftClick = true; }
public ResourceInfoComponent(DwarfGUI gui, GUIComponent parent, Faction faction) : base(gui, parent) { Faction = faction; UpdateTimer = new Timer(0.5f, false); Layout = new GridLayout(gui, this, 1, 1); CurrentResources = new List<ResourceAmount>(); PanelWidth = 40; PanelHeight = 40; }
public BuildMenu(DwarfGUI gui, GUIComponent parent, GameMaster faction) : base(gui, parent, WindowButtons.CloseButton) { GridLayout layout = new GridLayout(GUI, this, 1, 1); Master = faction; Selector = new TabSelector(GUI, layout, 3); layout.SetComponentPosition(Selector, 0, 0, 1, 1); SetupBuildRoomTab(); SetupBuildItemTab(); SetupBuildWallTab(); Selector.SetTab("Rooms"); MinWidth = 512; MinHeight = 256; }
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 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++; } }
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 Initialize() { ClearChildren(); GridLayout panelLayout = new GridLayout(GUI, this, 10, 10); GroupBox employeeBox = new GroupBox(GUI, panelLayout, "Employees"); GridLayout boxLayout = new GridLayout(GUI, employeeBox, 8, 4); ScrollView scrollView = new ScrollView(GUI, boxLayout); EmployeeSelector = new ListSelector(GUI, scrollView) { Label = "", DrawPanel = false, Mode = ListItem.SelectionMode.Selector, LocalBounds = new Rectangle(0, 0, 256, Faction.Minions.Count * 24), WidthSizeMode = SizeMode.Fit }; boxLayout.SetComponentPosition(scrollView, 0, 1, 3, 6); panelLayout.SetComponentPosition(employeeBox, 0, 0, 3, 10); foreach (CreatureAI creature in Faction.Minions) { EmployeeSelector.AddItem(creature.Stats.FullName); } EmployeeSelector.OnItemSelected += EmployeeSelector_OnItemSelected; Button hireButton = new Button(GUI, boxLayout, "Hire new", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn)) { ToolTip = "Hire new employees" }; boxLayout.SetComponentPosition(hireButton, 0, 7, 2, 1); hireButton.OnClicked += hireButton_OnClicked; CurrentMinionBox = new GroupBox(GUI, panelLayout, ""); GridLayout minionLayout = new GridLayout(GUI, CurrentMinionBox, 10, 10); CurrentMinionPanel = new MinionPanel(GUI, minionLayout, Faction.Minions.FirstOrDefault()); CurrentMinionPanel.Fire += CurrentMinionPanel_Fire; minionLayout.EdgePadding = 0; minionLayout.SetComponentPosition(CurrentMinionPanel, 0, 1, 10, 9); panelLayout.SetComponentPosition(CurrentMinionBox, 3, 0, 4, 10); if (Faction.Minions.Count > 0) { OnMinionSelected(Faction.Minions[0]); } }
public void CreateGUI() { 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); }
private MiniBar CreateStatusBar(string name, GridLayout layout) { StatusBars[name] = new MiniBar(GUI, layout, 0, name); return(StatusBars[name]); }
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 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 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; }
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 InitializeColorPanels(List<Color> colors) { int numRows = GlobalBounds.Height/PanelHeight; int numCols = GlobalBounds.Width/PanelWidth; Layout = new GridLayout(GUI, this, GlobalBounds.Height / PanelHeight, GlobalBounds.Width / PanelWidth); int rc = Math.Max((int)(Math.Sqrt(colors.Count)), 2); for (int i = 0; i < colors.Count; i++) { ColorPanel panel = new ColorPanel(GUI, Layout) { CurrentColor = colors[i] }; int row = i / numCols; int col = i % numCols; panel.OnClicked += () => panel_OnClicked(panel.CurrentColor); Layout.SetComponentPosition(panel, col, row, 1, 1); } }
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++; } } }
private void HoverItem(GridLayout roomLayout, int i) { roomLayout.HighlightRow(i, new Color(255, 100, 100, 200)); }
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 CreateMagicTab(MagicTab tab) { GridLayout tabLayout = new GridLayout(GUI, tab.Tab, 1, 3) { EdgePadding = 0 }; GridLayout infoLayout = new GridLayout(GUI, tabLayout, 4, 2); tabLayout.SetComponentPosition(infoLayout, 1, 0, 1, 1); tab.InfoImage = new ImagePanel(GUI, infoLayout, (Texture2D)null) { KeepAspectRatio = true }; infoLayout.SetComponentPosition(tab.InfoImage, 1, 0, 1, 1); tab.InfoTitle = new Label(GUI, infoLayout, "", GUI.DefaultFont); infoLayout.SetComponentPosition(tab.InfoTitle, 0, 0, 1, 1); tab.InfoDescription = new Label(GUI, infoLayout, "", GUI.SmallFont) { WordWrap = true }; infoLayout.SetComponentPosition(tab.InfoDescription, 0, 1, 1, 1); tab.InfoRequirements = new Label(GUI, infoLayout, "", GUI.SmallFont); infoLayout.SetComponentPosition(tab.InfoRequirements, 0, 2, 2, 1); tab.CastButton = new Button(GUI, infoLayout, "Cast", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetMouseFrame(GUI.Skin.MouseFrames[GUISkin.MousePointer.Magic])); tab.CastButton.OnClicked += CastButton_OnClicked; infoLayout.SetComponentPosition(tab.CastButton, 0, 3, 1, 1); tab.CastButton.IsVisible = false; tab.Scroller = new ScrollView(GUI, tabLayout) { DrawBorder = true }; tabLayout.SetComponentPosition(tab.Scroller, 0, 0, 1, 1); tabLayout.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(); }
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); } }
private MiniBar CreateStatusBar(string name, GridLayout layout) { StatusBars[name] = new MiniBar(GUI, layout, 0, name); return StatusBars[name]; }
public void SetupLayout() { Rectangle globalRect = GlobalBounds; TotalRows = globalRect.Height / GridHeight; TotalCols = globalRect.Width / GridWidth; Layout = new GridLayout(GUI, this, TotalRows, TotalCols); for(int r = 0; r < TotalRows; r++) { for(int c = 0; c < TotalCols; c++) { GUIComponent slot = new GUIComponent(GUI, Layout); Layout.SetComponentPosition(slot, c, r, 1, 1); DragManager.Slots[slot] = null; } } }
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 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; }
void Initialize() { Envoy.TradeMoney = Faction.TradeMoney + MathFunctions.Rand(-100.0f, 100.0f); Envoy.TradeMoney = Math.Max(Envoy.TradeMoney, 0.0f); TalkerName = TextGenerator.GenerateRandom(Datastructures.SelectRandom(Faction.Race.NameTemplates).ToArray()); Tabs = new Dictionary <string, GUIComponent>(); 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) { DebugDraw = false }; IsInitialized = true; Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice); MainWindow = new GUIComponent(GUI, GUI.RootComponent) { LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2) }; Layout = new GridLayout(GUI, MainWindow, 11, 4); Layout.UpdateSizes(); Talker = new SpeakerComponent(GUI, Layout, new Animation(Faction.Race.TalkAnimation)); Layout.SetComponentPosition(Talker, 0, 0, 4, 4); DialougeSelector = new ListSelector(GUI, Layout) { Mode = ListItem.SelectionMode.ButtonList, DrawButtons = true, DrawPanel = false, Label = "", ItemHeight = 35, Padding = 5 }; DialougeSelector.OnItemSelected += DialougeSelector_OnItemSelected; Layout.SetComponentPosition(DialougeSelector, 2, 3, 1, 8); BackButton = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow)); Layout.SetComponentPosition(BackButton, 2, 10, 1, 1); BackButton.OnClicked += back_OnClicked; BackButton.IsVisible = false; DialougeTree = new SpeechNode() { Text = GetGreeting(), Actions = new List <SpeechNode.SpeechAction>() { new SpeechNode.SpeechAction() { Text = "Trade...", Action = WaitForTrade }, new SpeechNode.SpeechAction() { Text = "Ask a question...", Action = AskAQuestion }, new SpeechNode.SpeechAction() { Text = "Declare war!", Action = DeclareWar }, new SpeechNode.SpeechAction() { Text = "Leave", Action = () => { BackButton.IsVisible = true; if (Envoy != null) { Diplomacy.RecallEnvoy(Envoy); } return(SpeechNode.Echo(new SpeechNode() { Text = GetFarewell(), Actions = new List <SpeechNode.SpeechAction>() })); } } } }; if (Politics.WasAtWar) { PreeTree = new SpeechNode() { Text = Datastructures.SelectRandom(Faction.Race.Speech.PeaceDeclarations), Actions = new List <SpeechNode.SpeechAction>() { new SpeechNode.SpeechAction() { Text = "Make peace with " + Faction.Name, Action = () => { if (!Politics.HasEvent("you made peace with us")) { Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = 0.4f, Description = "you made peace with us", Duration = new TimeSpan(4, 0, 0, 0), Time = PlayState.Time.CurrentDate }); } return(SpeechNode.Echo(DialougeTree)); } }, new SpeechNode.SpeechAction() { Text = "Continue the war with " + Faction.Name, Action = DeclareWar } } }; Transition(PreeTree); Politics.WasAtWar = false; } else { Transition(DialougeTree); } if (!Politics.HasMet) { Politics.HasMet = true; Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = 0.0f, Description = "we just met", Duration = new TimeSpan(1, 0, 0, 0), Time = PlayState.Time.CurrentDate }); } Layout.UpdateSizes(); Talker.TweenIn(Drawer2D.Alignment.Top, 0.25f); DialougeSelector.TweenIn(Drawer2D.Alignment.Right, 0.25f); }
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 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); } }
private Label CreateStatsLabel(string name, string shortName, GridLayout layout) { StatLabels[name] = new Label(GUI, layout, shortName, GUI.SmallFont) { ToolTip = name + " stat" }; return StatLabels[name]; }