mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
Fixed, Map Analysis mode, "Check stuck things" check: rewritten parts of the flags checking logic to allow more accurate flag checks.
Fixed, Map Analysis mode: fixed a crash when trying to dissolve an invalid sector when one of it's linedefs referenced it on the both sides. Fixed, Sectors mode: fixed incorrect undo description when deleting sectors. Internal: joined declaration and assignment of some more variables.
This commit is contained in:
parent
f6f277065f
commit
3a35b7603a
256 changed files with 2544 additions and 2716 deletions
|
@ -46,21 +46,29 @@ thingflagscompare
|
|||
{
|
||||
16
|
||||
{
|
||||
ignoredgroup = "skills";
|
||||
comparemethod = "equal";
|
||||
ignoredgroups = "skills";
|
||||
ingnorethisgroupwhenunset = true;
|
||||
}
|
||||
}
|
||||
|
||||
gamemodes_extra
|
||||
{
|
||||
optional = true;
|
||||
|
||||
32
|
||||
{
|
||||
invert = true;
|
||||
requiredflag = "16";
|
||||
requiredgroups = "gamemodes";
|
||||
ignoredgroups = "skills";
|
||||
}
|
||||
|
||||
64
|
||||
{
|
||||
invert = true;
|
||||
requiredflag = "16";
|
||||
requiredgroup = "skills";
|
||||
requiredgroups = "skills,gamemodes";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ thingflagscompare
|
|||
16
|
||||
{
|
||||
comparemethod = "equal";
|
||||
ignoredgroup = "skills";
|
||||
ignoredgroups = "skills";
|
||||
ingnorethisgroupwhenunset = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,9 +56,9 @@ thingflagscompare
|
|||
|
||||
gamemodes
|
||||
{
|
||||
256 { requiredgroup = "skills"; }
|
||||
512 { requiredgroup = "skills"; }
|
||||
1024 { ignoredgroup = "skills"; }
|
||||
256 { requiredgroups = "skills"; }
|
||||
512 { requiredgroups = "skills"; }
|
||||
1024 { ignoredgroups = "skills"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,18 +57,9 @@ thingflagscompare
|
|||
|
||||
gamemodes
|
||||
{
|
||||
single
|
||||
{
|
||||
requiredgroup = "skills";
|
||||
}
|
||||
coop
|
||||
{
|
||||
requiredgroup = "skills";
|
||||
}
|
||||
dm
|
||||
{
|
||||
ignoredgroup = "skills";
|
||||
}
|
||||
single { requiredgroups = "skills"; }
|
||||
coop { requiredgroups = "skills"; }
|
||||
dm { ignoredgroups = "skills"; }
|
||||
}
|
||||
|
||||
classes
|
||||
|
@ -76,6 +67,8 @@ thingflagscompare
|
|||
class1;
|
||||
class2;
|
||||
class3;
|
||||
class4;
|
||||
class5;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,12 +53,11 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
string[] resnames = asm.GetManifestResourceNames();
|
||||
string asmname = asm.GetName().Name.ToLowerInvariant() + "_";
|
||||
|
||||
foreach (string rn in resnames)
|
||||
foreach(string rn in resnames)
|
||||
{
|
||||
// Found one?
|
||||
if(rn.EndsWith(HINTS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
string line;
|
||||
string classname = string.Empty;
|
||||
string groupname = string.Empty;
|
||||
List<string> lines = new List<string>(2);
|
||||
|
@ -68,7 +67,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
{
|
||||
using(StreamReader reader = new StreamReader(data, Encoding.ASCII))
|
||||
{
|
||||
while (!reader.EndOfStream) lines.Add(reader.ReadLine());
|
||||
while(!reader.EndOfStream) lines.Add(reader.ReadLine());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +75,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
|
||||
foreach(string s in lines)
|
||||
{
|
||||
line = s.Trim();
|
||||
string line = s.Trim();
|
||||
if(string.IsNullOrEmpty(line) || line.StartsWith("//"))
|
||||
continue;
|
||||
|
||||
|
@ -139,7 +138,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
{
|
||||
string fullname = type.Assembly.GetName().Name.ToLowerInvariant() + "_" + type.Name;
|
||||
|
||||
if (!hints.ContainsKey(fullname) || !hints[fullname].ContainsKey(groupname))
|
||||
if(!hints.ContainsKey(fullname) || !hints[fullname].ContainsKey(groupname))
|
||||
{
|
||||
General.Interface.ShowHints(DEFAULT_HINT);
|
||||
#if DEBUG
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Console.WriteLine("MouseInput process failed: " + e.Message);
|
||||
Console.WriteLine("MouseInput process failed: " + e.Message);
|
||||
}
|
||||
return new Vector2D();
|
||||
}
|
||||
|
|
|
@ -69,10 +69,10 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
// Determine enum type
|
||||
IDictionary argdic = cfg.ReadSetting(argspath + ".arg" + istr, new Hashtable());
|
||||
if (argdic.Contains("enum"))
|
||||
if(argdic.Contains("enum"))
|
||||
{
|
||||
// Enum fully specified?
|
||||
if (argdic["enum"] is IDictionary)
|
||||
if(argdic["enum"] is IDictionary)
|
||||
{
|
||||
// Create anonymous enum
|
||||
this.enumlist = new EnumList(argdic["enum"] as IDictionary);
|
||||
|
@ -80,7 +80,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
else
|
||||
{
|
||||
// Check if referenced enum exists
|
||||
if ((argdic["enum"].ToString().Length > 0) && enums.ContainsKey(argdic["enum"].ToString()))
|
||||
if((argdic["enum"].ToString().Length > 0) && enums.ContainsKey(argdic["enum"].ToString()))
|
||||
{
|
||||
// Get the enum list
|
||||
this.enumlist = enums[argdic["enum"].ToString()];
|
||||
|
@ -92,7 +92,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
}
|
||||
}
|
||||
|
||||
if (this.enumlist == null) this.enumlist = new EnumList(); //mxd
|
||||
if(this.enumlist == null) this.enumlist = new EnumList(); //mxd
|
||||
}
|
||||
|
||||
//mxd. Constructor for an argument info defined in DECORATE
|
||||
|
|
|
@ -306,14 +306,12 @@ namespace CodeImp.DoomBuilder.Config
|
|||
//mxd
|
||||
private void SaveTestEngines()
|
||||
{
|
||||
IDictionary rlinfo;
|
||||
|
||||
// Fill structure
|
||||
IDictionary resinfo = new ListDictionary();
|
||||
|
||||
for(int i = 0; i < testEngines.Count; i++)
|
||||
{
|
||||
rlinfo = new ListDictionary();
|
||||
IDictionary rlinfo = new ListDictionary();
|
||||
rlinfo.Add("testprogramname", testEngines[i].TestProgramName);
|
||||
rlinfo.Add("testprogram", testEngines[i].TestProgram);
|
||||
rlinfo.Add("testparameters", testEngines[i].TestParameters);
|
||||
|
@ -332,14 +330,12 @@ namespace CodeImp.DoomBuilder.Config
|
|||
//mxd
|
||||
private void SaveLinedefColorPresets()
|
||||
{
|
||||
IDictionary rlinfo;
|
||||
|
||||
// Fill structure
|
||||
IDictionary resinfo = new ListDictionary();
|
||||
|
||||
for(int i = 0; i < linedefColorPresets.Length; i++)
|
||||
{
|
||||
rlinfo = new ListDictionary();
|
||||
IDictionary rlinfo = new ListDictionary();
|
||||
rlinfo.Add("name", linedefColorPresets[i].Name);
|
||||
rlinfo.Add("enabled", linedefColorPresets[i].Enabled);
|
||||
rlinfo.Add("color", linedefColorPresets[i].Color.ToInt());
|
||||
|
@ -378,7 +374,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
//mxd
|
||||
ci.testEngines = new List<EngineInfo>();
|
||||
foreach (EngineInfo info in testEngines) ci.testEngines.Add(new EngineInfo(info));
|
||||
foreach(EngineInfo info in testEngines) ci.testEngines.Add(new EngineInfo(info));
|
||||
ci.currentEngineIndex = this.currentEngineIndex;
|
||||
ci.linedefColorPresets = new LinedefColorPreset[linedefColorPresets.Length];
|
||||
for(int i = 0; i < linedefColorPresets.Length; i++)
|
||||
|
@ -411,7 +407,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
//mxd
|
||||
this.testEngines = new List<EngineInfo>();
|
||||
foreach (EngineInfo info in ci.testEngines) testEngines.Add(new EngineInfo(info));
|
||||
foreach(EngineInfo info in ci.testEngines) testEngines.Add(new EngineInfo(info));
|
||||
if(this.currentEngineIndex >= testEngines.Count) this.currentEngineIndex = Math.Max(0, testEngines.Count - 1);
|
||||
this.linedefColorPresets = new LinedefColorPreset[ci.linedefColorPresets.Length];
|
||||
for(int i = 0; i < ci.linedefColorPresets.Length; i++)
|
||||
|
|
|
@ -94,9 +94,9 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private readonly Dictionary<string, MapLumpInfo> maplumps;
|
||||
|
||||
//mxd. Map format
|
||||
private bool doommapformat;
|
||||
private bool hexenmapformat;
|
||||
private bool universalmapformat;
|
||||
private readonly bool doommapformat;
|
||||
private readonly bool hexenmapformat;
|
||||
private readonly bool universalmapformat;
|
||||
|
||||
// Texture/flat/voxel sources
|
||||
private readonly IDictionary textureranges;
|
||||
|
@ -112,7 +112,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private readonly List<ThingCategory> thingcategories;
|
||||
private readonly Dictionary<int, ThingTypeInfo> things;
|
||||
private readonly List<FlagTranslation> thingflagstranslation;
|
||||
private readonly Dictionary<string, Dictionary<string, ThingFlagsCompare>> thingflagscompare; //mxd
|
||||
private readonly Dictionary<string, ThingFlagsCompareGroup> thingflagscompare; //mxd
|
||||
private readonly Dictionary<string, string> thingrenderstyles; //mxd
|
||||
|
||||
// Linedefs
|
||||
|
@ -226,7 +226,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public ICollection<string> DefaultThingFlags { get { return defaultthingflags; } }
|
||||
public IDictionary<string, string> ThingFlags { get { return thingflags; } }
|
||||
public List<FlagTranslation> ThingFlagsTranslation { get { return thingflagstranslation; } }
|
||||
public Dictionary<string, Dictionary<string, ThingFlagsCompare>> ThingFlagsCompare { get { return thingflagscompare; } } //mxd
|
||||
public Dictionary<string, ThingFlagsCompareGroup> ThingFlagsCompare { get { return thingflagscompare; } } //mxd
|
||||
public Dictionary<string, string> ThingRenderStyles { get { return thingrenderstyles; } } //mxd
|
||||
|
||||
// Linedefs
|
||||
|
@ -301,7 +301,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.thingflagstranslation = new List<FlagTranslation>();
|
||||
this.linedefflagstranslation = new List<FlagTranslation>();
|
||||
this.thingfilters = new List<ThingsFilter>();
|
||||
this.thingflagscompare = new Dictionary<string, Dictionary<string, ThingFlagsCompare>>(); //mxd
|
||||
this.thingflagscompare = new Dictionary<string, ThingFlagsCompareGroup>(); //mxd
|
||||
this.brightnesslevels = new StepsList();
|
||||
this.makedoorflags = new Dictionary<string, bool>(StringComparer.Ordinal);
|
||||
this.linedefrenderstyles = new Dictionary<string, string>(StringComparer.Ordinal); //mxd
|
||||
|
@ -470,7 +470,6 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private List<UniversalFieldInfo> LoadUniversalFields(string elementname)
|
||||
{
|
||||
List<UniversalFieldInfo> list = new List<UniversalFieldInfo>();
|
||||
UniversalFieldInfo uf;
|
||||
|
||||
// Get fields
|
||||
IDictionary dic = cfg.ReadSetting("universalfields." + elementname, new Hashtable());
|
||||
|
@ -479,7 +478,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
try
|
||||
{
|
||||
// Read the field info and add to list
|
||||
uf = new UniversalFieldInfo(elementname, de.Key.ToString(), cfg, enums);
|
||||
UniversalFieldInfo uf = new UniversalFieldInfo(elementname, de.Key.ToString(), cfg, enums);
|
||||
list.Add(uf);
|
||||
}
|
||||
catch(Exception)
|
||||
|
@ -495,8 +494,6 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Things and thing categories
|
||||
private void LoadThingCategories()
|
||||
{
|
||||
ThingCategory thingcat;
|
||||
|
||||
// Get thing categories
|
||||
IDictionary dic = cfg.ReadSetting("thingtypes", new Hashtable());
|
||||
foreach(DictionaryEntry de in dic)
|
||||
|
@ -504,7 +501,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
if(de.Value is IDictionary)
|
||||
{
|
||||
// Make a category
|
||||
thingcat = new ThingCategory(cfg, null, de.Key.ToString(), enums);
|
||||
ThingCategory thingcat = new ThingCategory(cfg, null, de.Key.ToString(), enums);
|
||||
|
||||
//mxd. Otherwise nesting problems might occure
|
||||
if(thingcat.IsValid)
|
||||
|
@ -576,10 +573,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private void LoadLinedefActions()
|
||||
{
|
||||
Dictionary<string, LinedefActionCategory> cats = new Dictionary<string, LinedefActionCategory>(StringComparer.Ordinal);
|
||||
LinedefActionInfo ai;
|
||||
LinedefActionCategory ac;
|
||||
int actionnumber;
|
||||
|
||||
|
||||
// Get linedef categories
|
||||
IDictionary dic = cfg.ReadSetting("linedeftypes", new Hashtable());
|
||||
foreach(DictionaryEntry cde in dic)
|
||||
|
@ -590,6 +584,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
string cattitle = cfg.ReadSetting("linedeftypes." + cde.Key + ".title", "");
|
||||
|
||||
// Make or get category
|
||||
LinedefActionCategory ac;
|
||||
if(cats.ContainsKey(cde.Key.ToString()))
|
||||
ac = cats[cde.Key.ToString()];
|
||||
else
|
||||
|
@ -603,6 +598,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
foreach(DictionaryEntry de in catdic)
|
||||
{
|
||||
// Check if the item key is numeric
|
||||
int actionnumber;
|
||||
if(int.TryParse(de.Key.ToString(),
|
||||
NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
|
||||
CultureInfo.InvariantCulture, out actionnumber))
|
||||
|
@ -611,7 +607,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
if(de.Value is IDictionary)
|
||||
{
|
||||
// Make the line type
|
||||
ai = new LinedefActionInfo(actionnumber, cfg, cde.Key.ToString(), enums);
|
||||
LinedefActionInfo ai = new LinedefActionInfo(actionnumber, cfg, cde.Key.ToString(), enums);
|
||||
|
||||
// Add action to category and sorted list
|
||||
sortedlinedefactions.Add(ai);
|
||||
|
@ -682,20 +678,18 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Sector effects
|
||||
private void LoadSectorEffects()
|
||||
{
|
||||
SectorEffectInfo si;
|
||||
int actionnumber;
|
||||
|
||||
// Get sector effects
|
||||
IDictionary dic = cfg.ReadSetting("sectortypes", new Hashtable());
|
||||
foreach(DictionaryEntry de in dic)
|
||||
{
|
||||
// Try paring the action number
|
||||
int actionnumber;
|
||||
if(int.TryParse(de.Key.ToString(),
|
||||
NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
|
||||
CultureInfo.InvariantCulture, out actionnumber))
|
||||
{
|
||||
// Make effects
|
||||
si = new SectorEffectInfo(actionnumber, de.Value.ToString(), true, false);
|
||||
SectorEffectInfo si = new SectorEffectInfo(actionnumber, de.Value.ToString(), true, false);
|
||||
|
||||
// Add action to category and sorted list
|
||||
sortedsectoreffects.Add(si);
|
||||
|
@ -714,13 +708,12 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Brightness levels
|
||||
private void LoadBrightnessLevels()
|
||||
{
|
||||
int level;
|
||||
|
||||
// Get brightness levels structure
|
||||
IDictionary dic = cfg.ReadSetting("sectorbrightness", new Hashtable());
|
||||
foreach(DictionaryEntry de in dic)
|
||||
{
|
||||
// Try paring the level
|
||||
int level;
|
||||
if(int.TryParse(de.Key.ToString(),
|
||||
NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
|
||||
CultureInfo.InvariantCulture, out level))
|
||||
|
@ -769,48 +762,51 @@ namespace CodeImp.DoomBuilder.Config
|
|||
thingflagstranslation.Add(new FlagTranslation(de));
|
||||
|
||||
// Get thing compare flag info (for the stuck thing error checker
|
||||
HashSet<string> flagscache = new HashSet<string>();
|
||||
dic = cfg.ReadSetting("thingflagscompare", new Hashtable());
|
||||
foreach(DictionaryEntry de in dic)
|
||||
foreach(DictionaryEntry de in dic)
|
||||
{
|
||||
IDictionary gdic = cfg.ReadSetting("thingflagscompare." + de.Key, new Hashtable());
|
||||
|
||||
foreach(DictionaryEntry gde in gdic)
|
||||
string group = de.Key.ToString(); //mxd
|
||||
thingflagscompare[group] = new ThingFlagsCompareGroup(cfg, group); //mxd
|
||||
foreach(string s in thingflagscompare[group].Flags.Keys)
|
||||
{
|
||||
string group = de.Key.ToString(); //mxd
|
||||
string flag = gde.Key.ToString(); //mxd
|
||||
|
||||
if(!thingflagscompare.ContainsKey(group)) //mxd
|
||||
thingflagscompare.Add(group, new Dictionary<string, ThingFlagsCompare>());
|
||||
|
||||
if(!thingflagscompare[group].ContainsKey(flag)) //mxd
|
||||
thingflagscompare[group].Add(flag, new ThingFlagsCompare(cfg, group, flag));
|
||||
if(flagscache.Contains(s))
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "ThingFlagsCompare flag '" + s + "' is double-defined in '" + group + "' group!");
|
||||
else
|
||||
flagscache.Add(s);
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Integrity check
|
||||
foreach (KeyValuePair<string, Dictionary<string, ThingFlagsCompare>> group in thingflagscompare)
|
||||
foreach(KeyValuePair<string, ThingFlagsCompareGroup> group in thingflagscompare)
|
||||
{
|
||||
foreach (KeyValuePair<string, ThingFlagsCompare> flaggrp in group.Value)
|
||||
foreach(ThingFlagsCompare flag in group.Value.Flags.Values)
|
||||
{
|
||||
// Required group is missing?
|
||||
if (!string.IsNullOrEmpty(flaggrp.Value.RequiredGroup) && !thingflagscompare.ContainsKey(flaggrp.Value.RequiredGroup))
|
||||
// Required groups are missing?
|
||||
foreach(string s in flag.RequiredGroups)
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "thingflagscompare group '" + flaggrp.Value.RequiredGroup + "', required by flag '" + flaggrp.Key + "' does not exist!");
|
||||
flaggrp.Value.RequiredGroup = string.Empty;
|
||||
if(!thingflagscompare.ContainsKey(s))
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "ThingFlagsCompare group '" + s + "', required by flag '" + flag.Flag + "' does not exist!");
|
||||
flag.RequiredGroups.Remove(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Ignored group is missing?
|
||||
if(!string.IsNullOrEmpty(flaggrp.Value.IgnoredGroup) && !thingflagscompare.ContainsKey(flaggrp.Value.IgnoredGroup))
|
||||
// Ignored groups are missing?
|
||||
foreach(string s in flag.IgnoredGroups)
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "thingflagscompare group '" + flaggrp.Value.IgnoredGroup + "', ignored by flag '" + flaggrp.Key + "' does not exist!");
|
||||
flaggrp.Value.IgnoredGroup = string.Empty;
|
||||
if(!thingflagscompare.ContainsKey(s))
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "ThingFlagsCompare group '" + s + "', ignored by flag '" + flag.Flag + "' does not exist!");
|
||||
flag.IgnoredGroups.Remove(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Required flag is missing?
|
||||
if(!string.IsNullOrEmpty(flaggrp.Value.RequiredFlag) && !group.Value.ContainsKey(flaggrp.Value.RequiredFlag))
|
||||
if(!string.IsNullOrEmpty(flag.RequiredFlag) && !flagscache.Contains(flag.RequiredFlag) /*!group.Value.Flags.ContainsKey(flag.RequiredFlag)*/)
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "thingflagscompare flag '" + flaggrp.Value.RequiredFlag + "', required by flag '" + flaggrp.Key + "' does not exist!");
|
||||
flaggrp.Value.RequiredFlag = string.Empty;
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "ThingFlagsCompare flag '" + flag.RequiredFlag + "', required by flag '" + flag.Flag + "' does not exist!");
|
||||
flag.RequiredFlag = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -885,10 +881,10 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private void LoadMakeDoorFlags()
|
||||
{
|
||||
IDictionary dic = cfg.ReadSetting("makedoorflags", new Hashtable());
|
||||
foreach (DictionaryEntry de in dic)
|
||||
foreach(DictionaryEntry de in dic)
|
||||
{
|
||||
// Using minus will unset the flag
|
||||
if (de.Key.ToString()[0] == '-')
|
||||
if(de.Key.ToString()[0] == '-')
|
||||
{
|
||||
makedoorflags[de.Key.ToString().TrimStart('-')] = false;
|
||||
}
|
||||
|
@ -972,8 +968,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
//mxd
|
||||
public static bool IsGeneralizedSectorEffect(int effect, IEnumerable<GeneralizedOption> options)
|
||||
{
|
||||
if (effect == 0) return false;
|
||||
foreach (GeneralizedOption option in options)
|
||||
if(effect == 0) return false;
|
||||
foreach(GeneralizedOption option in options)
|
||||
{
|
||||
foreach(GeneralizedBit bit in option.Bits)
|
||||
{
|
||||
|
@ -987,7 +983,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
//mxd
|
||||
public string GetGeneralizedSectorEffectName(int effect)
|
||||
{
|
||||
if (effect == 0) return "None";
|
||||
if(effect == 0) return "None";
|
||||
string title = "Unknown";
|
||||
int matches = 0;
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Constructor
|
||||
internal GeneralizedOption(string structure, string cat, string name, IDictionary bitslist)
|
||||
{
|
||||
int index;
|
||||
string fullpath;
|
||||
|
||||
// Determine path
|
||||
|
@ -69,6 +68,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
foreach(DictionaryEntry de in bitslist)
|
||||
{
|
||||
// Check if the item key is numeric
|
||||
int index;
|
||||
if(int.TryParse(de.Key.ToString(), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.InvariantCulture, out index))
|
||||
{
|
||||
// Add to list
|
||||
|
|
|
@ -579,7 +579,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
//mxd. Set default arguments
|
||||
ThingTypeInfo tti = General.Map.Data.GetThingInfoEx(t.Type);
|
||||
if (tti != null)
|
||||
if(tti != null)
|
||||
{
|
||||
t.Args[0] = (int)tti.Args[0].DefaultValue;
|
||||
t.Args[1] = (int)tti.Args[1].DefaultValue;
|
||||
|
|
|
@ -201,24 +201,24 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
//mxd. Load Snippets
|
||||
string snippetsdir = cfg.ReadSetting("snippetsdir", "");
|
||||
if (!string.IsNullOrEmpty(snippetsdir))
|
||||
if(!string.IsNullOrEmpty(snippetsdir))
|
||||
{
|
||||
string snippetspath = Path.Combine(General.SnippetsPath, snippetsdir);
|
||||
if (Directory.Exists(snippetspath))
|
||||
if(Directory.Exists(snippetspath))
|
||||
{
|
||||
string[] files = Directory.GetFiles(snippetspath, "*.txt", SearchOption.TopDirectoryOnly);
|
||||
|
||||
foreach (string file in files)
|
||||
foreach(string file in files)
|
||||
{
|
||||
string name = Path.GetFileNameWithoutExtension(file);
|
||||
if (name.Contains(" "))
|
||||
if(name.Contains(" "))
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Failed to load snippet '" + file + "' for '" + description + "' script configuration: snippet file name must not contain spaces!");
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] lines = File.ReadAllLines(file);
|
||||
if (lines.Length > 0)
|
||||
if(lines.Length > 0)
|
||||
{
|
||||
snippets.Add(name, lines);
|
||||
}
|
||||
|
|
|
@ -150,8 +150,6 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Constructor
|
||||
internal ThingCategory(Configuration cfg, ThingCategory parent, string name, IDictionary<string, EnumList> enums)
|
||||
{
|
||||
int index;
|
||||
|
||||
// Initialize
|
||||
this.name = name;
|
||||
this.things = new List<ThingTypeInfo>();
|
||||
|
@ -225,6 +223,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
foreach(DictionaryEntry de in dic)
|
||||
{
|
||||
// Check if the item key is numeric
|
||||
int index;
|
||||
if(int.TryParse(de.Key.ToString(), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.InvariantCulture, out index))
|
||||
{
|
||||
// Check if the item value is a structure
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
|
@ -26,9 +26,114 @@ using CodeImp.DoomBuilder.Map;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Config
|
||||
{
|
||||
//mxd
|
||||
public class ThingFlagsCompareGroup
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly bool IsOptional; // When set to true, group flags won't be considered as required for a thing to show up ingame by CheckUnusedThings error check and ThingFlagsCompare.CheckThingEditFormFlags() method.
|
||||
public readonly Dictionary<string, ThingFlagsCompare> Flags;
|
||||
|
||||
public ThingFlagsCompareGroup(Configuration cfg, string name)
|
||||
{
|
||||
Name = name;
|
||||
Flags = new Dictionary<string, ThingFlagsCompare>();
|
||||
IsOptional = cfg.ReadSetting("thingflagscompare." + name + ".optional", false);
|
||||
|
||||
IDictionary dic = cfg.ReadSetting("thingflagscompare." + name, new Hashtable());
|
||||
foreach(DictionaryEntry de in dic)
|
||||
{
|
||||
if(de.Value != null && !(de.Value is IDictionary)) continue; // flag either has no value, or is defined as block
|
||||
string flag = de.Key.ToString();
|
||||
|
||||
// Duplicate flags check
|
||||
if(Flags.ContainsKey(flag))
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "ThingFlagsCompare flag '" + flag + "' is double-defined in '" + name + "' group");
|
||||
|
||||
Flags[flag] = new ThingFlagsCompare(cfg, name, flag);
|
||||
}
|
||||
}
|
||||
|
||||
// Compares flags group of the two things.
|
||||
public ThingFlagsCompareResult Compare(Thing t1, Thing t2)
|
||||
{
|
||||
ThingFlagsCompareResult result = new ThingFlagsCompareResult();
|
||||
foreach(ThingFlagsCompare tfc in Flags.Values)
|
||||
{
|
||||
// Current flag doesn't overlap when required flag does not overlap
|
||||
if(!string.IsNullOrEmpty(tfc.RequiredFlag) && !GetFlag(tfc.RequiredFlag).Compare(t1, t2))
|
||||
{
|
||||
result.Result = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Compare current flag
|
||||
bool flagoverlaps = tfc.Compare(t1, t2);
|
||||
|
||||
// Ignore this group when whole group doens't match or required flag is not set
|
||||
if(!flagoverlaps && tfc.IgnoreGroupWhenUnset) return new ThingFlagsCompareResult { Result = 0 };
|
||||
|
||||
// If current flag overlaps, check IgnoredGroup and RequiredGroup settings
|
||||
if(flagoverlaps)
|
||||
{
|
||||
result.Result = 1;
|
||||
|
||||
foreach(string s in tfc.IgnoredGroups)
|
||||
{
|
||||
if(!result.IgnoredGroups.Contains(s)) result.IgnoredGroups.Add(s);
|
||||
}
|
||||
|
||||
if(tfc.RequiredGroups.Count > 0)
|
||||
{
|
||||
foreach(string s in tfc.RequiredGroups)
|
||||
{
|
||||
if(result.IgnoredGroups.Contains(s)) result.IgnoredGroups.Remove(s);
|
||||
if(!result.RequiredGroups.Contains(s)) result.RequiredGroups.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ThingFlagsCompare GetFlag(string flag)
|
||||
{
|
||||
// Check our flags
|
||||
if(Flags.ContainsKey(flag)) return Flags[flag];
|
||||
|
||||
// Check other groups
|
||||
foreach(ThingFlagsCompareGroup group in General.Map.Config.ThingFlagsCompare.Values)
|
||||
{
|
||||
if(group != this && group.Flags.ContainsKey(flag)) return group.Flags[flag];
|
||||
}
|
||||
|
||||
// Fial...
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
public class ThingFlagsCompareResult
|
||||
{
|
||||
public readonly HashSet<string> IgnoredGroups;
|
||||
public readonly HashSet<string> RequiredGroups;
|
||||
|
||||
// -1 if group does not overlap
|
||||
// 0 if group should be ignored
|
||||
// 1 if group overlaps
|
||||
public int Result;
|
||||
|
||||
public ThingFlagsCompareResult()
|
||||
{
|
||||
Result = -1;
|
||||
IgnoredGroups = new HashSet<string>();
|
||||
RequiredGroups = new HashSet<string>();
|
||||
}
|
||||
}
|
||||
|
||||
public class ThingFlagsCompare
|
||||
{
|
||||
public enum CompareMethod
|
||||
private enum CompareMethod
|
||||
{
|
||||
Equal,
|
||||
And
|
||||
|
@ -41,22 +146,21 @@ namespace CodeImp.DoomBuilder.Config
|
|||
#region ================== Variables
|
||||
|
||||
private readonly string flag;
|
||||
private string requiredgroup; //mxd. This flag only works if at least one flag is set in the "requiredgroup"
|
||||
private string ignoredgroup; //mxd. If this flag is set, flags from ignoredgroup can be... well... ignored!
|
||||
private readonly HashSet<string> requiredgroups; //mxd. This flag only works if at least one flag is set in the "requiredgroup"
|
||||
private readonly HashSet<string> ignoredgroups; //mxd. If this flag is set, flags from ignoredgroup can be... well... ignored!
|
||||
private string requiredflag; //mxd. This flag only works if requiredflag is set.
|
||||
private readonly bool ingnorethisgroupwhenunset; //mxd
|
||||
private readonly CompareMethod comparemethod;
|
||||
private readonly bool invert;
|
||||
private readonly string group;
|
||||
private readonly char[] comma = new[] {','};
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public string Flag { get { return flag; } }
|
||||
public string Group { get { return group; } }
|
||||
public string RequiredGroup { get { return requiredgroup; } internal set { requiredgroup = value; } } //mxd
|
||||
public string IgnoredGroup { get { return ignoredgroup; } internal set { ignoredgroup = value; } } //mxd
|
||||
public HashSet<string> RequiredGroups { get { return requiredgroups; } } //mxd
|
||||
public HashSet<string> IgnoredGroups { get { return ignoredgroups; } } //mxd
|
||||
public string RequiredFlag { get { return requiredflag; } internal set { requiredflag = value; } } //mxd
|
||||
public bool IgnoreGroupWhenUnset { get { return ingnorethisgroupwhenunset; } } //mxd
|
||||
|
||||
|
@ -69,11 +173,9 @@ namespace CodeImp.DoomBuilder.Config
|
|||
{
|
||||
string cfgpath = "thingflagscompare." + group + "." + flag;
|
||||
this.flag = flag;
|
||||
this.group = group;
|
||||
|
||||
string cm = cfg.ReadSetting(cfgpath + ".comparemethod", "and");
|
||||
|
||||
switch (cm)
|
||||
switch(cm)
|
||||
{
|
||||
default:
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Unrecognized value \"" + cm + "\" for comparemethod in " + cfgpath + " in game configuration " + cfg.ReadSetting("game", "<unnamed game>") + ". Defaulting to \"and\".");
|
||||
|
@ -87,8 +189,19 @@ namespace CodeImp.DoomBuilder.Config
|
|||
}
|
||||
|
||||
invert = cfg.ReadSetting(cfgpath + ".invert", false);
|
||||
requiredgroup = cfg.ReadSetting(cfgpath + ".requiredgroup", string.Empty); //mxd
|
||||
ignoredgroup = cfg.ReadSetting(cfgpath + ".ignoredgroup", string.Empty); //mxd
|
||||
|
||||
//mxd
|
||||
requiredgroups = new HashSet<string>();
|
||||
string[] requiredgroupsarr = cfg.ReadSetting(cfgpath + ".requiredgroups", string.Empty).Split(comma, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach(string s in requiredgroupsarr)
|
||||
if(!requiredgroups.Contains(s)) requiredgroups.Add(s);
|
||||
|
||||
//mxd
|
||||
ignoredgroups = new HashSet<string>();
|
||||
string[] ignoredgroupsarr = cfg.ReadSetting(cfgpath + ".ignoredgroups", string.Empty).Split(comma, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach(string s in ignoredgroupsarr)
|
||||
if(!ignoredgroups.Contains(s)) ignoredgroups.Add(s);
|
||||
|
||||
requiredflag = cfg.ReadSetting(cfgpath + ".requiredflag", string.Empty); //mxd
|
||||
ingnorethisgroupwhenunset = cfg.ReadSetting(cfgpath + ".ingnorethisgroupwhenunset", false); //mxd
|
||||
|
||||
|
@ -101,150 +214,87 @@ namespace CodeImp.DoomBuilder.Config
|
|||
#region ================== Methods
|
||||
|
||||
// Compares the flag of the two things.
|
||||
// Returns:
|
||||
// -1 if the flag does not overlap
|
||||
// 0 if the flag should be ignored
|
||||
// 1 if the flag overlaps
|
||||
public int Compare(Thing t1, Thing t2)
|
||||
public bool Compare(Thing t1, Thing t2)
|
||||
{
|
||||
// Check if the flags exist
|
||||
if (!t1.Flags.ContainsKey(flag) || !t2.Flags.ContainsKey(flag)) return 0;
|
||||
//mxd. Get flags
|
||||
bool t1flag = (invert ? !t1.IsFlagSet(flag) : t1.IsFlagSet(flag));
|
||||
bool t2flag = (invert ? !t2.IsFlagSet(flag) : t2.IsFlagSet(flag));
|
||||
|
||||
//mxd. We should ignore the flag if requiredgroup doesn't have any flags set
|
||||
if(!string.IsNullOrEmpty(requiredgroup))
|
||||
//mxd. Ignore the flag when ingnorethisgroupwhenunset is set and both flags are unset
|
||||
if(!t1flag && !t2flag && ingnorethisgroupwhenunset) return false;
|
||||
|
||||
//mxd. Compare them
|
||||
switch(comparemethod)
|
||||
{
|
||||
bool t1hasrequiredflags = false;
|
||||
bool t2hasrequiredflags = false;
|
||||
foreach(string key in General.Map.Config.ThingFlagsCompare[requiredgroup].Keys)
|
||||
{
|
||||
if(General.Map.Config.ThingFlagsCompare[requiredgroup][key].invert ? !t1.IsFlagSet(key) : t1.IsFlagSet(key))
|
||||
t1hasrequiredflags = true;
|
||||
if(General.Map.Config.ThingFlagsCompare[requiredgroup][key].invert ? !t2.IsFlagSet(key) : t2.IsFlagSet(key))
|
||||
t2hasrequiredflags = true;
|
||||
}
|
||||
|
||||
// Can't compare...
|
||||
if (!t1hasrequiredflags || !t2hasrequiredflags) return 0;
|
||||
case CompareMethod.And: return t1flag && t2flag;
|
||||
case CompareMethod.Equal: return t1flag == t2flag;
|
||||
default: throw new NotImplementedException("Unknown compare method!");
|
||||
}
|
||||
|
||||
//mxd. We should ignore the flag if requiredflag is not set
|
||||
if(!string.IsNullOrEmpty(requiredflag))
|
||||
{
|
||||
bool inverted = General.Map.Config.ThingFlagsCompare[group].ContainsKey(requiredflag) && General.Map.Config.ThingFlagsCompare[group][requiredflag].invert;
|
||||
|
||||
bool t1hasrequiredflag = (inverted ? !t1.IsFlagSet(requiredflag) : t1.IsFlagSet(requiredflag));
|
||||
bool t2hasrequiredflag = (inverted ? !t2.IsFlagSet(requiredflag) : t2.IsFlagSet(requiredflag));
|
||||
|
||||
// Can't compare...
|
||||
if(!t1hasrequiredflag || !t2hasrequiredflag) return 0;
|
||||
}
|
||||
|
||||
//mxd. We should also ignore the flag if it's in ingoredgroup
|
||||
foreach(KeyValuePair<string, Dictionary<string, ThingFlagsCompare>> pair in General.Map.Config.ThingFlagsCompare)
|
||||
{
|
||||
foreach(KeyValuePair<string, ThingFlagsCompare> flaggrp in pair.Value)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(flaggrp.Value.ignoredgroup) && group == flaggrp.Value.ignoredgroup)
|
||||
{
|
||||
bool t1ignoreflagset = flaggrp.Value.invert ? !t1.IsFlagSet(flaggrp.Key) : t1.IsFlagSet(flaggrp.Key);
|
||||
bool t2ignoreflagset = flaggrp.Value.invert ? !t2.IsFlagSet(flaggrp.Key) : t2.IsFlagSet(flaggrp.Key);
|
||||
|
||||
// Can be ignored?
|
||||
if(!t1ignoreflagset && !t2ignoreflagset && flaggrp.Value.IgnoreGroupWhenUnset) continue;
|
||||
|
||||
// Can't compare...
|
||||
if(!t1ignoreflagset || !t2ignoreflagset) return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Take flag inversion into account
|
||||
bool t1flag = invert ? !t1.Flags[flag] : t1.Flags[flag];
|
||||
bool t2flag = invert ? !t2.Flags[flag] : t2.Flags[flag];
|
||||
|
||||
if (comparemethod == CompareMethod.And && (t1flag && t2flag)) return 1;
|
||||
if (comparemethod == CompareMethod.Equal && (t1flag == t2flag)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//mxd
|
||||
public static string CheckThingEditFormFlags(List<CheckBox> checkboxes)
|
||||
public static List<string> CheckFlags(HashSet<string> flags)
|
||||
{
|
||||
Dictionary<string, bool> flags = new Dictionary<string, bool>(checkboxes.Count);
|
||||
Dictionary<string, Dictionary<string, bool>> flagspergroup = new Dictionary<string, Dictionary<string, bool>>(General.Map.Config.ThingFlagsCompare.Count);
|
||||
Dictionary<string, bool> requiredgroups = new Dictionary<string, bool>();
|
||||
Dictionary<string, bool> ignoredgroups = new Dictionary<string, bool>();
|
||||
|
||||
// Gather flags
|
||||
foreach (CheckBox cb in checkboxes)
|
||||
{
|
||||
flags.Add(cb.Tag.ToString(), cb.CheckState != CheckState.Unchecked);
|
||||
}
|
||||
Dictionary<string, HashSet<string>> flagspergroup = new Dictionary<string, HashSet<string>>(General.Map.Config.ThingFlagsCompare.Count);
|
||||
HashSet<string> ignoredgroups = new HashSet<string>();
|
||||
|
||||
// Gather flags per group
|
||||
foreach (KeyValuePair<string, Dictionary<string, ThingFlagsCompare>> group in General.Map.Config.ThingFlagsCompare)
|
||||
foreach(KeyValuePair<string, ThingFlagsCompareGroup> group in General.Map.Config.ThingFlagsCompare)
|
||||
{
|
||||
flagspergroup.Add(group.Key, new Dictionary<string, bool>());
|
||||
flagspergroup.Add(group.Key, new HashSet<string>());
|
||||
|
||||
foreach (KeyValuePair<string, ThingFlagsCompare> flaggrp in group.Value)
|
||||
foreach(ThingFlagsCompare flag in group.Value.Flags.Values)
|
||||
{
|
||||
bool flagset = IsFlagSet(flags, flaggrp.Key, flaggrp.Value.invert) && (string.IsNullOrEmpty(flaggrp.Value.requiredflag) || IsFlagSet(flags, flaggrp.Value.requiredflag, group.Value[flaggrp.Value.requiredflag].invert));
|
||||
|
||||
if(flagset)
|
||||
if(IsFlagSet(flags, flag.flag, flag.invert) &&
|
||||
(string.IsNullOrEmpty(flag.requiredflag) || IsFlagSet(flags, flag.requiredflag, group.Value.GetFlag(flag.requiredflag).invert)))
|
||||
{
|
||||
flagspergroup[group.Key].Add(flaggrp.Key, true);
|
||||
|
||||
if(!string.IsNullOrEmpty(flaggrp.Value.requiredgroup) && !requiredgroups.ContainsKey(flaggrp.Value.requiredgroup))
|
||||
requiredgroups.Add(flaggrp.Value.requiredgroup, false);
|
||||
}
|
||||
else if(flaggrp.Value.ingnorethisgroupwhenunset)
|
||||
flagspergroup[group.Key].Add(flag.Flag);
|
||||
foreach(string s in flag.ignoredgroups)
|
||||
if(!ignoredgroups.Contains(s)) ignoredgroups.Add(s);
|
||||
}
|
||||
else if(flag.ingnorethisgroupwhenunset)
|
||||
{
|
||||
ignoredgroups.Add(group.Key, false);
|
||||
flagspergroup.Remove(group.Key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check dependancies
|
||||
foreach (KeyValuePair<string, Dictionary<string, bool>> group in flagspergroup)
|
||||
// Check required dependancies
|
||||
foreach(KeyValuePair<string, HashSet<string>> group in flagspergroup)
|
||||
{
|
||||
foreach(KeyValuePair<string, bool> flaggrp in group.Value)
|
||||
foreach(string flag in group.Value)
|
||||
{
|
||||
if(!flaggrp.Value) continue;
|
||||
|
||||
string ignoredgrp = General.Map.Config.ThingFlagsCompare[group.Key][flaggrp.Key].ignoredgroup;
|
||||
if (!string.IsNullOrEmpty(ignoredgrp) && !requiredgroups.ContainsKey(ignoredgrp))
|
||||
foreach(string s in General.Map.Config.ThingFlagsCompare[group.Key].Flags[flag].requiredgroups)
|
||||
{
|
||||
ignoredgroups.Add(ignoredgrp, false);
|
||||
if(ignoredgroups.Contains(s)) ignoredgroups.Remove(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get rid of ignoredgroups
|
||||
foreach (KeyValuePair<string, bool> group in ignoredgroups)
|
||||
{
|
||||
flagspergroup.Remove(group.Key);
|
||||
}
|
||||
|
||||
foreach(string s in ignoredgroups) flagspergroup.Remove(s);
|
||||
|
||||
// Return message
|
||||
string result = string.Empty;
|
||||
List<string> result = new List<string>();
|
||||
|
||||
foreach (KeyValuePair<string, Dictionary<string, bool>> group in flagspergroup)
|
||||
foreach(KeyValuePair<string, HashSet<string>> group in flagspergroup)
|
||||
{
|
||||
if (group.Value.Count == 0)
|
||||
if(group.Value.Count == 0 && !General.Map.Config.ThingFlagsCompare[group.Key].IsOptional)
|
||||
{
|
||||
switch(group.Key)
|
||||
{
|
||||
case "skills":
|
||||
result += "Thing is not used in any skill level.";
|
||||
result.Add("Thing is not used in any skill level.");
|
||||
break;
|
||||
case "gamemodes":
|
||||
result += "Thing is not used in any game mode.";
|
||||
result.Add("Thing is not used in any game mode.");
|
||||
break;
|
||||
case "classes":
|
||||
result += "Thing is not used by any class.";
|
||||
result.Add("Thing is not used by any class.");
|
||||
break;
|
||||
default:
|
||||
result += "At least one '" + group.Key + "' flag should be set.";
|
||||
result.Add("At least one '" + group.Key + "' flag should be set.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -254,9 +304,9 @@ namespace CodeImp.DoomBuilder.Config
|
|||
}
|
||||
|
||||
//mxd
|
||||
private static bool IsFlagSet(Dictionary<string, bool> flags, string flag, bool invert)
|
||||
private static bool IsFlagSet(HashSet<string> flags, string flag, bool invert)
|
||||
{
|
||||
bool result = flags.ContainsKey(flag) && flags[flag];
|
||||
bool result = flags.Contains(flag);
|
||||
return (invert ? !result : result);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,12 +99,10 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// This draws an item in the combobox
|
||||
private void list_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
INumberedTitle item;
|
||||
Brush displaybrush = SystemBrushes.WindowText;
|
||||
Brush backbrush = SystemBrushes.Window;
|
||||
string displayname = string.Empty;
|
||||
int intnumber;
|
||||
|
||||
|
||||
// Only when running
|
||||
if(!this.DesignMode)
|
||||
{
|
||||
|
@ -116,6 +114,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
backbrush = new SolidBrush(SystemColors.Window);
|
||||
|
||||
// Try getting integral number
|
||||
int intnumber;
|
||||
int.TryParse(number.Text, out intnumber);
|
||||
|
||||
// Check what to display
|
||||
|
@ -134,7 +133,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else if((e.State & DrawItemState.ComboBoxEdit) != 0)
|
||||
{
|
||||
// Show without number
|
||||
item = (INumberedTitle)list.Items[e.Index];
|
||||
INumberedTitle item = (INumberedTitle)list.Items[e.Index];
|
||||
displayname = item.Title.Trim();
|
||||
|
||||
// Determine colors to use
|
||||
|
@ -154,7 +153,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else
|
||||
{
|
||||
// Use number and description
|
||||
item = (INumberedTitle)list.Items[e.Index];
|
||||
INumberedTitle item = (INumberedTitle)list.Items[e.Index];
|
||||
displayname = item.Index + NUMBER_SEPERATOR + item.Title;
|
||||
|
||||
// Determine colors to use
|
||||
|
@ -195,8 +194,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
private void number_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
int itemindex = -1;
|
||||
INumberedTitle item;
|
||||
|
||||
|
||||
// Not nothing?
|
||||
if(number.Text.Length > 0)
|
||||
{
|
||||
|
@ -204,7 +202,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
for(int i = 0; i < list.Items.Count; i++)
|
||||
{
|
||||
// This is the item we're looking for?
|
||||
item = (INumberedTitle)list.Items[i];
|
||||
INumberedTitle item = (INumberedTitle)list.Items[i];
|
||||
if(item.Index.ToString() == number.Text)
|
||||
{
|
||||
// Found it
|
||||
|
@ -215,11 +213,14 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
// Select item
|
||||
if(list.SelectedIndex != itemindex) list.SelectedIndex = itemindex;
|
||||
list.Refresh();
|
||||
|
||||
// Raise change event
|
||||
if(ValueChanges != null) ValueChanges(this, EventArgs.Empty);
|
||||
if(list.SelectedIndex != itemindex)
|
||||
{
|
||||
list.SelectedIndex = itemindex;
|
||||
list.Refresh();
|
||||
|
||||
// Raise change event
|
||||
if(ValueChanges != null) ValueChanges(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
// Keys pressed in number box
|
||||
|
@ -231,9 +232,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(controlpressed && ((e.KeyCode == Keys.X) || (e.KeyCode == Keys.C) || (e.KeyCode == Keys.V))) return;
|
||||
|
||||
//mxd. Scroll action list using arrow keys
|
||||
if (e.KeyCode == Keys.Down)
|
||||
if(e.KeyCode == Keys.Down)
|
||||
{
|
||||
if (list.SelectedIndex > 0)
|
||||
if(list.SelectedIndex > 0)
|
||||
{
|
||||
list.SelectedIndex--;
|
||||
list_SelectionChangeCommitted(list, EventArgs.Empty);
|
||||
|
@ -244,7 +245,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
if(e.KeyCode == Keys.Up)
|
||||
{
|
||||
if (list.SelectedIndex < list.Items.Count)
|
||||
if(list.SelectedIndex < list.Items.Count)
|
||||
{
|
||||
list.SelectedIndex++;
|
||||
list_SelectionChangeCommitted(list, EventArgs.Empty);
|
||||
|
@ -281,12 +282,12 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
//mxd. Scrolls action list using mouse wheel
|
||||
private void number_OnMouseWheel(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Delta < 0 && list.SelectedIndex > 0)
|
||||
if(e.Delta < 0 && list.SelectedIndex > 0)
|
||||
{
|
||||
list.SelectedIndex--;
|
||||
list_SelectionChangeCommitted(list, EventArgs.Empty);
|
||||
}
|
||||
else if (e.Delta > 0 && list.SelectedIndex < list.Items.Count - 1)
|
||||
else if(e.Delta > 0 && list.SelectedIndex < list.Items.Count - 1)
|
||||
{
|
||||
list.SelectedIndex++;
|
||||
list_SelectionChangeCommitted(list, EventArgs.Empty);
|
||||
|
|
|
@ -271,7 +271,6 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// Strip prefixes
|
||||
string str = combobox.Text.Trim().ToLowerInvariant();
|
||||
str = str.TrimStart('+', '-');
|
||||
int num = original;
|
||||
|
||||
// Anything in the box?
|
||||
if(combobox.Text.Trim().Length > 0)
|
||||
|
@ -280,6 +279,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(combobox.Text.Trim().StartsWith("++"))
|
||||
{
|
||||
// Add number to original
|
||||
int num;
|
||||
if(!int.TryParse(str, out num)) num = 0;
|
||||
result = original + num;
|
||||
}
|
||||
|
@ -287,6 +287,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else if(combobox.Text.Trim().StartsWith("--"))
|
||||
{
|
||||
// Subtract number from original
|
||||
int num;
|
||||
if(!int.TryParse(str, out num)) num = 0;
|
||||
result = original - num;
|
||||
}
|
||||
|
|
|
@ -377,7 +377,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < labels.Length; i++)
|
||||
for(int i = 0; i < labels.Length; i++)
|
||||
{
|
||||
labels[i].Text = arginfo[i].Title;
|
||||
labels[i].Enabled = arginfo[i].Used;
|
||||
|
|
|
@ -76,9 +76,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
if(columns < 1 || checkboxes.Count < 1) return 0;
|
||||
int maxwidth = 0;
|
||||
foreach (CheckBox cb in checkboxes)
|
||||
foreach(CheckBox cb in checkboxes)
|
||||
{
|
||||
if (cb.Width > maxwidth) maxwidth = cb.Width;
|
||||
if(cb.Width > maxwidth) maxwidth = cb.Width;
|
||||
}
|
||||
|
||||
return maxwidth * columns;
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
//mxd. Create some scaled coordinates...
|
||||
int[] coords = new[] { 1, 2, 3, 4, 6, 8, 9, 14, 115 };
|
||||
scaled = new Dictionary<int, int>(coords.Length);
|
||||
foreach (int i in coords) scaled[i] = (int)Math.Round(i * MainForm.DPIScaler.Width);
|
||||
foreach(int i in coords) scaled[i] = (int)Math.Round(i * MainForm.DPIScaler.Width);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace CodeImp.DoomBuilder
|
|||
me = this;
|
||||
|
||||
// Setup filters
|
||||
foreach (ToolStripMenuItem item in filterselector.DropDownItems)
|
||||
foreach(ToolStripMenuItem item in filterselector.DropDownItems)
|
||||
{
|
||||
UpdateFilters(item);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace CodeImp.DoomBuilder
|
|||
wordwrap.Checked = console.WordWrap;
|
||||
|
||||
// Pending messages?
|
||||
if (messages.Count > 0) UpdateMessages();
|
||||
if(messages.Count > 0) UpdateMessages();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -111,7 +111,7 @@ namespace CodeImp.DoomBuilder
|
|||
}
|
||||
else
|
||||
{
|
||||
if (messages.Count + 1 > MAX_MESSAGES) lock (messages) { messages.RemoveAt(0); }
|
||||
if(messages.Count + 1 > MAX_MESSAGES) lock (messages) { messages.RemoveAt(0); }
|
||||
messages.Add(new KeyValuePair<DebugMessageType, string>(type, text));
|
||||
if(me != null && (me.filters & type) == type)
|
||||
{
|
||||
|
@ -127,13 +127,13 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
public static void Clear()
|
||||
{
|
||||
if (me != null && me.InvokeRequired)
|
||||
if(me != null && me.InvokeRequired)
|
||||
{
|
||||
me.Invoke(new Action(Clear));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (me != null) me.console.Clear();
|
||||
if(me != null) me.console.Clear();
|
||||
messages.Clear();
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
long duration = SlimDX.Configuration.Timer.ElapsedMilliseconds - starttime;
|
||||
|
||||
if (message.Contains("%"))
|
||||
if(message.Contains("%"))
|
||||
message = message.Replace("%", duration.ToString(CultureInfo.InvariantCulture));
|
||||
else
|
||||
message = message.TrimEnd() + " " + duration + " ms.";
|
||||
|
@ -225,7 +225,7 @@ namespace CodeImp.DoomBuilder
|
|||
console.Clear();
|
||||
|
||||
console.SuspendLayout();
|
||||
foreach (KeyValuePair<DebugMessageType, string> pair in messages)
|
||||
foreach(KeyValuePair<DebugMessageType, string> pair in messages)
|
||||
{
|
||||
if((filters & pair.Key) == pair.Key && CheckTextFilter(pair.Value, searchbox.Text))
|
||||
{
|
||||
|
@ -240,7 +240,7 @@ namespace CodeImp.DoomBuilder
|
|||
// Should we display this message?
|
||||
private static bool CheckTextFilter(string text, string filter)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filter) || filter.Length < 3) return true;
|
||||
if(string.IsNullOrEmpty(filter) || filter.Length < 3) return true;
|
||||
return text.ToUpperInvariant().Contains(filter.ToUpperInvariant());
|
||||
}
|
||||
|
||||
|
|
|
@ -250,8 +250,8 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
//mxd. This checks if given docker exists in this control
|
||||
public bool Contains(Docker d)
|
||||
{
|
||||
foreach (TabPage page in tabs.TabPages)
|
||||
if ((page.Tag as Docker) == d) return true;
|
||||
foreach(TabPage page in tabs.TabPages)
|
||||
if((page.Tag as Docker) == d) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
int sortcolumn = General.Settings.ReadSetting("customfieldssortcolumn", 0);
|
||||
int sortorder = General.Settings.ReadSetting("customfieldssortorder", (int)ListSortDirection.Ascending);
|
||||
|
||||
switch (sortorder)
|
||||
switch(sortorder)
|
||||
{
|
||||
case (int)SortOrder.Ascending:
|
||||
fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Ascending);
|
||||
|
@ -253,7 +253,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
UniFields tempfields = new UniFields(tofields);
|
||||
foreach(KeyValuePair<string, UniValue> f in tempfields)
|
||||
{
|
||||
if (uifields.ContainsKey(f.Key)) continue; //mxd
|
||||
if(uifields.ContainsKey(f.Key)) continue; //mxd
|
||||
|
||||
// Go for all rows
|
||||
bool foundrow = false;
|
||||
|
@ -436,12 +436,11 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else if(e.ColumnIndex == 2)
|
||||
{
|
||||
// Get the row
|
||||
FieldsEditorRow frow;
|
||||
DataGridViewRow row = fieldslist.Rows[e.RowIndex];
|
||||
if(row is FieldsEditorRow)
|
||||
{
|
||||
// Get specializedrow
|
||||
frow = row as FieldsEditorRow;
|
||||
FieldsEditorRow frow = row as FieldsEditorRow;
|
||||
|
||||
// Enumerable?
|
||||
if(frow.TypeHandler.IsEnumerable)
|
||||
|
@ -516,10 +515,10 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else
|
||||
{
|
||||
// Check if no other row already has this name
|
||||
foreach (DataGridViewRow r in fieldslist.Rows)
|
||||
foreach(DataGridViewRow r in fieldslist.Rows)
|
||||
{
|
||||
// Name matches and not the same row?
|
||||
if ((r.Index != row.Index) && (r.Cells.Count > 0) && (r.Cells[0].Value != null) &&
|
||||
if((r.Index != row.Index) && (r.Cells.Count > 0) && (r.Cells[0].Value != null) &&
|
||||
(r.Cells[0].Value.ToString().ToLowerInvariant() == validname))
|
||||
{
|
||||
// Cannot have two rows with same name
|
||||
|
@ -530,7 +529,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
// Still valid?
|
||||
if (validname.Length > 0)
|
||||
if(validname.Length > 0)
|
||||
{
|
||||
// Try to find the type in the map options
|
||||
int type = General.Map.Options.GetUniversalFieldType(elementname, validname, 0);
|
||||
|
@ -540,7 +539,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
frow.Visible = false;
|
||||
fieldslist.Rows.Insert(e.RowIndex + 1, frow);
|
||||
|
||||
if (OnFieldInserted != null)
|
||||
if(OnFieldInserted != null)
|
||||
OnFieldInserted(validname);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -596,9 +596,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
//mxd. This validates an item's texture size
|
||||
private static bool ValidateItemSize(ImageBrowserItem i, int w, int h)
|
||||
{
|
||||
if (!i.Icon.IsPreviewLoaded) return true;
|
||||
if (w > 0 && i.Icon.Width != w) return false;
|
||||
if (h > 0 && i.Icon.Height != h) return false;
|
||||
if(!i.Icon.IsPreviewLoaded) return true;
|
||||
if(w > 0 && i.Icon.Width != w) return false;
|
||||
if(h > 0 && i.Icon.Height != h) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
private void preview_Click(object sender, EventArgs e)
|
||||
{
|
||||
imagebox.BackColor = SystemColors.Highlight;
|
||||
switch (button)
|
||||
switch(button)
|
||||
{
|
||||
case MouseButtons.Right: name.Text = "-"; break;
|
||||
case MouseButtons.Left: name.Text = BrowseImage(name.Text); break;
|
||||
|
@ -228,7 +228,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
// Update icon and tooltip
|
||||
togglefullname.Visible = true;
|
||||
if (image.ShortName == name.Text)
|
||||
if(image.ShortName == name.Text)
|
||||
{
|
||||
togglefullname.Image = Properties.Resources.Expand;
|
||||
tooltip.SetToolTip(togglefullname, "Switch to full name");
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(l.Tags.Count > 1)
|
||||
{
|
||||
string[] tags = new string[l.Tags.Count];
|
||||
for (int i = 0; i < l.Tags.Count; i++) tags[i] = l.Tags[i].ToString();
|
||||
for(int i = 0; i < l.Tags.Count; i++) tags[i] = l.Tags[i].ToString();
|
||||
tag.Text = string.Join(", ", tags);
|
||||
tag.Enabled = true;
|
||||
taglabel.Enabled = true;
|
||||
|
@ -281,7 +281,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else
|
||||
{
|
||||
frontoffsetlabel.Text = "Front offset:";
|
||||
if (l.Front.OffsetX != 0 || l.Front.OffsetY != 0)
|
||||
if(l.Front.OffsetX != 0 || l.Front.OffsetY != 0)
|
||||
{
|
||||
frontoffset.Text = l.Front.OffsetX + ", " + l.Front.OffsetY;
|
||||
frontoffsetlabel.Enabled = true;
|
||||
|
@ -399,7 +399,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else
|
||||
{
|
||||
backoffsetlabel.Text = "Back offset:";
|
||||
if (l.Back.OffsetX != 0 || l.Back.OffsetY != 0)
|
||||
if(l.Back.OffsetX != 0 || l.Back.OffsetY != 0)
|
||||
{
|
||||
backoffset.Text = l.Back.OffsetX + ", " + l.Back.OffsetY;
|
||||
backoffsetlabel.Enabled = true;
|
||||
|
@ -563,7 +563,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
int light = (int)sd.Fields["light"].Value;
|
||||
|
||||
if (sd.Fields.GetValue("lightabsolute", false))
|
||||
if(sd.Fields.GetValue("lightabsolute", false))
|
||||
value.Text = light + " (abs.)";
|
||||
else
|
||||
value.Text = light + " (" + Math.Min(255, Math.Max(0, (light + sd.Sector.Brightness))) + ")";
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
//mxd. Check if * or / is pressed
|
||||
if(e.KeyChar == '*' || e.KeyChar == '/')
|
||||
{
|
||||
if (this.SelectionStart - 1 > -1) e.Handled = true; //only valid when at the start of the text
|
||||
if(this.SelectionStart - 1 > -1) e.Handled = true; //only valid when at the start of the text
|
||||
}
|
||||
// Check if + or - is pressed
|
||||
else if((e.KeyChar == '+') || (e.KeyChar == '-'))
|
||||
|
@ -270,7 +270,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// Divide original by number
|
||||
float resultf;
|
||||
float.TryParse(textpart, NumberStyles.Float, CultureInfo.CurrentCulture, out resultf);
|
||||
if (resultf == 0) return original;
|
||||
if(resultf == 0) return original;
|
||||
int newvalue = (int)Math.Round(original / resultf);
|
||||
if(!allownegative && (newvalue < 0)) newvalue = 0;
|
||||
return newvalue;
|
||||
|
@ -374,7 +374,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
public void UpdateTextboxStyle(string tip)
|
||||
{
|
||||
this.ForeColor = (allowrelative ? SystemColors.HotTrack : SystemColors.WindowText);
|
||||
if (allowrelative)
|
||||
if(allowrelative)
|
||||
{
|
||||
tooltip.SetToolTip(this, "Use ++ or -- prefixes to change by given value." + Environment.NewLine +
|
||||
"Use +++ or --- prefixes to incrementally change by given value." + Environment.NewLine +
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
InitializeComponent();
|
||||
ResizeColumnHeader();
|
||||
|
||||
if (General.Actions != null)
|
||||
if(General.Actions != null)
|
||||
{
|
||||
// Get key shortcuts (mxd)
|
||||
copyactionkey = General.Actions.GetActionByName("builder_copyselection").ShortcutKey;
|
||||
|
@ -394,7 +394,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
foreach(ListViewItem item in resourceitems.Items)
|
||||
{
|
||||
if (!((DataLocation)item.Tag).IsValid()) return false;
|
||||
if(!((DataLocation)item.Tag).IsValid()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
return FastPerform(2016, 0, 0) != 0 ? true : false;
|
||||
return FastPerform(2016, 0, 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
return FastPerform(2102, 0, 0) != 0 ? true : false;
|
||||
return FastPerform(2102, 0, 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
return FastPerform(2173, 0, 0) != 0 ? true : false;
|
||||
return FastPerform(2173, 0, 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
return FastPerform(2174, 0, 0) != 0 ? true : false;
|
||||
return FastPerform(2174, 0, 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
return FastPerform(2202, 0, 0) != 0 ? true : false;
|
||||
return FastPerform(2202, 0, 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -678,15 +678,15 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
int entryline = -1;
|
||||
string[] processedlines = ProcessLineBreaks(lines);
|
||||
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
for(int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
processedlines[i] = processedlines[i].Replace("\t", spaces);
|
||||
|
||||
//check if we have the [EP] marker
|
||||
if (entrypos == -1)
|
||||
if(entrypos == -1)
|
||||
{
|
||||
int pos = processedlines[i].IndexOf("[EP]");
|
||||
if (pos != -1)
|
||||
if(pos != -1)
|
||||
{
|
||||
entryline = curline + i;
|
||||
entrypos = pos + numtabs;
|
||||
|
@ -702,7 +702,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
scriptedit.ReplaceSel(text);
|
||||
|
||||
//move the cursor if we had the [EP] marker
|
||||
if (entrypos != -1)
|
||||
if(entrypos != -1)
|
||||
{
|
||||
MoveToLine(entryline);
|
||||
scriptedit.SelectionStart = scriptedit.PositionFromLine(entryline) + entrypos;
|
||||
|
|
|
@ -73,8 +73,6 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// This initializes the control
|
||||
public void Initialize()
|
||||
{
|
||||
ToolStripMenuItem item;
|
||||
|
||||
// Make list of script configs
|
||||
scriptconfigs = new List<ScriptConfiguration>(General.ScriptConfigs.Values);
|
||||
scriptconfigs.Add(new ScriptConfiguration());
|
||||
|
@ -84,7 +82,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
foreach(ScriptConfiguration cfg in scriptconfigs)
|
||||
{
|
||||
// Button for new script menu
|
||||
item = new ToolStripMenuItem(cfg.Description);
|
||||
ToolStripMenuItem item = new ToolStripMenuItem(cfg.Description);
|
||||
//item.Image = buttonnew.Image;
|
||||
item.Tag = cfg;
|
||||
item.Click += buttonnew_Click;
|
||||
|
@ -424,7 +422,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
// Ask to save
|
||||
DialogResult result = MessageBox.Show(this.ParentForm, "Do you want to save changes to " + t.Text + "?", "Close File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||
switch (result)
|
||||
switch(result)
|
||||
{
|
||||
case DialogResult.Yes:
|
||||
if(!SaveScript(t)) return false;
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
effectlabel.Enabled = (s.Effect != 0);
|
||||
|
||||
//mxd. Texture size
|
||||
if (s.LongFloorTexture == MapSet.EmptyLongName)
|
||||
if(s.LongFloorTexture == MapSet.EmptyLongName)
|
||||
{
|
||||
labelFloorTextureSize.Visible = false;
|
||||
General.DisplayZoomedImage(floortex, Properties.Resources.MissingTexture);
|
||||
|
@ -105,7 +105,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
General.DisplayZoomedImage(floortex, image.GetPreview());
|
||||
}
|
||||
|
||||
if (s.LongCeilTexture == MapSet.EmptyLongName)
|
||||
if(s.LongCeilTexture == MapSet.EmptyLongName)
|
||||
{
|
||||
labelCeilTextureSize.Visible = false;
|
||||
General.DisplayZoomedImage(ceilingtex, Properties.Resources.MissingTexture);
|
||||
|
@ -369,7 +369,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
private static int GetMaxRight(IEnumerable<Label> labels)
|
||||
{
|
||||
int max = 0;
|
||||
foreach (Label label in labels) if (label.Right > max) max = label.Right;
|
||||
foreach(Label label in labels) if(label.Right > max) max = label.Right;
|
||||
return max;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
public void SetValues(float anglexy, float anglez, float offset, bool first)
|
||||
{
|
||||
if (first)
|
||||
if(first)
|
||||
{
|
||||
// Set values
|
||||
this.anglexy = anglexy;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
UpdateToggleImageNameButton(null); //mxd
|
||||
|
||||
//mxd. Determine image to show
|
||||
if (multipletextures) return Properties.Resources.ImageStack;
|
||||
if(multipletextures) return Properties.Resources.ImageStack;
|
||||
return (required ? Properties.Resources.MissingTexture : null);
|
||||
}
|
||||
else if(imagename == "-") //mxd
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
private static void GetValidNodes(TreeNode root, ref Dictionary<string, TreeNode> vn)
|
||||
{
|
||||
if (root.Nodes.Count == 0)
|
||||
if(root.Nodes.Count == 0)
|
||||
{
|
||||
if(root.Tag is ThingTypeInfo && !vn.ContainsKey(root.Text)) vn.Add(root.Text, root);
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// so we set the correct one in typelist_AfterSelect handler (mxd)
|
||||
private void typelist_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (typelist.SelectedNodes.Count == 1
|
||||
if(typelist.SelectedNodes.Count == 1
|
||||
&& doubleclickednode != null
|
||||
&& doubleclickednode.Nodes.Count == 0
|
||||
&& doubleclickednode.Tag is ThingTypeInfo
|
||||
|
@ -274,7 +274,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
private void typelist_SelectionsChanged(object sender, EventArgs e)
|
||||
{
|
||||
doubleclickednode = null; //mxd
|
||||
if (!doupdatetextbox) return;
|
||||
if(!doupdatetextbox) return;
|
||||
|
||||
//mxd
|
||||
validnodes = GetValidNodes();
|
||||
|
@ -283,12 +283,12 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(typelist.SelectionMode == TreeViewSelectionMode.MultiSelectSameLevel && validnodes.Count > 1)
|
||||
{
|
||||
doupdatenode = false;
|
||||
if (!string.IsNullOrEmpty(typeid.Text))
|
||||
if(!string.IsNullOrEmpty(typeid.Text))
|
||||
{
|
||||
// Event will be raised in typeid_OnTextChanged
|
||||
typeid.Text = "";
|
||||
}
|
||||
else if (OnTypeChanged != null)
|
||||
else if(OnTypeChanged != null)
|
||||
{
|
||||
// Or raise event here
|
||||
UpdateThingSprite();
|
||||
|
@ -304,7 +304,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
doupdatenode = true;
|
||||
|
||||
// Set as double-clicked only if a single child node is selected
|
||||
if (typelist.SelectedNodes.Count == 1 && typelist.SelectedNodes[0].Nodes.Count == 0)
|
||||
if(typelist.SelectedNodes.Count == 1 && typelist.SelectedNodes[0].Nodes.Count == 0)
|
||||
{
|
||||
doubleclickednode = validnodes[0]; //mxd
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
else
|
||||
{
|
||||
thinginfo = null;
|
||||
if (doupdatenode)
|
||||
if(doupdatenode)
|
||||
{
|
||||
typelist.SelectedNodes.Clear();
|
||||
validnodes.Clear(); //mxd
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
public void OnValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ValueChanged != null) ValueChanged(this, e);
|
||||
if(ValueChanged != null) ValueChanged(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
//mxd
|
||||
public bool IsValid()
|
||||
{
|
||||
foreach(DataLocation location in this) if (!location.IsValid()) return false;
|
||||
foreach(DataLocation location in this) if(!location.IsValid()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
};
|
||||
|
||||
//mxd. Load comment icons
|
||||
foreach (ImageData data in commenttextures)
|
||||
foreach(ImageData data in commenttextures)
|
||||
{
|
||||
data.LoadImage();
|
||||
data.CreateTexture();
|
||||
|
@ -604,8 +604,6 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This stops background loading
|
||||
private void StopBackgroundLoader()
|
||||
{
|
||||
ImageData img;
|
||||
|
||||
General.WriteLogLine("Stopping background resource loading...");
|
||||
if(backgroundloader != null)
|
||||
{
|
||||
|
@ -616,7 +614,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Reset load states on all images in the list
|
||||
while(imageque.Count > 0)
|
||||
{
|
||||
img = imageque.Dequeue();
|
||||
ImageData img = imageque.Dequeue();
|
||||
|
||||
switch(img.ImageState)
|
||||
{
|
||||
|
@ -719,9 +717,9 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(loadfinishtime == 0)
|
||||
{
|
||||
//mxd. Release PK3 files
|
||||
foreach (DataReader reader in containers)
|
||||
foreach(DataReader reader in containers)
|
||||
{
|
||||
if (reader is PK3Reader) (reader as PK3Reader).BathMode = false;
|
||||
if(reader is PK3Reader) (reader as PK3Reader).BathMode = false;
|
||||
}
|
||||
|
||||
loadfinishtime = Clock.CurrentTime;
|
||||
|
@ -866,14 +864,13 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads the colormaps
|
||||
private int LoadColormaps(Dictionary<long, ImageData> list)
|
||||
{
|
||||
ICollection<ImageData> images;
|
||||
int counter = 0;
|
||||
|
||||
// Go for all opened containers
|
||||
foreach(DataReader dr in containers)
|
||||
{
|
||||
// Load colormaps
|
||||
images = dr.LoadColormaps();
|
||||
ICollection<ImageData> images = dr.LoadColormaps();
|
||||
if(images != null)
|
||||
{
|
||||
// Go for all colormaps
|
||||
|
@ -897,13 +894,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This returns a specific colormap stream
|
||||
internal Stream GetColormapData(string pname)
|
||||
{
|
||||
Stream colormap;
|
||||
|
||||
// Go for all opened containers
|
||||
for(int i = containers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// This contain provides this flat?
|
||||
colormap = containers[i].GetColormapData(pname);
|
||||
Stream colormap = containers[i].GetColormapData(pname);
|
||||
if(colormap != null) return colormap;
|
||||
}
|
||||
|
||||
|
@ -918,9 +913,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads the textures
|
||||
private int LoadTextures(Dictionary<long, ImageData> list, Dictionary<long, long> nametranslation)
|
||||
{
|
||||
ICollection<ImageData> images;
|
||||
PatchNames pnames = new PatchNames();
|
||||
PatchNames newpnames;
|
||||
int counter = 0;
|
||||
|
||||
// Go for all opened containers
|
||||
|
@ -930,11 +923,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Note that pnames is NOT set to null in the loop
|
||||
// because if a container has no pnames, the pnames
|
||||
// of the previous (higher) container should be used.
|
||||
newpnames = dr.LoadPatchNames();
|
||||
PatchNames newpnames = dr.LoadPatchNames();
|
||||
if(newpnames != null) pnames = newpnames;
|
||||
|
||||
// Load textures
|
||||
images = dr.LoadTextures(pnames);
|
||||
ICollection<ImageData> images = dr.LoadTextures(pnames);
|
||||
if(images != null)
|
||||
{
|
||||
// Go for all textures
|
||||
|
@ -972,13 +965,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This returns a specific patch stream
|
||||
internal Stream GetPatchData(string pname, bool longname)
|
||||
{
|
||||
Stream patch;
|
||||
|
||||
// Go for all opened containers
|
||||
for(int i = containers.Count - 1; i > -1; i--)
|
||||
{
|
||||
// This contain provides this patch?
|
||||
patch = containers[i].GetPatchData(pname, longname);
|
||||
Stream patch = containers[i].GetPatchData(pname, longname);
|
||||
if(patch != null) return patch;
|
||||
}
|
||||
|
||||
|
@ -989,13 +980,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This returns a specific texture stream
|
||||
internal Stream GetTextureData(string pname, bool longname)
|
||||
{
|
||||
Stream patch;
|
||||
|
||||
// Go for all opened containers
|
||||
for(int i = containers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// This contain provides this patch?
|
||||
patch = containers[i].GetTextureData(pname, longname);
|
||||
Stream patch = containers[i].GetTextureData(pname, longname);
|
||||
if(patch != null) return patch;
|
||||
}
|
||||
|
||||
|
@ -1038,7 +1027,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
//mxd
|
||||
public string GetFullTextureName(string name)
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(name) == name && name.Length > CLASIC_IMAGE_NAME_LENGTH)
|
||||
if(Path.GetFileNameWithoutExtension(name) == name && name.Length > CLASIC_IMAGE_NAME_LENGTH)
|
||||
name = name.Substring(0, CLASIC_IMAGE_NAME_LENGTH);
|
||||
long hash = MurmurHash2.Hash(name.Trim().ToUpperInvariant());
|
||||
|
||||
|
@ -1062,14 +1051,13 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads the flats
|
||||
private int LoadFlats(Dictionary<long, ImageData> list, Dictionary<long, long> nametranslation)
|
||||
{
|
||||
ICollection<ImageData> images;
|
||||
int counter = 0;
|
||||
|
||||
// Go for all opened containers
|
||||
foreach(DataReader dr in containers)
|
||||
{
|
||||
// Load flats
|
||||
images = dr.LoadFlats();
|
||||
ICollection<ImageData> images = dr.LoadFlats();
|
||||
if(images != null)
|
||||
{
|
||||
// Go for all flats
|
||||
|
@ -1083,7 +1071,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
//mxd. Also add as short name when texture name is longer than 8 chars
|
||||
// Or remove when a wad image with short name overrides previously added
|
||||
// resource image with long name
|
||||
if (img.HasLongName)
|
||||
if(img.HasLongName)
|
||||
{
|
||||
long longshortname = Lump.MakeLongName(Path.GetFileNameWithoutExtension(img.Name), false);
|
||||
nametranslation.Remove(longshortname);
|
||||
|
@ -1107,13 +1095,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This returns a specific flat stream
|
||||
internal Stream GetFlatData(string pname, bool longname)
|
||||
{
|
||||
Stream flat;
|
||||
|
||||
// Go for all opened containers
|
||||
for(int i = containers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// This contain provides this flat?
|
||||
flat = containers[i].GetFlatData(pname, longname);
|
||||
Stream flat = containers[i].GetFlatData(pname, longname);
|
||||
if(flat != null) return flat;
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1173,6 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads the hard defined sprites (not all the lumps, we do that on a need-to-know basis, see LoadThingSprites)
|
||||
private int LoadSprites()
|
||||
{
|
||||
ICollection<ImageData> images;
|
||||
int counter = 0;
|
||||
|
||||
// Load all defined sprites. Note that we do not use all sprites,
|
||||
|
@ -1195,7 +1180,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
foreach(DataReader dr in containers)
|
||||
{
|
||||
// Load sprites
|
||||
images = dr.LoadSprites();
|
||||
ICollection<ImageData> images = dr.LoadSprites();
|
||||
if(images != null)
|
||||
{
|
||||
// Add or replace in sprites list
|
||||
|
@ -1475,7 +1460,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
List<int> toremove = new List<int>();
|
||||
Dictionary<string, ThingTypeInfo> thingtypesbyclass = new Dictionary<string, ThingTypeInfo>();
|
||||
foreach (KeyValuePair<int, ThingTypeInfo> group in thingtypes)
|
||||
foreach(KeyValuePair<int, ThingTypeInfo> group in thingtypes)
|
||||
{
|
||||
if(string.IsNullOrEmpty(group.Value.ClassName)) continue;
|
||||
thingtypesbyclass[group.Value.ClassName.ToLowerInvariant()] = group.Value;
|
||||
|
@ -1599,13 +1584,13 @@ namespace CodeImp.DoomBuilder.Data
|
|||
General.Map.Config.Enums["spawnthing"] = newenums;
|
||||
|
||||
// Update all ArgumentInfos...
|
||||
foreach (ThingTypeInfo info in thingtypes.Values)
|
||||
foreach(ThingTypeInfo info in thingtypes.Values)
|
||||
{
|
||||
foreach(ArgumentInfo ai in info.Args)
|
||||
if(ai.Enum.Name == "spawnthing") ai.Enum = newenums;
|
||||
}
|
||||
|
||||
foreach (LinedefActionInfo info in General.Map.Config.LinedefActions.Values)
|
||||
foreach(LinedefActionInfo info in General.Map.Config.LinedefActions.Values)
|
||||
{
|
||||
foreach(ArgumentInfo ai in info.Args)
|
||||
if(ai.Enum.Name == "spawnthing") ai.Enum = newenums;
|
||||
|
|
|
@ -74,10 +74,10 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Note the backward order, because the last wad's images have priority
|
||||
if(!longname) //mxd. Patches with long names can't be in wads
|
||||
{
|
||||
for (int i = wads.Count - 1; i > -1; i--)
|
||||
for(int i = wads.Count - 1; i > -1; i--)
|
||||
{
|
||||
Stream data = wads[i].GetPatchData(pname, false);
|
||||
if (data != null) return data;
|
||||
if(data != null) return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,16 +89,16 @@ namespace CodeImp.DoomBuilder.Data
|
|||
pname = pname.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
return (FileExists(pname) ? LoadFile(pname) : null);
|
||||
}
|
||||
else if (General.Map.Config.MixTexturesFlats)
|
||||
else if(General.Map.Config.MixTexturesFlats)
|
||||
{
|
||||
//mxd. Find in directories ZDoom expects them to be
|
||||
string dir = Path.GetDirectoryName(pname);
|
||||
string name = Path.GetFileName(pname);
|
||||
foreach (string loc in PatchLocations)
|
||||
foreach(string loc in PatchLocations)
|
||||
{
|
||||
string path = Path.Combine(loc, dir);
|
||||
string filename = FindFirstFile(path, name, true);
|
||||
if (!string.IsNullOrEmpty(filename) && FileExists(filename))
|
||||
if(!string.IsNullOrEmpty(filename) && FileExists(filename))
|
||||
return LoadFile(filename);
|
||||
}
|
||||
}
|
||||
|
@ -128,19 +128,19 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
// Find in any of the wad files
|
||||
// Note the backward order, because the last wad's images have priority
|
||||
if (!longname) //mxd. Textures with long names can't be in wads
|
||||
if(!longname) //mxd. Textures with long names can't be in wads
|
||||
{
|
||||
for (int i = wads.Count - 1; i >= 0; i--)
|
||||
for(int i = wads.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Stream data = wads[i].GetTextureData(pname, false);
|
||||
if (data != null) return data;
|
||||
if(data != null) return data;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//mxd. Long names are absolute
|
||||
if (longname)
|
||||
if(longname)
|
||||
{
|
||||
pname = pname.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
return (FileExists(pname) ? LoadFile(pname) : null);
|
||||
|
@ -150,7 +150,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Find in textures directory
|
||||
string path = Path.Combine(TEXTURES_DIR, Path.GetDirectoryName(pname));
|
||||
string filename = FindFirstFile(path, Path.GetFileName(pname), true);
|
||||
if (!string.IsNullOrEmpty(filename) && FileExists(filename))
|
||||
if(!string.IsNullOrEmpty(filename) && FileExists(filename))
|
||||
return LoadFile(filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(!uselongtexturenames || (!forcelongtexturename && string.IsNullOrEmpty(Path.GetDirectoryName(name))))
|
||||
{
|
||||
this.name = Path.GetFileNameWithoutExtension(name.ToUpperInvariant());
|
||||
if (this.name.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
|
||||
if(this.name.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
|
||||
{
|
||||
this.name = this.name.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
this.virtualname = name;
|
||||
this.displayname = Path.GetFileNameWithoutExtension(name);
|
||||
this.shortname = this.displayname.ToUpperInvariant();
|
||||
if (this.shortname.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
|
||||
if(this.shortname.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
|
||||
{
|
||||
this.shortname = this.shortname.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
this.displayname = this.displayname.ToUpperInvariant();
|
||||
}
|
||||
|
||||
if (this.displayname.Length > ImageBrowserItem.MAX_NAME_LENGTH)
|
||||
if(this.displayname.Length > ImageBrowserItem.MAX_NAME_LENGTH)
|
||||
{
|
||||
this.displayname = this.displayname.Substring(0, ImageBrowserItem.MAX_NAME_LENGTH);
|
||||
}
|
||||
|
|
|
@ -98,19 +98,15 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
// Add it
|
||||
patches.Add(patch);
|
||||
if (patch.lumpname == Name) hasPatchWithSameName = true; //mxd
|
||||
if(patch.lumpname == Name) hasPatchWithSameName = true; //mxd
|
||||
}
|
||||
|
||||
// This loads the image
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
// Checks
|
||||
if(this.IsImageLoaded) return;
|
||||
if((width == 0) || (height == 0)) return;
|
||||
if(this.IsImageLoaded || width == 0 || height == 0) return;
|
||||
|
||||
IImageReader reader;
|
||||
MemoryStream mem;
|
||||
byte[] membytes;
|
||||
Graphics g = null;
|
||||
|
||||
lock(this)
|
||||
|
@ -147,21 +143,21 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
// Copy patch data to memory
|
||||
patchdata.Seek(0, SeekOrigin.Begin);
|
||||
membytes = new byte[(int)patchdata.Length];
|
||||
byte[] membytes = new byte[(int)patchdata.Length];
|
||||
patchdata.Read(membytes, 0, (int)patchdata.Length);
|
||||
mem = new MemoryStream(membytes);
|
||||
MemoryStream mem = new MemoryStream(membytes);
|
||||
mem.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// Get a reader for the data
|
||||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
|
||||
IImageReader reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
|
||||
if(reader is UnknownImageReader)
|
||||
{
|
||||
//mxd. Probably that's a flat?..
|
||||
if (General.Map.Config.MixTexturesFlats)
|
||||
if(General.Map.Config.MixTexturesFlats)
|
||||
{
|
||||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMFLAT, General.Map.Data.Palette);
|
||||
}
|
||||
if (reader is UnknownImageReader)
|
||||
if(reader is UnknownImageReader)
|
||||
{
|
||||
// Data is in an unknown format!
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'");
|
||||
|
@ -200,7 +196,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(p.rotate != 0)
|
||||
{
|
||||
RotateFlipType rotate;
|
||||
switch (p.rotate)
|
||||
switch(p.rotate)
|
||||
{
|
||||
case 90: rotate = RotateFlipType.Rotate90FlipNone; break;
|
||||
case 180: rotate = RotateFlipType.Rotate180FlipNone; break;
|
||||
|
|
|
@ -118,14 +118,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// signature, and expects the stream to be long enough.
|
||||
private static bool CheckSignature(Stream data, int[] sig)
|
||||
{
|
||||
int b;
|
||||
|
||||
// Go for all bytes
|
||||
for(int i = 0; i < sig.Length; i++)
|
||||
foreach(int s in sig)
|
||||
{
|
||||
// When byte doesnt match the signature, leave
|
||||
b = data.ReadByte();
|
||||
if(b != sig[i]) return false;
|
||||
if(data.ReadByte() != s) return false;
|
||||
}
|
||||
|
||||
// Signature matches
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
if(archivetype == ArchiveType.SevenZip) return;
|
||||
|
||||
if (enable && archive == null)
|
||||
if(enable && archive == null)
|
||||
{
|
||||
archive = ArchiveFactory.Open(location.location);
|
||||
}
|
||||
|
@ -150,12 +150,12 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
// Find in any of the wad files
|
||||
// Note the backward order, because the last wad's images have priority
|
||||
if (!longname) //mxd. Patches with long names can't be in wads
|
||||
if(!longname) //mxd. Patches with long names can't be in wads
|
||||
{
|
||||
for (int i = wads.Count - 1; i >= 0; i--)
|
||||
for(int i = wads.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Stream data = wads[i].GetPatchData(pname, false);
|
||||
if (data != null) return data;
|
||||
if(data != null) return data;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -164,13 +164,13 @@ namespace CodeImp.DoomBuilder.Data
|
|||
return (FileExists(pname) ? LoadFile(pname) : null);
|
||||
}
|
||||
|
||||
if (General.Map.Config.MixTexturesFlats)
|
||||
if(General.Map.Config.MixTexturesFlats)
|
||||
{
|
||||
//mxd. Find in directories ZDoom expects them to be
|
||||
foreach (string loc in PatchLocations)
|
||||
foreach(string loc in PatchLocations)
|
||||
{
|
||||
string filename = FindFirstFile(loc, pname, true);
|
||||
if ((filename != null) && FileExists(filename))
|
||||
if((filename != null) && FileExists(filename))
|
||||
return LoadFile(filename);
|
||||
}
|
||||
}
|
||||
|
@ -194,12 +194,12 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
// Find in any of the wad files
|
||||
// Note the backward order, because the last wad's images have priority
|
||||
if (!longname) //mxd. Textures with long names can't be in wads
|
||||
if(!longname) //mxd. Textures with long names can't be in wads
|
||||
{
|
||||
for (int i = wads.Count - 1; i >= 0; i--)
|
||||
for(int i = wads.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Stream data = wads[i].GetTextureData(pname, false);
|
||||
if (data != null) return data;
|
||||
if(data != null) return data;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -418,7 +418,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(archivetype == ArchiveType.SevenZip)
|
||||
{
|
||||
fn = fn.ToLowerInvariant();
|
||||
if (sevenzipentries.ContainsKey(fn)) filedata = new MemoryStream(sevenzipentries[fn]);
|
||||
if(sevenzipentries.ContainsKey(fn)) filedata = new MemoryStream(sevenzipentries[fn]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -326,10 +326,10 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Note the backward order, because the last wad's images have priority
|
||||
if(!longname) //mxd. Flats with long names can't be in wads
|
||||
{
|
||||
for (int i = wads.Count - 1; i > -1; i--)
|
||||
for(int i = wads.Count - 1; i > -1; i--)
|
||||
{
|
||||
Stream data = wads[i].GetFlatData(pname, false);
|
||||
if (data != null) return data;
|
||||
if(data != null) return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,6 @@ namespace CodeImp.DoomBuilder.Data
|
|||
public override ICollection<ImageData> LoadSprites()
|
||||
{
|
||||
Dictionary<long, ImageData> images = new Dictionary<long, ImageData>();
|
||||
ICollection<ImageData> collection;
|
||||
List<ImageData> imgset = new List<ImageData>();
|
||||
|
||||
// Error when suspended
|
||||
|
@ -355,7 +354,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Note the backward order, because the last wad's images have priority
|
||||
for(int i = wads.Count - 1; i >= 0; i--)
|
||||
{
|
||||
collection = wads[i].LoadSprites();
|
||||
ICollection<ImageData> collection = wads[i].LoadSprites();
|
||||
AddImagesToList(images, collection);
|
||||
}
|
||||
|
||||
|
@ -467,15 +466,15 @@ namespace CodeImp.DoomBuilder.Data
|
|||
public override Dictionary<string, Stream> GetModeldefData()
|
||||
{
|
||||
// Error when suspended
|
||||
if (issuspended) throw new Exception("Data reader is suspended");
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
// Modedef should be in root folder
|
||||
string[] files = GetAllFiles("", false);
|
||||
Dictionary<string, Stream> streams = new Dictionary<string, Stream>(StringComparer.Ordinal);
|
||||
|
||||
foreach (string s in files)
|
||||
foreach(string s in files)
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(s).ToUpperInvariant().StartsWith("MODELDEF"))
|
||||
if(Path.GetFileNameWithoutExtension(s).ToUpperInvariant().StartsWith("MODELDEF"))
|
||||
streams.Add(s, LoadFile(s));
|
||||
}
|
||||
|
||||
|
@ -496,7 +495,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
List<string> voxels = new List<string>();
|
||||
Regex spritename = new Regex(SPRITE_NAME_PATTERN);
|
||||
|
||||
foreach (string t in files)
|
||||
foreach(string t in files)
|
||||
{
|
||||
string s = Path.GetFileNameWithoutExtension(t).ToUpperInvariant();
|
||||
if(spritename.IsMatch(s)) voxels.Add(s);
|
||||
|
@ -531,17 +530,16 @@ namespace CodeImp.DoomBuilder.Data
|
|||
public override Dictionary<string, Stream> GetMapinfoData()
|
||||
{
|
||||
// Error when suspended
|
||||
if (issuspended) throw new Exception("Data reader is suspended");
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
//mapinfo should be in root folder
|
||||
Dictionary<string, Stream> streams = new Dictionary<string, Stream>(StringComparer.Ordinal);
|
||||
string[] files = GetAllFiles("", false);
|
||||
string filename;
|
||||
|
||||
//try to find (z)mapinfo
|
||||
foreach (string s in files)
|
||||
foreach(string s in files)
|
||||
{
|
||||
filename = Path.GetFileNameWithoutExtension(s.ToLowerInvariant());
|
||||
string filename = Path.GetFileNameWithoutExtension(s.ToLowerInvariant());
|
||||
if(filename == "zmapinfo" || filename == "mapinfo")
|
||||
streams.Add(s, LoadFile(s));
|
||||
}
|
||||
|
|
|
@ -112,12 +112,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This makes a preview for the given image and updates the image settings
|
||||
private void MakeImagePreview(ImageData img)
|
||||
{
|
||||
int imagewidth, imageheight;
|
||||
|
||||
lock(img)
|
||||
{
|
||||
// Load image if needed
|
||||
if(!img.IsImageLoaded) img.LoadImage();
|
||||
int imagewidth, imageheight;
|
||||
if(!img.LoadFailed)
|
||||
{
|
||||
imagewidth = img.Width;
|
||||
|
|
|
@ -72,29 +72,24 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads the image
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
Stream lumpdata;
|
||||
MemoryStream mem;
|
||||
IImageReader reader;
|
||||
byte[] membytes;
|
||||
|
||||
// Leave when already loaded
|
||||
if(this.IsImageLoaded) return;
|
||||
|
||||
lock(this)
|
||||
{
|
||||
// Get the lump data stream
|
||||
lumpdata = General.Map.Data.GetSpriteData(Name);
|
||||
Stream lumpdata = General.Map.Data.GetSpriteData(Name);
|
||||
if(lumpdata != null)
|
||||
{
|
||||
// Copy lump data to memory
|
||||
lumpdata.Seek(0, SeekOrigin.Begin);
|
||||
membytes = new byte[(int)lumpdata.Length];
|
||||
byte[] membytes = new byte[(int)lumpdata.Length];
|
||||
lumpdata.Read(membytes, 0, (int)lumpdata.Length);
|
||||
mem = new MemoryStream(membytes);
|
||||
MemoryStream mem = new MemoryStream(membytes);
|
||||
mem.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// Get a reader for the data
|
||||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
|
||||
IImageReader reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
|
||||
if(reader is UnknownImageReader)
|
||||
{
|
||||
// Data is in an unknown format!
|
||||
|
|
|
@ -70,16 +70,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads the image
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
IImageReader reader;
|
||||
BitmapData bitmapdata = null;
|
||||
MemoryStream mem;
|
||||
PixelColor* pixels = (PixelColor*)0;
|
||||
Stream patchdata;
|
||||
byte[] membytes;
|
||||
|
||||
// Checks
|
||||
if(this.IsImageLoaded) return;
|
||||
if((width == 0) || (height == 0)) return;
|
||||
if(this.IsImageLoaded || width == 0 || height == 0) return;
|
||||
|
||||
BitmapData bitmapdata = null;
|
||||
PixelColor* pixels = (PixelColor*)0;
|
||||
|
||||
lock(this)
|
||||
{
|
||||
|
@ -107,26 +102,26 @@ namespace CodeImp.DoomBuilder.Data
|
|||
foreach(TexturePatch p in patches)
|
||||
{
|
||||
// Get the patch data stream
|
||||
patchdata = General.Map.Data.GetPatchData(p.lumpname, p.haslongname);
|
||||
Stream patchdata = General.Map.Data.GetPatchData(p.lumpname, p.haslongname);
|
||||
if(patchdata != null)
|
||||
{
|
||||
// Copy patch data to memory
|
||||
patchdata.Seek(0, SeekOrigin.Begin);
|
||||
membytes = new byte[(int)patchdata.Length];
|
||||
byte[] membytes = new byte[(int)patchdata.Length];
|
||||
patchdata.Read(membytes, 0, (int)patchdata.Length);
|
||||
mem = new MemoryStream(membytes);
|
||||
MemoryStream mem = new MemoryStream(membytes);
|
||||
mem.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
// Get a reader for the data
|
||||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
|
||||
IImageReader reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
|
||||
if(reader is UnknownImageReader)
|
||||
{
|
||||
//mxd. Probably that's a flat?..
|
||||
if (General.Map.Config.MixTexturesFlats)
|
||||
if(General.Map.Config.MixTexturesFlats)
|
||||
{
|
||||
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMFLAT, General.Map.Data.Palette);
|
||||
}
|
||||
if (reader is UnknownImageReader)
|
||||
if(reader is UnknownImageReader)
|
||||
{
|
||||
// Data is in an unknown format!
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'. Does this lump contain valid picture data at all?");
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(flatranges.Count > 0)
|
||||
{
|
||||
//add range before the first flatrange
|
||||
if (flatranges[0].start > 0)
|
||||
if(flatranges[0].start > 0)
|
||||
{
|
||||
LumpRange range = new LumpRange {start = 0, end = flatranges[0].start - 1};
|
||||
invertedflatranges.Add(range);
|
||||
|
@ -205,7 +205,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
else
|
||||
{
|
||||
//mxd
|
||||
if (!failedrangestarts.ContainsKey(startindex))
|
||||
if(!failedrangestarts.ContainsKey(startindex))
|
||||
{
|
||||
failedranges.Add(range, new KeyValuePair<string, string>(rangestart, rangeend)); //mxd
|
||||
failedrangestarts.Add(startindex, false);
|
||||
|
@ -218,7 +218,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
//mxd. Display warnings for unclosed ranges
|
||||
foreach (KeyValuePair<LumpRange, KeyValuePair<string, string>> group in failedranges)
|
||||
foreach(KeyValuePair<LumpRange, KeyValuePair<string, string>> group in failedranges)
|
||||
{
|
||||
if(successfulrangestarts.ContainsKey(group.Key.start)) continue;
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "'" + group.Value.Key + "' range at index " + group.Key.start + " is not closed in '" + location.location + "' ('" + group.Value.Value + "' marker is missing)!");
|
||||
|
@ -249,7 +249,6 @@ namespace CodeImp.DoomBuilder.Data
|
|||
public override ICollection<ImageData> LoadColormaps()
|
||||
{
|
||||
List<ImageData> images = new List<ImageData>();
|
||||
string rangestart, rangeend;
|
||||
|
||||
// Error when suspended
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
@ -258,8 +257,8 @@ namespace CodeImp.DoomBuilder.Data
|
|||
foreach(DictionaryEntry r in General.Map.Config.ColormapRanges)
|
||||
{
|
||||
// Read start and end
|
||||
rangestart = General.Map.Config.ReadSetting("colormaps." + r.Key + ".start", "");
|
||||
rangeend = General.Map.Config.ReadSetting("colormaps." + r.Key + ".end", "");
|
||||
string rangestart = General.Map.Config.ReadSetting("colormaps." + r.Key + ".start", "");
|
||||
string rangeend = General.Map.Config.ReadSetting("colormaps." + r.Key + ".end", "");
|
||||
if((rangestart.Length > 0) && (rangeend.Length > 0))
|
||||
{
|
||||
// Load texture range
|
||||
|
@ -268,8 +267,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// Add images to the container-specific texture set
|
||||
foreach(ImageData img in images)
|
||||
textureset.AddFlat(img);
|
||||
foreach(ImageData img in images) textureset.AddFlat(img);
|
||||
|
||||
// Return result
|
||||
return images;
|
||||
|
@ -542,17 +540,17 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
|
||||
if (!strictpatches)
|
||||
if(!strictpatches)
|
||||
{
|
||||
//mxd. Find the lump anywhere EXCEPT flat ranges (the way it's done in ZDoom)
|
||||
foreach (LumpRange range in invertedflatranges)
|
||||
foreach(LumpRange range in invertedflatranges)
|
||||
{
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
|
||||
// Find the lump anywhere IN flat ranges
|
||||
foreach (LumpRange range in flatranges)
|
||||
foreach(LumpRange range in flatranges)
|
||||
{
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
|
@ -568,12 +566,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Error when suspended
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
if(longname) return null; //mxd
|
||||
Lump lump;
|
||||
|
||||
// Find the lump in ranges
|
||||
foreach(LumpRange range in textureranges)
|
||||
{
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
Lump lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
|
||||
|
@ -591,8 +588,6 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
List<ImageData> images = new List<ImageData>();
|
||||
FlatImage image;
|
||||
|
||||
foreach(LumpRange range in flatranges)
|
||||
{
|
||||
if(range.end < range.start + 2) continue;
|
||||
|
@ -600,10 +595,10 @@ namespace CodeImp.DoomBuilder.Data
|
|||
for(int i = range.start + 1; i < range.end; i++)
|
||||
{
|
||||
// Lump not zero-length?
|
||||
if(file.Lumps[i].Length > 0)
|
||||
if(file.Lumps[i].Length > 0)
|
||||
{
|
||||
// Make the image object
|
||||
image = new FlatImage(file.Lumps[i].Name);
|
||||
FlatImage image = new FlatImage(file.Lumps[i].Name);
|
||||
|
||||
// Add image to collection
|
||||
images.Add(image);
|
||||
|
@ -653,12 +648,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Error when suspended
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
if(longname) return null; //mxd
|
||||
Lump lump;
|
||||
|
||||
// Find the lump in ranges
|
||||
foreach(LumpRange range in flatranges)
|
||||
{
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
Lump lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
|
||||
|
@ -713,15 +707,13 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This finds and returns a sprite stream
|
||||
public override Stream GetSpriteData(string pname)
|
||||
{
|
||||
Lump lump;
|
||||
|
||||
// Error when suspended
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
// Find the lump in ranges
|
||||
foreach(LumpRange range in spriteranges)
|
||||
{
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
Lump lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
|
||||
|
@ -731,15 +723,13 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This checks if the given sprite exists
|
||||
public override bool GetSpriteExists(string pname)
|
||||
{
|
||||
Lump lump;
|
||||
|
||||
// Error when suspended
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
// Find the lump in ranges
|
||||
foreach(LumpRange range in spriteranges)
|
||||
{
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
Lump lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return true;
|
||||
}
|
||||
|
||||
|
@ -786,12 +776,10 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Error when suspended
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
Lump lump;
|
||||
|
||||
foreach(LumpRange range in voxelranges)
|
||||
{
|
||||
if(range.start == range.end) continue;
|
||||
lump = file.FindLump(name, range.start, range.end);
|
||||
Lump lump = file.FindLump(name, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
|
||||
|
@ -827,7 +815,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
//mxd
|
||||
public override Dictionary<string, Stream> GetMapinfoData()
|
||||
{
|
||||
if (issuspended) throw new Exception("Data reader is suspended");
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
Dictionary<string, Stream> streams = new Dictionary<string, Stream>(StringComparer.Ordinal);
|
||||
string src = "ZMAPINFO";
|
||||
|
@ -837,7 +825,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
int lumpindex = file.FindLumpIndex(src);
|
||||
|
||||
//then for MAPINFO
|
||||
if (lumpindex == -1)
|
||||
if(lumpindex == -1)
|
||||
{
|
||||
src = "MAPINFO";
|
||||
lumpindex = file.FindLumpIndex(src);
|
||||
|
@ -850,25 +838,25 @@ namespace CodeImp.DoomBuilder.Data
|
|||
//mxd
|
||||
public override Dictionary<string, Stream> GetGldefsData(GameType gameType)
|
||||
{
|
||||
if (issuspended) throw new Exception("Data reader is suspended");
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
Dictionary<string, Stream> streams = new Dictionary<string, Stream>(StringComparer.Ordinal);
|
||||
int lumpindex;
|
||||
|
||||
//try to load game specific GLDEFS first
|
||||
if (gameType != GameType.UNKNOWN)
|
||||
if(gameType != GameType.UNKNOWN)
|
||||
{
|
||||
string lumpName = Gldefs.GLDEFS_LUMPS_PER_GAME[(int)gameType];
|
||||
lumpindex = file.FindLumpIndex(lumpName);
|
||||
|
||||
if (lumpindex != -1)
|
||||
if(lumpindex != -1)
|
||||
streams.Add(lumpName, file.Lumps[lumpindex].Stream);
|
||||
}
|
||||
|
||||
//should be only one entry per wad
|
||||
lumpindex = file.FindLumpIndex("GLDEFS");
|
||||
|
||||
if (lumpindex != -1) streams.Add("GLDEFS", file.Lumps[lumpindex].Stream);
|
||||
if(lumpindex != -1) streams.Add("GLDEFS", file.Lumps[lumpindex].Stream);
|
||||
return streams;
|
||||
}
|
||||
|
||||
|
@ -922,7 +910,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
Lump l = file.FindLump(name);
|
||||
|
||||
if (l != null)
|
||||
if(l != null)
|
||||
{
|
||||
l.Stream.Seek(0, SeekOrigin.Begin);
|
||||
return new MemoryStream(l.Stream.ReadAllBytes());
|
||||
|
|
|
@ -521,8 +521,6 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Mouse moved inside the display
|
||||
public override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
Vector2D delta;
|
||||
|
||||
// Record last position
|
||||
mouseinside = true;
|
||||
mouselastpos = mousepos;
|
||||
|
@ -540,7 +538,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
if(mousedragging == MouseButtons.None)
|
||||
{
|
||||
// Check if moved enough pixels for dragging
|
||||
delta = mousedownpos - mousepos;
|
||||
Vector2D delta = mousedownpos - mousepos;
|
||||
if((Math.Abs(delta.x) > DRAG_START_MOVE_PIXELS) ||
|
||||
(Math.Abs(delta.y) > DRAG_START_MOVE_PIXELS))
|
||||
{
|
||||
|
@ -555,7 +553,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
if(selecting) OnUpdateMultiSelection();
|
||||
|
||||
// Panning?
|
||||
if (panning) OnUpdateViewPanning();
|
||||
if(panning) OnUpdateViewPanning();
|
||||
|
||||
// Let the base class know
|
||||
base.OnMouseMove(e);
|
||||
|
@ -667,12 +665,12 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
//find Single Player Start. Should be type 1 in all games
|
||||
Thing start = null;
|
||||
|
||||
foreach (Thing t in General.Map.Map.Things)
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
{
|
||||
if (t.Type == 1)
|
||||
if(t.Type == 1)
|
||||
{
|
||||
//store thing and position
|
||||
if (start == null)
|
||||
if(start == null)
|
||||
{
|
||||
start = t;
|
||||
}
|
||||
|
@ -684,7 +682,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
}
|
||||
|
||||
if (start == null)
|
||||
if(start == null)
|
||||
{
|
||||
General.MainWindow.DisplayStatus(StatusType.Warning, "Can't test from current position: no Player 1 start found!");
|
||||
return false;
|
||||
|
@ -700,7 +698,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
|
||||
//41 = player's height in Doom. Is that so in all other games as well?
|
||||
if (s.CeilHeight - s.FloorHeight < 41)
|
||||
if(s.CeilHeight - s.FloorHeight < 41)
|
||||
{
|
||||
General.MainWindow.DisplayStatus(StatusType.Warning, "Can't test from current position: sector is too low!");
|
||||
return false;
|
||||
|
@ -719,7 +717,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
|
||||
public override void OnMapTestEnd(bool testFromCurrentPosition)
|
||||
{
|
||||
if (testFromCurrentPosition)
|
||||
if(testFromCurrentPosition)
|
||||
{
|
||||
//restore position
|
||||
playerStart.Move(playerStartPosition);
|
||||
|
@ -919,7 +917,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
{
|
||||
//show form...
|
||||
CenterOnCoordinatesForm form = new CenterOnCoordinatesForm();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if(form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//center view
|
||||
renderer2d.PositionView(form.Coordinates.x, form.Coordinates.y);
|
||||
|
|
|
@ -330,7 +330,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
totalpasted += General.Map.Map.GetMarkedSectors(true).Count;
|
||||
if(totalpasted > 0)
|
||||
{
|
||||
foreach (Thing t in things) t.UpdateConfiguration(); //mxd
|
||||
foreach(Thing t in things) t.UpdateConfiguration(); //mxd
|
||||
General.Map.ThingsFilter.Update();
|
||||
General.Editing.Mode.OnPasteEnd(options.Copy());
|
||||
General.Plugins.OnPasteEnd(options);
|
||||
|
|
|
@ -255,11 +255,11 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
Vector2D sv = new Vector2D((float)Math.Round(v.x * gridsizeinv) * gridsize,
|
||||
(float)Math.Round(v.y * gridsizeinv) * gridsize);
|
||||
|
||||
if (sv.x < General.Map.Config.LeftBoundary) sv.x = General.Map.Config.LeftBoundary;
|
||||
else if (sv.x > General.Map.Config.RightBoundary) sv.x = General.Map.Config.RightBoundary;
|
||||
if(sv.x < General.Map.Config.LeftBoundary) sv.x = General.Map.Config.LeftBoundary;
|
||||
else if(sv.x > General.Map.Config.RightBoundary) sv.x = General.Map.Config.RightBoundary;
|
||||
|
||||
if (sv.y > General.Map.Config.TopBoundary) sv.y = General.Map.Config.TopBoundary;
|
||||
else if (sv.y < General.Map.Config.BottomBoundary) sv.y = General.Map.Config.BottomBoundary;
|
||||
if(sv.y > General.Map.Config.TopBoundary) sv.y = General.Map.Config.TopBoundary;
|
||||
else if(sv.y < General.Map.Config.BottomBoundary) sv.y = General.Map.Config.BottomBoundary;
|
||||
|
||||
return sv;
|
||||
}
|
||||
|
|
|
@ -249,13 +249,11 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// This checks and removes a level when the limit is reached
|
||||
private static void LimitUndoRedoLevel(List<UndoSnapshot> list)
|
||||
{
|
||||
UndoSnapshot u;
|
||||
|
||||
// Too many?
|
||||
if(list.Count > MAX_UNDO_LEVELS)
|
||||
{
|
||||
// Remove one and dispose map
|
||||
u = list[list.Count - 1];
|
||||
UndoSnapshot u = list[list.Count - 1];
|
||||
u.Dispose();
|
||||
list.RemoveAt(list.Count - 1);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
public int Angle { get { return (angle == NO_ANGLE ? NO_ANGLE : angle - angleoffset); } set { angle = (value == NO_ANGLE ? NO_ANGLE : value + angleoffset); this.Refresh(); } }
|
||||
public int AngleOffset { get { return angleoffset; } set { angleoffset = value; this.Refresh(); } }
|
||||
public static int NO_ANGLE = int.MinValue;
|
||||
public const int NO_ANGLE = int.MinValue;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -112,7 +112,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
SolidBrush fill;
|
||||
Brush center;
|
||||
|
||||
if (this.Enabled)
|
||||
if(this.Enabled)
|
||||
{
|
||||
outline = new Pen(outlineColor, 2.0f);
|
||||
fill = new SolidBrush(fillColor);
|
||||
|
@ -169,7 +169,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
int thisAngle = XYToDegrees(new Point(e.X, e.Y), origin);
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
if(e.Button == MouseButtons.Left)
|
||||
{
|
||||
thisAngle = (int)Math.Round(thisAngle / 45f) * 45;
|
||||
if(thisAngle == 360) thisAngle = 0;
|
||||
|
@ -185,7 +185,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
private void AngleSelector_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
|
||||
if(e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
|
||||
{
|
||||
int thisAngle = XYToDegrees(new Point(e.X, e.Y), origin);
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
protected void OnAfterDeselect(TreeNode tn)
|
||||
{
|
||||
if (AfterDeselect != null)
|
||||
if(AfterDeselect != null)
|
||||
{
|
||||
AfterDeselect(this, new TreeViewEventArgs(tn));
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
protected void OnBeforeDeselect(TreeNode tn)
|
||||
{
|
||||
if (BeforeDeselect != null)
|
||||
if(BeforeDeselect != null)
|
||||
{
|
||||
BeforeDeselect(this, new TreeViewEventArgs(tn));
|
||||
}
|
||||
|
@ -152,8 +152,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
protected void OnSelectionsChanged()
|
||||
{
|
||||
if (blnSelectionChanged)
|
||||
if (SelectionsChanged != null)
|
||||
if(blnSelectionChanged)
|
||||
if(SelectionsChanged != null)
|
||||
{
|
||||
SelectionsChanged(this, new EventArgs());
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
if (!blnInternalCall)
|
||||
if(!blnInternalCall)
|
||||
{
|
||||
throw new NotSupportedException("Use SelectedNodes instead of SelectedNode.");
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
}
|
||||
set
|
||||
{
|
||||
if (!blnInternalCall)
|
||||
if(!blnInternalCall)
|
||||
{
|
||||
throw new NotSupportedException("Use SelectedNodes instead of SelectedNode.");
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
// Create a SelectedNodesCollection to return, and add event handlers to catch actions on it
|
||||
NodesCollection selectedNodesCollection = new NodesCollection();
|
||||
foreach (TreeNode tn in htblSelectedNodes.Values)
|
||||
foreach(TreeNode tn in htblSelectedNodes.Values)
|
||||
{
|
||||
selectedNodesCollection.Add(tn);
|
||||
}
|
||||
|
@ -404,16 +404,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
// First, build list of nodes that need to be unselected
|
||||
List<TreeNode> arrNodesToDeselect = new List<TreeNode>(); //mxd
|
||||
foreach (TreeNode selectedTreeNode in htblSelectedNodes.Values)
|
||||
foreach(TreeNode selectedTreeNode in htblSelectedNodes.Values)
|
||||
{
|
||||
if (GetNodeLevel(selectedTreeNode) != level)
|
||||
if(GetNodeLevel(selectedTreeNode) != level)
|
||||
{
|
||||
arrNodesToDeselect.Add(selectedTreeNode);
|
||||
}
|
||||
}
|
||||
|
||||
// Do the actual unselect
|
||||
foreach (TreeNode tnToDeselect in arrNodesToDeselect)
|
||||
foreach(TreeNode tnToDeselect in arrNodesToDeselect)
|
||||
{
|
||||
SelectNode(tnToDeselect, false, tva);
|
||||
}
|
||||
|
@ -428,16 +428,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
// First, build list of nodes that need to be unselected
|
||||
List<TreeNode> arrNodesToDeselect = new List<TreeNode>(); //mxd
|
||||
foreach (TreeNode selectedTreeNode in htblSelectedNodes.Values)
|
||||
foreach(TreeNode selectedTreeNode in htblSelectedNodes.Values)
|
||||
{
|
||||
if (selectedTreeNode.Parent != parent)
|
||||
if(selectedTreeNode.Parent != parent)
|
||||
{
|
||||
arrNodesToDeselect.Add(selectedTreeNode);
|
||||
}
|
||||
}
|
||||
|
||||
// Do the actual unselect
|
||||
foreach (TreeNode tnToDeselect in arrNodesToDeselect)
|
||||
foreach(TreeNode tnToDeselect in arrNodesToDeselect)
|
||||
{
|
||||
SelectNode(tnToDeselect, false, tva);
|
||||
}
|
||||
|
@ -452,16 +452,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
// First, build list of nodes that need to be unselected
|
||||
List<TreeNode> arrNodesToDeselect = new List<TreeNode>(); //mxd
|
||||
foreach (TreeNode selectedTreeNode in htblSelectedNodes.Values)
|
||||
foreach(TreeNode selectedTreeNode in htblSelectedNodes.Values)
|
||||
{
|
||||
if (!IsChildOf(selectedTreeNode, parent))
|
||||
if(!IsChildOf(selectedTreeNode, parent))
|
||||
{
|
||||
arrNodesToDeselect.Add(selectedTreeNode);
|
||||
}
|
||||
}
|
||||
|
||||
// Do the actual unselect
|
||||
foreach (TreeNode tnToDeselect in arrNodesToDeselect)
|
||||
foreach(TreeNode tnToDeselect in arrNodesToDeselect)
|
||||
{
|
||||
SelectNode(tnToDeselect, false, tva);
|
||||
}
|
||||
|
@ -476,20 +476,20 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
// First, build list of nodes that need to be unselected
|
||||
List<TreeNode> arrNodesToDeselect = new List<TreeNode>(); //mxd
|
||||
foreach (TreeNode selectedTreeNode in htblSelectedNodes.Values)
|
||||
foreach(TreeNode selectedTreeNode in htblSelectedNodes.Values)
|
||||
{
|
||||
if (nodeKeepSelected == null)
|
||||
if(nodeKeepSelected == null)
|
||||
{
|
||||
arrNodesToDeselect.Add(selectedTreeNode);
|
||||
}
|
||||
else if ((nodeKeepSelected != null) && (selectedTreeNode != nodeKeepSelected))
|
||||
else if((nodeKeepSelected != null) && (selectedTreeNode != nodeKeepSelected))
|
||||
{
|
||||
arrNodesToDeselect.Add(selectedTreeNode);
|
||||
}
|
||||
}
|
||||
|
||||
// Do the actual unselect
|
||||
foreach (TreeNode tnToDeselect in arrNodesToDeselect)
|
||||
foreach(TreeNode tnToDeselect in arrNodesToDeselect)
|
||||
{
|
||||
SelectNode(tnToDeselect, false, tva);
|
||||
}
|
||||
|
@ -514,16 +514,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
/// <returns>True if specified node is selected, false if not.</returns>
|
||||
private bool IsNodeSelected(TreeNode tn)
|
||||
{
|
||||
if (tn != null)
|
||||
if(tn != null)
|
||||
return htblSelectedNodes.ContainsKey(tn.GetHashCode());
|
||||
return false;
|
||||
}
|
||||
|
||||
private void PreserveNodeColors(TreeNode tn)
|
||||
{
|
||||
if (tn == null) return;
|
||||
if(tn == null) return;
|
||||
|
||||
if (htblSelectedNodesOrigColors.ContainsKey(tn.GetHashCode()))
|
||||
if(htblSelectedNodesOrigColors.ContainsKey(tn.GetHashCode()))
|
||||
{
|
||||
// Color[] color = (Color[])htblSelectedNodesOrigColors[tn.GetHashCode()];
|
||||
// color[0]=tn.BackColor;
|
||||
|
@ -531,7 +531,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
htblSelectedNodesOrigColors.Add(tn.GetHashCode(), new Color[] { tn.BackColor, tn.ForeColor });
|
||||
htblSelectedNodesOrigColors.Add(tn.GetHashCode(), new[] { tn.BackColor, tn.ForeColor });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,18 +546,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
bool blnSelected = false;
|
||||
|
||||
if (tn == null)
|
||||
if(tn == null)
|
||||
return false;
|
||||
|
||||
if (select)
|
||||
if(select)
|
||||
{
|
||||
// Only try to select node if it was not already selected
|
||||
if (!IsNodeSelected(tn))
|
||||
if(!IsNodeSelected(tn))
|
||||
{
|
||||
// Check if node selection is cancelled
|
||||
TreeViewCancelEventArgs tvcea = new TreeViewCancelEventArgs(tn, false, tva);
|
||||
base.OnBeforeSelect(tvcea);
|
||||
if (tvcea.Cancel)
|
||||
if(tvcea.Cancel)
|
||||
{
|
||||
// This node selection was cancelled!
|
||||
return false;
|
||||
|
@ -580,12 +580,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
else
|
||||
{
|
||||
// Only unselect node if it was selected
|
||||
if (IsNodeSelected(tn))
|
||||
if(IsNodeSelected(tn))
|
||||
{
|
||||
OnBeforeDeselect(tn);
|
||||
|
||||
Color[] originalColors = (Color[])this.htblSelectedNodesOrigColors[tn.GetHashCode()];
|
||||
if (originalColors != null)
|
||||
if(originalColors != null)
|
||||
{
|
||||
htblSelectedNodes.Remove(tn.GetHashCode());
|
||||
blnSelectionChanged = true;
|
||||
|
@ -612,9 +612,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
private void SelectNodesInsideRange(TreeNode startNode, TreeNode endNode, TreeViewAction tva)
|
||||
{
|
||||
// Calculate start node and end node
|
||||
TreeNode firstNode = null;
|
||||
TreeNode lastNode = null;
|
||||
if (startNode.Bounds.Y < endNode.Bounds.Y)
|
||||
TreeNode firstNode, lastNode;
|
||||
if(startNode.Bounds.Y < endNode.Bounds.Y)
|
||||
{
|
||||
firstNode = startNode;
|
||||
lastNode = endNode;
|
||||
|
@ -628,10 +627,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
// Select each node in range
|
||||
SelectNode(firstNode, true, tva);
|
||||
TreeNode tnTemp = firstNode;
|
||||
while (tnTemp != lastNode)
|
||||
while(tnTemp != lastNode)
|
||||
{
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -648,9 +647,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
private void UnselectNodesOutsideRange(TreeNode startNode, TreeNode endNode, TreeViewAction tva)
|
||||
{
|
||||
// Calculate start node and end node
|
||||
TreeNode firstNode = null;
|
||||
TreeNode lastNode = null;
|
||||
if (startNode.Bounds.Y < endNode.Bounds.Y)
|
||||
TreeNode firstNode, lastNode;
|
||||
if(startNode.Bounds.Y < endNode.Bounds.Y)
|
||||
{
|
||||
firstNode = startNode;
|
||||
lastNode = endNode;
|
||||
|
@ -663,20 +661,20 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
// Unselect each node outside range
|
||||
TreeNode tnTemp = firstNode;
|
||||
while (tnTemp != null)
|
||||
while(tnTemp != null)
|
||||
{
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
SelectNode(tnTemp, false, tva);
|
||||
}
|
||||
}
|
||||
|
||||
tnTemp = lastNode;
|
||||
while (tnTemp != null)
|
||||
while(tnTemp != null)
|
||||
{
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
SelectNode(tnTemp, false, tva);
|
||||
}
|
||||
|
@ -691,7 +689,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
private void UnselectNodesRecursively(TreeNode tn, TreeViewAction tva)
|
||||
{
|
||||
SelectNode(tn, false, tva);
|
||||
foreach (TreeNode child in tn.Nodes)
|
||||
foreach(TreeNode child in tn.Nodes)
|
||||
{
|
||||
UnselectNodesRecursively(child, tva);
|
||||
}
|
||||
|
@ -709,7 +707,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
/// <returns>True is mouse was clicked inside the node bounds, false if it was clicked ouside the node bounds.</returns>
|
||||
private static bool IsClickOnNode(TreeNode tn, MouseEventArgs e)
|
||||
{
|
||||
if (tn == null) return false;
|
||||
if(tn == null) return false;
|
||||
|
||||
// GKM
|
||||
// Determine the rightmost position we'll process clicks (so that the click has to be on the node's bounds,
|
||||
|
@ -726,7 +724,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
public int GetNodeLevel(TreeNode node)
|
||||
{
|
||||
int level = 0;
|
||||
while ((node = node.Parent) != null)
|
||||
while((node = node.Parent) != null)
|
||||
level++;
|
||||
return level;
|
||||
}
|
||||
|
@ -742,9 +740,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
bool blnChild = false;
|
||||
|
||||
TreeNode tnTemp = child;
|
||||
while (tnTemp != null)
|
||||
while(tnTemp != null)
|
||||
{
|
||||
if (tnTemp == parent)
|
||||
if(tnTemp == parent)
|
||||
{
|
||||
blnChild = true;
|
||||
break;
|
||||
|
@ -767,7 +765,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
TreeNode tnParent = child;
|
||||
|
||||
while (tnParent.Parent != null)
|
||||
while(tnParent.Parent != null)
|
||||
{
|
||||
tnParent = tnParent.Parent;
|
||||
}
|
||||
|
@ -785,9 +783,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
TreeNode tnTemp = this.Nodes[0];
|
||||
|
||||
while (tnTemp != null)
|
||||
while(tnTemp != null)
|
||||
{
|
||||
if (tnTemp.IsVisible)
|
||||
if(tnTemp.IsVisible)
|
||||
{
|
||||
intCounter++;
|
||||
}
|
||||
|
@ -806,7 +804,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
TreeNode tnTemp = this.Nodes[0];
|
||||
|
||||
while (tnTemp.NextVisibleNode != null)
|
||||
while(tnTemp.NextVisibleNode != null)
|
||||
{
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
}
|
||||
|
@ -825,18 +823,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
int intCounter = 0;
|
||||
TreeNode tnTemp = start;
|
||||
while (intCounter < intNumber)
|
||||
while(intCounter < intNumber)
|
||||
{
|
||||
if (down)
|
||||
if(down)
|
||||
{
|
||||
if (tnTemp.NextVisibleNode != null)
|
||||
if(tnTemp.NextVisibleNode != null)
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tnTemp.PrevVisibleNode != null)
|
||||
if(tnTemp.PrevVisibleNode != null)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
break;
|
||||
|
@ -857,18 +855,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
Graphics g = this.CreateGraphics();
|
||||
Rectangle rect = new Rectangle(tn.Bounds.X, tn.Bounds.Y, tn.Bounds.Width, tn.Bounds.Height);
|
||||
if (visible)
|
||||
if(visible)
|
||||
{
|
||||
this.Invalidate(rect, false);
|
||||
Update();
|
||||
if (tn.BackColor != SelectionBackColor)
|
||||
if(tn.BackColor != SelectionBackColor)
|
||||
{
|
||||
using(Pen p = new Pen(SelectionBackColor, 1)) g.DrawRectangle(p, rect);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tn.BackColor != SelectionBackColor)
|
||||
if(tn.BackColor != SelectionBackColor)
|
||||
{
|
||||
using (Pen p = new Pen(BackColor, 1))
|
||||
{
|
||||
|
@ -889,9 +887,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
if(disposing)
|
||||
{
|
||||
if (components != null)
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
|
@ -928,7 +926,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
try
|
||||
{
|
||||
#endif
|
||||
if (!this.blnNodeProcessedOnMouseDown)
|
||||
if(!this.blnNodeProcessedOnMouseDown)
|
||||
{
|
||||
TreeNode tn = this.GetNodeAt(e.X, e.Y);
|
||||
|
||||
|
@ -936,7 +934,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
// a selected node was clicked again; in that case we handle that click here because in case the
|
||||
// user is dragging the node, we should not put it in edit mode.
|
||||
|
||||
if (IsClickOnNode(tn, e))
|
||||
if(IsClickOnNode(tn, e))
|
||||
{
|
||||
this.ProcessNodeRange(this.tnMostRecentSelectedNode, tn, e, Control.ModifierKeys, TreeViewAction.ByMouse, true);
|
||||
}
|
||||
|
@ -978,19 +976,19 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
TreeNode tn = this.GetNodeAt(e.X, e.Y);
|
||||
|
||||
if (tn == null) return;
|
||||
if(tn == null) return;
|
||||
|
||||
// Preserve colors here, because if you do it later then it will already have selected colors
|
||||
// Don't know why...!
|
||||
PreserveNodeColors(tn);
|
||||
|
||||
// If +/- was clicked, we should not process the node.
|
||||
if (!IsPlusMinusClicked(tn, e))
|
||||
if(!IsPlusMinusClicked(tn, e))
|
||||
{
|
||||
// If mouse down on a node that is already selected, then we should process this node in the mouse up event, because we
|
||||
// might want to drag it and it should not be put in edit mode.
|
||||
// Also, only process node if click was in node's bounds.
|
||||
if ((tn != null) && (IsClickOnNode(tn, e)) && (!IsNodeSelected(tn)))
|
||||
if((tn != null) && (IsClickOnNode(tn, e)) && (!IsNodeSelected(tn)))
|
||||
{
|
||||
// Flash node. In case the node selection is cancelled by the user, this gives the effect that it
|
||||
// was selected and unselected again.
|
||||
|
@ -1016,7 +1014,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
/// </summary>
|
||||
private void FlashNode()
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
if(this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(FlashNode));
|
||||
return;
|
||||
|
@ -1024,7 +1022,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
TreeNode tn = tnToFlash;
|
||||
// Only flash node is it's not yet selected
|
||||
if (!IsNodeSelected(tn))
|
||||
if(!IsNodeSelected(tn))
|
||||
{
|
||||
tn.BackColor = SelectionBackColor;
|
||||
tn.ForeColor = this.BackColor;
|
||||
|
@ -1035,7 +1033,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
}
|
||||
|
||||
// If node is not selected yet, restore default colors to end flashing
|
||||
if (!IsNodeSelected(tn))
|
||||
if(!IsNodeSelected(tn))
|
||||
{
|
||||
tn.BackColor = BackColor;
|
||||
tn.ForeColor = this.ForeColor;
|
||||
|
@ -1048,7 +1046,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
private void StartEdit()
|
||||
{
|
||||
System.Threading.Thread.Sleep(200);
|
||||
if (!blnWasDoubleClick)
|
||||
if(!blnWasDoubleClick)
|
||||
{
|
||||
blnInternalCall = true;
|
||||
SelectedNode = tnNodeToStartEditOn;
|
||||
|
@ -1078,27 +1076,27 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
blnSelectionChanged = false; // prepare for OnSelectionsChanged
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
if(e.Button == MouseButtons.Left)
|
||||
{
|
||||
blnWasDoubleClick = (intMouseClicks == 2);
|
||||
|
||||
TreeNode tnTemp;
|
||||
int intNodeLevelStart;
|
||||
|
||||
if (((keys & Keys.Control) == 0) && ((keys & Keys.Shift) == 0))
|
||||
if(((keys & Keys.Control) == 0) && ((keys & Keys.Shift) == 0))
|
||||
{
|
||||
// CTRL and SHIFT not held down
|
||||
tnSelectionMirrorPoint = endNode;
|
||||
int intNumberOfSelectedNodes = SelectedNodes.Count;
|
||||
|
||||
// If it was a double click, select node and suspend further processing
|
||||
if (blnWasDoubleClick)
|
||||
if(blnWasDoubleClick)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsPlusMinusClicked(endNode, e))
|
||||
if(!IsPlusMinusClicked(endNode, e))
|
||||
{
|
||||
bool blnNodeWasSelected = IsNodeSelected(endNode);
|
||||
|
||||
|
@ -1106,7 +1104,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
SelectNode(endNode, true, tva);
|
||||
|
||||
|
||||
if ((blnNodeWasSelected) && (LabelEdit) && (allowStartEdit) && (!blnWasDoubleClick) && (intNumberOfSelectedNodes <= 1))
|
||||
if((blnNodeWasSelected) && (LabelEdit) && (allowStartEdit) && (!blnWasDoubleClick) && (intNumberOfSelectedNodes <= 1))
|
||||
{
|
||||
// Node should be put in edit mode
|
||||
tnNodeToStartEditOn = endNode;
|
||||
|
@ -1115,14 +1113,14 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (((keys & Keys.Control) != 0) && ((keys & Keys.Shift) == 0))
|
||||
else if(((keys & Keys.Control) != 0) && ((keys & Keys.Shift) == 0))
|
||||
{
|
||||
// CTRL held down
|
||||
tnSelectionMirrorPoint = null;
|
||||
|
||||
if (!IsNodeSelected(endNode))
|
||||
if(!IsNodeSelected(endNode))
|
||||
{
|
||||
switch (selectionMode)
|
||||
switch(selectionMode)
|
||||
{
|
||||
case TreeViewSelectionMode.SingleSelect:
|
||||
UnselectAllNodesExceptNode(endNode, tva);
|
||||
|
@ -1156,15 +1154,15 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
SelectNode(endNode, false, tva);
|
||||
}
|
||||
}
|
||||
else if (((keys & Keys.Control) == 0) && ((keys & Keys.Shift) != 0))
|
||||
else if(((keys & Keys.Control) == 0) && ((keys & Keys.Shift) != 0))
|
||||
{
|
||||
// SHIFT pressed
|
||||
if (tnSelectionMirrorPoint == null)
|
||||
if(tnSelectionMirrorPoint == null)
|
||||
{
|
||||
tnSelectionMirrorPoint = startNode;
|
||||
}
|
||||
|
||||
switch (selectionMode)
|
||||
switch(selectionMode)
|
||||
{
|
||||
case TreeViewSelectionMode.SingleSelect:
|
||||
UnselectAllNodesExceptNode(endNode, tva);
|
||||
|
@ -1175,16 +1173,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
TreeNode tnAbsoluteParentStartNode = GetRootParent(startNode);
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
TreeNode tnAbsoluteParent = GetRootParent(tnTemp);
|
||||
if (tnAbsoluteParent == tnAbsoluteParentStartNode)
|
||||
if(tnAbsoluteParent == tnAbsoluteParentStartNode)
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1198,16 +1196,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
intNodeLevelStart = GetNodeLevel(startNode);
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
int intNodeLevel = GetNodeLevel(tnTemp);
|
||||
if (intNodeLevel == intNodeLevelStart)
|
||||
if(intNodeLevel == intNodeLevelStart)
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1222,17 +1220,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
intNodeLevelStart = GetNodeLevel(startNode);
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
int intNodeLevel = GetNodeLevel(tnTemp);
|
||||
TreeNode tnAbsoluteParent = GetRootParent(tnTemp);
|
||||
if ((intNodeLevel == intNodeLevelStart) && (tnAbsoluteParent == tnAbsoluteParentStart))
|
||||
if((intNodeLevel == intNodeLevelStart) && (tnAbsoluteParent == tnAbsoluteParentStart))
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1252,16 +1250,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
TreeNode tnParentStartNode = startNode.Parent;
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
TreeNode tnParent = tnTemp.Parent;
|
||||
if (tnParent == tnParentStartNode)
|
||||
if(tnParent == tnParentStartNode)
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1272,10 +1270,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (((keys & Keys.Control) != 0) && ((keys & Keys.Shift) != 0))
|
||||
else if(((keys & Keys.Control) != 0) && ((keys & Keys.Shift) != 0))
|
||||
{
|
||||
// SHIFT AND CTRL pressed
|
||||
switch (selectionMode)
|
||||
switch(selectionMode)
|
||||
{
|
||||
case TreeViewSelectionMode.SingleSelect:
|
||||
UnselectAllNodesExceptNode(endNode, tva);
|
||||
|
@ -1286,16 +1284,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
TreeNode tnAbsoluteParentStartNode = GetRootParent(startNode);
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
TreeNode tnAbsoluteParent = GetRootParent(tnTemp);
|
||||
if (tnAbsoluteParent == tnAbsoluteParentStartNode)
|
||||
if(tnAbsoluteParent == tnAbsoluteParentStartNode)
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1308,16 +1306,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
intNodeLevelStart = GetNodeLevel(startNode);
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
int intNodeLevel = GetNodeLevel(tnTemp);
|
||||
if (intNodeLevel == intNodeLevelStart)
|
||||
if(intNodeLevel == intNodeLevelStart)
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1331,17 +1329,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
intNodeLevelStart = GetNodeLevel(startNode);
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
int intNodeLevel = GetNodeLevel(tnTemp);
|
||||
TreeNode tnAbsoluteParent = GetRootParent(tnTemp);
|
||||
if ((intNodeLevel == intNodeLevelStart) && (tnAbsoluteParent == tnAbsoluteParentStart))
|
||||
if((intNodeLevel == intNodeLevelStart) && (tnAbsoluteParent == tnAbsoluteParentStart))
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1354,13 +1352,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
case TreeViewSelectionMode.MultiSelect:
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1371,16 +1369,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
TreeNode tnParentStartNode = startNode.Parent;
|
||||
tnTemp = startNode;
|
||||
// Check each visible node from startNode to endNode and select it if needed
|
||||
while ((tnTemp != null) && (tnTemp != endNode))
|
||||
while((tnTemp != null) && (tnTemp != endNode))
|
||||
{
|
||||
if (startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
if(startNode.Bounds.Y > endNode.Bounds.Y)
|
||||
tnTemp = tnTemp.PrevVisibleNode;
|
||||
else
|
||||
tnTemp = tnTemp.NextVisibleNode;
|
||||
if (tnTemp != null)
|
||||
if(tnTemp != null)
|
||||
{
|
||||
TreeNode tnParent = tnTemp.Parent;
|
||||
if (tnParent == tnParentStartNode)
|
||||
if(tnParent == tnParentStartNode)
|
||||
{
|
||||
SelectNode(tnTemp, true, tva);
|
||||
}
|
||||
|
@ -1391,10 +1389,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
else if(e.Button == MouseButtons.Right)
|
||||
{
|
||||
// if right mouse button clicked, clear selection and select right-clicked node
|
||||
if (!IsNodeSelected(endNode))
|
||||
if(!IsNodeSelected(endNode))
|
||||
{
|
||||
UnselectAllNodes(tva);
|
||||
SelectNode(endNode, true, tva);
|
||||
|
@ -1435,13 +1433,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
Keys kMod = Keys.None;
|
||||
switch (e.Modifiers)
|
||||
switch(e.Modifiers)
|
||||
{
|
||||
case Keys.Shift:
|
||||
case Keys.Control:
|
||||
case Keys.Control | Keys.Shift:
|
||||
kMod = Keys.Shift;
|
||||
if (tnKeysStartNode == null)
|
||||
if(tnKeysStartNode == null)
|
||||
tnKeysStartNode = tnMostRecentSelectedNode;
|
||||
break;
|
||||
default:
|
||||
|
@ -1452,7 +1450,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
int intNumber = 0;
|
||||
|
||||
TreeNode tnNewlySelectedNodeWithKeys = null;
|
||||
switch (e.KeyCode)
|
||||
switch(e.KeyCode)
|
||||
{
|
||||
case Keys.Down:
|
||||
tnNewlySelectedNodeWithKeys = tnMostRecentSelectedNode.NextVisibleNode;
|
||||
|
@ -1463,17 +1461,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
break;
|
||||
|
||||
case Keys.Left:
|
||||
if (tnMostRecentSelectedNode.IsExpanded)
|
||||
if(tnMostRecentSelectedNode.IsExpanded)
|
||||
tnMostRecentSelectedNode.Collapse();
|
||||
else
|
||||
tnNewlySelectedNodeWithKeys = tnMostRecentSelectedNode.Parent;
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
if (!tnMostRecentSelectedNode.IsExpanded)
|
||||
if(!tnMostRecentSelectedNode.IsExpanded)
|
||||
tnMostRecentSelectedNode.Expand();
|
||||
else
|
||||
if (tnMostRecentSelectedNode.Nodes != null)
|
||||
if(tnMostRecentSelectedNode.Nodes != null)
|
||||
tnNewlySelectedNodeWithKeys = tnMostRecentSelectedNode.Nodes[0];
|
||||
break;
|
||||
|
||||
|
@ -1502,7 +1500,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
return;
|
||||
}
|
||||
|
||||
if ((tnNewlySelectedNodeWithKeys != null))
|
||||
if((tnNewlySelectedNodeWithKeys != null))
|
||||
{
|
||||
SetFocusToNode(tnMostRecentSelectedNode, false);
|
||||
ProcessNodeRange(tnKeysStartNode, tnNewlySelectedNodeWithKeys, new MouseEventArgs(MouseButtons.Left, 1, Cursor.Position.X, Cursor.Position.Y, 0), kMod, TreeViewAction.ByKeyboard, false);
|
||||
|
@ -1511,10 +1509,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
}
|
||||
|
||||
// Ensure visibility
|
||||
if (tnMostRecentSelectedNode != null)
|
||||
if(tnMostRecentSelectedNode != null)
|
||||
{
|
||||
TreeNode tnToMakeVisible = null;
|
||||
switch (e.KeyCode)
|
||||
switch(e.KeyCode)
|
||||
{
|
||||
case Keys.Down:
|
||||
case Keys.Right:
|
||||
|
@ -1540,7 +1538,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
break;
|
||||
}
|
||||
|
||||
if (tnToMakeVisible != null)
|
||||
if(tnToMakeVisible != null)
|
||||
tnToMakeVisible.EnsureVisible();
|
||||
}
|
||||
|
||||
|
@ -1561,16 +1559,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
// All child nodes should be deselected
|
||||
bool blnChildSelected = false;
|
||||
foreach (TreeNode tn in e.Node.Nodes)
|
||||
foreach(TreeNode tn in e.Node.Nodes)
|
||||
{
|
||||
if (IsNodeSelected(tn))
|
||||
if(IsNodeSelected(tn))
|
||||
{
|
||||
blnChildSelected = true;
|
||||
}
|
||||
UnselectNodesRecursively(tn, TreeViewAction.Collapse);
|
||||
}
|
||||
|
||||
if (blnChildSelected)
|
||||
if(blnChildSelected)
|
||||
{
|
||||
SelectNode(e.Node, true, TreeViewAction.Collapse);
|
||||
}
|
||||
|
@ -1646,7 +1644,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
/// <returns>The position into which the new element was inserted.</returns>
|
||||
public int Add(TreeNode treeNode)
|
||||
{
|
||||
if (TreeNodeAdded != null)
|
||||
if(TreeNodeAdded != null)
|
||||
TreeNodeAdded(treeNode);
|
||||
|
||||
return List.Add(treeNode);
|
||||
|
@ -1659,7 +1657,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
/// <param name="treeNode">Tree node to insert.</param>
|
||||
public void Insert(int index, TreeNode treeNode)
|
||||
{
|
||||
if (TreeNodeInserted != null)
|
||||
if(TreeNodeInserted != null)
|
||||
TreeNodeInserted(treeNode);
|
||||
|
||||
List.Add(treeNode);
|
||||
|
@ -1671,7 +1669,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
/// <param name="treeNode">Tree node to remove.</param>
|
||||
public void Remove(TreeNode treeNode)
|
||||
{
|
||||
if (TreeNodeRemoved != null)
|
||||
if(TreeNodeRemoved != null)
|
||||
TreeNodeRemoved(treeNode);
|
||||
|
||||
List.Remove(treeNode);
|
||||
|
@ -1706,7 +1704,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
/// </summary>
|
||||
protected override void OnClear()
|
||||
{
|
||||
if (SelectedNodesCleared != null)
|
||||
if(SelectedNodesCleared != null)
|
||||
SelectedNodesCleared(this, EventArgs.Empty);
|
||||
|
||||
base.OnClear();
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
blockUpdate = true;
|
||||
|
||||
if (first)
|
||||
if(first)
|
||||
{
|
||||
value1.Text = val1.ToString(CultureInfo.CurrentCulture);
|
||||
value2.Text = val2.ToString(CultureInfo.CurrentCulture);
|
||||
|
@ -78,7 +78,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|| value1.GetResultFloat(defaultValue, 0) != defaultValue || value2.GetResultFloat(defaultValue, 0) != defaultValue);
|
||||
bReset.Visible = changed;
|
||||
|
||||
if (!blockUpdate && OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
|
||||
if(!blockUpdate && OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void bReset_Click(object sender, EventArgs e)
|
||||
|
@ -97,9 +97,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
private void value1_WhenTextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (blockUpdate) return;
|
||||
if(blockUpdate) return;
|
||||
|
||||
if (linkValues)
|
||||
if(linkValues)
|
||||
{
|
||||
blockUpdate = true;
|
||||
value2.Text = value1.Text;
|
||||
|
@ -111,9 +111,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
private void value2_WhenTextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (blockUpdate) return;
|
||||
if(blockUpdate) return;
|
||||
|
||||
if (linkValues)
|
||||
if(linkValues)
|
||||
{
|
||||
blockUpdate = true;
|
||||
value1.Text = value2.Text;
|
||||
|
|
|
@ -44,17 +44,17 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
{
|
||||
blockUpdate = true;
|
||||
|
||||
if (first)
|
||||
if(first)
|
||||
{
|
||||
value1.Text = val1.ToString(CultureInfo.InvariantCulture);
|
||||
value2.Text = val2.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value1.Text) && value1.Text != val1.ToString(CultureInfo.InvariantCulture))
|
||||
if(!string.IsNullOrEmpty(value1.Text) && value1.Text != val1.ToString(CultureInfo.InvariantCulture))
|
||||
value1.Text = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(value2.Text) && value2.Text != val2.ToString(CultureInfo.InvariantCulture))
|
||||
if(!string.IsNullOrEmpty(value2.Text) && value2.Text != val2.ToString(CultureInfo.InvariantCulture))
|
||||
value2.Text = string.Empty;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,9 +146,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|||
|
||||
public int GetSmartTag(int original, int offset)
|
||||
{
|
||||
if (!valid) return original;
|
||||
if (rangemode != 0) return tag + offset * rangemode;
|
||||
if (offsetmode != 0) return original + tag * offsetmode;
|
||||
if(!valid) return original;
|
||||
if(rangemode != 0) return tag + offset * rangemode;
|
||||
if(offsetmode != 0) return original + tag * offsetmode;
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
|
||||
public static void UpdateBoundingBoxSizes(ref BoundingBoxSizes bbs, WorldVertex v)
|
||||
{
|
||||
if (v.x < bbs.MinX) bbs.MinX = (int)v.x;
|
||||
if(v.x < bbs.MinX) bbs.MinX = (int)v.x;
|
||||
else if(v.x > bbs.MaxX) bbs.MaxX = (int)v.x;
|
||||
|
||||
if(v.z < bbs.MinZ) bbs.MinZ = (int)v.z;
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
{
|
||||
ThingTypeInfo info = General.Map.Data.GetThingInfoEx(t.Type);
|
||||
if(info == null) continue;
|
||||
switch (info.ClassName.ToLowerInvariant())
|
||||
switch(info.ClassName.ToLowerInvariant())
|
||||
{
|
||||
case "patrolpoint":
|
||||
if(t.Tag != 0 || t.Args[0] != 0)
|
||||
|
|
|
@ -76,8 +76,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
// Clean up
|
||||
if(Model != null)
|
||||
{
|
||||
foreach (Mesh mesh in Model.Meshes) mesh.Dispose();
|
||||
foreach (Texture t in Model.Textures) t.Dispose();
|
||||
foreach(Mesh mesh in Model.Meshes) mesh.Dispose();
|
||||
foreach(Texture t in Model.Textures) t.Dispose();
|
||||
loadstate = ModelLoadState.None;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,29 +53,29 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
|
||||
internal static int SortByIndex(ScriptItem i1, ScriptItem i2)
|
||||
{
|
||||
if (i1.isinclude && !i2.isinclude) return 1;
|
||||
if (!i1.isinclude && i2.isinclude) return -1;
|
||||
if (i1.Index > i2.Index) return 1;
|
||||
if (i1.Index == i2.Index) return 0;
|
||||
if(i1.isinclude && !i2.isinclude) return 1;
|
||||
if(!i1.isinclude && i2.isinclude) return -1;
|
||||
if(i1.Index > i2.Index) return 1;
|
||||
if(i1.Index == i2.Index) return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
internal static int SortByName(ScriptItem i1, ScriptItem i2)
|
||||
{
|
||||
if (i1.isinclude && !i2.isinclude) return 1;
|
||||
if (!i1.isinclude && i2.isinclude) return -1;
|
||||
if(i1.isinclude && !i2.isinclude) return 1;
|
||||
if(!i1.isinclude && i2.isinclude) return -1;
|
||||
|
||||
if (i1.Name == i2.Name) return 0;
|
||||
if (i1.Name.ToUpper()[0] > i2.Name.ToUpper()[0]) return 1;
|
||||
if (i1.Name.ToUpper()[0] == i2.Name.ToUpper()[0])
|
||||
if(i1.Name == i2.Name) return 0;
|
||||
if(i1.Name.ToUpper()[0] > i2.Name.ToUpper()[0]) return 1;
|
||||
if(i1.Name.ToUpper()[0] == i2.Name.ToUpper()[0])
|
||||
{
|
||||
int len = Math.Min(i1.Name.Length, i2.Name.Length);
|
||||
for (int i = 0; i < len; i++)
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
if (i1.Name.ToUpper()[i] > i2.Name.ToUpper()[i]) return 1;
|
||||
if (i1.Name.ToUpper()[i] < i2.Name.ToUpper()[i]) return -1;
|
||||
if(i1.Name.ToUpper()[i] > i2.Name.ToUpper()[i]) return 1;
|
||||
if(i1.Name.ToUpper()[i] < i2.Name.ToUpper()[i]) return -1;
|
||||
}
|
||||
if (i1.Name.Length > i2.Name.Length) return 1;
|
||||
if(i1.Name.Length > i2.Name.Length) return 1;
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
|
@ -85,7 +85,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
internal string[] GetArgumentsDescriptions(int action)
|
||||
{
|
||||
string[] result = new[] { index == int.MinValue ? "Script Name" : "Script Number", string.Empty, string.Empty, string.Empty, string.Empty };
|
||||
switch (action)
|
||||
switch(action)
|
||||
{
|
||||
case 80: //ACS_Execute (script, map, s_arg1, s_arg2, s_arg3)
|
||||
case 226: //ACS_ExecuteAlways (script, map, s_arg1, s_arg2, s_arg3)
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
int read;
|
||||
while ((read = bzip.Read(buffer, 0, buffer.Length)) > 0)
|
||||
while((read = bzip.Read(buffer, 0, buffer.Length)) > 0)
|
||||
ms.Write(buffer, 0, read);
|
||||
|
||||
return ms;
|
||||
|
|
|
@ -45,9 +45,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
for(int i = 0; i < args.Length; i++)
|
||||
t.Args[i] = args[i];
|
||||
|
||||
foreach (KeyValuePair<string, UniValue> group in fields)
|
||||
foreach(KeyValuePair<string, UniValue> group in fields)
|
||||
{
|
||||
if (t.Fields.ContainsKey(group.Key))
|
||||
if(t.Fields.ContainsKey(group.Key))
|
||||
t.Fields[group.Key] = group.Value;
|
||||
else
|
||||
t.Fields.Add(group.Key, group.Value);
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
if(!SkipWhitespace(true)) break;
|
||||
token = ReadToken();
|
||||
} while (!string.IsNullOrEmpty(token) && token != "{");
|
||||
} while(!string.IsNullOrEmpty(token) && token != "{");
|
||||
|
||||
token = ReadLine();
|
||||
string name = "";
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
SkipWhitespace(true);
|
||||
|
||||
token = StripTokenQuotes(ReadToken());
|
||||
if (!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out light.Color.Blue))
|
||||
if(!float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out light.Color.Blue))
|
||||
{
|
||||
// Not numeric!
|
||||
ReportError("Expected Blue color value, but got '" + token + "'");
|
||||
|
@ -717,7 +717,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
token2 = ReadToken();
|
||||
if(string.IsNullOrEmpty(token2)) break;
|
||||
}
|
||||
while (token2 != "{");
|
||||
while(token2 != "{");
|
||||
int scopelevel = 1;
|
||||
do
|
||||
{
|
||||
|
|
|
@ -325,7 +325,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
mapinfo.EvenLighting = true;
|
||||
}
|
||||
//smoothlighting
|
||||
else if (token == "smoothlighting")
|
||||
else if(token == "smoothlighting")
|
||||
{
|
||||
mapinfo.SmoothLighting = true;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace CodeImp.DoomBuilder.GZBuilder
|
|||
[BeginAction("gzreloadgldefs")]
|
||||
private static void ReloadGldefs()
|
||||
{
|
||||
if (General.Map != null) General.Map.Data.ReloadGldefs();
|
||||
if(General.Map != null) General.Map.Data.ReloadGldefs();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Rendering
|
|||
public void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if (!isdisposed)
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
if(shape != null) shape.Dispose();
|
||||
|
|
|
@ -40,10 +40,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Rendering
|
|||
public void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if (!isdisposed)
|
||||
if(!isdisposed)
|
||||
{
|
||||
if (arrow != null) arrow.Dispose();
|
||||
if (cage != null) cage.Dispose();
|
||||
if(arrow != null) arrow.Dispose();
|
||||
if(cage != null) cage.Dispose();
|
||||
|
||||
// Unregister resource
|
||||
General.Map.Graphics.UnregisterResource(this);
|
||||
|
|
|
@ -74,29 +74,29 @@ namespace CodeImp.DoomBuilder.GZBuilder.Rendering
|
|||
WorldVertex v6 = new WorldVertex(radius, radius, radius);
|
||||
WorldVertex v7 = new WorldVertex(radius, -radius, radius);
|
||||
|
||||
WorldVertex[] vu = new WorldVertex[]{ c, v0,
|
||||
c, v1,
|
||||
c, v2,
|
||||
c, v3,
|
||||
WorldVertex[] vu = new []{ c, v0,
|
||||
c, v1,
|
||||
c, v2,
|
||||
c, v3,
|
||||
|
||||
v0, v1,
|
||||
v1, v2,
|
||||
v2, v3,
|
||||
v3, v0 };
|
||||
v0, v1,
|
||||
v1, v2,
|
||||
v2, v3,
|
||||
v3, v0 };
|
||||
|
||||
upper = new VertexBuffer(General.Map.Graphics.Device, WorldVertex.Stride * vu.Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default);
|
||||
upper.Lock(0, WorldVertex.Stride * vu.Length, LockFlags.None).WriteRange(vu);
|
||||
upper.Unlock();
|
||||
|
||||
WorldVertex[] vl = new WorldVertex[]{ c, v4,
|
||||
c, v5,
|
||||
c, v6,
|
||||
c, v7,
|
||||
WorldVertex[] vl = new[]{ c, v4,
|
||||
c, v5,
|
||||
c, v6,
|
||||
c, v7,
|
||||
|
||||
v4, v5,
|
||||
v5, v6,
|
||||
v6, v7,
|
||||
v7, v4, };
|
||||
v4, v5,
|
||||
v5, v6,
|
||||
v6, v7,
|
||||
v7, v4 };
|
||||
|
||||
lower = new VertexBuffer(General.Map.Graphics.Device, WorldVertex.Stride * vl.Length, Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default);
|
||||
lower.Lock(0, WorldVertex.Stride * vl.Length, LockFlags.None).WriteRange(vl);
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
{
|
||||
if(s.Tag == 0) continue;
|
||||
tags.UnionWith(s.Tags);
|
||||
foreach (int tag in s.Tags)
|
||||
foreach(int tag in s.Tags)
|
||||
{
|
||||
if(!sectorsCountByTag.ContainsKey(tag)) sectorsCountByTag.Add(tag, 0);
|
||||
sectorsCountByTag[tag]++;
|
||||
|
@ -67,7 +67,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
{
|
||||
if(l.Tag == 0) continue;
|
||||
tags.UnionWith(l.Tags);
|
||||
foreach (int tag in l.Tags)
|
||||
foreach(int tag in l.Tags)
|
||||
{
|
||||
if(!linedefsCountByTag.ContainsKey(tag)) linedefsCountByTag.Add(tag, 0);
|
||||
linedefsCountByTag[tag]++;
|
||||
|
@ -193,7 +193,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
area.Inflate(100f, 100f);
|
||||
|
||||
// Zoom to area
|
||||
if (General.Editing.Mode is ClassicMode)
|
||||
if(General.Editing.Mode is ClassicMode)
|
||||
{
|
||||
ClassicMode editmode = (General.Editing.Mode as ClassicMode);
|
||||
editmode.CenterOnArea(area, 0.6f);
|
||||
|
@ -230,7 +230,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
if(e.ColumnIndex < 2 || e.RowIndex == -1) return;
|
||||
|
||||
//select
|
||||
if (e.Button == MouseButtons.Left)
|
||||
if(e.Button == MouseButtons.Left)
|
||||
{
|
||||
int tag = (int)dataGridView.Rows[e.RowIndex].Cells[0].Value;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
InitializeComponent();
|
||||
|
||||
//apply window size and location
|
||||
if (!size.IsEmpty && !location.IsEmpty)
|
||||
if(!size.IsEmpty && !location.IsEmpty)
|
||||
{
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = size;
|
||||
|
@ -47,7 +47,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
{
|
||||
if (thingcounts.ContainsKey(t.Type))
|
||||
if(thingcounts.ContainsKey(t.Type))
|
||||
{
|
||||
thingcounts[t.Type]++;
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
}
|
||||
|
||||
//add rows
|
||||
foreach (KeyValuePair<int, int> group in thingcounts)
|
||||
foreach(KeyValuePair<int, int> group in thingcounts)
|
||||
{
|
||||
if (hideUnused.Checked && group.Value == 0) continue;
|
||||
if(hideUnused.Checked && group.Value == 0) continue;
|
||||
|
||||
DataGridViewRow row = new DataGridViewRow();
|
||||
|
||||
|
@ -80,8 +80,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
private static List<Thing> GetThingsByType(int type)
|
||||
{
|
||||
List<Thing> list = new List<Thing>();
|
||||
foreach (Thing t in General.Map.Map.Things)
|
||||
if (t.Type == type) list.Add(t);
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
if(t.Type == type) list.Add(t);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -91,10 +91,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
RectangleF area = MapSet.CreateEmptyArea();
|
||||
|
||||
// Make a view area from the points
|
||||
foreach (Vector2D p in points) area = MapSet.IncreaseArea(area, p);
|
||||
foreach(Vector2D p in points) area = MapSet.IncreaseArea(area, p);
|
||||
|
||||
// Make the area square, using the largest side
|
||||
if (area.Width > area.Height)
|
||||
if(area.Width > area.Height)
|
||||
{
|
||||
float delta = area.Width - area.Height;
|
||||
area.Y -= delta * 0.5f;
|
||||
|
@ -111,7 +111,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
area.Inflate(100f, 100f);
|
||||
|
||||
// Zoom to area
|
||||
if (General.Editing.Mode is ClassicMode)
|
||||
if(General.Editing.Mode is ClassicMode)
|
||||
{
|
||||
ClassicMode editmode = (General.Editing.Mode as ClassicMode);
|
||||
editmode.CenterOnArea(area, 0.6f);
|
||||
|
@ -120,16 +120,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
|
||||
private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
if (e.RowIndex == -1) return;
|
||||
if (e.Button == MouseButtons.Left) //select
|
||||
if(e.RowIndex == -1) return;
|
||||
if(e.Button == MouseButtons.Left) //select
|
||||
{
|
||||
List<Thing> list = GetThingsByType((int)dataGridView.Rows[e.RowIndex].Cells[0].Value);
|
||||
if (list.Count > 0)
|
||||
if(list.Count > 0)
|
||||
{
|
||||
General.Map.Map.ClearSelectedThings();
|
||||
|
||||
List<Vector2D> points = new List<Vector2D>();
|
||||
foreach (Thing t in list)
|
||||
foreach(Thing t in list)
|
||||
{
|
||||
t.Selected = true;
|
||||
|
||||
|
@ -146,10 +146,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
|
|||
ShowSelection(points);
|
||||
}
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right) //edit
|
||||
else if(e.Button == MouseButtons.Right) //edit
|
||||
{
|
||||
List<Thing> list = GetThingsByType((int)dataGridView.Rows[e.RowIndex].Cells[0].Value);
|
||||
if (list.Count > 0)
|
||||
if(list.Count > 0)
|
||||
{
|
||||
General.MainWindow.ShowEditThings(list);
|
||||
General.Map.Map.Update();
|
||||
|
|
|
@ -58,15 +58,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3
|
|||
private static void LoadKVX(ModelData mde, List<DataReader> containers, Device device)
|
||||
{
|
||||
mde.Model = new GZModel();
|
||||
|
||||
for(int i = 0; i < mde.ModelNames.Count; i++)
|
||||
foreach(string name in mde.ModelNames)
|
||||
{
|
||||
//find the model
|
||||
Stream ms;
|
||||
|
||||
foreach(DataReader dr in containers)
|
||||
{
|
||||
ms = dr.GetVoxelData(mde.ModelNames[i]);
|
||||
Stream ms = dr.GetVoxelData(name);
|
||||
if(ms == null) continue;
|
||||
|
||||
//load kvx
|
||||
|
|
|
@ -182,7 +182,7 @@ namespace CodeImp.DoomBuilder
|
|||
/// </param>
|
||||
public void Update(byte[] buffer)
|
||||
{
|
||||
if (buffer == null) throw new ArgumentNullException("buffer");
|
||||
if(buffer == null) throw new ArgumentNullException("buffer");
|
||||
Update(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
|
@ -200,13 +200,13 @@ namespace CodeImp.DoomBuilder
|
|||
/// </param>
|
||||
public void Update(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null) throw new ArgumentNullException("buffer");
|
||||
if (count < 0) throw new ArgumentOutOfRangeException("count", "Count cannot be less than zero");
|
||||
if (offset < 0 || offset + count > buffer.Length) throw new ArgumentOutOfRangeException("offset");
|
||||
if(buffer == null) throw new ArgumentNullException("buffer");
|
||||
if(count < 0) throw new ArgumentOutOfRangeException("count", "Count cannot be less than zero");
|
||||
if(offset < 0 || offset + count > buffer.Length) throw new ArgumentOutOfRangeException("offset");
|
||||
|
||||
crc ^= CRC_SEED;
|
||||
|
||||
while (--count >= 0)
|
||||
while(--count >= 0)
|
||||
{
|
||||
crc = CRC_TABLE[(crc ^ buffer[offset++]) & 0xFF] ^ (crc >> 8);
|
||||
}
|
||||
|
|
|
@ -312,9 +312,6 @@ namespace CodeImp.DoomBuilder
|
|||
// This loads all game configurations
|
||||
private static void LoadAllGameConfigurations()
|
||||
{
|
||||
Configuration cfg;
|
||||
string fullfilename;
|
||||
|
||||
// Display status
|
||||
mainwindow.DisplayStatus(StatusType.Busy, "Loading game configurations...");
|
||||
|
||||
|
@ -327,10 +324,10 @@ namespace CodeImp.DoomBuilder
|
|||
foreach(string filepath in filenames)
|
||||
{
|
||||
// Check if it can be loaded
|
||||
cfg = LoadGameConfiguration(Path.GetFileName(filepath));
|
||||
Configuration cfg = LoadGameConfiguration(Path.GetFileName(filepath));
|
||||
if(cfg != null)
|
||||
{
|
||||
fullfilename = Path.GetFileName(filepath);
|
||||
string fullfilename = Path.GetFileName(filepath);
|
||||
ConfigurationInfo cfginfo = new ConfigurationInfo(cfg, fullfilename);
|
||||
|
||||
// Add to lists
|
||||
|
@ -346,9 +343,6 @@ namespace CodeImp.DoomBuilder
|
|||
// This loads all nodebuilder configurations
|
||||
private static void LoadAllNodebuilderConfigurations()
|
||||
{
|
||||
Configuration cfg;
|
||||
IDictionary builderslist;
|
||||
|
||||
// Display status
|
||||
mainwindow.DisplayStatus(StatusType.Busy, "Loading nodebuilder configurations...");
|
||||
|
||||
|
@ -362,7 +356,7 @@ namespace CodeImp.DoomBuilder
|
|||
try
|
||||
{
|
||||
// Try loading the configuration
|
||||
cfg = new Configuration(filepath, true);
|
||||
Configuration cfg = new Configuration(filepath, true);
|
||||
|
||||
// Check for erors
|
||||
if(cfg.ErrorResult)
|
||||
|
@ -374,7 +368,7 @@ namespace CodeImp.DoomBuilder
|
|||
else
|
||||
{
|
||||
// Get structures
|
||||
builderslist = cfg.ReadSetting("nodebuilders", new Hashtable());
|
||||
IDictionary builderslist = cfg.ReadSetting("nodebuilders", new Hashtable());
|
||||
foreach(DictionaryEntry de in builderslist)
|
||||
{
|
||||
// Check if this is a structure
|
||||
|
@ -1230,7 +1224,7 @@ namespace CodeImp.DoomBuilder
|
|||
[BeginAction("openmapincurrentwad")]
|
||||
internal static void OpenMapInCurrentWad()
|
||||
{
|
||||
if (map == null || string.IsNullOrEmpty(map.FilePathName) || !File.Exists(map.FilePathName))
|
||||
if(map == null || string.IsNullOrEmpty(map.FilePathName) || !File.Exists(map.FilePathName))
|
||||
{
|
||||
Interface.DisplayStatus(StatusType.Warning, "Unable to open map from current WAD!");
|
||||
return;
|
||||
|
@ -1248,7 +1242,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// If resources don't match, perform regular map loading
|
||||
bool resourcesmismatch = changemapwindow.Options.Resources.Count != map.Options.Resources.Count;
|
||||
if (!resourcesmismatch)
|
||||
if(!resourcesmismatch)
|
||||
{
|
||||
for(int i = 0; i < changemapwindow.Options.Resources.Count; i++)
|
||||
{
|
||||
|
@ -1314,7 +1308,7 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
// Show any errors if preferred
|
||||
mainwindow.DisplayStatus(StatusType.Warning, "There were errors during loading!");
|
||||
if (!delaymainwindow && Settings.ShowErrorsWindow)
|
||||
if(!delaymainwindow && Settings.ShowErrorsWindow)
|
||||
mainwindow.ShowErrors();
|
||||
}
|
||||
else
|
||||
|
@ -1440,7 +1434,7 @@ namespace CodeImp.DoomBuilder
|
|||
else
|
||||
{
|
||||
//mxd. Do we need to save the map?
|
||||
if (!map.MapSaveRequired(map.FilePathName, SavePurpose.Normal))
|
||||
if(!map.MapSaveRequired(map.FilePathName, SavePurpose.Normal))
|
||||
{
|
||||
// Still save settings file
|
||||
result = map.SaveSettingsFile(map.FilePathName);
|
||||
|
@ -1933,13 +1927,12 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
string filename;
|
||||
const string chars = "abcdefghijklmnopqrstuvwxyz1234567890";
|
||||
int i;
|
||||
|
||||
do
|
||||
{
|
||||
// Generate a filename
|
||||
filename = "";
|
||||
for(i = 0; i < 8; i++) filename += chars[Random(0, chars.Length - 1)];
|
||||
for(int i = 0; i < 8; i++) filename += chars[Random(0, chars.Length - 1)];
|
||||
filename = Path.Combine(tempdir, filename + "." + extension);
|
||||
}
|
||||
// Continue while file is not unique
|
||||
|
@ -1954,13 +1947,12 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
string dirname;
|
||||
const string chars = "abcdefghijklmnopqrstuvwxyz1234567890";
|
||||
int i;
|
||||
|
||||
do
|
||||
{
|
||||
// Generate a filename
|
||||
dirname = "";
|
||||
for(i = 0; i < 8; i++) dirname += chars[Random(0, chars.Length - 1)];
|
||||
for(int i = 0; i < 8; i++) dirname += chars[Random(0, chars.Length - 1)];
|
||||
dirname = Path.Combine(temppath, dirname);
|
||||
}
|
||||
// Continue while file is not unique
|
||||
|
@ -2114,7 +2106,7 @@ namespace CodeImp.DoomBuilder
|
|||
// Since we can't prevent the app from terminating, log this to the event log.
|
||||
try
|
||||
{
|
||||
if (!EventLog.SourceExists("ThreadException"))
|
||||
if(!EventLog.SourceExists("ThreadException"))
|
||||
EventLog.CreateEventSource("ThreadException", "Application");
|
||||
|
||||
// Create an EventLog instance and assign its source.
|
||||
|
|
|
@ -452,7 +452,7 @@ namespace CodeImp.DoomBuilder
|
|||
General.Settings.SetDefaultThingFlags(config.DefaultThingFlags);
|
||||
|
||||
// Center map in screen
|
||||
//if (General.Editing.Mode is ClassicMode) (General.Editing.Mode as ClassicMode).CenterInScreen();
|
||||
//if(General.Editing.Mode is ClassicMode) (General.Editing.Mode as ClassicMode).CenterInScreen();
|
||||
|
||||
// Success
|
||||
this.changed = maprestored; //mxd
|
||||
|
@ -678,7 +678,7 @@ namespace CodeImp.DoomBuilder
|
|||
// We're not using SetFlag here, this doesn't have to be undone.
|
||||
// Please note that this is totally exceptional!
|
||||
List<string> flagkeys = new List<string>(t.Flags.Keys);
|
||||
foreach (string k in flagkeys) t.Flags[k] = false;
|
||||
foreach(string k in flagkeys) t.Flags[k] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,7 +734,7 @@ namespace CodeImp.DoomBuilder
|
|||
// Write to temporary file
|
||||
General.WriteLogLine("Writing map data structures to file...");
|
||||
index = tempwad.FindLumpIndex(TEMP_MAP_HEADER);
|
||||
if (index == -1) index = 0;
|
||||
if(index == -1) index = 0;
|
||||
io.Write(outputset, TEMP_MAP_HEADER, index);
|
||||
outputset.Dispose();
|
||||
|
||||
|
@ -810,10 +810,10 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
try
|
||||
{
|
||||
if (File.Exists(newfilepathname))
|
||||
if(File.Exists(newfilepathname))
|
||||
{
|
||||
// mxd. Check if target wad already has a map with the same name
|
||||
if (purpose == SavePurpose.IntoFile)
|
||||
if(purpose == SavePurpose.IntoFile)
|
||||
{
|
||||
WAD wad = new WAD(newfilepathname, true);
|
||||
int mapindex = wad.FindLumpIndex(origmapname);
|
||||
|
@ -828,33 +828,33 @@ namespace CodeImp.DoomBuilder
|
|||
}
|
||||
|
||||
// Backup existing file, if any
|
||||
if (File.Exists(newfilepathname + ".backup3")) File.Delete(newfilepathname + ".backup3");
|
||||
if (File.Exists(newfilepathname + ".backup2")) File.Move(newfilepathname + ".backup2", newfilepathname + ".backup3");
|
||||
if (File.Exists(newfilepathname + ".backup1")) File.Move(newfilepathname + ".backup1", newfilepathname + ".backup2");
|
||||
if(File.Exists(newfilepathname + ".backup3")) File.Delete(newfilepathname + ".backup3");
|
||||
if(File.Exists(newfilepathname + ".backup2")) File.Move(newfilepathname + ".backup2", newfilepathname + ".backup3");
|
||||
if(File.Exists(newfilepathname + ".backup1")) File.Move(newfilepathname + ".backup1", newfilepathname + ".backup2");
|
||||
File.Copy(newfilepathname, newfilepathname + ".backup1");
|
||||
}
|
||||
|
||||
// Except when saving INTO another file,
|
||||
// kill the target file if it is different from source file
|
||||
if ((purpose != SavePurpose.IntoFile) && (newfilepathname != filepathname))
|
||||
if((purpose != SavePurpose.IntoFile) && (newfilepathname != filepathname))
|
||||
{
|
||||
// Kill target file
|
||||
if (File.Exists(newfilepathname)) File.Delete(newfilepathname);
|
||||
if(File.Exists(newfilepathname)) File.Delete(newfilepathname);
|
||||
|
||||
// Kill .dbs settings file
|
||||
settingsfile = newfilepathname.Substring(0, newfilepathname.Length - 4) + ".dbs";
|
||||
if (File.Exists(settingsfile)) File.Delete(settingsfile);
|
||||
if(File.Exists(settingsfile)) File.Delete(settingsfile);
|
||||
}
|
||||
|
||||
// On Save AS we have to copy the previous file to the new file
|
||||
if ((purpose == SavePurpose.AsNewFile) && (filepathname != ""))
|
||||
if((purpose == SavePurpose.AsNewFile) && (filepathname != ""))
|
||||
{
|
||||
// Copy if original file still exists
|
||||
if (File.Exists(filepathname)) File.Copy(filepathname, newfilepathname, true);
|
||||
if(File.Exists(filepathname)) File.Copy(filepathname, newfilepathname, true);
|
||||
}
|
||||
|
||||
// If the target file exists, we need to rebuild it
|
||||
if (File.Exists(newfilepathname))
|
||||
if(File.Exists(newfilepathname))
|
||||
{
|
||||
// Move the target file aside
|
||||
origwadfile = newfilepathname + ".temp";
|
||||
|
@ -868,7 +868,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Copy all lumps, except the original map
|
||||
GameConfiguration origcfg; //mxd
|
||||
if (origmapconfigname == configinfo.Filename)
|
||||
if(origmapconfigname == configinfo.Filename)
|
||||
{
|
||||
origcfg = config;
|
||||
}
|
||||
|
@ -913,13 +913,13 @@ namespace CodeImp.DoomBuilder
|
|||
// mxd. Was the map renamed?
|
||||
if(options.LevelNameChanged)
|
||||
{
|
||||
if (purpose != SavePurpose.IntoFile)
|
||||
if(purpose != SavePurpose.IntoFile)
|
||||
{
|
||||
General.WriteLogLine("Changing map name from '" + options.PreviousName + "' to '" + options.CurrentName + "'");
|
||||
|
||||
// Find the map header in target
|
||||
index = targetwad.FindLumpIndex(options.PreviousName);
|
||||
if (index > -1)
|
||||
if(index > -1)
|
||||
{
|
||||
// Rename the map lump name
|
||||
targetwad.Lumps[index].Rename(options.CurrentName);
|
||||
|
@ -942,10 +942,10 @@ namespace CodeImp.DoomBuilder
|
|||
data.Resume();
|
||||
|
||||
// Not saved for testing purpose?
|
||||
if (purpose != SavePurpose.Testing)
|
||||
if(purpose != SavePurpose.Testing)
|
||||
{
|
||||
// Saved in a different file?
|
||||
if (newfilepathname != filepathname)
|
||||
if(newfilepathname != filepathname)
|
||||
{
|
||||
// Keep new filename
|
||||
filepathname = newfilepathname;
|
||||
|
@ -1288,7 +1288,7 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
// Determine target index
|
||||
insertindex++;
|
||||
if (insertindex > target.Lumps.Count) insertindex = target.Lumps.Count;
|
||||
if(insertindex > target.Lumps.Count) insertindex = target.Lumps.Count;
|
||||
|
||||
// Create new, emtpy lump
|
||||
General.WriteLogLine(lumpname + " is required! Created empty lump.");
|
||||
|
@ -1325,7 +1325,7 @@ namespace CodeImp.DoomBuilder
|
|||
foreach(Lump lump in target.Lumps)
|
||||
if(!requiredLumps.Contains(lump.Name)) toRemove.Add(lump);
|
||||
|
||||
foreach (Lump lump in toRemove) target.Remove(lump);
|
||||
foreach(Lump lump in toRemove) target.Remove(lump);
|
||||
}
|
||||
|
||||
// This copies all lumps, except those of a specific map
|
||||
|
@ -1409,8 +1409,8 @@ namespace CodeImp.DoomBuilder
|
|||
// Determine target index
|
||||
// When original lump was found and removed then insert at that position
|
||||
// otherwise insert after last insertion position
|
||||
if (lumpindex > -1) targetindex = lumpindex; else targetindex++;
|
||||
if (targetindex > target.Lumps.Count) targetindex = target.Lumps.Count;
|
||||
if(lumpindex > -1) targetindex = lumpindex; else targetindex++;
|
||||
if(targetindex > target.Lumps.Count) targetindex = target.Lumps.Count;
|
||||
|
||||
// Copy the lump to the target
|
||||
//General.WriteLogLine(srclumpname + " copying as " + tgtlumpname);
|
||||
|
@ -1422,7 +1422,7 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
// We don't want to bother the user with this. There are a lot of lumps in
|
||||
// the game configs that are trivial and don't need to be found.
|
||||
if (group.Value.Required)
|
||||
if(group.Value.Required)
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, group.Key + " (required lump) should be read but was not found in the WAD file.");
|
||||
}
|
||||
|
@ -2370,10 +2370,9 @@ namespace CodeImp.DoomBuilder
|
|||
blockmap.AddVerticesSet(General.Map.Map.Vertices);
|
||||
|
||||
//merge overlapping vertices using teh power of BLOCKMAP!!!11
|
||||
BlockEntry block;
|
||||
foreach(Vertex v in movedVerts)
|
||||
{
|
||||
block = blockmap.GetBlockAt(v.Position);
|
||||
BlockEntry block = blockmap.GetBlockAt(v.Position);
|
||||
if(block == null) continue;
|
||||
|
||||
foreach(Vertex blockVert in block.Vertices)
|
||||
|
@ -2381,9 +2380,9 @@ namespace CodeImp.DoomBuilder
|
|||
if(blockVert.IsDisposed || blockVert.Index == v.Index || blockVert.Position != v.Position)
|
||||
continue;
|
||||
|
||||
foreach (Linedef l in blockVert.Linedefs)
|
||||
foreach(Linedef l in blockVert.Linedefs)
|
||||
{
|
||||
if (!movedLines.Contains(l)) movedLines.Add(l);
|
||||
if(!movedLines.Contains(l)) movedLines.Add(l);
|
||||
}
|
||||
v.Join(blockVert);
|
||||
break;
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace CodeImp.DoomBuilder
|
|||
return;
|
||||
}
|
||||
|
||||
string s = string.Empty;
|
||||
string s;
|
||||
using(StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
s = reader.ReadToEnd();
|
||||
|
@ -144,7 +144,6 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(stream);
|
||||
int noderev;
|
||||
|
||||
// Revision infos go in descending order
|
||||
if(doc.ChildNodes.Count == 0) return string.Empty;
|
||||
|
@ -153,6 +152,7 @@ namespace CodeImp.DoomBuilder
|
|||
if(log.ChildNodes.Count == 0) continue;
|
||||
foreach(XmlNode logentry in log.ChildNodes)
|
||||
{
|
||||
int noderev;
|
||||
if(logentry.Attributes == null || !int.TryParse(logentry.Attributes.GetNamedItem("revision").Value, out noderev)) continue;
|
||||
if(noderev <= localrev) break;
|
||||
|
||||
|
|
|
@ -112,7 +112,6 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
public bool Intersect(Vector2D p)
|
||||
{
|
||||
Vector2D v1 = base.Last.Value.Position;
|
||||
Vector2D v2;
|
||||
LinkedListNode<EarClipVertex> n = base.First;
|
||||
uint c = 0;
|
||||
|
||||
|
@ -120,7 +119,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
while(n != null)
|
||||
{
|
||||
// Get next vertex
|
||||
v2 = n.Value.Position;
|
||||
Vector2D v2 = n.Value.Position;
|
||||
|
||||
// Determine min/max values
|
||||
float miny = Math.Min(v1.y, v2.y);
|
||||
|
|
|
@ -3,8 +3,6 @@ using CodeImp.DoomBuilder.Rendering;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
|
||||
|
||||
public static class InterpolationTools
|
||||
{
|
||||
public enum Mode
|
||||
|
@ -17,7 +15,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
|
||||
public static int Interpolate(float val1, float val2, float delta, Mode mode)
|
||||
{
|
||||
switch (mode)
|
||||
switch(mode)
|
||||
{
|
||||
case Mode.LINEAR: return Linear(val1, val2, delta);
|
||||
case Mode.EASE_IN_SINE: return EaseInSine(val1, val2, delta);
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
u_ray = ((v2.x - v1.x) * (v1.y - y3) - (v2.y - v1.y) * (v1.x - x3)) / div;
|
||||
|
||||
// Return if intersecting
|
||||
if (u_ray < 0.0f || u_ray > 1.0f || u_line < 0.0f || u_line > 1.0f) return false; //mxd
|
||||
if(u_ray < 0.0f || u_ray > 1.0f || u_line < 0.0f || u_line > 1.0f) return false; //mxd
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,15 +47,6 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
/// <summary>
|
||||
/// This is used to indicate a side of a line without the need for a sidedef.
|
||||
/// </summary>
|
||||
public LinedefSide()
|
||||
{
|
||||
// Initialize
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used to indicate a side of a line without the need for a sidedef.
|
||||
/// </summary>
|
||||
|
@ -76,11 +67,6 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
this.front = original.front;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~LinedefSide()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
|
|
@ -138,11 +138,8 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// This finds the inner lines of the sector and adds them to the sector polygon
|
||||
private static void FindInnerLines(EarClipPolygon p, List<LinedefSide> alllines)
|
||||
{
|
||||
Vertex foundv;
|
||||
bool vvalid, findmore;
|
||||
Linedef foundline;
|
||||
bool findmore;
|
||||
float foundangle = 0f;
|
||||
bool foundlinefront;
|
||||
RectangleF bbox = p.CreateBBox();
|
||||
|
||||
do
|
||||
|
@ -150,7 +147,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
findmore = false;
|
||||
|
||||
// Go for all vertices to find the right-most vertex inside the polygon
|
||||
foundv = null;
|
||||
Vertex foundv = null;
|
||||
foreach(Vertex v in General.Map.Map.Vertices)
|
||||
{
|
||||
// Inside the polygon bounding box?
|
||||
|
@ -167,7 +164,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(v.Linedefs.Count > 0)
|
||||
{
|
||||
// Go for all lines to see if the vertex is not of the polygon itsself
|
||||
vvalid = true;
|
||||
bool vvalid = true;
|
||||
foreach(LinedefSide ls in alllines)
|
||||
{
|
||||
if((ls.Line.Start == v) || (ls.Line.End == v))
|
||||
|
@ -188,8 +185,8 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(foundv != null)
|
||||
{
|
||||
// Find the attached linedef with the smallest angle to the right
|
||||
float targetangle = Angle2D.PIHALF;
|
||||
foundline = null;
|
||||
const float targetangle = Angle2D.PIHALF;
|
||||
Linedef foundline = null;
|
||||
foreach(Linedef l in foundv.Linedefs)
|
||||
{
|
||||
// We need an angle unrelated to line direction, so correct for that
|
||||
|
@ -215,7 +212,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
|
||||
// Find the side at which to start pathfinding
|
||||
Vector2D testpos = new Vector2D(100.0f, 0.0f);
|
||||
foundlinefront = (foundline.SideOfLine(foundv.Position + testpos) < 0.0f);
|
||||
bool foundlinefront = (foundline.SideOfLine(foundv.Position + testpos) < 0.0f);
|
||||
|
||||
// Find inner path
|
||||
List<LinedefSide> innerlines = FindClosestPath(foundline, foundlinefront, true);
|
||||
|
@ -740,7 +737,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
//mxd. This applies overrides to a sidedef
|
||||
private static void ApplyOverridesToSidedef(Sidedef sd)
|
||||
{
|
||||
if (General.Map.Options.OverrideTopTexture) sd.SetTextureHigh(General.Map.Options.DefaultTopTexture);
|
||||
if(General.Map.Options.OverrideTopTexture) sd.SetTextureHigh(General.Map.Options.DefaultTopTexture);
|
||||
if(sd.MiddleRequired() && General.Map.Options.OverrideMiddleTexture) sd.SetTextureMid(General.Map.Options.DefaultWallTexture);
|
||||
if(General.Map.Options.OverrideBottomTexture) sd.SetTextureLow(General.Map.Options.DefaultBottomTexture);
|
||||
}
|
||||
|
@ -945,12 +942,12 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
Dictionary<Linedef, bool> processed = new Dictionary<Linedef, bool>(); //mxd
|
||||
|
||||
//mxd
|
||||
foreach (Sector s in map.Sectors)
|
||||
foreach(Sector s in map.Sectors)
|
||||
{
|
||||
//line intersects with sector's bounding box?
|
||||
if((MapSet.GetCSFieldBits(measureline.v1, s.BBox) & MapSet.GetCSFieldBits(measureline.v2, s.BBox)) == 0)
|
||||
{
|
||||
foreach (Sidedef side in s.Sidedefs)
|
||||
foreach(Sidedef side in s.Sidedefs)
|
||||
{
|
||||
if(processed.ContainsKey(side.Line)) continue;
|
||||
if(side.Line == ld) continue;
|
||||
|
@ -1464,10 +1461,10 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
}
|
||||
|
||||
//mxd. Apply texture overrides
|
||||
if (useOverrides && !General.Settings.AutoClearSidedefTextures)
|
||||
if(useOverrides && !General.Settings.AutoClearSidedefTextures)
|
||||
{
|
||||
//if new sectors are created, apply overrides to the sides of these sectors, otherwise, apply overrides to all new lines
|
||||
if (insidesides.Count > 0)
|
||||
if(insidesides.Count > 0)
|
||||
{
|
||||
foreach(Sidedef side in insidesides) ApplyOverridesToSidedef(side);
|
||||
}
|
||||
|
@ -1539,7 +1536,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
//mxd
|
||||
private static void AutoAlignLinedefStrip(List<Linedef> strip)
|
||||
{
|
||||
if (strip.Count < 2) return;
|
||||
if(strip.Count < 2) return;
|
||||
|
||||
float totalLength = 0f;
|
||||
foreach(Linedef l in strip) totalLength += l.Length;
|
||||
|
@ -1816,7 +1813,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
//mxd. This converts offsetY from/to "normalized" offset for given wall part
|
||||
public static float GetSidedefOffsetY(Sidedef side, VisualGeometryType part, float offset, float scaleY, bool fromNormalized)
|
||||
{
|
||||
switch (part)
|
||||
switch(part)
|
||||
{
|
||||
case VisualGeometryType.WALL_UPPER:
|
||||
return GetSidedefTopOffsetY(side, offset, scaleY, fromNormalized);
|
||||
|
@ -2336,13 +2333,13 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
//mxd
|
||||
public static int GetDropDownWidth(ComboBox cb)
|
||||
{
|
||||
int maxWidth = 0, temp;
|
||||
foreach(var obj in cb.Items)
|
||||
int maxwidth = 0;
|
||||
foreach(var obj in cb.Items)
|
||||
{
|
||||
temp = TextRenderer.MeasureText(obj.ToString(), cb.Font).Width;
|
||||
if(temp > maxWidth) maxWidth = temp;
|
||||
int temp = TextRenderer.MeasureText(obj.ToString(), cb.Font).Width;
|
||||
if(temp > maxwidth) maxwidth = temp;
|
||||
}
|
||||
return maxWidth > 0 ? maxWidth + 6 : 1;
|
||||
return maxwidth > 0 ? maxwidth + 6 : 1;
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
@ -2354,8 +2351,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
return General.Map.Data.MapInfo.OutsideFogColor.ToColor();
|
||||
}
|
||||
|
||||
if(General.Map.Data.MapInfo.HasFadeColor) return General.Map.Data.MapInfo.FadeColor.ToColor();
|
||||
return Color.Black;
|
||||
return (General.Map.Data.MapInfo.HasFadeColor ? General.Map.Data.MapInfo.FadeColor.ToColor() : Color.Black);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -433,21 +433,17 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
private static void MergeInnerPolys(EarClipPolygon p)
|
||||
{
|
||||
LinkedList<EarClipPolygon> todo = new LinkedList<EarClipPolygon>(p.Children);
|
||||
LinkedListNode<EarClipVertex> start;
|
||||
LinkedListNode<EarClipPolygon> ip;
|
||||
LinkedListNode<EarClipPolygon> found;
|
||||
LinkedListNode<EarClipVertex> foundstart;
|
||||
|
||||
|
||||
// Continue until no more inner polygons to process
|
||||
while(todo.Count > 0)
|
||||
{
|
||||
// Find the inner polygon with the highest x vertex
|
||||
found = null;
|
||||
foundstart = null;
|
||||
ip = todo.First;
|
||||
LinkedListNode<EarClipPolygon> found = null;
|
||||
LinkedListNode<EarClipVertex> foundstart = null;
|
||||
LinkedListNode<EarClipPolygon> ip = todo.First;
|
||||
while(ip != null)
|
||||
{
|
||||
start = FindRightMostVertex(ip.Value);
|
||||
LinkedListNode<EarClipVertex> start = FindRightMostVertex(ip.Value);
|
||||
if((foundstart == null) || (start.Value.Position.x > foundstart.Value.Position.x))
|
||||
{
|
||||
// Found a better start
|
||||
|
@ -491,7 +487,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
private static void SplitOuterWithInner(LinkedListNode<EarClipVertex> start, EarClipPolygon p)
|
||||
{
|
||||
LinkedListNode<EarClipVertex> insertbefore = null;
|
||||
float u, ul, foundu = float.MaxValue;
|
||||
float foundu = float.MaxValue;
|
||||
Vector2D foundpos = new Vector2D();
|
||||
|
||||
// Create a line from start that goes beyond the right most vertex of p
|
||||
|
@ -514,6 +510,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
{
|
||||
// Find intersection
|
||||
Line2D pl = new Line2D(v1.Value.Position, v2.Value.Position);
|
||||
float u, ul;
|
||||
pl.GetIntersection(starttoright, out u, out ul);
|
||||
if(float.IsNaN(u))
|
||||
{
|
||||
|
@ -637,8 +634,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
LinkedList<EarClipVertex> reflexes = new LinkedList<EarClipVertex>();
|
||||
LinkedList<EarClipVertex> eartips = new LinkedList<EarClipVertex>();
|
||||
LinkedListNode<EarClipVertex> n2;
|
||||
EarClipVertex v, v1, v2;
|
||||
EarClipVertex[] t, t1, t2;
|
||||
EarClipVertex[] t;
|
||||
int countvertices = 0;
|
||||
|
||||
// Go for all vertices to fill list
|
||||
|
@ -711,7 +707,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
while((eartips.Count > 0) && (verts.Count > 2))
|
||||
{
|
||||
// Get next ear
|
||||
v = eartips.First.Value;
|
||||
EarClipVertex v = eartips.First.Value;
|
||||
t = GetTriangle(v);
|
||||
|
||||
// Only save this triangle when it has an area
|
||||
|
@ -724,8 +720,8 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
|
||||
// Remove this ear from all lists
|
||||
v.Remove();
|
||||
v1 = t[0];
|
||||
v2 = t[2];
|
||||
EarClipVertex v1 = t[0];
|
||||
EarClipVertex v2 = t[2];
|
||||
|
||||
#if DEBUG
|
||||
if(TriangleHasArea(t))
|
||||
|
@ -735,7 +731,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
#endif
|
||||
|
||||
// Test first neighbour
|
||||
t1 = GetTriangle(v1);
|
||||
EarClipVertex[] t1 = GetTriangle(v1);
|
||||
//bool t1a = true; //TriangleHasArea(t1);
|
||||
if(/*t1a && */IsReflex(t1))
|
||||
{
|
||||
|
@ -750,7 +746,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
}
|
||||
|
||||
// Test second neighbour
|
||||
t2 = GetTriangle(v2);
|
||||
EarClipVertex[] t2 = GetTriangle(v2);
|
||||
//bool t2a = true; //TriangleHasArea(t2);
|
||||
if(/*t2a && */IsReflex(t2))
|
||||
{
|
||||
|
|
|
@ -356,12 +356,12 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
//mxd. Addeed to make compiler a bit more happy...
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Vector2D)) return false;
|
||||
if(!(obj is Vector2D)) return false;
|
||||
|
||||
Vector2D other = (Vector2D)obj;
|
||||
|
||||
if (x != other.x) return false;
|
||||
if (y != other.y) return false;
|
||||
if(x != other.x) return false;
|
||||
if(y != other.y) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -356,13 +356,13 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
//mxd. Addeed to make compiler a bit more happy...
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Vector3D)) return false;
|
||||
if(!(obj is Vector3D)) return false;
|
||||
|
||||
Vector3D other = (Vector3D)obj;
|
||||
|
||||
if (x != other.x) return false;
|
||||
if (y != other.y) return false;
|
||||
if (z != other.z) return false;
|
||||
if(x != other.x) return false;
|
||||
if(y != other.y) return false;
|
||||
if(z != other.z) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
|
||||
// Add custom fields
|
||||
v.Fields.BeforeFieldsChange();
|
||||
foreach (KeyValuePair<string, UniValue> group in fields)
|
||||
foreach(KeyValuePair<string, UniValue> group in fields)
|
||||
{
|
||||
v.Fields.Add(group.Key, group.Value);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Go for all collections
|
||||
map.SetCapacity(0, 0, 0, map.Sectors.Count + count, 0);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
int effect = reader.ReadInt32();
|
||||
int hfloor = reader.ReadInt32();
|
||||
|
@ -135,7 +135,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
for(int f = 0; f < numFlags; f++) stringflags.Add(ReadString(reader), true);
|
||||
|
||||
//add missing flags
|
||||
foreach (KeyValuePair<string, string> flag in General.Map.Config.SectorFlags)
|
||||
foreach(KeyValuePair<string, string> flag in General.Map.Config.SectorFlags)
|
||||
{
|
||||
if(stringflags.ContainsKey(flag.Key)) continue;
|
||||
stringflags.Add(flag.Key, false);
|
||||
|
@ -197,7 +197,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
}
|
||||
|
||||
//add missing activations
|
||||
foreach (LinedefActivateInfo activate in General.Map.Config.LinedefActivates)
|
||||
foreach(LinedefActivateInfo activate in General.Map.Config.LinedefActivates)
|
||||
{
|
||||
if(stringflags.ContainsKey(activate.Key)) continue;
|
||||
stringflags.Add(activate.Key, false);
|
||||
|
@ -207,11 +207,11 @@ namespace CodeImp.DoomBuilder.IO
|
|||
Dictionary<string, UniValue> fields = ReadCustomFields(reader);
|
||||
|
||||
// Check if not zero-length
|
||||
if (Vector2D.ManhattanDistance(vertexlink[v1].Position, vertexlink[v2].Position) > 0.0001f)
|
||||
if(Vector2D.ManhattanDistance(vertexlink[v1].Position, vertexlink[v2].Position) > 0.0001f)
|
||||
{
|
||||
// Create new linedef
|
||||
Linedef l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
|
||||
if (l != null)
|
||||
if(l != null)
|
||||
{
|
||||
l.Update(stringflags, 0, tags, special, args);
|
||||
l.UpdateCache();
|
||||
|
@ -259,7 +259,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
s.Update(data.OffsetX, data.OffsetY, data.HighTexture, data.MiddleTexture, data.LowTexture, data.Flags);
|
||||
|
||||
// Add custom fields
|
||||
foreach (KeyValuePair<string, UniValue> group in data.Fields)
|
||||
foreach(KeyValuePair<string, UniValue> group in data.Fields)
|
||||
{
|
||||
s.Fields.Add(group.Key, group.Value);
|
||||
}
|
||||
|
@ -399,9 +399,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
private static string ReadString(BinaryReader reader)
|
||||
{
|
||||
int len = reader.ReadInt32();
|
||||
if (len == 0) return string.Empty;
|
||||
if(len == 0) return string.Empty;
|
||||
char[] chars = new char[len];
|
||||
for (int i = 0; i < len; ++i) chars[i] = reader.ReadChar();
|
||||
for(int i = 0; i < len; ++i) chars[i] = reader.ReadChar();
|
||||
return new string(chars);
|
||||
}
|
||||
|
||||
|
|
|
@ -657,7 +657,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
}
|
||||
else
|
||||
{
|
||||
switch (c) { //mxd
|
||||
switch(c) //mxd
|
||||
{
|
||||
// Check for sequence start
|
||||
case '\\':
|
||||
// Next character is of escape sequence
|
||||
|
@ -932,7 +933,6 @@ namespace CodeImp.DoomBuilder.IO
|
|||
{
|
||||
// We now parse arguments, separated by commas, until we reach the end of the function
|
||||
List<object> args = new List<object>();
|
||||
object val;
|
||||
while((pos < data.Length) && !cpErrorResult)
|
||||
{
|
||||
// Get current character
|
||||
|
@ -954,11 +954,12 @@ namespace CodeImp.DoomBuilder.IO
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for string opening
|
||||
else if(c == '\"')
|
||||
if(c == '\"')
|
||||
{
|
||||
// Now parsing a string
|
||||
val = ParseString(ref file, ref data, ref pos, ref line);
|
||||
object val = ParseString(ref file, ref data, ref pos, ref line);
|
||||
if(cpErrorResult) return;
|
||||
args.Add(val);
|
||||
}
|
||||
|
@ -970,7 +971,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
pos--;
|
||||
|
||||
// Now parsing a number
|
||||
val = ParseNumber(ref file, ref data, ref pos, ref line);
|
||||
object val = ParseNumber(ref file, ref data, ref pos, ref line);
|
||||
if(cpErrorResult) return;
|
||||
args.Add(val);
|
||||
}
|
||||
|
@ -993,7 +994,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
pos--;
|
||||
|
||||
// Now parsing a keyword
|
||||
val = ParseKeyword(ref file, ref data, ref pos, ref line);
|
||||
object val = ParseKeyword(ref file, ref data, ref pos, ref line);
|
||||
if(cpErrorResult) return;
|
||||
args.Add(val);
|
||||
}
|
||||
|
@ -1012,7 +1013,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Go through all of the data until
|
||||
// the end or until the struct closes
|
||||
// or when an arror occurred
|
||||
while ((pos < data.Length) && !cpErrorResult)
|
||||
while((pos < data.Length) && !cpErrorResult)
|
||||
{
|
||||
// Get current character
|
||||
char c = data[pos++];
|
||||
|
|
|
@ -171,9 +171,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
path = CorrectPath(path).ToLowerInvariant();
|
||||
title = title.ToLowerInvariant();
|
||||
List<string> files = new List<string>(entries.Length);
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
for(int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
if ((entries[i].path == path) && (entries[i].filetitle.StartsWith(title)))
|
||||
if((entries[i].path == path) && (entries[i].filetitle.StartsWith(title)))
|
||||
files.Add(entries[i].filepathname);
|
||||
}
|
||||
return files;
|
||||
|
|
|
@ -80,10 +80,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Returns null on failure
|
||||
public unsafe Bitmap ReadAsBitmap(Stream stream)
|
||||
{
|
||||
BitmapData bitmapdata;
|
||||
PixelColor* targetdata;
|
||||
int width, height;
|
||||
Bitmap bmp;
|
||||
|
||||
// Read pixel data
|
||||
PixelColorBlock pixeldata = ReadAsPixelData(stream, out width, out height);
|
||||
|
@ -92,15 +89,16 @@ namespace CodeImp.DoomBuilder.IO
|
|||
try
|
||||
{
|
||||
// Create bitmap and lock pixels
|
||||
bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
bitmapdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
targetdata = (PixelColor*)bitmapdata.Scan0.ToPointer();
|
||||
Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
BitmapData bitmapdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
PixelColor* targetdata = (PixelColor*)bitmapdata.Scan0.ToPointer();
|
||||
|
||||
// Copy the pixels
|
||||
General.CopyMemory(targetdata, pixeldata.Pointer, (uint)(width * height * sizeof(PixelColor)));
|
||||
|
||||
// Done
|
||||
bmp.UnlockBits(bitmapdata);
|
||||
return bmp;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
@ -112,19 +110,14 @@ namespace CodeImp.DoomBuilder.IO
|
|||
else
|
||||
{
|
||||
// Failed loading picture
|
||||
bmp = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return result
|
||||
return bmp;
|
||||
}
|
||||
|
||||
// This draws the picture to the given pixel color data
|
||||
// Throws exception on failure
|
||||
public unsafe void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
|
||||
{
|
||||
int ox, oy, tx, ty;
|
||||
|
||||
// Get bitmap
|
||||
Bitmap bmp = ReadAsBitmap(stream);
|
||||
int width = bmp.Size.Width;
|
||||
|
@ -135,16 +128,16 @@ namespace CodeImp.DoomBuilder.IO
|
|||
PixelColor* pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
|
||||
|
||||
// Go for all pixels in the original image
|
||||
for(ox = 0; ox < width; ox++)
|
||||
for(int ox = 0; ox < width; ox++)
|
||||
{
|
||||
for(oy = 0; oy < height; oy++)
|
||||
for(int oy = 0; oy < height; oy++)
|
||||
{
|
||||
// Copy this pixel?
|
||||
if(pixels[oy * width + ox].a > 0.5f)
|
||||
{
|
||||
// Calculate target pixel and copy when within bounds
|
||||
tx = x + ox;
|
||||
ty = y + oy;
|
||||
int tx = x + ox;
|
||||
int ty = y + oy;
|
||||
if((tx >= 0) && (tx < targetwidth) && (ty >= 0) && (ty < targetheight))
|
||||
target[ty * targetwidth + tx] = pixels[oy * width + ox];
|
||||
}
|
||||
|
|
|
@ -429,7 +429,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
stream.Read(bytes, 0, bytes.Length);
|
||||
fixed(byte* bptr = bytes)
|
||||
{
|
||||
if (!ilLoadL(imagetype, new IntPtr(bptr), (uint)bytes.Length))
|
||||
if(!ilLoadL(imagetype, new IntPtr(bptr), (uint)bytes.Length))
|
||||
throw new BadImageFormatException();
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
ilDeleteImages(1, new IntPtr(&imageid));
|
||||
|
||||
//mxd. TGA fix
|
||||
if (imagetype == DevilImageType.IL_TGA)
|
||||
if(imagetype == DevilImageType.IL_TGA)
|
||||
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
|
||||
return bmp;
|
||||
|
|
|
@ -114,22 +114,18 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// This returns and instance of the specified IO class
|
||||
public static MapSetIO Create(string classname, WAD wadfile, MapManager manager)
|
||||
{
|
||||
object[] args;
|
||||
MapSetIO result;
|
||||
string fullname;
|
||||
|
||||
try
|
||||
{
|
||||
// Create arguments
|
||||
args = new object[2];
|
||||
object[] args = new object[2];
|
||||
args[0] = wadfile;
|
||||
args[1] = manager;
|
||||
|
||||
// Make the full class name
|
||||
fullname = "CodeImp.DoomBuilder.IO." + classname;
|
||||
string fullname = "CodeImp.DoomBuilder.IO." + classname;
|
||||
|
||||
// Create IO class
|
||||
result = (MapSetIO)General.ThisAssembly.CreateInstance(fullname, false,
|
||||
MapSetIO result = (MapSetIO)General.ThisAssembly.CreateInstance(fullname, false,
|
||||
BindingFlags.Default, null, args, CultureInfo.CurrentCulture, new object[0]);
|
||||
|
||||
// Check result
|
||||
|
|
|
@ -173,11 +173,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// from the given pos and line and updates pos and line.
|
||||
private UniversalCollection InputStructure(ref string[] data, ref int pos, ref int line, bool topLevel)
|
||||
{
|
||||
char c; // current data character
|
||||
int pm = PM_NOTHING; // current parse mode
|
||||
key.Remove(0, key.Length);
|
||||
val.Remove(0, val.Length);
|
||||
string s;
|
||||
bool escape = false; // escape sequence?
|
||||
bool endofstruct = false; // true as soon as this level struct ends
|
||||
UniversalCollection cs = new UniversalCollection();
|
||||
|
@ -196,7 +194,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
if(string.IsNullOrEmpty(data[line])) continue; //mxd. Skip empty lines here so correct line number is displayed on errors
|
||||
}
|
||||
|
||||
c = data[line][pos];
|
||||
char c = data[line][pos]; // current data character
|
||||
|
||||
// ================ What parse mode are we at?
|
||||
if(pm == PM_NOTHING)
|
||||
|
@ -206,7 +204,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
{
|
||||
case '{': // Begin of new struct
|
||||
// Validate key
|
||||
s = key.ToString().Trim();
|
||||
string s = key.ToString().Trim();
|
||||
if(ValidateKey(s, line))
|
||||
{
|
||||
// Next character
|
||||
|
@ -381,7 +379,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
if(c == ';')
|
||||
{
|
||||
// Hexadecimal?
|
||||
s = val.ToString();
|
||||
string s = val.ToString();
|
||||
if((s.Length > 2) && s.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
// Convert to int
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
args[3] = GetCollectionEntry(c, "arg3", false, 0, where);
|
||||
args[4] = GetCollectionEntry(c, "arg4", false, 0, where);
|
||||
|
||||
if (scale != 0) //mxd
|
||||
if(scale != 0) //mxd
|
||||
{
|
||||
scaleX = scale;
|
||||
scaleY = scale;
|
||||
|
@ -236,7 +236,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
int v1 = GetCollectionEntry(lc, "v1", true, 0, where);
|
||||
int v2 = GetCollectionEntry(lc, "v2", true, 0, where);
|
||||
|
||||
if (!vertexlink.ContainsKey(v1) || !vertexlink.ContainsKey(v2)) { //mxd
|
||||
if(!vertexlink.ContainsKey(v1) || !vertexlink.ContainsKey(v2)) { //mxd
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references one or more invalid vertices. Linedef has been removed.");
|
||||
continue;
|
||||
}
|
||||
|
@ -257,9 +257,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
if(!string.IsNullOrEmpty(moreids))
|
||||
{
|
||||
string[] moreidscol = moreids.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
|
||||
int id;
|
||||
foreach (string sid in moreidscol)
|
||||
foreach(string sid in moreidscol)
|
||||
{
|
||||
int id;
|
||||
if(int.TryParse(sid.Trim(), out id) && id != 0 && !tags.Contains(id))
|
||||
{
|
||||
tags.Add(id);
|
||||
|
@ -387,9 +387,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
if(!string.IsNullOrEmpty(moreids))
|
||||
{
|
||||
string[] moreidscol = moreids.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
|
||||
int id;
|
||||
foreach(string sid in moreidscol)
|
||||
foreach(string sid in moreidscol)
|
||||
{
|
||||
int id;
|
||||
if(int.TryParse(sid.Trim(), out id) && id != 0 && !tags.Contains(id))
|
||||
{
|
||||
tags.Add(id);
|
||||
|
@ -598,9 +598,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
List<UniversalCollection> list = new List<UniversalCollection>();
|
||||
|
||||
// Make list
|
||||
foreach (UniversalEntry e in collection)
|
||||
foreach(UniversalEntry e in collection)
|
||||
{
|
||||
if (!(e.Value is UniversalCollection) || (e.Key != entryname)) continue; //mxd
|
||||
if(!(e.Value is UniversalCollection) || (e.Key != entryname)) continue; //mxd
|
||||
list.Add(e.Value as UniversalCollection);
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
}
|
||||
|
||||
//mxd. Slopes
|
||||
if (s.FloorSlope.GetLengthSq() > 0)
|
||||
if(s.FloorSlope.GetLengthSq() > 0)
|
||||
{
|
||||
coll.Add("floorplane_a", Math.Round(s.FloorSlope.x, Sector.SLOPE_DECIMALS));
|
||||
coll.Add("floorplane_b", Math.Round(s.FloorSlope.y, Sector.SLOPE_DECIMALS));
|
||||
|
@ -302,7 +302,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
(float.IsNaN(s.FloorSlopeOffset) ? 0f : Math.Round(s.FloorSlopeOffset, Sector.SLOPE_DECIMALS)));
|
||||
}
|
||||
|
||||
if (s.CeilSlope.GetLengthSq() > 0)
|
||||
if(s.CeilSlope.GetLengthSq() > 0)
|
||||
{
|
||||
coll.Add("ceilingplane_a", Math.Round(s.CeilSlope.x, Sector.SLOPE_DECIMALS));
|
||||
coll.Add("ceilingplane_b", Math.Round(s.CeilSlope.y, Sector.SLOPE_DECIMALS));
|
||||
|
@ -336,10 +336,10 @@ namespace CodeImp.DoomBuilder.IO
|
|||
coll.Add("y", t.Position.y);
|
||||
if(t.Position.z != 0.0f) coll.Add("height", t.Position.z);
|
||||
coll.Add("angle", t.AngleDoom);
|
||||
if (t.Pitch != 0) coll.Add("pitch", t.Pitch); //mxd
|
||||
if (t.Roll != 0) coll.Add("roll", t.Roll); //mxd
|
||||
if (t.ScaleX != 0 && t.ScaleX != 1.0f) coll.Add("scalex", t.ScaleX); //mxd
|
||||
if (t.ScaleY != 0 && t.ScaleY != 1.0f) coll.Add("scaley", t.ScaleY); //mxd
|
||||
if(t.Pitch != 0) coll.Add("pitch", t.Pitch); //mxd
|
||||
if(t.Roll != 0) coll.Add("roll", t.Roll); //mxd
|
||||
if(t.ScaleX != 0 && t.ScaleX != 1.0f) coll.Add("scalex", t.ScaleX); //mxd
|
||||
if(t.ScaleY != 0 && t.ScaleY != 1.0f) coll.Add("scaley", t.ScaleY); //mxd
|
||||
coll.Add("type", t.Type);
|
||||
if(t.Action != 0) coll.Add("special", t.Action);
|
||||
if(t.Args[0] != 0) coll.Add("arg0", t.Args[0]);
|
||||
|
|
|
@ -186,9 +186,6 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// This reads the WAD header and lumps table
|
||||
private void ReadHeaders()
|
||||
{
|
||||
int offset, length;
|
||||
byte[] fixedname;
|
||||
|
||||
// Make sure the write is finished writing
|
||||
if(!isreadonly) writer.Flush();
|
||||
|
||||
|
@ -217,9 +214,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
for(int i = 0; i < numlumps; i++)
|
||||
{
|
||||
// Read lump information
|
||||
offset = reader.ReadInt32();
|
||||
length = reader.ReadInt32();
|
||||
fixedname = reader.ReadBytes(8);
|
||||
int offset = reader.ReadInt32();
|
||||
int length = reader.ReadInt32();
|
||||
byte[] fixedname = reader.ReadBytes(8);
|
||||
|
||||
// Create the lump
|
||||
lumps.Add(new Lump(file, this, fixedname, offset, length));
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
if (empty) return index + ": Empty";
|
||||
if(empty) return index + ": Empty";
|
||||
List<string> result = new List<string>();
|
||||
|
||||
if(numSectors > 0) result.Add(numSectors + (numSectors > 1 ? " sectors" : " sector"));
|
||||
|
|
|
@ -230,7 +230,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(s.IsWriting)
|
||||
{
|
||||
s.wInt(tags.Count);
|
||||
foreach (int tag in tags) s.wInt(tag);
|
||||
foreach(int tag in tags) s.wInt(tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -456,7 +456,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd. Hexen -> UDMF action translation. Hardcoded for now...
|
||||
if(previousmapformatinterfacetype == typeof(HexenMapSetIO))
|
||||
{
|
||||
switch (Action)
|
||||
switch(Action)
|
||||
{
|
||||
case 121: //Line_SetIdentification
|
||||
//Convert arg0 to tag
|
||||
|
@ -467,7 +467,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
//clear action and arguments
|
||||
action = 0;
|
||||
for (int i = 0; i < args.Length; i++) args[i] = 0;
|
||||
for(int i = 0; i < args.Length; i++) args[i] = 0;
|
||||
break;
|
||||
|
||||
case 208: //TranslucentLine
|
||||
|
@ -486,7 +486,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
case 160: //Sector_3DFloor
|
||||
// Convert to UDMF
|
||||
if ((args[1] & 8) == 8) // arg4 is LineID?
|
||||
if((args[1] & 8) == 8) // arg4 is LineID?
|
||||
{
|
||||
tags[0] = args[4];
|
||||
args[1] &= ~8; // Unset flag
|
||||
|
@ -585,9 +585,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
//mxd. UDMF -> Hexen action translation. Hardcoded for now...
|
||||
if (General.Map.FormatInterface is HexenMapSetIO)
|
||||
if(General.Map.FormatInterface is HexenMapSetIO)
|
||||
{
|
||||
switch (action)
|
||||
switch(action)
|
||||
{
|
||||
case 208: //TranslucentLine
|
||||
//Convert tag to arg0
|
||||
|
@ -645,7 +645,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
default: // Convert tag to Line_SetIdentification?
|
||||
if(tags[0] > General.Map.FormatInterface.MinArgument)
|
||||
{
|
||||
if (action != 0)
|
||||
if(action != 0)
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + Index + ": unable to convert Tag (" + tags[0] + ") to LineID, because linedef already has an action.");
|
||||
}
|
||||
|
@ -1249,8 +1249,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Returns false when the operation could not be completed.
|
||||
private bool JoinChangeSidedefs(Linedef target, bool front, Sidedef newside)
|
||||
{
|
||||
Sidedef sd;
|
||||
|
||||
// Change sidedefs
|
||||
if(front)
|
||||
{
|
||||
|
@ -1263,7 +1261,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
if(newside != null)
|
||||
{
|
||||
sd = map.CreateSidedef(target, front, newside.Sector);
|
||||
Sidedef sd = map.CreateSidedef(target, front, newside.Sector);
|
||||
if(sd == null) return false;
|
||||
newside.CopyPropertiesTo(sd);
|
||||
sd.Marked = newside.Marked;
|
||||
|
@ -1324,7 +1322,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if((oldline.back.MiddleRequired() && oldline.back.LongMiddleTexture != MapSet.EmptyLongName) || oldline.back.HighRequired() || oldline.back.LowRequired())
|
||||
{
|
||||
int distance = (int)Vector2D.Distance(newline.start.Position, newline.end.Position);
|
||||
if (General.Map.UDMF)
|
||||
if(General.Map.UDMF)
|
||||
{
|
||||
if(distance != 0) oldline.back.SetUdmfTextureOffsetX(distance);
|
||||
}
|
||||
|
|
|
@ -173,9 +173,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Constructor to load from Doom Builder Map Settings Configuration
|
||||
internal MapOptions(Configuration cfg, string mapname, bool longtexturenamessupported)
|
||||
{
|
||||
IDictionary resinfo;
|
||||
DataLocation res;
|
||||
|
||||
// Initialize
|
||||
this.previousname = "";
|
||||
this.currentname = mapname;
|
||||
|
@ -199,7 +196,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
foreach(DictionaryEntry entry in (ListDictionary)tagLabelsEntry.Value)
|
||||
{
|
||||
switch ((string)entry.Key)
|
||||
switch((string)entry.Key)
|
||||
{
|
||||
case "tag": tag = (int)entry.Value; break;
|
||||
case "label": label = (string)entry.Value; break;
|
||||
|
@ -250,8 +247,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(mp.Value is IDictionary)
|
||||
{
|
||||
// Create resource
|
||||
resinfo = (IDictionary)mp.Value;
|
||||
res = new DataLocation();
|
||||
IDictionary resinfo = (IDictionary)mp.Value;
|
||||
DataLocation res = new DataLocation();
|
||||
|
||||
// Copy information from Configuration to ResourceLocation
|
||||
if(resinfo.Contains("type") && (resinfo["type"] is int)) res.type = (int)resinfo["type"];
|
||||
|
|
|
@ -330,9 +330,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// </summary>
|
||||
public MapSet Clone()
|
||||
{
|
||||
Linedef nl;
|
||||
Sidedef nd;
|
||||
|
||||
// Create the map set
|
||||
MapSet newset = new MapSet();
|
||||
newset.BeginAddRemove();
|
||||
|
@ -358,14 +355,14 @@ namespace CodeImp.DoomBuilder.Map
|
|||
foreach(Linedef l in linedefs)
|
||||
{
|
||||
// Make new linedef
|
||||
nl = newset.CreateLinedef(l.Start.Clone, l.End.Clone);
|
||||
Linedef nl = newset.CreateLinedef(l.Start.Clone, l.End.Clone);
|
||||
l.CopyPropertiesTo(nl);
|
||||
|
||||
// Linedef has a front side?
|
||||
if(l.Front != null)
|
||||
{
|
||||
// Make new sidedef
|
||||
nd = newset.CreateSidedef(nl, true, l.Front.Sector.Clone);
|
||||
Sidedef nd = newset.CreateSidedef(nl, true, l.Front.Sector.Clone);
|
||||
l.Front.CopyPropertiesTo(nd);
|
||||
}
|
||||
|
||||
|
@ -373,7 +370,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(l.Back != null)
|
||||
{
|
||||
// Make new sidedef
|
||||
nd = newset.CreateSidedef(nl, false, l.Back.Sector.Clone);
|
||||
Sidedef nd = newset.CreateSidedef(nl, false, l.Back.Sector.Clone);
|
||||
l.Back.CopyPropertiesTo(nd);
|
||||
}
|
||||
}
|
||||
|
@ -1383,8 +1380,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd
|
||||
internal void WriteSelectionGroups(Configuration cfg)
|
||||
{
|
||||
List<string> indices;
|
||||
|
||||
// Fill structure
|
||||
IDictionary groups = new ListDictionary();
|
||||
for(int i = 0; i < 10; i++)
|
||||
|
@ -1393,7 +1388,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
int groupmask = 0x01 << i;
|
||||
|
||||
//store verts
|
||||
indices = new List<string>();
|
||||
List<string> indices = new List<string>();
|
||||
foreach(Vertex e in vertices) if(e.IsInGroup(groupmask)) indices.Add(e.Index.ToString());
|
||||
if(indices.Count > 0) group.Add("vertices", string.Join(" ", indices.ToArray()));
|
||||
|
||||
|
@ -1424,7 +1419,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
internal void ReadSelectionGroups(Configuration cfg)
|
||||
{
|
||||
IDictionary grouplist = cfg.ReadSetting(SELECTION_GROUPS_PATH, new Hashtable());
|
||||
IDictionary groupinfo;
|
||||
|
||||
foreach(DictionaryEntry mp in grouplist)
|
||||
{
|
||||
|
@ -1436,16 +1430,15 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(!int.TryParse(mp.Key as string, out groupnum)) continue;
|
||||
|
||||
int groupmask = 0x01 << General.Clamp(groupnum, 0, 10);
|
||||
groupinfo = (IDictionary)mp.Value;
|
||||
IDictionary groupinfo = (IDictionary)mp.Value;
|
||||
|
||||
if(groupinfo.Contains("vertices"))
|
||||
{
|
||||
string s = groupinfo["vertices"] as string;
|
||||
if (!string.IsNullOrEmpty(s))
|
||||
if(!string.IsNullOrEmpty(s))
|
||||
{
|
||||
List<int> indices = GetIndices(groupinfo["vertices"] as string);
|
||||
|
||||
foreach (int index in indices)
|
||||
foreach(int index in indices)
|
||||
{
|
||||
if(index > vertices.Length) continue;
|
||||
vertices[index].AddToGroup(groupmask);
|
||||
|
@ -1459,7 +1452,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(!string.IsNullOrEmpty(s))
|
||||
{
|
||||
List<int> indices = GetIndices(groupinfo["linedefs"] as string);
|
||||
|
||||
foreach(int index in indices)
|
||||
{
|
||||
if(index > linedefs.Length) continue;
|
||||
|
@ -1474,7 +1466,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(!string.IsNullOrEmpty(s))
|
||||
{
|
||||
List<int> indices = GetIndices(groupinfo["sectors"] as string);
|
||||
|
||||
foreach(int index in indices)
|
||||
{
|
||||
if(index > sectors.Length) continue;
|
||||
|
@ -1489,7 +1480,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(!string.IsNullOrEmpty(s))
|
||||
{
|
||||
List<int> indices = GetIndices(groupinfo["things"] as string);
|
||||
|
||||
foreach(int index in indices)
|
||||
{
|
||||
if(index > things.Length) continue;
|
||||
|
@ -1508,7 +1498,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
int index;
|
||||
List<int> result = new List<int>(parts.Length);
|
||||
|
||||
foreach (string part in parts) if(int.TryParse(part, out index)) result.Add(index);
|
||||
foreach(string part in parts) if(int.TryParse(part, out index)) result.Add(index);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -2005,7 +1995,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
foreach(Linedef l in lines)
|
||||
{
|
||||
// Check the cs field bits
|
||||
if ((GetCSFieldBits(l.Start.Position, area) & GetCSFieldBits(l.End.Position, area)) == 0)
|
||||
if((GetCSFieldBits(l.Start.Position, area) & GetCSFieldBits(l.End.Position, area)) == 0)
|
||||
{
|
||||
// The line could be in the area
|
||||
newlines.Add(l);
|
||||
|
@ -2367,7 +2357,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
float joindist2 = joindist * joindist;
|
||||
int joinsdone = 0;
|
||||
bool joined;
|
||||
Vertex v1, v2;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -2379,14 +2368,14 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
for(int c = i + 1; c < set.Count; c++)
|
||||
{
|
||||
v1 = set[i];
|
||||
v2 = set[c];
|
||||
Vertex v1 = set[i];
|
||||
Vertex v2 = set[c];
|
||||
|
||||
// Check if vertices are close enough
|
||||
if (v1.DistanceToSq(v2.Position) <= joindist2)
|
||||
if(v1.DistanceToSq(v2.Position) <= joindist2)
|
||||
{
|
||||
// Check if not the same vertex
|
||||
if (v1.Index != v2.Index)
|
||||
if(v1.Index != v2.Index)
|
||||
{
|
||||
// Move the second vertex to match the first
|
||||
v2.Move(v1.Position);
|
||||
|
@ -2435,7 +2424,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// will be added to changedlines. Returns false when the operation failed.</summary>
|
||||
public static bool SplitLinesByVertices(ICollection<Linedef> lines, ICollection<Vertex> verts, float splitdist, ICollection<Linedef> changedlines)
|
||||
{
|
||||
if (verts.Count == 0 || lines.Count == 0) return true; //mxd
|
||||
if(verts.Count == 0 || lines.Count == 0) return true; //mxd
|
||||
|
||||
float splitdist2 = splitdist * splitdist;
|
||||
bool splitted;
|
||||
|
@ -2449,19 +2438,17 @@ namespace CodeImp.DoomBuilder.Map
|
|||
int bmWidth = blockmap.Size.Width;
|
||||
int bmHeight = blockmap.Size.Height;
|
||||
BlockEntry[,] bmap = blockmap.Map;
|
||||
BlockEntry block;
|
||||
int w, h;
|
||||
|
||||
do
|
||||
{
|
||||
// No split yet
|
||||
splitted = false;
|
||||
|
||||
for(w = 0; w < bmWidth; w++)
|
||||
for(int w = 0; w < bmWidth; w++)
|
||||
{
|
||||
for(h = 0; h < bmHeight; h++)
|
||||
for(int h = 0; h < bmHeight; h++)
|
||||
{
|
||||
block = bmap[w, h];
|
||||
BlockEntry block = bmap[w, h];
|
||||
if(block.Vertices.Count == 0 || block.Lines.Count == 0) continue;
|
||||
|
||||
// Go for all the lines
|
||||
|
@ -2581,13 +2568,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
Linedef closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float maxrangesq = maxrange * maxrange;
|
||||
float d;
|
||||
|
||||
// Go for all linedefs in selection
|
||||
foreach(Linedef l in selection)
|
||||
{
|
||||
// Calculate distance and check if closer than previous find
|
||||
d = l.SafeDistanceToSq(pos, true);
|
||||
float d = l.SafeDistanceToSq(pos, true);
|
||||
if(d < distance && d <= maxrangesq)
|
||||
{
|
||||
// This one is closer
|
||||
|
@ -2629,13 +2615,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
Vertex closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float d;
|
||||
|
||||
|
||||
// Go for all vertices in selection
|
||||
foreach(Vertex v in selection)
|
||||
{
|
||||
// Calculate distance and check if closer than previous find
|
||||
d = v.DistanceToSq(pos);
|
||||
float d = v.DistanceToSq(pos);
|
||||
if(d < distance)
|
||||
{
|
||||
// This one is closer
|
||||
|
@ -2653,13 +2638,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
Thing closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float d;
|
||||
|
||||
// Go for all things in selection
|
||||
foreach(Thing t in selection)
|
||||
{
|
||||
// Calculate distance and check if closer than previous find
|
||||
d = t.DistanceToSq(pos);
|
||||
float d = t.DistanceToSq(pos);
|
||||
if(d < distance)
|
||||
{
|
||||
// This one is closer
|
||||
|
@ -2677,7 +2661,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
Thing closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float d;
|
||||
|
||||
// Go for all things in selection
|
||||
foreach(Thing t in selection)
|
||||
|
@ -2685,7 +2668,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(t == thing) continue;
|
||||
|
||||
// Calculate distance and check if closer than previous find
|
||||
d = t.DistanceToSq(thing.Position);
|
||||
float d = t.DistanceToSq(thing.Position);
|
||||
if(d < distance)
|
||||
{
|
||||
// This one is closer
|
||||
|
@ -2704,13 +2687,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
RectangleF range = RectangleF.FromLTRB(pos.x - maxrange, pos.y - maxrange, pos.x + maxrange, pos.y + maxrange);
|
||||
Vertex closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float d, px, py;
|
||||
|
||||
// Go for all vertices in selection
|
||||
foreach(Vertex v in selection)
|
||||
{
|
||||
px = v.Position.x;
|
||||
py = v.Position.y;
|
||||
float px = v.Position.x;
|
||||
float py = v.Position.y;
|
||||
|
||||
//mxd. Within range?
|
||||
if((v.Position.x < range.Left) || (v.Position.x > range.Right)
|
||||
|
@ -2718,7 +2700,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
continue;
|
||||
|
||||
// Close than previous find?
|
||||
d = Math.Abs(px - pos.x) + Math.Abs(py - pos.y);
|
||||
float d = Math.Abs(px - pos.x) + Math.Abs(py - pos.y);
|
||||
if(d < distance)
|
||||
{
|
||||
// This one is closer
|
||||
|
@ -2738,20 +2720,19 @@ namespace CodeImp.DoomBuilder.Map
|
|||
Thing closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float size = float.MaxValue; //mxd
|
||||
float d, px, py, ts;
|
||||
|
||||
// Go for all things in selection
|
||||
foreach(Thing t in selection)
|
||||
{
|
||||
px = t.Position.x;
|
||||
py = t.Position.y;
|
||||
ts = ((t.FixedSize && General.Map.Renderer2D.Scale > 1.0f) ? t.Size / General.Map.Renderer2D.Scale : t.Size); //mxd
|
||||
float px = t.Position.x;
|
||||
float py = t.Position.y;
|
||||
float ts = ((t.FixedSize && General.Map.Renderer2D.Scale > 1.0f) ? t.Size / General.Map.Renderer2D.Scale : t.Size);
|
||||
|
||||
//mxd. Within range?
|
||||
if(px < range.Left - ts || px > range.Right + ts || py < range.Top - ts || py > range.Bottom + ts) continue;
|
||||
|
||||
// Closer than previous find? mxd. Or smaller when distance is the same?
|
||||
d = Math.Abs(px - pos.x) + Math.Abs(py - pos.y);
|
||||
float d = Math.Abs(px - pos.x) + Math.Abs(py - pos.y);
|
||||
if(d < distance || (d == distance && ts < size))
|
||||
{
|
||||
// This one is closer
|
||||
|
@ -2833,7 +2814,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
case UniversalType.LinedefTag:
|
||||
for(int i = 0; i < linedefs.Length; i++)
|
||||
{
|
||||
foreach (int tag in linedefs[i].Tags)
|
||||
foreach(int tag in linedefs[i].Tags)
|
||||
{
|
||||
if(tag == 0) continue;
|
||||
if(!usedtags.ContainsKey(tag)) usedtags.Add(tag, false);
|
||||
|
@ -3101,9 +3082,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>This returns a sector if given coordinates are inside one.</summary>
|
||||
public Sector GetSectorByCoordinates(Vector2D pos)
|
||||
{
|
||||
foreach (Sector s in sectors)
|
||||
foreach(Sector s in sectors)
|
||||
{
|
||||
if (s.Intersect(pos)) return s;
|
||||
if(s.Intersect(pos)) return s;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -3143,13 +3124,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
Linedef closest = null;
|
||||
distance = float.MaxValue;
|
||||
float maxrangesq = maxrange * maxrange;
|
||||
float d;
|
||||
|
||||
// Go for all linedefs in selection
|
||||
foreach(Linedef l in linedefs)
|
||||
{
|
||||
// Calculate distance and check if closer than previous find
|
||||
d = l.SafeDistanceToSq(pos, true);
|
||||
float d = l.SafeDistanceToSq(pos, true);
|
||||
if((d <= maxrangesq) && (d < distance))
|
||||
{
|
||||
// Check if not selected
|
||||
|
@ -3194,7 +3174,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
foreach(Sidedef os in othersides)
|
||||
{
|
||||
// They must be in the same sector
|
||||
if (snsd.Sector == os.Sector)
|
||||
if(snsd.Sector == os.Sector)
|
||||
{
|
||||
// Check if sidedefs are really the same
|
||||
stored = os;
|
||||
|
@ -3204,14 +3184,14 @@ namespace CodeImp.DoomBuilder.Map
|
|||
SerializerStream otherdata = new SerializerStream(othermem);
|
||||
snsd.ReadWrite(sidedata);
|
||||
os.ReadWrite(otherdata);
|
||||
if (sidemem.Length == othermem.Length)
|
||||
if(sidemem.Length == othermem.Length)
|
||||
{
|
||||
samesidedef = true;
|
||||
sidemem.Seek(0, SeekOrigin.Begin);
|
||||
othermem.Seek(0, SeekOrigin.Begin);
|
||||
for (int i = 0; i < sidemem.Length; i++)
|
||||
for(int i = 0; i < sidemem.Length; i++)
|
||||
{
|
||||
if (sidemem.ReadByte() != othermem.ReadByte())
|
||||
if(sidemem.ReadByte() != othermem.ReadByte())
|
||||
{
|
||||
samesidedef = false;
|
||||
break;
|
||||
|
@ -3219,7 +3199,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
}
|
||||
|
||||
if (samesidedef) break;
|
||||
if(samesidedef) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3287,7 +3267,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd
|
||||
internal bool TranslateTextureNames(bool uselongnames, bool markedonly)
|
||||
{
|
||||
if (markedonly)
|
||||
if(markedonly)
|
||||
{
|
||||
List<Sector> markedsectors = GetMarkedSectors(true);
|
||||
List<Sidedef> markedsides = GetMarkedSidedefs(true);
|
||||
|
@ -3306,21 +3286,21 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
bool changed = false;
|
||||
|
||||
foreach (Sector s in sectors)
|
||||
foreach(Sector s in sectors)
|
||||
{
|
||||
if (s.FloorTexture != "-")
|
||||
if(s.FloorTexture != "-")
|
||||
{
|
||||
string ft = General.Map.Data.GetFullFlatName(s.FloorTexture);
|
||||
if (ft != s.FloorTexture)
|
||||
if(ft != s.FloorTexture)
|
||||
{
|
||||
s.SetFloorTexture(Lump.MakeLongName(ft));
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (s.CeilTexture != "-")
|
||||
if(s.CeilTexture != "-")
|
||||
{
|
||||
string ct = General.Map.Data.GetFullFlatName(s.CeilTexture);
|
||||
if (ct != s.CeilTexture)
|
||||
if(ct != s.CeilTexture)
|
||||
{
|
||||
s.SetCeilTexture(Lump.MakeLongName(ct));
|
||||
changed = true;
|
||||
|
@ -3328,30 +3308,30 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
}
|
||||
|
||||
foreach (Sidedef s in sidedefs)
|
||||
foreach(Sidedef s in sidedefs)
|
||||
{
|
||||
if (s.HighTexture != "-")
|
||||
if(s.HighTexture != "-")
|
||||
{
|
||||
string ht = General.Map.Data.GetFullTextureName(s.HighTexture);
|
||||
if (ht != s.HighTexture)
|
||||
if(ht != s.HighTexture)
|
||||
{
|
||||
s.SetTextureHigh(Lump.MakeLongName(ht));
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (s.MiddleTexture != "-")
|
||||
if(s.MiddleTexture != "-")
|
||||
{
|
||||
string mt = General.Map.Data.GetFullTextureName(s.MiddleTexture);
|
||||
if (mt != s.MiddleTexture)
|
||||
if(mt != s.MiddleTexture)
|
||||
{
|
||||
s.SetTextureMid(Lump.MakeLongName(mt));
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (s.LowTexture != "-")
|
||||
if(s.LowTexture != "-")
|
||||
{
|
||||
string lt = General.Map.Data.GetFullTextureName(s.LowTexture);
|
||||
if (lt != s.LowTexture)
|
||||
if(lt != s.LowTexture)
|
||||
{
|
||||
s.SetTextureLow(Lump.MakeLongName(lt));
|
||||
changed = true;
|
||||
|
@ -3371,7 +3351,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(s.FloorTexture != "-")
|
||||
{
|
||||
string ft = GetShortTextureName(s.FloorTexture);
|
||||
if (ft != s.FloorTexture)
|
||||
if(ft != s.FloorTexture)
|
||||
{
|
||||
s.SetFloorTexture(ft);
|
||||
changed = true;
|
||||
|
@ -3380,7 +3360,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(s.CeilTexture != "-")
|
||||
{
|
||||
string ct = GetShortTextureName(s.CeilTexture);
|
||||
if (ct != s.CeilTexture)
|
||||
if(ct != s.CeilTexture)
|
||||
{
|
||||
s.SetCeilTexture(ct);
|
||||
changed = true;
|
||||
|
@ -3393,7 +3373,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(s.HighTexture != "-")
|
||||
{
|
||||
string ht = GetShortTextureName(s.HighTexture);
|
||||
if (ht != s.HighTexture)
|
||||
if(ht != s.HighTexture)
|
||||
{
|
||||
s.SetTextureHigh(ht);
|
||||
changed = true;
|
||||
|
@ -3402,7 +3382,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(s.MiddleTexture != "-")
|
||||
{
|
||||
string mt = GetShortTextureName(s.MiddleTexture);
|
||||
if (mt != s.MiddleTexture)
|
||||
if(mt != s.MiddleTexture)
|
||||
{
|
||||
s.SetTextureMid(mt);
|
||||
changed = true;
|
||||
|
@ -3411,7 +3391,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(s.LowTexture != "-")
|
||||
{
|
||||
string lt = GetShortTextureName(s.LowTexture);
|
||||
if (lt != s.LowTexture)
|
||||
if(lt != s.LowTexture)
|
||||
{
|
||||
s.SetTextureLow(lt);
|
||||
changed = true;
|
||||
|
@ -3425,7 +3405,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
internal static string GetShortTextureName(string name)
|
||||
{
|
||||
string shortname = Path.GetFileNameWithoutExtension(name).ToUpperInvariant();
|
||||
if (shortname.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH) shortname = shortname.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH);
|
||||
if(shortname.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH) shortname = shortname.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH);
|
||||
return shortname;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue