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 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 SpellTreeDisplay(DwarfGUI gui, GUIComponent parent, SpellTree tree) : base(gui, parent) { Tree = tree; Scroller = new ScrollView(gui, this) { HeightSizeMode = SizeMode.Fit, WidthSizeMode = SizeMode.Fit }; MainPanel = new GUIComponent(gui, Scroller) { HeightSizeMode = SizeMode.Fixed, WidthSizeMode = SizeMode.Fixed }; InitializeSpellButtons(); }
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() { 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 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; }