public override void updatePreview() { PreviewDrawer drawer; // TODO: locations of the previews are uttely incorrect. fix them // direction N using (drawer = new PreviewDrawer(pictureN.ClientSize, new Size(2, 4), 0)) { drawer.draw(RailPattern.getSlope(Direction.NORTH, 3), 1, -1); drawer.draw(RailPattern.getSlope(Direction.NORTH, 2), 1, 0); drawer.draw(RailPattern.getSlope(Direction.NORTH, 1), 0, 2); drawer.draw(RailPattern.getSlope(Direction.NORTH, 0), 0, 3); if (pictureN.Image != null) { pictureN.Image.Dispose(); } pictureN.Image = drawer.createBitmap(); } // direction S using (drawer = new PreviewDrawer(pictureS.ClientSize, new Size(2, 4), 0)) { drawer.draw(RailPattern.getSlope(Direction.SOUTH, 0), 0, 0); drawer.draw(RailPattern.getSlope(Direction.SOUTH, 1), 0, 1); drawer.draw(RailPattern.getSlope(Direction.SOUTH, 2), 1, 1); drawer.draw(RailPattern.getSlope(Direction.SOUTH, 3), 1, 2); if (pictureS.Image != null) { pictureS.Image.Dispose(); } pictureS.Image = drawer.createBitmap(); } // direction E using (drawer = new PreviewDrawer(pictureE.ClientSize, new Size(4, 2), 0)) { drawer.draw(RailPattern.getSlope(Direction.EAST, 3), 3, 0); drawer.draw(RailPattern.getSlope(Direction.EAST, 2), 2, 0); drawer.draw(RailPattern.getSlope(Direction.EAST, 1), 0, 1); drawer.draw(RailPattern.getSlope(Direction.EAST, 0), -1, 1); if (pictureE.Image != null) { pictureE.Image.Dispose(); } pictureE.Image = drawer.createBitmap(); } // direction W using (drawer = new PreviewDrawer(pictureW.ClientSize, new Size(4, 2), 0)) { drawer.draw(RailPattern.getSlope(Direction.WEST, 3), 1, 0); drawer.draw(RailPattern.getSlope(Direction.WEST, 2), 2, 0); drawer.draw(RailPattern.getSlope(Direction.WEST, 1), 2, 1); drawer.draw(RailPattern.getSlope(Direction.WEST, 0), 3, 1); if (pictureW.Image != null) { pictureW.Image.Dispose(); } pictureW.Image = drawer.createBitmap(); } }
public void drawAfter(QuarterViewDrawer view, DrawContextEx dc) { if (!isPlacing) { return; } Location loc = lastMouse; if (loc == world.Location.UNPLACED) { return; } if (!SlopeRailRoad.canCreateSlope(loc, direction)) { return; } Surface canvas = dc.surface; int Z = loc.z; for (int i = 0; i < 4; i++) { if (i == 2) { loc.z++; } for (int j = World.world.getGroundLevel(loc); j < Z; j++) { // TODO: ground level handling BridgePierVoxel.defaultSprite.drawAlpha( canvas, view.fromXYZToClient(loc.x, loc.y, j)); } RailPattern.getSlope(direction, i).drawAlpha( canvas, view.fromXYZToClient(loc)); loc += direction; } }