Skip to content

Commit

Permalink
make it use bepinex
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenretriverYT committed Aug 11, 2024
1 parent be4619a commit e814f40
Show file tree
Hide file tree
Showing 8 changed files with 752 additions and 232 deletions.
329 changes: 329 additions & 0 deletions F2Rename.BepInEx/F2Rename.BepInEx.csproj

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions F2Rename.BepInEx/Plugin.cs
Original file line number Diff line number Diff line change
@@ -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<RenameUI>();
}
}

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<UnityEngine.UI.InputField>();
inputField.textComponent = inputFieldGO.AddComponent<UnityEngine.UI.Text>();
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>();
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<RTObjectSelection>.Get.SelectedObjects;
if (instances.Count != 1) return;

Plugin.Log.LogInfo("1 instance selected, showing change name ui");
instance = instances[0].GetComponent<Instance>();
name = instance.Name;


}
}
}
}
51 changes: 0 additions & 51 deletions F2Rename/F2Rename.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,4 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Il2CppBattlehub.RTEditor">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\Il2CppBattlehub.RTEditor.dll</HintPath>
</Reference>
<Reference Include="Il2CppInterop.Common">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\net6\Il2CppInterop.Common.dll</HintPath>
</Reference>
<Reference Include="Il2CppInterop.Generator">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\net6\Il2CppInterop.Generator.dll</HintPath>
</Reference>
<Reference Include="Il2CppInterop.Runtime">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\net6\Il2CppInterop.Runtime.dll</HintPath>
</Reference>
<Reference Include="Il2CppMirror">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\Il2CppMirror.dll</HintPath>
</Reference>
<Reference Include="Il2Cppmscorlib">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\Il2Cppmscorlib.dll</HintPath>
</Reference>
<Reference Include="MelonLoader">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\net6\MelonLoader.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputModule">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.InputModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>..\..\..\..\AppData\Roaming\Polytoria\Creator\1.3.37\MelonLoader\Il2CppAssemblies\UnityEngine.UIModule.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions Plugins for Polytoria Creator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Plugins for Polytoria Creator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static class Program {
/// The target version specifies the minimum version and the version
/// PfPC should be used on.
/// </summary>
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;
Expand All @@ -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"));

/// <summary>
/// The main entry point for the application.
Expand Down
Loading

0 comments on commit e814f40

Please sign in to comment.