terrain save-tile extensions Signed-off-by: Garmin Kawaguichi <garmin.kawaguichi@magalaxie.com>

Signed-off-by: Melanie <melanie@t-data.com>
0.7.4.1
Garmin Kawaguichi 2012-04-03 16:56:51 +02:00 committed by Melanie
parent e480e25d8b
commit 9a9923405a
11 changed files with 74 additions and 3 deletions

View File

@ -72,5 +72,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
return "BMP";
}
//Returns true if this extension is supported for terrain save-tile
public override bool SupportsTileSave()
{
return false;
}
}
}

View File

@ -57,5 +57,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
return "GIF";
}
//Returns true if this extension is supported for terrain save-tile
public override bool SupportsTileSave()
{
return false;
}
}
}

View File

@ -177,6 +177,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
return "SYS.DRAWING";
}
//Returns true if this extension is supported for terrain save-tile
public virtual bool SupportsTileSave()
{
return false;
}
/// <summary>
/// Protected method, generates a grayscale bitmap
/// image from a specified terrain channel.

View File

@ -91,6 +91,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
return "JPEG";
}
//Returns true if this extension is supported for terrain save-tile
public bool SupportsTileSave()
{
return false;
}
private static Bitmap CreateBitmapFromMap(ITerrainChannel map)
{
Bitmap gradientmapLd = new Bitmap("defaultstripe.png");

View File

@ -254,5 +254,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
return "LL/SL RAW";
}
//Returns true if this extension is supported for terrain save-tile
public bool SupportsTileSave()
{
return false;
}
}
}

View File

@ -57,5 +57,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
return "PNG";
}
//Returns true if this extension is supported for terrain save-tile
public override bool SupportsTileSave()
{
return true;
}
}
}

View File

@ -173,5 +173,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
return "RAW32";
}
//Returns true if this extension is supported for terrain save-tile
public bool SupportsTileSave()
{
return false;
}
}
}

View File

@ -57,5 +57,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
{
return "TIFF";
}
//Returns true if this extension is supported for terrain save-tile
public bool SupportsTileSave()
{
return false;
}
}
}

View File

@ -323,6 +323,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
return "Terragen";
}
//Returns true if this extension is supported for terrain save-tile
public bool SupportsTileSave()
{
return false;
}
/// <summary>
/// terragen SCAL floats need to be written intel ordered regardless of
/// big or little endian system

View File

@ -32,6 +32,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain
{
public interface ITerrainLoader
{
// Returns true if that extension can be used for terrain save-tile
// (Look into each file in Region.CoreModules.World.Terrain.FileLoaders)
bool SupportsTileSave();
string FileExtension { get; }
ITerrainChannel LoadFile(string filename);
ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight);

View File

@ -93,6 +93,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
/// </summary>
private string m_supportedFileExtensions = "";
//For terrain save-tile file extensions
private string m_supportFileExtensionsForTileSave = "";
#region ICommandableModule Members
public ICommander CommandInterface
@ -148,11 +151,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain
// Generate user-readable extensions list
string supportedFilesSeparator = "";
string supportedFilesSeparatorForTileSave = "";
m_supportFileExtensionsForTileSave = "";
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
{
m_supportedFileExtensions += supportedFilesSeparator + loader.Key + " (" + loader.Value + ")";
supportedFilesSeparator = ", ";
//For terrain save-tile file extensions
if (loader.Value.SupportsTileSave() == true)
{
m_supportFileExtensionsForTileSave += supportedFilesSeparatorForTileSave + loader.Key + " (" + loader.Value + ")";
supportedFilesSeparatorForTileSave = ", ";
}
}
}
@ -589,7 +601,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
// this region is included in the tile request
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
{
if (filename.EndsWith(loader.Key))
if (filename.EndsWith(loader.Key) && loader.Value.SupportsTileSave())
{
lock (m_scene)
{
@ -610,7 +622,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
MainConsole.Instance.OutputFormat(
"ERROR: Could not save terrain from {0} to {1}. Valid file extensions are {2}",
m_scene.RegionInfo.RegionName, filename, m_supportedFileExtensions);
m_scene.RegionInfo.RegionName, filename, m_supportFileExtensionsForTileSave);
}
/// <summary>
@ -1192,7 +1204,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
new Command("save-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceSaveTileFile, "Saves the current heightmap to the larger file.");
saveToTileCommand.AddArgument("filename",
"The file you wish to save to, the file extension determines the loader to be used. Supported extensions include: " +
m_supportedFileExtensions, "String");
m_supportFileExtensionsForTileSave, "String");
saveToTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",