Exemple #1
0
        public static String getGlobalScrollsInstallPath()
        {
            if (Platform.GlobalScrollsInstallPath != null)
            {
                return(Platform.GlobalScrollsInstallPath);
            }

            String path = null;

            //if we are already loaded from the game folder, get that instead
            if ((from file in Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).GetFiles()
                 where file.Name.Contains("Assembly-CSharp.dll")
                 select file).Count() > 0)
            {
                Platform.GlobalScrollsInstallPath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString() + Path.DirectorySeparatorChar;
                Console.WriteLine("GlobalScrollsInstallPath is : " + Platform.GlobalScrollsInstallPath);
                Platform.ErrorLog("GlobalScrollsInstallPath is : " + Platform.GlobalScrollsInstallPath);
                return(Platform.GlobalScrollsInstallPath);
            }

            // we are located in ScrollsLauncher folder
            string searchpath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString() + Path.DirectorySeparatorChar + "game" + Path.DirectorySeparatorChar;
            string dsc        = Path.DirectorySeparatorChar + "";

            if (Platform.getOS() == Platform.OS.Mac)
            {
                searchpath  = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString().Replace("Desktop" + dsc + "Summoner.app" + dsc + "Contents" + dsc + "MacOS", "");
                searchpath += "Library" + dsc + "Application Support" + dsc + "Scrolls" + dsc;
            }

            /*Platform.ErrorLog("path zero step : " + Directory.GetParent (searchpath));
             * Platform.ErrorLog (searchpath + " contains this files:");
             * foreach (FileInfo file in Directory.GetParent (searchpath).GetFiles ())
             * {
             *      Platform.ErrorLog("found file: " + file.FullName);
             * }*/

            Platform.ErrorLog("path zero step : " + Directory.GetParent(searchpath));

            if (Platform.getOS() == Platform.OS.Mac)
            {
                if ((from file in Directory.GetParent(searchpath).GetFiles()
                     where file.Name.Contains("launcher")
                     select file).Count() == 0)
                {
                    //maybe we are in Scrolls folder?
                    searchpath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString();
                }
            }



            if ((from file in Directory.GetParent(searchpath).GetFiles()
                 where file.Name.Contains("launcher")
                 select file).Count() > 0)
            {
                String folderpath = "";

                folderpath = Directory.GetParent(searchpath).ToString() + Path.DirectorySeparatorChar + "versions";

                Console.WriteLine("path first step : " + folderpath);
                Platform.ErrorLog("path first step : " + folderpath);

                if (Directory.Exists(folderpath))
                {
                    //Console.WriteLine ("path exists");
                    //search newest version
                    String newestVersion = "0";
                    foreach (String pathh in System.IO.Directory.GetDirectories(folderpath))
                    {
                        if (pathh.EndsWith("-production"))                           // change this for test builds!!!
                        {
                            String v = pathh.Split(Path.DirectorySeparatorChar) [pathh.Split(Path.DirectorySeparatorChar).Length - 1];
                            v = v.Replace("version-", "");
                            v = v.Replace("-production", "");                              // change this for test builds!!!

                            if (Convert.ToInt32(v) > Convert.ToInt32(newestVersion))
                            {
                                newestVersion = v;
                            }
                        }
                    }
                    folderpath += Path.DirectorySeparatorChar + "version-" + newestVersion + "-production";

                    //search newest file!
                    Console.WriteLine("path second step : " + folderpath);
                    Platform.ErrorLog("path second step : " + folderpath);

                    String fullnewest = "version-" + newestVersion + "-production-natives-";

                    String timestamp = "0";
                    foreach (String pathh in System.IO.Directory.GetDirectories(folderpath))
                    {
                        String p = pathh.Split(Path.DirectorySeparatorChar) [pathh.Split(Path.DirectorySeparatorChar).Length - 1];
                        if (p.StartsWith(fullnewest))                           // change this for test builds!!!
                        {
                            String v = p.Replace(fullnewest, "");
                            if (Convert.ToInt64(v) > Convert.ToInt64(timestamp))
                            {
                                timestamp = v;
                            }
                        }
                    }

                    if (Platform.getOS() == Platform.OS.Win)
                    {
                        folderpath += Path.DirectorySeparatorChar + fullnewest + timestamp + Path.DirectorySeparatorChar + "Scrolls_Data" + Path.DirectorySeparatorChar + "Managed" + Path.DirectorySeparatorChar;
                    }

                    if (Platform.getOS() == Platform.OS.Mac)
                    {
                        folderpath += Path.DirectorySeparatorChar + fullnewest + timestamp + Path.DirectorySeparatorChar + "MacScrolls.app" + Path.DirectorySeparatorChar + "Contents" + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + "Managed" + Path.DirectorySeparatorChar;
                    }


                    Platform.GlobalScrollsInstallPath = folderpath;
                    Console.WriteLine("GlobalScrollsInstallPath is : " + Platform.GlobalScrollsInstallPath);
                    Platform.ErrorLog("GlobalScrollsInstallPath is : " + Platform.GlobalScrollsInstallPath);
                    return(Platform.GlobalScrollsInstallPath);
                }
            }


            switch (Platform.getOS())
            {
            case Platform.OS.Win:
                path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Mojang\\Scrolls\\game\\Scrolls_Data\\Managed\\";
                if (!System.IO.File.Exists(path + "Assembly-CSharp.dll"))
                {
                    Console.WriteLine("Expected Path: " + path);
                    Dialogs.showNotification("Scrolls was not found", "Please select your local install of Scrolls");

                    path = Dialogs.fileOpenDialog();
                    if (path == null)
                    {
                        Dialogs.showNotification("No Selection was made", "Scrolls Summoner was not able to find your local install of Scrolls. Scrolls Summoner will close now");
                        return(null);
                    }
                    if (!System.IO.File.Exists(path + "\\Assembly-CSharp.dll"))
                    {
                        Dialogs.showNotification("Wrong Selection", "The selected file is not a valid Scrolls game folder. Scrolls Summoner will close now");
                        return(null);
                    }
                }

                Platform.GlobalScrollsInstallPath = path;
                Console.WriteLine("GlobalScrollsInstallPath is : " + Platform.GlobalScrollsInstallPath);
                Platform.ErrorLog("GlobalScrollsInstallPath is : " + Platform.GlobalScrollsInstallPath);
                return(Platform.GlobalScrollsInstallPath);

            case Platform.OS.Mac:

                //Apps are bundles (== folders) on MacOS
                if (System.IO.Directory.Exists("/Applications/Scrolls.app"))
                {
                    path = "/Applications/Scrolls.app/Contents/MacOS/game/MacScrolls.app/Contents/Data/Managed/";
                    break;
                }

                // MacOS User needs to tell us the path of their Scrolls.app
                Dialogs.showNotification("Scrolls was not found", "Please select your local install of Scrolls");

                path = Dialogs.fileOpenDialog();
                if (path == null)
                {
                    Dialogs.showNotification("No Selection was made", "Scrolls Summoner was not able to find your local install of Scrolls. Scrolls Summoner will close now");
                    return(null);
                }
                path += "/Contents/MacOS/game/MacScrolls.app/Contents/Data/Managed/";

                if (!System.IO.File.Exists(path + "Assembly-CSharp.dll"))
                {
                    Dialogs.showNotification("Wrong Selection", "The selected file is not a valid Scrolls.app. Scrolls Summoner will close now");
                    return(null);
                }

                break;

            default:
                Console.WriteLine("Unsupported Platform detected");
                return(null);
            }

            Platform.GlobalScrollsInstallPath = path;
            Console.WriteLine("GlobalScrollsInstallPath is : " + Platform.GlobalScrollsInstallPath);
            Platform.ErrorLog("GlobalScrollsInstallPath is : " + Platform.GlobalScrollsInstallPath);
            return(Platform.GlobalScrollsInstallPath);
        }
 public string FileOpenDialog()
 {
     return(Dialogs.fileOpenDialog());
 }
