|
@@ -660,8 +660,7 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
GUI.enabled = false;
|
|
|
}
|
|
|
|
|
|
- characterMgr.GetStockMaidCount();
|
|
|
- float pix = GetPix(45);
|
|
|
+ int iconSize = GetPix(45);
|
|
|
Rect position1;
|
|
|
Rect viewRect;
|
|
|
if (sceneLevel != 5)
|
|
@@ -673,7 +672,7 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
viewRect = new Rect(0.0f,
|
|
|
0.0f,
|
|
|
position1.width * 0.845f,
|
|
|
- Mathf.Ceil(sortList.Count / 4 + 1) * pix + GetPix(10));
|
|
|
+ Mathf.Ceil(sortList.Count / 4f) * iconSize + GetPix(10));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -684,57 +683,84 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
viewRect = new Rect(0.0f,
|
|
|
0.0f,
|
|
|
position1.width * 0.845f,
|
|
|
- Mathf.Ceil(sortList.Count / 4 + 1) * pix + GetPix(10));
|
|
|
+ Mathf.Ceil(sortList.Count / 4f) * iconSize + GetPix(10));
|
|
|
}
|
|
|
|
|
|
bg2ScrollPos = GUI.BeginScrollView(position1, bg2ScrollPos, viewRect);
|
|
|
for (int index = 0; index < sortList.Count; ++index)
|
|
|
{
|
|
|
- Rect position2 = new Rect(index % 4 * GetPix(45),
|
|
|
- index / 4 * GetPix(45),
|
|
|
- GetPix(44),
|
|
|
- GetPix(44));
|
|
|
- if (GUI.Button(position2, sortList[index].tex))
|
|
|
- {
|
|
|
- string menu = sortList[index].menu;
|
|
|
- byte[] f_byBuf = null;
|
|
|
+ SortItem sortItem = sortList[index];
|
|
|
+ Rect position2 = new Rect(
|
|
|
+ index % 4 * iconSize,
|
|
|
+ index / 4 * iconSize,
|
|
|
+ iconSize,
|
|
|
+ iconSize
|
|
|
+ );
|
|
|
+ if (GUI.Button(position2, ""))
|
|
|
+ {
|
|
|
+ string menu = sortItem.menu;
|
|
|
+ byte[] modBuf = null;
|
|
|
+ bool ready = true;
|
|
|
+ if (sortItem.isOfficialMod)
|
|
|
+ {
|
|
|
+ menu = sortItem.baseItem;
|
|
|
+
|
|
|
+ using (FileStream fileStream = new FileStream(sortItem.menu, FileMode.Open))
|
|
|
+ {
|
|
|
+ if (fileStream == null)
|
|
|
+ {
|
|
|
+ ready = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ modBuf = new byte[fileStream.Length];
|
|
|
+ fileStream.Read(modBuf, 0, (int)fileStream.Length);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ byte[] menuBuf = null;
|
|
|
using (AFileBase afileBase = GameUty.FileOpen(menu, null))
|
|
|
{
|
|
|
- NDebug.Assert(afileBase.IsValid(), "メニューファイルが存在しません。 :" + menu);
|
|
|
- if (f_byBuf == null || f_byBuf.Length < afileBase.GetSize())
|
|
|
+ if (ready = afileBase.IsValid())
|
|
|
{
|
|
|
- f_byBuf = new byte[afileBase.GetSize()];
|
|
|
+ menuBuf = afileBase.ReadAll();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- afileBase.Read(ref f_byBuf, afileBase.GetSize());
|
|
|
+ if (ready)
|
|
|
+ {
|
|
|
+ string[] meshInfo = ProcScriptBin(menuBuf);
|
|
|
+ GameObject gameObject = ImportCM2.LoadSkinMesh_R(meshInfo[0], meshInfo, 1);
|
|
|
+ gameObject.name = menu;
|
|
|
+ if (sortItem.isOfficialMod)
|
|
|
+ {
|
|
|
+ gameObject.name += $"#{Path.GetFileName(sortItem.menu)}";
|
|
|
+ ProcModScriptBin(modBuf, gameObject);
|
|
|
+ }
|
|
|
+ doguBObject.Add(gameObject);
|
|
|
+ Vector3 zero1 = Vector3.zero;
|
|
|
+ Vector3 zero2 = Vector3.zero;
|
|
|
+ zero1.z = 0.4f;
|
|
|
+ gameObject.transform.localPosition = zero1;
|
|
|
+ gameObject.transform.localRotation = Quaternion.Euler(zero2);
|
|
|
+ doguCnt = doguBObject.Count - 1;
|
|
|
+ gDogu[doguCnt] = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
|
|
+ gDogu[doguCnt].GetComponent<Renderer>().material = m_material;
|
|
|
+ gDogu[doguCnt].layer = 8;
|
|
|
+ gDogu[doguCnt].GetComponent<Renderer>().enabled = false;
|
|
|
+ gDogu[doguCnt].SetActive(false);
|
|
|
+ gDogu[doguCnt].transform.position = gameObject.transform.position;
|
|
|
+ mDogu[doguCnt] = gDogu[doguCnt].AddComponent<MouseDrag6>();
|
|
|
+ mDogu[doguCnt].isScale = false;
|
|
|
+ mDogu[doguCnt].obj = gDogu[doguCnt];
|
|
|
+ mDogu[doguCnt].maid = gameObject;
|
|
|
+ mDogu[doguCnt].angles = gameObject.transform.eulerAngles;
|
|
|
+ gDogu[doguCnt].transform.localScale = new Vector3(cubeSize, cubeSize, cubeSize);
|
|
|
+ mDogu[doguCnt].ido = 1;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- string[] filename2 = ProcScriptBin(maidArray[0], f_byBuf, menu, false);
|
|
|
- GameObject gameObject = ImportCM2.LoadSkinMesh_R(filename2[0], filename2, "", maidArray[0].body0.goSlot[8], 1);
|
|
|
- doguBObject.Add(gameObject);
|
|
|
- gameObject.name = menu;
|
|
|
- Vector3 zero1 = Vector3.zero;
|
|
|
- Vector3 zero2 = Vector3.zero;
|
|
|
- zero1.z = 0.4f;
|
|
|
- gameObject.transform.localPosition = zero1;
|
|
|
- gameObject.transform.localRotation = Quaternion.Euler(zero2);
|
|
|
- doguCnt = doguBObject.Count - 1;
|
|
|
- gDogu[doguCnt] = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
|
|
- gDogu[doguCnt].GetComponent<Renderer>().material = m_material;
|
|
|
- gDogu[doguCnt].layer = 8;
|
|
|
- gDogu[doguCnt].GetComponent<Renderer>().enabled = false;
|
|
|
- gDogu[doguCnt].SetActive(false);
|
|
|
- gDogu[doguCnt].transform.position = gameObject.transform.position;
|
|
|
- mDogu[doguCnt] = gDogu[doguCnt].AddComponent<MouseDrag6>();
|
|
|
- mDogu[doguCnt].isScale = false;
|
|
|
- mDogu[doguCnt].obj = gDogu[doguCnt];
|
|
|
- mDogu[doguCnt].maid = gameObject;
|
|
|
- mDogu[doguCnt].angles = gameObject.transform.eulerAngles;
|
|
|
- gDogu[doguCnt].transform.localScale = new Vector3(cubeSize, cubeSize, cubeSize);
|
|
|
- mDogu[doguCnt].ido = 1;
|
|
|
- }
|
|
|
-
|
|
|
- GUI.DrawTexture(position2, sortList[index].tex);
|
|
|
+ GUI.DrawTexture(position2, sortItem.tex);
|
|
|
}
|
|
|
|
|
|
GUI.EndScrollView();
|
|
@@ -852,8 +878,8 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
afileBase.Read(ref f_byBuf, afileBase.GetSize());
|
|
|
}
|
|
|
|
|
|
- string[] filename2 = ProcScriptBin(maidArray[0], f_byBuf, str, false);
|
|
|
- GameObject gameObject = ImportCM2.LoadSkinMesh_R(filename2[0], filename2, "", maidArray[0].body0.goSlot[8], 1);
|
|
|
+ string[] filename2 = ProcScriptBin(f_byBuf);
|
|
|
+ GameObject gameObject = ImportCM2.LoadSkinMesh_R(filename2[0], filename2, 1);
|
|
|
doguBObject.Add(gameObject);
|
|
|
gameObject.name = str;
|
|
|
Vector3 zero1 = Vector3.zero;
|
|
@@ -1070,24 +1096,25 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
slotIndex = num1;
|
|
|
sortList.Clear();
|
|
|
bg2ScrollPos = new Vector2(0.0f, 0.0f);
|
|
|
+
|
|
|
if (itemDataList.Count == 0)
|
|
|
{
|
|
|
+ #region menu files
|
|
|
foreach (string menuFile in GameUty.MenuFiles)
|
|
|
{
|
|
|
string fileName = Path.GetFileName(menuFile);
|
|
|
- byte[] f_byBuf = null;
|
|
|
- using (AFileBase afileBase = GameUty.FileOpen(fileName, null))
|
|
|
+ byte[] buf;
|
|
|
+ using (AFileBase aFileBase = GameUty.FileOpen(menuFile))
|
|
|
{
|
|
|
- NDebug.Assert(afileBase.IsValid(), "メニューファイルが存在しません。 :" + fileName);
|
|
|
- if (f_byBuf == null || f_byBuf.Length < afileBase.GetSize())
|
|
|
+ if (!aFileBase.IsValid())
|
|
|
{
|
|
|
- f_byBuf = new byte[afileBase.GetSize()];
|
|
|
+ continue;
|
|
|
}
|
|
|
-
|
|
|
- afileBase.Read(ref f_byBuf, afileBase.GetSize());
|
|
|
+ buf = aFileBase.ReadAll();
|
|
|
}
|
|
|
|
|
|
- BinaryReader binaryReader = new BinaryReader(new MemoryStream(f_byBuf), Encoding.UTF8);
|
|
|
+ ItemData item = new ItemData() { menu = fileName };
|
|
|
+ BinaryReader binaryReader = new BinaryReader(new MemoryStream(buf), Encoding.UTF8);
|
|
|
if (binaryReader.ReadString() != "CM3D2_MENU")
|
|
|
{
|
|
|
binaryReader.Close();
|
|
@@ -1098,75 +1125,176 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
{
|
|
|
binaryReader.ReadInt32();
|
|
|
binaryReader.ReadString();
|
|
|
- binaryReader.ReadString();
|
|
|
- string str1 = binaryReader.ReadString();
|
|
|
- string s = "";
|
|
|
+ item.name = binaryReader.ReadString();
|
|
|
+ item.category = binaryReader.ReadString();
|
|
|
binaryReader.ReadString();
|
|
|
binaryReader.ReadInt32();
|
|
|
- string str2 = "";
|
|
|
+ bool run = true;
|
|
|
do
|
|
|
{
|
|
|
- int num2;
|
|
|
+ int size;
|
|
|
do
|
|
|
{
|
|
|
- num2 = binaryReader.ReadByte();
|
|
|
- } while (num2 == 0);
|
|
|
+ size = binaryReader.ReadByte();
|
|
|
+ } while (size == 0);
|
|
|
|
|
|
- for (int index = 0; index < num2; ++index)
|
|
|
+ for (int index = 0; index < size; ++index)
|
|
|
{
|
|
|
- string str3 = binaryReader.ReadString();
|
|
|
- if (str3 == "icons" || str3 == "icon")
|
|
|
+ string header = binaryReader.ReadString();
|
|
|
+ if (header == "icons" || header == "icon")
|
|
|
{
|
|
|
- str2 = binaryReader.ReadString();
|
|
|
+ run = false;
|
|
|
+ item.icon = binaryReader.ReadString();
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (str3 == "priority")
|
|
|
+ if (header == "priority")
|
|
|
{
|
|
|
- s = binaryReader.ReadString();
|
|
|
+ int.TryParse(binaryReader.ReadString(), out item.priority);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- } while (str2 == "");
|
|
|
+ } while (run);
|
|
|
|
|
|
- int.TryParse(s, out int result);
|
|
|
- itemDataList.Add(new ItemData() { info = str1, name = str2, menu = fileName, order = result, cd = f_byBuf });
|
|
|
+ itemDataList.Add(item);
|
|
|
}
|
|
|
catch { }
|
|
|
|
|
|
binaryReader.Close();
|
|
|
}
|
|
|
}
|
|
|
+ #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()
|
|
|
+ {
|
|
|
+ isOfficialMod = true,
|
|
|
+ menu = modFile,
|
|
|
+ priority = 1000
|
|
|
+ };
|
|
|
+
|
|
|
+ BinaryReader binaryReader = new BinaryReader(new MemoryStream(buf), Encoding.UTF8);
|
|
|
+ if (binaryReader.ReadString() != "CM3D2_MOD")
|
|
|
+ {
|
|
|
+ binaryReader.Close();
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ if (slotIndex == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
foreach (ItemData itemData in itemDataList)
|
|
|
{
|
|
|
- if (slotIndex != 0 && itemData.info == slotArray[slotIndex] && itemData.order > 0)
|
|
|
+ if (itemData.category == slotArray[slotIndex] && itemData.priority > 0)
|
|
|
{
|
|
|
- sortList.Add(new SortItem() { order = itemData.order, name = itemData.name, menu = itemData.menu, tex = itemData.tex });
|
|
|
+ sortList.Add(new SortItem()
|
|
|
+ {
|
|
|
+ category = itemData.category,
|
|
|
+ priority = itemData.priority,
|
|
|
+ name = itemData.name,
|
|
|
+ icon = itemData.icon,
|
|
|
+ menu = itemData.menu,
|
|
|
+ tex = itemData.tex,
|
|
|
+ isOfficialMod = itemData.isOfficialMod,
|
|
|
+ baseItem = itemData.baseItem
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- IOrderedEnumerable<SortItem> orderedEnumerable = sortList
|
|
|
- .OrderBy(p => p.order)
|
|
|
- .ThenBy(p => p.name);
|
|
|
+ IOrderedEnumerable<SortItem> sortedItemList = sortList
|
|
|
+ .OrderBy(item => item.priority)
|
|
|
+ .ThenBy(item => item.name);
|
|
|
+
|
|
|
List<SortItem> sortItemList = new List<SortItem>();
|
|
|
- string str4 = "";
|
|
|
- foreach (SortItem sortItem in orderedEnumerable)
|
|
|
+
|
|
|
+ string previousMenu = "";
|
|
|
+ foreach (SortItem item in sortedItemList)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (!(sortItem.menu == str4))
|
|
|
+ if (item.menu != previousMenu)
|
|
|
{
|
|
|
- if (sortItem.tex == null)
|
|
|
+ if (item.tex == null)
|
|
|
{
|
|
|
- byte[] data = ImportCM.LoadTexture(GameUty.FileSystem, sortItem.name, false).data;
|
|
|
+ byte[] data = ImportCM.LoadTexture(GameUty.FileSystem, item.icon, false).data;
|
|
|
Texture2D texture2D = new Texture2D(50, 50, TextureFormat.RGB565, false);
|
|
|
texture2D.LoadImage(data);
|
|
|
- sortItem.tex = texture2D;
|
|
|
+ item.tex = texture2D;
|
|
|
}
|
|
|
- str4 = sortItem.menu;
|
|
|
- sortItemList.Add(sortItem);
|
|
|
+ previousMenu = item.menu;
|
|
|
+ sortItemList.Add(item);
|
|
|
}
|
|
|
}
|
|
|
catch { }
|