From 9a9923405a956026b1b67b4f6f993a292b230f67 Mon Sep 17 00:00:00 2001 From: Garmin Kawaguichi Date: Tue, 3 Apr 2012 16:56:51 +0200 Subject: terrain save-tile extensions Signed-off-by: Garmin Kawaguichi Signed-off-by: Melanie --- .../CoreModules/World/Terrain/FileLoaders/BMP.cs | 6 ++++++ .../CoreModules/World/Terrain/FileLoaders/GIF.cs | 6 ++++++ .../World/Terrain/FileLoaders/GenericSystemDrawing.cs | 6 ++++++ .../CoreModules/World/Terrain/FileLoaders/JPEG.cs | 6 ++++++ .../CoreModules/World/Terrain/FileLoaders/LLRAW.cs | 7 +++++++ .../CoreModules/World/Terrain/FileLoaders/PNG.cs | 6 ++++++ .../CoreModules/World/Terrain/FileLoaders/RAW32.cs | 6 ++++++ .../CoreModules/World/Terrain/FileLoaders/TIFF.cs | 6 ++++++ .../CoreModules/World/Terrain/FileLoaders/Terragen.cs | 6 ++++++ .../Region/CoreModules/World/Terrain/ITerrainLoader.cs | 4 ++++ .../Region/CoreModules/World/Terrain/TerrainModule.cs | 18 +++++++++++++++--- 11 files changed, 74 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs index 90f124b..fb57c82 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/BMP.cs @@ -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; + } } } diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs index f331b56..79cc50b 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GIF.cs @@ -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; + } } } diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index 58925fd..da81dc1 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs @@ -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; + } + /// /// Protected method, generates a grayscale bitmap /// image from a specified terrain channel. diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs index 1a0d8ec..699d67a 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs @@ -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"); diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs index fad7641..62d232e 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs @@ -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; + } + } } diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs index e009ecf..c5c12ae 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/PNG.cs @@ -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; + } } } diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs index ba073ca..9fb7ef7 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs @@ -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; + } } } diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs index fc1ad33..5d2f893 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/TIFF.cs @@ -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; + } } } diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs index 2f37d9d..1ebf916 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs @@ -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; + } + /// /// terragen SCAL floats need to be written intel ordered regardless of /// big or little endian system diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs index d407617..3ba3657 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs @@ -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); diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index b3c2969..8535a5a 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -93,6 +93,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain /// 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 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 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); } /// @@ -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", -- cgit v1.1