public void OnSelected(IGame selectedGame) { UInt64?GameIDNumber = SteamToolsContext.GetSteamGameID(selectedGame); if (GameIDNumber.HasValue) { bool handled = false; if (PluginHelper.StateManager.IsBigBox) { BigBoxLogic(ref handled, GameIDNumber.Value); } if (!handled) { if (PluginHelper.StateManager.IsBigBox) { // Start BigPicture first? InstallWithSteamDialog(GameIDNumber.Value); } else { // If we're in BigPicture this will just transparently install, we need to close BigPicture? InstallWithSteamDialog(GameIDNumber.Value); } } } }
public bool GetIsValidForGame(IGame selectedGame) { if (SteamToolsContext.IsSteamGame(selectedGame)) { UInt64?GameIDNumber = SteamToolsContext.GetSteamGameID(selectedGame); if (GameIDNumber.HasValue) { SteamContext context = SteamContext.GetInstance(); bool? l_IsInstalled = SteamToolsContext.IsInstalled(GameIDNumber.Value, selectedGame); if (l_IsInstalled.HasValue && !l_IsInstalled.Value) { return(true); } } } return(false); }
public void OnEventRaised(string eventType) { switch (eventType) { case SystemEventTypes.PluginInitialized: SteamToolsContext.Remap(); break; case SystemEventTypes.BigBoxStartupCompleted: case SystemEventTypes.LaunchBoxStartupCompleted: SteamToolsContext.Init(); break; case SystemEventTypes.BigBoxShutdownBeginning: case SystemEventTypes.LaunchBoxShutdownBeginning: SteamToolsContext.Shutdown(); break; } }
private void InstallWithSteamDialog(UInt64 GameIDNumber) { SteamToolsContext.InstallGame(GameIDNumber); try { Process steam = SteamContext.GetInstance().GetSteamProcess(); steam.Refresh(); string InstallWindowTitle = steam.MainWindowTitle; IntPtr InstallWindow = steam.MainWindowHandle; // try to get the install window int Timeout = 0; while (!InstallStrings.Any(name => InstallWindowTitle.StartsWith(name + @" - ")) && !InstallStringsEnd.Any(name => InstallWindowTitle.EndsWith(@" - " + name))) { if (Timeout > 10 * 5) { break; } Thread.Sleep(100); Timeout++; steam.Refresh(); InstallWindowTitle = steam.MainWindowTitle; InstallWindow = steam.MainWindowHandle; } // if we found the install window if (InstallStrings.Any(name => InstallWindowTitle.StartsWith(name + @" - ")) || InstallStringsEnd.Any(name => InstallWindowTitle.EndsWith(@" - " + name))) { while (IsWindow(InstallWindow)) { Thread.Sleep(100); } SetForegroundWindow(Process.GetCurrentProcess().MainWindowHandle); } } catch { } }
private void ScanLocalGames() { List <IGame> games = new List <IGame>(); foreach (ListViewItem item in lvPlatforms.Items) { if (item.Checked) { games.AddRange(PluginHelper.DataManager.GetPlatformByName(item.Text).GetAllGames(true, true)); } } //List<IGame> games = PluginHelper.DataManager.GetAllGames().ToList(); pbScanLaunchBox.Maximum = games.Count; int index = 0; games.ForEach(game => { pbScanLaunchBox.Value = ++index; if (SteamToolsContext.IsSteamGame(game)) { UInt64?GameIDNumber = SteamToolsContext.GetSteamGameID(game); if (GameIDNumber.HasValue) { if (!IsInstalled.Contains(GameIDNumber.Value) && (SteamToolsContext.IsInstalled(GameIDNumber.Value, game) ?? false)) { IsInstalled.Add(GameIDNumber.Value); } if (!KnownSteamGames.Contains(GameIDNumber.Value)) { KnownSteamGames.Add(GameIDNumber.Value); } } } }); }
private static bool?IsInstalled_External(ulong value, IGame game) { return(SteamToolsContext.IsInstalled(value, game)); }
private static ulong?GetSteamGameID_External(IGame game) { return(SteamToolsContext.GetSteamGameID(game)); }
private static bool IsSteamGame_External(IGame game) { return(SteamToolsContext.IsSteamGame(game)); }
// If this function is called without Caliburn.Micro it will crash. BigBox loads Caliburn.Micro // Encapsilating this logic into a function seems to keep .net happy // It must be some form of JIT assembly loading private void BigBoxLogic(ref bool handled, UInt64 GameIDNumber) { try { string[] libs = SteamToolsContext.GetGameLibraries(); if (libs.Length > 0) { // The ActiveView is just a small area of the UI sadly, but it has the plugin interface active System.Windows.Controls.UserControl ActiveView = (System.Windows.Controls.UserControl)(Unbroken.LaunchBox.Wpf.BigBox.App.MainViewModel.ActiveView); System.Windows.Controls.Panel ActiveViewContent = (System.Windows.Controls.Panel)(ActiveView.Content); // The entire window view, sadly the plugin interface doesn't work here //Unbroken.LaunchBox.Wpf.BigBox.Views.MainView MainView = (Unbroken.LaunchBox.Wpf.BigBox.Views.MainView)(Unbroken.LaunchBox.Wpf.BigBox.App.MainView); Window MainView = Unbroken.LaunchBox.Wpf.BigBox.App.MainView; System.Windows.Controls.Panel MainViewContent = (System.Windows.Controls.Panel)(MainView.Content); GenericPluginProxyView InstallLocationSelectorProxy = new GenericPluginProxyView(); SelectSteamInstallLocationView InstallLocationSelector = new SelectSteamInstallLocationView(); InstallLocationSelectorProxy.Proxy = InstallLocationSelector; InstallLocationSelector.SetLibraries(libs); InstallLocationSelector.SetHeader("Select Steam Library"); ActiveViewContent.Children.Add(InstallLocationSelectorProxy); MainViewContent.Children.Add(InstallLocationSelector); // When the UI is hidden remove it and the proxy from the Views and let the GC delete them InstallLocationSelector.IsVisibleChanged += (object sender, DependencyPropertyChangedEventArgs e) => { if (InstallLocationSelector.Visibility == Visibility.Hidden) { if (InstallLocationSelector.Accepted) { int index = InstallLocationSelector.SelectedIndex(); if (index >= 0) { try { SteamToolsContext.InstallGame(GameIDNumber, index); try { Unbroken.LaunchBox.Wpf.BigBox.ViewModels.TextGamesViewModel ActiveViewModel = Unbroken.LaunchBox.Wpf.BigBox.App.MainViewModel.ActiveViewModel as Unbroken.LaunchBox.Wpf.BigBox.ViewModels.TextGamesViewModel; if (ActiveViewModel != null) { ActiveViewModel.RefreshGame(); } else { // show a popup telling the user they must maually reload the page } } catch (Exception ex5) { // show a popup telling the user they must maually reload the page } } catch { // in case of error, inform the user it failed and ask them if we should use the alternate method } } } // I'm removing these from the end just in case they become orphans and get GCed mid way through // Though I guess I could just store the important one in a local variable to play it safe // And there is the wierd external scope stuff going on with this inline delegate too ActiveViewContent.Children.Remove(InstallLocationSelectorProxy); MainViewContent.Children.Remove(InstallLocationSelector); } }; InstallLocationSelector.Visibility = Visibility.Visible; handled = true; } } catch { } }