skin button fixes
This commit is contained in:
parent
4cad61403a
commit
42f5667d57
3 changed files with 96 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Unity.Collections;
|
||||||
using Unity.VisualScripting;
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
@ -29,6 +30,19 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
text.autoSizeTextContainer = true;
|
text.autoSizeTextContainer = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skin button resize
|
||||||
|
|
||||||
|
AlmanacPlantWindow window = __instance.window;
|
||||||
|
GameObject skinButton = window.skinButton;
|
||||||
|
GameObject skinTextObj = skinButton.transform.GetChild(0).gameObject;
|
||||||
|
GameObject skinShadowTextObj = skinTextObj.transform.GetChild(0).gameObject;
|
||||||
|
TextMeshProUGUI skinShadowText = skinShadowTextObj.GetComponent<TextMeshProUGUI>();
|
||||||
|
skinShadowText.text = StringStore.TranslateText("换肤_S");
|
||||||
|
skinButton.transform.localScale /= 1.75f;
|
||||||
|
skinButton.transform.localPosition = new Vector3(0.0f, 111.345f, 0.0f);
|
||||||
|
skinButton.transform.GetChild(1).Translate(new Vector3(-0.35f, 0));
|
||||||
|
skinButton.transform.GetChild(2).Translate(new Vector3(0.35f, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AlmanacPlantMenu.SearchChanged))]
|
[HarmonyPatch(nameof(AlmanacPlantMenu.SearchChanged))]
|
||||||
|
|
@ -54,6 +68,24 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
|
||||||
foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants)
|
foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants)
|
||||||
{
|
{
|
||||||
|
//List<int> uniqueIngredients = GetIngredients(plantInfo.seedType);
|
||||||
|
|
||||||
|
//// ingredient-based search
|
||||||
|
|
||||||
|
//foreach(int i in uniqueIngredients)
|
||||||
|
//{
|
||||||
|
// string name = Utils.GetPlantNameFromAlmanac((PlantType)i);
|
||||||
|
|
||||||
|
// if(name.ToLower().Contains(search.ToLower()))
|
||||||
|
// {
|
||||||
|
// searchedPlants.Add((PlantType)i);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
// keyword-based search
|
||||||
|
|
||||||
|
// name-based search
|
||||||
|
|
||||||
if (plantInfo.name.ToLower().Contains(search.ToLower()))
|
if (plantInfo.name.ToLower().Contains(search.ToLower()))
|
||||||
{
|
{
|
||||||
searchedPlants.Add((PlantType)plantInfo.seedType);
|
searchedPlants.Add((PlantType)plantInfo.seedType);
|
||||||
|
|
@ -67,5 +99,65 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<int> GetIngredients(int theSeedType)
|
||||||
|
{
|
||||||
|
List<int> ingredientPairs = new();
|
||||||
|
Il2CppSystem.Array mixData = MixData.data.Cast<Il2CppSystem.Array>();
|
||||||
|
int rows = mixData.GetLength(0);
|
||||||
|
int columns = mixData.GetLength(1);
|
||||||
|
|
||||||
|
for(int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < columns; j++)
|
||||||
|
{
|
||||||
|
if(ContainsFormula(theSeedType))
|
||||||
|
{
|
||||||
|
if (mixData.GetValue(i, j).Unbox<int>() == theSeedType)
|
||||||
|
{
|
||||||
|
if (!ingredientPairs.Contains(i))
|
||||||
|
{
|
||||||
|
ingredientPairs.Add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ingredientPairs.Contains(j))
|
||||||
|
{
|
||||||
|
ingredientPairs.Add(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ingredientPairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ingredientPairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool ContainsFormula(int theSeedType)
|
||||||
|
{
|
||||||
|
bool contains = false;
|
||||||
|
|
||||||
|
Il2CppSystem.Array mixData = MixData.data.Cast<Il2CppSystem.Array>();
|
||||||
|
int rows = mixData.GetLength(0);
|
||||||
|
int columns = mixData.GetLength(1);
|
||||||
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < columns; j++)
|
||||||
|
{
|
||||||
|
if (mixData.GetValue(i, j).Unbox<int>() == theSeedType)
|
||||||
|
{
|
||||||
|
contains = true;
|
||||||
|
return contains;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return contains;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,10 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
{
|
{
|
||||||
foreach (TextMeshProUGUI text in __instance.showedPlantName)
|
foreach (TextMeshProUGUI text in __instance.showedPlantName)
|
||||||
{
|
{
|
||||||
|
text.autoSizeTextContainer = false;
|
||||||
text.text = $"{Utils.RemoveSizeTags(plantInfo.name)} ({plantInfo.seedType})";
|
text.text = $"{Utils.RemoveSizeTags(plantInfo.name)} ({plantInfo.seedType})";
|
||||||
text.font = fontAsset;
|
text.font = fontAsset;
|
||||||
|
text.fontSizeMax = 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
__instance.showedPlantIntroduce.text = Utils.RemoveSizeTags(plantInfo.info) + "\n\n" + Utils.RemoveSizeTags(plantInfo.introduce) + "\n\n";
|
__instance.showedPlantIntroduce.text = Utils.RemoveSizeTags(plantInfo.info) + "\n\n" + Utils.RemoveSizeTags(plantInfo.introduce) + "\n\n";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations>
|
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations>
|
||||||
<GamePath>C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.2</GamePath>
|
<GamePath>C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.2.1</GamePath>
|
||||||
<Platforms>AnyCPU;ARM64;x64</Platforms>
|
<Platforms>AnyCPU;ARM64;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue