Started on splitting off classic strings manager
This commit is contained in:
parent
1daefa275b
commit
c245c7a9be
@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.1231
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CnCTDRAMapEditor", "CnCTDRAMapEditor\CnCTDRAMapEditor.csproj", "{397CEF00-8930-4EC8-B15F-F7CF7193FB22}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CnCTDRAMapEditor", "CnCTDRAMapEditor\CnCTDRAMapEditor.csproj", "{397CEF00-8930-4EC8-B15F-F7CF7193FB22}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CCFileSystem", "CCFileSystem\CCFileSystem.csproj", "{925C0B51-E256-4A5C-8B01-F46AA90982D5}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -27,6 +29,18 @@ Global
|
|||||||
{397CEF00-8930-4EC8-B15F-F7CF7193FB22}.Release|Any CPU.Build.0 = Release|Any CPU
|
{397CEF00-8930-4EC8-B15F-F7CF7193FB22}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{397CEF00-8930-4EC8-B15F-F7CF7193FB22}.Release|x64.ActiveCfg = Release|x64
|
{397CEF00-8930-4EC8-B15F-F7CF7193FB22}.Release|x64.ActiveCfg = Release|x64
|
||||||
{397CEF00-8930-4EC8-B15F-F7CF7193FB22}.Release|x64.Build.0 = Release|x64
|
{397CEF00-8930-4EC8-B15F-F7CF7193FB22}.Release|x64.Build.0 = Release|x64
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Gold|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Gold|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Gold|x64.ActiveCfg = Debug|x64
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Gold|x64.Build.0 = Debug|x64
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{925C0B51-E256-4A5C-8B01-F46AA90982D5}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -325,6 +325,7 @@
|
|||||||
<Compile Include="Interface\IFeedBackHandler.cs" />
|
<Compile Include="Interface\IFeedBackHandler.cs" />
|
||||||
<Compile Include="Interface\IArchiveManager.cs" />
|
<Compile Include="Interface\IArchiveManager.cs" />
|
||||||
<Compile Include="Interface\IGamePlugin.cs" />
|
<Compile Include="Interface\IGamePlugin.cs" />
|
||||||
|
<Compile Include="Interface\IGameTextManager.cs" />
|
||||||
<Compile Include="Interface\INamedType.cs" />
|
<Compile Include="Interface\INamedType.cs" />
|
||||||
<Compile Include="Interface\ITeamColor.cs" />
|
<Compile Include="Interface\ITeamColor.cs" />
|
||||||
<Compile Include="Interface\ITechno.cs" />
|
<Compile Include="Interface\ITechno.cs" />
|
||||||
@ -598,6 +599,7 @@
|
|||||||
<Compile Include="Utility\CRC.cs" />
|
<Compile Include="Utility\CRC.cs" />
|
||||||
<Compile Include="Utility\ExtensionMethods.cs" />
|
<Compile Include="Utility\ExtensionMethods.cs" />
|
||||||
<Compile Include="Utility\GameTextManager.cs" />
|
<Compile Include="Utility\GameTextManager.cs" />
|
||||||
|
<Compile Include="Utility\GameTextManagerClassic.cs" />
|
||||||
<Compile Include="Utility\GeneralUtils.cs" />
|
<Compile Include="Utility\GeneralUtils.cs" />
|
||||||
<Compile Include="Utility\GenericBooleanTypeConverter.cs" />
|
<Compile Include="Utility\GenericBooleanTypeConverter.cs" />
|
||||||
<Compile Include="Utility\ImageUtils.cs" />
|
<Compile Include="Utility\ImageUtils.cs" />
|
||||||
|
@ -130,7 +130,7 @@ namespace MobiusEditor
|
|||||||
public static TextureManager TheTextureManager;
|
public static TextureManager TheTextureManager;
|
||||||
public static TilesetManager TheTilesetManager;
|
public static TilesetManager TheTilesetManager;
|
||||||
public static ITeamColorManager TheTeamColorManager;
|
public static ITeamColorManager TheTeamColorManager;
|
||||||
public static GameTextManager TheGameTextManager;
|
public static IGameTextManager TheGameTextManager;
|
||||||
|
|
||||||
public static readonly string RootSaveDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"CnCRemastered\Local_Custom_Maps");
|
public static readonly string RootSaveDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"CnCRemastered\Local_Custom_Maps");
|
||||||
|
|
||||||
|
@ -12,5 +12,6 @@ namespace MobiusEditor.Interface
|
|||||||
bool LoadArchive(string archivePath);
|
bool LoadArchive(string archivePath);
|
||||||
bool FileExists(string path);
|
bool FileExists(string path);
|
||||||
Stream OpenFile(string path);
|
Stream OpenFile(string path);
|
||||||
|
void Reset(GameType gameType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
CnCTDRAMapEditor/Interface/IGameTextManager.cs
Normal file
14
CnCTDRAMapEditor/Interface/IGameTextManager.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MobiusEditor.Interface
|
||||||
|
{
|
||||||
|
public interface IGameTextManager
|
||||||
|
{
|
||||||
|
String this[string key] { get; }
|
||||||
|
void Reset(GameType gameType);
|
||||||
|
}
|
||||||
|
}
|
@ -1299,14 +1299,16 @@ namespace MobiusEditor
|
|||||||
|
|
||||||
private static IGamePlugin LoadNewPlugin(GameType gameType, bool isTdMegaMap, string[] modPaths, bool noImage)
|
private static IGamePlugin LoadNewPlugin(GameType gameType, bool isTdMegaMap, string[] modPaths, bool noImage)
|
||||||
{
|
{
|
||||||
|
// Resetting to a specific game type will take care of classic mode.
|
||||||
|
Globals.TheGameTextManager.Reset(gameType);
|
||||||
|
Globals.TheArchiveManager.Reset(gameType);
|
||||||
Globals.TheTextureManager.ExpandModPaths = modPaths;
|
Globals.TheTextureManager.ExpandModPaths = modPaths;
|
||||||
Globals.TheTextureManager.Reset();
|
Globals.TheTextureManager.Reset();
|
||||||
Globals.TheTilesetManager.ExpandModPaths = modPaths;
|
Globals.TheTilesetManager.ExpandModPaths = modPaths;
|
||||||
Globals.TheTilesetManager.Reset();
|
Globals.TheTilesetManager.Reset();
|
||||||
Globals.TheTeamColorManager.ExpandModPaths = modPaths;
|
Globals.TheTeamColorManager.ExpandModPaths = modPaths;
|
||||||
IGamePlugin plugin = null;
|
|
||||||
// Reset will take care of the colours in classic mode.
|
|
||||||
Globals.TheTeamColorManager.Reset(gameType);
|
Globals.TheTeamColorManager.Reset(gameType);
|
||||||
|
IGamePlugin plugin = null;
|
||||||
if (gameType == GameType.TiberianDawn)
|
if (gameType == GameType.TiberianDawn)
|
||||||
{
|
{
|
||||||
Globals.TheTeamColorManager.Load(@"DATA\XML\CNCTDTEAMCOLORS.XML");
|
Globals.TheTeamColorManager.Load(@"DATA\XML\CNCTDTEAMCOLORS.XML");
|
||||||
|
@ -19,15 +19,21 @@ using System.Text;
|
|||||||
|
|
||||||
namespace MobiusEditor.Utility
|
namespace MobiusEditor.Utility
|
||||||
{
|
{
|
||||||
public class GameTextManager
|
public class GameTextManager: IGameTextManager
|
||||||
{
|
{
|
||||||
|
private IArchiveManager fileManager;
|
||||||
|
private Dictionary<GameType, string> gameTextPaths;
|
||||||
private readonly Dictionary<string, string> gameText = new Dictionary<string, string>();
|
private readonly Dictionary<string, string> gameText = new Dictionary<string, string>();
|
||||||
|
|
||||||
public string this[string textId] => gameText.TryGetValue(textId, out string text) ? text : textId;
|
public string this[string textId] => gameText.TryGetValue(textId, out string text) ? text : textId;
|
||||||
|
|
||||||
public GameTextManager(IArchiveManager megafileManager, string gameTextFile)
|
public void Reset(GameType gameType)
|
||||||
{
|
{
|
||||||
using (var stream = megafileManager.OpenFile(gameTextFile))
|
// Do nothing.
|
||||||
|
if (gameTextPaths.TryGetValue(gameType, out string gameTextFile))
|
||||||
|
{
|
||||||
|
|
||||||
|
using (var stream = fileManager.OpenFile(gameTextFile))
|
||||||
using (var reader = new BinaryReader(stream))
|
using (var reader = new BinaryReader(stream))
|
||||||
using (var unicodeReader = new BinaryReader(stream, Encoding.Unicode))
|
using (var unicodeReader = new BinaryReader(stream, Encoding.Unicode))
|
||||||
using (var asciiReader = new BinaryReader(stream, Encoding.ASCII))
|
using (var asciiReader = new BinaryReader(stream, Encoding.ASCII))
|
||||||
@ -55,4 +61,12 @@ namespace MobiusEditor.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public GameTextManager(IArchiveManager fileManager, Dictionary<GameType, string> gameTextPaths)
|
||||||
|
{
|
||||||
|
this.fileManager = fileManager;
|
||||||
|
this.gameTextPaths = gameTextPaths;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,11 @@ namespace MobiusEditor.Utility
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Reset(GameType gameType)
|
||||||
|
{
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerator<string> GetEnumerator()
|
public IEnumerator<string> GetEnumerator()
|
||||||
{
|
{
|
||||||
return filenames.GetEnumerator();
|
return filenames.GetEnumerator();
|
||||||
|
@ -162,7 +162,7 @@ namespace MobiusEditor.Utility
|
|||||||
// First attempt to find the texture in an archive
|
// First attempt to find the texture in an archive
|
||||||
if (tga == null)
|
if (tga == null)
|
||||||
{
|
{
|
||||||
using (var fileStream = megafileManager.OpenFile(archivePath))
|
using (Stream fileStream = megafileManager.OpenFile(archivePath))
|
||||||
{
|
{
|
||||||
LoadTgaFromZipFileStream(fileStream, name, ref tga, ref metadata);
|
LoadTgaFromZipFileStream(fileStream, name, ref tga, ref metadata);
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ namespace MobiusEditor.Utility
|
|||||||
// Next attempt to load a standalone file
|
// Next attempt to load a standalone file
|
||||||
if (tga == null)
|
if (tga == null)
|
||||||
{
|
{
|
||||||
using (var fileStream = megafileManager.OpenFile(filename))
|
using (Stream fileStream = megafileManager.OpenFile(filename))
|
||||||
{
|
{
|
||||||
// megafileManager.OpenFile might return null if not found, so always check on this.
|
// megafileManager.OpenFile might return null if not found, so always check on this.
|
||||||
// The Load???FromFileStream functions do this check internally.
|
// The Load???FromFileStream functions do this check internally.
|
||||||
@ -182,7 +182,7 @@ namespace MobiusEditor.Utility
|
|||||||
if (tga != null)
|
if (tga != null)
|
||||||
{
|
{
|
||||||
var meta = Path.ChangeExtension(filename, ".meta");
|
var meta = Path.ChangeExtension(filename, ".meta");
|
||||||
using (var metaStream = megafileManager.OpenFile(meta))
|
using (Stream metaStream = megafileManager.OpenFile(meta))
|
||||||
{
|
{
|
||||||
if (metaStream != null)
|
if (metaStream != null)
|
||||||
{
|
{
|
||||||
@ -309,7 +309,7 @@ namespace MobiusEditor.Utility
|
|||||||
}
|
}
|
||||||
if (bitmap == null)
|
if (bitmap == null)
|
||||||
{
|
{
|
||||||
using (var fileStream = megafileManager.OpenFile(ddsFilename))
|
using (Stream fileStream = megafileManager.OpenFile(ddsFilename))
|
||||||
{
|
{
|
||||||
bitmap = LoadDDSFromFileStream(fileStream);
|
bitmap = LoadDDSFromFileStream(fileStream);
|
||||||
}
|
}
|
||||||
|
@ -60,10 +60,18 @@ namespace MobiusEditor.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (xmlDoc == null)
|
if (xmlDoc == null)
|
||||||
|
{
|
||||||
|
using (Stream xmlStream = megafileManager.OpenFile(xmlPath))
|
||||||
|
{
|
||||||
|
if (xmlStream != null)
|
||||||
{
|
{
|
||||||
xmlDoc = new XmlDocument();
|
xmlDoc = new XmlDocument();
|
||||||
xmlDoc.Load(megafileManager.OpenFile(xmlPath));
|
xmlDoc.Load(xmlStream);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (xmlDoc != null)
|
||||||
|
{
|
||||||
foreach (XmlNode fileNode in xmlDoc.SelectNodes("TilesetFiles/File"))
|
foreach (XmlNode fileNode in xmlDoc.SelectNodes("TilesetFiles/File"))
|
||||||
{
|
{
|
||||||
string xmlFile = Path.Combine(Path.GetDirectoryName(xmlPath), fileNode.InnerText);
|
string xmlFile = Path.Combine(Path.GetDirectoryName(xmlPath), fileNode.InnerText);
|
||||||
@ -82,19 +90,28 @@ namespace MobiusEditor.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fileXmlDoc == null)
|
if (fileXmlDoc == null)
|
||||||
|
{
|
||||||
|
using (Stream xmlStream = megafileManager.OpenFile(xmlFile))
|
||||||
|
{
|
||||||
|
if (xmlStream != null)
|
||||||
{
|
{
|
||||||
fileXmlDoc = new XmlDocument();
|
fileXmlDoc = new XmlDocument();
|
||||||
fileXmlDoc.Load(megafileManager.OpenFile(xmlFile));
|
fileXmlDoc.Load(xmlStream);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fileXmlDoc != null)
|
||||||
|
{
|
||||||
foreach (XmlNode tilesetNode in fileXmlDoc.SelectNodes("Tilesets/TilesetTypeClass"))
|
foreach (XmlNode tilesetNode in fileXmlDoc.SelectNodes("Tilesets/TilesetTypeClass"))
|
||||||
{
|
{
|
||||||
var tileset = new Tileset(textureManager);
|
var tileset = new Tileset(textureManager);
|
||||||
tileset.Load(tilesetNode.OuterXml, texturesPath);
|
tileset.Load(tilesetNode.OuterXml, texturesPath);
|
||||||
|
|
||||||
tilesets[tilesetNode.Attributes["name"].Value] = tileset;
|
tilesets[tilesetNode.Attributes["name"].Value] = tileset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user