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 TradePanel(DwarfGUI gui, GUIComponent parent, Faction faction, Faction otherFaction, List <ResourceAmount> resources) : base(gui, parent) { Resources = resources; 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, 1, 9, 1, 1); SpaceLabel.OnUpdate += SpaceLabel_OnUpdate; Layout.UpdateSizes(); CreateSelector(); }
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 GameSpeedControl(DwarfGUI gui, GUIComponent parent) : base(gui, parent) { Mode = PanelMode.Simple; GridLayout layout = new GridLayout(GUI, this, 1, 3); TimeLabel = new Label(GUI, layout, "", gui.SmallFont) { TextColor = Color.White, Alignment = Drawer2D.Alignment.Center }; layout.SetComponentPosition(TimeLabel, 1, 0, 1, 1); TimeBackward = new Button(GUI, layout, "", gui.SmallFont, Button.ButtonMode.PushButton, null) { DrawFrame = false, TextColor = Color.White }; layout.SetComponentPosition(TimeBackward, 0, 0, 1, 1); TimeForward = new Button(GUI, layout, "", gui.SmallFont, Button.ButtonMode.PushButton, null) { DrawFrame = false, TextColor = Color.White }; layout.SetComponentPosition(TimeForward, 2, 0, 1, 1); TimeForward.OnClicked += () => SetSpeed(_currSpeed + 1); TimeBackward.OnClicked += () => SetSpeed(_currSpeed - 1); SetSpeed(1); layout.UpdateSizes(); }
private void SetupBuildItemTab() { BuildItemTab = new BuildTab { Tab = Selector.AddTab("Objects") }; BuildItemTab.SelectedResourceBoxes = new List <ComboBox>(); CreateBuildTab(BuildItemTab, BuildType.Item); BuildItemTab.BuildButton.OnClicked += BuildItemButton_OnClicked; List <CraftItem> items = CraftLibrary.CraftItems.Values.Where(item => item.Type == CraftItem.CraftType.Object).ToList(); int numItems = items.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildItemTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (CraftItem itemType in items) { CraftItem item = itemType; GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; if (i == 0) { ItemTabOnClicked(item); } itemLayout.OnClicked += () => ItemTabOnClicked(item); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, itemLayout, item.Image) { KeepAspectRatio = true, MinWidth = 32, MinHeight = 32 }; itemLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, itemLayout, item.Name, GUI.SmallFont) { ToolTip = item.Description }; itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public void SetupSpellTab() { KnownSpellTab = new MagicTab { Tab = SpellsTab }; CreateMagicTab(KnownSpellTab); //BuildItemTab.BuildButton.OnClicked += BuildItemButton_OnClicked; List <Spell> spells = Master.Spells.GetKnownSpells(); int numItems = spells.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, KnownSpellTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (Spell spell in spells) { Spell currSpell = spell; GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; itemLayout.OnClicked += () => ItemTabOnClicked(currSpell); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, itemLayout, spell.Image) { KeepAspectRatio = true, ConstrainSize = true, MinWidth = 32, MinHeight = 32 }; itemLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, itemLayout, spell.Name, GUI.SmallFont) { ToolTip = spell.Description }; itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public void SetupBuildRoomTab() { BuildRoomTab = new BuildTab() { Tab = Selector.AddTab("Rooms") }; CreateBuildTab(BuildRoomTab); BuildRoomTab.BuildButton.OnClicked += BuildRoomButton_OnClicked; List <string> roomTypes = RoomLibrary.GetRoomTypes().ToList(); int numRooms = roomTypes.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildRoomTab.Scroller, numRooms, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numRooms), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (string roomType in roomTypes) { RoomData room = RoomLibrary.GetData(roomType); GridLayout roomLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; roomLayout.OnClicked += () => RoomTabOnClicked(room); int i1 = i; roomLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(roomLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, roomLayout, room.Icon) { KeepAspectRatio = true }; roomLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, roomLayout, room.Name, GUI.SmallFont) { ToolTip = room.Description }; roomLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
public ItemSelector(DwarfGUI gui, GUIComponent parent, WorldManager world, string title, bool hasMoney, bool moneyEditable) : base(gui, parent, title) { World = world; LikedThings = new List <Resource.ResourceTags>(); HatedThings = new List <Resource.ResourceTags>(); CommonThings = new List <Resource.ResourceTags>(); RareThings = new List <Resource.ResourceTags>(); Columns = new List <Column>() { Column.Image, Column.Name, Column.PricePerItem }; Items = new List <GItem>(); FilteredItems = new List <GItem>(); GridLayout layout = new GridLayout(GUI, this, 11, 1); if (hasMoney) { MoneyEdit = new MoneyEditor(GUI, layout, moneyEditable, 100.0f, 50.0f) { ToolTip = "Money to trade" }; layout.SetComponentPosition(MoneyEdit, 0, 9, 1, 1); } SearchBox = new LineEdit(GUI, layout, "") { Prompt = "Search...", ToolTip = "Type to search for keywords" }; layout.SetComponentPosition(SearchBox, 0, 10, 1, 1); SearchBox.OnTextModified += SearchBox_OnTextModified; ScrollArea = new ScrollView(GUI, layout) { DrawBorder = false, WidthSizeMode = SizeMode.Fit }; layout.UpdateSizes(); layout.SetComponentPosition(ScrollArea, 0, 0, 1, 9); ReCreateItems(); OnItemChanged += ItemSelector_OnItemChanged; OnItemRemoved += ItemSelector_OnItemRemoved; OnItemAdded += ItemSelector_OnItemAdded; Behavior = ClickBehavior.RemoveItem; AllowShiftClick = true; AllowControlClick = true; AllowAltClick = true; }
private void SetupBuildWallTab() { BuildWallTab = new BuildTab { Tab = Selector.AddTab("Walls") }; CreateBuildTab(BuildWallTab, BuildType.Wall); 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 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(); }
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 CreateBuildTab(BuildTab tab, BuildType type) { GridLayout tabLayout = new GridLayout(GUI, tab.Tab, 1, 3) { EdgePadding = 0 }; GridLayout infoLayout = new GridLayout(GUI, tabLayout, 4, 2) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed }; tabLayout.SetComponentPosition(infoLayout, 1, 0, 2, 1); tab.InfoImage = new ImagePanel(GUI, infoLayout, (Texture2D)null) { KeepAspectRatio = true, MinWidth = 32, MinHeight = 32 }; 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); switch (type) { case BuildType.Craft: tab.BuildButton = new Button(GUI, infoLayout, "Craft", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetMouseFrame(GUI.Skin.MouseFrames[GUISkin.MousePointer.Build])); break; case BuildType.Item: case BuildType.Room: case BuildType.Wall: tab.BuildButton = new Button(GUI, infoLayout, "Build", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetMouseFrame(GUI.Skin.MouseFrames[GUISkin.MousePointer.Build])); break; case BuildType.Cook: tab.BuildButton = new Button(GUI, infoLayout, "Cook", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetMouseFrame(GUI.Skin.MouseFrames[GUISkin.MousePointer.Cook])); break; } infoLayout.SetComponentPosition(tab.BuildButton, 0, 3, 1, 1); tab.BuildButton.IsVisible = false; tab.Scroller = new ScrollView(GUI, tabLayout) { DrawBorder = true }; tabLayout.SetComponentPosition(tab.Scroller, 0, 0, 1, 1); tabLayout.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(); }
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(); }
private void SetupBuildResourceTab() { bool hasCook = Build.HasFlag(BuildType.Cook); string name = Build.HasFlag(BuildType.Cook) ? "Food" : "Crafts"; BuildResourceTab = new BuildTab { Tab = Selector.AddTab(name), SelectedResourceBoxes = new List <ComboBox>() }; CreateBuildTab(BuildResourceTab, hasCook ? BuildType.Cook : BuildType.Craft); BuildResourceTab.BuildButton.OnClicked += BuildResource_OnClicked; List <CraftItem> items = CraftLibrary.CraftItems.Values.Where(item => item.Type == CraftItem.CraftType.Resource).ToList(); int numItems = items.Count(); int numColumns = 1; GridLayout layout = new GridLayout(GUI, BuildResourceTab.Scroller, numItems, numColumns) { LocalBounds = new Rectangle(0, 0, 720, 40 * numItems), EdgePadding = 0, WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fixed }; int i = 0; foreach (CraftItem itemType in items) { CraftItem item = itemType; bool isEdible = ResourceLibrary.Resources.ContainsKey(item.ResourceCreated) && ResourceLibrary.Resources[item.ResourceCreated].Tags.Contains(Resource.ResourceTags.Edible); if (!hasCook && isEdible) { continue; } else if (hasCook && !isEdible) { continue; } GridLayout itemLayout = new GridLayout(GUI, layout, 1, 3) { WidthSizeMode = SizeMode.Fixed, HeightSizeMode = SizeMode.Fixed, EdgePadding = 0 }; if (i == 0) { ResourceTabOnClicked(item); } itemLayout.OnClicked += () => ResourceTabOnClicked(item); int i1 = i; itemLayout.OnHover += () => HoverItem(layout, i1); layout.SetComponentPosition(itemLayout, 0, i, 1, 1); ImagePanel icon = new ImagePanel(GUI, itemLayout, item.Image) { KeepAspectRatio = true, MinWidth = 32, MinHeight = 32 }; itemLayout.SetComponentPosition(icon, 0, 0, 1, 1); Label description = new Label(GUI, itemLayout, item.Name, GUI.SmallFont) { ToolTip = item.Description }; itemLayout.SetComponentPosition(description, 1, 0, 1, 1); i++; } layout.UpdateSizes(); }
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 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(); }
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)); }
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; 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 = World.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 = World.Time.CurrentDate }); } Layout.UpdateSizes(); Talker.TweenIn(Drawer2D.Alignment.Top, 0.25f); DialougeSelector.TweenIn(Drawer2D.Alignment.Right, 0.25f); }
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(); }