From 2ea72437be215d99916b481dedd0ef60bf082c58 Mon Sep 17 00:00:00 2001 From: MaxED Date: Wed, 20 Jul 2016 19:17:31 +0000 Subject: [PATCH] Added, Visual mode: added support for "Change Floor Brightness to this Brightness" and "Change Ceiling Brightness to this Brightness" Boom actions. Changed, Sectors mode: "Flip Linedefs" and "Align Linedefs" actions will no longer flip single-sided linedefs with only front side. Fixed, Script Editor: fixed a crash when trying to update script navigator combo box when switching to a never saved ACS script. --- .../Configurations/Includes/Boom_linedefs.cfg | 6 +- Build/Scripting/ZDoom_ACS.cfg | 1 + Build/Scripting/ZDoom_DECORATE.cfg | 1 + .../Core/Data/Scripting/AccScriptHandler.cs | 2 +- Source/Core/Geometry/Tools.cs | 8 +- .../BuilderModes/ClassicModes/SectorsMode.cs | 12 +-- .../VisualModes/BaseVisualMode.cs | 87 ++++++++++++------- 7 files changed, 76 insertions(+), 41 deletions(-) diff --git a/Build/Configurations/Includes/Boom_linedefs.cfg b/Build/Configurations/Includes/Boom_linedefs.cfg index 7bcd7ceb..4dc23805 100644 --- a/Build/Configurations/Includes/Boom_linedefs.cfg +++ b/Build/Configurations/Includes/Boom_linedefs.cfg @@ -107,7 +107,8 @@ floor 213 { - title = "Floor Change Brightness to this Brightness"; + title = "Change Floor Brightness to this Brightness"; + id = "Boom_Transfer_FloorLight"; prefix = ""; } @@ -641,7 +642,8 @@ ceiling 261 { - title = "Ceiling Brightness to this Brightness"; + title = "Change Ceiling Brightness to this Brightness"; + id = "Boom_Transfer_CeilingLight"; prefix = ""; } } diff --git a/Build/Scripting/ZDoom_ACS.cfg b/Build/Scripting/ZDoom_ACS.cfg index d808289b..3bdd403a 100644 --- a/Build/Scripting/ZDoom_ACS.cfg +++ b/Build/Scripting/ZDoom_ACS.cfg @@ -551,6 +551,7 @@ constants APROP_Damage; APROP_DamageFactor; APROP_DamageMultiplier; + APROP_DamageType; APROP_DeathSound; APROP_Dormant; APROP_Dropped; diff --git a/Build/Scripting/ZDoom_DECORATE.cfg b/Build/Scripting/ZDoom_DECORATE.cfg index db7c0c9e..8c316998 100644 --- a/Build/Scripting/ZDoom_DECORATE.cfg +++ b/Build/Scripting/ZDoom_DECORATE.cfg @@ -1189,6 +1189,7 @@ constants DMSS_EXFILTER; DMSS_EXSPECIES; DMSS_EITHER; + DMSS_INFLICTORDMGTYPE; FMDF_NOPITCH; FMDF_NOANGLE; FMDF_INTERPOLATE; diff --git a/Source/Core/Data/Scripting/AccScriptHandler.cs b/Source/Core/Data/Scripting/AccScriptHandler.cs index fc0d6b00..0b851e2c 100644 --- a/Source/Core/Data/Scripting/AccScriptHandler.cs +++ b/Source/Core/Data/Scripting/AccScriptHandler.cs @@ -25,7 +25,7 @@ namespace CodeImp.DoomBuilder.Data.Scripting target.Items.Clear(); AcsParserSE parser = new AcsParserSE { AddArgumentsToScriptNames = true, IsMapScriptsLump = tab is ScriptLumpDocumentTab, IgnoreErrors = true }; - DataLocation dl = new DataLocation(DataLocation.RESOURCE_DIRECTORY, Path.GetDirectoryName(tab.Filename), false, false, false); + DataLocation dl = new DataLocation(DataLocation.RESOURCE_DIRECTORY, Path.GetDirectoryName(string.IsNullOrEmpty(tab.Filename)? tab.Title : tab.Filename), false, false, false); TextResourceData data = new TextResourceData(stream, dl, (parser.IsMapScriptsLump ? "?SCRIPTS" : tab.Filename), false); if(parser.Parse(data, false)) diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 8be3b259..e897a317 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -2314,8 +2314,12 @@ namespace CodeImp.DoomBuilder.Geometry { foreach(Linedef l in frontlines) { - l.FlipVertices(); - l.FlipSidedefs(); + // Skip single-sided lines with only front side + if(l.Back != null) + { + l.FlipVertices(); + l.FlipSidedefs(); + } } } } diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 9ac62532..6fd42b5e 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -2524,13 +2524,13 @@ namespace CodeImp.DoomBuilder.BuilderModes // Make undo if(selected.Count > 1) { - General.Map.UndoRedo.CreateUndo("Align linedefs of " + selected.Count + " sectors"); - General.Interface.DisplayStatus(StatusType.Action, "Aligned linedefs of " + selected.Count + "sectors."); + General.Map.UndoRedo.CreateUndo("Flip linedefs of " + selected.Count + " sectors"); + General.Interface.DisplayStatus(StatusType.Action, "Flipped linedefs of " + selected.Count + "sectors."); } else { - General.Map.UndoRedo.CreateUndo("Align sector linedefs"); - General.Interface.DisplayStatus(StatusType.Action, "Aligned sector linedefs."); + General.Map.UndoRedo.CreateUndo("Flip sector linedefs"); + General.Interface.DisplayStatus(StatusType.Action, "Flipped sector linedefs."); } HashSet selectedlines = new HashSet(); @@ -2538,7 +2538,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { foreach(Sidedef side in s.Sidedefs) { - if(!selectedlines.Contains(side.Line)) selectedlines.Add(side.Line); + // Skip single-sided lines with only front side + if(!selectedlines.Contains(side.Line) && (side.Line.Back != null || side.Line.Front == null)) + selectedlines.Add(side.Line); } } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 33af459b..88ae0698 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -745,19 +745,15 @@ namespace CodeImp.DoomBuilder.BuilderModes // This requires that the blockmap is up-to-date! internal void RebuildElementData() { - //mxd - Sector[] sectorsWithEffects = null; + HashSet effectsectors = null; //mxd - if(!General.Settings.GZDoomRenderingEffects) + if(!General.Settings.GZDoomRenderingEffects) //mxd { - //store all sectors with effects + // Store all sectors with effects if(sectordata != null && sectordata.Count > 0) - { - sectorsWithEffects = new Sector[sectordata.Count]; - sectordata.Keys.CopyTo(sectorsWithEffects, 0); - } + effectsectors = new HashSet(sectordata.Keys); - //remove all vertex handles from selection + // Remove all vertex handles from selection if(vertices != null && vertices.Count > 0) { foreach(IVisualEventReceiver i in selectedobjects) @@ -771,17 +767,16 @@ namespace CodeImp.DoomBuilder.BuilderModes sectordata = new Dictionary(General.Map.Map.Sectors.Count); thingdata = new Dictionary(General.Map.Map.Things.Count); - //mxd. rebuild all sectors with effects - if(sectorsWithEffects != null) + //mxd. Rebuild all sectors with effects + if(effectsectors != null) { - for(int i = 0; i < sectorsWithEffects.Length; i++) + foreach(Sector s in effectsectors) { + if(!VisualSectorExists(s)) continue; + // The visual sector associated is now outdated - if(VisualSectorExists(sectorsWithEffects[i])) - { - BaseVisualSector vs = (BaseVisualSector)GetVisualSector(sectorsWithEffects[i]); - vs.UpdateSectorGeometry(true); - } + BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s); + vs.UpdateSectorGeometry(true); } } @@ -793,7 +788,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(!General.Settings.GZDoomRenderingEffects) return; //mxd - // Find all sector who's tag is not 0 and hash them so that we can find them quicly + // Find all sector who's tag is not 0 and hash them so that we can find them quickly foreach(Sector s in General.Map.Map.Sectors) { foreach(int tag in s.Tags) @@ -852,10 +847,13 @@ namespace CodeImp.DoomBuilder.BuilderModes // Find interesting linedefs (such as line slopes) foreach(Linedef l in General.Map.Map.Linedefs) { - switch(l.Action) + //mxd. Rewritten to use action ID instead of number + if(l.Action == 0 || !General.Map.Config.LinedefActions.ContainsKey(l.Action)) continue; + + switch(General.Map.Config.LinedefActions[l.Action].Id.ToLowerInvariant()) { - // ========== Plane Align (see http://zdoom.org/wiki/Plane_Align) ========== - case 181: + // ========== Plane Align (181) (see http://zdoom.org/wiki/Plane_Align) ========== + case "plane_align": if(((l.Args[0] == 1) || (l.Args[1] == 1)) && (l.Front != null)) { SectorData sd = GetSectorData(l.Front.Sector); @@ -868,8 +866,8 @@ namespace CodeImp.DoomBuilder.BuilderModes } break; - // ========== Plane Copy (mxd) (see http://zdoom.org/wiki/Plane_Copy) ========== - case 118: + // ========== Plane Copy (118) (mxd) (see http://zdoom.org/wiki/Plane_Copy) ========== + case "plane_copy": { //check the flags... bool floorCopyToBack = false; @@ -907,8 +905,8 @@ namespace CodeImp.DoomBuilder.BuilderModes } break; - // ========== Sector 3D floor (see http://zdoom.org/wiki/Sector_Set3dFloor) ========== - case 160: + // ========== Sector 3D floor (160) (see http://zdoom.org/wiki/Sector_Set3dFloor) ========== + case "sector_set3dfloor": if(l.Front != null) { //mxd. Added hi-tag/line ID check @@ -925,8 +923,8 @@ namespace CodeImp.DoomBuilder.BuilderModes } break; - // ========== Transfer Brightness (see http://zdoom.org/wiki/ExtraFloor_LightOnly) ========= - case 50: + // ========== Transfer Brightness (50) (see http://zdoom.org/wiki/ExtraFloor_LightOnly) ========= + case "extrafloor_lightonly": if(l.Front != null && sectortags.ContainsKey(l.Args[0])) { List sectors = sectortags[l.Args[0]]; @@ -938,8 +936,8 @@ namespace CodeImp.DoomBuilder.BuilderModes } break; - // ========== mxd. Transfer Floor Brightness (see http://www.zdoom.org/w/index.php?title=Transfer_FloorLight) ========= - case 210: + // ========== mxd. Transfer Floor Brightness (210) (see http://www.zdoom.org/w/index.php?title=Transfer_FloorLight) ========= + case "transfer_floorlight": if(l.Front != null && sectortags.ContainsKey(l.Args[0])) { List sectors = sectortags[l.Args[0]]; @@ -951,8 +949,8 @@ namespace CodeImp.DoomBuilder.BuilderModes } break; - // ========== mxd. Transfer Ceiling Brightness (see http://www.zdoom.org/w/index.php?title=Transfer_CeilingLight) ========= - case 211: + // ========== mxd. Transfer Ceiling Brightness (211) (see http://www.zdoom.org/w/index.php?title=Transfer_CeilingLight) ========= + case "transfer_ceilinglight": if(l.Front != null && sectortags.ContainsKey(l.Args[0])) { List sectors = sectortags[l.Args[0]]; @@ -963,10 +961,37 @@ namespace CodeImp.DoomBuilder.BuilderModes } } break; + + // ========== mxd. BOOM: Set Tagged Floor Lighting to Lighting on 1st Sidedef's Sector (213) ========= + case "boom_transfer_floorlight": + if(l.Front != null && sectortags.ContainsKey(l.Tag)) + { + List sectors = sectortags[l.Tag]; + foreach(Sector s in sectors) + { + SectorData sd = GetSectorData(s); + sd.AddEffectTransferFloorBrightness(l); + } + } + break; + + // ========== mxd. BOOM: Set Tagged Ceiling Lighting to Lighting on 1st Sidedef's Sector (261) ========= + case "boom_transfer_ceilinglight": + if(l.Front != null && sectortags.ContainsKey(l.Tag)) + { + List sectors = sectortags[l.Tag]; + foreach(Sector s in sectors) + { + SectorData sd = GetSectorData(s); + sd.AddEffectTransferCeilingBrightness(l); + } + } + break; } } // Find interesting things (such as sector slopes) + //TODO: rewrite using classnames instead of numbers foreach(Thing t in General.Map.Map.Things) { switch(t.Type)