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

public class ToukaEditor : MonoBehaviour {

    static string assetPath = Application.dataPath;
    static string maxPath = assetPath + "/Plugins/ToukaGames/ADSSDK/MAXSDKs";
    static string toponPath = assetPath + "/Plugins/ToukaGames/ADSSDK/ToponSDK";
    static string maxPathX = assetPath + "/Plugins/ToukaGames/ADSSDK/MAXSDKs~";
    static string toponPathX = assetPath + "/Plugins/ToukaGames/ADSSDK/ToponSDK~";

    [MenuItem("ToukaGames/ClearPlayerPrefs")]
	public static void ClearPlayerPrefs(){
		PlayerPrefs.DeleteAll();
		PlayerPrefs.Save();
	}

    [MenuItem("ToukaGames/Setings For IOS CN")]
    public static void SetIOSCNTOPONSeting()
    {
        // bundle id
        PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, StaticStringsKey.BunldId_CN);
        PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, StaticStringsKey.ScriptingDefineSymbols_CN);

        if(Directory.Exists(maxPath))
        {
            ChangePathName(maxPath, maxPathX);
        }

        if (!Directory.Exists(toponPath))
        {
            if (Directory.Exists(toponPathX))
            {
                ChangePathName(toponPathX, toponPath);
            }
            
        }
    }

    [MenuItem("ToukaGames/Setings For IOS US")]
    public static void SetIOSUSSeting()
    {
        // bundle id
        PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, StaticStringsKey.BunldId_US);

        PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, StaticStringsKey.ScriptingDefineSymbols_US);

        if (Directory.Exists(toponPath))
        {
            ChangePathName(toponPath, toponPathX);
        }

        if (!Directory.Exists(maxPath))
        {
            if (Directory.Exists(maxPathX))
            {
                ChangePathName(maxPathX, maxPath);
            }

        }
    }

    private static void ChangePathName(string _oldPath, string _newPath)
    {
        System.IO.File.Move(_oldPath, _newPath);
    }
}
