using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class BuildModeSelector
{
	const string ALLOW_FAST_EXPORT_MODE_KEY = "fast export";

	const string CHANGE_MESSAGE = "When using Test Map or Content mod (Ctrl + T) the RFTools can optionally use Fast Export mode, where an uncompressed package containing your map or content mod is exported. This can significantly speed up export and load times but also uses more disk space on your computer.\n\nOnly compressed packages can be uploaded to the Steam Workshop, so while fast export is enabled, you must export a compressed package of your mod (Ctrl+E) before uploading to the workshop. If your compressed package is older than your uncompressed testing version the rfc or rfl file will be marked as Out Of Date in the workshop upload page.";

	public static bool allowFastExportMode
	{
		get
		{
			return PlayerPrefs.HasKey(ALLOW_FAST_EXPORT_MODE_KEY) && PlayerPrefs.GetInt(ALLOW_FAST_EXPORT_MODE_KEY) != 0;
		}
	}

	public static void EnableFastExportMode()
	{
		PlayerPrefs.SetInt(ALLOW_FAST_EXPORT_MODE_KEY, 1);
		PlayerPrefs.Save();
	}

	public static void DisableFastExportMode()
	{
		PlayerPrefs.SetInt(ALLOW_FAST_EXPORT_MODE_KEY, 0);
		PlayerPrefs.Save();
	}

	[MenuItem("Ravenfield Tools/Fast Export/Change Export Mode")]
	public static void OpenChangeDialog()
	{
		string changeMessage = $"{CHANGE_MESSAGE}\n\nFast Export is currently {(allowFastExportMode ? "ENABLED" : "DISABLED")}";

		bool useFastExport = EditorUtility.DisplayDialog("Change Export Mode", changeMessage, "Enable", "Disable");

		switch(useFastExport)
		{
			case true:
				EnableFastExportMode();
				break;

			case false:
				DisableFastExportMode();
				break;
		}
	}
}
