public AnnouncementViewer(DwarfGUI gui, GUIComponent parent, AnnouncementManager manager) : base(gui, parent) { TweenTimer = new Timer(0.5f, true); TweenOutTimer = new Timer(0.5f, true); SpeechBubble = new Panel(gui, this) { Mode = Panel.PanelMode.SpeechBubble, DrawOrder = -2 }; SpeechBubble.IsVisible = false; Manager = manager; Manager.OnAdded += Manager_OnAdded; Manager.OnRemoved += Manager_OnRemoved; IsMaximized = false; AnnouncementViews = new List<AnnouncementView>(); MaxViews = 4; WaitTimer = new Timer(5, true); Talker = new AnimatedImagePanel(GUI, this, animation); animation.Play(); animation.Loops = true; animation.FrameHZ = 2.0f; }
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 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 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 }; }
void Initialize() { 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 Panel(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, DrawPanel = false, Label = "" }; DialougeSelector.OnItemSelected += DialougeSelector_OnItemSelected; Layout.SetComponentPosition(DialougeSelector, 2, 2, 2, 10); Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow)); Layout.SetComponentPosition(back, 0, 10, 1, 1); back.OnClicked += back_OnClicked; DialougeTree = new SpeechNode() { Text = GetGreeting(), Actions = new List<SpeechNode.SpeechAction>() { new SpeechNode.SpeechAction() { Text = "Let's trade.", Action = WaitForTrade }, new SpeechNode.SpeechAction() { Text = "Goodbye.", Action = () => SpeechNode.Echo(new SpeechNode() { Text = GetFarewell(), Actions = new List<SpeechNode.SpeechAction>() }) } } }; Transition(DialougeTree); Politics.HasMet = true; PlayerFation.AddResources(new ResourceAmount(ResourceLibrary.ResourceType.Mana, 64)); }