public override void Update(DwarfTime gameTime) { foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { // Pass event to game... } } GenerationProgress.Text = Generator.LoadingMessage; GenerationProgress.Percentage = Generator.Progress * 100.0f; // Enable or disable start button based on Generator state. GuiRoot.Update(gameTime.ToGameTime()); if (Generator.CurrentState == WorldGenerator.GenerationState.Finished) { Preview.Update(); } base.Update(gameTime); Preview.PreparePreview(StateManager.Game.GraphicsDevice); }
public void FireActions(Gui.Root Gui, Action <Gui.InputEvents, Gui.InputEventArgs> externalHandler) { if (!GameState.Game.IsActive) { return; } var queue = Mapper.GetInputQueue(); foreach (var @event in queue) { if (Gui != null) { Gui.HandleInput(@event.Message, @event.Args); } if ([email protected]) { if (externalHandler != null) { externalHandler(@event.Message, @event.Args); } } } }
public void FireActions(Gui.Root Gui, Action <Gui.InputEvents, Gui.InputEventArgs> MouseHandler) { if (!GameState.Game.IsActive) { return; } var queue = Mapper.GetInputQueue(); foreach (var @event in queue) { if (Gui != null) { Gui.HandleInput(@event.Message, @event.Args); } if ([email protected]) { if (@event.Message == global::DwarfCorp.Gui.InputEvents.MouseClick || @event.Message == global::DwarfCorp.Gui.InputEvents.MouseMove || @event.Message == global::DwarfCorp.Gui.InputEvents.MouseDown || @event.Message == global::DwarfCorp.Gui.InputEvents.MouseUp || @event.Message == global::DwarfCorp.Gui.InputEvents.MouseWheel) { if (MouseHandler != null) { MouseHandler(@event.Message, @event.Args); } } else if (@event.Message == global::DwarfCorp.Gui.InputEvents.KeyUp) { GumInputMapper.QueuedInput localevent = @event; foreach (var binding in InputActions.Where((KeyValuePair <string, InputAction> ia) => ia.Value.Keys.Contains((Keys)localevent.Args.KeyValue) && ia.Value.Type == KeyBindingType.Pressed)) { if (binding.Value.Handler != null) { binding.Value.Handler(); } } } } } // Check 'Held' actions var kbState = Keyboard.GetState(); foreach (var binding in InputActions.Where(ia => ia.Value.Type == KeyBindingType.Held)) { if (binding.Value.Keys.Count(k => kbState.IsKeyDown(k)) > 0 && binding.Value.Handler != null) { binding.Value.Handler(); } } }
public override void Update(DwarfTime gameTime) { foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { // Pass event to game... } } GuiRoot.Update(gameTime.ToRealTime()); base.Update(gameTime); }
public override void Update(DwarfTime gameTime) { World.Tutorial("diplomacy"); foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { // Pass event to game... } } World.TutorialManager.Update(GuiRoot); GuiRoot.Update(gameTime.ToRealTime()); base.Update(gameTime); }
public override void Update(DwarfTime gameTime) { foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); } GuiRoot.Update(gameTime.ToRealTime()); World.TutorialManager.Update(GuiRoot); if (TradePanel.Result == Gui.Widgets.TradeDialogResult.Pending) { return; } StateManager.PopState(); }
public override void Update(DwarfTime gameTime) { foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { // Pass event to game... } } SpriteFrame.AnimationPlayer.Update(gameTime, false, Timer.TimerMode.Real); SpriteFrame.Sprite.Update(StateManager.Game.GraphicsDevice); GuiRoot.Update(gameTime.ToGameTime()); base.Update(gameTime); }
public override void Update(DwarfTime gameTime) { foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { // Pass event to game... } } Progress.Percentage = (float)gameTime.TotalGameTime.TotalSeconds / 10.0f; Progress.Percentage = Progress.Percentage - (float)Math.Floor(Progress.Percentage); GuiRoot.Update(gameTime.ToRealTime()); base.Update(gameTime); }
public override void Update(DwarfTime gameTime) { World.Tutorial("economy"); foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { // Pass event to game... } } SoundManager.Update(gameTime, World.Camera, World.Time); World.TutorialManager.Update(GuiRoot); TabPanel.GetTabButton(1).IndicatorValue = World.GoalManager.NewAvailableGoals; TabPanel.GetTabButton(3).IndicatorValue = World.GoalManager.NewCompletedGoals; GuiRoot.Update(gameTime.ToGameTime()); base.Update(gameTime); }
public override void Update(DwarfTime gameTime) { foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { if (@event.Args.KeyValue > 0) { DialogueContext.Skip(); } // Pass event to game... } } SoundManager.Update(gameTime, World.Camera, World.Time); GuiRoot.Update(gameTime.ToGameTime()); DialogueContext.Update(gameTime); World.TutorialManager.Update(GuiRoot); World.Paused = true; IsInitialized = true; base.OnEnter(); }
public void FireKeyboardActionsOnly(Gui.Root Gui) { if (!GameState.Game.IsActive) { return; } var queue = Mapper.GetInputQueue(); foreach (var @event in queue) { if (@event.Message == InputEvents.KeyDown || @event.Message == InputEvents.KeyPress || @event.Message == InputEvents.KeyUp) { Gui.HandleInput(@event.Message, @event.Args); } if ([email protected]) { Mapper.QueueLock.WaitOne(); Mapper.Queued.Add(@event); Mapper.QueueLock.ReleaseMutex(); } } }
public override void Update(DwarfTime gameTime) { if (DoneLoading) { // Todo: Decouple gui/input from world. // Copy important bits to PlayState - This is a hack; decouple world from gui and input instead. PlayState.Input = Input; StateManager.PopState(false); StateManager.PushState(new PlayState(Game, StateManager, World)); World.OnSetLoadingMessage = null; Overworld.NativeFactions = World.Natives; } else { if (Settings.GenerateFromScratch && Generator.CurrentState == WorldGenerator.GenerationState.Finished && World == null) { Settings = Generator.Settings; CreateWorld(); } else if (Settings.GenerateFromScratch) { if (!LoadTicker.HasMesssage(Generator.LoadingMessage)) { LoadTicker.AddMessage(Generator.LoadingMessage); } } foreach (var item in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(item.Message, item.Args); if (item.Message == Gui.InputEvents.KeyPress) { Runner.Jump(); } } GuiRoot.Update(gameTime.ToRealTime()); Runner.Update(gameTime); if (World != null && World.LoadStatus == WorldManager.LoadingStatus.Failure && !DisplayException) { DisplayException = true; string exceptionText = World.LoadingException == null ? "Unknown exception." : World.LoadingException.ToString(); GuiRoot.MouseVisible = true; GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0); DwarfTime.LastTime.IsPaused = false; DwarfTime.LastTime.Speed = 1.0f; World = null; GuiRoot.ShowModalPopup(new Gui.Widgets.Confirm() { CancelText = "", Text = "Oh no! Loading failed :( This crash has been automatically reported to Completely Fair Games: " + exceptionText, OnClick = (s, a) => { StateManager.PopState(); StateManager.ClearState(); StateManager.PushState(new MainMenuState(Game, StateManager)); }, OnClose = (s) => { StateManager.PopState(); StateManager.ClearState(); StateManager.PushState(new MainMenuState(Game, StateManager)); }, Rect = GuiRoot.RenderData.VirtualScreen }); } } base.Update(gameTime); }
public override void Update(DwarfTime gameTime) { foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { // Pass event to game... } } if (NeedsRefresh) { NeedsRefresh = false; Grid.ClearItems(); int i = 0; foreach (var item in Items) { var itemWidget = new ChooserWidget { Item = item, Background = new TileReference("basic", 0), BackgroundColor = i % 2 == 0 ? new Vector4(0, 0, 0, 0.1f) : new Vector4(0, 0, 0, 0.2f) }; Grid.AddItem(itemWidget); itemWidget.DeleteButton.OnClick = (sender, args) => { var confirm = GuiRoot.ConstructWidget(new Gui.Widgets.Confirm { OkayText = "Delete", CancelText = "Keep", Text = "Are you sure you want to delete this?", OnClose = (s) => { if ((s as Gui.Widgets.Confirm).DialogResult == Gui.Widgets.Confirm.Result.OKAY) { var selectedItem = itemWidget.Item; Items.Remove(selectedItem); try { global::System.IO.Directory.Delete(selectedItem.Path, true); } catch (Exception e) { GuiRoot.ShowModalPopup(new Gui.Widgets.Confirm() { OkayText = "Ok", CancelText = "", Text = e.Message }); } NeedsRefresh = true; } } }); GuiRoot.ShowModalPopup(confirm); }; if (itemWidget.LoadButton != null) { itemWidget.LoadButton.OnClick = (sender, args) => { if (String.IsNullOrEmpty(itemWidget.Item.Valid) && OnProceedClicked != null) { OnProceedClicked(itemWidget.Item.Path); } } } ; i++; } Grid.OnSelectedIndexChanged = (widget) => { this.ItemSelected = Grid.SelectedIndex; NeedsRefresh = true; }; if (Grid.SelectedIndex > Items.Count - 1 || Grid.SelectedIndex < 0) { Grid.SelectedIndex = 0; } ItemSelected = Grid.SelectedIndex; if (Items.Count > 0) { DateTime directoryTime; try { directoryTime = global::System.IO.File.GetLastWriteTime(Items[ItemSelected].Path + System.IO.Path.DirectorySeparatorChar + "meta.txt"); } catch (Exception) { directoryTime = DateTime.MinValue; } BottomBar.Text = Items[ItemSelected].Path; if (!String.IsNullOrEmpty(Items[ItemSelected].Valid)) { BottomBar.Text += "\n" + Items[ItemSelected].Valid; } else { BottomBar.Text += "\n" + directoryTime.ToShortDateString() + " " + directoryTime.ToShortTimeString(); } } else { BottomBar.Text = NoItemsText; } } GuiRoot.Update(gameTime.ToRealTime()); base.Update(gameTime); }
public override void Update(DwarfTime gameTime) { if (DoneLoading) { // Todo: Decouple gui/input from world. // Copy important bits to PlayState - This is a hack; decouple world from gui and input instead. PlayState.Input = Input; GameStateManager.PopState(false); GameStateManager.PushState(new PlayState(Game, World)); World.OnSetLoadingMessage = null; } else { if (LoadType == LoadTypes.GenerateOverworld) { if (Generator.CurrentState == OverworldGenerator.GenerationState.Finished && World == null) { // World generation is finished! LoadTicker.AddMessage("Checking spawn position..."); while (InitialCell.Bounds.Width == 8 && InitialCell.Bounds.Height == 8 && !IsGoodSpawn()) { LoadTicker.AddMessage("Selecting new spawn..."); InitialCell = Settings.ColonyCells.EnumerateCells().Where(c => c.Bounds.Width == 8 && c.Bounds.Height == 8).SelectRandom(); } CreateWorld(); } else { if (!LoadTicker.HasMesssage(Generator.LoadingMessage)) { LoadTicker.AddMessage(Generator.LoadingMessage); } } } foreach (var item in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(item.Message, item.Args); if (item.Message == Gui.InputEvents.KeyPress) { Runner.Jump(); } } GuiRoot.Update(gameTime.ToRealTime()); Runner.Update(gameTime); if (World != null && World.LoadStatus == WorldManager.LoadingStatus.Failure && !DisplayException) { DisplayException = true; string exceptionText = World.LoadingException == null ? "Unknown exception." : World.LoadingException.ToString(); GuiRoot.MouseVisible = true; GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0); DwarfTime.LastTime.IsPaused = false; DwarfTime.LastTime.Speed = 1.0f; World = null; DwarfGame.LogSentryBreadcrumb("Loading", "Loading failed.", SharpRaven.Data.BreadcrumbLevel.Error); GuiRoot.ShowModalPopup(new Gui.Widgets.Confirm() { CancelText = "", Text = "Oh no! Loading failed :( This crash has been automatically reported to the developers: " + exceptionText, OnClick = (s, a) => { DwarfGame.LogSentryBreadcrumb("Loading", "Loading failed. Player going back to start."); GameStateManager.ClearState(); }, OnClose = (s) => { DwarfGame.LogSentryBreadcrumb("Loading", "Loading failed. Player going back to start."); GameStateManager.ClearState(); }, Rect = GuiRoot.RenderData.VirtualScreen }); } } base.Update(gameTime); }
public override void Update(DwarfTime gameTime) { foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue()) { GuiRoot.HandleInput(@event.Message, @event.Args); if ([email protected]) { // Pass event to game... } } if (NeedsRefresh) { NeedsRefresh = false; if (PreviewOffset >= Items.Count && Items.Count > 0) // We're looking at an empty last page... { PreviewOffset -= Grid.ItemsThatFit; } // Keep from selecting empty squares on final, incomplete page. var pageSize = System.Math.Min(Items.Count - PreviewOffset, Grid.ItemsThatFit); if (ItemSelected >= pageSize) { ItemSelected = pageSize - 1; } var totalPages = (int)System.Math.Ceiling((float)Items.Count / (float)Grid.ItemsThatFit); Grid.Text = String.Format("Page {0} of {1}", (int)System.Math.Ceiling((float)PreviewOffset / (float)Grid.ItemsThatFit), totalPages); PrevButton.Hidden = PreviewOffset == 0; NextButton.Hidden = (PreviewOffset + Grid.ItemsThatFit >= Items.Count); DeleteButton.Hidden = Items.Count == 0; LoadButton.Hidden = Items.Count == 0; for (var i = 0; i < Grid.Children.Count; ++i) { var square = Grid.GetChild(i); if (i < pageSize) { square.Hidden = false; square.BackgroundColor = new Vector4(1, 1, 1, 1); if (i == ItemSelected) { square.BackgroundColor = new Vector4(1, 0, 0, 1); } } else { square.Hidden = true; } square.Invalidate(); } if (Items.Count > 0) { var directoryTime = System.IO.Directory.GetLastWriteTime(Items[PreviewOffset + ItemSelected].Path); BottomBar.Text = Items[PreviewOffset + ItemSelected].Path; if (!Items[PreviewOffset + ItemSelected].Valid) { BottomBar.Text += "\n" + InvalidItemText; } else { BottomBar.Text += "\n" + directoryTime.ToShortDateString() + " " + directoryTime.ToShortTimeString(); } } else { BottomBar.Text = NoItemsText; } } GuiRoot.Update(gameTime.ToGameTime()); base.Update(gameTime); }