From fd085848e60831a8582c24de8f30ad4528f9d490 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 26 Mar 2011 03:45:34 +0100 Subject: unfinished console interface to NW4RTools added --- NW4RTools/BrresReader.cs | 14 +++++++++++--- NW4RTools/Logger.cs | 20 ++++++++++++++++++++ NW4RTools/ResFile.cs | 2 +- NW4RTools/bin/Debug/NW4RTools.dll | Bin 238592 -> 239104 bytes NW4RTools/bin/Debug/NW4RTools.dll.mdb | Bin 114661 -> 114935 bytes 5 files changed, 32 insertions(+), 4 deletions(-) (limited to 'NW4RTools') diff --git a/NW4RTools/BrresReader.cs b/NW4RTools/BrresReader.cs index d5db720..aa54437 100644 --- a/NW4RTools/BrresReader.cs +++ b/NW4RTools/BrresReader.cs @@ -7,7 +7,11 @@ using NW4RTools.Models; namespace NW4RTools { public class BrresReader { public static ResFile LoadFile(byte[] data) { - return new BrresReader().Load(new InputStream(data, ByteEndian.BigEndian)); + return LoadFile(data, true); + } + + public static ResFile LoadFile(byte[] data, bool debug) { + return new BrresReader(debug).Load(new InputStream(data, ByteEndian.BigEndian)); } @@ -21,8 +25,12 @@ namespace NW4RTools { private ILogger Debug; private SortedDictionary OffsetMap; - private BrresReader() { - Debug = new ConsoleLogger(); + private BrresReader(bool debug) { + if (debug) + Debug = new ConsoleLogger(); + else + Debug = new NullLogger(); + OffsetMap = new SortedDictionary(); } diff --git a/NW4RTools/Logger.cs b/NW4RTools/Logger.cs index a6fbb70..9f7d063 100644 --- a/NW4RTools/Logger.cs +++ b/NW4RTools/Logger.cs @@ -24,6 +24,26 @@ namespace NW4RTools { void Unblock(); } + public class NullLogger : ILogger { + public NullLogger() { } + + public void Send(string format, params object[] args) { + } + + public LogContext Push(string format, params object[] args) { + return new LogContext(this); + } + + public void Pop() { + } + + public void Block() { + } + + public void Unblock() { + } + } + public class ConsoleLogger : ILogger { private List PrefixElements; private List Names; diff --git a/NW4RTools/ResFile.cs b/NW4RTools/ResFile.cs index 4f4a1b8..aae0038 100644 --- a/NW4RTools/ResFile.cs +++ b/NW4RTools/ResFile.cs @@ -19,7 +19,7 @@ namespace NW4RTools { } public ResDict GetGroup(string name) { - return this[name] as ResDict; + return ContainsKey(name) ? (this[name] as ResDict) : null; } diff --git a/NW4RTools/bin/Debug/NW4RTools.dll b/NW4RTools/bin/Debug/NW4RTools.dll index 9b33424..3e86a0a 100755 Binary files a/NW4RTools/bin/Debug/NW4RTools.dll and b/NW4RTools/bin/Debug/NW4RTools.dll differ diff --git a/NW4RTools/bin/Debug/NW4RTools.dll.mdb b/NW4RTools/bin/Debug/NW4RTools.dll.mdb index 183dfbb..1bff220 100644 Binary files a/NW4RTools/bin/Debug/NW4RTools.dll.mdb and b/NW4RTools/bin/Debug/NW4RTools.dll.mdb differ -- cgit v1.2.3