Merge branch 'AttractVideoPlayer' of https://gitea.tendokyu.moe/jujuforce/mu3-mods into AttractVideoPlayer

# Conflicts:
#	AttractVideoPlayer/MU3.OperationManager/patch_OperationManager.cs
#	AttractVideoPlayer/MU3.Sequence/patch_Advertise.cs
#	AttractVideoPlayer/MU3/patch_AdvManager.cs
This commit is contained in:
Jujuforce 2024-07-23 22:21:39 +02:00
commit a3a7475592
12 changed files with 256 additions and 150 deletions

View File

@ -1,54 +1,45 @@
using MU3.Operation;
using MU3.SceneObject;
using MU3.Sequence;
using MU3.Util;
using System;
using System.Collections.ObjectModel;
using UnityEngine;
using System.IO;
namespace MU3.Operation;
class patch_OperationManager: OperationManager
{
private static readonly string CurrentSongIndexFilePath = "BepInEx/monomod/AttractVideoPlayer.currentSongIndex.txt";
class patch_OperationManager: OperationManager {
private static readonly string _fname = "data_advert_cache.txt";
private ReadOnlyCollection<MovieData> _movieDataList;
public new MovieData movieData
{
get
{
if (_movieDataList.Count > 0)
{
int currentSongIndex = 0;
try
{
currentSongIndex = int.Parse(System.IO.File.ReadAllText(CurrentSongIndexFilePath));
}
catch (System.Exception)
{
saveCurrentSongIndex(0);
}
private int _movieIndex;
if (currentSongIndex < 0)
{
currentSongIndex = _movieDataList.Count - 1;
saveCurrentSongIndex(currentSongIndex);
}
if (currentSongIndex >= _movieDataList.Count)
{
currentSongIndex = 0;
saveCurrentSongIndex(currentSongIndex);
}
Debug.Log("currentSongIndex: " + currentSongIndex);
return _movieDataList[currentSongIndex];
~patch_OperationManager() {
try {
File.WriteAllText(_fname, _movieIndex.ToString());
} catch(Exception) {}
}
public int MovieIndex {
set {
_movieIndex = (value + _movieDataList.Count) % _movieDataList.Count;
}
get {
return _movieIndex;
}
}
public new MovieData movieData {
get {
if(_movieDataList.Count > 0) {
return _movieDataList[_movieIndex];
}
return null;
}
}
private void saveCurrentSongIndex(int currentSongIndex)
{
System.IO.File.WriteAllText(CurrentSongIndexFilePath, currentSongIndex.ToString());
public extern void orig_initialize();
public new void initialize() {
orig_initialize();
try {
_movieIndex = Math.Max(0, int.Parse(File.ReadAllText(_fname)));
} catch(Exception) {
_movieIndex = 0;
}
}
}

View File

@ -1,26 +1,18 @@
using Mono.Cecil;
using MU3.AM;
using MU3.Operation;
using MU3.SceneObject;
using MU3.Sequence;
using MU3.Util;
using UnityEngine;
using MU3.Util;
namespace MU3.Sequence;
class patch_Advertise : Advertise
{
private bool checkButtonOrAime()
{
if (SingletonStateMachine<AMManager, AMManager.EState>.instance.aimeReader.advCheck())
{
Singleton<OperationManager>.instance.loginType = OperationManager.LoginType.Aime;
return true;
}
class patch_Advertise: Advertise {
// Exclude Back/Left/Right
private bool anyKeyDown() {
UIInput instance = Singleton<UIInput>.instance;
if (instance.getTriggerOn(UIInput.Key.Decision) || instance.getTriggerOn(UIInput.Key.OptionBackward) || instance.getTriggerOn(UIInput.Key.OptionForward) || instance.getTriggerOn(UIInput.Key.SkipRight) || instance.getTriggerOn(UIInput.Key.MenuLeft) || instance.getTriggerOn(UIInput.Key.MenuRight))
{
Singleton<OperationManager>.instance.loginType = OperationManager.LoginType.Button;
if(instance.getTriggerOn(UIInput.Key.Decision)
|| instance.getTriggerOn(UIInput.Key.OptionBackward)
|| instance.getTriggerOn(UIInput.Key.OptionForward)
|| instance.getTriggerOn(UIInput.Key.SkipLeft)
|| instance.getTriggerOn(UIInput.Key.SkipRight)
|| instance.getTriggerOn(UIInput.Key.MenuLeft)
|| instance.getTriggerOn(UIInput.Key.MenuRight)) {
return true;
}
return false;

View File

@ -1,63 +1,32 @@
using Mono.Cecil;
using MU3.Operation;
using MU3.SceneObject;
using MU3.Sequence;
using MU3.Operation;
using MU3.Util;
using UnityEngine;
namespace MU3;
class patch_AdvManager : AdvManager
{
private static readonly string CurrentSongIndexFilePath = "BepInEx/monomod/AttractVideoPlayer.currentSongIndex.txt";
private static readonly float DelayBetweenButtonPress = 0.5f;
private float lastButtonPressedTime = 0f;
class patch_AdvManager: AdvManager {
private GameObject objMovie;
private CriManaMovieMaterial movieController;
private extern bool orig_initMovie();
public new bool initMovie()
{
return orig_initMovie();
}
private extern bool orig_exec();
public new bool exec()
{
if (Time.time - lastButtonPressedTime > DelayBetweenButtonPress)
{
if (Singleton<UIInput>.instance.getStateOn(UIInput.Key.Service))
{
lastButtonPressedTime = Time.time;
movieController?.player.Pause(!movieController.player.IsPaused());
}
else if (Singleton<UIInput>.instance.getStateOn(UIInput.Key.L2))
{
lastButtonPressedTime = Time.time;
addOffsetToCurrentSongIndexAndPlayMovie(-1);
}
else if (Singleton<UIInput>.instance.getStateOn(UIInput.Key.L3))
{
lastButtonPressedTime = Time.time;
addOffsetToCurrentSongIndexAndPlayMovie(1);
public new bool exec() {
if(movieController?.player?.status == CriMana.Player.Status.Playing) {
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.Service)) {
movieController.player.Pause(!movieController.player.IsPaused());
} else if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.L2)) {
addMovieOffset(-1);
} else if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.L3)) {
addMovieOffset(1);
}
}
return orig_exec();
}
public void addOffsetToCurrentSongIndexAndPlayMovie(int offset)
{
try
{
int currentSongIndex = int.Parse(System.IO.File.ReadAllText(CurrentSongIndexFilePath)) + offset;
System.IO.File.WriteAllText(CurrentSongIndexFilePath, currentSongIndex.ToString());
}
catch (System.Exception) { }
public void addMovieOffset(int offset) {
var om = (patch_OperationManager)Singleton<OperationManager>.instance;
om.MovieIndex += offset;
movieController?.Stop();
movieController.Stop();
Utility.destroyGameObject(ref movieController);
Utility.destroyGameObject(ref objMovie);

View File

@ -1,13 +1,12 @@
namespace MU3.User;
class patch_UserManager: UserManager {
public new const int DefaultGP = 666;
public new const int DefaultGP = 999;
private int _gp;
private OnUpdate _onUpdateGP;
private OnReset _onResetGP;
public new void resetGP() {
_gp = 999;
if(_onResetGP != null) {
_onResetGP(_gp);
}
@ -18,10 +17,20 @@ class patch_UserManager: UserManager {
return _gp;
}
private set {
_gp = 999;
if(_onUpdateGP != null) {
_onUpdateGP(_gp);
}
}
}
public new bool checkBattleGP(int needed) {
return true;
}
public extern void orig_initialize();
public new void initialize() {
orig_initialize();
using IniFile iniFile = new("mu3.ini");
_gp = iniFile.getIntValue("Extra", "GP", 999);
}
}

View File

@ -0,0 +1,55 @@
using MU3.CustomUI;
using UnityEngine;
namespace MU3;
class patch_UICredit: UICredit {
private Animator gpAnimator_;
private GameObject creditRoot_;
private MU3UICounter credit_;
private GameObject freePlayRoot_;
private GameObject gpRoot_;
private MU3UICounter gp_;
private MU3UICounter gpPlus_;
private MU3UICounter gpMinus_;
private MU3UIImageChanger netIcon_;
private MU3UIImageChanger groupIcon_;
private void onUpdateGP(int value) { /* nop */ }
public extern void orig_initialize();
public new void initialize() {
orig_initialize();
using IniFile iniFile = new("mu3.ini");
if(iniFile.getValue("Extra", "HideGP", true)) {
DestroyImmediate(gpAnimator_);
gpRoot_.transform.localScale = new Vector3(0, 0, 0);
gp_.transform.localScale = new Vector3(0, 0, 0);
gpPlus_.transform.localScale = new Vector3(0, 0, 0);
gpMinus_.transform.localScale = new Vector3(0, 0, 0);
}
if(iniFile.getValue("Extra", "HideCredits", true)) {
creditRoot_.transform.localScale = new Vector3(0, 0, 0);
credit_.transform.localScale = new Vector3(0, 0, 0);
freePlayRoot_.transform.localScale = new Vector3(0, 0, 0);
netIcon_.transform.localPosition = new Vector3(
-514,
netIcon_.transform.localPosition.y,
netIcon_.transform.localPosition.z
);
netIcon_.image.rectTransform.pivot = new Vector2(0f, 0.5f);
groupIcon_.transform.localPosition = new Vector3(
-476,
groupIcon_.transform.localPosition.y,
groupIcon_.transform.localPosition.z
);
groupIcon_.image.rectTransform.pivot = new Vector2(0f, 0.5f);
}
}
}

View File

@ -1,42 +0,0 @@
using MU3.CustomUI;
using UnityEngine;
namespace MU3;
class patch_UICredit: UICredit {
private Animator gpAnimator_;
private GameObject creditRoot_;
private MU3UICounter credit_;
private GameObject freePlayRoot_;
private GameObject gpRoot_;
private MU3UICounter gp_;
private MU3UICounter gpPlus_;
private MU3UICounter gpMinus_;
private MU3UIImageChanger netIcon_;
private void onUpdateGP(int value) { /* nop */ }
public extern void orig_initialize();
public new void initialize() {
orig_initialize();
DestroyImmediate(gpAnimator_);
creditRoot_.transform.localScale = new Vector3(0, 0, 0);
credit_.transform.localScale = new Vector3(0, 0, 0);
freePlayRoot_.transform.localScale = new Vector3(0, 0, 0);
gpRoot_.transform.localScale = new Vector3(0, 0, 0);
gp_.transform.localScale = new Vector3(0, 0, 0);
gpPlus_.transform.localScale = new Vector3(0, 0, 0);
gpMinus_.transform.localScale = new Vector3(0, 0, 0);
var tf = (RectTransform)netIcon_.transform;
tf.localPosition = new Vector3(35, netIcon_.transform.localPosition.y, netIcon_.transform.localPosition.z);
for(int i = 0; i < 3; ++i) {
tf.anchorMin = new Vector2(0f, 0.5f);
tf.anchorMax = new Vector2(1f, 0.5f);
tf = (RectTransform)tf.parent;
}
netIcon_.image.rectTransform.pivot = new Vector2(0f, 0.5f);
}
}

View File

@ -39,6 +39,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnlockGameEvents", "UnlockG
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnlockMemoryChapters", "UnlockMemoryChapters\UnlockMemoryChapters.csproj", "{3A217A12-6082-491B-89F6-C1D13AD69A19}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatinumTiming", "PlatinumTiming\PlatinumTiming.csproj", "{099AD6AF-181A-4745-88C4-1D0466BECCB1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AttractVideoPlayer", "AttractVideoPlayer\AttractVideoPlayer.csproj", "{6889330F-2E7E-4778-ADFF-70AF036F1BD5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@ -117,6 +121,14 @@ Global
{3A217A12-6082-491B-89F6-C1D13AD69A19}.Debug|x64.Build.0 = Debug|x64
{3A217A12-6082-491B-89F6-C1D13AD69A19}.Release|x64.ActiveCfg = Release|x64
{3A217A12-6082-491B-89F6-C1D13AD69A19}.Release|x64.Build.0 = Release|x64
{099AD6AF-181A-4745-88C4-1D0466BECCB1}.Debug|x64.ActiveCfg = Debug|x64
{099AD6AF-181A-4745-88C4-1D0466BECCB1}.Debug|x64.Build.0 = Debug|x64
{099AD6AF-181A-4745-88C4-1D0466BECCB1}.Release|x64.ActiveCfg = Release|x64
{099AD6AF-181A-4745-88C4-1D0466BECCB1}.Release|x64.Build.0 = Release|x64
{6889330F-2E7E-4778-ADFF-70AF036F1BD5}.Debug|x64.ActiveCfg = Debug|x64
{6889330F-2E7E-4778-ADFF-70AF036F1BD5}.Debug|x64.Build.0 = Debug|x64
{6889330F-2E7E-4778-ADFF-70AF036F1BD5}.Release|x64.ActiveCfg = Release|x64
{6889330F-2E7E-4778-ADFF-70AF036F1BD5}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,26 @@
using MU3.Notes;
namespace MU3.Battle;
class patch_Counters: Counters {
public int PlatinumFastCount { get; private set; } = 0;
public int PlatinumLateCount { get; private set; } = 0;
public extern void orig_addPlatinumScore(Judge judge, Timing timing);
public new void addPlatinumScore(Judge judge, Timing timing) {
orig_addPlatinumScore(judge, timing);
if(judge == Judge.Perfect) {
if(timing == Timing.Fast) {
PlatinumFastCount += 1;
} else if(timing == Timing.Late) {
PlatinumLateCount += 1;
}
}
}
public extern void orig_reset();
public new void reset() {
orig_reset();
PlatinumFastCount = 0;
PlatinumLateCount = 0;
}
}

View File

@ -0,0 +1,13 @@
using MU3.Game;
namespace MU3.Battle;
class patch_GameEngine: GameEngine {
private patch_Counters _counters;
public extern void orig_calcCurrentBattleResult(SessionResult sessionResult);
public void calcCurrentBattleResult(patch_SessionResult sessionResult) {
orig_calcCurrentBattleResult(sessionResult);
sessionResult.PlatinumFastCount = _counters.PlatinumFastCount;
sessionResult.PlatinumLateCount = _counters.PlatinumLateCount;
}
}

View File

@ -0,0 +1,5 @@
namespace MU3.Game;
class patch_SessionResult: SessionResult {
public int PlatinumFastCount { get; set; }
public int PlatinumLateCount { get; set; }
}

View File

@ -0,0 +1,63 @@
using MU3.CustomUI;
using MU3.Game;
using MU3.Sequence;
using MU3.Util;
using System.Collections;
using UnityEngine;
namespace MU3;
class patch_UIResultTechScore: UIResultTechScore {
private MU3UICounter counterFast_;
private MU3UICounter counterLate_;
private Animator animator_;
private static readonly int State_TechnicalScore_Loop;
private void cloneCounter(MU3UICounter counter, Color color, int value) {
var otherValue = counter.CounterAsInt;
var offset = 12;
while(otherValue > 9) {
otherValue /= 10;
offset += 8;
}
var cpy = Instantiate(counter);
cpy.color = color;
cpy.gameObject.transform.SetParent(counter.transform.parent, false);
var pos = counter.gameObject.transform.localPosition;
cpy.gameObject.transform.localPosition = new Vector3(pos.x - offset, pos.y, pos.z);
cpy.gameObject.SetActive(true);
cpy.CounterAsInt = value;
}
private void drawCounters() {
float posXf = counterFast_.gameObject.transform.localPosition.x + 5.0f;
float posXl = counterLate_.gameObject.transform.localPosition.x + 5.0f;
float posY = counterLate_.gameObject.transform.localPosition.y;
counterFast_.gameObject.transform.localPosition = new Vector3(posXf, posY, 0.0f);
counterLate_.gameObject.transform.localPosition = new Vector3(posXl, posY, 0.0f);
var sessionResult = (patch_SessionResult)Singleton<PlayInfo>.instance.sessionResult;
cloneCounter(
counterFast_,
new Color(0.630f, 0.766f, 0.829f, 1.000f),
sessionResult.PlatinumFastCount
);
cloneCounter(
counterLate_,
new Color(0.809f, 0.396f, 0.365f, 1.000f),
sessionResult.PlatinumLateCount
);
}
private extern IEnumerator orig_showPlatinumScore(PlayInfo playInfo);
private IEnumerator showPlatinumScore(PlayInfo playInfo) {
StartCoroutine(orig_showPlatinumScore(playInfo));
while(!AnimatorState.stateEquals(animator_, State_TechnicalScore_Loop)) {
yield return null;
}
drawCounters();
}
}

View File

@ -0,0 +1,13 @@
<Project>
<PropertyGroup>
<AssemblyName>Assembly-CSharp.PlatinumTiming.mm</AssemblyName>
<Description>Platinum early/late</Description>
</PropertyGroup>
<Import Project="..\Mu3Mods.csproj" />
<ItemGroup>
<None Remove="MU3\patch_UIResultTechScore.experiment" />
</ItemGroup>
<ItemGroup>
<Compile Include="MU3\patch_UIResultTechScore.experiment" />
</ItemGroup>
</Project>