1
0
forked from akanyan/mu3-mods

feat: implement ExclusiveAudio

This commit is contained in:
2025-01-12 15:31:21 +00:00
parent 31fa3ce028
commit 7900fbbce9
15 changed files with 141 additions and 27 deletions

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class DisableGP { };
}

View File

@ -7,9 +7,7 @@ class patch_UserManager: UserManager {
private OnReset _onResetGP;
public new void resetGP() {
if(_onResetGP != null) {
_onResetGP(_gp);
}
_onResetGP?.Invoke(_gp);
}
public new int GP {
@ -17,9 +15,7 @@ class patch_UserManager: UserManager {
return _gp;
}
private set {
if(_onUpdateGP != null) {
_onUpdateGP(_gp);
}
_onUpdateGP?.Invoke(_gp);
}
}
public new bool checkBattleGP(int needed) {

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class Blacklist { };
}

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class SelectBGM { };
}

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class SkipCutscenes { };
}

View File

@ -8,6 +8,8 @@ using UnityEngine;
namespace MU3.Sequence;
class patch_PlayMusic: PlayMusic {
public class CutscenePatch { };
private GameEngine _gameEngine;
private bool _quickStart = false;

View File

@ -0,0 +1,3 @@
namespace MU3.Mod;
class TestMenuEnable { }

View File

@ -42,10 +42,10 @@ class TestModePageModConfig: TestModePage {
}
}
private bool isEnabled(string v) => typeof(TestMenuEnable).GetNestedType(v) != null;
private List<Option> _options;
private Dictionary<string, string> _onOff;
private bool _isDisableGPActive;
private bool _isSkipCutscenesActive;
private MethodInfo _writeToFile;
protected new void Awake() {
@ -62,8 +62,7 @@ class TestModePageModConfig: TestModePage {
{ "OFF", "0" },
{ "ON", "1" }
};
_isDisableGPActive = typeof(UICredit).GetMethod("orig_initialize") != null;
_isSkipCutscenesActive = typeof(Notes.NotesManager).GetMethod("orig_reset") != null;
_writeToFile = typeof(IniFile).GetMethod("writeToFile", BindingFlags.Instance | BindingFlags.NonPublic);
writeOtherOptions();
@ -88,7 +87,7 @@ class TestModePageModConfig: TestModePage {
{ "RANDOM", "0" }
},
5,
typeof(Game.GameBGM).GetMethod("orig_playBGM") != null
isEnabled("SelectBGM")
));
_options.Add(new Option(
@ -96,7 +95,7 @@ class TestModePageModConfig: TestModePage {
"HideCredits",
_onOff,
1,
_isDisableGPActive
isEnabled("DisableGP")
));
_options.Add(new Option(
@ -104,7 +103,7 @@ class TestModePageModConfig: TestModePage {
"HideGP",
_onOff,
1,
_isDisableGPActive
isEnabled("DisableGP")
));
_options.Add(new Option(
@ -112,7 +111,7 @@ class TestModePageModConfig: TestModePage {
"HideVersion",
_onOff,
0,
_isDisableGPActive
isEnabled("DisableGP")
));
_options.Add(new Option(
@ -120,7 +119,7 @@ class TestModePageModConfig: TestModePage {
"SkipCamera",
_onOff,
1,
typeof(Data.DataStudioManager).GetMethod("orig_IsLoaded") != null,
isEnabled("LoadBoost"),
"Sequence"
));
@ -129,7 +128,7 @@ class TestModePageModConfig: TestModePage {
"QuickStart",
_onOff,
0,
_isSkipCutscenesActive,
isEnabled("SkipCutscenes"),
"Sequence"
));
@ -138,12 +137,42 @@ class TestModePageModConfig: TestModePage {
"AutoContinue",
_onOff,
0,
_isSkipCutscenesActive,
isEnabled("SkipCutscenes"),
"Sequence"
));
var d = new Dictionary<string, string> {
{ "SHARED", "0" },
{ "EXCLUSIVE 6CH", "1" }
};
if(isEnabled("ExclusiveAudio")) {
d.Add("EXCLUSIVE 2CH", "2");
}
_options.Add(new Option(
"FRAMERATE",
"AUDIO MODE*",
"WasapiExclusive",
d,
0,
true,
"Sound"
));
_options.Add(new Option(
"SAMPLE RATE*",
"SampleRate",
new Dictionary<string, string> {
{ "44100Hz", "44100" },
{ "48000Hz", "48000" },
{ "96000Hz", "96000" },
{ "192000Hz", "192000" }
},
1,
isEnabled("ExclusiveAudio"),
"Sound"
));
_options.Add(new Option(
"FRAME RATE*",
"Framerate",
new Dictionary<string, string> {
{ "60", "60" },
@ -155,7 +184,7 @@ class TestModePageModConfig: TestModePage {
{ "VSYNC", "V" }
},
0,
typeof(Notes.NotesManager).GetMethod("orig_initialize") != null,
isEnabled("FrameRate"),
"Video"
));
@ -165,7 +194,15 @@ class TestModePageModConfig: TestModePage {
}).ToList();
itemDefs.Add(new() {
lineNumber = 8,
lineNumber = 11,
label = "(*) REQUIRES A RESTART",
isSelectable = false,
isFinishOnSelect = false,
isDefaultSelection = false
});
itemDefs.Add(new() {
lineNumber = 13,
label = "終了",
isSelectable = true,
isFinishOnSelect = true,
@ -184,11 +221,13 @@ class TestModePageModConfig: TestModePage {
}
protected override void onInitializeItem(Item item, int index) {
item.setState(item.isSelectable ? Item.State.Selectable : Item.State.UnselectableTemp);
if(!item.define.hasValueField) {
return;
}
var op = _options[index];
var op = _options[index];
if(op.fieldName == "Framerate") {
using IniFile iniFile = new("mu3.ini");
if(iniFile.getValue(op.sectionName, "VSync", false)) {
@ -199,7 +238,6 @@ class TestModePageModConfig: TestModePage {
}
item.setValueString(op.values[op.selection].Key);
item.setState(op.itemDefine.isSelectable ? Item.State.Selectable : Item.State.UnselectableTemp);
}
protected override void onSelectItem(Item item, int index) {
@ -240,15 +278,14 @@ class TestModePageModConfig: TestModePage {
using IniFile iniFile = new("mu3.ini");
using StreamWriter sw = new("mu3.ini");
rewriteOption(iniFile, "Sound", "WasapiExclusive", "0");
rewriteOption(iniFile, "AM", "IgnoreError", "1");
rewriteOption(iniFile, "Device", "CameraType", "1");
rewriteOption(iniFile, "Extra", "CacheDir", ".");
if(_isDisableGPActive) {
if(isEnabled("DisableGP")) {
rewriteOption(iniFile, "Extra", "GP", "999");
}
if(typeof(User.UserManager).GetMethod("orig_getUserFumen") != null) {
if(isEnabled("Blacklist")) {
rewriteOption(iniFile, "Extra", "BlacklistMin", "10000");
rewriteOption(iniFile, "Extra", "BlacklistMin", "19999");
}

View File

@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>Assembly-CSharp.ExclusiveAudio.mm</AssemblyName>
<Description>2ch exclusive audio</Description>
<OutCategory>fixes</OutCategory>
</PropertyGroup>
<Import Project="..\..\Mu3Mods.csproj" />
</Project>

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class ExclusiveAudio { };
}

View File

@ -0,0 +1,27 @@
using System;
namespace MU3.Sound;
class patch_SoundManager: SoundManager {
public class SoundPatch { };
private void setWasapiExclusive() {
using IniFile iniFile = new IniFile("mu3.ini");
var sixCh = iniFile.getValue("Sound", "WasapiExclusive", 1) == 1;
var sampleRate = (uint)iniFile.getValue("Sound", "SampleRate", 48000);
CriAtomUserExtension.WaveFormatExtensible format = default;
format.Format = default;
format.Format.wFormatTag = 65534;
format.Format.nChannels = (ushort)(sixCh ? 6 : 2);
format.Format.nSamplesPerSec = sampleRate;
format.Format.wBitsPerSample = 32;
format.Format.nBlockAlign = (ushort)(format.Format.wBitsPerSample / 8 * format.Format.nChannels);
format.Format.nAvgBytesPerSec = format.Format.nSamplesPerSec * format.Format.nBlockAlign;
format.Format.cbSize = 22;
format.Samples.wValidBitsPerSample = 24;
format.dwChannelMask = sixCh ? 0b111111u : 0b11u;
format.SubFormat = new Guid("00000001-0000-0010-8000-00aa00389b71");
CriAtomUserExtension.SetAudioClientShareMode(CriAtomUserExtension.AudioClientShareMode.Exclusive);
CriAtomUserExtension.SetAudioClientFormat(ref format);
}
}

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class FrameRate { };
}

View File

@ -0,0 +1,5 @@
namespace MU3.Mod;
class TestMenuEnable {
public class LoadBoost { };
}

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Company>7EVENDAYS⇔HOLIDAYS</Company>
<Version>3.0.1.0</Version>
<Version>3.2.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<Platforms>x64</Platforms>

View File

@ -50,6 +50,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestMenuScaling", "Fixes\Te
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestMenuConfig", "Extras\TestMenuConfig\TestMenuConfig.csproj", "{7043743F-24B5-4A39-838E-964091AC7FF1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExclusiveAudio", "Fixes\ExclusiveAudio\ExclusiveAudio.csproj", "{0043743F-24B5-4A39-838E-964091AC7FF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@ -152,6 +154,10 @@ Global
{7043743F-24B5-4A39-838E-964091AC7FF1}.Debug|x64.Build.0 = Debug|x64
{7043743F-24B5-4A39-838E-964091AC7FF1}.Release|x64.ActiveCfg = Release|x64
{7043743F-24B5-4A39-838E-964091AC7FF1}.Release|x64.Build.0 = Release|x64
{0043743F-24B5-4A39-838E-964091AC7FF1}.Debug|x64.ActiveCfg = Debug|x64
{0043743F-24B5-4A39-838E-964091AC7FF1}.Debug|x64.Build.0 = Debug|x64
{0043743F-24B5-4A39-838E-964091AC7FF1}.Release|x64.ActiveCfg = Release|x64
{0043743F-24B5-4A39-838E-964091AC7FF1}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE