Skip to content

Commit

Permalink
* PH Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mantas-2155X committed Nov 15, 2020
1 parent 00deeb1 commit 471a930
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 0 deletions.
21 changes: 21 additions & 0 deletions PH_StudioAccessoryNames/Hooks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using HarmonyLib;

using Studio;

namespace PH_StudioAccessoryNames
{
public static class Hooks
{
[HarmonyPostfix, HarmonyPatch(typeof(MPCharCtrl.AccessoriesInfo), "UpdateInfo")]
private static void AccessoriesInfo_UpdateInfo_ChangeLabels(OCIChar _char)
{
PH_StudioAccessoryNames.instance.StartCoroutine(PH_StudioAccessoryNames.UpdateStudioLabelsDelayed(_char));
}

[HarmonyPostfix, HarmonyPatch(typeof(MPCharCtrl), "UpdateInfo")]
private static void MPCharCtrl_UpdateInfo_ChangeLabels(OCIChar ___m_OCIChar)
{
PH_StudioAccessoryNames.instance.StartCoroutine(PH_StudioAccessoryNames.UpdateStudioLabelsDelayed(___m_OCIChar));
}
}
}
81 changes: 81 additions & 0 deletions PH_StudioAccessoryNames/PH_StudioAccessoryNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System.Collections;

using BepInEx;
using HarmonyLib;

using Studio;

using UnityEngine;
using UnityEngine.UI;

namespace PH_StudioAccessoryNames
{
[BepInPlugin(nameof(PH_StudioAccessoryNames), nameof(PH_StudioAccessoryNames), VERSION)]
[BepInProcess("PlayHomeStudio64bit")]
[BepInProcess("PlayHomeStudio32bit")]
public class PH_StudioAccessoryNames : BaseUnityPlugin
{
public const string VERSION = "1.0.0";

public static PH_StudioAccessoryNames instance;

private void Awake()
{
instance = this;

var harmony = new Harmony("PH_StudioAccessoryNames");
harmony.PatchAll(typeof(Hooks));
}

public static IEnumerator UpdateStudioLabelsDelayed(OCIChar _char)
{
yield return null;

var slots = GameObject.Find("StudioScene/Canvas Main Menu/02_Manipulate/00_Chara/01_State/Viewport/Content/Slot");
var moreAccs = slots.transform.childCount > 10;

for (var i = 0; i < slots.transform.childCount; i++)
{
var child = slots.transform.GetChild(i);

var buttons = child.GetComponentsInChildren<Button>();
foreach (var btn in buttons)
{
var oldPos = btn.transform.localPosition;

switch ((int)oldPos.x)
{
case 80:
btn.transform.localPosition = new Vector3(104, oldPos.y, oldPos.z);
break;
case 104:
btn.transform.localPosition = new Vector3(128, oldPos.y, oldPos.z);
break;
}
}

var text = child.GetComponentInChildren<Text>();
if (text == null)
continue;

text.resizeTextMinSize = 6;

var textRect = text.GetComponent<RectTransform>();
textRect.offsetMax = new Vector2(100, textRect.offsetMax.y);

if (moreAccs && i == slots.transform.childCount - 1)
continue;

if (!child.gameObject.activeSelf)
{
text.text = $"スロット{i + 1:D2}";
}
else
{
var acc = _char.charInfo.human.accessories.GetAccessoryData(_char.charInfo.human.customParam.acce, i);
text.text = acc == null ? $"スロット{i+1:D2}" : $"{i+1:D2} {acc.name}";
}
}
}
}
}
70 changes: 70 additions & 0 deletions PH_StudioAccessoryNames/PH_StudioAccessoryNames.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{74D2DF72-B325-4DA2-883F-CCAB8EA065E2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PH_StudioAccessoryNames</RootNamespace>
<AssemblyName>PH_StudioAccessoryNames</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>false</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>../_bin/PH/BepInEx/plugins/2155X/</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\..\libs\GitHub\BepInEx\latest\BepInEx\core\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\libs\Game\PH\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\..\libs\GitHub\BepInEx\latest\BepInEx\core\BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx.Harmony">
<HintPath>..\..\..\libs\GitHub\BepInEx\latest\BepInEx\core\BepInEx.Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\libs\Game\PH\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\libs\Game\PH\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PH_StudioAccessoryNames.cs" />
<Compile Include="Hooks.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
35 changes: 35 additions & 0 deletions PH_StudioAccessoryNames/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PH_StudioAccessoryNames")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Mantas-2155X aka 2155X")]
[assembly: AssemblyProduct("PH_StudioAccessoryNames")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("74D2DF72-B325-4DA2-883F-CCAB8EA065E2")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(PH_StudioAccessoryNames.PH_StudioAccessoryNames.VERSION)]
[assembly: AssemblyFileVersion(PH_StudioAccessoryNames.PH_StudioAccessoryNames.VERSION)]
6 changes: 6 additions & 0 deletions StudioAccessoryNames.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HS2_StudioAccessoryNames",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AI_StudioAccessoryNames", "AI_StudioAccessoryNames\AI_StudioAccessoryNames.csproj", "{92072B35-8BBB-4FAC-95C9-35AD4CEAA06B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PH_StudioAccessoryNames", "PH_StudioAccessoryNames\PH_StudioAccessoryNames.csproj", "{74D2DF72-B325-4DA2-883F-CCAB8EA065E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -24,5 +26,9 @@ Global
{92072B35-8BBB-4FAC-95C9-35AD4CEAA06B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92072B35-8BBB-4FAC-95C9-35AD4CEAA06B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92072B35-8BBB-4FAC-95C9-35AD4CEAA06B}.Release|Any CPU.Build.0 = Release|Any CPU
{74D2DF72-B325-4DA2-883F-CCAB8EA065E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74D2DF72-B325-4DA2-883F-CCAB8EA065E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74D2DF72-B325-4DA2-883F-CCAB8EA065E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74D2DF72-B325-4DA2-883F-CCAB8EA065E2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit 471a930

Please sign in to comment.