UltimateZoneBuilder/Source/Core/Data/DataLocationList.cs

122 lines
3.5 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.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using CodeImp.DoomBuilder.IO;
#endregion
namespace CodeImp.DoomBuilder.Data
{
public sealed class DataLocationList : List<DataLocation>
{
#region ================== Constructors
// This creates a new list
public DataLocationList()
{
}
// This makes a copy of a list
public DataLocationList(IEnumerable<DataLocation> list) : base(list)
{
}
// This creates a list from a configuration structure
internal DataLocationList(Configuration cfg, string path)
{
// Go for all items in the map info
IDictionary resinfo = cfg.ReadSetting(path, new ListDictionary());
foreach(DictionaryEntry rl in resinfo)
{
// Item is a structure?
IDictionary rlinfo = rl.Value as IDictionary;
if(rlinfo != null)
{
// Create resource location
DataLocation res = new DataLocation();
// Copy information from Configuration to ResourceLocation
if(rlinfo.Contains("type") && (rlinfo["type"] is int)) res.type = (int)rlinfo["type"];
if(rlinfo.Contains("location") && (rlinfo["location"] is string)) res.location = (string)rlinfo["location"];
if(rlinfo.Contains("option1") && (rlinfo["option1"] is int)) res.option1 = General.Int2Bool((int)rlinfo["option1"]);
if(rlinfo.Contains("option2") && (rlinfo["option2"] is int)) res.option2 = General.Int2Bool((int)rlinfo["option2"]);
if(rlinfo.Contains("notfortesting") && (rlinfo["notfortesting"] is int)) res.notfortesting = General.Int2Bool((int)rlinfo["notfortesting"]);
// Add resource
Add(res);
}
}
}
#endregion
#region ================== Methods
// This merges two lists together
public static DataLocationList Combined(DataLocationList a, DataLocationList b)
{
DataLocationList result = new DataLocationList(a);
//mxd. In case of duplicates, keep the last entry
foreach(DataLocation dl in b)
{
result.Remove(dl);
result.Add(dl);
}
return result;
}
// This writes the list to configuration
internal void WriteToConfig(Configuration cfg, string path)
{
// Fill structure
IDictionary resinfo = new ListDictionary();
for(int i = 0; i < this.Count; i++)
{
// Create structure for resource
IDictionary rlinfo = new ListDictionary();
rlinfo.Add("type", this[i].type);
rlinfo.Add("location", this[i].location);
rlinfo.Add("option1", General.Bool2Int(this[i].option1));
rlinfo.Add("option2", General.Bool2Int(this[i].option2));
rlinfo.Add("notfortesting", General.Bool2Int(this[i].notfortesting));
// Add structure
resinfo.Add("resource" + i.ToString(CultureInfo.InvariantCulture), rlinfo);
}
// Write to config
cfg.WriteSetting(path, resinfo);
}
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()
{
foreach(DataLocation location in this) if(!location.IsValid()) return false;
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;
}
#endregion
}
}