AttractVideoPlayer #2

Merged
akanyan merged 3 commits from jujuforce/mu3-mods:AttractVideoPlayer into main 2024-07-22 14:55:54 +00:00
5 changed files with 167 additions and 0 deletions
Showing only changes of commit 1023dee2b7 - Show all commits

View File

@ -0,0 +1,13 @@
<Project ToolsVersion="Current">
<PropertyGroup>
<AssemblyName>Assembly-CSharp.AttractVideoPlayer.mm</AssemblyName>
<Description>Control attract video</Description>
jujuforce marked this conversation as resolved Outdated

description unchanged

description unchanged
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<ProjectGuid>{6889330F-2E7E-4778-ADFF-70AF036F1BD5}</ProjectGuid>
</PropertyGroup>
<Import Project="..\Mu3Mods.csproj" />
</Project>

View File

@ -0,0 +1,54 @@
using MU3.Operation;
using MU3.SceneObject;
using MU3.Sequence;
using MU3.Util;
using System.Collections.ObjectModel;
using UnityEngine;
namespace MU3.Operation;
class patch_OperationManager: OperationManager
{
private static readonly string CurrentSongIndexFilePath = "BepInEx/monomod/AttractVideoPlayer.currentSongIndex.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);
}
if (currentSongIndex < 0)
{
currentSongIndex = _movieDataList.Count - 1;
saveCurrentSongIndex(currentSongIndex);
}
if (currentSongIndex >= _movieDataList.Count)
{
currentSongIndex = 0;
saveCurrentSongIndex(currentSongIndex);
}
Debug.Log("currentSongIndex: " + currentSongIndex);
return _movieDataList[currentSongIndex];
}
return null;
}
}
private void saveCurrentSongIndex(int currentSongIndex)
{
System.IO.File.WriteAllText(CurrentSongIndexFilePath, currentSongIndex.ToString());
}
}

View File

@ -0,0 +1,28 @@
using Mono.Cecil;
using MU3.AM;
using MU3.Operation;
using MU3.SceneObject;
using MU3.Sequence;
using MU3.Util;
using UnityEngine;
namespace MU3.Sequence;
class patch_Advertise : Advertise
{
private bool checkButtonOrAime()
akanyan marked this conversation as resolved Outdated

doesn't this effectively disable guest login?

doesn't this effectively disable guest login?

oh crap you are right... I would be tempted to say we don't care about guest login but I don't like to remove a feature.
Let me cook something...

oh crap you are right... I would be tempted to say we don't care about guest login but I don't like to remove a feature. Let me cook something...
{
if (SingletonStateMachine<AMManager, AMManager.EState>.instance.aimeReader.advCheck())
{
Singleton<OperationManager>.instance.loginType = OperationManager.LoginType.Aime;
return true;
}
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;
return true;
}
return false;
}
}

View File

@ -0,0 +1,66 @@
using Mono.Cecil;
using MU3.Operation;
using MU3.SceneObject;
using MU3.Sequence;
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;
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);
}
}
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) { }
movieController?.Stop();
Utility.destroyGameObject(ref movieController);
Utility.destroyGameObject(ref objMovie);
initMovie();
}
}

View File

@ -39,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnlockMemoryChapters", "Unl
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 +119,10 @@ Global
{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