using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using I2.Loc;
using UnityEngine;

public static class Product
{
	public static Product.Type type { get; private set; }

	public static bool supportMultiLanguage
	{
		get
		{
			return Product.type != Product.Type.JpAdult && Product.type != Product.Type.JpPublic;
		}
	}

	public static bool isPublic
	{
		get
		{
			return Product.type == Product.Type.JpPublic || Product.type == Product.Type.EnPublic;
		}
	}

	public static bool isJapan
	{
		get
		{
			return Product.type == Product.Type.JpAdult || Product.type == Product.Type.JpPublic;
		}
	}

	public static bool isEnglish
	{
		get
		{
			return Product.type == Product.Type.EnAdult || Product.type == Product.Type.EnPublic;
		}
	}

	public static Product.Language systemLanguage
	{
		get
		{
			if (!Product.supportMultiLanguage)
			{
				return Product.Language.Japanese;
			}
			string currentLanguage = LocalizationManager.CurrentLanguage;
			return (!(currentLanguage == "English")) ? Product.Language.Japanese : Product.Language.English;
		}
		set
		{
			if (!Product.supportMultiLanguage)
			{
				LocalizationManager.CurrentLanguage = Product.EnumConvert.ToI2LocalizeLanguageName(Product.Language.Japanese);
				return;
			}
			LocalizationManager.CurrentLanguage = Product.EnumConvert.ToI2LocalizeLanguageName(value);
			foreach (LanguageSource languageSource in LocalizationManager.Sources)
			{
				languageSource.LoadAllLanguages(false);
			}
		}
	}

	public static Product.Language defaultLanguage
	{
		get
		{
			return (!Product.supportMultiLanguage) ? Product.Language.Japanese : Product.Language.English;
		}
	}

	public static string gameTitle
	{
		get
		{
			string text = "System/カスタムオーダーメイド3D 2";
			if (Product.isPublic)
			{
				text += "全年齢";
			}
			return LocalizationManager.GetTranslation(text, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.systemLanguage));
		}
	}

	public static string windowTitel
	{
		get
		{
			string text = Product.gameTitle;
			if (Product.isJapan)
			{
				text = "CUSTOM ORDER MAID 3D 2";
				if (Product.isPublic)
				{
					text += " It's a Night Magic";
				}
			}
			return text;
		}
	}

	public static string gameDataPath
	{
		get
		{
			Product.Type type = Product.type;
			if (type == Product.Type.JpPublic)
			{
				return "_public";
			}
			if (type == Product.Type.EnAdult)
			{
				return "_en";
			}
			if (type != Product.Type.EnPublic)
			{
				return string.Empty;
			}
			return "_enpublic";
		}
	}

	public static bool enabeldAdditionalRelation
	{
		get
		{
			return true;
		}
	}

	public static bool lockDLCSiteLink
	{
		get
		{
			return Product.type == Product.Type.EnPublic && File.Exists(Path.Combine(UTY.gameProjectPath, "platform_others"));
		}
	}

	public static void Initialize(AFileSystemBase fileSystem)
	{
		KeyValuePair<string, Product.Type>[] array = new KeyValuePair<string, Product.Type>[]
		{
			new KeyValuePair<string, Product.Type>("RDFBMTE5RTItMEQxOC00NkM3LUFCNzctRERGNjkyNjNCNzcy", Product.Type.JpAdult),
			new KeyValuePair<string, Product.Type>("Nzc1RjVFNUQtQzc5Ri00NThGLTg4QzYtRTEwQ0JCRTVCRTVB", Product.Type.JpPublic),
			new KeyValuePair<string, Product.Type>("QTZEQUE0MDItNTI4MS00RTMxLUFGOEMtMTY3RUE5M0QwQ0Q5", Product.Type.EnAdult),
			new KeyValuePair<string, Product.Type>("QzhFODY4MkMtRTU1QS00MDZBLTkyREItRjQ5RTE1N0Y4M0VC", Product.Type.EnPublic)
		};
		Encoding encoding = Encoding.GetEncoding("UTF-8");
		Product.type = Product.Type.JpAdult;
		foreach (KeyValuePair<string, Product.Type> keyValuePair in array)
		{
			if (fileSystem.IsExistentFile(encoding.GetString(Convert.FromBase64String(keyValuePair.Key))))
			{
				Product.type = keyValuePair.Value;
				break;
			}
		}
		Debug.Log("ProductType:" + Product.type.ToString());
		Product.systemLanguage = Product.defaultLanguage;
	}

	public static void OnApplicationQuit()
	{
	}

	public enum Type
	{
		JpAdult,
		JpPublic,
		EnAdult,
		EnPublic
	}

	public enum Language
	{
		Japanese,
		English
	}

	public static class EnumConvert
	{
		public static string GetString(Product.Language language)
		{
			if (language == Product.Language.Japanese)
			{
				return "日本語";
			}
			return "英語";
		}

		public static string ToI2LocalizeLanguageName(Product.Language language)
		{
			if (language == Product.Language.Japanese)
			{
				return "Japanese";
			}
			if (language != Product.Language.English)
			{
				return "Japanese";
			}
			return "English";
		}

		public static string GetTerm(Product.Language language)
		{
			return "System/言語/" + Product.EnumConvert.GetString(language);
		}
	}
}
