Browse Source

clean up code and few small adjustment

meidomustard 5 years ago
parent
commit
a6501fd203

+ 4 - 22
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Gui.cs

@@ -489,16 +489,6 @@ namespace CM3D2.MultipleMaids.Plugin
                     bgCombo2List[index] = bgUiNames.TryGetValue(bgArray[index], out string name)
                                                   ? new GUIContent(name)
                                                   : new GUIContent(bgArray[index]);
-
-                    Dictionary<string, string> saveDataDic = CreativeRoomManager.GetSaveDataDic();
-                    if (saveDataDic != null)
-                    {
-                        foreach (KeyValuePair<string, string> keyValuePair in saveDataDic)
-                        {
-                            if (bgArray[index] == keyValuePair.Key)
-                                bgCombo2List[index] = new GUIContent(keyValuePair.Value);
-                        }
-                    }
                 }
 
                 slotCombo.selectedItemIndex = 0;
@@ -1169,15 +1159,10 @@ namespace CM3D2.MultipleMaids.Plugin
 
                 bgCombo.selectedItemIndex = bgIndex;
                 bgComboList = new GUIContent[bgArray.Length];
-                Dictionary<string, string> saveDataDic = CreativeRoomManager.GetSaveDataDic();
                 for (int j = 0; j < bgArray.Length; j++)
                 {
-                    // TODO: Merge dicts at some point?
-                    if (bgUiNames.TryGetValue(bgArray[j], out string name))
-                        bgComboList[j] = new GUIContent(name);
-                    else if(saveDataDic.TryGetValue(bgArray[j], out name))
-                        bgComboList[j] = new GUIContent(name);
-                    else if(bgDict.TryGetValue(bgArray[j], out name))
+                    // Dicts merged during init
+                    if (bgDict.TryGetValue(bgArray[j], out string name))
                         bgComboList[j] = new GUIContent(name);
                     else
                         bgComboList[j] = new GUIContent(bgArray[j]);
@@ -1187,11 +1172,9 @@ namespace CM3D2.MultipleMaids.Plugin
                 doguComboList = new GUIContent[doguBArray.Length];
                 for (int j = 0; j < doguComboList.Length; j++)
                 {
-                    // TODO: Neater?
+                    // Dicts merged during init
                     if (doguUiNames.TryGetValue(doguBArray[j], out string name))
                         doguComboList[j] = new GUIContent(name);
-                    else if(doguDict.TryGetValue(doguBArray[j], out var data))
-                        doguComboList[j] = new GUIContent(data.name);
                     else
                         doguComboList[j] = new GUIContent(doguBArray[j]);
                 }
@@ -2811,9 +2794,8 @@ namespace CM3D2.MultipleMaids.Plugin
                            "追加",
                            guistyle3))
             {
-                PhotoBGObjectData objResult = null;
                 GameObject gameObject2 = null;
-                if (doguDict.TryGetValue(doguBArray[doguBIndex], out objResult))
+                if (doguDict.TryGetValue(doguBArray[doguBIndex], out PhotoBGObjectData objResult))
                 {
                     if (!string.IsNullOrEmpty(objResult.create_prefab_name))
                     {

+ 23 - 4
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Init.cs

@@ -1163,16 +1163,21 @@ namespace CM3D2.MultipleMaids.Plugin
             foreach (var bgdata in photList)
             {
                 if (!string.IsNullOrEmpty(bgdata.create_prefab_name))
-                    bgDict.Add(bgdata.create_prefab_name, bgdata.name);
+                    bgDict[bgdata.create_prefab_name] = bgdata.name;
             }
 
+            bgUiNames.ToList().ForEach(x => bgDict[x.Key] = x.Value);
+
             stringList8.AddRange(neiList);
 
             var stringList9 = new List<string>();
             var saveDataDic = CreativeRoomManager.GetSaveDataDic();
             if (saveDataDic != null)
                 foreach (var keyValuePair in saveDataDic)
+                {
                     stringList9.Add(keyValuePair.Key);
+                    bgDict[keyValuePair.Key] = keyValuePair.Value;
+                }
             stringList8.AddRange(stringList9.ToArray());
             if (isCM3D2)
             {
@@ -1277,13 +1282,27 @@ namespace CM3D2.MultipleMaids.Plugin
             PhotoBGObjectData.Create();
             doguDict = new Dictionary<string, PhotoBGObjectData>();
             var filteredList = PhotoBGObjectData.data.Where(prpdata => prpdata.category != "パーティクル");
-            Console.WriteLine("ADDING DOGU DICT");
             foreach (var bgObj in filteredList)
             {
+                string tmp = null;
                 if (!string.IsNullOrEmpty(bgObj.create_prefab_name))
-                    doguDict.Add(bgObj.create_prefab_name, bgObj);
+                { 
+                    doguDict[bgObj.create_prefab_name] = bgObj;
+                    tmp = bgObj.create_prefab_name;
+                }
                 else if (!string.IsNullOrEmpty(bgObj.create_asset_bundle_name))
-                    doguDict.Add(bgObj.create_asset_bundle_name, bgObj);
+                {
+                    doguDict[bgObj.create_asset_bundle_name] = bgObj;
+                    tmp = bgObj.create_asset_bundle_name;
+                }
+                else if (!string.IsNullOrEmpty(bgObj.direct_file))
+			    {
+                    doguDict[bgObj.direct_file] = bgObj;
+                    tmp = bgObj.direct_file;
+
+                }
+                if (!string.IsNullOrEmpty(tmp))
+                    doguUiNames[tmp] = bgObj.name;
             }
 
             var propList1 = filteredList.Where(prpdata => !string.IsNullOrEmpty(prpdata.create_prefab_name))

+ 1 - 1
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.cs

@@ -595,7 +595,7 @@ namespace CM3D2.MultipleMaids.Plugin
             ["Syosai_Night"] = "Study (Night)",
             ["Theater"] = "劇場",
             ["Theater_LightOff"] = "劇場(夜)",
-            ["Toilet"] = "Neightlet",
+            ["Toilet"] = "Toilet",
             ["Town"] = "Town",
             ["Train"] = "電車",
             ["villa"] = "ヴィラ1F",

+ 1 - 1
README.md

@@ -12,7 +12,7 @@ Decompiled version of 22.1 with some edits.
 * Formatted code with CodeFormatter
 * RAM fix by a fellow anon
 * Fix for COM3D2 1.18
-* Read BGs from PhotoMode instead of having them hardcoded
+* Read BGs and Prop Items from PhotoMode instead of having them hardcoded
 
 ## Note