This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
beatsaber-scoretracker/Mod/Plugin.cs

56 lines
1.4 KiB
C#
Raw Normal View History

2024-08-06 22:57:47 +00:00
using IPA;
using IPALogger = IPA.Logging.Logger;
2024-08-07 04:19:39 +00:00
using SiraUtil.Zenject;
using System.Threading.Tasks;
using ScoreTracker.API;
2024-08-07 07:26:12 +00:00
using IPA.Config.Stores;
using IPA.Config;
using ScoreTracker.Configuration;
using ScoreTracker.Installers;
2024-08-06 22:57:47 +00:00
namespace ScoreTracker
{
2024-08-07 07:26:12 +00:00
[Plugin(RuntimeOptions.DynamicInit)]
[NoEnableDisable]
2024-08-06 22:57:47 +00:00
public class Plugin
{
internal static Plugin Instance { get; private set; }
2024-08-07 04:19:39 +00:00
internal static IPALogger Log { get; private set; }
2024-08-06 22:57:47 +00:00
[Init]
2024-08-07 07:26:12 +00:00
public Plugin(IPALogger logger, Zenjector zenjector, Config config)
2024-08-06 22:57:47 +00:00
{
Instance = this;
2024-08-07 04:19:39 +00:00
Log = logger; // Setup the logger
2024-08-07 07:26:12 +00:00
// Setup Zenject
zenjector.UseLogger(logger);
zenjector.UseMetadataBinder<Plugin>();
2024-08-07 04:19:39 +00:00
zenjector.Install<AppInstaller>(Location.App);
2024-08-07 07:26:12 +00:00
// Setup the config
PluginConfig.Instance = config.Generated<PluginConfig>();
2024-08-06 22:57:47 +00:00
}
[OnStart]
public void OnApplicationStart()
{
2024-08-07 04:19:39 +00:00
Log.Info("OnApplicationStart");
2024-08-07 07:26:12 +00:00
// Ensure the user is logged in
Task.Factory.StartNew(async () =>
2024-08-07 04:19:39 +00:00
{
2024-08-07 07:26:12 +00:00
var authHelper = new AuthHelper();
await authHelper.EnsureLoggedIn();
2024-08-07 04:19:39 +00:00
});
2024-08-06 22:57:47 +00:00
}
[OnExit]
public void OnApplicationQuit()
{
2024-08-07 04:19:39 +00:00
Log.Info("OnApplicationQuit");
2024-08-06 22:57:47 +00:00
}
}
}