public WorldView(World world, CameraClampMode cameraClampMode, InputHandler input) { _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache"); World = world; GameStatusHandler = new GameStatusHandler(GameStatus.OverlandMap); Input = input; Camera = new Camera(this, new Rectangle(0, 0, 1680, 1080), cameraClampMode, Input); var globalContextPresentation = CallContext <GlobalContextPresentation> .GetData("GlobalContextPresentation"); globalContextPresentation.Camera = Camera; OverlandMapView = new OverlandMapView(this, World.OverlandMap, Input); OverlandSettlementViews = new OverlandSettlementViews(this, World.Settlements, Input); StackViews = new StackViews(this, World.Stacks, Input); SettlementView = new SettlementView(this, World.Settlements.Count > 0 ? World.Settlements[0] : new Settlement("Test", 1, PointI.Zero, 1, World.OverlandMap.CellGrid, new int[0]), Input); HudView = new HudView(this, StackViews, Input); //Tooltip = new Tooltip(Vector2.Zero, Alignment.TopLeft, new Vector2(200.0f, 300.0f), "GUI_Textures_1.sp_frame", 25, 25, 25, 25, "tooltip") { Enabled = false }; var context = CallContext <GlobalContextPresentation> .GetData("GlobalContextPresentation"); Viewport = new Viewport(0, 0, Camera.GetViewport.Width, Camera.GetViewport.Height, 0.0f, 1.0f); ViewportAdapter = new ScalingViewportAdapter(context.GraphicsDevice, Camera.GetViewport.Width, Camera.GetViewport.Height); MovementTypeImages = InitializeMovementTypeImages(); ActionButtons = InitializeActionButtons(); }
internal void LoadContent(ContentManager content) { Camera.LoadContent(content); OverlandMapView.LoadContent(content); OverlandSettlementViews.LoadContent(content); StackViews.LoadContent(content); SettlementView.LoadContent(content); HudView.LoadContent(content); //Tooltip.LoadContent(content); MovementTypeImages.LoadContent(content); ActionButtons.LoadContent(content, true); }
internal (bool unitClicked, UnitView unitView) CheckForUnitSelectionInHudView(Point mouseLocation) { var mouseLocation2 = new Point(mouseLocation.X - 1680, mouseLocation.Y); var unitsToDraw = HudView.GetUnitsToDraw(StackViews, CurrentlySelectedStackView); foreach (var unitToDraw in unitsToDraw) { if (unitToDraw.DestinationRectangle.Contains(mouseLocation2)) { return(true, unitToDraw); } } return(false, null); }
internal void Update(GameTime gameTime) { var deltaTime = (float)gameTime.ElapsedGameTime.TotalMilliseconds; Camera.Update(deltaTime); OverlandMapView.Update(deltaTime); OverlandSettlementViews.Update(deltaTime); StackViews.Update(deltaTime); SettlementView.Settlement = World.Settlements.Selected; if (SettlementView.Settlement != null) { SettlementView.Update(gameTime, null); } HudView.Update(gameTime); StackViews.RemoveDeadUnits(); }
internal void Draw(SpriteBatch spriteBatch) { OverlandMapView.Draw(spriteBatch, Camera); OverlandSettlementViews.Draw(spriteBatch, Camera); StackViews.Draw(spriteBatch, Camera); HudView.Draw(spriteBatch); //if (Tooltip.Enabled) //{ // var originalViewport = spriteBatch.GraphicsDevice.Viewport; // spriteBatch.GraphicsDevice.Viewport = Viewport; // spriteBatch.Begin(samplerState: SamplerState.PointWrap, transformMatrix: ViewportAdapter.GetScaleMatrix()); // Tooltip.Draw(spriteBatch); // spriteBatch.End(); // spriteBatch.GraphicsDevice.Viewport = originalViewport; //} SettlementView.Draw(spriteBatch); }