From 25947e59f7cd3ab916096362851d61aa66a5e4ec Mon Sep 17 00:00:00 2001 From: MaxED <j.maxed@gmail.com> Date: Thu, 16 Jun 2016 22:05:17 +0000 Subject: [PATCH] Added "Automap Mode" plugin by Boris Iwansky. --- Builder.sln | 10 + Clean Rebuild.bat | 9 + MakeRelease.bat | 9 + MakeSVNRelease.bat | 9 + Source/Core/Editing/ClassicMode.cs | 3 + Source/Core/Properties/AssemblyInfo.cs | 4 +- Source/Core/Rendering/IRenderer2D.cs | 2 + Source/Core/Rendering/Renderer2D.cs | 28 +- Source/Plugins/AutomapMode/AutomapMode.cs | 291 ++++++++++++++++++ Source/Plugins/AutomapMode/AutomapMode.csproj | 70 +++++ Source/Plugins/AutomapMode/BuilderPlug.cs | 118 +++++++ .../AutomapMode/Properties/AssemblyInfo.cs | 35 +++ .../Plugins/AutomapMode/Resources/Actions.cfg | 31 ++ .../Plugins/AutomapMode/Resources/Hints.cfg | 11 + .../Plugins/AutomapMode/Resources/automap.png | Bin 0 -> 1320 bytes .../BuilderModes/Properties/AssemblyInfo.cs | 4 +- 16 files changed, 620 insertions(+), 14 deletions(-) create mode 100644 Source/Plugins/AutomapMode/AutomapMode.cs create mode 100644 Source/Plugins/AutomapMode/AutomapMode.csproj create mode 100644 Source/Plugins/AutomapMode/BuilderPlug.cs create mode 100644 Source/Plugins/AutomapMode/Properties/AssemblyInfo.cs create mode 100644 Source/Plugins/AutomapMode/Resources/Actions.cfg create mode 100644 Source/Plugins/AutomapMode/Resources/Hints.cfg create mode 100644 Source/Plugins/AutomapMode/Resources/automap.png diff --git a/Builder.sln b/Builder.sln index 92c4b1f30..b89c00d93 100644 --- a/Builder.sln +++ b/Builder.sln @@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoundPropagation", "Source\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StairSectorBuilder", "Source\Plugins\StairSectorBuilder\StairSectorBuilder.csproj", "{3F365121-906B-409D-BB1E-37E0A78056C2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomapMode", "Source\Plugins\AutomapMode\AutomapMode.csproj", "{B33F68D5-1335-400C-A1D7-7F5602A030EF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug + Profiler|x86 = Debug + Profiler|x86 @@ -119,6 +121,14 @@ Global {3F365121-906B-409D-BB1E-37E0A78056C2}.Release + Profiler|x86.Build.0 = Release + Profiler|x86 {3F365121-906B-409D-BB1E-37E0A78056C2}.Release|x86.ActiveCfg = Release|x86 {3F365121-906B-409D-BB1E-37E0A78056C2}.Release|x86.Build.0 = Release|x86 + {B33F68D5-1335-400C-A1D7-7F5602A030EF}.Debug + Profiler|x86.ActiveCfg = Debug|x86 + {B33F68D5-1335-400C-A1D7-7F5602A030EF}.Debug + Profiler|x86.Build.0 = Debug|x86 + {B33F68D5-1335-400C-A1D7-7F5602A030EF}.Debug|x86.ActiveCfg = Debug|x86 + {B33F68D5-1335-400C-A1D7-7F5602A030EF}.Debug|x86.Build.0 = Debug|x86 + {B33F68D5-1335-400C-A1D7-7F5602A030EF}.Release + Profiler|x86.ActiveCfg = Release|x86 + {B33F68D5-1335-400C-A1D7-7F5602A030EF}.Release + Profiler|x86.Build.0 = Release|x86 + {B33F68D5-1335-400C-A1D7-7F5602A030EF}.Release|x86.ActiveCfg = Release|x86 + {B33F68D5-1335-400C-A1D7-7F5602A030EF}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Clean Rebuild.bat b/Clean Rebuild.bat index 1b37cfaa7..fae95069a 100644 --- a/Clean Rebuild.bat +++ b/Clean Rebuild.bat @@ -20,6 +20,15 @@ msbuild "Source\Core\Builder.csproj" /t:Rebuild /p:Configuration=Release /p:Plat IF %ERRORLEVEL% NEQ 0 GOTO ERRORFAIL IF NOT EXIST "Build\Builder.exe" GOTO FILEFAIL +ECHO. +ECHO Compiling Automap Mode plugin... +ECHO. +IF EXIST "Build\Plugins\AutomapMode.dll" DEL /F /Q "Build\Plugins\AutomapMode.dll" > NUL +IF EXIST "Source\Plugins\AutomapMode\obj" RD /S /Q "Source\Plugins\AutomapMode\obj" +msbuild "Source\Plugins\AutomapMode\AutomapMode.csproj" /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal +IF %ERRORLEVEL% NEQ 0 GOTO ERRORFAIL +IF NOT EXIST "Build\Plugins\AutomapMode.dll" GOTO FILEFAIL + ECHO. ECHO Compiling Builder Effects plugin... ECHO. diff --git a/MakeRelease.bat b/MakeRelease.bat index 15010d636..ce63eac16 100644 --- a/MakeRelease.bat +++ b/MakeRelease.bat @@ -60,6 +60,15 @@ msbuild "Source\Core\Builder.csproj" /t:Rebuild /p:Configuration=Release /p:Plat IF %ERRORLEVEL% NEQ 0 GOTO ERRORFAIL IF NOT EXIST "Build\Builder.exe" GOTO FILEFAIL +ECHO. +ECHO Compiling Automap Mode plugin... +ECHO. +IF EXIST "Build\Plugins\AutomapMode.dll" DEL /F /Q "Build\Plugins\AutomapMode.dll" > NUL +IF EXIST "Source\Plugins\AutomapMode\obj" RD /S /Q "Source\Plugins\AutomapMode\obj" +msbuild "Source\Plugins\AutomapMode\AutomapMode.csproj" /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal +IF %ERRORLEVEL% NEQ 0 GOTO ERRORFAIL +IF NOT EXIST "Build\Plugins\AutomapMode.dll" GOTO FILEFAIL + ECHO. ECHO Compiling Builder Effects plugin... ECHO. diff --git a/MakeSVNRelease.bat b/MakeSVNRelease.bat index f315e5786..69533d0dc 100644 --- a/MakeSVNRelease.bat +++ b/MakeSVNRelease.bat @@ -60,6 +60,15 @@ msbuild "Source\Core\Builder.csproj" /t:Rebuild /p:Configuration=Release /p:Plat IF %ERRORLEVEL% NEQ 0 GOTO ERRORFAIL IF NOT EXIST "Build\Builder.exe" GOTO FILEFAIL +ECHO. +ECHO Compiling Automap Mode plugin... +ECHO. +IF EXIST "Build\Plugins\AutomapMode.dll" DEL /F /Q "Build\Plugins\AutomapMode.dll" > NUL +IF EXIST "Source\Plugins\AutomapMode\obj" RD /S /Q "Source\Plugins\AutomapMode\obj" +msbuild "Source\Plugins\AutomapMode\AutomapMode.csproj" /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal +IF %ERRORLEVEL% NEQ 0 GOTO ERRORFAIL +IF NOT EXIST "Build\Plugins\AutomapMode.dll" GOTO FILEFAIL + ECHO. ECHO Compiling Builder Effects plugin... ECHO. diff --git a/Source/Core/Editing/ClassicMode.cs b/Source/Core/Editing/ClassicMode.cs index 8e4666968..805e34552 100644 --- a/Source/Core/Editing/ClassicMode.cs +++ b/Source/Core/Editing/ClassicMode.cs @@ -665,6 +665,9 @@ namespace CodeImp.DoomBuilder.Editing renderer.Finish(); } + //mxd. We want map center drawn by default + renderer.DrawMapCenter = true; + base.OnEngage(); } diff --git a/Source/Core/Properties/AssemblyInfo.cs b/Source/Core/Properties/AssemblyInfo.cs index 61275ec10..05310ee95 100644 --- a/Source/Core/Properties/AssemblyInfo.cs +++ b/Source/Core/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ using System.Resources; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("GZDoom Builder")] -[assembly: AssemblyDescription("ZDoom, GZDoom and Zandronum map editor")] +[assembly: AssemblyDescription("ZDoom, GZDoom and Zandronum map editor (can be used for Vanilla/Boom mapping too!)")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("CodeImp, MaxED")] [assembly: AssemblyProduct("GZDoom Builder")] @@ -29,5 +29,5 @@ using System.Resources; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.2411")] +[assembly: AssemblyVersion("2.3.0.2651")] [assembly: NeutralResourcesLanguageAttribute("en")] diff --git a/Source/Core/Rendering/IRenderer2D.cs b/Source/Core/Rendering/IRenderer2D.cs index bef6a2a6d..0eb9c7af1 100644 --- a/Source/Core/Rendering/IRenderer2D.cs +++ b/Source/Core/Rendering/IRenderer2D.cs @@ -35,6 +35,7 @@ namespace CodeImp.DoomBuilder.Rendering float TranslateY { get; } float Scale { get; } int VertexSize { get; } + bool DrawMapCenter { get; set; } //mxd ViewMode ViewMode { get; } // View methods @@ -58,6 +59,7 @@ namespace CodeImp.DoomBuilder.Rendering // Drawing methods void PlotLine(Vector2D start, Vector2D end, PixelColor c); + void PlotLine(Vector2D start, Vector2D end, PixelColor c, float lengthscaler); //mxd void PlotLinedef(Linedef l, PixelColor c); void PlotLinedefSet(ICollection<Linedef> linedefs); void PlotSector(Sector s); diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index 636a3c282..eee120b9e 100644 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -105,6 +105,8 @@ namespace CodeImp.DoomBuilder.Rendering private float linenormalsize; private float minlinelength; //mxd. Linedef should be longer than this to be rendered private float minlinenormallength; //mxd. Linedef direction indicator should be longer than this to be rendered + private bool drawmapcenter = true; //mxd + private bool lastdrawmapcenter = true; //mxd private float lastgridscale = -1f; private int lastgridsize; private float lastgridx; @@ -125,6 +127,7 @@ namespace CodeImp.DoomBuilder.Rendering public float TranslateY { get { return translatey; } } public float Scale { get { return scale; } } public int VertexSize { get { return vertexsize; } } + public bool DrawMapCenter { get { return drawmapcenter; } set { drawmapcenter = value; } } //mxd public ViewMode ViewMode { get { return viewmode; } } public SurfaceManager Surfaces { get { return surfaces; } } public RectangleF Viewport { get { return viewport; } } //mxd @@ -810,8 +813,8 @@ namespace CodeImp.DoomBuilder.Rendering private unsafe void RenderBackgroundGrid() { // Do we need to redraw grid? - if((lastgridsize != General.Map.Grid.GridSize) || (lastgridscale != scale) || - (lastgridx != offsetx) || (lastgridy != offsety)) + if(lastgridsize != General.Map.Grid.GridSize || lastgridscale != scale || + lastgridx != offsetx || lastgridy != offsety || drawmapcenter != lastdrawmapcenter) { // Lock background rendertarget memory DataRectangle lockedrect = backtex.LockRectangle(0, LockFlags.NoSystemLock); @@ -841,12 +844,15 @@ namespace CodeImp.DoomBuilder.Rendering } //mxd. Render center of map - Vector2D center = new Vector2D().GetTransformed(translatex, translatey, scale, -scale); - int cx = (int)center.x; - int cy = (int)center.y; - PixelColor c = General.Colors.Highlight; - gridplotter.DrawLineSolid(cx, cy + MAP_CENTER_SIZE, cx, cy - MAP_CENTER_SIZE, ref c); - gridplotter.DrawLineSolid(cx - MAP_CENTER_SIZE, cy, cx + MAP_CENTER_SIZE, cy, ref c); + if(drawmapcenter) + { + Vector2D center = new Vector2D().GetTransformed(translatex, translatey, scale, -scale); + int cx = (int)center.x; + int cy = (int)center.y; + PixelColor c = General.Colors.Highlight; + gridplotter.DrawLineSolid(cx, cy + MAP_CENTER_SIZE, cx, cy - MAP_CENTER_SIZE, ref c); + gridplotter.DrawLineSolid(cx - MAP_CENTER_SIZE, cy, cx + MAP_CENTER_SIZE, cy, ref c); + } // Done backtex.UnlockRectangle(0); @@ -855,6 +861,7 @@ namespace CodeImp.DoomBuilder.Rendering lastgridsize = General.Map.Grid.GridSize; lastgridx = offsetx; lastgridy = offsety; + lastdrawmapcenter = drawmapcenter; //mxd } } @@ -2031,14 +2038,15 @@ namespace CodeImp.DoomBuilder.Rendering } // This renders a simple line - public void PlotLine(Vector2D start, Vector2D end, PixelColor c) + public void PlotLine(Vector2D start, Vector2D end, PixelColor c) { PlotLine(start, end, c, 0.0625f); } + public void PlotLine(Vector2D start, Vector2D end, PixelColor c, float lengthscaler) { // Transform coordinates Vector2D v1 = start.GetTransformed(translatex, translatey, scale, -scale); Vector2D v2 = end.GetTransformed(translatex, translatey, scale, -scale); //mxd. Should we bother? - if((v2 - v1).GetLengthSq() < linenormalsize * 0.0625f) return; + if((v2 - v1).GetLengthSq() < linenormalsize * lengthscaler) return; // Draw line plotter.DrawLineSolid((int)v1.x, (int)v1.y, (int)v2.x, (int)v2.y, ref c); diff --git a/Source/Plugins/AutomapMode/AutomapMode.cs b/Source/Plugins/AutomapMode/AutomapMode.cs new file mode 100644 index 000000000..e22964cfa --- /dev/null +++ b/Source/Plugins/AutomapMode/AutomapMode.cs @@ -0,0 +1,291 @@ + +#region ================== Copyright (c) 2016 Boris Iwanski + +/* + * Copyright (c) 2016 Boris Iwanski https://github.com/biwa/automapmode + * This program is released under GNU General Public License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#endregion + +#region ================== Namespaces + +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using CodeImp.DoomBuilder.Map; +using CodeImp.DoomBuilder.Rendering; +using CodeImp.DoomBuilder.Editing; + +#endregion + +namespace CodeImp.DoomBuilder.AutomapMode +{ + [EditMode(DisplayName = "Automap Mode", + SwitchAction = "automapmode", // Action name used to switch to this mode + ButtonImage = "automap.png", // Image resource name for the button + ButtonOrder = int.MinValue + 503, // Position of the button (lower is more to the bottom) + ButtonGroup = "000_editing", + UseByDefault = true, + SafeStartMode = true)] + + public class AutomapMode : ClassicMode + { + #region ================== Constants + + private const float LINE_LENGTH_SCALER = 0.001f; //mxd + + #endregion + + #region ================== Variables + + private CustomPresentation automappresentation; + private List<Linedef> validlinedefs; + + // Highlighted item + private Linedef highlighted; + + #endregion + + #region ================== Properties + + public override object HighlightedObject { get { return highlighted; } } + + #endregion + + #region ================== Constructor / Disposer + + #endregion + + #region ================== Methods + + // This highlights a new item + private void Highlight(Linedef l) + { + // Update display + if(renderer.StartPlotter(false)) + { + // Undraw previous highlight + if((highlighted != null) && !highlighted.IsDisposed) + { + PixelColor c = LinedefIsValid(highlighted) ? DetermineLinedefColor(highlighted) : new PixelColor(255, 0, 0, 0); + renderer.PlotLine(highlighted.Start.Position, highlighted.End.Position, c, LINE_LENGTH_SCALER); + } + + // Set new highlight + highlighted = l; + + // Render highlighted item + if((highlighted != null) && !highlighted.IsDisposed && LinedefIsValid(highlighted)) + { + renderer.PlotLine(highlighted.Start.Position, highlighted.End.Position, General.Colors.InfoLine, LINE_LENGTH_SCALER); + } + + // Done + renderer.Finish(); + renderer.Present(); + } + + // Show highlight info + if((highlighted != null) && !highlighted.IsDisposed) + General.Interface.ShowLinedefInfo(highlighted); + else + General.Interface.HideInfo(); + } + + //mxd + internal void UpdateValidLinedefs() + { + validlinedefs = new List<Linedef>(); + foreach(Linedef ld in General.Map.Map.Linedefs) + if(LinedefIsValid(ld)) validlinedefs.Add(ld); + } + + private static PixelColor DetermineLinedefColor(Linedef ld) + { + if(ld.IsFlagSet(BuilderPlug.Me.HiddenFlag)) + return new PixelColor(255, 192, 192, 192); + + if(ld.Back == null || ld.IsFlagSet(BuilderPlug.Me.SecretFlag)) + return new PixelColor(255, 252, 0, 0); + + if(ld.Front.Sector.FloorHeight != ld.Back.Sector.FloorHeight) + return new PixelColor(255, 188, 120, 72); + + if(ld.Front.Sector.CeilHeight != ld.Back.Sector.CeilHeight) + return new PixelColor(255, 252, 252, 0); + + if(ld.Front.Sector.CeilHeight == ld.Back.Sector.CeilHeight && ld.Front.Sector.FloorHeight == ld.Back.Sector.FloorHeight) + return new PixelColor(255, 128, 128, 128); + + if(General.Interface.CtrlState) + return new PixelColor(255, 192, 192, 192); + + return new PixelColor(255, 255, 255, 255); + } + + private static bool LinedefIsValid(Linedef ld) + { + if(General.Interface.CtrlState) return true; + if(ld.IsFlagSet(BuilderPlug.Me.HiddenFlag)) return false; + if(ld.Back == null || ld.IsFlagSet(BuilderPlug.Me.SecretFlag)) return true; + if(ld.Back != null && (ld.Front.Sector.FloorHeight != ld.Back.Sector.FloorHeight || ld.Front.Sector.CeilHeight != ld.Back.Sector.CeilHeight)) return true; + + return false; + } + + #endregion + + #region ================== Events + + public override void OnHelp() + { + General.ShowHelp("/gzdb/features/classic_modes/mode_automap.html"); + } + + // Cancel mode + public override void OnCancel() + { + base.OnCancel(); + + // Return to this mode + General.Editing.ChangeMode(new AutomapMode()); + } + + // Mode engages + public override void OnEngage() + { + base.OnEngage(); + renderer.DrawMapCenter = false; //mxd + + // Automap presentation without the surfaces + automappresentation = new CustomPresentation(); + automappresentation.AddLayer(new PresentLayer(RendererLayer.Background, BlendingMode.Mask, General.Settings.BackgroundAlpha)); + automappresentation.AddLayer(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask)); + automappresentation.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true)); + renderer.SetPresentation(automappresentation); + + UpdateValidLinedefs(); + } + + // Mode disengages + public override void OnDisengage() + { + base.OnDisengage(); + + // Hide highlight info + General.Interface.HideInfo(); + } + + // This redraws the display + public override void OnRedrawDisplay() + { + renderer.RedrawSurface(); + + // Render lines + if(renderer.StartPlotter(true)) + { + foreach(Linedef ld in General.Map.Map.Linedefs) + { + if(LinedefIsValid(ld)) + renderer.PlotLine(ld.Start.Position, ld.End.Position, DetermineLinedefColor(ld), LINE_LENGTH_SCALER); + } + + if((highlighted != null) && !highlighted.IsDisposed && LinedefIsValid(highlighted)) + { + renderer.PlotLine(highlighted.Start.Position, highlighted.End.Position, General.Colors.InfoLine, LINE_LENGTH_SCALER); + } + + renderer.Finish(); + } + + renderer.Present(); + } + + protected override void OnSelectEnd() + { + // Item highlighted? + if((highlighted != null) && !highlighted.IsDisposed) + { + General.Map.UndoRedo.CreateUndo("Toggle linedef show as 1-sided on automap flag"); + + // Toggle flag + highlighted.SetFlag(BuilderPlug.Me.SecretFlag, !highlighted.IsFlagSet(BuilderPlug.Me.SecretFlag)); + UpdateValidLinedefs(); + } + + base.OnSelectEnd(); + } + + protected override void OnEditEnd() + { + // Item highlighted? + if((highlighted != null) && !highlighted.IsDisposed) + { + General.Map.UndoRedo.CreateUndo("Toggle linedef not shown on automap flag"); + + // Toggle flag + highlighted.SetFlag(BuilderPlug.Me.HiddenFlag, !highlighted.IsFlagSet(BuilderPlug.Me.HiddenFlag)); + UpdateValidLinedefs(); + General.Interface.RedrawDisplay(); + } + + base.OnEditEnd(); + } + + // Mouse moves + public override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + // Not holding any buttons? + if(e.Button == MouseButtons.None) + { + // Find the nearest linedef within highlight range + Linedef l = MapSet.NearestLinedefRange(validlinedefs, mousemappos, BuilderPlug.Me.HighlightRange / renderer.Scale); + + // Highlight if not the same + if(l != highlighted) Highlight(l); + } + } + + // Mouse leaves + public override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + + // Highlight nothing + Highlight(null); + } + + public override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + + if(e.Control) + { + UpdateValidLinedefs(); + General.Interface.RedrawDisplay(); + } + } + + public override void OnKeyUp(KeyEventArgs e) + { + base.OnKeyUp(e); + + if(!e.Control) + { + UpdateValidLinedefs(); + General.Interface.RedrawDisplay(); + } + } + + #endregion + } +} diff --git a/Source/Plugins/AutomapMode/AutomapMode.csproj b/Source/Plugins/AutomapMode/AutomapMode.csproj new file mode 100644 index 000000000..8431646ba --- /dev/null +++ b/Source/Plugins/AutomapMode/AutomapMode.csproj @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{B33F68D5-1335-400C-A1D7-7F5602A030EF}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>CodeImp.DoomBuilder.AutomapMode</RootNamespace> + <AssemblyName>AutomapMode</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <StartupObject> + </StartupObject> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <OutputPath>..\..\..\Build\Plugins\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <OutputPath>..\..\..\Build\Plugins\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>x86</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> + <ItemGroup> + <Compile Include="BuilderPlug.cs" /> + <Compile Include="AutomapMode.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Core\Builder.csproj"> + <Project>{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}</Project> + <Name>Builder</Name> + <Private>False</Private> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Windows.Forms" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Resources\automap.png" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Resources\Actions.cfg" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Resources\Hints.cfg" /> + </ItemGroup> +</Project> \ No newline at end of file diff --git a/Source/Plugins/AutomapMode/BuilderPlug.cs b/Source/Plugins/AutomapMode/BuilderPlug.cs new file mode 100644 index 000000000..5c74205b8 --- /dev/null +++ b/Source/Plugins/AutomapMode/BuilderPlug.cs @@ -0,0 +1,118 @@ + +#region ================== Copyright (c) 2016 Boris Iwanski + +/* + * Copyright (c) 2016 Boris Iwanski https://github.com/biwa/automapmode + * This program is released under GNU General Public License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#endregion + +#region ================== Namespaces + +using CodeImp.DoomBuilder.Plugins; + +#endregion + +namespace CodeImp.DoomBuilder.AutomapMode +{ + // + // MANDATORY: The plug! + // This is an important class to the Doom Builder core. Every plugin must + // have exactly 1 class that inherits from Plug. When the plugin is loaded, + // this class is instantiated and used to receive events from the core. + // Make sure the class is public, because only public classes can be seen + // by the core. + // + + public class BuilderPlug : Plug + { + #region ================== Variables + + private float highlightrange; + + // Static instance. We can't use a real static class, because BuilderPlug must + // be instantiated by the core, so we keep a static reference. (this technique + // should be familiar to object-oriented programmers) + private static BuilderPlug me; + + #endregion + + #region ================== Properties + + public float HighlightRange { get { return highlightrange; } } + public string SecretFlag { get { return General.Map.UDMF ? "secret" : "32"; } } + public string HiddenFlag { get { return General.Map.UDMF ? "dontdraw" : "128"; } } + + // This plugin relies on some functionality that wasn't there in older versions + public override int MinimumRevision { get { return 2651; } } + + // Static property to access the BuilderPlug + public static BuilderPlug Me { get { return me; } } + + #endregion + + #region ================== Methods + + // This event is called when the plugin is initialized + public override void OnInitialize() + { + base.OnInitialize(); + + // This binds the methods in this class that have the BeginAction + // and EndAction attributes with their actions. Without this, the + // attributes are useless. Note that in classes derived from EditMode + // this is not needed, because they are bound automatically when the + // editing mode is engaged. + General.Actions.BindMethods(this); + + // TODO: Add DB2 version check so that old DB2 versions won't crash + // General.ErrorLogger.Add(ErrorType.Error, "zomg!"); + + // Keep a static reference + me = this; + + LoadSettings(); + } + + //mxd + public override void OnMapOpenEnd() + { + AutomapMode mode = General.Editing.Mode as AutomapMode; + if(mode != null) mode.UpdateValidLinedefs(); + + base.OnMapOpenEnd(); + } + + //mxd + public override void OnMapNewEnd() + { + AutomapMode mode = General.Editing.Mode as AutomapMode; + if(mode != null) mode.UpdateValidLinedefs(); + + base.OnMapNewEnd(); + } + + // This is called when the plugin is terminated + public override void Dispose() + { + base.Dispose(); + + // This must be called to remove bound methods for actions. + General.Actions.UnbindMethods(this); + } + + private void LoadSettings() + { + highlightrange = General.Settings.ReadPluginSetting("buildermodes", "highlightrange", 20); + } + + #endregion + } +} diff --git a/Source/Plugins/AutomapMode/Properties/AssemblyInfo.cs b/Source/Plugins/AutomapMode/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..fc4af16e3 --- /dev/null +++ b/Source/Plugins/AutomapMode/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Automap Mode")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AutomapMode")] +[assembly: AssemblyCopyright("Copyright (c) 2016 Boris Iwanski")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("508a1fd7-53a2-40cf-be6c-9b306ee730fa")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute("en")] diff --git a/Source/Plugins/AutomapMode/Resources/Actions.cfg b/Source/Plugins/AutomapMode/Resources/Actions.cfg new file mode 100644 index 000000000..9fee98f9d --- /dev/null +++ b/Source/Plugins/AutomapMode/Resources/Actions.cfg @@ -0,0 +1,31 @@ +// +// This file defines which actions there are, what description they have and +// some behaviour options. The Doom Builder core will bind to these actions +// with delegates (function pointers) where you use the BeginAction and +// EndAction attributes. This file must be named Actions.cfg and must be +// included in the plugin project as "Embedded Resource". +// + +// +// Options: +// +// allowkeys: Allows the user to bind standard keys to this action. +// allowmouse: Allows the user to bind mouse buttons to this action. +// allowscroll: Allows the user to bind the scrollwheel to this action. +// disregardshift: This action will trigger regardless if Shift or Control is used. +// repeat: BeginAction will be called for automatic key repetition. +// default: Default key is only used when the action is loaded for the first +// time and the default key is not used by any other action. +// +// allowkeys and allowmouse are true by default, the others are false by default. +// + +automapmode +{ + title = "Automap mode"; + category = "modes"; + description = "Displays the map as shown in Doom's automap"; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} \ No newline at end of file diff --git a/Source/Plugins/AutomapMode/Resources/Hints.cfg b/Source/Plugins/AutomapMode/Resources/Hints.cfg new file mode 100644 index 000000000..f2d3e1b64 --- /dev/null +++ b/Source/Plugins/AutomapMode/Resources/Hints.cfg @@ -0,0 +1,11 @@ +// This is GZDB hints configuration file. It's dev-only stuff so bare minimum of boilerplate is present in the parser class +// (e.g. create your Hints.cfg exactly the way it's done here or face consequences). +// "class" should exactly match your classname; "group" can be anything. "general" and "multiselection" groups are shown automatically when appropriate. +// Supported tags are <b> for Bold and <br> for line break. Action name inside of <k> tag will insert keyboard shortcut for given action in bold. +// Only single-line comments are supported. + +class AutomapMode +group general +"<b>Left click</b> on a line to toggle the <b>'Shown as 1-sided on automap'</b> flag." +"<b>Right click</b> on a line to toggle the <b>'Not shown on automap'</b> flag." +"Hold <b>Ctrl</b> to show lines that are not drawn, either because there was no height change (gray) or the <b>'Not shown on automap'</b> flag is set (light gray)." \ No newline at end of file diff --git a/Source/Plugins/AutomapMode/Resources/automap.png b/Source/Plugins/AutomapMode/Resources/automap.png new file mode 100644 index 0000000000000000000000000000000000000000..4802d6d5474ea3ef9a0764716d8b8d5732e45135 GIT binary patch literal 1320 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nAI{vB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxOgGuU%v{0TQqR!T z+}y-mN5ROz&{W^RSl`${*T~q)#K6kLNC66zfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD<cE0=g99h1>$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;Np<V zf>iyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0!ZY(y z^2>`g!FqgstvvIJOA_;vQ$1a5m4K$`WoD*W85lVk7(1I=8XLPg8XCHqIawN;xjDPK zIvW{Vn7BEb!t}c2Czs}?=9R$orXch>;?xUD4!H$Dn_W_iGRsm^+=}vZ6~NxM%Eav! zbDZWu^`_u<iv>=-`as9%gCZ9xvSC8N6a-?zlP-`0PyDHQz!YBuOxoXrBik4l7-x98 zIEGZ*ni6E~!R#ndYdL*QMQ2;EkW!t)8O<)2Zh>UQrW+bftv5QOZY|k(B}za<vA1__ z?~R)g90x^&IH!dj<Nv|vcp}k&?R|{!ci~_TH<`Bb_i6Xf+<DuxTGD{AZ>uhQimDRZ zl&QNtZ$|5XnC{_|mbL1e)rKbvSN^a#p6O6&x=GK}%adit$*JvjEVC_qgC|X8=gkw! zyJi_!DDp<GeQv0bMr4Fs@cpPQGnLr%ZNwj@<feJ-QJ*xM&--%=KQqUMyMM1#PAu3O zx*^nwS#;~RKD{tCb~C<n{H5Du9Tu|&y<#(ZV|i+m`Tn?zxd;EfNjR}Uq%|zPW5OY+ zu&J3pmS@hNR-v&bF;w#6x<<Q4<trrD{3*GZXn!SE?pC$GK+-JM>nt_L<NjyXOnBHk z|LprEa=MPUcxvDOUbnMXby7vG{KFiPheoG1ANx>I|N7*sDJzeuu#0p5tZX?h&O2BC zM3;=&{+xvzQG%9bwMWvHohpd%_S=$Gf2uv@y!Y0c#G4Br#eF{iwD{+P*DmRkUrb)U iV{ygGz4zjoco<erUC7Fv`>+;Nc6qw`xvX<aXaWGaY16&{ literal 0 HcmV?d00001 diff --git a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs index d7a3d9389..0d4f21326 100644 --- a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs +++ b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Resources; [assembly: AssemblyDescription("GZDoom Builder Editing Modes")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("CodeImp, MaxED")] -[assembly: AssemblyProduct("Doom Builder")] +[assembly: AssemblyProduct("GZDoom Builder")] [assembly: AssemblyCopyright("Copyright © 2007, 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -29,5 +29,5 @@ using System.Resources; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.2411")] +[assembly: AssemblyVersion("2.3.0.2651")] [assembly: NeutralResourcesLanguageAttribute("en")] -- GitLab