-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added about window and supports multi-steam installs
- Loading branch information
Showing
8 changed files
with
181 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Window x:Class="Terrafirma.AboutWin" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
Title="AboutWin" Height="201.493" Width="268.657" ResizeMode="NoResize"> | ||
<Grid> | ||
<Button Content="Close" HorizontalAlignment="Left" Margin="176,140,0,0" VerticalAlignment="Top" Width="75" IsDefault="True" Click="Button_Click"/> | ||
<Label x:Name="Version" Content="Terrafirma" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="241" FontWeight="Bold" FontFamily="Segoe UI Black"/> | ||
<Label x:Name="Copyright" Content="Copyright" HorizontalAlignment="Left" Margin="10,36,0,0" VerticalAlignment="Top" Width="241" FontStretch="Condensed" FontStyle="Italic" FontSize="10"/> | ||
<TextBlock x:Name="Description" HorizontalAlignment="Left" Margin="10,72,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Height="63" Width="241"/> | ||
|
||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Shapes; | ||
|
||
namespace Terrafirma | ||
{ | ||
/// <summary> | ||
/// Interaction logic for AboutWin.xaml | ||
/// </summary> | ||
public partial class AboutWin : Window | ||
{ | ||
public AboutWin() | ||
{ | ||
InitializeComponent(); | ||
|
||
Assembly app = Assembly.GetExecutingAssembly(); | ||
AssemblyTitleAttribute title = (AssemblyTitleAttribute)app.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0]; | ||
AssemblyCopyrightAttribute copy = (AssemblyCopyrightAttribute)app.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]; | ||
AssemblyDescriptionAttribute desc = (AssemblyDescriptionAttribute)app.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0]; | ||
Version version = app.GetName().Version; | ||
|
||
Title = String.Format("About {0}", title.Title); | ||
Version.Content = String.Format("{0} Version {1}", title.Title, version.ToString()); | ||
Copyright.Content = copy.Copyright.ToString(); | ||
Description.Text = desc.Description; | ||
} | ||
|
||
private void Button_Click(object sender, RoutedEventArgs e) | ||
{ | ||
this.Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Terrafirma | ||
{ | ||
class SteamConfig | ||
{ | ||
class Element | ||
{ | ||
public Dictionary<string, Element> Children { get; set; } | ||
public string Name { get; set; } | ||
public string Value; | ||
|
||
private static Regex keyRegex = new Regex("\"[^\"]*\""); | ||
|
||
public Element(Queue<string> lines) | ||
{ | ||
Children = new Dictionary<string, Element>(); | ||
string line = lines.Dequeue(); | ||
|
||
MatchCollection matches = keyRegex.Matches(line); | ||
if (matches.Count == 0) //corrupt | ||
return; | ||
Name = matches[0].Value.Trim('\"'); | ||
if (matches.Count > 1) //value is a string | ||
Value = matches[1].Value.Trim('\"').Replace(@"\\","\\"); | ||
line = lines.Peek(); | ||
if (line.Contains('{')) | ||
{ | ||
lines.Dequeue(); | ||
while (true) | ||
{ | ||
line = lines.Peek(); | ||
if (line.Contains('}')) | ||
{ | ||
lines.Dequeue(); | ||
return; | ||
} | ||
Element e = new Element(lines); | ||
Children.Add(e.Name, e); | ||
} | ||
} | ||
} | ||
public string Find(string path) | ||
{ | ||
string[] kv = path.Split(new char[] { '/' }, 2); | ||
if (kv.Length == 1) | ||
return Children[kv[0]].Value; | ||
return Children[kv[0]].Find(kv[1]); | ||
} | ||
} | ||
Element root = null; | ||
public SteamConfig() | ||
{ | ||
Microsoft.Win32.RegistryKey key; | ||
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\\Valve\\Steam"); | ||
if (key != null) | ||
{ | ||
string path = key.GetValue("SteamPath") as string; | ||
path = Path.Combine(path, "config"); | ||
path = Path.Combine(path, "config.vdf"); | ||
if (File.Exists(path)) | ||
parse(path); | ||
} | ||
} | ||
public bool Ready { get { return root != null; } } | ||
|
||
public string Get(string path) | ||
{ | ||
return root.Find(path); | ||
} | ||
|
||
private void parse(string path) | ||
{ | ||
TextReader read = new StreamReader(path); | ||
Queue<string> lines = new Queue<string>(); | ||
String line = read.ReadLine(); | ||
while (line != null) | ||
{ | ||
lines.Enqueue(line); | ||
line = read.ReadLine(); | ||
} | ||
root = new Element(lines); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters