56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using IPA;
|
|
using IPALogger = IPA.Logging.Logger;
|
|
using SiraUtil.Zenject;
|
|
using System.Threading.Tasks;
|
|
using ScoreTracker.API;
|
|
using IPA.Config.Stores;
|
|
using IPA.Config;
|
|
using ScoreTracker.Configuration;
|
|
using ScoreTracker.Installers;
|
|
|
|
namespace ScoreTracker
|
|
{
|
|
[Plugin(RuntimeOptions.DynamicInit)]
|
|
[NoEnableDisable]
|
|
public class Plugin
|
|
{
|
|
internal static Plugin Instance { get; private set; }
|
|
internal static IPALogger Log { get; private set; }
|
|
|
|
[Init]
|
|
public Plugin(IPALogger logger, Zenjector zenjector, Config config)
|
|
{
|
|
Instance = this;
|
|
Log = logger; // Setup the logger
|
|
|
|
// Setup Zenject
|
|
zenjector.UseLogger(logger);
|
|
zenjector.UseMetadataBinder<Plugin>();
|
|
zenjector.Install<AppInstaller>(Location.App);
|
|
|
|
// Setup the config
|
|
PluginConfig.Instance = config.Generated<PluginConfig>();
|
|
}
|
|
|
|
[OnStart]
|
|
public void OnApplicationStart()
|
|
{
|
|
Log.Info("OnApplicationStart");
|
|
|
|
// Ensure the user is logged in
|
|
Task.Factory.StartNew(async () =>
|
|
{
|
|
var authHelper = new AuthHelper();
|
|
await authHelper.EnsureLoggedIn();
|
|
});
|
|
}
|
|
|
|
[OnExit]
|
|
public void OnApplicationQuit()
|
|
{
|
|
Log.Info("OnApplicationQuit");
|
|
}
|
|
|
|
}
|
|
}
|