|
@@ -1,4 +1,4 @@
|
|
|
-using ExIni;
|
|
|
+using ExIni;
|
|
|
using MyRoomCustom;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
@@ -1167,109 +1167,27 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
{
|
|
|
if (itemDataList.Count == 0)
|
|
|
{
|
|
|
- #region menu files
|
|
|
- HashSet<string> modMenus = null;
|
|
|
if (!modItemsOnly)
|
|
|
{
|
|
|
- modMenus = new HashSet<string>(GameUty.ModOnlysMenuFiles);
|
|
|
- }
|
|
|
-
|
|
|
- string[] menuFiles = modItemsOnly ? GameUty.ModOnlysMenuFiles : GameUty.MenuFiles;
|
|
|
- foreach (string menuFile in menuFiles)
|
|
|
+ for (int i = 0; i < GameMain.Instance.MenuDataBase.GetDataSize(); i++)
|
|
|
{
|
|
|
- if (menuFile.EndsWith("_del.menu"))
|
|
|
- {
|
|
|
- continue;
|
|
|
+ ItemData item = new ItemData();
|
|
|
+ if (ParseNativeMenuFile(i, item)) itemDataList.Add(item);
|
|
|
}
|
|
|
- byte[] buf;
|
|
|
- using (AFileBase aFileBase = GameUty.FileOpen(menuFile))
|
|
|
- {
|
|
|
- if (!aFileBase.IsValid())
|
|
|
- {
|
|
|
- continue;
|
|
|
}
|
|
|
- buf = aFileBase.ReadAll();
|
|
|
- }
|
|
|
|
|
|
+ foreach (string modMenuFile in GameUty.ModOnlysMenuFiles)
|
|
|
+ {
|
|
|
ItemData item = new ItemData()
|
|
|
{
|
|
|
- menu = menuFile,
|
|
|
- isMod = modItemsOnly || modMenus.Contains(menuFile)
|
|
|
+ menu = modMenuFile,
|
|
|
+ isMod = true
|
|
|
};
|
|
|
- BinaryReader binaryReader = new BinaryReader(new MemoryStream(buf), Encoding.UTF8);
|
|
|
- if (binaryReader.ReadString() != "CM3D2_MENU")
|
|
|
- {
|
|
|
- binaryReader.Close();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- binaryReader.ReadInt32();
|
|
|
- binaryReader.ReadString();
|
|
|
- item.name = binaryReader.ReadString();
|
|
|
- item.category = binaryReader.ReadString();
|
|
|
- binaryReader.ReadString();
|
|
|
- binaryReader.ReadInt32();
|
|
|
- bool run = true;
|
|
|
- do
|
|
|
- {
|
|
|
- int size;
|
|
|
- do
|
|
|
- {
|
|
|
- size = binaryReader.ReadByte();
|
|
|
- } while (size == 0);
|
|
|
-
|
|
|
- for (int index = 0; index < size; ++index)
|
|
|
- {
|
|
|
- string header = binaryReader.ReadString();
|
|
|
- if (header == "icons" || header == "icon")
|
|
|
- {
|
|
|
- run = false;
|
|
|
- item.icon = binaryReader.ReadString();
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (header == "priority")
|
|
|
- {
|
|
|
- int.TryParse(binaryReader.ReadString(), out item.priority);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } while (run);
|
|
|
-
|
|
|
- itemDataList.Add(item);
|
|
|
- }
|
|
|
- catch { }
|
|
|
-
|
|
|
- binaryReader.Close();
|
|
|
- }
|
|
|
+ if (ParseMenuFile(modMenuFile, item)) itemDataList.Add(item);
|
|
|
}
|
|
|
- #endregion
|
|
|
|
|
|
- #region mod files
|
|
|
foreach (string modFile in Menu.GetModFiles())
|
|
|
{
|
|
|
- byte[] buf = null;
|
|
|
- try
|
|
|
- {
|
|
|
- using (FileStream fileStream = new FileStream(modFile, FileMode.Open))
|
|
|
- {
|
|
|
- if (fileStream == null)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- buf = new byte[fileStream.Length];
|
|
|
- fileStream.Read(buf, 0, (int)fileStream.Length);
|
|
|
- }
|
|
|
- }
|
|
|
- catch { }
|
|
|
-
|
|
|
- if (buf == null)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
ItemData item = new ItemData()
|
|
|
{
|
|
|
isMod = true,
|
|
@@ -1277,61 +1195,9 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
menu = modFile,
|
|
|
priority = 1000
|
|
|
};
|
|
|
-
|
|
|
- BinaryReader binaryReader = new BinaryReader(new MemoryStream(buf), Encoding.UTF8);
|
|
|
- if (binaryReader.ReadString() != "CM3D2_MOD")
|
|
|
- {
|
|
|
- binaryReader.Close();
|
|
|
+ if (ParseModMenuFile(modFile, item)) itemDataList.Add(item);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- binaryReader.ReadInt32();
|
|
|
- string iconName = binaryReader.ReadString();
|
|
|
- string baseItemPath = binaryReader.ReadString().Replace(":", " ");
|
|
|
- item.baseItem = Path.GetFileName(baseItemPath);
|
|
|
- item.name = binaryReader.ReadString();
|
|
|
- item.category = binaryReader.ReadString();
|
|
|
- binaryReader.ReadString();
|
|
|
- string mpnValue = binaryReader.ReadString();
|
|
|
- MPN mpn = MPN.null_mpn;
|
|
|
- try
|
|
|
- {
|
|
|
- mpn = (MPN)Enum.Parse(typeof(MPN), mpnValue, true);
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- binaryReader.Close();
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (mpn != MPN.null_mpn)
|
|
|
- {
|
|
|
- binaryReader.ReadString();
|
|
|
- }
|
|
|
- binaryReader.ReadString();
|
|
|
- int size = binaryReader.ReadInt32();
|
|
|
- for (int i = 0; i < size; i++)
|
|
|
- {
|
|
|
- string key = binaryReader.ReadString();
|
|
|
- int count = binaryReader.ReadInt32();
|
|
|
- byte[] data = binaryReader.ReadBytes(count);
|
|
|
- if (string.Equals(key, iconName, StringComparison.InvariantCultureIgnoreCase))
|
|
|
- {
|
|
|
- Texture2D tex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
|
|
|
- tex.LoadImage(data);
|
|
|
- item.tex = tex;
|
|
|
- break;
|
|
|
- }
|
|
|
}
|
|
|
- itemDataList.Add(item);
|
|
|
- }
|
|
|
- catch { }
|
|
|
- binaryReader.Close();
|
|
|
- }
|
|
|
- }
|
|
|
- #endregion
|
|
|
- }
|
|
|
|
|
|
foreach (ItemData itemData in itemDataList)
|
|
|
{
|