private void UpdateLabels() { TimeLabel.Text = String.Format("{0}x", _currentSpeed); TimeLabel.Invalidate(); PlayPauseButton.Text = (_currentSpeed == 0 ? ">" : "||"); PlayPauseButton.Tooltip = (_currentSpeed == 0 ? "Resume" : "Pause"); PlayPauseButton.Invalidate(); if (_currentSpeed <= 0) { SlowButton.Hidden = true; SlowButton.Invalidate(); } else { SlowButton.Hidden = false; SlowButton.Invalidate();; } if (_currentSpeed >= 3) { FastButton.Hidden = true; FastButton.Invalidate(); } else { FastButton.Hidden = false; FastButton.Invalidate(); } }
public void Say(string Text) { sentence = Text; SpeechBubble.Text = ""; SpeechBubble.Invalidate(); speech = Race.Speech.Language.Say(Text).GetEnumerator(); }
public void Say(String Text) { sentence = Text; SpeechBubble.Text = ""; SpeechBubble.Invalidate(); speech = Envoy.OwnerFaction.Race.Speech.Language.Say(Text).GetEnumerator(); }
public void Update() { if (Transaction != null) { if (Transaction.Status == UGCStatus.Working) { Transaction.Update(); } if (StatusMessageDisplay != null) { StatusMessageDisplay.Text = Transaction.Message; StatusMessageDisplay.Invalidate(); } if (!RanCallbacks) { if (Transaction.Status == UGCStatus.Success) { RanCallbacks = true; OnSuccess?.Invoke(this); } else if (Transaction.Status == UGCStatus.Failure) { RanCallbacks = true; OnFailure?.Invoke(this); } } } }
public override void Render(DwarfTime gameTime) { GuiRoot.Draw(); SpeakerWidget.Background = new TileReference(SpeakerAnimation.SpriteSheet.AssetName, SpeakerAnimation.Frames[SpeakerAnimationPlayer.CurrentFrame].X); SpeakerWidget.Invalidate(); base.Render(gameTime); }
public override void Render(DwarfTime gameTime) { TipTimer.Update(gameTime); if (TipTimer.HasTriggered) { var entry = Datastructures.SelectRandom(TutorialManager.EnumerateTutorials()); Tip.Text = entry.Value.Title + "\n" + entry.Value.Text; Tip.Invalidate(); TipTimer.Reset(10.0f); } EnableScreensaver = true; base.Render(gameTime); Runner.Render(Game.GraphicsDevice, DwarfGame.SpriteBatch, gameTime); GuiRoot.Draw(); }
public override void Render(DwarfTime gameTime) { TipTimer.Update(gameTime); if (TipTimer.HasTriggered) { Tip.Text = LoadingTips[MathFunctions.Random.Next(LoadingTips.Count)]; Tip.Invalidate(); } EnableScreensaver = true; if (World != null) { World.Render(gameTime); } base.Render(gameTime); Runner.Render(Game.GraphicsDevice, DwarfGame.SpriteBatch, gameTime); GuiRoot.Draw(); }
private Gui.Widget CreateTrayIcon(int Tile, Gui.Widget Child) { var r = new Gui.Widgets.FramedIcon { Icon = new Gui.TileReference("tool-icons", Tile), OnClick = (sender, args) => { }, OnHover = (sender) => { foreach (var child in sender.Parent.EnumerateChildren().Where(c => c is Gui.Widgets.FramedIcon) .SelectMany(c => c.EnumerateChildren())) { child.Hidden = true; child.Invalidate(); } if (Child != null) { Child.Hidden = false; Child.Invalidate(); } }, OnLayout = (sender) => { if (Child != null) { var midPoint = sender.Rect.X + (sender.Rect.Width / 2); Child.Rect.X = midPoint - (Child.Rect.Width / 2); Child.Rect.Y = sender.Rect.Y - 60; } } }; GuiRoot.ConstructWidget(r); if (Child != null) { r.AddChild(Child); } return(r); }
public override void OnEnter() { // Clear the input queue... cause other states aren't using it and it's been filling up. DwarfGame.GumInputMapper.GetInputQueue(); GuiRoot = new Gui.Root(DwarfGame.GumSkin); GuiRoot.MousePointer = new MousePointer("mouse", 15.0f, 16, 17, 18, 19, 20, 21, 22, 23); var mainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget { Rect = GuiRoot.RenderData.VirtualScreen, Border = "border-fancy", Text = Settings.Name, Font = "font16", TextColor = new Vector4(0, 0, 0, 1), Padding = new Gui.Margin(4, 4, 4, 4), InteriorMargin = new Gui.Margin(24, 0, 0, 0), }); var rightPanel = mainPanel.AddChild(new Gui.Widget { AutoLayout = Gui.AutoLayout.DockRight, MinimumSize = new Point(256, 0), Padding = new Gui.Margin(2, 2, 2, 2) }); rightPanel.AddChild(new Gui.Widget { Text = "Regenerate", Border = "border-button", ChangeColorOnHover = true, TextColor = new Vector4(0, 0, 0, 1), Font = "font16", AutoLayout = Gui.AutoLayout.DockTop, OnClick = (sender, args) => { Settings = new WorldGenerationSettings(); RestartGeneration(); } }); rightPanel.AddChild(new Gui.Widget { Text = "Save World", Border = "border-button", ChangeColorOnHover = true, TextColor = new Vector4(0, 0, 0, 1), Font = "font16", AutoLayout = Gui.AutoLayout.DockTop, OnClick = (sender, args) => { if (Generator.CurrentState != WorldGenerator.GenerationState.Finished) { GuiRoot.ShowTooltip(GuiRoot.MousePosition, "Generator is not finished."); } else { System.IO.DirectoryInfo worldDirectory = System.IO.Directory.CreateDirectory(DwarfGame.GetWorldDirectory() + ProgramData.DirChar + Settings.Name); NewOverworldFile file = new NewOverworldFile(Game.GraphicsDevice, Overworld.Map, Settings.Name, Settings.SeaLevel); file.WriteFile(worldDirectory.FullName); file.SaveScreenshot(worldDirectory.FullName + ProgramData.DirChar + "screenshot.png"); GuiRoot.ShowModalPopup(GuiRoot.ConstructWidget(new Gui.Widgets.Popup { Text = "File saved." })); } } }); rightPanel.AddChild(new Gui.Widget { Text = "Advanced", Border = "border-button", ChangeColorOnHover = true, TextColor = new Vector4(0, 0, 0, 1), Font = "font16", AutoLayout = Gui.AutoLayout.DockTop, OnClick = (sender, args) => { var advancedSettingsEditor = GuiRoot.ConstructWidget(new Gui.Widgets.WorldGenerationSettingsDialog { Settings = Settings, OnClose = (s) => RestartGeneration() }); GuiRoot.ShowModalPopup(advancedSettingsEditor); } }); rightPanel.AddChild(new Gui.Widget { Text = "Back", Border = "border-button", ChangeColorOnHover = true, TextColor = new Vector4(0, 0, 0, 1), Font = "font16", AutoLayout = Gui.AutoLayout.DockTop, OnClick = (sender, args) => { Generator.Abort(); StateManager.PopState(); } }); StartButton = rightPanel.AddChild(new Gui.Widget { Text = "Start Game", Border = "border-button", ChangeColorOnHover = true, TextColor = new Vector4(0, 0, 0, 1), Font = "font16", AutoLayout = Gui.AutoLayout.DockBottom, OnClick = (sender, args) => { if (Generator.CurrentState != WorldGenerator.GenerationState.Finished) { GuiRoot.ShowTooltip(GuiRoot.MousePosition, "World generation is not finished."); } else { Overworld.Name = Settings.Name; Settings.ExistingFile = null; Settings.WorldOrigin = Settings.WorldGenerationOrigin; if (Settings.Natives == null || Settings.Natives.Count == 0) { Settings.Natives = Generator.NativeCivilizations; } StateManager.ClearState(); StateManager.PushState(new LoadState(Game, StateManager, Settings)); } } }); rightPanel.AddChild(new Gui.Widget { Text = "Colony size", AutoLayout = Gui.AutoLayout.DockTop, Font = "font8", TextColor = new Vector4(0, 0, 0, 1) }); var colonySizeCombo = rightPanel.AddChild(new Gui.Widgets.ComboBox { AutoLayout = Gui.AutoLayout.DockTop, Items = new List <string>(new string[] { "Small", "Medium", "Large" }), Font = "font8", TextColor = new Vector4(0, 0, 0, 1), OnSelectedIndexChanged = (sender) => { switch ((sender as Gui.Widgets.ComboBox).SelectedItem) { case "Small": Settings.ColonySize = new Point3(4, 1, 4); break; case "Medium": Settings.ColonySize = new Point3(8, 1, 8); break; case "Large": Settings.ColonySize = new Point3(10, 1, 10); break; } var worldSize = Settings.ColonySize.ToVector3() * VoxelConstants.ChunkSizeX / Settings.WorldScale; float w = worldSize.X / 2; float h = worldSize.Z / 2; float clickX = System.Math.Max(System.Math.Min(Settings.WorldGenerationOrigin.X, Settings.Width - w), w); float clickY = System.Math.Max(System.Math.Min(Settings.WorldGenerationOrigin.Y, Settings.Height - h), h); Settings.WorldGenerationOrigin = new Vector2((int)(clickX), (int)(clickY)); } }) as Gui.Widgets.ComboBox; rightPanel.AddChild(new Gui.Widget { Text = "Difficulty", AutoLayout = Gui.AutoLayout.DockTop, Font = "font8", TextColor = new Vector4(0, 0, 0, 1) }); var difficultySelectorCombo = rightPanel.AddChild(new Gui.Widgets.ComboBox { AutoLayout = Gui.AutoLayout.DockTop, Items = Embarkment.EmbarkmentLibrary.Select(e => e.Key).ToList(), TextColor = new Vector4(0, 0, 0, 1), Font = "font8", OnSelectedIndexChanged = (sender) => { Settings.InitalEmbarkment = Embarkment.EmbarkmentLibrary[(sender as Gui.Widgets.ComboBox).SelectedItem]; } }) as Gui.Widgets.ComboBox; ZoomedPreview = rightPanel.AddChild(new Gui.Widget { AutoLayout = Gui.AutoLayout.DockBottom, OnLayout = (sender) => { var space = System.Math.Min( difficultySelectorCombo.Rect.Width, StartButton.Rect.Top - difficultySelectorCombo.Rect.Bottom - 4); sender.Rect.Height = space; sender.Rect.Width = space; sender.Rect.Y = difficultySelectorCombo.Rect.Bottom + 2; sender.Rect.X = difficultySelectorCombo.Rect.X + ((difficultySelectorCombo.Rect.Width - space) / 2); } }); StatsLabel = rightPanel.AddChild(new Gui.Widget() { AutoLayout = Gui.AutoLayout.DockBottom, Font = "font8", TextColor = new Vector4(1, 1, 1, 1), Background = new TileReference("sbasic", 0), BackgroundColor = new Vector4(0.0f, 0.0f, 0.0f, 0.2f), TextHorizontalAlign = HorizontalAlign.Left, MinimumSize = new Point(128, 64), WrapText = true, Padding = new Margin(10, 10, 10, 0) }); GenerationProgress = mainPanel.AddChild(new Gui.Widgets.ProgressBar { AutoLayout = Gui.AutoLayout.DockBottom, TextHorizontalAlign = Gui.HorizontalAlign.Center, TextVerticalAlign = Gui.VerticalAlign.Center, Font = "font10", TextColor = new Vector4(1, 1, 1, 1) }) as Gui.Widgets.ProgressBar; Preview = mainPanel.AddChild(new WorldGeneratorPreview(Game.GraphicsDevice) { Border = "border-thin", AutoLayout = Gui.AutoLayout.DockFill }) as WorldGeneratorPreview; GuiRoot.RootItem.Layout(); Preview.PreviewPanel.OnClick += (widget, args) => { StatsLabel.Text = Generator.GetSpawnStats(); StatsLabel.Invalidate(); }; difficultySelectorCombo.SelectedIndex = difficultySelectorCombo.Items.IndexOf("Normal"); colonySizeCombo.SelectedIndex = colonySizeCombo.Items.IndexOf("Medium"); IsInitialized = true; if (AutoGenerate) { RestartGeneration(); } else // Setup a dummy generator for now. { Generator = new WorldGenerator(Settings); Generator.LoadDummy( new Color[Overworld.Map.GetLength(0) * Overworld.Map.GetLength(1)], Game.GraphicsDevice); Preview.SetGenerator(Generator); } base.OnEnter(); }