mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-30 15:41:30 +00:00
130 lines
2.5 KiB
C#
130 lines
2.5 KiB
C#
|
|
#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;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Text;
|
|
using System.Drawing;
|
|
using System.Drawing.Imaging;
|
|
using System.IO;
|
|
|
|
#endregion
|
|
|
|
namespace CodeImp.DoomBuilder.Data
|
|
{
|
|
internal class DataManager : IDisposable
|
|
{
|
|
#region ================== Constants
|
|
|
|
#endregion
|
|
|
|
#region ================== Variables
|
|
|
|
// Data containers
|
|
private List<IDataReader> containers;
|
|
|
|
// Disposing
|
|
private bool isdisposed = false;
|
|
|
|
#endregion
|
|
|
|
#region ================== Properties
|
|
|
|
// Disposing
|
|
public bool IsDisposed { get { return isdisposed; } }
|
|
|
|
#endregion
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
// Constructor
|
|
public DataManager()
|
|
{
|
|
// Initialize
|
|
containers = new List<IDataReader>();
|
|
|
|
// We have no destructor
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
// Disposer
|
|
public void Dispose()
|
|
{
|
|
// Not already disposed?
|
|
if(!isdisposed)
|
|
{
|
|
// Clean up
|
|
|
|
// Done
|
|
isdisposed = true;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ================== Loading / Unloading
|
|
|
|
// This loads all data resources
|
|
public void Load(DataLocationList locations)
|
|
{
|
|
IDataReader c;
|
|
|
|
// Go for all locations
|
|
foreach(DataLocation dl in locations)
|
|
{
|
|
// Nothing chosen yet
|
|
c = null;
|
|
|
|
// Choose container type
|
|
switch(dl.type)
|
|
{
|
|
// WAD file container
|
|
case DataLocation.RESOURCE_WAD:
|
|
c = new WADReader(dl);
|
|
break;
|
|
|
|
// Directory container
|
|
case DataLocation.RESOURCE_DIRECTORY:
|
|
c = new DirectoryReader(dl);
|
|
break;
|
|
}
|
|
|
|
// Container type chosen?
|
|
if(c != null)
|
|
{
|
|
// TODO: Let the container read stuff
|
|
|
|
// Keep container reference
|
|
containers.Add(c);
|
|
}
|
|
}
|
|
}
|
|
|
|
// This unloads all data
|
|
public void Unload()
|
|
{
|
|
// Dispose containers
|
|
foreach(IDataReader c in containers) c.Dispose();
|
|
containers.Clear();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|