﻿using System;
using System.IO;
using UnityEngine;

public static class DLCConfiguration
{
    private const string CdnUrlKey = "com.nhnent.dlc.test.cdnurl";
    private const string MetaFileNameKey = "com.nhnent.dlc.test.metafilename";
    private const string DownloadPathKey = "com.nhnent.dlc.test.downloadpath";

    private const string LeafDirectory = "DLCDownloads";
    private static readonly string Seperator = Path.DirectorySeparatorChar.ToString();

    private const string DefaultCdnUrl = "http://api-storage.cloud.toast.com/v1/AUTH_f78ddd86bc434df184b505896de4d535/Holdem";
    //private const string DefaultCdnUrl = "http://vbtnpmfc.cdn.toastcloud.com/v1/AUTH_f78ddd86bc434df184b505896de4d535/Holdem";
    private const string DefaultMetaFileName = "metafile.json";

    private static string DefaultDownloadPath
    {
        get
        {
            return
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
                // Windows Path : C:\Users\{USER_NAME}\Documents\DLCDownloads
                Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Seperator + LeafDirectory;
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                // MacOS Path : /Users/{USER_NAME}/Documents/DLCDownloads
                Environment.GetFolderPath (Environment.SpecialFolder.Personal) + Seperator + "Documents" + Seperator + LeafDirectory;
#else
				Application.persistentDataPath + Seperator + LeafDirectory;
#endif
        }
    }

    public static string CdnUrl { get { return PlayerPrefs.GetString(CdnUrlKey, DefaultCdnUrl); } }
    public static string MetaFileName { get { return PlayerPrefs.GetString(MetaFileNameKey, DefaultMetaFileName); } }
    public static string DownloadPath { get { return PlayerPrefs.GetString(DownloadPathKey, DefaultDownloadPath); } }

    public static void SaveCdnUrl(string cdnUrl) { PlayerPrefs.SetString(CdnUrlKey, cdnUrl); }
    public static void SaveMetaFileName(string metaFileName) { PlayerPrefs.SetString(MetaFileNameKey, metaFileName); }
    public static void SaveDownloadPath(string downloadPath) { PlayerPrefs.SetString(DownloadPathKey, downloadPath); }
}
