/// <summary> /// Loads data into a chunk in the 'Current Map' panel. /// </summary> /// <param name="p">The x and y indexes of the chunk to load.</param> /// <param name="index">The index of the chunk in the Current Map panel.</param> private void loadChunk(Point p, int ctl_index) { Data.Map map = State.Data.Maps[State.SelectedMap]; MapChunk ctlChunk = m_Chunks[ctl_index]; int chunk_index = p.X + p.Y * State.Data.Maps[State.SelectedMap].WidthInChunks; int chunk_type = map.GetSuperChunk(p.X / 2, p.Y / 2).Chunks[p.X % 2 + (p.Y % 2) * 2]; ctlChunk.Chunk.ChunkIndexXY = p; if (ctlChunk.Chunk.ChunkType != chunk_type) { if (p.X < 0 || p.X >= map.WidthInChunks || p.Y < 0 || p.Y >= map.HeightInChunks) { return; } else { ctlChunk.Chunk.ChunkType = chunk_type; Data.Chunk chunk = State.Data.Chunks[chunk_type]; for (int i = 0; i < 64; i++) { int tile = chunk[i]; for (int j = 0; j < 4; j++) { TilePageAttribute tile_page_attrib = State.Data.TileSets[State.SelectedTileset].GetSubTile(tile, j); ctlChunk.Chunk.SetTile(i, j, tile_page_attrib.Tile, State.GfxPage(tile_page_attrib.Page).Texture); ctlChunk.Chunk.SetAttribute(i, tile_page_attrib.Attribute); } } } } }
private void refreshEntireMap() { try { m_RenderingMap = true; int w = m_Map.WidthInSuperChunks; int h = m_Map.HeightInSuperChunks; RenderRule.TextureDimension = w * 2 * 2; for (int i = 0; i < w * h; i++) { for (int j = 0; j < 4; j++) { RenderRule.WriteChunk((i % w) * 2 + (j % 2), (i / w) * 2 + (j / 2), State.Data.Chunks[m_Map.GetSuperChunk(i % w, (i / w)).Chunks[j]], State.Data.TileSets[State.SelectedTileset], State.Data.TileGfx); if (m_Cancel) { m_RenderingMap = false; return; } } } } catch { m_RenderingMap = false; return; } m_RenderingMap = false; }
private void mapChunks_Click(Widget widget, InputEventMouse e) { Data.Map map = State.Data.Maps[State.SelectedMap]; Elements.ChunkElement chkelem = ((Elements.ChunkElement)widget); int index = chkelem.ChunkIndex; int x = chkelem.ChunkIndexXY.X; int y = chkelem.ChunkIndexXY.Y; switch (EditMode) { case EditModeEnum.MiniMap: break; case EditModeEnum.Chunks: map.GetSuperChunk(x / 2, y / 2).Chunks[x % 2 + (y % 2) * 2] = State.SelectedChunk; loadChunk(new Point(x, y), x % m_ChunkW + (y % m_ChunkH) * m_ChunkW); break; case EditModeEnum.Actors: case EditModeEnum.Eggs: break; } }