private void MapSizeSelect_SelectedIndexChanged(object sender, EventArgs e)
{
// Reset image
if (MapPictureBox.Image != null)
{
MapPictureBox.Image.Dispose();
MapPictureBox.Image = null;
}
// Dispose old image
if (MapImage != null)
MapImage.Dispose();
// Enable add button
AddToMapList.Enabled = true;
// If the freeimage library is not available, stop here
if (!FreeImage.IsAvailable())
return;
// Load map image
// Get Values
string map = MapListSelect.SelectedItem.ToString();
string mode = ((KeyValuePair)GameModeSelect.SelectedItem).Key;
string size = MapSizeSelect.SelectedItem.ToString();
string ImgPath = Path.Combine(SelectedMap.RootPath, "Info", mode + "_" + size + "_menumap.png");
// Alot of server files dont contain the map image files, so search the client if we need to
if (!File.Exists(ImgPath))
{
if (!String.IsNullOrWhiteSpace(Program.Config.ClientPath))
{
ImgPath = Path.Combine(
Program.Config.ClientPath, "mods", MainForm.SelectedMod.Name, "levels",
SelectedMap.Name, "Info", mode + "_" + size + "_menumap.png"
);
// If the client doesnt have the image either, then Oh well :(
if (!File.Exists(ImgPath))
ImgPath = null;
}
else
ImgPath = null;
}
// Load the image if we have one
if (ImgPath != null)
{
// Attempt to load image as a DDS file... or png if its a mod sometimes
FREE_IMAGE_FORMAT Format = FREE_IMAGE_FORMAT.FIF_UNKNOWN;
MapImage = FreeImage.LoadBitmap(ImgPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT, ref Format);
if (MapImage != null)
{
MapPictureBox.Image = new Bitmap(MapImage, 250, 250);
}
}
}