using UnityEngine;
using GadgetCore.API;
using GadgetCore.API.ConfigMenu;
using UnityEngine.SceneManagement;

namespace StorageExpansion
{
  [Gadget("StorageExpansion", LoadBefore: new string[] { "QuickStack" })]
  public class StorageExpansion : Gadget<StorageExpansion>
  {
    public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
    public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.

    protected override void LoadConfig()
    {
      Config.Load();
      string fileVersion = Config.ReadString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
      if (fileVersion != CONFIG_VERSION)
      {
        Config.Reset();
        Config.WriteString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
      }

      Core.settingSizeEnum = Config.ReadEnum("StorageSize", StorageSizeEnum.Large, requiresRestart: true, comments: new string[] { "How large should your storage be?", "!! Restart required !!" });

      Config.Save();
    }

    public override string GetModDescription()
    {
      return "Increases the available storage space.";
    }

    protected override void Initialize()
    {
      Logger.Log("Storage Expansion v" + Info.Mod.Version);
      Core.logger = Logger;

      SceneManager.sceneLoaded += OnSceneLoaded;
    }

    internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
      if (scene.buildIndex == 1)
      {
      }
    }
  }
}
