Skip to content

Commit

Permalink
Save LastPlayed information for non-steam games. Added Browser button…
Browse files Browse the repository at this point in the history
… for Game Executable.
  • Loading branch information
EnemyWithin authored and Theo47 committed Feb 23, 2016
1 parent 494558d commit dac3beb
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 17 deletions.
10 changes: 10 additions & 0 deletions Depressurizer/DlgGame.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Depressurizer/DlgGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License
along with Depressurizer. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.IO;
using System.Windows.Forms;

namespace Depressurizer {
Expand Down Expand Up @@ -84,5 +85,26 @@ private void cmdOk_Click( object sender, EventArgs e ) {
DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}

private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();

try
{
FileInfo f = new FileInfo(txtExecutable.Text);
dlg.InitialDirectory = f.DirectoryName;
dlg.FileName = f.Name;
}
catch (ArgumentException)
{
}

DialogResult res = dlg.ShowDialog();
if (res == DialogResult.OK)
{
txtExecutable.Text = dlg.FileName;
}
}
}
}
60 changes: 45 additions & 15 deletions Depressurizer/DlgGame.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtId.ZOrder" xml:space="preserve">
<value>11</value>
<value>12</value>
</data>
<data name="lblId.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -165,7 +165,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblId.ZOrder" xml:space="preserve">
<value>10</value>
<value>11</value>
</data>
<data name="lblName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -192,7 +192,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblName.ZOrder" xml:space="preserve">
<value>9</value>
<value>10</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="txtName.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
Expand All @@ -217,7 +217,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtName.ZOrder" xml:space="preserve">
<value>8</value>
<value>9</value>
</data>
<data name="lblCategory.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -244,7 +244,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblCategory.ZOrder" xml:space="preserve">
<value>7</value>
<value>8</value>
</data>
<data name="chkFavorite.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
Expand Down Expand Up @@ -274,13 +274,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;chkFavorite.ZOrder" xml:space="preserve">
<value>6</value>
<value>7</value>
</data>
<data name="cmdOk.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="cmdOk.Location" type="System.Drawing.Point, System.Drawing">
<value>398, 120</value>
<value>285, 124</value>
</data>
<data name="cmdOk.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
Expand All @@ -301,13 +301,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cmdOk.ZOrder" xml:space="preserve">
<value>5</value>
<value>6</value>
</data>
<data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="cmdCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>317, 120</value>
<value>148, 124</value>
</data>
<data name="cmdCancel.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
Expand All @@ -328,7 +328,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cmdCancel.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="txtCategory.Location" type="System.Drawing.Point, System.Drawing">
<value>70, 65</value>
Expand All @@ -349,7 +349,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtCategory.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="chkHidden.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -376,13 +376,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;chkHidden.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="txtExecutable.Location" type="System.Drawing.Point, System.Drawing">
<value>70, 95</value>
</data>
<data name="txtExecutable.Size" type="System.Drawing.Size, System.Drawing">
<value>403, 20</value>
<value>321, 20</value>
</data>
<data name="txtExecutable.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
Expand All @@ -397,7 +397,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;txtExecutable.ZOrder" xml:space="preserve">
<value>0</value>
<value>1</value>
</data>
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand Down Expand Up @@ -427,7 +427,37 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="btnBrowse.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="btnBrowse.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="btnBrowse.Location" type="System.Drawing.Point, System.Drawing">
<value>398, 94</value>
</data>
<data name="btnBrowse.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="btnBrowse.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="btnBrowse.Text" xml:space="preserve">
<value>Browse...</value>
</data>
<data name="&gt;&gt;btnBrowse.Name" xml:space="preserve">
<value>btnBrowse</value>
</data>
<data name="&gt;&gt;btnBrowse.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnBrowse.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;btnBrowse.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand Down
3 changes: 2 additions & 1 deletion Depressurizer/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,8 @@ private void GetLastPlayedFromVdf(VdfFileNode appsNode, SortedSet<int> ignore, A

if (gameNodePair.Value.ContainsKey("LastPlayed") && gameNodePair.Value["LastPlayed"].NodeInt != 0)
{
game.LastPlayed = Utility.GetDTFromUTime(gameNodePair.Value["LastPlayed"].NodeInt);
DateTime dt = Utility.GetDTFromUTime(gameNodePair.Value["LastPlayed"].NodeInt);
if (dt > game.LastPlayed) game.LastPlayed = dt;
Program.Logger.Write(LoggerLevel.Verbose, GlobalStrings.GameData_ProcessedGame, gameId, game.LastPlayed.ToString());
}
}
Expand Down
1 change: 1 addition & 0 deletions Depressurizer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3560,6 +3560,7 @@ void LaunchGame( GameInfo g ) {
// // Steam game
// gameIdentifier = g.Id.ToString();
//}
g.LastPlayed = DateTime.Now;
System.Diagnostics.Process.Start( g.Executable );
}
}
Expand Down
6 changes: 5 additions & 1 deletion Depressurizer/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private const string
XmlName_Game_Hidden = "hidden",
XmlName_Game_CategoryList = "categories",
XmlName_Game_Category = "category",
XmlName_Game_Executable = "executable";
XmlName_Game_Executable = "executable",
XmlName_Game_LastPlayed = "lastplayed";

// Old Xml names
private const string XmlName_Old_SteamIDShort = "account_id",
Expand Down Expand Up @@ -292,6 +293,7 @@ private static void AddGameFromXmlNode( XmlNode node, Profile profile, int profi

game.Hidden = XmlUtil.GetBoolFromNode( node[XmlName_Game_Hidden], false );
game.Executable = XmlUtil.GetStringFromNode(node[XmlName_Game_Executable], null);
game.LastPlayed = Convert.ToDateTime(XmlUtil.GetStringFromNode(node[XmlName_Game_LastPlayed], null));

if ( profileVersion < 1 ) {
string catName;
Expand Down Expand Up @@ -374,6 +376,8 @@ public bool Save( string path ) {
}

writer.WriteElementString( XmlName_Game_Hidden, g.Hidden.ToString() );

if (g.LastPlayed != DateTime.MinValue) writer.WriteElementString(XmlName_Game_LastPlayed, g.LastPlayed.ToString());

if (!g.Executable.Contains("steam://")) writer.WriteElementString(XmlName_Game_Executable, g.Executable);

Expand Down

0 comments on commit dac3beb

Please sign in to comment.