/// <summary> /// When overridden in the derived class, draws the graphics to the control. /// </summary> /// <param name="currentTime">The current time.</param> protected override void HandleDraw(TickCount currentTime) { if (DesignMode) { base.HandleDraw(currentTime); return; } TransBoxManager.Update(currentTime); Cursor = TransBoxManager.CurrentCursor; int deltaTime; if (_lastUpdateTime == TickCount.MinValue) { deltaTime = 30; } else { deltaTime = Math.Max(5, (int)(currentTime - _lastUpdateTime)); } _lastUpdateTime = currentTime; DrawingManager.Update(currentTime); _camera.Min += _cameraVelocity * (deltaTime / 1000f); // Update UpdateMap(currentTime, deltaTime); ToolManager.Instance.MapDrawingExtensions.Map = Map; // Draw the world try { var worldSB = DrawingManager.BeginDrawWorld(Camera); if (worldSB != null) { DrawMapWorld(worldSB); } } finally { if (DrawingManager.State != DrawingManagerState.Idle) { DrawingManager.EndDrawWorld(); } } // Draw the GUI try { var guiSB = DrawingManager.BeginDrawGUI(); if (guiSB != null) { DrawMapGUI(guiSB); } } finally { if (DrawingManager.State != DrawingManagerState.Idle) { DrawingManager.EndDrawGUI(); } } }
/// <summary> /// When overridden in the derived class, draws the graphics to the control. /// </summary> /// <param name="currentTime">The current time.</param> protected override void HandleDraw(TickCount currentTime) { base.HandleDraw(currentTime); if (DesignMode) { return; } if (_drawingManager.RenderWindow == null) { return; } if (Grh == null) { return; } Grh.Update(currentTime); m.Update(currentTime); _drawingManager.Update(currentTime); var sb = _drawingManager.BeginDrawWorld(_camera); if (sb == null) { return; } // Change the view var oldView = RenderWindow.GetView(); _drawView.Reset(new FloatRect(Camera.Min.X, Camera.Min.Y, Camera.Size.X, Camera.Size.Y)); RenderWindow.SetView(_drawView); try { try { Grh.Draw(sb, Vector2.Zero, Color.White); } catch (LoadingFailedException) { // A LoadingFailedException is generally fine here since it probably means the graphic file was invalid // or does not exist } // Draw the walls if (Walls != null) { foreach (var wall in Walls) { var rect = wall.ToRectangle(); RenderRectangle.Draw(sb, rect, _autoWallColor); } } m.Draw(sb, Camera); } finally { _drawingManager.EndDrawWorld(); // Restore the view RenderWindow.SetView(oldView); } }
/// <summary> /// When overridden in the derived class, draws the graphics to the control. /// </summary> /// <param name="currentTime">The current time.</param> protected override void HandleDraw(TickCount currentTime) { if (DesignMode) { base.HandleDraw(currentTime); return; } TransBoxManager.Update(currentTime); // Update the cursor display for the transformation box. Only change the cursor if we are currently // under a transbox, or we have just stopped being under one. If we update it every frame, it screws with the // UI display for everything else (like when the cursor is over a textbox). var transBoxCursor = TransBoxManager.CurrentCursor; if (transBoxCursor == null) { if (_wasUnderTransBox) { Cursor = Cursors.Default; _wasUnderTransBox = false; } } else { Cursor = transBoxCursor; _wasUnderTransBox = true; } int deltaTime; if (_lastUpdateTime == TickCount.MinValue) { deltaTime = 30; } else { deltaTime = Math.Max(5, (int)(currentTime - _lastUpdateTime)); } _lastUpdateTime = currentTime; DrawingManager.Update(currentTime); _camera.Min += _cameraVelocity * (deltaTime / 1000f); // Update UpdateMap(currentTime, deltaTime); ToolManager.Instance.MapDrawingExtensions.Map = Map; // Draw the world try { var worldSB = DrawingManager.BeginDrawWorld(Camera); if (worldSB != null) { DrawMapWorld(worldSB); } } finally { if (DrawingManager.State != DrawingManagerState.Idle) { DrawingManager.EndDrawWorld(); } } // Draw the GUI try { var guiSB = DrawingManager.BeginDrawGUI(); if (guiSB != null) { DrawMapGUI(guiSB); } } finally { if (DrawingManager.State != DrawingManagerState.Idle) { DrawingManager.EndDrawGUI(); } } }