예제 #1
0
        public void OnSelected(IGame selectedGame)
        {
            frmHLTBGames frm = new frmHLTBGames();

            frm.txtGameTitle.Text = selectedGame.Title;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                var oldfields = selectedGame.GetAllCustomFields();
                foreach (var field in oldfields)
                {
                    if (field.Name == MAIN_STORY || field.Name == MAIN_EXTRA || field.Name == COMPLETIONIST)
                    {
                        selectedGame.TryRemoveCustomField(field);
                    }
                }

                if (MainStoryEnabled && frm.selectedGame.mainStory > 0)
                {
                    var mainStory = selectedGame.AddNewCustomField();
                    mainStory.Name  = MAIN_STORY;
                    mainStory.Value = frm.selectedGame.mainStory.ToString().PadLeft(3, '0') + " Hours";
                }

                if (MainExtraEnabled && frm.selectedGame.mainExtra > 0)
                {
                    var mainStory = selectedGame.AddNewCustomField();
                    mainStory.Name  = MAIN_EXTRA;
                    mainStory.Value = frm.selectedGame.mainExtra.ToString().PadLeft(3, '0') + " Hours";
                }

                if (CompletionistEnabled && frm.selectedGame.completionist > 0)
                {
                    var mainStory = selectedGame.AddNewCustomField();
                    mainStory.Name  = COMPLETIONIST;
                    mainStory.Value = frm.selectedGame.completionist.ToString().PadLeft(3, '0') + " Hours";
                }
            }

            PluginHelper.DataManager.Save();
        }
예제 #2
0
        private void gameImport_doWork(IProgress <int> progress, IProgress <String> msg)
        {
            int j     = 0;
            int items = gamesFound.Count;

            PluginHelper.DataManager.ReloadIfNeeded();
            foreach (GameImport gi in gamesFound)
            {
                if (progress != null)
                {
                    progress.Report((j * 100) / items);
                }
                j++;

                if (gi.title != null)
                {
                    msg.Report(gi.title);
                }

                if (!gi.import)
                {
                    continue;
                }

                IGame game = PluginHelper.DataManager.AddNewGame(gi._importTitle);

                //ICustomField markedAsImported = game.AddNewCustomField();
                //markedAsImported.Name = "addedByGogPlugin";
                //markedAsImported.Value = "true";

                ICustomField gogId = game.AddNewCustomField();
                gogId.Name  = "gogId";
                gogId.Value = gi._gogId;

                game.Status       = "Imported from gog.com";
                game.Source       = "gog.com";
                game.DateAdded    = DateTime.Now;
                game.DateModified = DateTime.Now;
                game.Platform     = this.platforms[platformNo];

                if (mode.Equals(Mode.startWithGalaxy))
                {
                    game.ApplicationPath = $@"{galaxyPath}\GalaxyClient.exe";
                    game.CommandLine     = $@"/gameid={gi._gogId} /command=runGame";
                }
                else if (mode.Equals(Mode.linkToDownload))
                {
                    game.ApplicationPath = "https://embed.gog.com" + gi._selectedDownload._link;
                    game.Version         = gi._selectedDownload._version + "(" + gi._selectedDownload._language.Substring(0, 2) + ")";
                }
            }
            PluginHelper.DataManager.Save();
        }
