UltimateZoneBuilder/Source/Core/Data/DataLocation.cs

143 lines
3.6 KiB
C#
Raw Normal View History

#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
Visual mode: "Fit Textures" action can now fit textures across multiple selected surfaces. A number of times to repeat a texture can now be specified. Visual mode: removed "Fit Texture's Width" and "Fit Texture's Height" actions. Visual mode: "Auto-align texture offsets" actions were incorrectly aligning double-sided middle walls in some cases. Visual mode: "Auto-align texture offsets" actions now align non-wrapped double-sided middle walls to vertical offset closest to their initial vertical offset. Visual mode: middle parts of double-sided walls were ignored when Shift-selecting walls. Nodebuilders/Game configurations: GL nodes definitions were missing from game configurations. Nodebuilders/Game configurations: "~MAP" wildcard can now be a part of a lump name. Nodebuilders: GL nodes were not properly handled by the editor. Main Window: the window is now moved into the view when stored position is ouside of screen bounds. Classic and Visual modes: changing thing pitch was ignored in some cases. Visual mode: raising and lowering a thing with "+SPAWNCEILING" flag now works the same way as when raising/lowering a regular thing. Visual mode: using "Raise/Lower Floor/Ceiling to adjacent sector" actions on a thing with "+SPAWNCEILING" flag now works the same way as when using them on a regular thing. Rendering: even more fixes to MODELDEF and UDMF properties-related model rendering logic. Internal, ResourceListEditor: rewritten resource validation check in a more OOP-ish way. Configurations: fixed an infinite loop crash when a file was trying to include() itself. UDMF thing flags: added Skill 6-8 to the flags list (because there are thing filters for these). ZDoom_ACS.cfg: added definitions for SetTeleFog and SwapTeleFog. ZDoom_DECORATE.cfg: added definitions for A_SetTeleFog and A_SwapTeleFog. Updated ZDoom ACC. Updated documentation.
2014-12-22 21:36:49 +00:00
using System.IO;
#endregion
namespace CodeImp.DoomBuilder.Data
{
public struct DataLocation : IComparable<DataLocation>, IComparable, IEquatable<DataLocation>
{
// Constants
public const int RESOURCE_WAD = 0;
public const int RESOURCE_DIRECTORY = 1;
public const int RESOURCE_PK3 = 2;
// Members
public int type;
public string location;
private string initiallocation; //mxd. Stores intial path inside a PK3/PK7. For display purposes only!
private string name; //mxd
public bool option1;
public bool option2;
public bool notfortesting;
// Constructor
public DataLocation(int type, string location, bool option1, bool option2, bool notfortesting)
{
// Initialize
this.type = type;
this.location = location;
this.initiallocation = string.Empty; //mxd
this.option1 = option1;
this.option2 = option2;
this.notfortesting = notfortesting;
this.name = string.Empty; //mxd
}
//mxd. Constructor for WADs inside of PK3s
internal DataLocation(int type, string location, string initiallocation, bool option1, bool option2, bool notfortesting)
{
// Initialize
this.type = type;
this.location = location;
this.initiallocation = initiallocation;
this.option1 = option1;
this.option2 = option2;
this.notfortesting = notfortesting;
this.name = string.Empty;
}
// This displays the struct as string
public override string ToString()
{
// Simply show location
return location;
}
//mxd. This returns short location name. May not correspond to actual file location! Use for display purposes only!
public string GetDisplayName()
{
if(string.IsNullOrEmpty(name))
{
// Make shorter name for display purposes
switch(type)
{
case RESOURCE_DIRECTORY:
name = location.Substring(location.LastIndexOf(Path.DirectorySeparatorChar) + 1);
break;
case RESOURCE_WAD:
name = (!string.IsNullOrEmpty(initiallocation) ? initiallocation : Path.GetFileName(location));
break;
case RESOURCE_PK3:
name = Path.GetFileName(location);
break;
default:
throw new NotImplementedException("Unknown location type: " + type);
}
}
return (name ?? string.Empty);
}
// This compares two locations
public int CompareTo(DataLocation other)
{
return string.Compare(this.location, other.location, true);
}
// This compares two locations
public int CompareTo(object obj)
{
return string.Compare(this.location, ((DataLocation)obj).location, true);
}
// This compares two locations
public bool Equals(DataLocation other)
{
return (this.CompareTo(other) == 0);
}
Visual mode: "Fit Textures" action can now fit textures across multiple selected surfaces. A number of times to repeat a texture can now be specified. Visual mode: removed "Fit Texture's Width" and "Fit Texture's Height" actions. Visual mode: "Auto-align texture offsets" actions were incorrectly aligning double-sided middle walls in some cases. Visual mode: "Auto-align texture offsets" actions now align non-wrapped double-sided middle walls to vertical offset closest to their initial vertical offset. Visual mode: middle parts of double-sided walls were ignored when Shift-selecting walls. Nodebuilders/Game configurations: GL nodes definitions were missing from game configurations. Nodebuilders/Game configurations: "~MAP" wildcard can now be a part of a lump name. Nodebuilders: GL nodes were not properly handled by the editor. Main Window: the window is now moved into the view when stored position is ouside of screen bounds. Classic and Visual modes: changing thing pitch was ignored in some cases. Visual mode: raising and lowering a thing with "+SPAWNCEILING" flag now works the same way as when raising/lowering a regular thing. Visual mode: using "Raise/Lower Floor/Ceiling to adjacent sector" actions on a thing with "+SPAWNCEILING" flag now works the same way as when using them on a regular thing. Rendering: even more fixes to MODELDEF and UDMF properties-related model rendering logic. Internal, ResourceListEditor: rewritten resource validation check in a more OOP-ish way. Configurations: fixed an infinite loop crash when a file was trying to include() itself. UDMF thing flags: added Skill 6-8 to the flags list (because there are thing filters for these). ZDoom_ACS.cfg: added definitions for SetTeleFog and SwapTeleFog. ZDoom_DECORATE.cfg: added definitions for A_SetTeleFog and A_SwapTeleFog. Updated ZDoom ACC. Updated documentation.
2014-12-22 21:36:49 +00:00
//mxd
public bool IsValid()
{
switch(type)
{
case RESOURCE_DIRECTORY:
if(!Directory.Exists(location)) return false;
break;
case RESOURCE_WAD:
case RESOURCE_PK3:
if(!File.Exists(location)) return false;
break;
default:
throw new NotImplementedException("Unknown location type: " + type);
Visual mode: "Fit Textures" action can now fit textures across multiple selected surfaces. A number of times to repeat a texture can now be specified. Visual mode: removed "Fit Texture's Width" and "Fit Texture's Height" actions. Visual mode: "Auto-align texture offsets" actions were incorrectly aligning double-sided middle walls in some cases. Visual mode: "Auto-align texture offsets" actions now align non-wrapped double-sided middle walls to vertical offset closest to their initial vertical offset. Visual mode: middle parts of double-sided walls were ignored when Shift-selecting walls. Nodebuilders/Game configurations: GL nodes definitions were missing from game configurations. Nodebuilders/Game configurations: "~MAP" wildcard can now be a part of a lump name. Nodebuilders: GL nodes were not properly handled by the editor. Main Window: the window is now moved into the view when stored position is ouside of screen bounds. Classic and Visual modes: changing thing pitch was ignored in some cases. Visual mode: raising and lowering a thing with "+SPAWNCEILING" flag now works the same way as when raising/lowering a regular thing. Visual mode: using "Raise/Lower Floor/Ceiling to adjacent sector" actions on a thing with "+SPAWNCEILING" flag now works the same way as when using them on a regular thing. Rendering: even more fixes to MODELDEF and UDMF properties-related model rendering logic. Internal, ResourceListEditor: rewritten resource validation check in a more OOP-ish way. Configurations: fixed an infinite loop crash when a file was trying to include() itself. UDMF thing flags: added Skill 6-8 to the flags list (because there are thing filters for these). ZDoom_ACS.cfg: added definitions for SetTeleFog and SwapTeleFog. ZDoom_DECORATE.cfg: added definitions for A_SetTeleFog and A_SwapTeleFog. Updated ZDoom ACC. Updated documentation.
2014-12-22 21:36:49 +00:00
}
return true;
}
}
}