diff --git a/F2Rename.BepInEx/F2Rename.BepInEx.csproj b/F2Rename.BepInEx/F2Rename.BepInEx.csproj new file mode 100644 index 0000000..f348975 --- /dev/null +++ b/F2Rename.BepInEx/F2Rename.BepInEx.csproj @@ -0,0 +1,329 @@ + + + + net6.0 + F2Rename.BepInEx + f2rename for pauly + 1.0.0 + true + latest + + https://api.nuget.org/v3/index.json; + https://nuget.bepinex.dev/v3/index.json; + https://nuget.samboy.dev/v3/index.json + + F2Rename.BepInEx + + + + + + + + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Assembly-CSharp.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Assembly-CSharp-firstpass.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Battlehub.RTEditor.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\BouncyCastle.Cryptography.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\glTFast.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\HSVPicker.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppMono.Security.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2Cppmscorlib.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppSystem.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppSystem.Configuration.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppSystem.Core.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppSystem.Net.Http.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppSystem.Numerics.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppSystem.Runtime.CompilerServices.Unsafe.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppSystem.Xml.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Il2CppSystem.Xml.Linq.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\kcp2k.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\MiddlewareTransport.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Mirror.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Mirror.Authenticators.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Mirror.Components.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Mirror.Transports.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\MultiplexTransport.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\SimpleFileBrowser.Runtime.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\SimpleWebTransport.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\SoftMask.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Telepathy.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\U8XmlParser.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Unity.AI.Navigation.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Unity.Burst.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Unity.Burst.Unsafe.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Unity.Collections.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Unity.Mathematics.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Unity.Postprocessing.Runtime.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\Unity.TextMeshPro.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.AccessibilityModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.AIModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.AndroidJNIModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.AnimationModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.AssetBundleModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.AudioModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.ClothModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.ClusterInputModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.ClusterRendererModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.ContentLoadModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.CoreModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.CrashReportingModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.DirectorModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.DSPGraphModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.GameCenterModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.GIModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.GraphicsStateCollectionSerializerModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.GridModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.HierarchyCoreModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.HotReloadModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.ImageConversionModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.IMGUIModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.InputForUIModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.InputLegacyModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.InputModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.JSONSerializeModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.LocalizationModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.MarshallingModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.MultiplayerModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.ParticleSystemModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.PerformanceReportingModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.Physics2DModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.PhysicsModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.PropertiesModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.ScreenCaptureModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.ShaderVariantAnalyticsModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.SharedInternalsModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.SpriteMaskModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.SpriteShapeModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.StreamingModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.SubstanceModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.SubsystemsModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.TerrainModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.TerrainPhysicsModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.TextCoreFontEngineModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.TextCoreTextEngineModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.TextRenderingModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UI.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UIElementsModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UIModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityAnalyticsCommonModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityAnalyticsModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityConnectModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityTestProtocolModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityWebRequestAssetBundleModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityWebRequestAudioModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityWebRequestModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityWebRequestTextureModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.UnityWebRequestWWWModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.VehiclesModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.VideoModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\UnityEngine.WindModule.dll + + + ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.4.106\BepInEx\interop\__Generated.dll + + + + + + + diff --git a/F2Rename.BepInEx/Plugin.cs b/F2Rename.BepInEx/Plugin.cs new file mode 100644 index 0000000..533ce6e --- /dev/null +++ b/F2Rename.BepInEx/Plugin.cs @@ -0,0 +1,84 @@ +using BepInEx; +using BepInEx.Logging; +using BepInEx.Unity.IL2CPP; +using Il2CppInterop.Runtime; +using Polytoria.Controllers; +using Polytoria.Datamodel; +using RLD; +using UnityEngine; +using GUI = UnityEngine.GUI; + +namespace F2Rename.BepInEx +{ + [BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)] + public class Plugin : BasePlugin + { + internal static new ManualLogSource Log; + private RenameUI comp; + + public override void Load() + { + // Plugin startup logic + Log = base.Log; + Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!"); + comp = AddComponent(); + } + } + + public class RenameUI : MonoBehaviour + { + internal string name = ""; + internal bool inputEnabled = false; + internal bool justOpened = false; + internal Instance instance; + + public UnityEngine.UI.InputField inputField; + + private void Start() + { + // find global canvas + var canvas = GameObject.Find("Canvas"); + + // create input field + var inputFieldGO = new GameObject("InputField"); + inputFieldGO.transform.SetParent(canvas.transform); + inputField = inputFieldGO.AddComponent(); + inputField.textComponent = inputFieldGO.AddComponent(); + inputField.textComponent.font = Font.CreateDynamicFontFromOSFont("Arial", 14); + inputField.textComponent.fontSize = 14; + inputField.textComponent.color = Color.black; + inputField.textComponent.alignment = TextAnchor.MiddleCenter; + inputField.textComponent.text = "Enter new name"; + inputField.text = "Enter new name"; + + // set input field size + var rectTransform = inputFieldGO.GetComponent(); + rectTransform.sizeDelta = new Vector2(200, 30); + rectTransform.anchoredPosition = new Vector2(0, 0); + rectTransform.localScale = new Vector2( + 1f / canvas.transform.localScale.x, + 1f / canvas.transform.localScale.y + ); + rectTransform.localPosition = new Vector2( + rectTransform.localPosition.x / canvas.transform.localScale.x, + rectTransform.localPosition.y / canvas.transform.localScale.y + ); + } + + private void Update() + { + if (Input.GetKeyDown(KeyCode.F2)) + { + Plugin.Log.LogInfo("F2 pressed"); + var instances = MonoSingleton.Get.SelectedObjects; + if (instances.Count != 1) return; + + Plugin.Log.LogInfo("1 instance selected, showing change name ui"); + instance = instances[0].GetComponent(); + name = instance.Name; + + + } + } + } +} diff --git a/F2Rename/F2Rename.csproj b/F2Rename/F2Rename.csproj index 6a16cc0..132c02c 100644 --- a/F2Rename/F2Rename.csproj +++ b/F2Rename/F2Rename.csproj @@ -6,55 +6,4 @@ enable - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\Assembly-CSharp.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\Il2CppBattlehub.RTEditor.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\net6\Il2CppInterop.Common.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\net6\Il2CppInterop.Generator.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\net6\Il2CppInterop.Runtime.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\Il2CppMirror.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\Il2Cppmscorlib.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\net6\MelonLoader.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.CoreModule.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.IMGUIModule.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.InputLegacyModule.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.InputModule.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.TextRenderingModule.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.UI.dll - - - ..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.UIModule.dll - - - diff --git a/Plugins for Polytoria Creator.sln b/Plugins for Polytoria Creator.sln index 6264809..3b94f23 100644 --- a/Plugins for Polytoria Creator.sln +++ b/Plugins for Polytoria Creator.sln @@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugins for Polytoria Creat EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PolytoriaCreatorProxy", "PolytoriaCreatorProxy\PolytoriaCreatorProxy.csproj", "{E57BDB5F-586A-4854-9EBE-BAE7FBFBF1EF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "F2Rename", "F2Rename\F2Rename.csproj", "{F9593D1E-133D-486A-95DF-9AA402DF6255}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "F2Rename.BepInEx", "F2Rename.BepInEx\F2Rename.BepInEx.csproj", "{FDEC592F-1CB9-4B94-B539-AEE12BC9604F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -23,10 +23,10 @@ Global {E57BDB5F-586A-4854-9EBE-BAE7FBFBF1EF}.Debug|Any CPU.Build.0 = Debug|Any CPU {E57BDB5F-586A-4854-9EBE-BAE7FBFBF1EF}.Release|Any CPU.ActiveCfg = Release|Any CPU {E57BDB5F-586A-4854-9EBE-BAE7FBFBF1EF}.Release|Any CPU.Build.0 = Release|Any CPU - {F9593D1E-133D-486A-95DF-9AA402DF6255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9593D1E-133D-486A-95DF-9AA402DF6255}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9593D1E-133D-486A-95DF-9AA402DF6255}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9593D1E-133D-486A-95DF-9AA402DF6255}.Release|Any CPU.Build.0 = Release|Any CPU + {FDEC592F-1CB9-4B94-B539-AEE12BC9604F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDEC592F-1CB9-4B94-B539-AEE12BC9604F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDEC592F-1CB9-4B94-B539-AEE12BC9604F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDEC592F-1CB9-4B94-B539-AEE12BC9604F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Plugins for Polytoria Creator/Program.cs b/Plugins for Polytoria Creator/Program.cs index 19fbdc9..1334b2e 100644 --- a/Plugins for Polytoria Creator/Program.cs +++ b/Plugins for Polytoria Creator/Program.cs @@ -10,7 +10,7 @@ internal static class Program { /// The target version specifies the minimum version and the version /// PfPC should be used on. /// - public const long TargetVersion = 103037; // 1.3.37 + public const long TargetVersion = 1040106; // 1.4.106 public static string CreatorVersion { get; private set; } = "Unknown!"; public static long CreatorVersionNumeric { get; private set; } = -1; @@ -22,7 +22,7 @@ internal static class Program { public static string LocalModsPath { get; private set; } = Path.Join(AppPath, "installed"); - public static bool LoaderInstalled => File.Exists(Path.Join(InstalledCreatorPath, "version.dll")); + public static bool LoaderInstalled => File.Exists(Path.Join(InstalledCreatorPath, "winhttp.dll")); /// /// The main entry point for the application. diff --git a/Plugins for Polytoria Creator/StartForm.Designer.cs b/Plugins for Polytoria Creator/StartForm.Designer.cs index a34d046..62d08a7 100644 --- a/Plugins for Polytoria Creator/StartForm.Designer.cs +++ b/Plugins for Polytoria Creator/StartForm.Designer.cs @@ -22,162 +22,174 @@ protected override void Dispose(bool disposing) { /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// - private void InitializeComponent() { - this.LabelPolytoriaCreator = new System.Windows.Forms.Label(); - this.ButtonInstallLoader = new System.Windows.Forms.Button(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.ProgessBarState = new System.Windows.Forms.ToolStripProgressBar(); - this.LabelState = new System.Windows.Forms.ToolStripStatusLabel(); - this.ListBoxMods = new System.Windows.Forms.ListBox(); - this.LabelInstalled = new System.Windows.Forms.Label(); - this.LabelModTitle = new System.Windows.Forms.Label(); - this.LabelMinVersion = new System.Windows.Forms.Label(); - this.LabelMaxVersion = new System.Windows.Forms.Label(); - this.ButtonRemove = new System.Windows.Forms.Button(); - this.ButtonInstallFromZip = new System.Windows.Forms.Button(); - this.OpenFileDialogZipFile = new System.Windows.Forms.OpenFileDialog(); - this.statusStrip1.SuspendLayout(); - this.SuspendLayout(); + private void InitializeComponent() + { + LabelPolytoriaCreator = new Label(); + ButtonInstallLoader = new Button(); + statusStrip1 = new StatusStrip(); + ProgessBarState = new ToolStripProgressBar(); + LabelState = new ToolStripStatusLabel(); + ListBoxMods = new ListBox(); + LabelInstalled = new Label(); + LabelModTitle = new Label(); + LabelMinVersion = new Label(); + LabelMaxVersion = new Label(); + ButtonRemove = new Button(); + ButtonInstallFromZip = new Button(); + OpenFileDialogZipFile = new OpenFileDialog(); + installFromFolder = new Button(); + OpenFolderDialog = new FolderBrowserDialog(); + statusStrip1.SuspendLayout(); + SuspendLayout(); // // LabelPolytoriaCreator // - this.LabelPolytoriaCreator.AutoSize = true; - this.LabelPolytoriaCreator.Location = new System.Drawing.Point(15, 13); - this.LabelPolytoriaCreator.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.LabelPolytoriaCreator.Name = "LabelPolytoriaCreator"; - this.LabelPolytoriaCreator.Size = new System.Drawing.Size(371, 21); - this.LabelPolytoriaCreator.TabIndex = 0; - this.LabelPolytoriaCreator.Text = "Polytoria Creator Version: 0.0.0; Loader installed: No"; + LabelPolytoriaCreator.AutoSize = true; + LabelPolytoriaCreator.Location = new Point(15, 13); + LabelPolytoriaCreator.Margin = new Padding(4, 0, 4, 0); + LabelPolytoriaCreator.Name = "LabelPolytoriaCreator"; + LabelPolytoriaCreator.Size = new Size(466, 27); + LabelPolytoriaCreator.TabIndex = 0; + LabelPolytoriaCreator.Text = "Polytoria Creator Version: 0.0.0; Loader installed: No"; // // ButtonInstallLoader // - this.ButtonInstallLoader.Location = new System.Drawing.Point(629, 13); - this.ButtonInstallLoader.Name = "ButtonInstallLoader"; - this.ButtonInstallLoader.Size = new System.Drawing.Size(162, 36); - this.ButtonInstallLoader.TabIndex = 1; - this.ButtonInstallLoader.Text = "Install Loader/Sync"; - this.ButtonInstallLoader.UseVisualStyleBackColor = true; - this.ButtonInstallLoader.Click += new System.EventHandler(this.ButtonInstallLoader_Click); + ButtonInstallLoader.Location = new Point(629, 13); + ButtonInstallLoader.Name = "ButtonInstallLoader"; + ButtonInstallLoader.Size = new Size(162, 36); + ButtonInstallLoader.TabIndex = 1; + ButtonInstallLoader.Text = "Install Loader/Sync"; + ButtonInstallLoader.UseVisualStyleBackColor = true; + ButtonInstallLoader.Click += ButtonInstallLoader_Click; // // statusStrip1 // - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.ProgessBarState, - this.LabelState}); - this.statusStrip1.Location = new System.Drawing.Point(0, 388); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(803, 22); - this.statusStrip1.TabIndex = 2; - this.statusStrip1.Text = "statusStrip1"; + statusStrip1.ImageScalingSize = new Size(20, 20); + statusStrip1.Items.AddRange(new ToolStripItem[] { ProgessBarState, LabelState }); + statusStrip1.Location = new Point(0, 385); + statusStrip1.Name = "statusStrip1"; + statusStrip1.Size = new Size(803, 25); + statusStrip1.TabIndex = 2; + statusStrip1.Text = "statusStrip1"; // // ProgessBarState // - this.ProgessBarState.Name = "ProgessBarState"; - this.ProgessBarState.Size = new System.Drawing.Size(250, 16); + ProgessBarState.Name = "ProgessBarState"; + ProgessBarState.Size = new Size(250, 17); // // LabelState // - this.LabelState.Margin = new System.Windows.Forms.Padding(10, 3, 0, 2); - this.LabelState.Name = "LabelState"; - this.LabelState.Size = new System.Drawing.Size(116, 17); - this.LabelState.Text = "State: Doing nothing"; + LabelState.Margin = new Padding(10, 3, 0, 2); + LabelState.Name = "LabelState"; + LabelState.Size = new Size(146, 20); + LabelState.Text = "State: Doing nothing"; // // ListBoxMods // - this.ListBoxMods.FormattingEnabled = true; - this.ListBoxMods.ItemHeight = 21; - this.ListBoxMods.Location = new System.Drawing.Point(12, 65); - this.ListBoxMods.Name = "ListBoxMods"; - this.ListBoxMods.Size = new System.Drawing.Size(305, 277); - this.ListBoxMods.TabIndex = 3; + ListBoxMods.FormattingEnabled = true; + ListBoxMods.ItemHeight = 27; + ListBoxMods.Location = new Point(12, 65); + ListBoxMods.Name = "ListBoxMods"; + ListBoxMods.Size = new Size(305, 247); + ListBoxMods.TabIndex = 3; // // LabelInstalled // - this.LabelInstalled.AutoSize = true; - this.LabelInstalled.Location = new System.Drawing.Point(12, 41); - this.LabelInstalled.Name = "LabelInstalled"; - this.LabelInstalled.Size = new System.Drawing.Size(115, 21); - this.LabelInstalled.TabIndex = 4; - this.LabelInstalled.Text = "Isntalled mods:"; + LabelInstalled.AutoSize = true; + LabelInstalled.Location = new Point(12, 41); + LabelInstalled.Name = "LabelInstalled"; + LabelInstalled.Size = new Size(145, 27); + LabelInstalled.TabIndex = 4; + LabelInstalled.Text = "Isntalled mods:"; // // LabelModTitle // - this.LabelModTitle.AutoSize = true; - this.LabelModTitle.Font = new System.Drawing.Font("Segoe UI Variable Display", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.LabelModTitle.Location = new System.Drawing.Point(323, 65); - this.LabelModTitle.Name = "LabelModTitle"; - this.LabelModTitle.Size = new System.Drawing.Size(460, 30); - this.LabelModTitle.TabIndex = 5; - this.LabelModTitle.Text = "Click an installed mod to see more information"; + LabelModTitle.AutoSize = true; + LabelModTitle.Font = new Font("Segoe UI Variable Display", 16F, FontStyle.Regular, GraphicsUnit.Point); + LabelModTitle.Location = new Point(323, 65); + LabelModTitle.Name = "LabelModTitle"; + LabelModTitle.Size = new Size(563, 36); + LabelModTitle.TabIndex = 5; + LabelModTitle.Text = "Click an installed mod to see more information"; // // LabelMinVersion // - this.LabelMinVersion.AutoSize = true; - this.LabelMinVersion.Location = new System.Drawing.Point(323, 95); - this.LabelMinVersion.Name = "LabelMinVersion"; - this.LabelMinVersion.Size = new System.Drawing.Size(203, 21); - this.LabelMinVersion.TabIndex = 6; - this.LabelMinVersion.Text = "Minimum creator version: ?"; + LabelMinVersion.AutoSize = true; + LabelMinVersion.Location = new Point(323, 95); + LabelMinVersion.Name = "LabelMinVersion"; + LabelMinVersion.Size = new Size(251, 27); + LabelMinVersion.TabIndex = 6; + LabelMinVersion.Text = "Minimum creator version: ?"; // // LabelMaxVersion // - this.LabelMaxVersion.AutoSize = true; - this.LabelMaxVersion.Location = new System.Drawing.Point(323, 116); - this.LabelMaxVersion.Name = "LabelMaxVersion"; - this.LabelMaxVersion.Size = new System.Drawing.Size(205, 21); - this.LabelMaxVersion.TabIndex = 7; - this.LabelMaxVersion.Text = "Maximum creator version: ?"; + LabelMaxVersion.AutoSize = true; + LabelMaxVersion.Location = new Point(323, 116); + LabelMaxVersion.Name = "LabelMaxVersion"; + LabelMaxVersion.Size = new Size(254, 27); + LabelMaxVersion.TabIndex = 7; + LabelMaxVersion.Text = "Maximum creator version: ?"; // // ButtonRemove // - this.ButtonRemove.Location = new System.Drawing.Point(323, 345); - this.ButtonRemove.Name = "ButtonRemove"; - this.ButtonRemove.Size = new System.Drawing.Size(460, 40); - this.ButtonRemove.TabIndex = 8; - this.ButtonRemove.Text = "Remove"; - this.ButtonRemove.UseVisualStyleBackColor = true; - this.ButtonRemove.Click += new System.EventHandler(this.ButtonRemove_Click); + ButtonRemove.Location = new Point(323, 345); + ButtonRemove.Name = "ButtonRemove"; + ButtonRemove.Size = new Size(460, 40); + ButtonRemove.TabIndex = 8; + ButtonRemove.Text = "Remove"; + ButtonRemove.UseVisualStyleBackColor = true; + ButtonRemove.Click += ButtonRemove_Click; // // ButtonInstallFromZip // - this.ButtonInstallFromZip.Location = new System.Drawing.Point(12, 345); - this.ButtonInstallFromZip.Name = "ButtonInstallFromZip"; - this.ButtonInstallFromZip.Size = new System.Drawing.Size(305, 40); - this.ButtonInstallFromZip.TabIndex = 9; - this.ButtonInstallFromZip.Text = "Install from zip file"; - this.ButtonInstallFromZip.UseVisualStyleBackColor = true; - this.ButtonInstallFromZip.Click += new System.EventHandler(this.ButtonInstallFromZip_Click); + ButtonInstallFromZip.Location = new Point(12, 349); + ButtonInstallFromZip.Name = "ButtonInstallFromZip"; + ButtonInstallFromZip.Size = new Size(305, 33); + ButtonInstallFromZip.TabIndex = 9; + ButtonInstallFromZip.Text = "Install from zip file"; + ButtonInstallFromZip.UseVisualStyleBackColor = true; + ButtonInstallFromZip.Click += ButtonInstallFromZip_Click; // // OpenFileDialogZipFile // - this.OpenFileDialogZipFile.Filter = "ZIP-Files|*.zip"; - this.OpenFileDialogZipFile.FileOk += new System.ComponentModel.CancelEventHandler(this.OpenFileDialogZipFile_FileOk); + OpenFileDialogZipFile.Filter = "ZIP-Files|*.zip"; + OpenFileDialogZipFile.FileOk += OpenFileDialogZipFile_FileOk; + // + // installFromFolder + // + installFromFolder.Location = new Point(12, 318); + installFromFolder.Name = "installFromFolder"; + installFromFolder.Size = new Size(305, 35); + installFromFolder.TabIndex = 10; + installFromFolder.Text = "Install from folder"; + installFromFolder.UseVisualStyleBackColor = true; + installFromFolder.Click += installFromFolder_Click; // // StartForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(803, 410); - this.Controls.Add(this.ButtonInstallFromZip); - this.Controls.Add(this.ButtonRemove); - this.Controls.Add(this.LabelMaxVersion); - this.Controls.Add(this.LabelMinVersion); - this.Controls.Add(this.LabelModTitle); - this.Controls.Add(this.LabelInstalled); - this.Controls.Add(this.ListBoxMods); - this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.ButtonInstallLoader); - this.Controls.Add(this.LabelPolytoriaCreator); - this.Font = new System.Drawing.Font("Segoe UI Variable Display", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.Margin = new System.Windows.Forms.Padding(4); - this.Name = "StartForm"; - this.Text = "MainForm"; - this.Load += new System.EventHandler(this.StartForm_Load); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(11F, 27F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(803, 410); + Controls.Add(installFromFolder); + Controls.Add(ButtonInstallFromZip); + Controls.Add(ButtonRemove); + Controls.Add(LabelMaxVersion); + Controls.Add(LabelMinVersion); + Controls.Add(LabelModTitle); + Controls.Add(LabelInstalled); + Controls.Add(ListBoxMods); + Controls.Add(statusStrip1); + Controls.Add(ButtonInstallLoader); + Controls.Add(LabelPolytoriaCreator); + Font = new Font("Segoe UI Variable Display", 12F, FontStyle.Regular, GraphicsUnit.Point); + Margin = new Padding(4); + Name = "StartForm"; + Text = "MainForm"; + Load += StartForm_Load; + statusStrip1.ResumeLayout(false); + statusStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -195,5 +207,7 @@ private void InitializeComponent() { private Button ButtonRemove; private Button ButtonInstallFromZip; private OpenFileDialog OpenFileDialogZipFile; + private Button installFromFolder; + private FolderBrowserDialog OpenFolderDialog; } } \ No newline at end of file diff --git a/Plugins for Polytoria Creator/StartForm.cs b/Plugins for Polytoria Creator/StartForm.cs index a4a331b..89d409a 100644 --- a/Plugins for Polytoria Creator/StartForm.cs +++ b/Plugins for Polytoria Creator/StartForm.cs @@ -6,11 +6,13 @@ using System.Net; namespace Plugins_for_Polytoria_Creator { - public partial class StartForm : Form { + public partial class StartForm : Form + { public static StartForm Instance { get; private set; } private BindingList mods = new(); - public StartForm() { + public StartForm() + { InitializeComponent(); ListBoxMods.DataSource = mods; Instance = this; @@ -18,26 +20,31 @@ public StartForm() { LoadInstalledMods(); } - private void LoadInstalledMods() { + private void LoadInstalledMods() + { mods.Clear(); ListBoxMods.ClearSelected(); string[] modDirectories = Directory.GetDirectories(Program.LocalModsPath); - foreach (var modDirectory in modDirectories) { + foreach (var modDirectory in modDirectories) + { var metaPath = Path.Join(modDirectory, "meta.json"); - if (!File.Exists(metaPath)) { + if (!File.Exists(metaPath)) + { continue; // Probably a corrupted mod } ModMeta? meta = JsonConvert.DeserializeObject( File.ReadAllText(metaPath), - new JsonSerializerSettings() { + new JsonSerializerSettings() + { MissingMemberHandling = MissingMemberHandling.Ignore, }); - if (meta == null) { + if (meta == null) + { continue; } @@ -47,10 +54,12 @@ private void LoadInstalledMods() { UpdateSelectedUI(); } - private void UpdateSelectedUI() { + private void UpdateSelectedUI() + { ModMeta? selectedMod = ListBoxMods.SelectedItem as ModMeta; - if (selectedMod == null) { + if (selectedMod == null) + { return; } @@ -59,14 +68,17 @@ private void UpdateSelectedUI() { LabelMaxVersion.Text = $"Maximum Creator Version: {selectedMod.MaxCreatorVersion}"; } - private void StartForm_Load(object sender, EventArgs e) { + private void StartForm_Load(object sender, EventArgs e) + { LabelPolytoriaCreator.Text = $"Polytoria Creator Version: {Program.CreatorVersionNumeric} ({Program.CreatorVersion}); Loader Installed: {Program.LoaderInstalled}"; UpdateInstallerButton(); } - private async void ButtonInstallLoader_Click(object sender, EventArgs e) { - if (Program.LoaderInstalled) { + private async void ButtonInstallLoader_Click(object sender, EventArgs e) + { + if (Program.LoaderInstalled) + { ErrorUtils.ShowError("PfPC is already installed for that version!"); return; } @@ -84,27 +96,33 @@ private async void ButtonInstallLoader_Click(object sender, EventArgs e) { LabelState.Text = "Synced mods!"; } - private async Task DownloadMelonLoader() { - LabelState.Text = "Downloading MelonLoader... (0 mb / ? mb)"; + private async Task DownloadMelonLoader() + { + LabelState.Text = "Downloading BepInEx... (0 mb / ? mb)"; ProgessBarState.Value = 0; WebClient wc = new(); wc.DownloadProgressChanged += MelonLoader_DownloadProgressChanged; - try { + try + { await wc.DownloadFileTaskAsync( - new Uri("https://github.com/LavaGang/MelonLoader/releases/latest/download/MelonLoader.x64.zip"), + //new Uri("https://nightly.link/LavaGang/MelonLoader/workflows/build/alpha-development/MelonLoader.Windows.x64.CI.Release.zip"), + new Uri("https://builds.bepinex.dev/projects/bepinex_be/692/BepInEx-Unity.IL2CPP-win-x64-6.0.0-be.692%2B851521c.zip"), Path.Join(Program.AppPath, "MelonLoader.zip")); - } catch (Exception ex) { - ErrorUtils.ShowError($"Failed to download melonloader!\n" + + } catch (Exception ex) + { + ErrorUtils.ShowError($"Failed to download BepInEx!\n" + $"Error: {ex.Message}"); } return true; } - private async Task ExtractMelonLoader() { - try { + private async Task ExtractMelonLoader() + { + try + { LabelState.Text = "Extracting files..."; ProgessBarState.Value = 0; @@ -123,15 +141,18 @@ private async Task ExtractMelonLoader() { ProgessBarState.Value = 100; return true; - } catch (Exception ex) { + } catch (Exception ex) + { ErrorUtils.ShowError($"Failed to extract melonloader!\n" + $"Error: {ex.Message}"); return false; } } - private async Task CopyFiles() { - try { + private async Task CopyFiles() + { + try + { LabelState.Text = "Installing loader..."; ProgessBarState.Value = 0; @@ -168,39 +189,47 @@ private async Task CopyFiles() { ProgessBarState.Value = 100; return true; - } catch (Exception ex) { + } catch (Exception ex) + { ErrorUtils.ShowError($"Failed to install loader!\n" + $"Error: {ex.Message}"); return false; } } - private async Task SyncMods() { - try { + private async Task SyncMods() + { + try + { if (mods.Count == 0) return true; LabelState.Text = "Syncing mods..."; ProgessBarState.Value = 0; ProgessBarState.Maximum = mods.Count; - foreach (var mod in mods) { - try { + foreach (var mod in mods) + { + try + { InstallModToCreator(Path.Join(Program.LocalModsPath, mod.ModFolderName)); - } catch (Exception ex) { + } catch (Exception ex) + { ErrorUtils.ShowError($"Failed to synchronize mod '{mod.ModDisplayName}'!\n" + $"Error: {ex.Message}"); } } return true; - } catch (Exception ex) { + } catch (Exception ex) + { ErrorUtils.ShowError($"Failed to synchronize mods!\n" + $"Error: {ex.Message}"); return false; } } - private void MelonLoader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { + private void MelonLoader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) + { LabelState.Text = $"Downloading MelonLoader... (" + $"{SizeUtils.GetSizeInMegabytes(e.BytesReceived):F2} mb / " + $"{SizeUtils.GetSizeInMegabytes(e.TotalBytesToReceive):F2} mb" + @@ -209,40 +238,74 @@ private void MelonLoader_DownloadProgressChanged(object sender, DownloadProgress ProgessBarState.Value = e.ProgressPercentage; } - private void UpdateInstallerButton() { - if (Program.LoaderInstalled) { + private void UpdateInstallerButton() + { + if (Program.LoaderInstalled) + { ButtonInstallLoader.Visible = false; } } - private void ButtonInstallFromGIT_Click(object sender, EventArgs e) { + private void ButtonInstallFromGIT_Click(object sender, EventArgs e) + { var dialog = new AddFromGITForm(); dialog.ShowDialog(); } - public void InstallFromGIT(string url) { + public void InstallFromGIT(string url) + { } - private void ButtonInstallFromZip_Click(object sender, EventArgs e) { + private void ButtonInstallFromZip_Click(object sender, EventArgs e) + { OpenFileDialogZipFile.ShowDialog(); } - private void OpenFileDialogZipFile_FileOk(object sender, CancelEventArgs e) { + private void installFromFolder_Click(object sender, EventArgs e) + { + OpenFolderDialog.ShowDialog(); + + if (!Directory.Exists(OpenFolderDialog.SelectedPath)) + { + ErrorUtils.ShowError("The specified folder was not found."); + } + + try + { + var meta = InstallModToCreator(OpenFolderDialog.SelectedPath); + + DirectoryUtils.CopyRecursive(OpenFolderDialog.SelectedPath, + Path.Join(Program.LocalModsPath, meta.ModFolderName)); + + LoadInstalledMods(); + } catch (Exception ex) + { + ErrorUtils.ShowError("Was not able to install mod.\n\n" + + "Error:" + ex.Message); + } + } + + private void OpenFileDialogZipFile_FileOk(object sender, CancelEventArgs e) + { // TODO: Add Status Strip Updates - if (!File.Exists(OpenFileDialogZipFile.FileName)) { + if (!File.Exists(OpenFileDialogZipFile.FileName)) + { ErrorUtils.ShowError("The specified file was not found."); } - try { + try + { var extractPath = Path.Join(Program.AppPath, "tmpextract"); - if (Directory.Exists(extractPath)) { + if (Directory.Exists(extractPath)) + { Directory.Delete(extractPath, true); } using (ZipArchive archive = - new ZipArchive(File.OpenRead(OpenFileDialogZipFile.FileName), ZipArchiveMode.Read)) { + new ZipArchive(File.OpenRead(OpenFileDialogZipFile.FileName), ZipArchiveMode.Read)) + { archive.ExtractToDirectory(extractPath); var meta = InstallModToCreator(extractPath); @@ -252,35 +315,42 @@ private void OpenFileDialogZipFile_FileOk(object sender, CancelEventArgs e) { LoadInstalledMods(); } - } catch (Exception ex) { + } catch (Exception ex) + { ErrorUtils.ShowError("Was not able to install mod.\n\n" + "Error:" + ex.Message); } } - private ModMeta InstallModToCreator(string path) { - if (!File.Exists(Path.Join(path, "meta.json"))) { + private ModMeta InstallModToCreator(string path) + { + if (!File.Exists(Path.Join(path, "meta.json"))) + { throw new InvalidDataException("Mod is missing a meta.json file in root."); } ModMeta meta = JsonConvert.DeserializeObject( File.ReadAllText(Path.Join(path, "meta.json")), - new JsonSerializerSettings() { + new JsonSerializerSettings() + { MissingMemberHandling = MissingMemberHandling.Error, }) ?? throw new InvalidDataException("Invalid meta.json"); - if (!Directory.Exists(Path.Join(path, "files"))) { + if (!Directory.Exists(Path.Join(path, "files"))) + { throw new InvalidDataException("Mod is missing mod files."); } var creatorModTypePath = GetCreatorPathForModType(meta.ModType); - if (!Directory.Exists(creatorModTypePath)) { + if (!Directory.Exists(creatorModTypePath)) + { Directory.CreateDirectory(creatorModTypePath); } - if (!Directory.Exists(Path.Join(Program.LocalModsPath, meta.ModFolderName))) { + if (!Directory.Exists(Path.Join(Program.LocalModsPath, meta.ModFolderName))) + { Directory.CreateDirectory(Path.Join(Program.LocalModsPath, meta.ModFolderName)); } @@ -289,46 +359,57 @@ private ModMeta InstallModToCreator(string path) { return meta; } - private string GetCreatorPathForModType(ModType modType) { + private string GetCreatorPathForModType(ModType modType) + { var path = Program.InstalledCreatorPath; - if (modType == ModType.Mod) { - path = Path.Join(path, "Mods"); - } else if (modType == ModType.UserLib) { - path = Path.Join(path, "UserLibs"); + if (modType == ModType.Mod) + { + path = Path.Join(path, "BepInEx", "plugins"); + } else if (modType == ModType.UserLib) + { + throw new Exception("Unsupported type: UserLib"); + //path = Path.Join(path, "UserLibs"); } return path; } - private void ButtonRemove_Click(object sender, EventArgs e) { + private void ButtonRemove_Click(object sender, EventArgs e) + { ModMeta? selectedMod = ListBoxMods.SelectedItem as ModMeta; - if (selectedMod == null) { + if (selectedMod == null) + { return; } RemoveMod(selectedMod); } - private void RemoveMod(ModMeta meta) { + private void RemoveMod(ModMeta meta) + { var localModPath = Path.Join(Program.LocalModsPath, meta.ModFolderName); var creatorModBasePath = GetCreatorPathForModType(meta.ModType); - foreach (var modFile in Directory.GetFiles(Path.Join(localModPath, "files"))) { + foreach (var modFile in Directory.GetFiles(Path.Join(localModPath, "files"))) + { var creatorModFilePath = Path.Join(creatorModBasePath, Path.GetFileName(modFile)); - if (File.Exists(creatorModFilePath)) { + if (File.Exists(creatorModFilePath)) + { File.Delete(creatorModFilePath); } } - if (Directory.Exists(localModPath)) { + if (Directory.Exists(localModPath)) + { Directory.Delete(localModPath, true); } LoadInstalledMods(); } + } } diff --git a/Plugins for Polytoria Creator/StartForm.resx b/Plugins for Polytoria Creator/StartForm.resx index b7f8251..6ea0bda 100644 --- a/Plugins for Polytoria Creator/StartForm.resx +++ b/Plugins for Polytoria Creator/StartForm.resx @@ -1,4 +1,64 @@ - + + + @@ -63,4 +123,7 @@ 133, 17 + + 342, 17 + \ No newline at end of file