Beispiel #1
0
 public static void InstallGame(CGame game)
 {
     CDock.DeleteCustomImage(game.Title);
     if (OperatingSystem.IsWindows())
     {
         try
         {
             using RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"itch\shell\open\command", RegistryKeyPermissionCheck.ReadSubTree);
             string[] subs    = GetRegStrVal(key, null).Split(' ');
             string   command = "";
             string   args    = "";
             for (int i = 0; i > subs.Length; i++)
             {
                 if (i > 0)
                 {
                     args += subs[i];
                 }
                 else
                 {
                     command = subs[0];
                 }
             }
             CDock.StartAndRedirect(command, args.Replace("%1", INSTALL_GAME + "/" + GetGameID(game.ID)));
         }
         catch (Exception e)
         {
             CLogger.LogError(e);
         }
     }
 }
Beispiel #2
0
 public static void Launch()
 {
     if (OperatingSystem.IsWindows())
     {
         /*
          * using (RegistryKey key = Registry.LocalMachine.OpenSubKey(GOG_REG_CLIENT, RegistryKeyPermissionCheck.ReadSubTree)) // HKLM32
          * {
          *  string launcherPath = Path.Combine(GetRegStrVal(key, "client"), LAUNCH);
          *  if (File.Exists(launcherPath))
          *      Process.Start(launcherPath);
          *  else
          *  {
          *      //SetFgColour(cols.errorCC, cols.errorLtCC);
          *      CLogger.LogWarn("Cannot start {0} launcher.", _name.ToUpper());
          *      Console.WriteLine("ERROR: Launcher couldn't start. Is it installed properly?");
          *      //Console.ResetColor();
          *  }
          * }
          */
         CDock.StartShellExecute(PROTOCOL);
     }
     else
     {
         Process.Start(PROTOCOL);
     }
 }
Beispiel #3
0
 public static void InstallGame(CGame game)
 {
     if (OperatingSystem.IsWindows())
     {
         CDock.StartShellExecute(START_GAME + "/" + GetGameID(game.ID));
     }
     else
     {
         Process.Start(START_GAME + "/" + GetGameID(game.ID));
     }
 }
Beispiel #4
0
 public static void Launch()
 {
     if (OperatingSystem.IsWindows())
     {
         CDock.StartShellExecute(PROTOCOL);
     }
     else
     {
         Process.Start(PROTOCOL);
     }
 }
Beispiel #5
0
 public static void InstallGame(CGame game)
 {
     CDock.DeleteCustomImage(game.Title);
     if (OperatingSystem.IsWindows())
     {
         CDock.StartShellExecute(INSTALL_GAME + "/" + GetGameID(game.ID));
     }
     else
     {
         Process.Start(INSTALL_GAME + "/" + GetGameID(game.ID));
     }
 }
Beispiel #6
0
 // return value
 // -1 = not implemented
 // 0 = failure
 // 1 = success
 public static int InstallGame(CGame game)
 {
     CDock.DeleteCustomImage(game.Title);
     if (OperatingSystem.IsWindows())
     {
         CDock.StartShellExecute(START_GAME + game.ID);
     }
     else
     {
         Process.Start(START_GAME + game.ID);
     }
     return(1);
 }
Beispiel #7
0
        [STAThread]         // Requirement for Shell32.Shell COM object
        static void Main(string[] args)
        {
#if DEBUG
            // Log unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Logger.CLogger.ExceptionHandleEvent);
#endif
            Logger.CLogger.Configure("GameLauncherConsole.log");             // Create a log file

            // Allow for unicode characters, such as trademark symbol
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            CDock gameDock = new CDock();
            gameDock.MainLoop();
        }
Beispiel #8
0
        // return value
        // -1 = not implemented
        // 0 = failure
        // 1 = success
        public static int InstallGame(CGame game)
        {
            //CDock.DeleteCustomImage(game.Title);
            //bool useEGL = (bool)CConfig.GetConfigBool(CConfig.CFG_USEEGL);
            bool   useLeg  = (bool)CConfig.GetConfigBool(CConfig.CFG_USELEG);
            string pathLeg = CConfig.GetConfigString(CConfig.CFG_PATHLEG);

            if (string.IsNullOrEmpty(pathLeg))
            {
                useLeg = false;
            }
            if (!pathLeg.Contains(@"\") && !pathLeg.Contains("/"))             // legendary.exe in current directory
            {
                pathLeg = Path.Combine(Directory.GetCurrentDirectory(), pathLeg);
            }

            if (useLeg && File.Exists(pathLeg))
            {
                if (OperatingSystem.IsWindows())
                {
                    CLogger.LogInfo($"Launch: cmd.exe /c \"" + pathLeg + "\" -y install " + game.ID);
                    CDock.StartAndRedirect("cmd.exe", "/c '\"" + pathLeg + "\" -y install " + game.ID);
                }
                else
                {
                    CLogger.LogInfo($"Launch: " + pathLeg + " -y install " + game.ID);
                    Process.Start(pathLeg, "-y install " + game.ID);
                }
                return(1);
            }
            else             //if (useEGL)
            {
                if (OperatingSystem.IsWindows())
                {
                    CDock.StartShellExecute(START_GAME + game.ID + INSTALL_GAME_ARGS);
                }
                else
                {
                    Process.Start(START_GAME + game.ID + INSTALL_GAME_ARGS);
                }
                return(1);
            }
            //return 0;
        }
Beispiel #9
0
 public static void Launch()
 {
     if (OperatingSystem.IsWindows())
     {
         using RegistryKey key = Registry.LocalMachine.OpenSubKey(IG_REG, RegistryKeyPermissionCheck.ReadSubTree); // HKLM64
         Process igcProcess   = new();
         string  launcherPath = Path.Combine(GetRegStrVal(key, GAME_INSTALL_LOCATION), "IGClient.exe");
         if (File.Exists(launcherPath))
         {
             CDock.StartAndRedirect(launcherPath);
         }
         else
         {
             //SetFgColour(cols.errorCC, cols.errorLtCC);
             CLogger.LogWarn("Cannot start {0} launcher.", _name.ToUpper());
             Console.WriteLine("ERROR: Launcher couldn't start. Is it installed properly?");
             //Console.ResetColor();
         }
     }
 }
Beispiel #10
0
 // Can't call PROTOCOL directly as itch is launched in command line mode, and StartInfo.Redirect* don't work when ShellExecute=True
 public static void Launch()
 {
     if (OperatingSystem.IsWindows())
     {
         using RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"itch\shell\open\command", RegistryKeyPermissionCheck.ReadSubTree);
         string   value   = GetRegStrVal(key, null);
         string[] subs    = value.Split();
         string   command = "";
         string   args    = "";
         for (int i = 0; i < subs.Length; i++)
         {
             if (i > 0)
             {
                 args += subs[i];
             }
             else
             {
                 command = subs[0];
             }
         }
         CDock.StartAndRedirect(command, args.Replace("%1", LAUNCH));
     }
 }
Beispiel #11
0
        // return value
        // -1 = not implemented
        // 0 = failure
        // 1 = success
        public static int InstallGame(CGame game)
        {
            /*
             * // Some games don't provide a valid ID
             * if (game.ID.StartsWith(PlatformUplay.UPLAY_PREFIX))
             * {
             */
            //CDock.DeleteCustomImage(game.Title);
            if (OperatingSystem.IsWindows())
            {
                CDock.StartShellExecute(START_GAME + GetGameID(game.ID));
            }
            else
            {
                Process.Start(START_GAME + GetGameID(game.ID));
            }
            return(1);

            /*
             * }
             * else return 0;
             */
        }
Beispiel #12
0
 public static void InstallGame(CGame game)
 {
     CDock.DeleteCustomImage(game.Title);
     Launch();
 }
Beispiel #13
0
        public void GetGames(List <ImportGameData> gameDataList, bool expensiveIcons = false)
        {
            List <string> igcIds      = new();
            string        strPlatform = GetPlatformString(ENUM);

            // Get installed games
            string file = Path.Combine(GetFolderPath(SpecialFolder.ApplicationData), IG_JSON);

            if (!File.Exists(file))
            {
                CLogger.LogInfo("{0} installed games not found in AppData", _name.ToUpper());
                return;
            }
            else
            {
                string strDocumentData = File.ReadAllText(file);

                if (string.IsNullOrEmpty(strDocumentData))
                {
                    CLogger.LogWarn(string.Format("Malformed {0} file: {1}", _name.ToUpper(), file));
                }
                else
                {
                    try
                    {
                        using JsonDocument document = JsonDocument.Parse(@strDocumentData, jsonTrailingCommas);
                        foreach (JsonElement element in document.RootElement.EnumerateArray())
                        {
                            string strID     = "";
                            string strTitle  = "";
                            string strLaunch = "";
                            string strAlias  = "";

                            element.TryGetProperty("target", out JsonElement target);
                            if (!target.Equals(null))
                            {
                                target.TryGetProperty("item_data", out JsonElement item);
                                if (!item.Equals(null))
                                {
                                    strID = GetStringProperty(item, "id_key_name");
                                    igcIds.Add(strID);
                                    strTitle = GetStringProperty(item, "name");
                                }
                            }
                            element.TryGetProperty("path", out JsonElement paths);
                            if (!paths.Equals(null))
                            {
                                foreach (JsonElement path in paths.EnumerateArray())
                                {
                                    strLaunch = CGameFinder.FindGameBinaryFile(path.ToString(), strTitle);
                                }
                            }

                            CLogger.LogDebug($"- {strTitle}");

                            if (!string.IsNullOrEmpty(strLaunch))
                            {
                                strAlias = GetAlias(Path.GetFileNameWithoutExtension(strLaunch));
                                if (strAlias.Length > strTitle.Length)
                                {
                                    strAlias = GetAlias(strTitle);
                                }
                                if (strAlias.Equals(strTitle, CDock.IGNORE_CASE))
                                {
                                    strAlias = "";
                                }
                                gameDataList.Add(new ImportGameData(strID, strTitle, strLaunch, strLaunch, "", strAlias, true, strPlatform));
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        CLogger.LogError(e, string.Format("Malformed {0} file: {1}", _name.ToUpper(), file));
                    }
                }
            }

            // Get not-installed games
            if (!(bool)CConfig.GetConfigBool(CConfig.CFG_INSTONLY))
            {
                file = Path.Combine(GetFolderPath(SpecialFolder.ApplicationData), IG_OWN_JSON);
                if (!File.Exists(file))
                {
                    CLogger.LogInfo("{0} not-installed games not found in AppData", _name.ToUpper());
                }
                else
                {
                    CLogger.LogDebug("{0} not-installed games:", _name.ToUpper());

                    string strDocumentData = File.ReadAllText(file);

                    if (string.IsNullOrEmpty(strDocumentData))
                    {
                        CLogger.LogWarn(string.Format("Malformed {0} file: {1}", _name.ToUpper(), file));
                    }
                    else
                    {
                        try
                        {
                            using JsonDocument document = JsonDocument.Parse(@strDocumentData, jsonTrailingCommas);
                            bool        exists = false;
                            bool        found  = false;
                            JsonElement coll   = new();
                            document.RootElement.TryGetProperty("gala_data", out JsonElement gData);
                            if (!gData.Equals(null))
                            {
                                gData.TryGetProperty("data", out JsonElement data);
                                if (!data.Equals(null))
                                {
                                    data.TryGetProperty("showcase_content", out JsonElement sContent);
                                    if (!sContent.Equals(null))
                                    {
                                        sContent.TryGetProperty("content", out JsonElement content);
                                        if (!content.Equals(null))
                                        {
                                            content.TryGetProperty("user_collection", out coll);
                                            if (!coll.Equals(null))
                                            {
                                                exists = true;
                                            }
                                        }
                                    }
                                }
                            }

                            if (exists)
                            {
                                foreach (JsonElement prod in coll.EnumerateArray())
                                {
                                    string strID = GetStringProperty(prod, "prod_id_key_name");
                                    if (!string.IsNullOrEmpty(strID))
                                    {
                                        foreach (string id in igcIds)
                                        {
                                            if (id.Equals(strID))
                                            {
                                                found = true;
                                            }
                                        }
                                        if (!found)
                                        {
                                            string strTitle = GetStringProperty(prod, "prod_name");
                                            CLogger.LogDebug($"- *{strTitle}");
                                            gameDataList.Add(new ImportGameData(strID, strTitle, "", "", "", "", false, strPlatform));

                                            // Use prod_dev_image to download not-installed icons
                                            if (!(bool)(CConfig.GetConfigBool(CConfig.CFG_IMGDOWN)))
                                            {
                                                string devName = GetStringProperty(prod, "prod_dev_namespace");
                                                string image   = GetStringProperty(prod, "prod_dev_image");
                                                if (!string.IsNullOrEmpty(devName) && !string.IsNullOrEmpty(image))
                                                {
                                                    string iconUrl = $"https://www.indiegalacdn.com/imgs/devs/{devName}/products/{strID}/prodmain/{image}";
                                                    CDock.DownloadCustomImage(strTitle, iconUrl);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            CLogger.LogError(e, string.Format("Malformed {0} file: {1}", _name.ToUpper(), file));
                        }
                    }
                }
            }
            CLogger.LogDebug("--------------------");
        }
Beispiel #14
0
        public void GetGames(List <ImportGameData> gameDataList, bool expensiveIcons = false)
        {
            List <RegistryKey> keyList;

            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(BIGFISH_GAMES, RegistryKeyPermissionCheck.ReadSubTree))             // HKLM32
            {
                if (key == null)
                {
                    CLogger.LogInfo("{0} client not found in the registry.", _name.ToUpper());
                    return;
                }

                keyList = FindGameFolders(key, "");

                CLogger.LogInfo("{0} {1} games found", keyList.Count > 1 ? keyList.Count - 1 : keyList.Count, _name.ToUpper());
                foreach (var data in keyList)
                {
                    string wrap = Path.GetFileName(data.Name);
                    if (wrap.Equals(BIGFISH_CASINO_ID))                      // hide Big Fish Casino Activator
                    {
                        continue;
                    }

                    string strID        = "bfg_" + wrap;
                    string strTitle     = "";
                    string strLaunch    = "";
                    string strIconPath  = "";
                    string strUninstall = "";
                    string strAlias     = "";
                    string strPlatform  = GetPlatformString(ENUM);
                    try
                    {
                        //found = true;
                        bool isInstalled = false;
                        strTitle = GetRegStrVal(data, "Name");

                        // If this is an expired trial, count it as not-installed
                        int activated = (int)GetRegDWORDVal(data, "Activated");
                        int daysLeft  = (int)GetRegDWORDVal(data, "DaysLeft");
                        int timeLeft  = (int)GetRegDWORDVal(data, "TimeLeft");
                        if (activated > 0 || timeLeft > 0 || daysLeft > 0)
                        {
                            isInstalled = true;
                            CLogger.LogDebug($"- {strTitle}");
                        }
                        else
                        {
                            CLogger.LogDebug($"- *{strTitle}");
                        }

                        strLaunch = GetRegStrVal(data, BIGFISH_PATH);
                        strAlias  = GetAlias(strTitle);
                        if (strAlias.Equals(strTitle, CDock.IGNORE_CASE))
                        {
                            strAlias = "";
                        }
                        //strIconPath = GetRegStrVal(data, "Thumbnail");	// 80x80
                        strIconPath = GetRegStrVal(data, "feature");                                // 175x150

                        //ushort userRating = (ushort)GetRegDWORDVal(data, "Rating"); // Not used?
                        uint     numberRuns = (uint)GetRegDWORDVal(data, "PlayCount");
                        byte[]   dateData   = GetRegBinaryVal(data, "LastActionTime");
                        DateTime lastRun    = BFRegToDateTime(dateData);
                        //CLogger.LogDebug("    LastActionTime: " + BitConverter.ToString(dateData) + " -> " + lastRun.ToShortDateString());

                        List <RegistryKey> unKeyList;
                        using (RegistryKey key2 = Registry.LocalMachine.OpenSubKey(NODE32_REG, RegistryKeyPermissionCheck.ReadSubTree))                         // HKLM32
                        {
                            if (key2 != null)
                            {
                                unKeyList = FindGameFolders(key2, BIGFISH_PREFIX);
                                foreach (var data2 in unKeyList)
                                {
                                    if (GetRegStrVal(data2, BIGFISH_ID).Equals(wrap))
                                    {
                                        if (string.IsNullOrEmpty(strIconPath))
                                        {
                                            strIconPath = GetRegStrVal(data2, GAME_DISPLAY_ICON).Trim(new char[] { ' ', '"' });
                                        }
                                        strUninstall = GetRegStrVal(data2, GAME_UNINSTALL_STRING).Trim(new char[] { ' ', '"' });
                                    }
                                }
                            }
                        }
                        if (string.IsNullOrEmpty(strIconPath) && expensiveIcons)
                        {
                            bool   success = false;
                            string dir     = Path.GetDirectoryName(strLaunch);
                            string xmlPath = Path.Combine(dir, "bfgstate.xml");
                            try
                            {
                                if (File.Exists(xmlPath))
                                {
                                    XmlDocument doc = new();
                                    doc.Load(xmlPath);
                                    //XmlNode node = doc.DocumentElement.SelectSingleNode("thumbnail");	// 80x80
                                    XmlNode node = doc.DocumentElement.SelectSingleNode("feature");                                             // 175x150
                                    if (node != null)
                                    {
                                        strIconPath = node.InnerText;
                                        if (File.Exists(strIconPath))
                                        {
                                            success = true;
                                        }
                                        else
                                        {
                                            // Use website to download missing icons
                                            if (!(bool)(CConfig.GetConfigBool(CConfig.CFG_IMGDOWN)))
                                            {
                                                if (CDock.DownloadCustomImage(strTitle, GetIconUrl(GetGameID(strID), strTitle)))
                                                {
                                                    success = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                CLogger.LogError(e);
                            }
                            if (!success)
                            {
                                strIconPath = CGameFinder.FindGameBinaryFile(dir, strTitle);
                            }
                        }
                        if (!(string.IsNullOrEmpty(strLaunch)))
                        {
                            gameDataList.Add(
                                new ImportGameData(strID, strTitle, strLaunch, strIconPath, strUninstall, strAlias, isInstalled, strPlatform, dateLastRun: lastRun, numRuns: numberRuns));
                        }
                    }
                    catch (Exception e)
                    {
                        CLogger.LogError(e);
                    }
                }
            }
            CLogger.LogDebug("------------------------");
        }
Beispiel #15
0
        public void GetGames(List <ImportGameData> gameDataList, bool expensiveIcons = false)
        {
            // Get installed games
            string db = Path.Combine(GetFolderPath(SpecialFolder.ApplicationData), ITCH_DB);

            if (!File.Exists(db))
            {
                CLogger.LogInfo("{0} database not found.", _name.ToUpper());
                return;
            }

            try
            {
                using var con = new SQLiteConnection($"Data Source={db}");
                con.Open();

                // Get both installed and not-installed games

                using (var cmd = new SQLiteCommand("SELECT id, title, classification, cover_url, still_cover_url FROM games;", con))
                    using (SQLiteDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            if (!rdr.GetString(2).Equals("assets")) // i.e., just "game" or "tool"
                            {
                                int      id          = rdr.GetInt32(0);
                                string   strID       = $"itch_{id}";
                                string   strTitle    = rdr.GetString(1);
                                string   strAlias    = "";
                                string   strLaunch   = "";
                                string   strPlatform = GetPlatformString(ENUM);
                                DateTime lastRun     = DateTime.MinValue;

                                string iconUrl = rdr.GetString(4);
                                if (string.IsNullOrEmpty(iconUrl))
                                {
                                    iconUrl = rdr.GetString(3);
                                }

                                // SELECT path FROM install_locations;
                                // SELECT install_folder FROM downloads;
                                using (var cmd2 = new SQLiteCommand($"SELECT installed_at, last_touched_at, verdict, install_folder_name FROM caves WHERE game_id = {id};", con))
                                    using (SQLiteDataReader rdr2 = cmd2.ExecuteReader())
                                    {
                                        while (rdr2.Read())
                                        {
                                            if (!rdr2.IsDBNull(1))
                                            {
                                                lastRun = rdr2.GetDateTime(1);
                                                //CLogger.LogDebug("    last_touched_at: " + rdr2.GetString(1) + " -> " + lastRun.ToShortDateString());
                                            }
                                            //else if (!rdr2.IsDBNull(0))
                                            //    lastRun = rdr2.GetDateTime(0);
                                            string verdict = rdr2.GetString(2);
                                            //strAlias = rdr2.GetString(3);
                                            strAlias = GetAlias(strTitle);
                                            if (strAlias.Equals(strTitle, CDock.IGNORE_CASE))
                                            {
                                                strAlias = "";
                                            }

                                            using JsonDocument document = JsonDocument.Parse(@verdict, jsonTrailingCommas);
                                            string basePath = GetStringProperty(document.RootElement, "basePath");
                                            if (document.RootElement.TryGetProperty("candidates", out JsonElement candidates) && !string.IsNullOrEmpty(candidates.ToString()))
                                            {
                                                foreach (JsonElement jElement in candidates.EnumerateArray())
                                                {
                                                    strLaunch = string.Format("{0}\\{1}", basePath, GetStringProperty(jElement, "path"));
                                                }
                                            }
                                            // Add installed games
                                            if (!string.IsNullOrEmpty(strLaunch))
                                            {
                                                CLogger.LogDebug($"- {strTitle}");
                                                gameDataList.Add(new ImportGameData(strID, strTitle, strLaunch, strLaunch, "", strAlias, true, strPlatform, dateLastRun: lastRun));

                                                // Use still_cover_url, or cover_url if it doesn't exist, to download missing icons
                                                if (!(bool)(CConfig.GetConfigBool(CConfig.CFG_IMGDOWN)) &&
                                                    !Path.GetExtension(strLaunch).Equals(".exe", CDock.IGNORE_CASE))
                                                {
                                                    CDock.DownloadCustomImage(strTitle, iconUrl);
                                                }
                                            }
                                        }
                                    }
                                // Add not-installed games
                                if (string.IsNullOrEmpty(strLaunch) && !(bool)CConfig.GetConfigBool(CConfig.CFG_INSTONLY))
                                {
                                    CLogger.LogDebug($"- *{strTitle}");
                                    gameDataList.Add(new ImportGameData(strID, strTitle, "", "", "", "", false, strPlatform));

                                    // Use still_cover_url, or cover_url if it doesn't exist, to download not-installed icons
                                    if (!(bool)(CConfig.GetConfigBool(CConfig.CFG_IMGDOWN)))
                                    {
                                        CDock.DownloadCustomImage(strTitle, iconUrl);
                                    }
                                }
                            }
                        }
                    }
                con.Close();
            }
            catch (Exception e)
            {
                CLogger.LogError(e, string.Format("Malformed {0} database output!", _name.ToUpper()));
            }
            CLogger.LogDebug("-------------------");
        }
Beispiel #16
0
 // return value
 // -1 = not implemented
 // 0 = failure
 // 1 = success
 public static int InstallGame(CGame game)
 {
     CDock.DeleteCustomImage(game.Title);
     Launch();
     return(-1);
 }
Beispiel #17
0
        // return value
        // -1 = not implemented
        // 0 = failure
        // 1 = success
        public static int UninstallGame(CGame game)
        {
            //bool useEGL = (bool)CConfig.GetConfigBool(CConfig.CFG_USEEGL);
            bool   useLeg  = (bool)CConfig.GetConfigBool(CConfig.CFG_USELEG);
            string pathLeg = CConfig.GetConfigString(CConfig.CFG_PATHLEG);

            if (string.IsNullOrEmpty(pathLeg))
            {
                useLeg = false;
            }
            if (!pathLeg.Contains(@"\") && !pathLeg.Contains("/"))             // legendary.exe in current directory
            {
                pathLeg = Path.Combine(Directory.GetCurrentDirectory(), pathLeg);
            }
            if (useLeg && File.Exists(pathLeg))
            {
                //Process ps;
                if (OperatingSystem.IsWindows())
                {
                    CLogger.LogInfo("Launch: cmd.exe /c \"" + pathLeg + "\" -y uninstall " + game.ID);
                    CDock.StartAndRedirect("cmd.exe", "/c \"" + pathLeg + "\" -y uninstall " + game.ID);
                }
                else
                {
                    CLogger.LogInfo("Launch: " + pathLeg + " -y uninstall " + game.ID);
                    Process.Start(pathLeg, "-y uninstall " + game.ID);
                }

                /*
                 * ps.WaitForExit(30000);
                 * if (ps.ExitCode == 0)
                 */
                return(1);
            }

            /*
             * else if (useEGL)
             * {
             *      Launch();
             *      return -1;
             * }
             */
            else if (!string.IsNullOrEmpty(game.Uninstaller))
            {
                // delete Desktop icon
                File.Delete(Path.Combine(GetFolderPath(SpecialFolder.Desktop), game.Title + ".lnk"));
                string[] un = game.Uninstaller.Split(';');

                // delete manifest file
                if (un.Length > 1 && !string.IsNullOrEmpty(un[1]) && un[1].EndsWith(".item"))
                {
                    File.Delete(Path.Combine(GetFolderPath(SpecialFolder.CommonApplicationData), EPIC_ITEMS, un[1]));
                }

                if (un.Length > 0 && !string.IsNullOrEmpty(un[0]) && !un[0].EndsWith(".item"))
                {
                    DirectoryInfo rootDir = new(un[0]);
                    if (rootDir.Exists)
                    {
                        /*
                         * foreach (DirectoryInfo dir in rootDir.EnumerateDirectories())
                         *      dir.Delete(true);
                         * foreach (FileInfo file in rootDir.EnumerateFiles())
                         *      file.Delete();
                         */
                        rootDir.Delete(true);
                        return(1);
                    }
                }
            }
            return(0);
        }
Beispiel #18
0
        public void GetGames(List <ImportGameData> gameDataList, bool expensiveIcons = false)
        {
            List <string> azIds       = new();
            string        strPlatform = GetPlatformString(ENUM);

            // Get installed games
            string db = Path.Combine(GetFolderPath(SpecialFolder.LocalApplicationData), AMAZON_DB);

            if (!File.Exists(db))
            {
                CLogger.LogInfo("{0} installed game database not found.", _name.ToUpper());
                //return;
            }

            try
            {
                using SQLiteConnection con = new($"Data Source={db}");
                con.Open();

                using SQLiteCommand cmd    = new("SELECT Id, InstallDirectory, ProductTitle FROM DbSet;", con);
                using SQLiteDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    string dir   = rdr.GetString(1);
                    string strID = rdr.GetString(0);
                    azIds.Add(strID);
                    string strTitle = rdr.GetString(2);
                    CLogger.LogDebug($"- {strTitle}");
                    string strLaunch    = START_GAME + strID;
                    string strIconPath  = "";
                    string strUninstall = "";

                    using (RegistryKey key = Registry.CurrentUser.OpenSubKey(Path.Combine(NODE64_REG, "AmazonGames", strTitle), RegistryKeyPermissionCheck.ReadSubTree))
                    {
                        if (key != null)
                        {
                            strIconPath  = GetRegStrVal(key, "DisplayIcon");
                            strUninstall = GetRegStrVal(key, "UninstallString");
                        }
                    }
                    if (string.IsNullOrEmpty(strIconPath))
                    {
                        if (expensiveIcons)
                        {
                            bool   success  = false;
                            string fuelPath = Path.Combine(dir, "fuel.json");
                            if (File.Exists(fuelPath))
                            {
                                string strDocumentData = File.ReadAllText(fuelPath);

                                if (!string.IsNullOrEmpty(strDocumentData))
                                {
                                    using JsonDocument document = JsonDocument.Parse(@strDocumentData, jsonTrailingCommas);
                                    document.RootElement.TryGetProperty("Main", out JsonElement main);
                                    if (!main.Equals(null))
                                    {
                                        string iconFile = GetStringProperty(main, "Command");
                                        if (!string.IsNullOrEmpty(strIconPath))
                                        {
                                            strIconPath = Path.Combine(dir, iconFile);
                                            success     = true;
                                        }
                                    }
                                }
                            }
                            if (!success)
                            {
                                strIconPath = CGameFinder.FindGameBinaryFile(dir, strTitle);
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(strUninstall))
                    {
                        strUninstall = Path.Combine(Directory.GetParent(dir).FullName, UNINST_GAME) + " " + UNINST_GAME_ARGS + " " + strID;
                    }
                    string strAlias = GetAlias(strTitle);

                    if (!string.IsNullOrEmpty(strLaunch))
                    {
                        if (strAlias.Equals(strTitle, CDock.IGNORE_CASE))
                        {
                            strAlias = "";
                        }
                        gameDataList.Add(new ImportGameData(strID, strTitle, strLaunch, strIconPath, strUninstall, strAlias, true, strPlatform));
                    }
                }
                con.Close();
            }
            catch (Exception e)
            {
                CLogger.LogError(e, string.Format("Malformed {0} database output!", _name.ToUpper()));
            }

            // Get not-installed games
            if (!(bool)CConfig.GetConfigBool(CConfig.CFG_INSTONLY))
            {
                db = Path.Combine(GetFolderPath(SpecialFolder.LocalApplicationData), AMAZON_OWN_DB);
                if (!File.Exists(db))
                {
                    CLogger.LogInfo("{0} not-installed game database not found.", _name.ToUpper());
                }
                else
                {
                    CLogger.LogDebug("{0} not-installed games:", _name.ToUpper());
                    try
                    {
                        using SQLiteConnection con = new($"Data Source={db}");
                        con.Open();

                        using SQLiteCommand cmd    = new("SELECT Id, ProductIconUrl, ProductIdStr, ProductTitle FROM DbSet;", con);
                        using SQLiteDataReader rdr = cmd.ExecuteReader();
                        while (rdr.Read())
                        {
                            bool   found = false;
                            string strID = rdr.GetString(2); // TODO: Should I use Id or ProductIdStr?
                            foreach (string id in azIds)
                            {
                                if (id.Equals(strID))
                                {
                                    found = true;
                                }
                            }
                            if (!found)
                            {
                                string strTitle = rdr.GetString(3);
                                CLogger.LogDebug($"- *{strTitle}");
                                gameDataList.Add(new ImportGameData(strID, strTitle, "", "", "", "", false, strPlatform));

                                // Use ProductIconUrl to download not-installed icons
                                if (!(bool)(CConfig.GetConfigBool(CConfig.CFG_IMGDOWN)))
                                {
                                    string iconUrl = rdr.GetString(1);
                                    CDock.DownloadCustomImage(strTitle, iconUrl);
                                }
                            }
                        }
                        con.Close();
                    }
                    catch (Exception e)
                    {
                        CLogger.LogError(e, string.Format("Malformed {0} database output!", _name.ToUpper()));
                    }
                }
            }
            CLogger.LogDebug("-------------------");
        }
Beispiel #19
0
        public void GetGames(List <ImportGameData> gameDataList, bool expensiveIcons = false)
        {
            List <string> epicIds     = new();
            string        strPlatform = GetPlatformString(ENUM);
            string        dir         = Path.Combine(GetFolderPath(SpecialFolder.CommonApplicationData), EPIC_ITEMS);

            if (!Directory.Exists(dir))
            {
                CLogger.LogInfo("{0} games not found in ProgramData.", _name.ToUpper());
                return;
            }
            string[] files = Directory.GetFiles(dir, "*.item", SearchOption.TopDirectoryOnly);
            CLogger.LogInfo("{0} {1} games found", files.Length, _name.ToUpper());

            foreach (string file in files)
            {
                string strDocumentData = File.ReadAllText(file);

                if (string.IsNullOrEmpty(strDocumentData))
                {
                    continue;
                }

                try
                {
                    using JsonDocument document = JsonDocument.Parse(@strDocumentData, jsonTrailingCommas);
                    string strID = GetStringProperty(document.RootElement, "AppName");
                    if (string.IsNullOrEmpty(strID))
                    {
                        strID = Path.GetFileName(file);
                    }
                    string strTitle = GetStringProperty(document.RootElement, "DisplayName");
                    CLogger.LogDebug($"- {strTitle}");
                    string strLaunch    = GetStringProperty(document.RootElement, "LaunchExecutable");                  // DLCs won't have this set
                    string strUninstall = "";
                    string strAlias     = "";

                    if (!string.IsNullOrEmpty(strLaunch))
                    {
                        epicIds.Add(strID);
                        strUninstall  = GetStringProperty(document.RootElement, "InstallLocation");
                        strLaunch     = Path.Combine(strUninstall, strLaunch);
                        strUninstall += ";" + Path.GetFileName(file);
                        // rather than an uninstaller like most platforms, for Epic, strUninstall holds two fields: the install location and the manifest file
                        strAlias = GetAlias(GetStringProperty(document.RootElement, "MandatoryAppFolderName"));
                        if (strAlias.Length > strTitle.Length)
                        {
                            strAlias = GetAlias(strTitle);
                        }
                        if (strAlias.Equals(strTitle, CDock.IGNORE_CASE))
                        {
                            strAlias = "";
                        }
                        gameDataList.Add(new ImportGameData(strID, strTitle, strLaunch, strLaunch, strUninstall, strAlias, true, strPlatform));
                    }
                }
                catch (Exception e)
                {
                    CLogger.LogError(e, string.Format("Malformed {0} file: {1}", _name.ToUpper(), file));
                }
            }

            // Get not-installed games (requires Legendary)
            if (!(bool)CConfig.GetConfigBool(CConfig.CFG_INSTONLY))
            {
                bool   useLeg  = (bool)CConfig.GetConfigBool(CConfig.CFG_USELEG);
                string pathLeg = CConfig.GetConfigString(CConfig.CFG_PATHLEG);
                if (string.IsNullOrEmpty(pathLeg))
                {
                    useLeg = false;
                }
                if (!pathLeg.Contains(@"\") && !pathLeg.Contains("/"))                 // legendary.exe in current directory
                {
                    pathLeg = Path.Combine(Directory.GetCurrentDirectory(), pathLeg);
                }

                if (useLeg && File.Exists(pathLeg))
                {
                    try
                    {
                        Process ps;
                        string  tmpfile = $"tmp_{_name}.json";
                        string  errfile = $"tmp_{_name}.err";
                        if (OperatingSystem.IsWindows())
                        {
                            CLogger.LogInfo("Launch: cmd.exe /c \"" + pathLeg + "\" list --json 1> " + tmpfile + " 2> " + errfile);
                            ps = CDock.StartAndRedirect("cmd.exe", "/c \"" + pathLeg + "\" list --json 1> " + tmpfile + " 2> " + errfile);
                        }
                        else
                        {
                            CLogger.LogInfo("Launch: " + pathLeg + " list 1> " + tmpfile + " 2> " + errfile);
                            ps = Process.Start(pathLeg, "list 1> " + tmpfile + " 2> " + errfile);
                        }
                        ps.WaitForExit(30000);
                        if (File.Exists(tmpfile))
                        {
                            if (ps.ExitCode != 0)
                            {
                                if (File.Exists(errfile))
                                {
                                    string strErrorData = File.ReadAllText(errfile);
                                    if (!string.IsNullOrEmpty(strErrorData))
                                    {
                                        using StreamReader reader = new(errfile);
                                        string line;
                                        while ((line = reader.ReadLine()) != null)
                                        {
                                            if (line.Trim().EndsWith("No saved credentials"))
                                            {
                                                CLogger.LogInfo("Error getting not-installed {0} games. Is Legendary authenticated?\n" +
                                                                $"To login, enter: \"{pathLeg}\" auth",
                                                                _name.ToUpper());
                                            }
                                        }
                                    }
                                }
                            }

                            string strDocumentData = File.ReadAllText(tmpfile);
                            if (!string.IsNullOrEmpty(strDocumentData))
                            {
                                CLogger.LogDebug("{0} not-installed games:", _name.ToUpper());
                                using JsonDocument document = JsonDocument.Parse(@strDocumentData, jsonTrailingCommas);
                                foreach (JsonElement element in document.RootElement.EnumerateArray())
                                {
                                    string strID = GetStringProperty(element, "app_name");
                                    if (epicIds.Contains(strID))                                     // Check if game is already installed
                                    {
                                        continue;
                                    }
                                    string strTitle = GetStringProperty(element, "app_title");
                                    CLogger.LogDebug($"- *{strTitle}");
                                    string strAlias = GetAlias(strTitle);
                                    if (strAlias.Equals(strTitle, CDock.IGNORE_CASE))
                                    {
                                        strAlias = "";
                                    }
                                    gameDataList.Add(new ImportGameData(strID, strTitle, "", "", "", strAlias, false, strPlatform));
                                }
                            }
#if !DEBUG
                            File.Delete(tmpfile);
                            File.Delete(errfile);
#endif
                        }
                        else
                        {
                            CLogger.LogInfo("Can't get not-installed {0} games. Error running Legendary.",
                                            _name.ToUpper());
                        }
                    }
                    catch (Exception e)
                    {
                        CLogger.LogError(e, string.Format("Malformed {0} output.", _name.ToUpper()));
                    }
                }
                else
                {
                    CLogger.LogInfo("Can't get not-installed {0} games. Legendary must be installed.\n" +
                                    "Go to <https://legendary.gl/release/latest>.",
                                    _name.ToUpper());
                }
            }

            CLogger.LogDebug("--------------------");
        }
Beispiel #20
0
        public void GetGames(List <ImportGameData> gameDataList, bool expensiveIcons = false)
        {
            string strInstallPath = "";
            string strClientPath  = "";

            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(STEAM_REG, RegistryKeyPermissionCheck.ReadSubTree))             // HKLM32
            {
                if (key == null)
                {
                    CLogger.LogInfo("{0} client not found in the registry.", _name.ToUpper());
                    return;
                }

                strInstallPath = GetRegStrVal(key, GAME_INSTALL_PATH);
                strClientPath  = Path.Combine(strInstallPath, STEAM_PATH);
            }

            if (!Directory.Exists(strClientPath))
            {
                CLogger.LogInfo("{0} library not found: {1}", _name.ToUpper(), strClientPath);
                return;
            }

            string        libFile = Path.Combine(strClientPath, STEAM_LIBFILE);
            List <string> libs    = new()
            {
                strClientPath
            };
            int nLibs = 1;

            try
            {
                if (File.Exists(libFile))
                {
                    SteamWrapper document     = new(libFile);
                    ACF_Struct   documentData = document.ACFFileToStruct();
                    ACF_Struct   folders      = new();
                    if (documentData.SubACF.ContainsKey(STEAM_LIBARR))
                    {
                        folders = documentData.SubACF[STEAM_LIBARR];
                    }
                    else if (documentData.SubACF.ContainsKey(STEAM_LIBARR.ToLower()))
                    {
                        folders = documentData.SubACF[STEAM_LIBARR.ToLower()];
                    }
                    for (; nLibs <= STEAM_MAX_LIBS; ++nLibs)
                    {
                        folders.SubItems.TryGetValue(nLibs.ToString(), out string library);
                        if (string.IsNullOrEmpty(library))
                        {
                            if (folders.SubACF.ContainsKey(nLibs.ToString()))
                            {
                                folders.SubACF[nLibs.ToString()].SubItems.TryGetValue("path", out library);
                            }
                            if (string.IsNullOrEmpty(library))
                            {
                                nLibs--;
                                break;
                            }
                        }
                        library = Path.Combine(library, STEAM_PATH);
                        if (!library.Equals(strClientPath) && Directory.Exists(library))
                        {
                            libs.Add(library);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CLogger.LogError(e, string.Format("Malformed {0} file: {1}", _name.ToUpper(), libFile));
                nLibs--;
            }

            int           i        = 0;
            List <string> allFiles = new();

            foreach (string lib in libs)
            {
                List <string> libFiles = new();
                try
                {
                    libFiles = Directory.GetFiles(lib, "appmanifest_*.acf", SearchOption.TopDirectoryOnly).ToList();
                    allFiles.AddRange(libFiles);
                    CLogger.LogInfo("{0} {1} games found in library {2}", libFiles.Count, _name.ToUpper(), lib);
                }
                catch (Exception e)
                {
                    CLogger.LogError(e, string.Format("{0} directory read error: {1}", _name.ToUpper(), lib));
                    continue;
                }

                foreach (string file in libFiles)
                {
                    try
                    {
                        SteamWrapper document     = new(file);
                        ACF_Struct   documentData = document.ACFFileToStruct();
                        ACF_Struct   app          = documentData.SubACF["AppState"];

                        string id = app.SubItems["appid"];
                        if (id.Equals("228980"))                          // Steamworks Common Redistributables
                        {
                            continue;
                        }

                        string strID    = Path.GetFileName(file);
                        string strTitle = app.SubItems["name"];
                        CLogger.LogDebug($"- {strTitle}");
                        string strLaunch    = START_GAME + "/" + id;
                        string strIconPath  = "";
                        string strUninstall = "";
                        string strAlias     = "";
                        string strPlatform  = GetPlatformString(ENUM);

                        strAlias = GetAlias(strTitle);
                        if (!string.IsNullOrEmpty(strLaunch))
                        {
                            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(Path.Combine(NODE64_REG, STEAM_GAME_PREFIX + id), RegistryKeyPermissionCheck.ReadSubTree),                              // HKLM64
                                   key2 = Registry.LocalMachine.OpenSubKey(Path.Combine(NODE32_REG, STEAM_GAME_PREFIX + id), RegistryKeyPermissionCheck.ReadSubTree))                                         // HKLM32
                            {
                                if (key != null)
                                {
                                    strIconPath = GetRegStrVal(key, GAME_DISPLAY_ICON).Trim(new char[] { ' ', '"' });
                                }
                                else if (key2 != null)
                                {
                                    strIconPath = GetRegStrVal(key2, GAME_DISPLAY_ICON).Trim(new char[] { ' ', '"' });
                                }
                            }
                            if (string.IsNullOrEmpty(strIconPath) && expensiveIcons)
                            {
                                bool success = false;

                                // Search for an .exe to use as icon
                                strIconPath = CGameFinder.FindGameBinaryFile(Path.Combine(lib, "common", app.SubItems["installdir"]), strTitle);
                                if (!string.IsNullOrEmpty(strIconPath))
                                {
                                    success  = true;
                                    strAlias = GetAlias(Path.GetFileNameWithoutExtension(strIconPath));
                                    if (strAlias.Length > strTitle.Length)
                                    {
                                        strAlias = GetAlias(strTitle);
                                    }
                                }

                                if (!success && !(bool)(CConfig.GetConfigBool(CConfig.CFG_IMGDOWN)))
                                {
                                    // Download missing icons
                                    string iconUrl = $"https://cdn.cloudflare.steamstatic.com/steam/apps/{id}/capsule_184x69.jpg";
                                    if (CDock.DownloadCustomImage(strTitle, iconUrl))
                                    {
                                        success = true;
                                    }
                                }
                            }
                            if (strAlias.Equals(strTitle, CDock.IGNORE_CASE))
                            {
                                strAlias = "";
                            }
                            strUninstall = UNINST_GAME + "/" + id;
                            gameDataList.Add(new ImportGameData(strID, strTitle, strLaunch, strIconPath, strUninstall, strAlias, true, strPlatform));
                        }
                    }
                    catch (Exception e)
                    {
                        CLogger.LogError(e, string.Format("Malformed {0} file: {1}", _name.ToUpper(), file));
                    }
                }
                i++;

                /*
                 * if (i > nLibs)
                 *      CLogger.LogDebug("---------------------");
                 */
            }

            // Get not-installed games
            if (!(bool)CConfig.GetConfigBool(CConfig.CFG_INSTONLY))
            {
                // First get Steam user ID
                ulong userId = (ulong)CConfig.GetConfigULong(CConfig.CFG_STEAMID);

                if (userId < 1)
                {
                    try
                    {
                        ulong  userIdTmp     = 0;
                        string userName      = "";
                        string userNameTmp   = "";
                        string strConfigPath = Path.Combine(strInstallPath, "config");
                        string appFile       = Path.Combine(strConfigPath, STEAM_APPFILE);

                        if (File.Exists(appFile))
                        {
                            SteamWrapper appDoc     = new(appFile);
                            ACF_Struct   appDocData = appDoc.ACFFileToStruct();
                            ACF_Struct   appData    = appDocData.SubACF["SteamAppData"];

                            appData.SubItems.TryGetValue("AutoLoginUser", out userName);

                            SteamWrapper usrDoc     = new(Path.Combine(strConfigPath, STEAM_USRFILE));
                            ACF_Struct   usrDocData = usrDoc.ACFFileToStruct();
                            ACF_Struct   usrData    = usrDocData.SubACF["users"];

                            foreach (KeyValuePair <string, ACF_Struct> user in usrData.SubACF)
                            {
                                if (!ulong.TryParse(user.Key, out userIdTmp))
                                {
                                    userIdTmp = 0;
                                }

                                foreach (KeyValuePair <string, string> userVal in user.Value.SubItems)
                                {
                                    if (userVal.Key.Equals("AccountName"))
                                    {
                                        userNameTmp = userVal.Value;
                                        if (userNameTmp.Equals(userName))
                                        {
                                            if (!ulong.TryParse(user.Key, out userId))
                                            {
                                                userId = 0;
                                            }
                                        }
                                    }
                                    if (userVal.Key.Equals("MostRecent") && userVal.Value.Equals("1") && string.IsNullOrEmpty(userName))
                                    {
                                        userId   = userIdTmp;
                                        userName = userNameTmp;
                                        break;
                                    }
                                }
                            }
                            if (userId < 1)
                            {
                                userId   = userIdTmp;
                                userName = userNameTmp;
                            }
                        }
                        if (userId > 0)
                        {
                            CLogger.LogInfo("Setting default {0} user to {1} #{2}", _name.ToUpper(), userName, userId);
                            CConfig.SetConfigValue(CConfig.CFG_STEAMID, userId);
                            ExportConfig();
                        }
                    }
                    catch (Exception e)
                    {
                        CLogger.LogError(e, string.Format("Malformed {0} file: {1} or {2}", _name.ToUpper(), STEAM_APPFILE, STEAM_USRFILE));
                    }
                }

                if (userId > 0)
                {
                    // Download game list from public user profile
                    try
                    {
                        string url = string.Format("https://steamcommunity.com/profiles/{0}/games/?tab=all", userId);

                        /*
                         #if DEBUG
                         * // Don't re-download if file exists
                         * string tmpfile = $"tmp_{NAME}.html";
                         * if (!File.Exists(tmpfile))
                         * {
                         *      using (var client = new WebClient());
                         *      client.DownloadFile(url, tmpfile);
                         * }
                         * HtmlDocument doc = new HtmlDocument
                         * {
                         *      OptionUseIdAttribute = true
                         * };
                         * doc.Load(tmpfile);
                         #else
                         */
                        HtmlWeb web = new()
                        {
                            UseCookies = true
                        };
                        HtmlDocument doc = web.Load(url);
                        doc.OptionUseIdAttribute = true;
//#endif
                        HtmlNode gameList = doc.DocumentNode.SelectSingleNode("//script[@language='javascript']");
                        if (gameList != null)
                        {
                            CLogger.LogDebug("{0} not-installed games (user #{1}):", _name.ToUpper(), userId);

                            var options = new JsonDocumentOptions
                            {
                                AllowTrailingCommas = true
                            };
                            string rgGames = gameList.InnerText.Remove(0, gameList.InnerText.IndexOf('['));
                            rgGames = rgGames.Remove(rgGames.IndexOf(';'));

                            using JsonDocument document = JsonDocument.Parse(@rgGames, options);
                            foreach (JsonElement game in document.RootElement.EnumerateArray())
                            {
                                ulong id = GetULongProperty(game, "appid");
                                if (id > 0)
                                {
                                    // Check if game is already installed
                                    string strID = $"appmanifest_{id}.acf";
                                    bool   found = false;
                                    foreach (string file in allFiles)
                                    {
                                        if (file.EndsWith(strID))
                                        {
                                            found = true;
                                        }
                                    }
                                    if (!found)
                                    {
                                        string strTitle    = GetStringProperty(game, "name");
                                        string strPlatform = GetPlatformString(ENUM);

                                        // Add not-installed games
                                        CLogger.LogDebug($"- *{strTitle}");
                                        gameDataList.Add(new ImportGameData(strID, strTitle, "", "", "", "", false, strPlatform));

                                        // Use logo to download not-installed icons
                                        if (!(bool)(CConfig.GetConfigBool(CConfig.CFG_IMGDOWN)))
                                        {
                                            string iconUrl = GetStringProperty(game, "logo");
                                            CDock.DownloadCustomImage(strTitle, iconUrl);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            CLogger.LogInfo("Can't get not-installed {0} games. Profile may not be public.\n" +
                                            "To change this, go to <https://steamcommunity.com/my/edit/settings>.",
                                            _name.ToUpper());
                        }

                        /*
                         #if DEBUG
                         *      File.Delete(tmpfile);
                         #endif
                         */
                    }
                    catch (Exception e)
                    {
                        CLogger.LogError(e);
                    }
                    CLogger.LogDebug("---------------------");
                }
            }
        }
Beispiel #21
0
        public static void StartGame(CGame game)
        {
            bool   useEGL  = (bool)CConfig.GetConfigBool(CConfig.CFG_USEEGL);
            bool   useLeg  = (bool)CConfig.GetConfigBool(CConfig.CFG_USELEG);
            bool   syncLeg = (bool)CConfig.GetConfigBool(CConfig.CFG_SYNCLEG);
            string pathLeg = CConfig.GetConfigString(CConfig.CFG_PATHLEG);

            if (string.IsNullOrEmpty(pathLeg))
            {
                useLeg = false;
            }
            if (!pathLeg.Contains(@"\") && !pathLeg.Contains("/"))             // legendary.exe in current directory
            {
                pathLeg = Path.Combine(Directory.GetCurrentDirectory(), pathLeg);
            }

            if (useLeg && File.Exists(pathLeg))
            {
                if (OperatingSystem.IsWindows())
                {
                    string cmdLine = "\"" + pathLeg + "\" -y launch " + game.ID;
                    CLogger.LogInfo($"Launch: cmd.exe /c " + cmdLine);
                    if (syncLeg)
                    {
                        cmdLine = "\"" + pathLeg + "\" -y sync-saves " + game.ID + " & " + cmdLine + " & \"" + pathLeg + "\" -y sync-saves " + game.ID;
                    }
                    CDock.StartAndRedirect("cmd.exe", "/c '" + cmdLine + " '");
                }
                else
                {
                    CLogger.LogInfo($"Launch: " + pathLeg + " -y launch " + game.ID);
                    if (syncLeg)
                    {
                        Process.Start(pathLeg, "-y sync-saves " + game.ID);
                    }
                    Process.Start(pathLeg, "-y launch " + game.ID);
                    if (syncLeg)
                    {
                        Process.Start(pathLeg, "-y sync-saves " + game.ID);
                    }
                }
            }
            else if (useEGL)
            {
                if (OperatingSystem.IsWindows())
                {
                    CDock.StartShellExecute(START_GAME + game.ID + START_GAME_ARGS);
                }
                else
                {
                    Process.Start(PROTOCOL + START_GAME + game.ID + START_GAME_ARGS);
                }
            }
            else
            {
                if (OperatingSystem.IsWindows())
                {
                    CDock.StartShellExecute(game.Launch);
                }
                else
                {
                    Process.Start(game.Launch);
                }
            }
        }