using Wizard;

namespace Cute;

public class CustomPreference
{
	public enum eSchemeType
	{
		Http,
		Https,
		File,
		Node,
		StreamingAssets
	}

	public enum PlatformType
	{
		NONE,
		APPLE,
		GOOGLE,
		DMM,
		STEAM
	}

	public enum SmallResourceStatus
	{
		NO_SELECT,
		USE_NORMAL,
		USE_SMALL
	}

	private const string fileScheme = "file:///";

	private const string httpScheme = "http://";

	private const string httpsScheme = "https://";

	private const string jarFileScheme = "jar:file://";

	private static string nodeServerScheme = "ws://";

	private const string directoryLowLevelResources = "Low/";

	private const string directoryHighLevelResources = "High/";

	private static string directoryRoot = "dl/";

	private static string _applicationServerUrl = "";

	private static string _resourceServerUrl = "";

	private static string _nodeServerUrl = "";

	private static string _deckBuilderServerUrl = "";

	public static string _localePref = "Eng";

	private static string _signaturePref = "";

	private static string _languagePref = "Eng";

	private static string _languageSoundPref = "Eng";

	private static string _assetbundleurl = "";

	private static string _manifestsuburl = "";

	private static string _soundurl = "";

	private static string _movieurl = "";

	private static string _manifestUrl = "";

	private static eSchemeType _schemeType = eSchemeType.Http;

	private static eSchemeType _schemeCDNType = eSchemeType.Http;

	private static bool _isPreferenceComplete = false;

	private static bool _isLocalAssetBundles = false;

	public static bool isPreferenceComplete
	{
		get
		{
			return _isPreferenceComplete;
		}
		set
		{
			_isPreferenceComplete = value;
		}
	}

	public static bool isLocalAssetBundles
	{
		get
		{
			return _isLocalAssetBundles;
		}
		set
		{
			_isLocalAssetBundles = value;
		}
	}

	public static bool IsNormalResource => !IsSmallResource;

	public static bool IsSmallResource => PlayerPrefsCache.Instance.GetValue(PlayerPrefsWrapper.SMALL_RESOURCE_STATUS) == 2;

	public static string GetApplicationServerURL()
	{
		return GetScheme() + _applicationServerUrl;
	}

	public static void SetApplicationServerURL(string strApplicationServer)
	{
		_applicationServerUrl = strApplicationServer;
	}

	public static string GetResourceServerURL()
	{
		return GetCDNScheme() + _resourceServerUrl;
	}

	public static void SetResourceServerURL(string strResourceServer)
	{
		_resourceServerUrl = strResourceServer;
	}

	public static string GetNodeServerURL()
	{
		return nodeServerScheme + _nodeServerUrl;
	}

	public static void SetNodeServerURL(string strNodeServer)
	{
		if (!string.IsNullOrEmpty(strNodeServer))
		{
			_nodeServerUrl = strNodeServer;
		}
	}

	public static string GetDeckBuilderServerURL()
	{
		return GetScheme() + _deckBuilderServerUrl;
	}

	public static void SetDeckBuilderServerURL(string strDeckBuilderServer)
	{
		_deckBuilderServerUrl = strDeckBuilderServer;
	}

	public static int GetPlatform()
	{
		return 4;
	}

	public static string GetAssetBundleURL()
	{
		return _assetbundleurl;
	}

	public static string GetManifestURL()
	{
		return _manifestUrl;
	}

	public static string GetSubManifestURL()
	{
		if (_isLocalAssetBundles)
		{
			_manifestsuburl = GetResourceServerURL() + Utility.GetRuntimePlatform() + "/";
		}
		else
		{
			_manifestsuburl = GetResourceServerURL() + directoryRoot + "Manifest/" + GetVersionFolderName() + GetSoundMovieLanguageFolderName() + Utility.GetRuntimePlatform() + "/";
		}
		return _manifestsuburl;
	}

	public static string GetSoundResourceURL()
	{
		return _soundurl;
	}

	public static string GetMoiveResourceURL()
	{
		return _movieurl;
	}

	public static string GetScheme()
	{
		return _schemeType switch
		{
			eSchemeType.Http => "http://", 
			eSchemeType.Https => "https://", 
			eSchemeType.File => "file:///", 
			eSchemeType.Node => nodeServerScheme, 
			eSchemeType.StreamingAssets => "file:///", 
			_ => "http://", 
		};
	}

	public static string GetCDNScheme()
	{
		return _schemeCDNType switch
		{
			eSchemeType.Http => "http://", 
			eSchemeType.Https => "https://", 
			_ => "http://", 
		};
	}

	public static string GetVersionFolderName()
	{
		return Toolbox.SavedataManager.GetResourceVersion() + "/";
	}

	public static void SetScemeMode(eSchemeType schemeType)
	{
		_schemeType = schemeType;
	}

	public static void SetScemeModeCDN(eSchemeType schemeCDNType)
	{
		_schemeCDNType = schemeCDNType;
	}

	public static void SetOptionalNodeSceme()
	{
		if (PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.IS_SELECT_WSS))
		{
			SetNodeSceme("wss://");
		}
		else
		{
			SetNodeSceme("ws://");
		}
	}

	private static void SetNodeSceme(string scheme)
	{
		nodeServerScheme = scheme;
	}

	public static void SetRootFolderName(string strDir)
	{
		directoryRoot = strDir;
	}

	public static void SetTextLanguage(string strLanguage)
	{
		_languagePref = strLanguage;
	}

	public static void SetLocale(string strLocale)
	{
		_localePref = strLocale;
	}

	public static string GetLanguageFolderName()
	{
		return _languagePref + "/";
	}

	public static string GetTextLanguage()
	{
		return GetResourceLanguage();
	}

	public static string GetResourceLanguage()
	{
		return _languagePref;
	}

	public static void SetSoundLanguage(string strLanguage)
	{
		_languageSoundPref = strLanguage;
	}

	public static string GetSoundMovieLanguageFolderName()
	{
		return _languageSoundPref + "/";
	}

	public static string GetSoundMovieLanguage()
	{
		return _languageSoundPref;
	}

	public static void SetSignature(string strSignature)
	{
		_signaturePref = strSignature;
	}

	public static string GetSignaturePath()
	{
		return "/../" + _signaturePref;
	}

	public static void createResourcePath()
	{
		if (_isLocalAssetBundles)
		{
			_assetbundleurl = GetResourceServerURL() + Utility.GetRuntimePlatform() + "/";
			_manifestsuburl = GetResourceServerURL() + Utility.GetRuntimePlatform() + "/";
		}
		else
		{
			_assetbundleurl = GetResourceServerURL() + directoryRoot + "Resource/" + GetLanguageFolderName() + Utility.GetRuntimePlatform() + "/";
			string text = "Manifest/";
			_manifestsuburl = GetResourceServerURL() + directoryRoot + text + GetVersionFolderName() + GetSoundMovieLanguageFolderName() + Utility.GetRuntimePlatform() + "/";
			_manifestUrl = GetResourceServerURL() + directoryRoot + text + GetVersionFolderName() + GetLanguageFolderName() + Utility.GetRuntimePlatform() + "/";
		}
		_soundurl = GetResourceServerURL() + directoryRoot + "Sound/" + GetSoundMovieLanguageFolderName();
		_movieurl = GetResourceServerURL() + directoryRoot + "Resource/" + GetSoundMovieLanguageFolderName() + Utility.GetRuntimePlatform() + "/";
	}
}