예제 #3
0
        private void SSaveButton_Click(object sender, RoutedEventArgs e)
        {
            string LBFolder     = AppDomain.CurrentDomain.BaseDirectory;
            string pluginFolder = Path.Combine(LBFolder, "Plugins");

            Directory.CreateDirectory(pluginFolder + "\\PlaytimeTracker");
            string subFolder   = Path.Combine(pluginFolder, "PlaytimeTracker");
            string oldSaveFile = Path.Combine(subFolder, _setGame.Title + "." + _setGame.Id + ".txt");
            string saveFile    = Path.Combine(subFolder, _setGame.Id + ".txt");

            var existingField = _setGame.GetAllCustomFields().FirstOrDefault(f => f.Name.Equals("Playtime", StringComparison.OrdinalIgnoreCase));

            if (File.Exists(oldSaveFile))
            {
                //check if old style txt file exists and update to new style and delete old if found
                string   s = File.ReadAllText(oldSaveFile);
                TimeSpan t = TimeSpan.Parse(s);
                File.WriteAllText(saveFile, t.ToString("G"));
                File.Delete(oldSaveFile);
            }

            TimeSpan?ts = sTimesetter.Value;
            TimeSpan timeSpan;

            if (ts.HasValue)
            {
                timeSpan = ts.Value;
                if (existingField != null)
                {
                    existingField.Value = PlaytimeTracker.FriendlyTimeOutput(timeSpan);
                    File.WriteAllText(saveFile, timeSpan.ToString("G"));
                    PluginHelper.DataManager.Save();
                    System.Windows.MessageBox.Show("Saved");
                    this.Close();
                }
                else
                {
                    var newField = _setGame.AddNewCustomField();
                    newField.Name  = "Playtime";
                    newField.Value = PlaytimeTracker.FriendlyTimeOutput(timeSpan);
                    File.WriteAllText(saveFile, timeSpan.ToString("G"));
                    PluginHelper.DataManager.Save();
                    System.Windows.MessageBox.Show("Saved");
                    this.Close();
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Input a playtime");
                sTimesetter.Focus();
            }
        }
예제 #4
0
        public void OnSelected(IGame selectedGame)
        {
            //showing a messagebox of custom fields
            var fields = selectedGame.GetAllCustomFields();

            foreach (var field in fields)
            {
                MessageBox.Show(field.Name + " : " + field.Value);
            }
            //staring the game
            selectedGame.Play();
            //waiting 60 seconds to get past the menus
            System.Threading.Thread.Sleep(60000);
            //sending f11 to start benchmark
            SendKeys.SendWait("{F11}");
            //waiting for benchmark to finish
            System.Threading.Thread.Sleep(60000);
            //reading benchmark results
            string text = System.IO.File.ReadAllText(@"C:\Fraps\Benchmarks\FRAPSLOG.txt");
            //striping out average frames per second
            int    pFrom  = text.IndexOf("- Avg: ") + "- Avg: ".Length;
            int    pTo    = text.LastIndexOf(" - Min:");
            String result = text.Substring(pFrom, pTo - pFrom);
            //removing old custom  fields
            var oldfields = selectedGame.GetAllCustomFields();

            foreach (var field in oldfields)
            {
                if (field.Name == "FPS")
                {
                    selectedGame.TryRemoveCustomField(field);
                }
            }
            //setting the custom field
            var fps = selectedGame.AddNewCustomField();

            fps.Name  = "FPS";
            fps.Value = result;
            //deleting the log so we can start fresh next time
            System.IO.File.Delete(@"C:\Fraps\Benchmarks\FRAPSLOG.txt");
        }
예제 #5
0
        public void OnGameExited()
        {
            _Finished          = DateTime.UtcNow;
            _SessionTimePlayed = _Finished.Subtract(_Started);

            string LBFolder     = AppDomain.CurrentDomain.BaseDirectory;
            string pluginFolder = Path.Combine(LBFolder, "Plugins");

            Directory.CreateDirectory(pluginFolder + "\\PlaytimeTracker");
            string subFolder   = Path.Combine(pluginFolder, "PlaytimeTracker");
            string oldSaveFile = Path.Combine(subFolder, _game.Title + "." + _GameId + ".txt");
            string saveFile    = Path.Combine(subFolder, _GameId + ".txt");

            //check to see if the Playtime custom field already exists
            var existingField = _game.GetAllCustomFields().FirstOrDefault(f => f.Name.Equals("Playtime", StringComparison.OrdinalIgnoreCase));

            if (File.Exists(oldSaveFile))
            {
                //check if old style txt file exists and update to new style and delete old if found
                string   s  = File.ReadAllText(oldSaveFile);
                TimeSpan ts = TimeSpan.Parse(s);
                File.WriteAllText(saveFile, ts.ToString("G"));
                File.Delete(oldSaveFile);
            }

            if (File.Exists(saveFile))
            {
                //file exists, update
                string   s  = File.ReadAllText(saveFile);
                TimeSpan ts = TimeSpan.Parse(s);

                _TotalTimePlayed = _SessionTimePlayed.Add(ts);
                File.WriteAllText(saveFile, _TotalTimePlayed.ToString("G"));

                if (existingField != null)
                {
                    existingField.Value = FriendlyTimeOutput(_TotalTimePlayed);
                }
                else
                {
                    var newField = _game.AddNewCustomField();
                    newField.Name  = "Playtime";
                    newField.Value = FriendlyTimeOutput(_TotalTimePlayed);
                }
                PluginHelper.DataManager.Save();
            }
            else
            {
                //file doesn't exist, create
                File.WriteAllText(saveFile, _SessionTimePlayed.ToString("G"));

                if (existingField != null)
                {
                    existingField.Value = FriendlyTimeOutput(_SessionTimePlayed);
                }
                else
                {
                    var newField = _game.AddNewCustomField();
                    newField.Name  = "Playtime";
                    newField.Value = FriendlyTimeOutput(_SessionTimePlayed);
                }
                PluginHelper.DataManager.Save();
            }
        }
예제 #6
0
        /// <summary>
        /// Is this Steam game Installed?
        /// </summary>
        /// <param name="GameID">Steam GameID</param>
        /// <returns>Nullable Boolean</returns>
        public static bool?IsInstalled(UInt64 GameID, IGame game)
        {
            lock (contextLock)
            {
                if (!context.SteamIsRunning)
                {
                    if (game == null)
                    {
                        return(null);
                    }
                    if (!LaunchBoxPremiumLicenceFound)
                    {
                        return(null);
                    }

                    ICustomField installedFieldX = game.GetAllCustomFields().Where(field => field.Name == "Steam Game Installed").FirstOrDefault();
                    if (installedFieldX == null)
                    {
                        return(null);
                    }
                    bool retVal;
                    if (bool.TryParse(installedFieldX.Value, out retVal))
                    {
                        return(retVal);
                    }
                    return(null);
                }

                bool _isInstalled = context.IsInstalled(GameID);
                if (game == null)
                {
                    return(context.IsInstalled(GameID));
                }

                //if(SteamGameAutoHideShow)
                //{
                //    //show or hide game
                //}

                bool dataDirty = false;
                if (LaunchBoxPremiumLicenceFound)
                {
                    ICustomField installedField = game.GetAllCustomFields().Where(field => field.Name == "Steam Game Installed").FirstOrDefault();
                    if (installedField == null)
                    {
                        installedField       = game.AddNewCustomField();
                        installedField.Name  = "Steam Game Installed";
                        installedField.Value = _isInstalled.ToString();
                        dataDirty           |= true; // PluginHelper.DataManager.Save(false);
                    }
                    else if (installedField.Value != _isInstalled.ToString())
                    {
                        installedField.Value = _isInstalled.ToString();
                        dataDirty           |= true; // PluginHelper.DataManager.Save(false);
                    }
                }
                if (SteamToolsOptions.HideUninstalled)
                {
                    if (!game.Hide && !_isInstalled)
                    {
                        game.Hide  = true;
                        dataDirty |= true;
                    }
                }
                if (SteamToolsOptions.ShowInstalled)
                {
                    if (game.Hide && _isInstalled)
                    {
                        game.Hide  = false;
                        dataDirty |= true;
                    }
                }

                if (dataDirty)
                {
                    PluginHelper.DataManager.Save(false);
                }

                return(_isInstalled);
            }
        }