mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-19 06:51:09 +00:00
Improve game detection in "Open Map" modal dialog (#595)
This commit is contained in:
parent
166e3281d2
commit
73b7eac30c
10 changed files with 43 additions and 1 deletions
|
@ -32,6 +32,9 @@ include("Includes\\Boom_common.cfg", "mapformat_doom");
|
|||
// Settings common to Doom games
|
||||
include("Includes\\Game_Doom.cfg");
|
||||
|
||||
// Map name format for Doom 2.
|
||||
mapnameformat = "MAPxy";
|
||||
|
||||
//mxd. No DECORATE support in vanilla
|
||||
decorategames = "";
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ include("Includes\\Boom_common.cfg", "mapformat_doom");
|
|||
// Settings common to Doom games
|
||||
include("Includes\\Game_Doom.cfg");
|
||||
|
||||
// Map name format for Doom.
|
||||
mapnameformat = "ExMy";
|
||||
|
||||
//mxd. No DECORATE support in vanilla
|
||||
decorategames = "";
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ include("Includes\\Doom_common.cfg", "mapformat_doom");
|
|||
// Settings common to Doom games
|
||||
include("Includes\\Game_Doom.cfg");
|
||||
|
||||
// Map name format for Doom 2.
|
||||
mapnameformat = "MAPxy";
|
||||
|
||||
//mxd. No DECORATE support in vanilla
|
||||
decorategames = "";
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ include("Includes\\Doom_common.cfg", "mapformat_doom");
|
|||
// Settings common to Doom games
|
||||
include("Includes\\Game_Doom.cfg");
|
||||
|
||||
// Map name format for Doom.
|
||||
mapnameformat = "ExMy";
|
||||
|
||||
//mxd. No DECORATE support in vanilla
|
||||
decorategames = "";
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ include("Includes\\Heretic_common.cfg", "mapformat_doom");
|
|||
// Settings common to Doom games
|
||||
include("Includes\\Game_Heretic.cfg");
|
||||
|
||||
// Map name format for Heretic.
|
||||
mapnameformat = "ExMy";
|
||||
|
||||
//mxd. No DECORATE support in vanilla
|
||||
decorategames = "";
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ include("Includes\\Hexen_common.cfg", "mapformat_hexen");
|
|||
// Settings common to Hexen games
|
||||
include("Includes\\Game_Hexen.cfg");
|
||||
|
||||
// Map name format for Hexen.
|
||||
mapnameformat = "MAPxy";
|
||||
|
||||
//mxd. No DECORATE support in vanilla
|
||||
decorategames = "";
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ include("Includes\\MBF21_common.cfg", "mapformat_doom");
|
|||
// Settings common to Doom games
|
||||
include("Includes\\Game_Doom.cfg");
|
||||
|
||||
// Map name format for Doom 2.
|
||||
mapnameformat = "MAPxy";
|
||||
|
||||
//mxd. No DECORATE support in vanilla
|
||||
decorategames = "";
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ include("Includes\\Strife_common.cfg", "mapformat_doom");
|
|||
// Settings common to Strife games
|
||||
include("Includes\\Game_Strife.cfg");
|
||||
|
||||
// Map name format for Strife.
|
||||
mapnameformat = "MAPxy";
|
||||
|
||||
//mxd. No DECORATE support in vanilla
|
||||
decorategames = "";
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ namespace CodeImp.DoomBuilder
|
|||
internal const string TEMP_MAP_HEADER = "TEMPMAP";
|
||||
internal const string BUILD_MAP_HEADER = "MAP01";
|
||||
public const string CONFIG_MAP_HEADER = "~MAP";
|
||||
public const string CONFIG_MAP_NAME_FORMAT_EPISODE = "ExMy";
|
||||
public const string CONFIG_MAP_NAME_FORMAT_NO_EPISODE = "MAPxy";
|
||||
private const int REPLACE_TARGET_MAP = -1; //mxd
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -23,6 +23,7 @@ using CodeImp.DoomBuilder.IO;
|
|||
using CodeImp.DoomBuilder.Map;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
|
||||
|
@ -38,7 +39,9 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private WAD wadfile;
|
||||
private readonly string filepathname;
|
||||
private string selectedmapname;
|
||||
|
||||
private static readonly Regex episodemapregex = new Regex("^E[1-9]M[1-9]$");
|
||||
private static readonly Regex noepisodemapregex = new Regex("^MAP[0-9][0-9]$");
|
||||
|
||||
// Properties
|
||||
//public string FilePathName { get { return filepathname; } }
|
||||
public MapOptions Options { get { return options; } }
|
||||
|
@ -237,6 +240,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// by checking if the specific lumps are detected
|
||||
private static bool MatchConfiguration(Configuration cfg, WAD wadfile)
|
||||
{
|
||||
string mapnameformat = cfg.ReadSetting("mapnameformat", "");
|
||||
int lumpsrequired = 0;
|
||||
|
||||
// Get the map lump names
|
||||
|
@ -257,6 +261,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Go for all the lumps in the wad
|
||||
for(int scanindex = 0; scanindex < (wadfile.Lumps.Count - 1); scanindex++)
|
||||
{
|
||||
if(MapNameFormatMismatch(mapnameformat, wadfile.Lumps[scanindex].Name)) return false;
|
||||
|
||||
// Make sure this lump is not part of the map.
|
||||
if(!maplumpnames.Contains(wadfile.Lumps[scanindex].Name))
|
||||
{
|
||||
|
@ -292,6 +298,16 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
return false;
|
||||
}
|
||||
|
||||
// Determine if the given map lump name is not accepted by the given game configuration setting.
|
||||
private static bool MapNameFormatMismatch(string mapnameformat, string lumpname)
|
||||
{
|
||||
return (
|
||||
mapnameformat == MapManager.CONFIG_MAP_NAME_FORMAT_NO_EPISODE && episodemapregex.IsMatch(lumpname)
|
||||
) || (
|
||||
mapnameformat == MapManager.CONFIG_MAP_NAME_FORMAT_EPISODE && noepisodemapregex.IsMatch(lumpname)
|
||||
);
|
||||
}
|
||||
|
||||
// Configuration is selected
|
||||
private void config_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue