diff --git a/Help/gz_actions.html b/Help/gz_actions.html index 53c29133..8d9654e4 100644 --- a/Help/gz_actions.html +++ b/Help/gz_actions.html @@ -192,6 +192,19 @@
Ctrl + Middle-Click
Moves selected Things to cursor location preserving relative offsets in Visual Modes. + + + Rotate Selected Things Clockwise +
Ctrl-Shift-MScroll
+ Rotates selected things clockwise. + + + + Rotate Selected Things Counterclockwise +
Ctrl-Shift-MScroll
+ Rotates selected things counterclockwise. + +

diff --git a/Source/Core/Builder.sln b/Source/Core/Builder.sln index 4c148dbc..78d03781 100644 --- a/Source/Core/Builder.sln +++ b/Source/Core/Builder.sln @@ -7,10 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuilderModes", "..\Plugins\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GZDoomEditing", "..\Plugins\GZDoomEditing\GZDoomEditing.csproj", "{760A9BC7-CB73-4C36-858B-994C14996FCD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UDMFControls", "..\Plugins\UMDFControls\UDMFControls.csproj", "{2D11C828-295C-463A-8545-CA1AD6D51518}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagExplorer", "..\Plugins\TagExplorer\TagExplorer.csproj", "{BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -51,28 +47,6 @@ Global {760A9BC7-CB73-4C36-858B-994C14996FCD}.Release|Mixed Platforms.Build.0 = Release|x86 {760A9BC7-CB73-4C36-858B-994C14996FCD}.Release|x86.ActiveCfg = Release|x86 {760A9BC7-CB73-4C36-858B-994C14996FCD}.Release|x86.Build.0 = Release|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|x86.ActiveCfg = Debug|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|x86.Build.0 = Debug|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|Any CPU.Build.0 = Release|Any CPU - {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|Mixed Platforms.Build.0 = Release|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|x86.ActiveCfg = Release|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|x86.Build.0 = Release|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Any CPU.ActiveCfg = Debug|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|x86.ActiveCfg = Debug|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|x86.Build.0 = Debug|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Any CPU.ActiveCfg = Release|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Mixed Platforms.Build.0 = Release|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|x86.ActiveCfg = Release|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs index 26e34aca..fef23f4e 100644 --- a/Source/Core/Data/DataManager.cs +++ b/Source/Core/Data/DataManager.cs @@ -1456,6 +1456,9 @@ namespace CodeImp.DoomBuilder.Data foreach (KeyValuePair group in modeldefEntries) group.Value.Dispose(); } + + foreach (Thing t in General.Map.Map.Things) t.IsModel = false; //drop model flag + General.MainWindow.DisplayStatus(StatusType.Busy, "Reloading model definitions..."); loadModeldefs(createActorsByClassList()); LoadModels(); @@ -1504,6 +1507,8 @@ namespace CodeImp.DoomBuilder.Data return; } + foreach(Thing t in General.Map.Map.Things) t.IsModel = false; //drop model flag + Dictionary modelDefEntriesByName = new Dictionary(); ModeldefParser mdeParser = new ModeldefParser(); diff --git a/Source/Core/Data/DirectoryReader.cs b/Source/Core/Data/DirectoryReader.cs index fc73d3f2..6041ed6d 100644 --- a/Source/Core/Data/DirectoryReader.cs +++ b/Source/Core/Data/DirectoryReader.cs @@ -284,6 +284,11 @@ namespace CodeImp.DoomBuilder.Data { return files.GetAllFilesWithTitle(path, title, subfolders).ToArray(); } + + //mxd. This returns all files in a given directory which title starts with given title + protected override string[] GetAllFilesWhichTitleStartsWith(string path, string title) { + return files.GetAllFilesWhichTitleStartsWith(path, title).ToArray(); + } // This returns all files in a given directory that match the given extension protected override string[] GetFilesWithExt(string path, string extension, bool subfolders) diff --git a/Source/Core/Data/FileImage.cs b/Source/Core/Data/FileImage.cs index d0880a34..6c46b665 100644 --- a/Source/Core/Data/FileImage.cs +++ b/Source/Core/Data/FileImage.cs @@ -46,7 +46,7 @@ namespace CodeImp.DoomBuilder.Data { // Initialize //this.filepathname = filepathname; - this.fullName = filepathname; + this.fullName = filepathname; //mxd SetName(name); if(asflat) @@ -70,7 +70,7 @@ namespace CodeImp.DoomBuilder.Data public FileImage(string name, string filepathname, bool asflat, float scalex, float scaley) { // Initialize - this.fullName = filepathname; + this.fullName = filepathname; //mxd this.scale.x = scalex; this.scale.y = scaley; SetName(name); diff --git a/Source/Core/Data/ImageData.cs b/Source/Core/Data/ImageData.cs index 1ea417e4..745ae797 100644 --- a/Source/Core/Data/ImageData.cs +++ b/Source/Core/Data/ImageData.cs @@ -54,8 +54,7 @@ namespace CodeImp.DoomBuilder.Data protected Vector2D scale; protected bool worldpanning; protected bool usecolorcorrection; - //mxd - protected string fullName; //name with path; + protected string fullName; //mxd. name with path; // Loading private volatile ImageLoadState previewstate; diff --git a/Source/Core/Data/ImageDataFormat.cs b/Source/Core/Data/ImageDataFormat.cs index 7892460c..d27675b5 100644 --- a/Source/Core/Data/ImageDataFormat.cs +++ b/Source/Core/Data/ImageDataFormat.cs @@ -40,22 +40,15 @@ namespace CodeImp.DoomBuilder.Data // File format signatures private static readonly int[] PNG_SIGNATURE = new int[] { 137, 80, 78, 71, 13, 10, 26, 10 }; private static readonly int[] GIF_SIGNATURE = new int[] { 71, 73, 70 }; - //private static readonly int[] BMP_SIGNATURE = new int[] { 66, 77 }; //mxd. Not supported in (G)ZDoom + private static readonly int[] BMP_SIGNATURE = new int[] { 66, 77 }; private static readonly int[] DDS_SIGNATURE = new int[] { 68, 68, 83, 32 }; - //mxd - private static readonly int[] PCX_SIGNATURE = new int[] { 10, 5, 1, 8 }; - //char Manufacturer; // 10 = ZSoft .PCX - //char Version; // 0 = Version 2.5 - // 2 = Version 2.8 with palette info - // 3 = Version 2.8 without palette info - // 5 = Version 3.0 - //char Encoding; // 1 = .PCX encoding - //char BitsPerLayer; // bpp + private static readonly int[] JPG_SIGNATURE = new int[] { 255, 216, 255, 224 }; //mxd + private static readonly int[] TGA_SIGNATURE = new int[] { 0, 0, 2, 0 }; //mxd + private static readonly int[] PCX_SIGNATURE = new int[] { 10, 5, 1, 8 }; //mxd // This check image data and returns the appropriate image reader public static IImageReader GetImageReader(Stream data, int guessformat, Playpal palette) { - //BinaryReader bindata = new BinaryReader(data); DoomPictureReader picreader; DoomFlatReader flatreader; DoomColormapReader colormapreader; @@ -68,27 +61,31 @@ namespace CodeImp.DoomBuilder.Data { // Check for PNG signature data.Seek(0, SeekOrigin.Begin); - if(CheckSignature(data, PNG_SIGNATURE)) return new FileImageReader(); + if(CheckSignature(data, PNG_SIGNATURE)) return new FileImageReader(DevilImageType.IL_PNG); // Check for DDS signature data.Seek(0, SeekOrigin.Begin); - if(CheckSignature(data, DDS_SIGNATURE)) return new FileImageReader(); + if (CheckSignature(data, DDS_SIGNATURE)) return new FileImageReader(DevilImageType.IL_DDS); // Check for GIF signature data.Seek(0, SeekOrigin.Begin); - if(CheckSignature(data, GIF_SIGNATURE)) return new FileImageReader(); + if (CheckSignature(data, GIF_SIGNATURE)) return new FileImageReader(DevilImageType.IL_GIF); //mxd. Check for PCX signature data.Seek(0, SeekOrigin.Begin); - if (CheckSignature(data, PCX_SIGNATURE)) return new FileImageReader(); + if (CheckSignature(data, PCX_SIGNATURE)) return new FileImageReader(DevilImageType.IL_PCX); + + //mxd. Check for JPG signature + data.Seek(0, SeekOrigin.Begin); + if (CheckSignature(data, JPG_SIGNATURE)) return new FileImageReader(DevilImageType.IL_JPG); + + //mxd. Check for TGA signature + data.Seek(0, SeekOrigin.Begin); + if (CheckSignature(data, TGA_SIGNATURE)) return new FileImageReader(DevilImageType.IL_TGA); // Check for BMP signature - /*data.Seek(0, SeekOrigin.Begin); - if(CheckSignature(data, BMP_SIGNATURE)) - { - // Check if data size matches the size specified in the data - if(bindata.ReadUInt32() <= data.Length) return new FileImageReader(); - }*/ + data.Seek(0, SeekOrigin.Begin); + if (CheckSignature(data, BMP_SIGNATURE)) return new UnknownImageReader(); //mxd. Not supported in (G)ZDoom } // Could it be a doom picture? diff --git a/Source/Core/Data/PK3Reader.cs b/Source/Core/Data/PK3Reader.cs index ee3d730d..aa72012e 100644 --- a/Source/Core/Data/PK3Reader.cs +++ b/Source/Core/Data/PK3Reader.cs @@ -290,6 +290,11 @@ namespace CodeImp.DoomBuilder.Data { return files.GetAllFilesWithTitle(path, title, subfolders).ToArray(); } + + //mxd. This returns all files in a given directory which title starts with given title + protected override string[] GetAllFilesWhichTitleStartsWith(string path, string title) { + return files.GetAllFilesWhichTitleStartsWith(path, title).ToArray(); + } // This returns all files in a given directory that match the given extension protected override string[] GetFilesWithExt(string path, string extension, bool subfolders) diff --git a/Source/Core/Data/PK3StructuredReader.cs b/Source/Core/Data/PK3StructuredReader.cs index 8dec8a49..62336fd8 100644 --- a/Source/Core/Data/PK3StructuredReader.cs +++ b/Source/Core/Data/PK3StructuredReader.cs @@ -181,9 +181,10 @@ namespace CodeImp.DoomBuilder.Data AddImagesToList(images, collection); } + //mxd // Add images from texture directory - collection = LoadDirectoryImages(TEXTURES_DIR, ImageDataFormat.DOOMPICTURE, true); - AddImagesToList(images, collection); + //collection = LoadDirectoryImages(TEXTURES_DIR, ImageDataFormat.DOOMPICTURE, true); + //AddImagesToList(images, collection); // Load TEXTURE1 lump file imgset.Clear(); @@ -207,9 +208,10 @@ namespace CodeImp.DoomBuilder.Data // Add images from TEXTURE1 and TEXTURE2 lump files AddImagesToList(images, imgset); - // Load TEXTURES lump file + // Load TEXTURES lump files imgset.Clear(); - string[] alltexturefiles = GetAllFilesWithTitle("", "TEXTURES", false); + //string[] alltexturefiles = GetAllFilesWithTitle("", "TEXTURES", false); + string[] alltexturefiles = GetAllFilesWhichTitleStartsWith("", "TEXTURES"); //mxd foreach(string texturesfile in alltexturefiles) { MemoryStream filedata = LoadFile(texturesfile); @@ -219,6 +221,10 @@ namespace CodeImp.DoomBuilder.Data // Add images from TEXTURES lump file AddImagesToList(images, imgset); + + //mxd. Add images from texture directory. Textures defined in TEXTURES override ones in "textures" folder + collection = LoadDirectoryImages(TEXTURES_DIR, ImageDataFormat.DOOMPICTURE, true); + AddImagesToList(images, collection); // Add images to the container-specific texture set foreach(ImageData img in images.Values) @@ -579,6 +585,9 @@ namespace CodeImp.DoomBuilder.Data // This must return all files in a given directory that have the given file title protected abstract string[] GetAllFilesWithTitle(string path, string title, bool subfolders); + //mxd. This must return all files in a given directory which title starts with given title + protected abstract string[] GetAllFilesWhichTitleStartsWith(string path, string title); + // This must return all files in a given directory that match the given extension protected abstract string[] GetFilesWithExt(string path, string extension, bool subfolders); diff --git a/Source/Core/Data/WADReader.cs b/Source/Core/Data/WADReader.cs index 1e31d580..7a60cde3 100644 --- a/Source/Core/Data/WADReader.cs +++ b/Source/Core/Data/WADReader.cs @@ -551,7 +551,9 @@ namespace CodeImp.DoomBuilder.Data { // Find the lump anywhere lump = file.FindLump(pname); - if(lump != null) return lump.Stream; + if (lump != null) { + return lump.Stream; + } } return null; diff --git a/Source/Core/GZBuilder/GZGeneral.cs b/Source/Core/GZBuilder/GZGeneral.cs index 5f858638..d9c4b570 100644 --- a/Source/Core/GZBuilder/GZGeneral.cs +++ b/Source/Core/GZBuilder/GZGeneral.cs @@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.GZBuilder //version public const float Version = 1.12f; - public const char Revision = 'a'; + public const char Revision = 'b'; //debug console #if DEBUG diff --git a/Source/Core/IO/DirectoryFilesList.cs b/Source/Core/IO/DirectoryFilesList.cs index f7abba2f..108049a8 100644 --- a/Source/Core/IO/DirectoryFilesList.cs +++ b/Source/Core/IO/DirectoryFilesList.cs @@ -167,6 +167,17 @@ namespace CodeImp.DoomBuilder.IO } } + //mxd. This returns a list of all files that are in the given path and which names starts with title + public List GetAllFilesWhichTitleStartsWith(string path, string title) { + path = CorrectPath(path).ToLowerInvariant(); + title = title.ToLowerInvariant(); + List files = new List(entries.Length); + for (int i = 0; i < entries.Length; i++) + if ((entries[i].path == path) && (entries[i].filetitle.StartsWith(title))) + files.Add(entries[i].filepathname); + return files; + } + // This returns a list of all files that are in the given path and subdirectories and have the given extension public List GetAllFiles(string path, string extension) { diff --git a/Source/Core/IO/DoomColormapReader.cs b/Source/Core/IO/DoomColormapReader.cs index 8b9649b7..0e8444f8 100644 --- a/Source/Core/IO/DoomColormapReader.cs +++ b/Source/Core/IO/DoomColormapReader.cs @@ -39,6 +39,7 @@ namespace CodeImp.DoomBuilder.IO // Palette to use private Playpal palette; + public uint ImageType { get; private set; } //mxd #endregion @@ -49,6 +50,7 @@ namespace CodeImp.DoomBuilder.IO { // Initialize this.palette = palette; + ImageType = DevilImageType.IL_TYPE_UNKNOWN; //mxd // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/Core/IO/DoomFlatReader.cs b/Source/Core/IO/DoomFlatReader.cs index a8eca29a..baae683c 100644 --- a/Source/Core/IO/DoomFlatReader.cs +++ b/Source/Core/IO/DoomFlatReader.cs @@ -39,6 +39,7 @@ namespace CodeImp.DoomBuilder.IO // Palette to use private Playpal palette; + public uint ImageType { get; private set; } //mxd #endregion @@ -49,6 +50,7 @@ namespace CodeImp.DoomBuilder.IO { // Initialize this.palette = palette; + ImageType = DevilImageType.IL_TYPE_UNKNOWN;//mxd // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/Core/IO/DoomPictureReader.cs b/Source/Core/IO/DoomPictureReader.cs index 7dc25c74..6b24ebd9 100644 --- a/Source/Core/IO/DoomPictureReader.cs +++ b/Source/Core/IO/DoomPictureReader.cs @@ -39,6 +39,7 @@ namespace CodeImp.DoomBuilder.IO // Palette to use private Playpal palette; + public uint ImageType { get; private set; } //mxd #endregion @@ -49,6 +50,7 @@ namespace CodeImp.DoomBuilder.IO { // Initialize this.palette = palette; + ImageType = DevilImageType.IL_TYPE_UNKNOWN; //mxd // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/Core/IO/FileImageReader.cs b/Source/Core/IO/FileImageReader.cs index 85b22abb..ea42ee09 100644 --- a/Source/Core/IO/FileImageReader.cs +++ b/Source/Core/IO/FileImageReader.cs @@ -34,7 +34,22 @@ using System.Drawing.Imaging; namespace CodeImp.DoomBuilder.IO { - internal unsafe class FileImageReader : IImageReader + //mxd + internal struct DevilImageType + { + internal const int IL_TYPE_UNKNOWN = 0x0000; + //internal const int IL_DOOM = 0x0422; //!< DooM walls - no specific extension + //internal const int IL_DOOM_FLAT = 0x0423; //!< DooM flats - no specific extension + + internal const int IL_JPG = 0x0425; //!< JPEG - .jpg, .jpe and .jpeg extensions + internal const int IL_PCX = 0x0428; //!< ZSoft PCX - .pcx extension + internal const int IL_PNG = 0x042A; //!< Portable Network Graphics - .png extension + internal const int IL_TGA = 0x042D; //!< TrueVision Targa File - .tga, .vda, .icb and .vst extensions + internal const int IL_GIF = 0x0436; //!< Graphics Interchange Format - .gif extension + internal const int IL_DDS = 0x0437; //!< DirectDraw Surface - .dds extension + } + + internal unsafe class FileImageReader : IImageReader { #region ================== APIs @@ -59,90 +74,90 @@ namespace CodeImp.DoomBuilder.IO [DllImport("devil.dll")] private static extern uint ilCopyPixels(uint xoff, uint yoff, uint zoff, uint width, uint height, uint depth, uint format, uint type, IntPtr data); + //mxd. Look's like we don't need many of those... // Matches OpenGL's right now. //! Data formats \link Formats Formats\endlink - private const int IL_COLOUR_INDEX = 0x1900; - private const int IL_COLOR_INDEX = 0x1900; - private const int IL_ALPHA = 0x1906; - private const int IL_RGB = 0x1907; - private const int IL_RGBA = 0x1908; - private const int IL_BGR = 0x80E0; + //private const int IL_COLOUR_INDEX = 0x1900; + //private const int IL_COLOR_INDEX = 0x1900; + //private const int IL_ALPHA = 0x1906; + //private const int IL_RGB = 0x1907; + //private const int IL_RGBA = 0x1908; + //private const int IL_BGR = 0x80E0; private const int IL_BGRA = 0x80E1; - private const int IL_LUMINANCE = 0x1909; - private const int IL_LUMINANCE_ALPHA = 0x190A; + //private const int IL_LUMINANCE = 0x1909; + //private const int IL_LUMINANCE_ALPHA = 0x190A; //! Data types \link Types Types\endlink - private const int IL_BYTE = 0x1400; + //private const int IL_BYTE = 0x1400; private const int IL_UNSIGNED_BYTE = 0x1401; - private const int IL_SHORT = 0x1402; - private const int IL_UNSIGNED_SHORT = 0x1403; - private const int IL_INT = 0x1404; - private const int IL_UNSIGNED_INT = 0x1405; - private const int IL_FLOAT = 0x1406; - private const int IL_DOUBLE = 0x140A; - private const int IL_HALF = 0x140B; - - // Image types - private const int IL_TYPE_UNKNOWN = 0x0000; - private const int IL_BMP = 0x0420; //!< Microsoft Windows Bitmap - .bmp extension - private const int IL_CUT = 0x0421; //!< Dr. Halo - .cut extension - private const int IL_DOOM = 0x0422; //!< DooM walls - no specific extension - private const int IL_DOOM_FLAT = 0x0423; //!< DooM flats - no specific extension - private const int IL_ICO = 0x0424; //!< Microsoft Windows Icons and Cursors - .ico and .cur extensions - private const int IL_JPG = 0x0425; //!< JPEG - .jpg, .jpe and .jpeg extensions - private const int IL_JFIF = 0x0425; //!< - private const int IL_ILBM = 0x0426; //!< Amiga IFF (FORM ILBM) - .iff, .ilbm, .lbm extensions - private const int IL_PCD = 0x0427; //!< Kodak PhotoCD - .pcd extension - private const int IL_PCX = 0x0428; //!< ZSoft PCX - .pcx extension - private const int IL_PIC = 0x0429; //!< PIC - .pic extension - private const int IL_PNG = 0x042A; //!< Portable Network Graphics - .png extension - private const int IL_PNM = 0x042B; //!< Portable Any Map - .pbm, .pgm, .ppm and .pnm extensions - private const int IL_SGI = 0x042C; //!< Silicon Graphics - .sgi, .bw, .rgb and .rgba extensions - private const int IL_TGA = 0x042D; //!< TrueVision Targa File - .tga, .vda, .icb and .vst extensions - private const int IL_TIF = 0x042E; //!< Tagged Image File Format - .tif and .tiff extensions - private const int IL_CHEAD = 0x042F; //!< C-Style Header - .h extension - private const int IL_RAW = 0x0430; //!< Raw Image Data - any extension - private const int IL_MDL = 0x0431; //!< Half-Life Model Texture - .mdl extension - private const int IL_WAL = 0x0432; //!< Quake 2 Texture - .wal extension - private const int IL_LIF = 0x0434; //!< Homeworld Texture - .lif extension - private const int IL_MNG = 0x0435; //!< Multiple-image Network Graphics - .mng extension - private const int IL_JNG = 0x0435; //!< - private const int IL_GIF = 0x0436; //!< Graphics Interchange Format - .gif extension - private const int IL_DDS = 0x0437; //!< DirectDraw Surface - .dds extension - private const int IL_DCX = 0x0438; //!< ZSoft Multi-PCX - .dcx extension - private const int IL_PSD = 0x0439; //!< Adobe PhotoShop - .psd extension - private const int IL_EXIF = 0x043A; //!< - private const int IL_PSP = 0x043B; //!< PaintShop Pro - .psp extension - private const int IL_PIX = 0x043C; //!< PIX - .pix extension - private const int IL_PXR = 0x043D; //!< Pixar - .pxr extension - private const int IL_XPM = 0x043E; //!< X Pixel Map - .xpm extension - private const int IL_HDR = 0x043F; //!< Radiance High Dynamic Range - .hdr extension - private const int IL_ICNS = 0x0440; //!< Macintosh Icon - .icns extension - private const int IL_JP2 = 0x0441; //!< Jpeg 2000 - .jp2 extension - private const int IL_EXR = 0x0442; //!< OpenEXR - .exr extension - private const int IL_WDP = 0x0443; //!< Microsoft HD Photo - .wdp and .hdp extension - private const int IL_VTF = 0x0444; //!< Valve Texture Format - .vtf extension - private const int IL_WBMP = 0x0445; //!< Wireless Bitmap - .wbmp extension - private const int IL_SUN = 0x0446; //!< Sun Raster - .sun, .ras, .rs, .im1, .im8, .im24 and .im32 extensions - private const int IL_IFF = 0x0447; //!< Interchange File Format - .iff extension - private const int IL_TPL = 0x0448; //!< Gamecube Texture - .tpl extension - private const int IL_FITS = 0x0449; //!< Flexible Image Transport System - .fit and .fits extensions - private const int IL_DICOM = 0x044A; //!< Digital Imaging and Communications in Medicine (DICOM) - .dcm and .dicom extensions - private const int IL_IWI = 0x044B; //!< Call of Duty Infinity Ward Image - .iwi extension - private const int IL_BLP = 0x044C; //!< Blizzard Texture Format - .blp extension - private const int IL_FTX = 0x044D; //!< Heavy Metal: FAKK2 Texture - .ftx extension - private const int IL_ROT = 0x044E; //!< Homeworld 2 - Relic Texture - .rot extension - private const int IL_TEXTURE = 0x044F; //!< Medieval II: Total War Texture - .texture extension - private const int IL_DPX = 0x0450; //!< Digital Picture Exchange - .dpx extension - private const int IL_UTX = 0x0451; //!< Unreal (and Unreal Tournament) Texture - .utx extension - private const int IL_MP3 = 0x0452; //!< MPEG-1 Audio Layer 3 - .mp3 extension + /*private const int IL_SHORT = 0x1402; + private const int IL_UNSIGNED_SHORT = 0x1403; + private const int IL_INT = 0x1404; + private const int IL_UNSIGNED_INT = 0x1405; + private const int IL_FLOAT = 0x1406; + private const int IL_DOUBLE = 0x140A; + private const int IL_HALF = 0x140B;*/ + // Image types + //private const int IL_TYPE_UNKNOWN = 0x0000; + /*private const int IL_BMP = 0x0420; //!< Microsoft Windows Bitmap - .bmp extension + private const int IL_CUT = 0x0421; //!< Dr. Halo - .cut extension + private const int IL_DOOM = 0x0422; //!< DooM walls - no specific extension + private const int IL_DOOM_FLAT = 0x0423; //!< DooM flats - no specific extension + private const int IL_ICO = 0x0424; //!< Microsoft Windows Icons and Cursors - .ico and .cur extensions + private const int IL_JPG = 0x0425; //!< JPEG - .jpg, .jpe and .jpeg extensions + private const int IL_JFIF = 0x0425; //!< + private const int IL_ILBM = 0x0426; //!< Amiga IFF (FORM ILBM) - .iff, .ilbm, .lbm extensions + private const int IL_PCD = 0x0427; //!< Kodak PhotoCD - .pcd extension + private const int IL_PCX = 0x0428; //!< ZSoft PCX - .pcx extension + private const int IL_PIC = 0x0429; //!< PIC - .pic extension + private const int IL_PNG = 0x042A; //!< Portable Network Graphics - .png extension + private const int IL_PNM = 0x042B; //!< Portable Any Map - .pbm, .pgm, .ppm and .pnm extensions + private const int IL_SGI = 0x042C; //!< Silicon Graphics - .sgi, .bw, .rgb and .rgba extensions + private const int IL_TGA = 0x042D; //!< TrueVision Targa File - .tga, .vda, .icb and .vst extensions + private const int IL_TIF = 0x042E; //!< Tagged Image File Format - .tif and .tiff extensions + private const int IL_CHEAD = 0x042F; //!< C-Style Header - .h extension + private const int IL_RAW = 0x0430; //!< Raw Image Data - any extension + private const int IL_MDL = 0x0431; //!< Half-Life Model Texture - .mdl extension + private const int IL_WAL = 0x0432; //!< Quake 2 Texture - .wal extension + private const int IL_LIF = 0x0434; //!< Homeworld Texture - .lif extension + private const int IL_MNG = 0x0435; //!< Multiple-image Network Graphics - .mng extension + private const int IL_JNG = 0x0435; //!< + private const int IL_GIF = 0x0436; //!< Graphics Interchange Format - .gif extension + private const int IL_DDS = 0x0437; //!< DirectDraw Surface - .dds extension + private const int IL_DCX = 0x0438; //!< ZSoft Multi-PCX - .dcx extension + private const int IL_PSD = 0x0439; //!< Adobe PhotoShop - .psd extension + private const int IL_EXIF = 0x043A; //!< + private const int IL_PSP = 0x043B; //!< PaintShop Pro - .psp extension + private const int IL_PIX = 0x043C; //!< PIX - .pix extension + private const int IL_PXR = 0x043D; //!< Pixar - .pxr extension + private const int IL_XPM = 0x043E; //!< X Pixel Map - .xpm extension + private const int IL_HDR = 0x043F; //!< Radiance High Dynamic Range - .hdr extension + private const int IL_ICNS = 0x0440; //!< Macintosh Icon - .icns extension + private const int IL_JP2 = 0x0441; //!< Jpeg 2000 - .jp2 extension + private const int IL_EXR = 0x0442; //!< OpenEXR - .exr extension + private const int IL_WDP = 0x0443; //!< Microsoft HD Photo - .wdp and .hdp extension + private const int IL_VTF = 0x0444; //!< Valve Texture Format - .vtf extension + private const int IL_WBMP = 0x0445; //!< Wireless Bitmap - .wbmp extension + private const int IL_SUN = 0x0446; //!< Sun Raster - .sun, .ras, .rs, .im1, .im8, .im24 and .im32 extensions + private const int IL_IFF = 0x0447; //!< Interchange File Format - .iff extension + private const int IL_TPL = 0x0448; //!< Gamecube Texture - .tpl extension + private const int IL_FITS = 0x0449; //!< Flexible Image Transport System - .fit and .fits extensions + private const int IL_DICOM = 0x044A; //!< Digital Imaging and Communications in Medicine (DICOM) - .dcm and .dicom extensions + private const int IL_IWI = 0x044B; //!< Call of Duty Infinity Ward Image - .iwi extension + private const int IL_BLP = 0x044C; //!< Blizzard Texture Format - .blp extension + private const int IL_FTX = 0x044D; //!< Heavy Metal: FAKK2 Texture - .ftx extension + private const int IL_ROT = 0x044E; //!< Homeworld 2 - Relic Texture - .rot extension + private const int IL_TEXTURE = 0x044F; //!< Medieval II: Total War Texture - .texture extension + private const int IL_DPX = 0x0450; //!< Digital Picture Exchange - .dpx extension + private const int IL_UTX = 0x0451; //!< Unreal (and Unreal Tournament) Texture - .utx extension + private const int IL_MP3 = 0x0452; //!< MPEG-1 Audio Layer 3 - .mp3 extension*/ private const int IL_JASC_PAL = 0x0475; //!< PaintShop Pro Palette // Error Types - private const int IL_NO_ERROR = 0x0000; + /*private const int IL_NO_ERROR = 0x0000; private const int IL_INVALID_ENUM = 0x0501; private const int IL_OUT_OF_MEMORY = 0x0502; private const int IL_FORMAT_NOT_SUPPORTED = 0x0503; @@ -161,96 +176,96 @@ namespace CodeImp.DoomBuilder.IO private const int IL_INVALID_CONVERSION = 0x0510; private const int IL_BAD_DIMENSIONS = 0x0511; private const int IL_FILE_READ_ERROR = 0x0512; // 05/12/2002: Addition by Sam. - private const int IL_FILE_WRITE_ERROR = 0x0512; + private const int IL_FILE_WRITE_ERROR = 0x0512;*/ - private const int IL_LIB_GIF_ERROR = 0x05E1; + /*private const int IL_LIB_GIF_ERROR = 0x05E1; private const int IL_LIB_JPEG_ERROR = 0x05E2; private const int IL_LIB_PNG_ERROR = 0x05E3; private const int IL_LIB_TIFF_ERROR = 0x05E4; private const int IL_LIB_MNG_ERROR = 0x05E5; private const int IL_LIB_JP2_ERROR = 0x05E6; private const int IL_LIB_EXR_ERROR = 0x05E7; - private const int IL_UNKNOWN_ERROR = 0x05FF; + private const int IL_UNKNOWN_ERROR = 0x05FF;*/ // Origin Definitions - private const int IL_ORIGIN_SET = 0x0600; + /*private const int IL_ORIGIN_SET = 0x0600; private const int IL_ORIGIN_LOWER_LEFT = 0x0601; private const int IL_ORIGIN_UPPER_LEFT = 0x0602; - private const int IL_ORIGIN_MODE = 0x0603; + private const int IL_ORIGIN_MODE = 0x0603;*/ // Format and Type Mode Definitions - private const int IL_FORMAT_SET = 0x0610; + /*private const int IL_FORMAT_SET = 0x0610; private const int IL_FORMAT_MODE = 0x0611; private const int IL_TYPE_SET = 0x0612; - private const int IL_TYPE_MODE = 0x0613; + private const int IL_TYPE_MODE = 0x0613;*/ // File definitions - private const int IL_FILE_OVERWRITE = 0x0620; + /*private const int IL_FILE_OVERWRITE = 0x0620; private const int IL_FILE_MODE = 0x0621; - + */ // Palette definitions - private const int IL_CONV_PAL = 0x0630; + //private const int IL_CONV_PAL = 0x0630; // Load fail definitions - private const int IL_DEFAULT_ON_FAIL = 0x0632; + //private const int IL_DEFAULT_ON_FAIL = 0x0632; // Key colour and alpha definitions - private const int IL_USE_KEY_COLOUR = 0x0635; + /*private const int IL_USE_KEY_COLOUR = 0x0635; private const int IL_USE_KEY_COLOR = 0x0635; - private const int IL_BLIT_BLEND = 0x0636; + private const int IL_BLIT_BLEND = 0x0636;*/ // Interlace definitions - private const int IL_SAVE_INTERLACED = 0x0639; - private const int IL_INTERLACE_MODE = 0x063A; + /*private const int IL_SAVE_INTERLACED = 0x0639; + private const int IL_INTERLACE_MODE = 0x063A;*/ // Quantization definitions - private const int IL_QUANTIZATION_MODE = 0x0640; + /*private const int IL_QUANTIZATION_MODE = 0x0640; private const int IL_WU_QUANT = 0x0641; private const int IL_NEU_QUANT = 0x0642; private const int IL_NEU_QUANT_SAMPLE = 0x0643; private const int IL_MAX_QUANT_INDEXS = 0x0644; //XIX : ILint : Maximum number of colors to reduce to, default of 256. and has a range of 2-256 - private const int IL_MAX_QUANT_INDICES = 0x0644; // Redefined, since the above private const int is misspelled + private const int IL_MAX_QUANT_INDICES = 0x0644; // Redefined, since the above private const int is misspelled*/ // Hints - private const int IL_FASTEST = 0x0660; + /*private const int IL_FASTEST = 0x0660; private const int IL_LESS_MEM = 0x0661; private const int IL_DONT_CARE = 0x0662; private const int IL_MEM_SPEED_HINT = 0x0665; private const int IL_USE_COMPRESSION = 0x0666; private const int IL_NO_COMPRESSION = 0x0667; - private const int IL_COMPRESSION_HINT = 0x0668; + private const int IL_COMPRESSION_HINT = 0x0668;*/ // Compression - private const int IL_NVIDIA_COMPRESS = 0x0670; - private const int IL_SQUISH_COMPRESS = 0x0671; + /*private const int IL_NVIDIA_COMPRESS = 0x0670; + private const int IL_SQUISH_COMPRESS = 0x0671;*/ // Subimage types - private const int IL_SUB_NEXT = 0x0680; + /*private const int IL_SUB_NEXT = 0x0680; private const int IL_SUB_MIPMAP = 0x0681; - private const int IL_SUB_LAYER = 0x0682; + private const int IL_SUB_LAYER = 0x0682;*/ // Compression definitions - private const int IL_COMPRESS_MODE = 0x0700; + /*private const int IL_COMPRESS_MODE = 0x0700; private const int IL_COMPRESS_NONE = 0x0701; private const int IL_COMPRESS_RLE = 0x0702; private const int IL_COMPRESS_LZO = 0x0703; - private const int IL_COMPRESS_ZLIB = 0x0704; + private const int IL_COMPRESS_ZLIB = 0x0704;*/ // File format-specific values - private const int IL_TGA_CREATE_STAMP = 0x0710; + /*private const int IL_TGA_CREATE_STAMP = 0x0710; private const int IL_JPG_QUALITY = 0x0711; private const int IL_PNG_INTERLACE = 0x0712; private const int IL_TGA_RLE = 0x0713; @@ -271,11 +286,11 @@ namespace CodeImp.DoomBuilder.IO private const int IL_PCD_PICNUM = 0x0723; private const int IL_PNG_ALPHA_INDEX = 0x0724; //XIX : ILint : the color in the palette at this index value (0-255) is considered transparent, -1 for no trasparent color private const int IL_JPG_PROGRESSIVE = 0x0725; - private const int IL_VTF_COMP = 0x0726; + private const int IL_VTF_COMP = 0x0726;*/ // DXTC definitions - private const int IL_DXTC_FORMAT = 0x0705; + /*private const int IL_DXTC_FORMAT = 0x0705; private const int IL_DXT1 = 0x0706; private const int IL_DXT2 = 0x0707; private const int IL_DXT3 = 0x0708; @@ -287,51 +302,54 @@ namespace CodeImp.DoomBuilder.IO private const int IL_3DC = 0x070E; private const int IL_RXGB = 0x070F; private const int IL_ATI1N = 0x0710; - private const int IL_DXT1A = 0x0711; // Normally the same as IL_DXT1, except for nVidia Texture Tools. + private const int IL_DXT1A = 0x0711; // Normally the same as IL_DXT1, except for nVidia Texture Tools.*/ // Environment map definitions - private const int IL_CUBEMAP_POSITIVEX = 0x00000400; + /*private const int IL_CUBEMAP_POSITIVEX = 0x00000400; private const int IL_CUBEMAP_NEGATIVEX = 0x00000800; private const int IL_CUBEMAP_POSITIVEY = 0x00001000; private const int IL_CUBEMAP_NEGATIVEY = 0x00002000; private const int IL_CUBEMAP_POSITIVEZ = 0x00004000; private const int IL_CUBEMAP_NEGATIVEZ = 0x00008000; - private const int IL_SPHEREMAP = 0x00010000; + private const int IL_SPHEREMAP = 0x00010000;*/ // Values - private const int IL_VERSION_NUM = 0x0DE2; + //private const int IL_VERSION_NUM = 0x0DE2; private const int IL_IMAGE_WIDTH = 0x0DE4; private const int IL_IMAGE_HEIGHT = 0x0DE5; - private const int IL_IMAGE_DEPTH = 0x0DE6; - private const int IL_IMAGE_SIZE_OF_DATA = 0x0DE7; - private const int IL_IMAGE_BPP = 0x0DE8; - private const int IL_IMAGE_BYTES_PER_PIXEL = 0x0DE8; - private const int IL_IMAGE_BITS_PER_PIXEL = 0x0DE9; - private const int IL_IMAGE_FORMAT = 0x0DEA; - private const int IL_IMAGE_TYPE = 0x0DEB; - private const int IL_PALETTE_TYPE = 0x0DEC; - private const int IL_PALETTE_SIZE = 0x0DED; - private const int IL_PALETTE_BPP = 0x0DEE; - private const int IL_PALETTE_NUM_COLS = 0x0DEF; - private const int IL_PALETTE_BASE_TYPE = 0x0DF0; - private const int IL_NUM_FACES = 0x0DE1; - private const int IL_NUM_IMAGES = 0x0DF1; - private const int IL_NUM_MIPMAPS = 0x0DF2; - private const int IL_NUM_LAYERS = 0x0DF3; - private const int IL_ACTIVE_IMAGE = 0x0DF4; - private const int IL_ACTIVE_MIPMAP = 0x0DF5; - private const int IL_ACTIVE_LAYER = 0x0DF6; - private const int IL_ACTIVE_FACE = 0x0E00; - private const int IL_CUR_IMAGE = 0x0DF7; - private const int IL_IMAGE_DURATION = 0x0DF8; - private const int IL_IMAGE_PLANESIZE = 0x0DF9; - private const int IL_IMAGE_BPC = 0x0DFA; - private const int IL_IMAGE_OFFX = 0x0DFB; - private const int IL_IMAGE_OFFY = 0x0DFC; - private const int IL_IMAGE_CUBEFLAGS = 0x0DFD; - private const int IL_IMAGE_ORIGIN = 0x0DFE; - private const int IL_IMAGE_CHANNELS = 0x0DFF; + /*private const int IL_IMAGE_DEPTH = 0x0DE6; + private const int IL_IMAGE_SIZE_OF_DATA = 0x0DE7; + private const int IL_IMAGE_BPP = 0x0DE8; + private const int IL_IMAGE_BYTES_PER_PIXEL = 0x0DE8; + private const int IL_IMAGE_BITS_PER_PIXEL = 0x0DE9; + private const int IL_IMAGE_FORMAT = 0x0DEA; + private const int IL_IMAGE_TYPE = 0x0DEB; + private const int IL_PALETTE_TYPE = 0x0DEC; + private const int IL_PALETTE_SIZE = 0x0DED; + private const int IL_PALETTE_BPP = 0x0DEE; + private const int IL_PALETTE_NUM_COLS = 0x0DEF; + private const int IL_PALETTE_BASE_TYPE = 0x0DF0; + private const int IL_NUM_FACES = 0x0DE1; + private const int IL_NUM_IMAGES = 0x0DF1; + private const int IL_NUM_MIPMAPS = 0x0DF2; + private const int IL_NUM_LAYERS = 0x0DF3; + private const int IL_ACTIVE_IMAGE = 0x0DF4; + private const int IL_ACTIVE_MIPMAP = 0x0DF5; + private const int IL_ACTIVE_LAYER = 0x0DF6; + private const int IL_ACTIVE_FACE = 0x0E00; + private const int IL_CUR_IMAGE = 0x0DF7; + private const int IL_IMAGE_DURATION = 0x0DF8; + private const int IL_IMAGE_PLANESIZE = 0x0DF9; + private const int IL_IMAGE_BPC = 0x0DFA; + private const int IL_IMAGE_OFFX = 0x0DFB; + private const int IL_IMAGE_OFFY = 0x0DFC; + private const int IL_IMAGE_CUBEFLAGS = 0x0DFD; + private const int IL_IMAGE_ORIGIN = 0x0DFE; + private const int IL_IMAGE_CHANNELS = 0x0DFF;*/ + + //mxd + public uint ImageType { get; private set; } #endregion @@ -340,10 +358,20 @@ namespace CodeImp.DoomBuilder.IO // Constructor public FileImageReader() { - // We have no destructor + ImageType = DevilImageType.IL_TYPE_UNKNOWN;//mxd + + // We have no destructor GC.SuppressFinalize(this); } + //mxd + public FileImageReader(uint devilImageType) { + ImageType = devilImageType;//mxd + + // We have no destructor + GC.SuppressFinalize(this); + } + #endregion #region ================== Methods @@ -357,6 +385,7 @@ namespace CodeImp.DoomBuilder.IO return ReadAsBitmap(stream); } + // This reads the image and returns a Bitmap public Bitmap ReadAsBitmap(Stream stream) { @@ -372,7 +401,7 @@ namespace CodeImp.DoomBuilder.IO stream.Read(bytes, 0, bytes.Length); fixed(byte* bptr = bytes) { - if(!ilLoadL(IL_TYPE_UNKNOWN, new IntPtr(bptr), (uint)bytes.Length)) + if (!ilLoadL(ImageType, new IntPtr(bptr), (uint)bytes.Length)) throw new BadImageFormatException(); } @@ -394,6 +423,10 @@ namespace CodeImp.DoomBuilder.IO // Clean up ilDeleteImages(1, new IntPtr(&imageid)); + //mxd. TGA fix + if (ImageType == DevilImageType.IL_TGA) + bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); + return bmp; } catch(Exception e) diff --git a/Source/Core/IO/IImageReader.cs b/Source/Core/IO/IImageReader.cs index 366e4ff8..8f432434 100644 --- a/Source/Core/IO/IImageReader.cs +++ b/Source/Core/IO/IImageReader.cs @@ -35,8 +35,11 @@ namespace CodeImp.DoomBuilder.IO { internal unsafe interface IImageReader { - // Methods - Bitmap ReadAsBitmap(Stream stream); + //mxd. Variables + uint ImageType { get; } //holds Devil library Image type + + // Methods + Bitmap ReadAsBitmap(Stream stream); Bitmap ReadAsBitmap(Stream stream, out int offsetx, out int offsety); void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y); } diff --git a/Source/Core/IO/UnknownImageReader.cs b/Source/Core/IO/UnknownImageReader.cs index 50bc42d9..7e82e340 100644 --- a/Source/Core/IO/UnknownImageReader.cs +++ b/Source/Core/IO/UnknownImageReader.cs @@ -35,12 +35,15 @@ namespace CodeImp.DoomBuilder.IO { internal unsafe class UnknownImageReader : IImageReader { - #region ================== Constructor / Disposer + public uint ImageType { get; private set; } //mxd + + #region ================== Constructor / Disposer // Constructor public UnknownImageReader() { - // We have no destructor + ImageType = DevilImageType.IL_TYPE_UNKNOWN;//mxd + // We have no destructor GC.SuppressFinalize(this); } diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index f8a03723..be67415c 100644 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -150,8 +150,7 @@ namespace CodeImp.DoomBuilder.Rendering public int VertexSize { get { return vertexsize; } } public ViewMode ViewMode { get { return viewmode; } } public SurfaceManager Surfaces { get { return surfaces; } } - //mxd - public RectangleF Viewport { get { return viewport; } } + public RectangleF Viewport { get { return viewport; } } //mxd #endregion diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs index 041a57bd..22af65e2 100644 --- a/Source/Core/Rendering/Renderer3D.cs +++ b/Source/Core/Rendering/Renderer3D.cs @@ -527,7 +527,8 @@ namespace CodeImp.DoomBuilder.Rendering graphics.Shaders.World3D.Begin(); // SOLID PASS - world = Matrix.Identity; + //world = Matrix.Identity; + world = Matrix.Scaling(new Vector3(1.0f, 1.0f, 1.2f)); //mxd. GZDoom vertical scale hack ApplyMatrices3D(); RenderSinglePass((int)RenderPass.Solid); @@ -538,12 +539,14 @@ namespace CodeImp.DoomBuilder.Rendering graphics.Device.SetRenderState(RenderState.CullMode, Cull.Counterclockwise); // MASK PASS - world = Matrix.Identity; + //world = Matrix.Identity; + world = Matrix.Scaling(new Vector3(1.0f, 1.0f, 1.2f)); //mxd. GZDoom vertical scale hack ApplyMatrices3D(); RenderSinglePass((int)RenderPass.Mask); // ALPHA PASS - world = Matrix.Identity; + //world = Matrix.Identity; + world = Matrix.Scaling(new Vector3(1.0f, 1.0f, 1.2f)); //mxd. GZDoom vertical scale hack ApplyMatrices3D(); graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, true); graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false); @@ -556,14 +559,17 @@ namespace CodeImp.DoomBuilder.Rendering if(renderthingcages) RenderThingCages(); // ADDITIVE PASS - world = Matrix.Identity; + //world = Matrix.Identity; + world = Matrix.Scaling(new Vector3(1.0f, 1.0f, 1.2f)); //mxd. GZDoom vertical scale hack ApplyMatrices3D(); graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.One); RenderSinglePass((int)RenderPass.Additive); //mxd. LIGHT PASS - if (General.Settings.GZDrawLights && !fullbrightness && thingsWithLight.Count > 0 && litGeometry.Count > 0) + if (General.Settings.GZDrawLights && !fullbrightness && thingsWithLight.Count > 0 && litGeometry.Count > 0) { + world = Matrix.Scaling(new Vector3(1.0f, 1.0f, 1.2f)); //mxd. GZDoom vertical scale hack RenderLights(litGeometry, thingsWithLight); + } // Remove references graphics.Shaders.World3D.Texture1 = null; @@ -571,10 +577,6 @@ namespace CodeImp.DoomBuilder.Rendering // Done graphics.Shaders.World3D.End(); geometry = null; - - //dbg - //GZBuilder.GZGeneral.TraceLine("Affected by lights: "+totalGeo+"; skipped: "+geoSkipped+"; total things:"+totalThings); - //GZBuilder.GZGeneral.TraceInHeader("FPS:" + calculateFrameRate()); } //mxd @@ -742,10 +744,6 @@ namespace CodeImp.DoomBuilder.Rendering litGeometry[curtexture.Texture].Add(g); } } - - //mxd. Scale everything to match GZDoom's wicked way of rendering - world = Matrix.Scaling(new Vector3(1.0f, 1.0f, 1.2f)); - ApplyMatrices3D(); // Switch shader pass? if(currentshaderpass != wantedshaderpass) @@ -818,70 +816,70 @@ namespace CodeImp.DoomBuilder.Rendering //mxd if (General.Settings.GZDrawModels && (!General.Settings.GZDrawSelectedModelsOnly || t.Selected) && t.Thing.IsModel) continue; - + // Update buffer if needed - t.Update(); + t.Update(); - // Only do this sector when a vertexbuffer is created - if (t.GeometryBuffer != null) { - // Determine the shader pass we want to use for this object - int wantedshaderpass = (((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass; + // Only do this sector when a vertexbuffer is created + if (t.GeometryBuffer != null) { + // Determine the shader pass we want to use for this object + int wantedshaderpass = (((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass; - //mxd. if fog is enagled, switch to shader, which calculates it - if (General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && t.Thing.Sector.Brightness < 248) - wantedshaderpass += 8; + //mxd. if fog is enagled, switch to shader, which calculates it + if (General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && t.Thing.Sector.Brightness < 248) + wantedshaderpass += 8; - //mxd. if current thing is light - set it's color to light color - if (Array.IndexOf(GZBuilder.GZGeneral.GZ_LIGHTS, t.Thing.Type) != -1 && !fullbrightness) { - wantedshaderpass += 4; //render using one of passes, which uses World3D.VertexColor - graphics.Shaders.World3D.VertexColor = t.LightColor; + //mxd. if current thing is light - set it's color to light color + if (Array.IndexOf(GZBuilder.GZGeneral.GZ_LIGHTS, t.Thing.Type) != -1 && !fullbrightness) { + wantedshaderpass += 4; //render using one of passes, which uses World3D.VertexColor + graphics.Shaders.World3D.VertexColor = t.LightColor; //mxd. check if Thing is affected by dynamic lights and set color accordingly - }else if (General.Settings.GZDrawLights && !fullbrightness && thingsWithLight.Count > 0) { - Color4 litColor = getLitColorForThing(t); - if (litColor.ToArgb() != 0) { - wantedshaderpass += 4; //render using one of passes, which uses World3D.VertexColor - graphics.Shaders.World3D.VertexColor = new Color4(t.VertexColor) + litColor; - } + } else if (General.Settings.GZDrawLights && !fullbrightness && thingsWithLight.Count > 0) { + Color4 litColor = getLitColorForThing(t); + if (litColor.ToArgb() != 0) { + wantedshaderpass += 4; //render using one of passes, which uses World3D.VertexColor + graphics.Shaders.World3D.VertexColor = new Color4(t.VertexColor) + litColor; } - - // Switch shader pass? - if (currentshaderpass != wantedshaderpass) { - graphics.Shaders.World3D.EndPass(); - graphics.Shaders.World3D.BeginPass(wantedshaderpass); - currentshaderpass = wantedshaderpass; - } - - // Set the colors to use - if (!graphics.Shaders.Enabled) { - graphics.Device.SetTexture(2, (t.Selected && showselection) ? selectionimage.Texture : null); - graphics.Device.SetTexture(3, ((t == highlighted) && showhighlight) ? highlightimage.Texture : null); - } else { - graphics.Shaders.World3D.SetHighlightColor(CalculateHighlightColor((t == highlighted) && showhighlight, (t.Selected && showselection)).ToArgb()); - } - - // Create the matrix for positioning / rotation - world = t.Orientation; - if (t.Billboard) world = Matrix.Multiply(world, billboard); - world = Matrix.Multiply(world, t.ScaledPosition); //mxd. GZDoom vertical scale hack - ApplyMatrices3D(); - - //mxd. set variables for fog rendering - if (wantedshaderpass > 7) { - graphics.Shaders.World3D.World = world; - - bool sectorHasFogColor = getFogColor(t.Thing.Sector, out fogColor); - graphics.Shaders.World3D.LightColor = fogColor; - graphics.Shaders.World3D.CameraPosition = new Vector4(cameraposition.x, cameraposition.y, cameraposition.z, getFogEnd(t.Thing.Sector, sectorHasFogColor)); - } - - graphics.Shaders.World3D.ApplySettings(); - - // Apply buffer - graphics.Device.SetStreamSource(0, t.GeometryBuffer, 0, WorldVertex.Stride); - - // Render! - graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, t.Triangles); } + + // Switch shader pass? + if (currentshaderpass != wantedshaderpass) { + graphics.Shaders.World3D.EndPass(); + graphics.Shaders.World3D.BeginPass(wantedshaderpass); + currentshaderpass = wantedshaderpass; + } + + // Set the colors to use + if (!graphics.Shaders.Enabled) { + graphics.Device.SetTexture(2, (t.Selected && showselection) ? selectionimage.Texture : null); + graphics.Device.SetTexture(3, ((t == highlighted) && showhighlight) ? highlightimage.Texture : null); + } else { + graphics.Shaders.World3D.SetHighlightColor(CalculateHighlightColor((t == highlighted) && showhighlight, (t.Selected && showselection)).ToArgb()); + } + + // Create the matrix for positioning / rotation + world = t.Orientation; + if (t.Billboard) world = Matrix.Multiply(world, billboard); + world = Matrix.Multiply(world, t.ScaledPosition); //mxd. GZDoom vertical scale hack + ApplyMatrices3D(); + + //mxd. set variables for fog rendering + if (wantedshaderpass > 7) { + graphics.Shaders.World3D.World = world; + + bool sectorHasFogColor = getFogColor(t.Thing.Sector, out fogColor); + graphics.Shaders.World3D.LightColor = fogColor; + graphics.Shaders.World3D.CameraPosition = new Vector4(cameraposition.x, cameraposition.y, cameraposition.z, getFogEnd(t.Thing.Sector, sectorHasFogColor)); + } + + graphics.Shaders.World3D.ApplySettings(); + + // Apply buffer + graphics.Device.SetStreamSource(0, t.GeometryBuffer, 0, WorldVertex.Stride); + + // Render! + graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, t.Triangles); + } } } } @@ -927,7 +925,6 @@ namespace CodeImp.DoomBuilder.Rendering if (lpr.W == 0) continue; graphics.Shaders.World3D.LightColor = lights[i].LightColor; - //graphics.Shaders.World3D.LightPositionAndRadius = lights[i].LightPositionAndRadius; graphics.Shaders.World3D.LightPositionAndRadius = lpr; graphics.Shaders.World3D.ApplySettings(); graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, g.VertexOffset, g.Triangles); @@ -942,12 +939,10 @@ namespace CodeImp.DoomBuilder.Rendering for (i = lightOffsets[0]; i < count; i++) { if (checkBBoxIntersection(g.BoundingBox, lights[i].BoundingBox)) { - //lpr = lights[i].LightPositionAndRadius; lpr = new Vector4(lights[i].Center, lights[i].LightRadius); if (lpr.W == 0) continue; graphics.Shaders.World3D.LightColor = lights[i].LightColor; - //graphics.Shaders.World3D.LightPositionAndRadius = lights[i].LightPositionAndRadius; graphics.Shaders.World3D.LightPositionAndRadius = lpr; graphics.Shaders.World3D.ApplySettings(); graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, g.VertexOffset, g.Triangles); @@ -962,13 +957,11 @@ namespace CodeImp.DoomBuilder.Rendering for (i = lightOffsets[0] + lightOffsets[1]; i < count; i++) { if (checkBBoxIntersection(g.BoundingBox, lights[i].BoundingBox)) { - //lpr = lights[i].LightPositionAndRadius; lpr = new Vector4(lights[i].Center, lights[i].LightRadius); if (lpr.W == 0) continue; Color4 lc = lights[i].LightColor; graphics.Shaders.World3D.LightColor = new Color4(lc.Alpha, (lc.Green + lc.Blue) / 2, (lc.Red + lc.Blue) / 2, (lc.Green + lc.Red) / 2); - //graphics.Shaders.World3D.LightPositionAndRadius = lights[i].LightPositionAndRadius; graphics.Shaders.World3D.LightPositionAndRadius = lpr; graphics.Shaders.World3D.ApplySettings(); graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, g.VertexOffset, g.Triangles); @@ -980,9 +973,6 @@ namespace CodeImp.DoomBuilder.Rendering graphics.Shaders.World3D.EndPass(); graphics.Device.SetRenderState(RenderState.BlendOperation, BlendOperation.Add); - - //dbg - //GZBuilder.GZGeneral.TraceLine("Lit " + gcount + " geometries; Lights: [" + lightOffsets[0] + ";" + lightOffsets[1] + ";" + lightOffsets[2] + "]" + Environment.NewLine + "Models count: " + thingsWithModel.Count); } //mxd. render models @@ -1033,7 +1023,7 @@ namespace CodeImp.DoomBuilder.Rendering // Create the matrix for positioning / rotation world = Matrix.Multiply(t.Orientation, Matrix.RotationZ(t.Thing.Angle)); - world = Matrix.Multiply(world, t.Position); + world = Matrix.Multiply(world, t.ScaledPosition); //mxd. GZDoom vertical scale hack ApplyMatrices3D(); //mxd. set variables for fog rendering @@ -1212,10 +1202,7 @@ namespace CodeImp.DoomBuilder.Rendering Vector3D camNormal = Vector3D.FromAngleXYZ(General.Map.VisualCamera.AngleXY, General.Map.VisualCamera.AngleZ); Vector3D thingNormal = D3DDevice.V3D(bbox[0]) - cameraposition; //bbox[0] is always thing center - if (Vector3D.DotProduct(camNormal, thingNormal) < 0) { //behind camera plane - //GZBuilder.GZGeneral.Trace("Skipped geo. Vector3D.DotProduct(camNormal, thingNormal) < 0"); - return false; - } + if (Vector3D.DotProduct(camNormal, thingNormal) < 0) return false; //behind camera plane int len = bbox.Length; Vector3 screenPos; @@ -1245,12 +1232,8 @@ namespace CodeImp.DoomBuilder.Rendering bottomCount++; } - if (behindCount == len || leftCount == len || rightCount == len || topCount == len || bottomCount == len) { - //dbg - //GZBuilder.GZGeneral.Trace("Skipped geo. Not on screen"); - return false; //Not on screen - } - return true; + bool notOnScreen = (behindCount == len || leftCount == len || rightCount == len || topCount == len || bottomCount == len); + return !notOnScreen; } //mxd diff --git a/Source/Core/VisualModes/VisualMode.cs b/Source/Core/VisualModes/VisualMode.cs index 2c3b2bbc..d10c2a4e 100644 --- a/Source/Core/VisualModes/VisualMode.cs +++ b/Source/Core/VisualModes/VisualMode.cs @@ -645,12 +645,22 @@ namespace CodeImp.DoomBuilder.VisualModes #region ================== Object Picking + //mxd + public VisualPickResult PickObject(Vector3D from, Vector3D to) { + return PickObject(from, to, true); + } + // This picks an object from the scene - public VisualPickResult PickObject(Vector3D from, Vector3D to) + public VisualPickResult PickObject(Vector3D from, Vector3D to, bool scaleHack) { //mxd GZDoom vertical scale hack - to.z *= SCALE_OFFSET; - from.z *= SCALE_OFFSET; + Vector3D from_orig = from; + Vector3D to_orig = to; + + if(scaleHack) { + to.z *= SCALE_OFFSET; + from.z *= SCALE_OFFSET; + } VisualPickResult result = new VisualPickResult(); Line2D ray2d = new Line2D(from, to); @@ -812,7 +822,11 @@ namespace CodeImp.DoomBuilder.VisualModes // Setup final result result.hitpos = from + to * result.u_ray; - + + //mxd. Hackish way to select Things correctly + if(scaleHack && result.picked is VisualThing) + return PickObject(from_orig, to_orig, false); + // Done return result; } diff --git a/Source/Core/Windows/LinedefEditForm.cs b/Source/Core/Windows/LinedefEditForm.cs index b024c737..1acfd0ad 100644 --- a/Source/Core/Windows/LinedefEditForm.cs +++ b/Source/Core/Windows/LinedefEditForm.cs @@ -340,9 +340,6 @@ namespace CodeImp.DoomBuilder.Windows //update arg0str items if (General.Map.NamedScripts.Count > 0) { - //dbg - GZBuilder.GZGeneral.Trace("Got " + General.Map.NamedScripts.Count + " script names"); - ScriptItem[] sn = new ScriptItem[General.Map.NamedScripts.Count]; General.Map.NamedScripts.CopyTo(sn, 0); arg0str.Items.AddRange(sn); @@ -354,11 +351,7 @@ namespace CodeImp.DoomBuilder.Windows } } - //int index = General.Map.NamedScripts.IndexOf(selectedValue); - //if (index != -1) - // arg0str.SelectedIndex = index; - } - else { + } else { arg0str.Text = selectedValue; } } diff --git a/Source/Core/Windows/MainForm.Designer.cs b/Source/Core/Windows/MainForm.Designer.cs index 300cf0c9..038123a1 100644 --- a/Source/Core/Windows/MainForm.Designer.cs +++ b/Source/Core/Windows/MainForm.Designer.cs @@ -190,7 +190,7 @@ namespace CodeImp.DoomBuilder.Windows this.dockersspace = new System.Windows.Forms.Panel(); this.dockerspanel = new CodeImp.DoomBuilder.Controls.DockersControl(); this.dockerscollapser = new System.Windows.Forms.Timer(this.components); - this.warntimer = new System.Windows.Forms.Timer(this.components); + this.warnsTimer = new System.Windows.Forms.Timer(this.components); toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator(); @@ -1745,10 +1745,10 @@ namespace CodeImp.DoomBuilder.Windows this.dockerscollapser.Interval = 200; this.dockerscollapser.Tick += new System.EventHandler(this.dockerscollapser_Tick); // - // warntimer + // warnsTimer // - this.warntimer.Interval = 500; - this.warntimer.Tick += new System.EventHandler(this.warntimer_Tick); + this.warnsTimer.Interval = 500; + this.warnsTimer.Tick += new System.EventHandler(this.warnsTimer_Tick); // // MainForm // @@ -1944,10 +1944,10 @@ namespace CodeImp.DoomBuilder.Windows private System.Windows.Forms.ToolStripButton buttontogglefx; private System.Windows.Forms.ToolStripButton buttontogglefog; private System.Windows.Forms.ToolStripStatusLabel warnsLabel; - private System.Windows.Forms.Timer warntimer; private System.Windows.Forms.ToolStripMenuItem itemReloadModedef; private System.Windows.Forms.ToolStripMenuItem itemReloadGldefs; private System.Windows.Forms.ToolStripMenuItem itemReloadMapinfo; private System.Windows.Forms.ToolStripSeparator separatorDrawModes; + private System.Windows.Forms.Timer warnsTimer; } } \ No newline at end of file diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index e74ce8dd..be5ffed4 100644 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -158,7 +158,7 @@ namespace CodeImp.DoomBuilder.Windows private int lockupdatecount; //mxd - private bool warnStatus; //status of warnings panel icon + private int warningsCount; #endregion @@ -2687,21 +2687,16 @@ namespace CodeImp.DoomBuilder.Windows //mxd. Warnings panel internal void SetWarningsCount(int count) { - if (count == 0) { - if (warnsLabel.Font.Bold) { - warnsLabel.Font = new Font(warnsLabel.Font, FontStyle.Regular); - warnsLabel.Image = global::CodeImp.DoomBuilder.Properties.Resources.WarningOff; - warnsLabel.BackColor = SystemColors.Control; - } - warntimer.Stop(); - warnStatus = false; - } else if (!warnsLabel.Font.Bold) { + warningsCount = count; + + if (warningsCount > 0 && !warnsLabel.Font.Bold) warnsLabel.Font = new Font(warnsLabel.Font, FontStyle.Bold); - warnsLabel.Image = global::CodeImp.DoomBuilder.Properties.Resources.Warning; - warnStatus = true; - warntimer.Start(); + + warnsLabel.Text = warningsCount.ToString(); + if (!warnsTimer.Enabled) { + warnsTimer.Enabled = true; + Console.WriteLine("warntimer Enabled"); } - warnsLabel.Text = count.ToString(); } //mxd @@ -2710,15 +2705,25 @@ namespace CodeImp.DoomBuilder.Windows } //mxd - private void warntimer_Tick(object sender, EventArgs e) { - if (warnStatus) { - warnsLabel.Image = global::CodeImp.DoomBuilder.Properties.Resources.WarningOff; - warnsLabel.BackColor = Color.Red; + private void warnsTimer_Tick(object sender, EventArgs e) { + Console.WriteLine("warntimer_Tick"); + + if (warningsCount > 0) { + if (warnsLabel.BackColor == Color.Red) { + warnsLabel.Font = new Font(warnsLabel.Font, FontStyle.Regular); + warnsLabel.Image = global::CodeImp.DoomBuilder.Properties.Resources.WarningOff; + warnsLabel.BackColor = SystemColors.Control; + } else { + warnsLabel.Font = new Font(warnsLabel.Font, FontStyle.Bold); + warnsLabel.Image = global::CodeImp.DoomBuilder.Properties.Resources.Warning; + warnsLabel.BackColor = Color.Red; + } } else { - warnsLabel.Image = global::CodeImp.DoomBuilder.Properties.Resources.Warning; + warnsLabel.Font = new Font(warnsLabel.Font, FontStyle.Regular); + warnsLabel.Image = global::CodeImp.DoomBuilder.Properties.Resources.WarningOff; warnsLabel.BackColor = SystemColors.Control; + warnsTimer.Stop(); } - warnStatus = !warnStatus; } #endregion diff --git a/Source/Core/Windows/MainForm.resx b/Source/Core/Windows/MainForm.resx index 7aeaf58d..54c320a3 100644 --- a/Source/Core/Windows/MainForm.resx +++ b/Source/Core/Windows/MainForm.resx @@ -246,9 +246,6 @@ 781, 17 - - 17, 56 - True diff --git a/Source/Core/Windows/ThingEditForm.cs b/Source/Core/Windows/ThingEditForm.cs index ef76db11..df0b8810 100644 --- a/Source/Core/Windows/ThingEditForm.cs +++ b/Source/Core/Windows/ThingEditForm.cs @@ -216,9 +216,6 @@ namespace CodeImp.DoomBuilder.Windows //update arg0str items if (General.Map.NamedScripts.Count > 0) { - //dbg - GZBuilder.GZGeneral.Trace("Got " + General.Map.NamedScripts.Count + " script names"); - ScriptItem[] sn = new ScriptItem[General.Map.NamedScripts.Count]; General.Map.NamedScripts.CopyTo(sn, 0); arg0str.Items.AddRange(sn); @@ -229,9 +226,7 @@ namespace CodeImp.DoomBuilder.Windows break; } } - //int index = General.Map.NamedScripts.IndexOf(selectedValue); - //if (index != -1) - //arg0str.SelectedIndex = index; + } else { arg0str.Text = selectedValue; } diff --git a/Source/Plugins/BuilderModes/General/UndoGroup.cs b/Source/Plugins/BuilderModes/General/UndoGroup.cs index 229cceb9..f721ac7a 100644 --- a/Source/Plugins/BuilderModes/General/UndoGroup.cs +++ b/Source/Plugins/BuilderModes/General/UndoGroup.cs @@ -38,5 +38,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public const int SectorBrightnessChange = 3; public const int TextureOffsetChange = 4; public const int SectorHeightChange = 5; + public const int ThingMove = 6; //mxd + public const int ThingRotate = 7; //mxd } } diff --git a/Source/Plugins/BuilderModes/Resources/Actions.cfg b/Source/Plugins/BuilderModes/Resources/Actions.cfg index a2050ac9..84a41a77 100644 --- a/Source/Plugins/BuilderModes/Resources/Actions.cfg +++ b/Source/Plugins/BuilderModes/Resources/Actions.cfg @@ -828,3 +828,26 @@ flipselectionh allowscroll = true; } +//mxd +rotatethingscw +{ + title = "Rotate Selected Things Clockwise"; + category = "visual"; + description = "Rotates selected things clockwise."; + allowkeys = true; + allowmouse = false; + allowscroll = true; + default = 262138; +} + +//mxd +rotatethingsccw +{ + title = "Rotate Selected Things Counterclockwise"; + category = "visual"; + description = "Rotates selected things counterclockwise."; + allowkeys = true; + allowmouse = false; + allowscroll = true; + default = 262139; +} \ No newline at end of file diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 6694e0d1..ed322258 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -439,7 +439,7 @@ namespace CodeImp.DoomBuilder.BuilderModes return; } - PreAction(UndoGroup.SectorHeightChange); + PreAction(UndoGroup.ThingMove); Vector3D[] coords = new Vector3D[visualThings.Count]; for (int i = 0; i < visualThings.Count; i++) @@ -1498,6 +1498,42 @@ namespace CodeImp.DoomBuilder.BuilderModes } PostAction(); } + + //mxd. rotate clockwise + [BeginAction("rotatethingscw")] + public void RotateThingsCW() { + List things = GetSelectedVisualThings(true); + + PreAction(UndoGroup.ThingRotate); + + if (things.Count == 0) { + General.Interface.DisplayStatus(StatusType.Warning, "Select some Things first!"); + return; + } + + foreach (VisualThing t in things) + ((BaseVisualThing)t).OnRotate(General.ClampAngle(t.Thing.AngleDoom + 5)); + + PostAction(); + } + + //mxd. rotate counterclockwise + [BeginAction("rotatethingsccw")] + public void RotateThingsCCW() { + List things = GetSelectedVisualThings(true); + + PreAction(UndoGroup.ThingRotate); + + if (things.Count == 0) { + General.Interface.DisplayStatus(StatusType.Warning, "Select some Things first!"); + return; + } + + foreach (VisualThing t in things) + ((BaseVisualThing)t).OnRotate(General.ClampAngle(t.Thing.AngleDoom - 5)); + + PostAction(); + } #endregion } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 217f793c..bf4fdc03 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -474,13 +474,22 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd - public virtual void OnMove(Vector3D newPosition) { + public void OnMove(Vector3D newPosition) { if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) undoticket = mode.CreateUndo("Move thing"); Thing.Move(newPosition); mode.SetActionResult("Changed thing position to " + Thing.Position.ToString() + "."); this.Changed = true; } + + //mxd + public void OnRotate(int ammount) { + if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) + undoticket = mode.CreateUndo("Rotate thing"); + Thing.Rotate(ammount); + mode.SetActionResult("Changed thing rotation to " + Thing.AngleDoom.ToString() + "."); + this.Changed = true; + } #endregion } diff --git a/Source/Plugins/GZDoomEditing/General/UndoGroup.cs b/Source/Plugins/GZDoomEditing/General/UndoGroup.cs index a08a4b86..0e2a6d20 100644 --- a/Source/Plugins/GZDoomEditing/General/UndoGroup.cs +++ b/Source/Plugins/GZDoomEditing/General/UndoGroup.cs @@ -38,5 +38,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing public const int SectorBrightnessChange = 3; public const int TextureOffsetChange = 4; public const int SectorHeightChange = 5; + public const int ThingMove = 6; //mxd + public const int ThingRotate = 7; //mxd } } diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs index 1b2c3f60..208fd592 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs @@ -456,7 +456,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing return; } - PreAction(UndoGroup.SectorHeightChange); + PreAction(UndoGroup.ThingMove); Vector3D[] coords = new Vector3D[visualThings.Count]; for (int i = 0; i < visualThings.Count; i++) @@ -1758,6 +1758,42 @@ namespace CodeImp.DoomBuilder.GZDoomEditing } PostAction(); } + + //mxd. rotate clockwise + [BeginAction("rotatethingscw", Library = "BuilderModes")] + public void RotateThingsCW() { + List things = GetSelectedVisualThings(true); + + PreAction(UndoGroup.ThingRotate); + + if (things.Count == 0) { + General.Interface.DisplayStatus(StatusType.Warning, "Select some Things first!"); + return; + } + + foreach (VisualThing t in things) + ((BaseVisualThing)t).OnRotate(General.ClampAngle(t.Thing.AngleDoom + 5)); + + PostAction(); + } + + //mxd. rotate counterclockwise + [BeginAction("rotatethingsccw", Library = "BuilderModes")] + public void RotateThingsCCW() { + List things = GetSelectedVisualThings(true); + + PreAction(UndoGroup.ThingRotate); + + if (things.Count == 0) { + General.Interface.DisplayStatus(StatusType.Warning, "Select some Things first!"); + return; + } + + foreach (VisualThing t in things) + ((BaseVisualThing)t).OnRotate(General.ClampAngle(t.Thing.AngleDoom - 5)); + + PostAction(); + } #endregion } diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualThing.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualThing.cs index f5e2d91e..6edde13d 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualThing.cs @@ -521,7 +521,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing } //mxd - public virtual void OnMove(Vector3D newPosition) { + public void OnMove(Vector3D newPosition) { if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) undoticket = mode.CreateUndo("Move thing"); Thing.Move(newPosition); @@ -538,6 +538,15 @@ namespace CodeImp.DoomBuilder.GZDoomEditing this.Changed = true; } + + //mxd + public void OnRotate(int ammount) { + if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) + undoticket = mode.CreateUndo("Rotate thing"); + Thing.Rotate(ammount); + mode.SetActionResult("Changed thing rotation to " + Thing.AngleDoom.ToString() + "."); + this.Changed = true; + } #endregion }