Esempio n. 1
0
 public static void smethod_2(GClass32 gclass32_0)
 {
     try
     {
         string str1 = GClass128.smethod_9(gclass32_0);
         if (str1 == null)
         {
             return;
         }
         string string_1 = GClass128.smethod_8(gclass32_0);
         foreach (string user in SteamManager.GetUsers(SteamManager.GetSteamFolder()))
         {
             ulong  num   = GClass128.smethod_3(gclass32_0.Name, string_1);
             string path2 = "config";
             string path3 = "grid";
             string str2  = System.IO.Path.Combine(user, path2, path3);
             System.IO.Directory.CreateDirectory(str2);
             string destFileName = System.IO.Path.Combine(str2, ((long)num).ToString() + ".png");
             System.IO.File.Copy(str1, destFileName, true);
         }
         GClass6.smethod_6(str1);
     }
     catch
     {
     }
 }
Esempio n. 2
0
        public static void ClearAllShortcuts()
        {
            Debug.WriteLine("DBG: Clearing all elements in shortcuts.vdf");
            string[] tags         = Settings.Default.Tags.Split(',');
            string   steam_folder = SteamManager.GetSteamFolder();

            if (Directory.Exists(steam_folder))
            {
                var users   = SteamManager.GetUsers(steam_folder);
                var exePath = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @"""";
                var exeDir  = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                foreach (var user in users)
                {
                    try
                    {
                        VDFEntry[] shortcuts = new VDFEntry[0];

                        try
                        {
                            if (!Directory.Exists(user + @"\\config\\"))
                            {
                                Directory.CreateDirectory(user + @"\\config\\");
                            }
                            //Write the file with all the shortcuts
                            File.WriteAllBytes(user + @"\\config\\shortcuts.vdf", VDFSerializer.Serialize(shortcuts));
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Program failed while trying to clear your Steam shortcuts:" + Environment.NewLine + ex.Message + ex.StackTrace);
                    }
                }
                MessageBox.Show("All non-Steam shortcuts has been cleared.");
            }
        }
Esempio n. 3
0
 public static void smethod_1()
 {
     Task.Run((Action)(() =>
     {
         try
         {
             foreach (string user in SteamManager.GetUsers(SteamManager.GetSteamFolder()))
             {
                 foreach (VDFEntry vdfEntry in ((IEnumerable <VDFEntry>)SteamManager.ReadShortcuts(user)).Where <VDFEntry>((Func <VDFEntry, bool>)(vdfentry_0 =>
                 {
                     if (vdfentry_0.Tags.Length >= 1)
                     {
                         return(vdfentry_0.Tags[0] == "Wii U USB Helper");
                     }
                     return(false);
                 })))
                 {
                     try
                     {
                         ulong num = GClass128.smethod_3(vdfEntry.AppName, vdfEntry.Exe);
                         string str = System.IO.Path.Combine(user, "config", "grid");
                         System.IO.Directory.CreateDirectory(str);
                         if (!System.IO.File.Exists(System.IO.Path.Combine(str, ((long)num).ToString() + ".png")))
                         {
                             TitleId index = new TitleId(System.IO.Path.GetFileNameWithoutExtension(vdfEntry.Exe));
                             GClass128.smethod_2(GClass28.dictionary_0[index]);
                         }
                     }
                     catch
                     {
                     }
                 }
             }
         }
         catch
         {
         }
     }));
 }
Esempio n. 4
0
        private void BwrSave_DoWork(object sender, DoWorkEventArgs e)
        {
            string steam_folder = SteamManager.GetSteamFolder();

            if (Directory.Exists(steam_folder))
            {
                var users         = SteamManager.GetUsers(steam_folder);
                var selected_apps = Apps.Entries.Where(app => app.Selected);

                //To make things faster, decide icons before looping users
                foreach (var app in selected_apps)
                {
                    app.Icon = app.widestSquareIcon();
                }

                foreach (var user in users)
                {
                    try
                    {
                        VDFEntry[] shortcuts = new VDFEntry[0];
                        try
                        {
                            shortcuts = SteamManager.ReadShortcuts(user);
                        }
                        catch (Exception ex)
                        {
                            //If it's a short VDF, let's just overwrite it
                            if (ex.GetType() != typeof(VDFTooShortException))
                            {
                                throw new Exception("Error: Program failed to load existing Steam shortcuts." + Environment.NewLine + ex.Message);
                            }
                        }

                        if (shortcuts != null)
                        {
                            var exePath = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @"""";
                            var exeDir  = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                            foreach (var app in selected_apps)
                            {
                                VDFEntry newApp = new VDFEntry()
                                {
                                    AppName            = app.Name,
                                    Exe                = exePath,
                                    StartDir           = exeDir,
                                    LaunchOptions      = app.Aumid,
                                    AllowDesktopConfig = 1,
                                    AllowOverlay       = 1,
                                    Icon               = app.Icon,
                                    Index              = shortcuts.Length,
                                    IsHidden           = 0,
                                    OpenVR             = 0,
                                    ShortcutPath       = "",
                                    Tags               = new string[0],
                                    Devkit             = 0,
                                    DevkitGameID       = "",
                                    LastPlayTime       = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                                };

                                //Resize this array so it fits the new entries
                                Array.Resize(ref shortcuts, shortcuts.Length + 1);
                                shortcuts[shortcuts.Length - 1] = newApp;
                            }

                            try
                            {
                                if (!Directory.Exists(user + @"\\config\\"))
                                {
                                    Directory.CreateDirectory(user + @"\\config\\");
                                }
                                //Write the file with all the shortcuts
                                File.WriteAllBytes(user + @"\\config\\shortcuts.vdf", VDFSerializer.Serialize(shortcuts));
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Program failed exporting your games:" + Environment.NewLine + ex.Message + ex.StackTrace);
                    }
                }
            }
        }
