public MinimapTileReadyArgs(MapTileXY position, MapTileBounds bounds, string image, uint index) { Position = position; Bounds = bounds; Image = image; RunnerIndex = index; }
public override void Work() { if (!Program.IsCASCReady) { return; } positions = new MapTileXY[files.Length]; MapTileBounds bounds = new MapTileBounds(); for (int i = 0; i < files.Length; i++) { CASCFile file = files[i]; string tileName = Path.GetFileNameWithoutExtension(file.FullName); Match match = pattern.Match(tileName); if (match.Success) { int tileX = int.Parse(match.Groups[1].Value); int tileY = int.Parse(match.Groups[2].Value); // Update bounds. if (bounds.LowX == -1 || tileX < bounds.LowX) { bounds.LowX = tileX; } if (bounds.HighX == -1 || tileX > bounds.HighX) { bounds.HighX = tileX; } if (bounds.LowY == -1 || tileY < bounds.LowY) { bounds.LowY = tileY; } if (bounds.HighY == -1 || tileY > bounds.HighY) { bounds.HighY = tileY; } positions[i] = new MapTileXY(tileX, tileY); } else { // This should not happen. positions[i] = new MapTileXY(0, 0); } } for (int i = 0; i < files.Length; i++) { CASCFile file = files[i]; MapTileXY position = positions[i]; string tempPath = Path.Combine(Constants.TEMP_DIRECTORY, file.FullName); // Extract the file if we don't already have it cached. if (!File.Exists(tempPath)) { try { Program.CASCEngine.SaveFileTo(file.FullName, Constants.TEMP_DIRECTORY); } catch (Exception e) { Log.Write("Warning: Unable to extract minimap tile {0} -> {1}", file.FullName, e.Message); } } if (File.Exists(tempPath)) { EventManager.Trigger_MinimapTileDone(position, bounds, tempPath, Index); } } }
public override void Work() { if (!Program.IsCASCReady) return; positions = new MapTileXY[files.Length]; MapTileBounds bounds = new MapTileBounds(); for (int i = 0; i < files.Length; i++) { CASCFile file = files[i]; string tileName = Path.GetFileNameWithoutExtension(file.FullName); Match match = pattern.Match(tileName); if (match.Success) { int tileX = int.Parse(match.Groups[1].Value); int tileY = int.Parse(match.Groups[2].Value); // Update bounds. if (bounds.LowX == -1 || tileX < bounds.LowX) bounds.LowX = tileX; if (bounds.HighX == -1 || tileX > bounds.HighX) bounds.HighX = tileX; if (bounds.LowY == -1 || tileY < bounds.LowY) bounds.LowY = tileY; if (bounds.HighY == -1 || tileY > bounds.HighY) bounds.HighY = tileY; positions[i] = new MapTileXY(tileX, tileY); } else { // This should not happen. positions[i] = new MapTileXY(0, 0); } } for (int i = 0; i < files.Length; i++) { CASCFile file = files[i]; MapTileXY position = positions[i]; string tempPath = Path.Combine(Constants.TEMP_DIRECTORY, file.FullName); // Extract the file if we don't already have it cached. if (!File.Exists(tempPath)) { try { Program.CASCEngine.SaveFileTo(file.FullName, Constants.TEMP_DIRECTORY); } catch (Exception e) { Log.Write("Warning: Unable to extract minimap tile {0} -> {1}", file.FullName, e.Message); } } if (File.Exists(tempPath)) EventManager.Trigger_MinimapTileDone(position, bounds, tempPath, Index); } }