소스 검색

Migrate to BepInEx

Why not
habeebweeb 4 년 전
부모
커밋
fe7a10bed5

+ 31 - 34
COM3D2.MeidoPhotoStudio.Plugin/COM3D2.MeidoPhotoStudio.Plugin.csproj

@@ -1,36 +1,33 @@
 <Project Sdk="Microsoft.Net.Sdk">
-  <PropertyGroup>
-    <TargetFramework>net35</TargetFramework>
-    <AssemblyName>COM3D2.MeidoPhotoStudio.Plugin</AssemblyName>
-    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
-    <FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="Assembly-CSharp">
-      <HintPath>..\lib\Assembly-CSharp.dll</HintPath>
-    </Reference>
-    <Reference Include="Assembly-CSharp-firstpass">
-      <HintPath>..\lib\Assembly-CSharp-firstpass.dll</HintPath>
-    </Reference>
-    <Reference Include="Assembly-UnityScript-firstpass">
-      <HintPath>..\lib\Assembly-UnityScript-firstpass.dll</HintPath>
-    </Reference>
-    <Reference Include="ExIni">
-      <HintPath>..\lib\ExIni.dll</HintPath>
-    </Reference>
-    <Reference Include="UnityEngine">
-      <HintPath>..\lib\UnityEngine.dll</HintPath>
-    </Reference>
-    <Reference Include="UnityInjector">
-      <HintPath>..\lib\UnityInjector.dll</HintPath>
-    </Reference>
-    <Reference Include="Newtonsoft.Json">
-      <HintPath>..\lib\Newtonsoft.Json.dll</HintPath>
-    </Reference>
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Config\**">
-        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-  </ItemGroup>
+    <PropertyGroup>
+        <TargetFramework>net35</TargetFramework>
+        <AssemblyName>COM3D2.MeidoPhotoStudio</AssemblyName>
+        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+        <FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
+    </PropertyGroup>
+    <ItemGroup>
+        <Reference Include="Assembly-CSharp">
+            <HintPath>..\lib\Assembly-CSharp.dll</HintPath>
+        </Reference>
+        <Reference Include="Assembly-CSharp-firstpass">
+            <HintPath>..\lib\Assembly-CSharp-firstpass.dll</HintPath>
+        </Reference>
+        <Reference Include="Assembly-UnityScript-firstpass">
+            <HintPath>..\lib\Assembly-UnityScript-firstpass.dll</HintPath>
+        </Reference>
+        <Reference Include="UnityEngine">
+            <HintPath>..\lib\UnityEngine.dll</HintPath>
+        </Reference>
+        <Reference Include="Newtonsoft.Json">
+            <HintPath>..\lib\Newtonsoft.Json.dll</HintPath>
+        </Reference>
+        <Reference Include="BepInEx.dll">
+            <HintPath>..\lib\BepInEx.dll</HintPath>
+        </Reference>
+    </ItemGroup>
+    <ItemGroup>
+        <Content Include="Config\**">
+            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+        </Content>
+    </ItemGroup>
 </Project>

+ 4 - 12
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Constants.cs

@@ -34,8 +34,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public static readonly Dictionary<string, List<string>> PoseDict = new Dictionary<string, List<string>>();
         public static readonly List<string> CustomPoseGroupList = new List<string>();
         public static readonly Dictionary<string, List<string>> CustomPoseDict = new Dictionary<string, List<string>>();
-        // public static readonly Dictionary<string, List<KeyValuePair<string, string>>> CustomPoseDict
-        //     = new Dictionary<string, List<KeyValuePair<string, string>>>();
         public static readonly List<string> FaceBlendList = new List<string>();
         public static readonly List<string> BGList = new List<string>();
         public static readonly List<KeyValuePair<string, string>> MyRoomCustomBGList
@@ -68,14 +66,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         static Constants()
         {
-            string modsPath = Path.Combine(Path.GetFullPath(".\\"), @"Mod\MeidoPhotoStudio");
+            string modsPath = Path.Combine(BepInEx.Paths.GameRootPath, @"Mod\MeidoPhotoStudio");
+
             customPosePath = Path.Combine(modsPath, "Custom Poses");
             scenesPath = Path.Combine(modsPath, "Scenes");
             kankyoPath = Path.Combine(modsPath, "Environments");
-            configPath = Path.Combine(
-                Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
-                @"Config\MeidoPhotoStudio"
-            );
+            configPath = Path.Combine(BepInEx.Paths.ConfigPath, "MeidoPhotoStudio");
 
             foreach (string directory in new[] { customPosePath, scenesPath, kankyoPath, configPath })
             {
@@ -667,10 +663,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         }
         public static MenuFilesEventArgs HandItems => new MenuFilesEventArgs(EventType.HandItems);
         public static MenuFilesEventArgs MenuFiles => new MenuFilesEventArgs(EventType.MenuFiles);
-
-        public MenuFilesEventArgs(EventType type)
-        {
-            this.Type = type;
-        }
+        public MenuFilesEventArgs(EventType type) => this.Type = type;
     }
 }

+ 1 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MainWindow.cs

@@ -106,7 +106,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             labelStyle.fontSize = 10;
             labelStyle.alignment = TextAnchor.LowerLeft;
 
-            GUILayout.Label("MeidoPhotoStudio 1.0.0", labelStyle);
+            GUILayout.Label(MeidoPhotoStudio.pluginString, labelStyle);
             GUI.DragWindow();
         }
 

+ 15 - 18
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MeidoPhotoStudio.cs

@@ -1,19 +1,19 @@
-using System.Linq;
-using System;
+using System;
 using System.Collections;
 using System.Collections.Generic;
-using System.IO;
 using UnityEngine;
 using UnityEngine.SceneManagement;
-using UnityInjector;
-using UnityInjector.Attributes;
+using BepInEx;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
-    [PluginName("COM3D2.MeidoPhotoStudio.Plugin"), PluginVersion("0.0.0")]
-    public class MeidoPhotoStudio : PluginBase
+    [BepInPlugin(pluginGuid, pluginName, pluginVersion)]
+    public class MeidoPhotoStudio : BaseUnityPlugin
     {
-        private static MonoBehaviour instance;
+        private const string pluginGuid = "com.habeebweeb.com3d2.meidophotostudio";
+        public const string pluginName = "MeidoPhotoStudio";
+        public const string pluginVersion = "0.0.0";
+        public static string pluginString;
         private WindowManager windowManager;
         private MeidoManager meidoManager;
         private EnvironmentManager environmentManager;
@@ -22,18 +22,15 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         private bool initialized = false;
         private bool isActive = false;
         private bool uiActive = false;
-        private MeidoPhotoStudio()
-        {
-            MeidoPhotoStudio.instance = this;
-        }
-        private void Awake()
-        {
-            DontDestroyOnLoad(this);
-            Translation.Initialize("en");
-            Constants.Initialize();
-        }
+
+        static MeidoPhotoStudio() => pluginString = $"{pluginName} {pluginVersion}";
+
+        private void Awake() => DontDestroyOnLoad(this);
+
         private void Start()
         {
+            Constants.Initialize();
+            Translation.Initialize("en");
             SceneManager.sceneLoaded += OnSceneLoaded;
         }