/// <summary> /// Sets up the 'Current map' Panel. /// </summary> private void refreshCurrentMapPanel() { if (scrCurrentMap == null) { panelCurrentMap.AddWidget(scrCurrentMap = new ScrollBars()); State.MapScreen_WindowArea = new Point(panelCurrentMap.InputArea.Width, panelCurrentMap.InputArea.Width); } Data.Map map = State.Data.Maps[State.SelectedMap]; Point mapArea = new Point(map.WidthInSuperChunks * 256, map.HeightInSuperChunks * 256); scrCurrentMap.OverrideScrollArea(new Rectangle(0, 0, mapArea.X, mapArea.Y)); State.MapScreen_MapArea = mapArea; if (State.MapScreen_Scroll.X >= mapArea.X - panelCurrentMap.InputArea.Width) { State.MapScreen_Scroll.X = mapArea.X - panelCurrentMap.InputArea.Width; } if (State.MapScreen_Scroll.Y >= mapArea.Y - panelCurrentMap.InputArea.Height) { State.MapScreen_Scroll.Y = mapArea.Y - panelCurrentMap.InputArea.Height; } initializeMapAndLoadAllChunks(1); mmpMini.RefreshEntireMap(State.Data.Maps[State.SelectedMap]); }
/// <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); } } } } }
public void RefreshEntireMap(Data.Map map) { if (m_RenderingMap) { m_Cancel = true; while (m_RenderingMap) { System.Threading.Thread.Sleep(1); } } m_Cancel = false; m_Map = map; Core.ParallelTasks.Parallel.StartBackground(new Action(refreshEntireMap)); }
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; } }