ClothingPluginManager_patched

创建于 差异永不过期
1 删除
435 行
35 添加
468 行
using System;
using System;
using UnityEngine;
using UnityEngine;
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Text;
using System.Text;
using SimpleJSON;
using SimpleJSON;
using MVR;
using MVR;
using MeshVR;
using MeshVR;
using System.Linq;
using System.Linq;
using Leap.Unity;
using Leap.Unity;
using MVR.FileManagementSecure;
using MVR.FileManagementSecure;
using System.Security.AccessControl;
using System.Security.AccessControl;




namespace Stopper {
namespace Stopper {
public class ClothingPluginManager : MVRScript {
public class ClothingPluginManager : MVRScript {


string fileExt = "clothingplugins";
string fileExt = "clothingplugins";


DAZDynamic dazDynamic;
DAZDynamic dazDynamic;
DAZDynamicItem dazDynamicItem;
DAZDynamicItem dazDynamicItem;
MVRPluginManager pluginManager;
MVRPluginManager pluginManager;
PresetManager presetManager;
PresetManager presetManager;
Destructor destruct;
Destructor destruct;


bool needsReload = false;
bool needsReload = false;


JSONClass sceneJson = null;
JSONClass sceneJson = null;
bool lastRestoreWasSceneRestore = false;
bool lastRestoreWasSceneRestore = false;


public override void Init() {
public override void Init() {
WalkAndGetParentItems();
WalkAndGetParentItems();
if(containingAtom == null) throw new Exception("Unable to determine containing atom.");
if(containingAtom == null) throw new Exception("Unable to determine containing atom.");
if(pluginManager == null) throw new Exception("Unable to find plugin manager.");
if(pluginManager == null) throw new Exception("Unable to find plugin manager.");
if(dazDynamicItem == null) throw new Exception("Unable to find dynamic item.");
if(dazDynamicItem == null) throw new Exception("Unable to find dynamic item.");
if(dazDynamic == null) throw new Exception("Unable to find dazDynamic item.");
if(dazDynamic == null) throw new Exception("Unable to find dazDynamic item.");


this.overrideId = $"{dazDynamic.uid}:{this.storeId}";
this.overrideId = $"{dazDynamic.uid}:{this.storeId}";


DAZCharacterSelector selector = containingAtom.GetStorableByID("geometry") as DAZCharacterSelector;
DAZCharacterSelector selector = containingAtom.GetStorableByID("geometry") as DAZCharacterSelector;
if(selector == null) throw new Exception("Unable to find CharacterSelector");
if(selector == null) throw new Exception("Unable to find CharacterSelector");




pluginManager.containingAtom = containingAtom;
pluginManager.containingAtom = containingAtom;
pluginManager.gameObject.SetActive(true);
pluginManager.gameObject.SetActive(true);
pluginManager.exclude = true;
pluginManager.exclude = true;


presetManager = dazDynamic.GetComponentInChildren<PresetManager>();
presetManager = dazDynamic.GetComponentInChildren<PresetManager>();
List<PresetManager.SpecificStorable> specificStorables = presetManager.specificStorables.ToList();
List<PresetManager.SpecificStorable> specificStorables = presetManager.specificStorables.ToList();


PresetManager.SpecificStorable specificStorable = null;
PresetManager.SpecificStorable specificStorable = null;
foreach(var storable in specificStorables) {
foreach(var storable in specificStorables) {
if(storable.specificKey == "ClothingPluginManager") {
if(storable.specificKey == "ClothingPluginManager") {
specificStorable = storable;
specificStorable = storable;
specificStorable.specificStorableBucket = this.transform;
specificStorable.specificStorableBucket = this.transform;
}
}
}
}
if(specificStorable == null) {
if(specificStorable == null) {
specificStorable = new PresetManager.SpecificStorable();
specificStorable = new PresetManager.SpecificStorable();
specificStorable.specificKey = "ClothingPluginManager";
specificStorable.specificKey = "ClothingPluginManager";
specificStorable.storeId = this.storeId;
specificStorable.storeId = this.storeId;
specificStorable.specificStorableBucket = this.transform;
specificStorable.specificStorableBucket = this.transform;
specificStorable.includeChildren = false;
specificStorable.includeChildren = false;
}
}
presetManager.specificStorables = specificStorables.ToArray();
presetManager.specificStorables = specificStorables.ToArray();
presetManager.RefreshStorables();
presetManager.RefreshStorables();


// Add the destructor to unload mods if we do a force reload
// Add the destructor to unload mods if we do a force reload
if(dazDynamicItem != selector.femaleClothingCreatorItem && dazDynamicItem != selector.maleClothingCreatorItem) {
if(dazDynamicItem != selector.femaleClothingCreatorItem && dazDynamicItem != selector.maleClothingCreatorItem) {
destruct = dazDynamic.binaryStorableBucket.gameObject.AddComponent<Destructor>();
destruct = dazDynamic.binaryStorableBucket.gameObject.AddComponent<Destructor>();
destruct.pluginManager = pluginManager;
destruct.pluginManager = pluginManager;
destruct.storedContainingAtom = containingAtom;
destruct.storedContainingAtom = containingAtom;
}
}




// If this isn't set on the plugin manager by the time we reach here, then
// If this isn't set on the plugin manager by the time we reach here, then
// this plugin will not show up in the UI. In that case we'll want to reload the plugins.
// this plugin will not show up in the UI. In that case we'll want to reload the plugins.
if(pluginManager.pluginPanelPrefab == null) {
if(pluginManager.pluginPanelPrefab == null) {
needsReload = true;
needsReload = true;
}
}
// Copy over all of the prefabs
// Copy over all of the prefabs
MVRPluginManager containingAtomPluginManager = containingAtom.GetStorableByID("PluginManager") as MVRPluginManager;
MVRPluginManager containingAtomPluginManager = containingAtom.GetStorableByID("PluginManager") as MVRPluginManager;
if(containingAtomPluginManager != null){
if(containingAtomPluginManager != null){
pluginManager.pluginPanelPrefab = containingAtomPluginManager.pluginPanelPrefab;
pluginManager.pluginPanelPrefab = containingAtomPluginManager.pluginPanelPrefab;
pluginManager.scriptControllerPanelPrefab = containingAtomPluginManager.scriptControllerPanelPrefab;
pluginManager.scriptControllerPanelPrefab = containingAtomPluginManager.scriptControllerPanelPrefab;
pluginManager.scriptUIPrefab = containingAtomPluginManager.scriptUIPrefab;
pluginManager.scriptUIPrefab = containingAtomPluginManager.scriptUIPrefab;
pluginManager.configurableSliderPrefab = containingAtomPluginManager.configurableSliderPrefab;
pluginManager.configurableSliderPrefab = containingAtomPluginManager.configurableSliderPrefab;
pluginManager.configurableTogglePrefab = containingAtomPluginManager.configurableTogglePrefab;
pluginManager.configurableTogglePrefab = containingAtomPluginManager.configurableTogglePrefab;
pluginManager.configurableColorPickerPrefab = containingAtomPluginManager.configurableColorPickerPrefab;
pluginManager.configurableColorPickerPrefab = containingAtomPluginManager.configurableColorPickerPrefab;
pluginManager.configurableButtonPrefab = containingAtomPluginManager.configurableButtonPrefab;
pluginManager.configurableButtonPrefab = containingAtomPluginManager.configurableButtonPrefab;
pluginManager.configurablePopupPrefab = containingAtomPluginManager.configurablePopupPrefab;
pluginManager.configurablePopupPrefab = containingAtomPluginManager.configurablePopupPrefab;
pluginManager.configurableScrollablePopupPrefab = containingAtomPluginManager.configurableScrollablePopupPrefab;
pluginManager.configurableScrollablePopupPrefab = containingAtomPluginManager.configurableScrollablePopupPrefab;
pluginManager.configurableFilterablePopupPrefab = containingAtomPluginManager.configurableFilterablePopupPrefab;
pluginManager.configurableFilterablePopupPrefab = containingAtomPluginManager.configurableFilterablePopupPrefab;
pluginManager.configurableTextFieldPrefab = containingAtomPluginManager.configurableTextFieldPrefab;
pluginManager.configurableTextFieldPrefab = containingAtomPluginManager.configurableTextFieldPrefab;
pluginManager.configurableSpacerPrefab = containingAtomPluginManager.configurableSpacerPrefab;
pluginManager.configurableSpacerPrefab = containingAtomPluginManager.configurableSpacerPrefab;
} else {
} else {
throw new Exception("Unable to find plugin manager for main atom.");
throw new Exception("Unable to find plugin manager for main atom.");
}
}