Esempio n. 5
0
        private async Task ExportGames()
        {
            string steam_folder = SteamManager.GetSteamFolder();

            if (Directory.Exists(steam_folder))
            {
                var users         = SteamManager.GetUsers(steam_folder);
                var selected_apps = Apps.Entries.Where(app => app.Selected);
                var exePath       = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @"""";
                var exeDir        = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                List <Task> gridImagesDownloadTasks = new List <Task>();
                bool        downloadGridImages      = !String.IsNullOrEmpty(Properties.Settings.Default.SteamGridDbApiKey);

                //To make things faster, decide icons and download grid images before looping users
                foreach (var app in selected_apps)
                {
                    app.Icon = app.widestSquareIcon();

                    if (downloadGridImages)
                    {
                        gridImagesDownloadTasks.Add(DownloadTempGridImages(app.Name, exePath));
                    }
                }

                foreach (var user in users)
                {
                    try
                    {
                        VDFEntry[] shortcuts = new VDFEntry[0];
                        try
                        {
                            shortcuts = SteamManager.ReadShortcuts(user);
                        }
                        catch (Exception ex)
                        {
                            //If it's a short VDF, let's just overwrite it
                            if (ex.GetType() != typeof(VDFTooShortException))
                            {
                                throw new Exception("Error: Program failed to load existing Steam shortcuts." + Environment.NewLine + ex.Message);
                            }
                        }

                        if (shortcuts != null)
                        {
                            foreach (var app in selected_apps)
                            {
                                VDFEntry newApp = new VDFEntry()
                                {
                                    AppName            = app.Name,
                                    Exe                = exePath,
                                    StartDir           = exeDir,
                                    LaunchOptions      = app.Aumid,
                                    AllowDesktopConfig = 1,
                                    AllowOverlay       = 1,
                                    Icon               = app.Icon,
                                    Index              = shortcuts.Length,
                                    IsHidden           = 0,
                                    OpenVR             = 0,
                                    ShortcutPath       = "",
                                    Tags               = new string[2] {
                                        "XBOX", "READY TO PLAY"
                                    },
                                    Devkit       = 0,
                                    DevkitGameID = "",
                                    LastPlayTime = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                                };

                                //Resize this array so it fits the new entries
                                Array.Resize(ref shortcuts, shortcuts.Length + 1);
                                shortcuts[shortcuts.Length - 1] = newApp;
                            }

                            try
                            {
                                if (!Directory.Exists(user + @"\\config\\"))
                                {
                                    Directory.CreateDirectory(user + @"\\config\\");
                                }
                                //Write the file with all the shortcuts
                                File.WriteAllBytes(user + @"\\config\\shortcuts.vdf", VDFSerializer.Serialize(shortcuts));
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Program failed exporting your games:" + Environment.NewLine + ex.Message + ex.StackTrace);
                    }
                }

                if (gridImagesDownloadTasks.Count > 0)
                {
                    await Task.WhenAll(gridImagesDownloadTasks);

                    await Task.Run(() =>
                    {
                        foreach (var user in users)
                        {
                            CopyTempGridImagesToSteamUser(user);
                        }

                        RemoveTempGridImages();
                    });
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Main Task to export the selected games to steam
        /// </summary>
        /// <param name="restartSteam"></param>
        /// <returns></returns>
        private async Task <bool> ExportGames(bool restartSteam)
        {
            string[] tags         = Settings.Default.Tags.Split(',');
            string   steam_folder = SteamManager.GetSteamFolder();

            if (Directory.Exists(steam_folder))
            {
                var users         = SteamManager.GetUsers(steam_folder);
                var selected_apps = Apps.Entries.Where(app => app.Selected);
                var exePath       = @"""" + System.Reflection.Assembly.GetExecutingAssembly().Location + @"""";
                var exeDir        = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                List <Task> gridImagesDownloadTasks = new List <Task>();
                bool        downloadGridImages      = !String.IsNullOrEmpty(Properties.Settings.Default.SteamGridDbApiKey);
                //To make things faster, decide icons and download grid images before looping users
                Debug.WriteLine("downloadGridImages: " + (downloadGridImages));

                foreach (var app in selected_apps)
                {
                    app.Icon = app.widestSquareIcon();

                    if (downloadGridImages)
                    {
                        Debug.WriteLine("Downloading grid images for app " + app.Name);

                        gridImagesDownloadTasks.Add(DownloadTempGridImages(app.Name, exePath));
                    }
                }

                // Export the selected apps and the downloaded images to each user
                // in the steam folder by modifying it's VDF file
                foreach (var user in users)
                {
                    try
                    {
                        VDFEntry[] shortcuts = new VDFEntry[0];
                        try
                        {
                            shortcuts = SteamManager.ReadShortcuts(user);
                        }
                        catch (Exception ex)
                        {
                            //If it's a short VDF, let's just overwrite it
                            if (ex.GetType() != typeof(VDFTooShortException))
                            {
                                throw new Exception("Error: Program failed to load existing Steam shortcuts." + Environment.NewLine + ex.Message);
                            }
                        }

                        if (shortcuts != null)
                        {
                            foreach (var app in selected_apps)
                            {
                                VDFEntry newApp = new VDFEntry()
                                {
                                    AppName            = app.Name,
                                    Exe                = exePath,
                                    StartDir           = exeDir,
                                    LaunchOptions      = app.Aumid,
                                    AllowDesktopConfig = 1,
                                    AllowOverlay       = 1,
                                    Icon               = app.Icon,
                                    Index              = shortcuts.Length,
                                    IsHidden           = 0,
                                    OpenVR             = 0,
                                    ShortcutPath       = "",
                                    Tags               = tags,
                                    Devkit             = 0,
                                    DevkitGameID       = "",
                                    LastPlayTime       = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                                };
                                Boolean isFound = false;
                                for (int i = 0; i < shortcuts.Length; i++)
                                {
                                    Debug.WriteLine(shortcuts[i].ToString());


                                    if (shortcuts[i].AppName == app.Name)
                                    {
                                        isFound = true;
                                        Debug.WriteLine(app.Name + " already added to Steam. Updating existing shortcut.");
                                        shortcuts[i] = newApp;
                                    }
                                }

                                if (!isFound)
                                {
                                    //Resize this array so it fits the new entries
                                    Array.Resize(ref shortcuts, shortcuts.Length + 1);
                                    shortcuts[shortcuts.Length - 1] = newApp;
                                }
                            }

                            try
                            {
                                if (!Directory.Exists(user + @"\\config\\"))
                                {
                                    Directory.CreateDirectory(user + @"\\config\\");
                                }
                                //Write the file with all the shortcuts
                                File.WriteAllBytes(user + @"\\config\\shortcuts.vdf", VDFSerializer.Serialize(shortcuts));
                            }
                            catch (Exception ex)
                            {
                                throw new Exception("Error: Program failed while trying to write your Steam shortcuts" + Environment.NewLine + ex.Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Program failed exporting your games:" + Environment.NewLine + ex.Message + ex.StackTrace);
                    }
                }

                if (gridImagesDownloadTasks.Count > 0)
                {
                    await Task.WhenAll(gridImagesDownloadTasks);

                    await Task.Run(() =>
                    {
                        foreach (var user in users)
                        {
                            CopyTempGridImagesToSteamUser(user);
                        }

                        RemoveTempGridImages();
                    });
                }
            }

            if (restartSteam)
            {
                Func <Process> getSteam = () => Process.GetProcessesByName("steam").SingleOrDefault();

                Process steam = getSteam();
                if (steam != null)
                {
                    string steamExe = steam.MainModule.FileName;

                    //we always ask politely
                    Debug.WriteLine("Requesting Steam shutdown");
                    Process.Start(steamExe, "-exitsteam");

                    bool      restarted = false;
                    Stopwatch watch     = new Stopwatch();
                    watch.Start();

                    //give it N seconds to sort itself out
                    int waitSeconds = 8;
                    while (watch.Elapsed.TotalSeconds < waitSeconds)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(0.5f));
                        if (getSteam() == null)
                        {
                            Debug.WriteLine("Restarting Steam");
                            Process.Start(steamExe);
                            restarted = true;
                            break;
                        }
                    }

                    if (!restarted)
                    {
                        Debug.WriteLine("Steam instance not restarted");
                        MessageBox.Show("Failed to restart Steam, please launch it manually", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return(false);
                    }
                }
                else
                {
                    Debug.WriteLine("Steam instance not found to be restarted");
                }
            }

            return(true);
        }
Esempio n. 7
0
 private static void smethod_7(GClass32 gclass32_0, GClass95 gclass95_0)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     GClass128.Class114 class114 = new GClass128.Class114();
     // ISSUE: reference to a compiler-generated field
     class114.gclass32_0 = gclass32_0;
     if (GClass6.smethod_16("Steam"))
     {
         int num1 = (int)RadMessageBox.Show("Games cannot be added while Steam is running. Please close it and try again");
     }
     else
     {
         string steamFolder = SteamManager.GetSteamFolder();
         if (!System.IO.Directory.Exists(steamFolder))
         {
             int num2 = (int)RadMessageBox.Show("Steam is not installed. Cannot proceed.");
         }
         else
         {
             string[] users = SteamManager.GetUsers(steamFolder);
             if (users.Length == 0)
             {
                 int num3 = (int)RadMessageBox.Show("USB Helper was unable to find any registered Steam user. Make sure you have logged in at least once.");
             }
             else
             {
                 string str1 = System.IO.Path.Combine(GClass128.String_0, "backup");
                 System.IO.Directory.CreateDirectory(GClass128.String_0);
                 System.IO.Directory.CreateDirectory(str1);
                 // ISSUE: reference to a compiler-generated field
                 string str2 = System.IO.Path.Combine(GClass128.String_0, "icon" + class114.gclass32_0.TitleId.IdRaw + ".tmp");
                 // ISSUE: reference to a compiler-generated field
                 string filename = System.IO.Path.Combine(GClass128.String_0, "icon" + class114.gclass32_0.TitleId.IdRaw + ".png");
                 // ISSUE: reference to a compiler-generated field
                 new GClass78().method_5(class114.gclass32_0.IconUrl, str2, 0UL, GClass78.GEnum4.const_0, (WebProxy)null, 0L, (byte[])null, (byte[])null, (byte)0);
                 Image image = Image.FromFile(str2);
                 image.Save(filename, ImageFormat.Png);
                 image.Dispose();
                 GClass6.smethod_6(str2);
                 // ISSUE: reference to a compiler-generated field
                 string str3 = GClass128.smethod_4(class114.gclass32_0, gclass95_0);
                 // ISSUE: reference to a compiler-generated field
                 VDFEntry vdfEntry = new VDFEntry()
                 {
                     AppName = class114.gclass32_0.Name, Exe = str3, Icon = filename, Tags = new string[1] {
                         "Wii U USB Helper"
                     }
                 };
                 foreach (string userPath in users)
                 {
                     List <VDFEntry> source = new List <VDFEntry>();
                     try
                     {
                         source = new List <VDFEntry>((IEnumerable <VDFEntry>)SteamManager.ReadShortcuts(userPath));
                     }
                     catch
                     {
                     }
                     // ISSUE: reference to a compiler-generated field
                     // ISSUE: reference to a compiler-generated field
                     // ISSUE: reference to a compiler-generated method
                     if (!source.Any <VDFEntry>(class114.func_0 ?? (class114.func_0 = new Func <VDFEntry, bool>(class114.method_0))))
                     {
                         source.Add(vdfEntry);
                         string str4 = userPath + "\\config\\shortcuts.vdf";
                         System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(str4));
                         if (System.IO.File.Exists(str4))
                         {
                             System.IO.File.Copy(str4, System.IO.Path.Combine(str1, DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString()), true);
                         }
                         SteamManager.WriteShortcuts(source.ToArray(), str4);
                     }
                 }
                 // ISSUE: reference to a compiler-generated field
                 GClass128.smethod_2(class114.gclass32_0);
             }
         }
     }
 }