コード例 #1
0
ファイル: Google2u.cs プロジェクト: joenarus/Stressident
        public static string Google2uGenPath(string in_pathType)
        {
            var retPath = string.Empty;

            if (Google2uGUIUtil.GfuStrCmp(in_pathType, "Google2uGEN"))
            {
                retPath = Path.Combine(Instance.InstanceData.ProjectPath, "Google2uGen").Replace('\\', '/');
                if (!Directory.Exists(retPath))
                {
                    Debug.Log("Generating: " + retPath);
                    Directory.CreateDirectory(retPath);
                }
            } // Standard Assets
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "OBJDB"))
            {
                {
                    var Google2ugenPath = Google2uGenPath("Google2uGEN");

                    retPath = Path.Combine(Google2ugenPath, "ObjDB").Replace('\\', '/');
                    if (!Directory.Exists(retPath))
                    {
                        Debug.Log("Generating: " + retPath);
                        Directory.CreateDirectory(retPath);
                    }
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "OBJDBRESOURCES"))
            {
                {
                    retPath = Google2uGUIUtil.GetString("g2uobjDBResourcesDirectory", retPath);
                    if (!Directory.Exists(retPath))
                    {
                        var objdbPath = Google2uGenPath("OBJDB");

                        retPath = Path.Combine(objdbPath, "Resources").Replace('\\', '/');
                        if (!Directory.Exists(retPath))
                        {
                            Debug.Log("Generating: " + retPath);
                            Directory.CreateDirectory(retPath);
                        }

                        Google2uGUIUtil.SetString("g2uobjDBResourcesDirectory", retPath);
                    }
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "OBJDBEDITOR"))
            {
                {
                    retPath = Google2uGUIUtil.GetString("g2uobjDBEditorDirectory", retPath);
                    if (!Directory.Exists(retPath))
                    {
                        var objdbPath = Google2uGenPath("OBJDB");

                        retPath = Path.Combine(objdbPath, "Editor").Replace('\\', '/');
                        if (!Directory.Exists(retPath))
                        {
                            Debug.Log("Generating: " + retPath);
                            Directory.CreateDirectory(retPath);
                        }

                        Google2uGUIUtil.SetString("g2uobjDBEditorDirectory", retPath);
                    }
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "STATICDB"))
            {
                {
                    var Google2ugenPath = Google2uGenPath("Google2uGEN");

                    retPath = Path.Combine(Google2ugenPath, "StaticDB").Replace('\\', '/');
                    if (!Directory.Exists(retPath))
                    {
                        Debug.Log("Generating: " + retPath);
                        Directory.CreateDirectory(retPath);
                    }
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "STATICDBRESOURCES"))
            {
                {
                    retPath = Google2uGUIUtil.GetString("g2uStaticDBResourcesDirectory", retPath);
                    if (Directory.Exists(retPath))
                    {
                        return(retPath);
                    }
                    var staticdbPath = Google2uGenPath("STATICDB");

                    retPath = Path.Combine(staticdbPath, "Resources").Replace('\\', '/');
                    if (!Directory.Exists(retPath))
                    {
                        Debug.Log("Generating: " + retPath);
                        Directory.CreateDirectory(retPath);
                    }

                    Google2uGUIUtil.SetString("g2uStaticDBResourcesDirectory", retPath);
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "JSON"))
            {
                {
                    retPath = Google2uGUIUtil.GetString("g2ujsonDirectory", retPath);
                    if (Directory.Exists(retPath))
                    {
                        return(retPath);
                    }
                    var Google2ugenPath = Google2uGenPath("Google2uGEN");

                    retPath = Path.Combine(Google2ugenPath, "JSON").Replace('\\', '/');
                    if (!Directory.Exists(retPath))
                    {
                        Debug.Log("Generating: " + retPath);
                        Directory.CreateDirectory(retPath);
                    }

                    Google2uGUIUtil.SetString("g2ujsonDirectory", retPath);
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "CSV"))
            {
                {
                    retPath = Google2uGUIUtil.GetString("g2ucsvDirectory", retPath);
                    if (Directory.Exists(retPath))
                    {
                        return(retPath);
                    }
                    var Google2ugenPath = Google2uGenPath("Google2uGEN");

                    retPath = Path.Combine(Google2ugenPath, "CSV").Replace('\\', '/');
                    if (!Directory.Exists(retPath))
                    {
                        Debug.Log("Generating: " + retPath);
                        Directory.CreateDirectory(retPath);
                    }

                    Google2uGUIUtil.SetString("g2ucsvDirectory", retPath);
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "XML"))
            {
                {
                    retPath = Google2uGUIUtil.GetString("g2uxmlDirectory", retPath);
                    if (Directory.Exists(retPath))
                    {
                        return(retPath);
                    }
                    var Google2ugenPath = Google2uGenPath("Google2uGEN");

                    retPath = Path.Combine(Google2ugenPath, "XML").Replace('\\', '/');
                    if (!Directory.Exists(retPath))
                    {
                        Debug.Log("Generating: " + retPath);
                        Directory.CreateDirectory(retPath);
                    }

                    Google2uGUIUtil.SetString("g2uxmlDirectory", retPath);
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "NGUI"))
            {
                {
                    retPath = Google2uGUIUtil.GetString("g2unguiDirectory", retPath);
                    if (Directory.Exists(retPath))
                    {
                        return(retPath);
                    }
                    var Google2ugenPath = Google2uGenPath("Google2uGEN");

                    retPath = Path.Combine(Google2ugenPath, "NGUI").Replace('\\', '/');
                    if (!Directory.Exists(retPath))
                    {
                        Debug.Log("Generating: " + retPath);
                        Directory.CreateDirectory(retPath);
                    }

                    Google2uGUIUtil.SetString("g2unguiDirectory", retPath);
                }
            }
            else if (Google2uGUIUtil.GfuStrCmp(in_pathType, "PLAYMAKER"))
            {
                {
                    retPath = Google2uGUIUtil.GetString("g2uplaymakerDirectory", retPath);
                    if (Directory.Exists(retPath))
                    {
                        return(retPath);
                    }
                    // attempt to find the playmaker actions directory
                    // We already know that the playmaker dll exists, but we need to find the actual path
                    var playmakerPaths = Directory.GetFiles(Application.dataPath, "PlayMaker.dll",
                                                            SearchOption.AllDirectories);
                    var playmakerPath = string.Empty;
                    if (playmakerPaths.Length > 0)
                    {
                        // We are just going to use the first entry. If there is more than 1 entry, there are bigger issues
                        var fileName = playmakerPaths[0];
                        var fileInfo = new FileInfo(fileName);
                        playmakerPath = fileInfo.DirectoryName;
                    }

                    if (playmakerPath != string.Empty)
                    {
                        if (playmakerPath != null)
                        {
                            retPath = Path.Combine(playmakerPath, "Actions");
                        }
                        if (Directory.Exists(retPath))
                        {
                            // We have found the Playmaker Actions dir!
                            Google2uGUIUtil.SetString("g2uplaymakerDirectory", retPath);
                        }
                        else
                        {
                            // The actions subdirectory doesn't exist? Rather than making it in the playmaker directory,
                            // We will just use our Google2uGen path instead and let the user figure it out
                            var Google2ugenPath = Google2uGenPath("Google2uGEN");

                            retPath = Path.Combine(Google2ugenPath, "PlayMaker").Replace('\\', '/');
                            if (!Directory.Exists(retPath))
                            {
                                Directory.CreateDirectory(retPath);
                            }

                            Google2uGUIUtil.SetString("g2uplaymakerDirectory", retPath);
                        }
                    }
                }
            }

            return(retPath);
        }
