mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +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
|
||||
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
|
||||
include("ZDoom_misc.cfg", "speciallinedefs_doomhexen");
|
||||
|
||||
|
@ -347,6 +351,13 @@ mapformat_udmf
|
|||
// Enables support for individual offsets of upper/middle/lower sidedef textures
|
||||
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
|
||||
defaultsavecompiler = "zdbsp_udmf_normal";
|
||||
defaulttestcompiler = "zdbsp_udmf_fast";
|
||||
|
|
|
@ -21,6 +21,8 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
|
@ -92,6 +94,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private readonly string thingclasshelp; //mxd
|
||||
private readonly bool sidedefcompressionignoresaction; //mxd
|
||||
private readonly bool localsidedeftextureoffsets; //MaxW
|
||||
private readonly bool effect3dfloorsupport;
|
||||
private readonly bool planeequationsupport;
|
||||
|
||||
// Skills
|
||||
private readonly List<SkillInfo> skills;
|
||||
|
@ -243,6 +247,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public bool DOOM { get { return doommapformat; } }
|
||||
|
||||
public bool UseLocalSidedefTextureOffsets { get { return localsidedeftextureoffsets; } } //MaxW
|
||||
public bool Effect3DFloorSupport { get { return effect3dfloorsupport; } }
|
||||
public bool PlaneEquationSupport { get { return planeequationsupport; } }
|
||||
|
||||
// Texture/flat/voxel sources
|
||||
public IDictionary TextureRanges { get { return textureranges; } }
|
||||
|
@ -409,7 +415,9 @@ namespace CodeImp.DoomBuilder.Config
|
|||
sidedefcompressionignoresaction = cfg.ReadSetting("sidedefcompressionignoresaction", false); //mxd
|
||||
defaultlinedefactivation = cfg.ReadSetting("defaultlinedefactivation", ""); //mxd
|
||||
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
|
||||
universalmapformat = (formatinterface == "UniversalMapSetIO");
|
||||
|
@ -1236,6 +1244,37 @@ namespace CodeImp.DoomBuilder.Config
|
|||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
private bool usebydefault;
|
||||
private bool safestartmode;
|
||||
private string[] supportedmapformats; //mxd
|
||||
private string[] requiredmapfeatures;
|
||||
private bool isdeprecated = false;
|
||||
private string deprecationmessage = string.Empty;
|
||||
|
||||
|
@ -117,6 +118,11 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
/// </summary>
|
||||
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>
|
||||
/// When set to true the DeprecationMessage will be shown as a warning in the errors and warnings dialog
|
||||
/// </summary>
|
||||
|
|
|
@ -248,9 +248,10 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
{
|
||||
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
|
||||
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[emi.Type.FullName] )
|
||||
|| !emi.IsOptional) )
|
||||
|
|
|
@ -20,6 +20,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
|
@ -196,13 +197,22 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
EditModeInfo emi = (lvi.Tag as EditModeInfo);
|
||||
|
||||
//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)
|
||||
{
|
||||
lvi.Text = emi.Attributes.DisplayName + " (map format not supported" + (emi.Attributes.IsDeprecated ? ", deprecated" : "") + ")";
|
||||
lvi.ForeColor = SystemColors.GrayText;
|
||||
lvi.BackColor = SystemColors.InactiveBorder;
|
||||
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
|
||||
{
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
ButtonGroup = "000_editing",
|
||||
AllowCopyPaste = false,
|
||||
SupportedMapFormats = new[] { "UniversalMapSetIO" },
|
||||
RequiredMapFeatures = new[] { "PlaneEquationSupport" },
|
||||
Volatile = true,
|
||||
UseByDefault = true,
|
||||
Optional = false,
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
|
|||
ButtonOrder = int.MinValue + 501, // Position of the button (lower is more to the left)
|
||||
ButtonGroup = "000_editing",
|
||||
SupportedMapFormats = new[] { "UniversalMapSetIO" },
|
||||
RequiredMapFeatures = new[] { "PlaneEquationSupport" },
|
||||
UseByDefault = true,
|
||||
SafeStartMode = 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)
|
||||
ButtonGroup = "000_editing",
|
||||
SupportedMapFormats = new[] { "HexenMapSetIO", "UniversalMapSetIO" },
|
||||
RequiredMapFeatures = new[] { "Effect3DFloorSupport" },
|
||||
UseByDefault = true,
|
||||
SafeStartMode = false,
|
||||
Volatile = false)]
|
||||
|
|
Loading…
Reference in a new issue