private void canvas_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                var canvas         = sender as ZoomableCanvas;
                var pixelLocationF = canvas.PointToImagePixel(e.Location);
                var location       = new Point((int)Math.Round(pixelLocationF.X, 0), (int)Math.Round(pixelLocationF.Y, 0));
                if (location.X < 0 || location.Y < 0 || location.X >= canvas.ImageSize.Width || location.Y >= canvas.ImageSize.Height)
                {
                    return;
                }

                var tile = _tiles.GetTileScreen(location);
                if (tile == null)
                {
                    return;
                }
                _drawingSurface.Lock();
                RequestTileEvaluate(tile);
                _drawingSurface.Unlock();
            }
            if (e.Button == MouseButtons.Right)
            {
                _oldPoint = e.Location;
            }
        }
		public DebugDrawingSurfaceWindow(DrawingSurface ds, TileLayer tiles, Theater t, Map.Map map)
			: this() {
			_drawingSurface = ds;
			_tiles = tiles;
			_theater = t;
			_map = map;

			ds.Unlock();
			pictureBox1.Image = ds.Bitmap;
		}
        public DebugDrawingSurfaceWindow(DrawingSurface ds, TileLayer tiles, Theater t, Map.Map map)
            : this()
        {
            _drawingSurface = ds;
            _tiles          = tiles;
            _theater        = t;
            _map            = map;

            ds.Unlock();
            pictureBox1.Image = ds.Bitmap;
        }
Example #4
0
        public DebugDrawingSurfaceWindow(DrawingSurface ds, TileLayer tiles, Theater t, Map.Map map)
            : this()
        {
            _drawingSurface = ds;
            _tiles          = tiles;
            _theater        = t;
            _map            = map;

            _cells = (_map.FullSize.Width * 2 - 1) * _map.FullSize.Height;

            ds.Unlock();
            pictureBox1.Image = ds.Bitmap;
        }
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         var tile = _tiles.GetTileScreen(e.Location);
         if (tile == null)
         {
             return;
         }
         _drawingSurface.Lock();
         RequestTileEvaluate(tile);
         _drawingSurface.Unlock();
     }
 }
        public DebugDrawingSurfaceWindow(DrawingSurface ds, TileLayer tiles, Theater t, Map.Map map)
            : this()
        {
            _drawingSurface = ds;
            _tiles          = tiles;
            _theater        = t;
            _map            = map;

            _cells = (_map.FullSize.Width * 2 - 1) * _map.FullSize.Height;

            ds.Unlock();

            // map is pre-rendered bitmap, shadow/heightmap are rendered on demand
            canvasMap.Image = ds.Bitmap;
        }
Example #7
0
		public void Draw() {
			_drawingSurface = new DrawingSurface(FullSize.Width * TileWidth, FullSize.Height * TileHeight, PixelFormat.Format24bppRgb);
			
#if SORT
			Logger.Info("Sorting objects map");
			var sorter = new ObjectSorter(_theater, _tiles);
			var orderedObjs = sorter.GetOrderedObjects().ToList();

			double lastReported = 0.0;
			Logger.Info("Drawing map... 0%");
			for (int i = 0; i < orderedObjs.Count; i++) {
				var obj = orderedObjs[i];
				_theater.Draw(obj, _drawingSurface);
				double pct = 100.0 * i / orderedObjs.Count;
				if (pct > lastReported + 5) {
					Logger.Info("Drawing map... {0}%", Math.Round(pct, 0));
					lastReported = pct;
				}
			}
#else
			double lastReported = 0.0;
			for (int y = 0; y < FullSize.Height; y++) {
				Logger.Trace("Drawing tiles row {0}", y);
				for (int x = FullSize.Width * 2 - 2; x >= 0; x -= 2)
					_theater.Draw(_tiles.GetTile(x, y), _drawingSurface);
				for (int x = FullSize.Width * 2 - 3; x >= 0; x -= 2)
					_theater.Draw(_tiles.GetTile(x, y), _drawingSurface);

				double pct = 50.0 * y / FullSize.Height;
				if (pct > lastReported + 5) {
					Logger.Info("Drawing tiles... {0}%", Math.Round(pct, 0));
					lastReported = pct;
				}
			}
			Logger.Info("Tiles drawn");

			for (int y = 0; y < FullSize.Height; y++) {
				Logger.Trace("Drawing objects row {0}", y);
				for (int x = FullSize.Width * 2 - 2; x >= 0; x -= 2)
					foreach (GameObject o in GetObjectsAt(x, y))
						_theater.Draw(o, _drawingSurface);

				for (int x = FullSize.Width * 2 - 3; x >= 0; x -= 2)
					foreach (GameObject o in GetObjectsAt(x, y))
						_theater.Draw(o, _drawingSurface);

				double pct = 50 + 50.0 * y / FullSize.Height;
				if (pct > lastReported + 5) {
					Logger.Info("Drawing objects... {0}%", Math.Round(pct, 0));
					lastReported = pct;
				}
			}
#endif


#if DEBUG && FALSE
			// test that my bounds make some kind of sense
			_drawingSurface.Unlock();
			using (Graphics gfx = Graphics.FromImage(_drawingSurface.Bitmap)) {
				foreach (var obj in _tiles.SelectMany(t=>t.AllObjects))
					if (obj.Drawable != null)
						obj.Drawable.DrawBoundingBox(obj, gfx);
			}
#endif

			Logger.Info("Map drawing completed");
		}