mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-07 16:16:03 +00:00
Changed some member variables in LOCFile
This commit is contained in:
@@ -12,15 +12,9 @@ namespace PckStudio.Classes.FileTypes
|
||||
// loc key => language, name
|
||||
public Dictionary<string, Dictionary<string, string>> keys { get; set; } = new Dictionary<string, Dictionary<string, string>>();
|
||||
|
||||
public List<string> _languages = new List<string>(languages.Length);
|
||||
public List<string> languages = new List<string>(valid_languages.Length);
|
||||
|
||||
public void InitializeDefault(string PackName)
|
||||
{
|
||||
AddLanguage("en-EN");
|
||||
AddLocKey("IDS_DISPLAY_NAME", PackName);
|
||||
}
|
||||
|
||||
public static readonly string[] languages = new string[]
|
||||
public static readonly string[] valid_languages = new string[]
|
||||
{
|
||||
"cs-CS",
|
||||
"cs-CZ",
|
||||
@@ -60,6 +54,8 @@ namespace PckStudio.Classes.FileTypes
|
||||
|
||||
"ko-KR",
|
||||
|
||||
"la-LAS",
|
||||
|
||||
"no-NO",
|
||||
|
||||
"nb-NO",
|
||||
@@ -80,8 +76,6 @@ namespace PckStudio.Classes.FileTypes
|
||||
|
||||
"tr-TR",
|
||||
|
||||
"la-LAS",
|
||||
|
||||
"zh-CN",
|
||||
"zh-HK",
|
||||
"zh-SG",
|
||||
@@ -90,10 +84,17 @@ namespace PckStudio.Classes.FileTypes
|
||||
"zh-HanS",
|
||||
"zh-HanT",
|
||||
};
|
||||
public void InitializeDefault(string PackName)
|
||||
{
|
||||
AddLanguage("en-EN");
|
||||
AddLocKey("IDS_DISPLAY_NAME", PackName);
|
||||
}
|
||||
|
||||
|
||||
public void AddSingleLocKey(string locKey, string language, string value)
|
||||
{
|
||||
if (keys.ContainsKey(locKey)) throw new Exception("Loc key already exists");
|
||||
if (!languages.Contains(language)) throw new Exception("Language not found");
|
||||
var dict = new Dictionary<string, string>();
|
||||
dict.Add(language, value);
|
||||
keys.Add(locKey, dict);
|
||||
@@ -105,7 +106,7 @@ namespace PckStudio.Classes.FileTypes
|
||||
throw new ArgumentNullException("string cant be null");
|
||||
if (keys.ContainsKey(locKey))
|
||||
throw new Exception("loc key already exists");
|
||||
foreach (var langauge in _languages)
|
||||
foreach (var langauge in languages)
|
||||
{
|
||||
AddSingleLocKey(locKey, langauge, value);
|
||||
}
|
||||
@@ -113,7 +114,7 @@ namespace PckStudio.Classes.FileTypes
|
||||
public void ChangeSingleEntry(string locKey, string language, string newValue)
|
||||
{
|
||||
if (!keys.ContainsKey(locKey)) throw new KeyNotFoundException("Loc key not found");
|
||||
if (!keys[locKey].ContainsKey(language)) throw new KeyNotFoundException("Language Entry not found");
|
||||
if (!keys[locKey].ContainsKey(language) || !languages.Contains(language)) throw new KeyNotFoundException("Language Entry not found");
|
||||
keys[locKey][language] = newValue;
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ namespace PckStudio.Classes.FileTypes
|
||||
throw new ArgumentNullException("string cant be null");
|
||||
if (!keys.ContainsKey(locKey))
|
||||
throw new KeyNotFoundException("loc key not found");
|
||||
foreach (var langauge in _languages)
|
||||
foreach (var langauge in languages)
|
||||
{
|
||||
ChangeSingleEntry(locKey, langauge, newValue);
|
||||
}
|
||||
@@ -136,9 +137,10 @@ namespace PckStudio.Classes.FileTypes
|
||||
keys.Remove(locKey);
|
||||
}
|
||||
|
||||
private void AddLanguage(string language)
|
||||
public void AddLanguage(string language)
|
||||
{
|
||||
_languages.Add(language);
|
||||
if (!valid_languages.Contains(language)) throw new Exception("Invalid language");
|
||||
languages.Add(language);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace PckStudio.Classes.IO.LOC
|
||||
for (int i = 0; i < language_count; i++)
|
||||
{
|
||||
string language = ReadString(stream);
|
||||
_file._languages.Add(language);
|
||||
_file.languages.Add(language);
|
||||
ReadInt(stream); // padding ???
|
||||
}
|
||||
for (int i = 0; i < language_count; i++)
|
||||
@@ -37,7 +37,7 @@ namespace PckStudio.Classes.IO.LOC
|
||||
Console.WriteLine(ReadInt(stream).ToString());
|
||||
Console.WriteLine(stream.ReadByte());
|
||||
string language = ReadString(stream);
|
||||
if (!_file._languages.Contains(language))
|
||||
if (!_file.languages.Contains(language))
|
||||
throw new Exception("language not found");
|
||||
int count = ReadInt(stream);
|
||||
for (int j = 0; j < count; j++)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace PckStudio.Classes.IO.LOC
|
||||
{
|
||||
if (_locfile == null) throw new ArgumentNullException("Loc File is null");
|
||||
WriteInt(stream, type);
|
||||
WriteInt(stream, _locfile._languages.Count);
|
||||
WriteInt(stream, _locfile.languages.Count);
|
||||
if (type == 2) WriteLocKeys(stream);
|
||||
WriteLanguages(stream);
|
||||
WriteLanguageEntries(stream, type);
|
||||
@@ -41,7 +41,7 @@ namespace PckStudio.Classes.IO.LOC
|
||||
|
||||
private void WriteLanguages(Stream stream)
|
||||
{
|
||||
foreach (var language in _locfile._languages)
|
||||
foreach (var language in _locfile.languages)
|
||||
{
|
||||
WriteString(stream, language);
|
||||
WriteInt(stream, 0);
|
||||
@@ -50,7 +50,7 @@ namespace PckStudio.Classes.IO.LOC
|
||||
|
||||
private void WriteLanguageEntries(Stream stream, int type)
|
||||
{
|
||||
foreach (var language in _locfile._languages)
|
||||
foreach (var language in _locfile.languages)
|
||||
{
|
||||
WriteInt(stream, 0x1337);
|
||||
stream.WriteByte(0);
|
||||
|
||||
Reference in New Issue
Block a user