コード例 #2
0
ファイル: Google2u.cs プロジェクト: joenarus/Stressident
        private static void AddManualWorkbookByUrl(string in_manualUrl, Google2uData in_instance)
        {
            WorkbookBase info;

            if (string.IsNullOrEmpty(in_manualUrl))
            {
                Debug.LogError(LocalizationInfo.Localize(Localization.rowIds.ID_ERROR_EMPTY_URL));
                return;
            }

            var refreshManualWorkbookCache = false;

            try
            {
                var key =
                    in_manualUrl.Substring(in_manualUrl.IndexOf("key=", StringComparison.InvariantCultureIgnoreCase) + 4);
                key = key.Split('&')[0];

                var singleQuery = new WorksheetQuery(key, "public", "values");

                if (in_instance.ManualService == null && !SetupManualService(in_instance))
                {
                    return;
                }

                var feed = in_instance.ManualService.Query(singleQuery);

                var finalUrl = in_manualUrl.Split('&')[0];

                if (feed != null)
                {
                    info =
                        in_instance.ManualWorkbooks.Find(in_i => Google2uGUIUtil.GfuStrCmp(in_i.WorkbookUrl, finalUrl)) ??
                        in_instance.AccountWorkbooks.Find(in_i => Google2uGUIUtil.GfuStrCmp(in_i.WorkbookUrl, finalUrl))
                        as WorkbookBase;
                    if (info == null)
                    {
                        var newWorkbook = new Google2uManualWorkbook(feed, finalUrl, feed.Title.Text,
                                                                     in_instance.ManualService);
                        in_instance.ManualWorkbooks.Add(newWorkbook);

                        refreshManualWorkbookCache = true;
                    }
                }
            }
            catch
            {
                try
                {
                    var key =
                        in_manualUrl.Substring(
                            in_manualUrl.IndexOf("spreadsheets/d/", StringComparison.InvariantCultureIgnoreCase) + 15);
                    key = key.Split('/')[0];

                    if (in_instance.ManualService == null && !SetupManualService(in_instance))
                    {
                        return;
                    }

                    var singleQuery = new WorksheetQuery(key, "public", "values");
                    var feed        = in_instance.ManualService.Query(singleQuery);
                    var urlParts    = in_manualUrl.Split('/');

                    var    finalUrl = "";
                    var    urlBuild = 0;
                    string urlPart;
                    do
                    {
                        urlPart   = urlParts[urlBuild];
                        finalUrl += urlPart + '/';
                        urlBuild++;
                    } while (urlPart != key);
                    if (feed != null)
                    {
                        info =
                            in_instance.ManualWorkbooks.Find(
                                in_i => Google2uGUIUtil.GfuStrCmp(in_i.WorkbookUrl, finalUrl)) ??
                            in_instance.AccountWorkbooks.Find(
                                in_i => Google2uGUIUtil.GfuStrCmp(in_i.WorkbookUrl, finalUrl)) as WorkbookBase;
                        if (info == null)
                        {
                            var newWorkbook = new Google2uManualWorkbook(feed, finalUrl, feed.Title.Text,
                                                                         in_instance.ManualService);
                            in_instance.ManualWorkbooks.Add(newWorkbook);

                            refreshManualWorkbookCache = true;
                        }
                    }
                }
                catch
                {
                    Debug.LogError(LocalizationInfo.Localize(Localization.rowIds.ID_ERROR_INVALID_URL));
                }
            }

            if (refreshManualWorkbookCache)
            {
                in_instance.ManualWorkbookCache = string.Empty;
                foreach (var Google2uSpreadsheet in in_instance.ManualWorkbooks)
                {
                    in_instance.ManualWorkbookCache += Google2uSpreadsheet.WorkbookUrl + "|";
                }
            }
        }