mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-25 20:12:39 +00:00
[+] Use the png jacket as bga
This commit is contained in:
parent
8b72214780
commit
2946c51774
@ -13,6 +13,7 @@
|
|||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
|
<LangVersion>12</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugSymbols>false</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
@ -281,6 +282,7 @@
|
|||||||
<Compile Include="UX\ImmediateSave.cs" />
|
<Compile Include="UX\ImmediateSave.cs" />
|
||||||
<Compile Include="UX\LoadJacketPng.cs" />
|
<Compile Include="UX\LoadJacketPng.cs" />
|
||||||
<Compile Include="UX\LoadAssetBundleWithoutManifest.cs" />
|
<Compile Include="UX\LoadAssetBundleWithoutManifest.cs" />
|
||||||
|
<Compile Include="UX\LoadLocalBga.cs" />
|
||||||
<Compile Include="UX\QuickSkip.cs" />
|
<Compile Include="UX\QuickSkip.cs" />
|
||||||
<Compile Include="UX\RandomBgm.cs" />
|
<Compile Include="UX\RandomBgm.cs" />
|
||||||
<Compile Include="UX\RunCommandOnEvents.cs" />
|
<Compile Include="UX\RunCommandOnEvents.cs" />
|
||||||
|
|||||||
@ -22,6 +22,9 @@ SkipToMusicSelection=false
|
|||||||
CustomVersionString=""
|
CustomVersionString=""
|
||||||
# Load Jacket image from folder "LocalAssets" and filename "{MusicID}.png" for self-made charts
|
# Load Jacket image from folder "LocalAssets" and filename "{MusicID}.png" for self-made charts
|
||||||
LoadJacketPng=true
|
LoadJacketPng=true
|
||||||
|
# Use the png jacket above as BGA if BGA is not found for self-made charts
|
||||||
|
# Use together with `LoadJacketPng`
|
||||||
|
LoadLocalBga=true
|
||||||
# Press key "7" for 1 second to skip to next step or restart current song
|
# Press key "7" for 1 second to skip to next step or restart current song
|
||||||
QuickSkip=true
|
QuickSkip=true
|
||||||
# Add ".ab" image resources without the need of rebuilding a manifest
|
# Add ".ab" image resources without the need of rebuilding a manifest
|
||||||
@ -42,4 +45,4 @@ ImmediateSave=true
|
|||||||
|
|
||||||
[Performance]
|
[Performance]
|
||||||
# Disable some useless delays to speed up the game boot process
|
# Disable some useless delays to speed up the game boot process
|
||||||
ImproveLoadSpeed=false
|
ImproveLoadSpeed=false
|
||||||
|
|||||||
@ -29,6 +29,7 @@ namespace AquaMai
|
|||||||
public bool ExtendTimer { get; set; }
|
public bool ExtendTimer { get; set; }
|
||||||
public bool SkipEventInfo { get; set; }
|
public bool SkipEventInfo { get; set; }
|
||||||
public bool ImmediateSave { get; set; }
|
public bool ImmediateSave { get; set; }
|
||||||
|
public bool LoadLocalBga { get; set; }
|
||||||
public string CustomVersionString { get; set; }
|
public string CustomVersionString { get; set; }
|
||||||
public string ExecOnIdle { get; set; }
|
public string ExecOnIdle { get; set; }
|
||||||
public string ExecOnEntry { get; set; }
|
public string ExecOnEntry { get; set; }
|
||||||
|
|||||||
@ -5,7 +5,6 @@ using System.Reflection;
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using MelonLoader;
|
|
||||||
|
|
||||||
namespace AquaMai.UX
|
namespace AquaMai.UX
|
||||||
{
|
{
|
||||||
@ -27,26 +26,49 @@ namespace AquaMai.UX
|
|||||||
}
|
}
|
||||||
|
|
||||||
var id = matches[0].Groups[1].Value;
|
var id = matches[0].Groups[1].Value;
|
||||||
foreach (var ext in new[] { ".jpg", ".png", ".webp", ".bmp", ".gif" })
|
|
||||||
{
|
|
||||||
if (File.Exists(Path.Combine(Environment.CurrentDirectory, "LocalAssets", id + ext)))
|
|
||||||
{
|
|
||||||
filename = id + ext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var localPath = Path.Combine(Environment.CurrentDirectory, "LocalAssets", filename);
|
var texture = GetJacketTexture2D(id);
|
||||||
if (File.Exists(localPath))
|
if (texture is null)
|
||||||
{
|
{
|
||||||
__result = new Texture2D(1, 1);
|
__result = __instance.LoadAsset<Texture2D>($"Jacket/UI_Jacket_{id}.png");
|
||||||
ImageConversion.LoadImage(__result, File.ReadAllBytes(localPath));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__result = __instance.LoadAsset<Texture2D>($"Jacket/UI_Jacket_{id}.png");
|
__result = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetJacketPath(string id)
|
||||||
|
{
|
||||||
|
foreach (var ext in new[] { ".jpg", ".png", ".webp", ".bmp", ".gif" })
|
||||||
|
{
|
||||||
|
if (File.Exists(Path.Combine(Environment.CurrentDirectory, "LocalAssets", id + ext)))
|
||||||
|
{
|
||||||
|
return Path.Combine(Environment.CurrentDirectory, "LocalAssets", id + ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Texture2D GetJacketTexture2D(string id)
|
||||||
|
{
|
||||||
|
var path = GetJacketPath(id);
|
||||||
|
if (path == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var texture = new Texture2D(1, 1);
|
||||||
|
texture.LoadImage(File.ReadAllBytes(path));
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Texture2D GetJacketTexture2D(int id)
|
||||||
|
{
|
||||||
|
return GetJacketTexture2D($"{id:000000}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
43
AquaMai/UX/LoadLocalBga.cs
Normal file
43
AquaMai/UX/LoadLocalBga.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using HarmonyLib;
|
||||||
|
using MAI2.Util;
|
||||||
|
using Manager;
|
||||||
|
using MelonLoader;
|
||||||
|
using Monitor.Game;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace AquaMai.UX;
|
||||||
|
|
||||||
|
public class LoadLocalBga
|
||||||
|
{
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(GameCtrl), "IsReady")]
|
||||||
|
public static void LoadLocalBgaAwake(GameObject ____movieMaskObj)
|
||||||
|
{
|
||||||
|
var components = ____movieMaskObj.GetComponentsInChildren<Component>(false);
|
||||||
|
var movie = components.FirstOrDefault(it => it.name == "Movie");
|
||||||
|
if (movie is null) return;
|
||||||
|
|
||||||
|
var music = Singleton<DataManager>.Instance.GetMusic(GameManager.SelectMusicID[0]);
|
||||||
|
var moviePath = string.Format(Singleton<OptionDataManager>.Instance.GetMovieDataPath($"{music.movieName.id:000000}") + ".dat");
|
||||||
|
if (!moviePath.Contains("dummy")) return;
|
||||||
|
|
||||||
|
var jacket = LoadJacketPng.GetJacketTexture2D(music.movieName.id);
|
||||||
|
if (jacket is null)
|
||||||
|
{
|
||||||
|
MelonLogger.Msg("No jacket found for music " + music);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If I create a new RawImage component, the jacket will be not be displayed
|
||||||
|
// I think it will be difficult to make it work with RawImage
|
||||||
|
// So I change the material that plays video to default sprite material
|
||||||
|
// The original player is actually a sprite renderer and plays video with a custom material
|
||||||
|
var sprite = movie.GetComponent<SpriteRenderer>();
|
||||||
|
sprite.sprite = Sprite.Create(jacket, new Rect(0, 0, jacket.width, jacket.height), new Vector2(0.5f, 0.5f));
|
||||||
|
sprite.material = new Material(Shader.Find("Sprites/Default"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// movie.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user