private void LayoutYZ(Vector3i Sides, Vector3i min, Vector3i max) { Console.WriteLine("long y = {0}; y < {1}; y += {2}", min.Y / Sides.Y, max.Y / Sides.Y, _Map.ChunkScale.Y / Sides.Y); for (long y = min.Y / Sides.Y; y < max.Y / Sides.Y; y += _Map.ChunkScale.Y / Sides.Y) { for (long x = min.X / Sides.X; x < max.X / Sides.X; x += _Map.ChunkScale.X / Sides.X) { Vector3i cc = new Vector3i(x + (min.X / _Map.ChunkScale.X), y + (min.Y / _Map.ChunkScale.Y), (CurrentPosition.Z / _Map.ChunkScale.X)); if (!Chunks.ContainsKey(cc)) { MapChunkControl mcc = new MapChunkControl(this, cc, _Map.ChunkScale); mcc.SetBounds((int)(cc.Y * _Map.ChunkScale.Y) + 6, (int)(cc.Z * _Map.ChunkScale.Z) + 6, (int)(_Map.ChunkScale.Y), (int)(_Map.ChunkScale.Z)); Controls.Add(mcc); Chunks.Add(cc, mcc); } else { /* * MapChunkControl mcc = Chunks[cc]; * mcc.SetBounds((int)(cc.Y * _Map.ChunkScale.Y)+6, (int)(cc.Z * _Map.ChunkScale.Z)+6, (int)(_Map.ChunkScale.Y), (int)(_Map.ChunkScale.Z)); * Controls.Add(mcc); * Chunks.Add(cc, mcc);*/ } } } }
private void LayoutXY(Vector3i Sides, Vector3i min, Vector3i max) { for (int x = 0; x < (Width / Sides.X); x++) { for (int y = 0; y < (Height / Sides.Y); y++) { Vector3i cc = new Vector3i(x + (min.X / _Map.ChunkScale.X), y + (min.Y / _Map.ChunkScale.Y), (CurrentPosition.Z / _Map.ChunkScale.X)); if (!Chunks.ContainsKey(cc)) { MapChunkControl mcc = new MapChunkControl(this, cc, _Map.ChunkScale); mcc.SetBounds((int)(cc.X * _Map.ChunkScale.X), (int)(cc.Y * _Map.ChunkScale.Y), (int)(_Map.ChunkScale.X), (int)(_Map.ChunkScale.Y)); Controls.Add(mcc); Chunks.Add(cc, mcc); } else { MapChunkControl mcc = Chunks[cc]; mcc.SetBounds((int)(cc.X * _Map.ChunkScale.X), (int)(cc.Y * _Map.ChunkScale.Y), (int)(_Map.ChunkScale.X), (int)(_Map.ChunkScale.Y)); Controls.Add(mcc); Chunks.Add(cc, mcc); } } } }
private void LayoutYZ(Vector3i Sides, Vector3i min, Vector3i max) { Console.WriteLine("long y = {0}; y < {1}; y += {2}", min.Y / Sides.Y, max.Y / Sides.Y, _Map.ChunkScale.Y / Sides.Y); for (long y = min.Y / Sides.Y; y < max.Y / Sides.Y; y += _Map.ChunkScale.Y / Sides.Y) { for (long x = min.X / Sides.X; x < max.X / Sides.X; x += _Map.ChunkScale.X/Sides.X) { Vector3i cc = new Vector3i(x+(min.X / _Map.ChunkScale.X), y + (min.Y / _Map.ChunkScale.Y), (CurrentPosition.Z / _Map.ChunkScale.X)); if (!Chunks.ContainsKey(cc)) { MapChunkControl mcc = new MapChunkControl(this, cc, _Map.ChunkScale); mcc.SetBounds((int)(cc.Y * _Map.ChunkScale.Y)+6, (int)(cc.Z * _Map.ChunkScale.Z)+6, (int)(_Map.ChunkScale.Y), (int)(_Map.ChunkScale.Z)); Controls.Add(mcc); Chunks.Add(cc, mcc); } else { /* MapChunkControl mcc = Chunks[cc]; mcc.SetBounds((int)(cc.Y * _Map.ChunkScale.Y)+6, (int)(cc.Z * _Map.ChunkScale.Z)+6, (int)(_Map.ChunkScale.Y), (int)(_Map.ChunkScale.Z)); Controls.Add(mcc); Chunks.Add(cc, mcc);*/ } } } }
private void LayoutXY(Vector3i Sides, Vector3i min, Vector3i max) { for (int x = 0; x < (Width/Sides.X); x++) { for (int y = 0; y < (Height/Sides.Y); y++) { Vector3i cc = new Vector3i(x + (min.X / _Map.ChunkScale.X), y + (min.Y / _Map.ChunkScale.Y), (CurrentPosition.Z / _Map.ChunkScale.X)); if (!Chunks.ContainsKey(cc)) { MapChunkControl mcc = new MapChunkControl(this, cc, _Map.ChunkScale); mcc.SetBounds((int)(cc.X * _Map.ChunkScale.X), (int)(cc.Y * _Map.ChunkScale.Y), (int)(_Map.ChunkScale.X), (int)(_Map.ChunkScale.Y)); Controls.Add(mcc); Chunks.Add(cc, mcc); } else { MapChunkControl mcc = Chunks[cc]; mcc.SetBounds((int)(cc.X * _Map.ChunkScale.X), (int)(cc.Y * _Map.ChunkScale.Y), (int)(_Map.ChunkScale.X), (int)(_Map.ChunkScale.Y)); Controls.Add(mcc); Chunks.Add(cc, mcc); } } } }
/// <summary> /// Only version that works correctly atm. /// </summary> /// <param name="Sides"></param> /// <param name="min"></param> /// <param name="max"></param> private void LayoutTopdown(Vector3i Sides, Vector3i min, Vector3i max) { for (int x = 0; x < Width/Sides.X; x++) { for (int y = 0; y <Height/Sides.Y; y++) { Vector3i cc = new Vector3i(x + (min.X / _Map.ChunkScale.X),y + (CurrentPosition.Y / _Map.ChunkScale.Y), (min.Y / _Map.ChunkScale.Z)); if (!Chunks.ContainsKey(cc)) { MapChunkControl mcc = new MapChunkControl(this, cc, _Map.ChunkScale); mcc.MouseClick += new MouseEventHandler(ChunkRightClicked); mcc.SendToBack(); mcc.SetBounds((int)(x * _Map.ChunkScale.X)*ZoomLevel+6, (int)(y * _Map.ChunkScale.Y)*ZoomLevel+6, (int)(_Map.ChunkScale.X)*ZoomLevel, (int)(_Map.ChunkScale.Y)*ZoomLevel); //Console.WriteLine("Added chunk to {0},{1}", mcc.Top, mcc.Left); Controls.Add(mcc); Chunks.Add(cc, mcc); } else { MapChunkControl mcc = Chunks[cc]; mcc.SetBounds((int)(x * _Map.ChunkScale.X) * ZoomLevel+6, (int)(y * _Map.ChunkScale.Y) * ZoomLevel+6, (int)(_Map.ChunkScale.X) * ZoomLevel, (int)(_Map.ChunkScale.Y) * ZoomLevel); Controls.Add(mcc); Chunks.Add(cc, mcc); } } } /* foreach (KeyValuePair<Guid, Entity> k in _Map.Entities) { Entity e = k.Value; if (e.Pos.X > min.X && e.Pos.X < max.X && e.Pos.Y > min.Y && e.Pos.Y < max.Y) { Button b = new Button(); float x = (float)e.Pos.X + (float)min.X; float y = (float)e.Pos.Y + (float)min.Y; //b.SetBounds((int)y * ZoomLevel - 2, (int)y * ZoomLevel - 2, 16, 16); b.SetBounds((int)(e.Pos.X - min.X) * ZoomLevel, (int)(e.Pos.Y - min.Y) * ZoomLevel, 16, 16); b.Image = e.Image; b.UseVisualStyleBackColor = true; b.BackColor = Color.Transparent; b.FlatStyle = FlatStyle.Flat; b.ImageAlign = ContentAlignment.MiddleCenter; b.FlatAppearance.BorderSize = 1; b.FlatAppearance.BorderColor = Color.Black; b.FlatAppearance.MouseOverBackColor = Color.Transparent; b.Click += new EventHandler(OnEntityClicked); b.Tag = e; Controls.Add(b); EntityControls.Add(b); b.Show(); b.BringToFront(); Console.WriteLine("{0} {1} added to pos {2},{3}", e, e.UUID, b.Top, b.Left); } } foreach (KeyValuePair<Guid, TileEntity> k in _Map.TileEntities) { TileEntity e = k.Value; if (e.Pos.X > min.X && e.Pos.X < max.X && e.Pos.Y > min.Y && e.Pos.Y < max.Y) { Button b = new Button(); b.SetBounds((int)(e.Pos.X - min.X) * ZoomLevel + 6, (int)(e.Pos.Y - min.Y) * ZoomLevel + 6, 16, 16); b.Image = e.Image; b.UseVisualStyleBackColor = true; b.BackColor = Color.Transparent; b.FlatStyle = FlatStyle.Flat; b.ImageAlign = ContentAlignment.MiddleCenter; b.FlatAppearance.BorderSize = 1; b.FlatAppearance.BorderColor = Color.Black; b.FlatAppearance.MouseOverBackColor = Color.Transparent; b.Click += new EventHandler(OnTileEntityClicked); b.Tag = e; Controls.Add(b); EntityControls.Add(b); b.Show(); b.BringToFront(); Console.WriteLine("{0} {1} added to pos {2},{3}", e, e.UUID, b.Top, b.Left); } }*/ }
/// <summary> /// Only version that works correctly atm. /// </summary> /// <param name="Sides"></param> /// <param name="min"></param> /// <param name="max"></param> private void LayoutTopdown(Vector3i Sides, Vector3i min, Vector3i max) { for (int x = 0; x < Width / Sides.X; x++) { for (int y = 0; y < Height / Sides.Y; y++) { Vector3i cc = new Vector3i(x + (min.X / _Map.ChunkScale.X), y + (CurrentPosition.Y / _Map.ChunkScale.Y), (min.Y / _Map.ChunkScale.Z)); if (!Chunks.ContainsKey(cc)) { MapChunkControl mcc = new MapChunkControl(this, cc, _Map.ChunkScale); mcc.MouseClick += new MouseEventHandler(ChunkRightClicked); mcc.SendToBack(); mcc.SetBounds((int)(x * _Map.ChunkScale.X) * ZoomLevel + 6, (int)(y * _Map.ChunkScale.Y) * ZoomLevel + 6, (int)(_Map.ChunkScale.X) * ZoomLevel, (int)(_Map.ChunkScale.Y) * ZoomLevel); //Console.WriteLine("Added chunk to {0},{1}", mcc.Top, mcc.Left); Controls.Add(mcc); Chunks.Add(cc, mcc); } else { MapChunkControl mcc = Chunks[cc]; mcc.SetBounds((int)(x * _Map.ChunkScale.X) * ZoomLevel + 6, (int)(y * _Map.ChunkScale.Y) * ZoomLevel + 6, (int)(_Map.ChunkScale.X) * ZoomLevel, (int)(_Map.ChunkScale.Y) * ZoomLevel); Controls.Add(mcc); Chunks.Add(cc, mcc); } } } /* * foreach (KeyValuePair<Guid, Entity> k in _Map.Entities) * { * Entity e = k.Value; * if (e.Pos.X > min.X && e.Pos.X < max.X && e.Pos.Y > min.Y && e.Pos.Y < max.Y) * { * Button b = new Button(); * float x = (float)e.Pos.X + (float)min.X; * float y = (float)e.Pos.Y + (float)min.Y; * //b.SetBounds((int)y * ZoomLevel - 2, (int)y * ZoomLevel - 2, 16, 16); * b.SetBounds((int)(e.Pos.X - min.X) * ZoomLevel, (int)(e.Pos.Y - min.Y) * ZoomLevel, 16, 16); * b.Image = e.Image; * b.UseVisualStyleBackColor = true; * b.BackColor = Color.Transparent; * b.FlatStyle = FlatStyle.Flat; * b.ImageAlign = ContentAlignment.MiddleCenter; * b.FlatAppearance.BorderSize = 1; * b.FlatAppearance.BorderColor = Color.Black; * b.FlatAppearance.MouseOverBackColor = Color.Transparent; * b.Click += new EventHandler(OnEntityClicked); * b.Tag = e; * Controls.Add(b); * EntityControls.Add(b); * b.Show(); * b.BringToFront(); * Console.WriteLine("{0} {1} added to pos {2},{3}", e, e.UUID, b.Top, b.Left); * } * } * foreach (KeyValuePair<Guid, TileEntity> k in _Map.TileEntities) * { * TileEntity e = k.Value; * if (e.Pos.X > min.X && e.Pos.X < max.X && e.Pos.Y > min.Y && e.Pos.Y < max.Y) * { * Button b = new Button(); * b.SetBounds((int)(e.Pos.X - min.X) * ZoomLevel + 6, (int)(e.Pos.Y - min.Y) * ZoomLevel + 6, 16, 16); * b.Image = e.Image; * b.UseVisualStyleBackColor = true; * b.BackColor = Color.Transparent; * b.FlatStyle = FlatStyle.Flat; * b.ImageAlign = ContentAlignment.MiddleCenter; * b.FlatAppearance.BorderSize = 1; * b.FlatAppearance.BorderColor = Color.Black; * b.FlatAppearance.MouseOverBackColor = Color.Transparent; * b.Click += new EventHandler(OnTileEntityClicked); * b.Tag = e; * Controls.Add(b); * EntityControls.Add(b); * b.Show(); * b.BringToFront(); * Console.WriteLine("{0} {1} added to pos {2},{3}", e, e.UUID, b.Top, b.Left); * } * }*/ }