Exemple #3
0
        public static String getGlobalScrollsInstallPath()
        {
            String path = null;

            //if we are already loaded from the game folder, get that instead
            if ((from file in Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).GetFiles()
                 where file.Name.Contains("Assembly-CSharp.dll")
                 select file).Count() > 0)
            {
                return(Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString() + Path.DirectorySeparatorChar);
            }

            switch (Platform.getOS())
            {
            case Platform.OS.Win:
                path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Mojang\\Scrolls\\game\\Scrolls_Data\\Managed\\";
                if (!System.IO.File.Exists(path + "Assembly-CSharp.dll"))
                {
                    Console.WriteLine("Expected Path: " + path);
                    Dialogs.showNotification("Scrolls was not found", "Please select your local install of Scrolls");

                    path = Dialogs.fileOpenDialog();
                    if (path == null)
                    {
                        Dialogs.showNotification("No Selection was made", "Scrolls Summoner was not able to find your local install of Scrolls. Scrolls Summoner will close now");
                        return(null);
                    }
                    if (!System.IO.File.Exists(path + "\\Assembly-CSharp.dll"))
                    {
                        Dialogs.showNotification("Wrong Selection", "The selected file is not a valid Scrolls game folder. Scrolls Summoner will close now");
                        return(null);
                    }
                }
                return(path);

            case Platform.OS.Mac:

                //Apps are bundles (== folders) on MacOS
                if (System.IO.Directory.Exists("/Applications/Scrolls.app"))
                {
                    path = "/Applications/Scrolls.app/Contents/MacOS/game/MacScrolls.app/Contents/Data/Managed/";
                    break;
                }

                // MacOS User needs to tell us the path of their Scrolls.app
                Dialogs.showNotification("Scrolls was not found", "Please select your local install of Scrolls");

                path = Dialogs.fileOpenDialog();
                if (path == null)
                {
                    Dialogs.showNotification("No Selection was made", "Scrolls Summoner was not able to find your local install of Scrolls. Scrolls Summoner will close now");
                    return(null);
                }
                path += "/Contents/MacOS/game/MacScrolls.app/Contents/Data/Managed/";

                if (!System.IO.File.Exists(path + "Assembly-CSharp.dll"))
                {
                    Dialogs.showNotification("Wrong Selection", "The selected file is not a valid Scrolls.app. Scrolls Summoner will close now");
                    return(null);
                }

                break;

            default:
                Console.WriteLine("Unsupported Platform detected");
                return(null);
            }

            Console.WriteLine("Install Path: " + path);
            return(path);
        }