private static void DownloadConfiguration(string domain)
        {
            string store = "google";

            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS)
            {
                store = "apple";
            }
            string url    = domain + RATEUS_URL_ADDITION + store + "/" + PlayerSettings.applicationIdentifier;
            string output = null;

            if (!TTPMenu.DownloadConfiguration(url, RATEUS_JSON_FN, out output))
            {
                Debug.LogWarning("RateUsConfigurationDownloader:: DownloadConfiguration: failed to download configuration. Wont download app icon");
                return;
            }
#if UNITY_ANDROID
            if (output != null)
            {
                var rateUsJson = SimpleJSON.JSON.Parse(output);
                if (rateUsJson != null)
                {
                    string iconUrl = rateUsJson["iconUrl"];
                    if (iconUrl != null)
                    {
                        string extenstion = iconUrl.Substring(iconUrl.LastIndexOf(".", System.StringComparison.InvariantCultureIgnoreCase) + 1);
                        TTPEditorUtils.DownloadFile(iconUrl, "Assets/StreamingAssets/ttp/rateus/game_icon." + extenstion);
                    }
                }
            }
#endif
        }
Beispiel #2
0
 public static bool DownloadConfiguration(string url, string fileName, out string configurationOutput)
 {
     if (TTPEditorUtils.DownloadStringToFile(url, CONFIGURATIONS_PATH + "/" + fileName + ".json", out configurationOutput))
     {
         return(true);
     }
     else
     {
         EditorUtility.DisplayDialog("Failed to Download Configuration", "Failed to download configuration from the following url - " + url, "OK");
     }
     return(false);
 }
        private static void DownloadConfiguration(string domain)
        {
            string store = "google";

            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS)
            {
                store = "apple";
            }
            string url    = domain + CORE_URL_ADDITION + store + "/" + PlayerSettings.applicationIdentifier;
            bool   result = TTPMenu.DownloadConfiguration(url, CORE_JSON_FN);

            if (!result)
            {
                Debug.LogWarning("CoreConfigurationDownloader:: DownloadConfiguration: failed to download global configuration.");
            }
#if UNITY_ANDROID
            string strictModeConfigUrl = domain + "/" + STRICT_MODE_JSON_FN + "/" + store + "/" + PlayerSettings.applicationIdentifier;
            bool   strictModeResult    = TTPMenu.DownloadConfiguration(strictModeConfigUrl, STRICT_MODE_JSON_FN);
            if (!strictModeResult)
            {
                Debug.LogWarning("CoreConfigurationDownloader:: DownloadConfiguration: failed to download configuration for strict mode android");
            }
#endif
            var additionalConfigUrl    = domain + "/" + ADDITIONAL_CONFIG_JSON_FN + "/" + store + "/" + PlayerSettings.applicationIdentifier;
            var additionalConfigResult = TTPMenu.DownloadConfiguration(additionalConfigUrl, ADDITIONAL_CONFIG_JSON_FN);
            if (!additionalConfigResult)
            {
                Debug.LogWarning("CoreConfigurationDownloader:: DownloadConfiguration: failed to download additional configuration");
            }
            #if UNITY_IOS
            else
            {
                var json = File.ReadAllText(CONFIGURATIONS_PATH + "/" + CORE_JSON_FN + ".json");
                if (json != null)
                {
                    var dict = TTPJson.Deserialize(json) as Dictionary <string, object>;
                    if (dict != null)
                    {
                        var conversionModelType = "A";
                        if (dict.ContainsKey("conversionModelType"))
                        {
                            conversionModelType = dict["conversionModelType"] as string;
                        }
                        var conversionRulesUrl = "http://promo-images.ttpsdk.info/conversionJS/" + conversionModelType + "/conversion.js";
                        TTPEditorUtils.DownloadStringToFile(conversionRulesUrl, "Assets/StreamingAssets/ttp/conversion/conversion.js");
                    }
                }
            }
            #endif
        }
Beispiel #4
0
        public static void DownloadAppConfigFile(string baseUrl)
        {
            string url = baseUrl + "/alm/title/" + PlayerSettings.applicationIdentifier;

            TTPEditorUtils.DownloadStringToFile(url, APP_CONFIG_PATH, true);
        }
Beispiel #5
0
        private static void DownloadConfiguration(string domain)
        {
            string store = "google";

            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS)
            {
                store = "apple";
            }
            string url = domain + BANNERS_URL_ADDITION + store + "/" + PlayerSettings.applicationIdentifier;

            Debug.Log("BannersConfigurationDownloader:: DownloadConfiguration: download config from url: " + url);

            bool result = TTPMenu.DownloadConfiguration(url, BANNERS_JSON_FN);

            if (!result)
            {
                Debug.LogWarning("BannersConfigurationDownloader:: DownloadConfiguration: failed to download configuration.");
            }

            string houseAdsConfigUrl = domain + BANNERS_HOUSE_ADS_URL_ADDITION + store + "/" + PlayerSettings.applicationIdentifier;

            Debug.Log("BannersConfigurationDownloader:: DownloadConfiguration: houseAdsConfigUrl: " + houseAdsConfigUrl);
            string houseAdsJson = null;

            if (TTPEditorUtils.DownloadStringToFile(houseAdsConfigUrl, BANNERS_HOUSE_ADS_FP, out houseAdsJson))
            {
                var houseAdsConfig = JSON.Parse(houseAdsJson);
                if (houseAdsConfig != null)
                {
                    var apps = houseAdsConfig["apps"];
                    if (apps != null)
                    {
                        if (System.IO.File.Exists("Assets/StreamingAssets/ttp/houseads/houseads.zip"))
                        {
                            System.IO.File.Delete("Assets/StreamingAssets/ttp/houseads/houseads.zip");
                        }

                        foreach (var app in apps.Values)
                        {
                            string thumbnailUrl = app["thumbnail"];
                            if (thumbnailUrl != null)
                            {
                                Debug.Log("BannersConfigurationDownloader:: DownloadConfiguration: download thumbnail form url: " + thumbnailUrl);
                                string fn = thumbnailUrl.Substring(thumbnailUrl.LastIndexOf("/") + 1);
                                if (TTPEditorUtils.DownloadFile(thumbnailUrl, "Assets/StreamingAssets/ttp/houseads/" + fn))
                                {
                                    app["thumbnail"] = System.IO.Path.GetFileName(thumbnailUrl);
                                }
                            }
                        }
                        System.IO.File.WriteAllText(BANNERS_HOUSE_ADS_FP, houseAdsConfig.ToString());

                        string[] files = ZipUtil.ZipDirectoryContents(BANNER_ZIP_PATH, "Assets/StreamingAssets/ttp/houseads");
                        if (files != null)
                        {
                            foreach (string path in files)
                            {
                                Debug.Log("BannersConfigurationDownloader:: DownloadConfiguration: delete file from path: " + path);
                                System.IO.File.Delete(path);
                            }
                        }
                        else
                        {
                            Debug.LogWarning("BannersConfigurationDownloader:: DownloadConfiguration: NO files in houseads dir.");
                        }
                    }
                    else
                    {
                        Debug.LogWarning("BannersConfigurationDownloader:: DownloadConfiguration: there're NO apps in JSON.");
                    }
                }
                else
                {
                    Debug.LogWarning("BannersConfigurationDownloader:: DownloadConfiguration: JSON parse of houseAdsConfig failed.");
                }
            }
        }