mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-09 09:11:11 +00:00
Added support for only enabling editing modes when the current game configuration supports the features. Currently only applies to 3D Floor Mode, Slope Mode, and Draw Slope Mode. Fixes #463
This commit is contained in:
parent
58c476f4e5
commit
6c003f1cb1
8 changed files with 78 additions and 8 deletions
|
@ -231,6 +231,10 @@ mapformat_hexen
|
||||||
// When this is set to true, sectors with the same tag will light up when a line is highlighted
|
// When this is set to true, sectors with the same tag will light up when a line is highlighted
|
||||||
linetagindicatesectors = false;
|
linetagindicatesectors = false;
|
||||||
|
|
||||||
|
// Enables support for 3D floors (not really, since support for 3D floors is pretty much hard-coded, but
|
||||||
|
// this tells plugins that the game supports 3D floors)
|
||||||
|
effect3dfloorsupport = true;
|
||||||
|
|
||||||
// Special linedefs
|
// Special linedefs
|
||||||
include("ZDoom_misc.cfg", "speciallinedefs_doomhexen");
|
include("ZDoom_misc.cfg", "speciallinedefs_doomhexen");
|
||||||
|
|
||||||
|
@ -347,6 +351,13 @@ mapformat_udmf
|
||||||
// Enables support for individual offsets of upper/middle/lower sidedef textures
|
// Enables support for individual offsets of upper/middle/lower sidedef textures
|
||||||
localsidedeftextureoffsets = true;
|
localsidedeftextureoffsets = true;
|
||||||
|
|
||||||
|
// Enables support for 3D floors (not really, since support for 3D floors is pretty much hard-coded, but
|
||||||
|
// this tells plugins that the game supports 3D floors)
|
||||||
|
effect3dfloorsupport = true;
|
||||||
|
|
||||||
|
// Enables support for plane equation slopes
|
||||||
|
planeequationsupport = true;
|
||||||
|
|
||||||
// Default nodebuilder configurations
|
// Default nodebuilder configurations
|
||||||
defaultsavecompiler = "zdbsp_udmf_normal";
|
defaultsavecompiler = "zdbsp_udmf_normal";
|
||||||
defaulttestcompiler = "zdbsp_udmf_fast";
|
defaulttestcompiler = "zdbsp_udmf_fast";
|
||||||
|
|
|
@ -21,6 +21,8 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
using CodeImp.DoomBuilder.Map;
|
using CodeImp.DoomBuilder.Map;
|
||||||
using CodeImp.DoomBuilder.Editing;
|
using CodeImp.DoomBuilder.Editing;
|
||||||
|
@ -92,6 +94,8 @@ namespace CodeImp.DoomBuilder.Config
|
||||||
private readonly string thingclasshelp; //mxd
|
private readonly string thingclasshelp; //mxd
|
||||||
private readonly bool sidedefcompressionignoresaction; //mxd
|
private readonly bool sidedefcompressionignoresaction; //mxd
|
||||||
private readonly bool localsidedeftextureoffsets; //MaxW
|
private readonly bool localsidedeftextureoffsets; //MaxW
|
||||||
|
private readonly bool effect3dfloorsupport;
|
||||||
|
private readonly bool planeequationsupport;
|
||||||
|
|
||||||
// Skills
|
// Skills
|
||||||
private readonly List<SkillInfo> skills;
|
private readonly List<SkillInfo> skills;
|
||||||
|
@ -243,6 +247,8 @@ namespace CodeImp.DoomBuilder.Config
|
||||||
public bool DOOM { get { return doommapformat; } }
|
public bool DOOM { get { return doommapformat; } }
|
||||||
|
|
||||||
public bool UseLocalSidedefTextureOffsets { get { return localsidedeftextureoffsets; } } //MaxW
|
public bool UseLocalSidedefTextureOffsets { get { return localsidedeftextureoffsets; } } //MaxW
|
||||||
|
public bool Effect3DFloorSupport { get { return effect3dfloorsupport; } }
|
||||||
|
public bool PlaneEquationSupport { get { return planeequationsupport; } }
|
||||||
|
|
||||||
// Texture/flat/voxel sources
|
// Texture/flat/voxel sources
|
||||||
public IDictionary TextureRanges { get { return textureranges; } }
|
public IDictionary TextureRanges { get { return textureranges; } }
|
||||||
|
@ -409,7 +415,9 @@ namespace CodeImp.DoomBuilder.Config
|
||||||
sidedefcompressionignoresaction = cfg.ReadSetting("sidedefcompressionignoresaction", false); //mxd
|
sidedefcompressionignoresaction = cfg.ReadSetting("sidedefcompressionignoresaction", false); //mxd
|
||||||
defaultlinedefactivation = cfg.ReadSetting("defaultlinedefactivation", ""); //mxd
|
defaultlinedefactivation = cfg.ReadSetting("defaultlinedefactivation", ""); //mxd
|
||||||
localsidedeftextureoffsets = (cfg.ReadSetting("localsidedeftextureoffsets", false)); //MaxW
|
localsidedeftextureoffsets = (cfg.ReadSetting("localsidedeftextureoffsets", false)); //MaxW
|
||||||
for(int i = 0; i < Linedef.NUM_ARGS; i++) makedoorargs[i] = cfg.ReadSetting("makedoorarg" + i.ToString(CultureInfo.InvariantCulture), 0);
|
effect3dfloorsupport = cfg.ReadSetting("effect3dfloorsupport", false);
|
||||||
|
planeequationsupport = cfg.ReadSetting("planeequationsupport", false);
|
||||||
|
for (int i = 0; i < Linedef.NUM_ARGS; i++) makedoorargs[i] = cfg.ReadSetting("makedoorarg" + i.ToString(CultureInfo.InvariantCulture), 0);
|
||||||
|
|
||||||
//mxd. Update map format flags
|
//mxd. Update map format flags
|
||||||
universalmapformat = (formatinterface == "UniversalMapSetIO");
|
universalmapformat = (formatinterface == "UniversalMapSetIO");
|
||||||
|
@ -1236,6 +1244,37 @@ namespace CodeImp.DoomBuilder.Config
|
||||||
return maplumps.Values.Count(o => o.ScriptBuild || o.Script != null) > 0;
|
return maplumps.Values.Count(o => o.ScriptBuild || o.Script != null) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if this game configuration supports the requested map feature(s)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="features">Array of strings of property names of the GameConfiguration class</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool SupportsMapFeatures(string[] features, [CallerMemberName] string callername = "")
|
||||||
|
{
|
||||||
|
bool supported = true;
|
||||||
|
|
||||||
|
foreach (string rmf in features)
|
||||||
|
{
|
||||||
|
PropertyInfo pi = GetType().GetProperty(rmf);
|
||||||
|
|
||||||
|
if (pi == null)
|
||||||
|
{
|
||||||
|
General.ErrorLogger.Add(ErrorType.Error, "Check for supported map features (" + string.Join(", ", features) + ") was requested my " + callername + ", but property \"" + rmf + "\" does not exist.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
object value = pi.GetValue(this);
|
||||||
|
|
||||||
|
if (value is bool && (bool)value == false)
|
||||||
|
{
|
||||||
|
supported = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return supported;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
private bool usebydefault;
|
private bool usebydefault;
|
||||||
private bool safestartmode;
|
private bool safestartmode;
|
||||||
private string[] supportedmapformats; //mxd
|
private string[] supportedmapformats; //mxd
|
||||||
|
private string[] requiredmapfeatures;
|
||||||
private bool isdeprecated = false;
|
private bool isdeprecated = false;
|
||||||
private string deprecationmessage = string.Empty;
|
private string deprecationmessage = string.Empty;
|
||||||
|
|
||||||
|
@ -117,6 +118,11 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] SupportedMapFormats { get { return supportedmapformats; } set { supportedmapformats = value; } }
|
public string[] SupportedMapFormats { get { return supportedmapformats; } set { supportedmapformats = value; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of required map features to make the mode usable. Uses strings of GameConfiguration class properties
|
||||||
|
/// </summary>
|
||||||
|
public string[] RequiredMapFeatures { get { return requiredmapfeatures; } set { requiredmapfeatures = value; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When set to true the DeprecationMessage will be shown as a warning in the errors and warnings dialog
|
/// When set to true the DeprecationMessage will be shown as a warning in the errors and warnings dialog
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -248,9 +248,10 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
{
|
{
|
||||||
foreach(EditModeInfo emi in allmodes)
|
foreach(EditModeInfo emi in allmodes)
|
||||||
{
|
{
|
||||||
// Include the mode if it supports current map format (mxd)
|
// Include the mode if it supports current map format (mxd) and map features
|
||||||
// Also include the mode when it is listed and enabled or when it's not optional
|
// Also include the mode when it is listed and enabled or when it's not optional
|
||||||
if( (emi.Attributes.SupportedMapFormats == null || Array.IndexOf(emi.Attributes.SupportedMapFormats, General.Map.Config.FormatInterface) != -1) &&
|
if( (emi.Attributes.SupportedMapFormats == null || Array.IndexOf(emi.Attributes.SupportedMapFormats, General.Map.Config.FormatInterface) != -1) &&
|
||||||
|
(emi.Attributes.RequiredMapFeatures == null || General.Map.Config.SupportsMapFeatures(emi.Attributes.RequiredMapFeatures)) &&
|
||||||
((General.Map.ConfigSettings.EditModes.ContainsKey(emi.Type.FullName) &&
|
((General.Map.ConfigSettings.EditModes.ContainsKey(emi.Type.FullName) &&
|
||||||
General.Map.ConfigSettings.EditModes[emi.Type.FullName] )
|
General.Map.ConfigSettings.EditModes[emi.Type.FullName] )
|
||||||
|| !emi.IsOptional) )
|
|| !emi.IsOptional) )
|
||||||
|
|
|
@ -20,6 +20,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using CodeImp.DoomBuilder.Config;
|
using CodeImp.DoomBuilder.Config;
|
||||||
using CodeImp.DoomBuilder.Data;
|
using CodeImp.DoomBuilder.Data;
|
||||||
|
@ -196,13 +197,22 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
EditModeInfo emi = (lvi.Tag as EditModeInfo);
|
EditModeInfo emi = (lvi.Tag as EditModeInfo);
|
||||||
|
|
||||||
//mxd. Disable item if the mode does not support current map format
|
//mxd. Disable item if the mode does not support current map format
|
||||||
if(emi.Attributes.SupportedMapFormats != null &&
|
if (emi.Attributes.SupportedMapFormats != null &&
|
||||||
Array.IndexOf(emi.Attributes.SupportedMapFormats, gameconfig.FormatInterface) == -1)
|
Array.IndexOf(emi.Attributes.SupportedMapFormats, gameconfig.FormatInterface) == -1)
|
||||||
{
|
{
|
||||||
lvi.Text = emi.Attributes.DisplayName + " (map format not supported" + (emi.Attributes.IsDeprecated ? ", deprecated" : "") + ")";
|
lvi.Text = emi.Attributes.DisplayName + " (map format not supported" + (emi.Attributes.IsDeprecated ? ", deprecated" : "") + ")";
|
||||||
lvi.ForeColor = SystemColors.GrayText;
|
lvi.ForeColor = SystemColors.GrayText;
|
||||||
lvi.BackColor = SystemColors.InactiveBorder;
|
lvi.BackColor = SystemColors.InactiveBorder;
|
||||||
lvi.Checked = false;
|
lvi.Checked = false;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (emi.Attributes.RequiredMapFeatures != null && !gameconfig.SupportsMapFeatures(emi.Attributes.RequiredMapFeatures))
|
||||||
|
{
|
||||||
|
lvi.Text = emi.Attributes.DisplayName + " (map feature not supported)";
|
||||||
|
lvi.ForeColor = SystemColors.GrayText;
|
||||||
|
lvi.BackColor = SystemColors.InactiveBorder;
|
||||||
|
lvi.Checked = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
||||||
ButtonGroup = "000_editing",
|
ButtonGroup = "000_editing",
|
||||||
AllowCopyPaste = false,
|
AllowCopyPaste = false,
|
||||||
SupportedMapFormats = new[] { "UniversalMapSetIO" },
|
SupportedMapFormats = new[] { "UniversalMapSetIO" },
|
||||||
|
RequiredMapFeatures = new[] { "PlaneEquationSupport" },
|
||||||
Volatile = true,
|
Volatile = true,
|
||||||
UseByDefault = true,
|
UseByDefault = true,
|
||||||
Optional = false,
|
Optional = false,
|
||||||
|
|
|
@ -62,6 +62,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
||||||
ButtonOrder = int.MinValue + 501, // Position of the button (lower is more to the left)
|
ButtonOrder = int.MinValue + 501, // Position of the button (lower is more to the left)
|
||||||
ButtonGroup = "000_editing",
|
ButtonGroup = "000_editing",
|
||||||
SupportedMapFormats = new[] { "UniversalMapSetIO" },
|
SupportedMapFormats = new[] { "UniversalMapSetIO" },
|
||||||
|
RequiredMapFeatures = new[] { "PlaneEquationSupport" },
|
||||||
UseByDefault = true,
|
UseByDefault = true,
|
||||||
SafeStartMode = true,
|
SafeStartMode = true,
|
||||||
IsDeprecated = true,
|
IsDeprecated = true,
|
||||||
|
|
|
@ -53,6 +53,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
||||||
ButtonOrder = int.MinValue + 501, // Position of the button (lower is more to the left)
|
ButtonOrder = int.MinValue + 501, // Position of the button (lower is more to the left)
|
||||||
ButtonGroup = "000_editing",
|
ButtonGroup = "000_editing",
|
||||||
SupportedMapFormats = new[] { "HexenMapSetIO", "UniversalMapSetIO" },
|
SupportedMapFormats = new[] { "HexenMapSetIO", "UniversalMapSetIO" },
|
||||||
|
RequiredMapFeatures = new[] { "Effect3DFloorSupport" },
|
||||||
UseByDefault = true,
|
UseByDefault = true,
|
||||||
SafeStartMode = false,
|
SafeStartMode = false,
|
||||||
Volatile = false)]
|
Volatile = false)]
|
||||||
|
|
Loading…
Reference in a new issue