Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintegrate Melody Mania #433

Merged
merged 12 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
26 changes: 25 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
**/InitTestScene*

# Spleeter models
pretrained_models/

# Generated classes
# TODO: Cannot generate code in Unity from C#. Thus, all generated files need to be added to Git.
# See https://forum.unity.com/threads/generate-code-before-build-in-project-with-compiler-errors.1412511/#post-8878443.
#R_PlaySharedUssClasses.cs
#R_PlaySharedUxmlNames.cs
#RUssClasses.cs
#RUxmlNames.cs

# Source maps
*.*.map
*.*.map.meta

# Generated classes
# TODO: Cannot generate code in Unity from C#. Thus, all generated files need to be added to Git.
Expand All @@ -25,6 +41,9 @@ Assets/AssetStoreTools*
# Visual Studio cache directory
.vs/

# Visual Studio Code config
.vscode/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
Expand All @@ -51,6 +70,7 @@ sysinfo.txt
# Builds
*.apk
*.unitypackage
.utmp/

# OS generated
.DS_Store*
Expand All @@ -63,4 +83,8 @@ ehthumbs.db
[Dd]esktop.ini

# Custom files
ToDo.txt.lnk
ToDo.txt.lnk
UltraStar Play - Data.lnk
MelodyMania-Data.lnk
Unity-Editor-Log.lnk
Steam Workshop Content.lnk
5 changes: 5 additions & 0 deletions UltraStar Play Companion/Assets/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VERSION.txt

Plugins/UniRx/
Plugins/UniRx.meta

Expand All @@ -17,3 +19,6 @@ Plugins/Serilog/Serilog.Sinks.File.meta

Plugins/LeanTween/
Plugins/LeanTween.meta

Plugins/LiteNetLib/
Plugins/LiteNetLib.meta
244 changes: 145 additions & 99 deletions UltraStar Play Companion/Assets/Common/ApplicationManager.cs
Original file line number Diff line number Diff line change
@@ -1,99 +1,145 @@
using System;
using System.Collections.Generic;
using UniInject;
using UnityEngine;

public class ApplicationManager : AbstractSingletonBehaviour, INeedInjection
{
public static ApplicationManager Instance
{
get
{
return GameObjectUtils.FindComponentWithTag<ApplicationManager>("ApplicationManager");
}
}

public List<string> simulatedCommandLineArguments = new List<string>();

[Range(-1, 60)]
public int targetFrameRate = 30;


[Inject]
private Settings settings;

protected override object GetInstance()
{
return Instance;
}

protected override void StartSingleton()
{
targetFrameRate = settings.TargetFps;
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = targetFrameRate;
}

protected override void OnEnableSingleton()
{
Application.logMessageReceivedThreaded += Log.HandleUnityLog;
}

protected override void OnDisableSingleton()
{
Application.logMessageReceivedThreaded -= Log.HandleUnityLog;
}

void Update()
{
if (Application.targetFrameRate != targetFrameRate)
{
Application.targetFrameRate = targetFrameRate;
}
}

public bool HasCommandLineArgument(string argumentName)
{
string[] args = GetCommandLineArguments();
for (int i = 0; i < args.Length; i++)
{
if (string.Equals(args[i], argumentName, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
}
return false;
}

public string GetCommandLineArgument(string argumentName)
{
string[] args = GetCommandLineArguments();
for (int i = 0; i < (args.Length - 1); i++)
{
if (string.Equals(args[i], argumentName, StringComparison.InvariantCultureIgnoreCase))
{
return args[i + 1];
}
}
return "";
}

public string[] GetCommandLineArguments()
{
if (Application.isEditor)
{
return simulatedCommandLineArguments.ToArray();
}
else
{
if (PlatformUtils.IsStandalone)
{
return System.Environment.GetCommandLineArgs();
}
else
{
return Array.Empty<string>();
}
}
}
}
using System;
using System.Collections.Generic;
using UniInject;
using UniRx;
using UnityEngine;
using UnityEngine.InputSystem.EnhancedTouch;
using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;

public class ApplicationManager : AbstractSingletonBehaviour, INeedInjection
{
public static ApplicationManager Instance
{
get
{
return GameObjectUtils.FindComponentWithTag<ApplicationManager>("ApplicationManager");
}
}

public List<string> simulatedCommandLineArguments = new List<string>();

[Range(-1, 60)]
public int targetFrameRate = 30;

[Inject]
private Settings settings;

private readonly Subject<Finger> fingerUpEventStream = new();
public IObservable<Finger> FingerUpEventStream => fingerUpEventStream;

private readonly Subject<Finger> fingerDownEventStream = new();
public IObservable<Finger> FingerDownEventStream => fingerDownEventStream;

protected override object GetInstance()
{
return Instance;
}

protected override void AwakeSingleton()
{
EnhancedTouchSupport.Enable();
}

protected override void StartSingleton()
{
UpdateTargetFps();
settings.ObserveEveryValueChanged(it => it.TargetFps)
.Subscribe(_ => UpdateTargetFps())
.AddTo(gameObject);
}

private void UpdateTargetFps()
{
if (!Application.isPlaying)
{
return;
}

targetFrameRate = settings.TargetFps;
if (targetFrameRate > 0)
{
Application.targetFrameRate = targetFrameRate;
QualitySettings.vSyncCount = 0;
}
else
{
Application.targetFrameRate = -1;
QualitySettings.vSyncCount = 1;
}
}

protected override void OnEnableSingleton()
{
Touch.onFingerDown += OnFingerDown;
Touch.onFingerUp += OnFingerUp;
}

protected override void OnDisableSingleton()
{
Touch.onFingerDown -= OnFingerDown;
Touch.onFingerUp -= OnFingerUp;
}

void Update()
{
if (Application.targetFrameRate != targetFrameRate)
{
Application.targetFrameRate = targetFrameRate;
}
}

public bool HasCommandLineArgument(string argumentName)
{
string[] args = GetCommandLineArguments();
for (int i = 0; i < args.Length; i++)
{
if (string.Equals(args[i], argumentName, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
}
return false;
}

public string GetCommandLineArgument(string argumentName)
{
string[] args = GetCommandLineArguments();
for (int i = 0; i < (args.Length - 1); i++)
{
if (string.Equals(args[i], argumentName, StringComparison.InvariantCultureIgnoreCase))
{
return args[i + 1];
}
}
return "";
}

public string[] GetCommandLineArguments()
{
if (Application.isEditor)
{
return simulatedCommandLineArguments.ToArray();
}
else
{
if (PlatformUtils.IsStandalone)
{
return Environment.GetCommandLineArgs();
}
else
{
return Array.Empty<string>();
}
}
}

private void OnFingerUp(Finger obj)
{
fingerUpEventStream.OnNext(obj);
}

private void OnFingerDown(Finger obj)
{
fingerDownEventStream.OnNext(obj);
}
}
3 changes: 2 additions & 1 deletion UltraStar Play Companion/Assets/Common/Common.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"com.achimmihca.primeinputactions",
"Unity.InputSystem",
"playshared",
"playsharedui"
"playsharedui",
"LiteNetLib"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Loading
Loading