Add api key field to settings screen

pull/50/head
Allex Rodrigues 4 years ago
parent e499b0a992
commit 90718a3fa4

@ -14,7 +14,7 @@
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="TargetLanguage" serializeAs="String"> <setting name="TargetLanguage" serializeAs="String">
<value/> <value />
</setting> </setting>
<setting name="Seconds" serializeAs="String"> <setting name="Seconds" serializeAs="String">
<value>5</value> <value>5</value>
@ -22,6 +22,9 @@
<setting name="StreamMode" serializeAs="String"> <setting name="StreamMode" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="SteamGridDbApiKey" serializeAs="String">
<value />
</setting>
</UWPHook.Properties.Settings> </UWPHook.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

@ -148,8 +148,7 @@ namespace UWPHook
private async Task DownloadGridImages(string userId, string appName, string appTarget) private async Task DownloadGridImages(string userId, string appName, string appTarget)
{ {
// Generate app id for grid images SteamGridDbApi api = new SteamGridDbApi(Properties.Settings.Default.SteamGridDbApiKey);
SteamGridDbApi api = new SteamGridDbApi("0973373b2cec3120ce673d06747d506c");
string gridDirectory = userId + @"\\config\\grid\\"; string gridDirectory = userId + @"\\config\\grid\\";
var games = await api.SearchGame(appName); var games = await api.SearchGame(appName);
@ -267,8 +266,10 @@ namespace UWPHook
Array.Resize(ref shortcuts, shortcuts.Length + 1); Array.Resize(ref shortcuts, shortcuts.Length + 1);
shortcuts[shortcuts.Length - 1] = newApp; shortcuts[shortcuts.Length - 1] = newApp;
// TODO: Check if api key setting exist if (!String.IsNullOrEmpty(Properties.Settings.Default.SteamGridDbApiKey))
await DownloadGridImages(user, app.Name, appTarget); {
await DownloadGridImages(user, app.Name, appTarget);
}
} }
try try

@ -12,7 +12,7 @@ namespace UWPHook.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -70,5 +70,17 @@ namespace UWPHook.Properties {
this["StreamMode"] = value; this["StreamMode"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string SteamGridDbApiKey {
get {
return ((string)(this["SteamGridDbApiKey"]));
}
set {
this["SteamGridDbApiKey"] = value;
}
}
} }
} }

@ -14,5 +14,8 @@
<Setting Name="StreamMode" Type="System.Boolean" Scope="User"> <Setting Name="StreamMode" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="SteamGridDbApiKey" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

@ -26,9 +26,12 @@
<Image x:Name="image" HorizontalAlignment="Left" Width="178" Height="80" VerticalAlignment="Top" Source="Resources/WhiteTransparent.png" Stretch="UniformToFill" ToolTip="Welcome to UWPHook, add your UWP apps and games to Steam!"/> <Image x:Name="image" HorizontalAlignment="Left" Width="178" Height="80" VerticalAlignment="Top" Source="Resources/WhiteTransparent.png" Stretch="UniformToFill" ToolTip="Welcome to UWPHook, add your UWP apps and games to Steam!"/>
<Grid Margin="10,9.4,10.2,10.2" Grid.Row="1"> <Grid Margin="10,9.4,10.2,10.2" Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="93.6"/> <RowDefinition Height="72"/>
<RowDefinition Height="48.8"/> <RowDefinition Height="44"/>
<RowDefinition/> <RowDefinition Height="41*"/>
<RowDefinition Height="72*"/>
<RowDefinition Height="56*"/>
<RowDefinition Height="51*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="52*"/> <ColumnDefinition Width="52*"/>
@ -39,16 +42,19 @@
<materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="27" Grid.ColumnSpan="4"> <materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="27" Grid.ColumnSpan="4">
<Label Content="Settings" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/> <Label Content="Settings" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone> </materialDesign:ColorZone>
<ToggleButton x:Name="language_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="4,56,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" /> <ToggleButton x:Name="language_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="0,42,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" RenderTransformOrigin="0.304,0.444" />
<Label ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="label1" Content="Set system language when launching an app*" Margin="5,48,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.ColumnSpan="2"/> <Label ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="label1" Content="Set system language when launching an app*" Margin="5,34,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.ColumnSpan="2"/>
<ComboBox ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="cultures_comboBox" Margin="0,48,10,0" VerticalAlignment="Top" Height="31" Grid.Column="3" HorizontalAlignment="Right" Width="93"/> <ComboBox ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="cultures_comboBox" Margin="0,34,10,0" VerticalAlignment="Top" Height="31" Grid.Column="3" HorizontalAlignment="Right" Width="93"/>
<Button x:Name="save_button" Content="Save" HorizontalAlignment="Right" Margin="0,42,10,0" VerticalAlignment="Top" Width="93" Click="saveButton_Click" Grid.Column="3" Grid.Row="2"/> <Button x:Name="save_button" Content="Save" HorizontalAlignment="Right" Margin="0,14.333,10,0" VerticalAlignment="Top" Width="93" Click="saveButton_Click" Grid.Column="3" Grid.Row="4"/>
<Label x:Name="label3" Content="Check if the launched app is running every" Margin="5,0,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"/> <Label x:Name="label3" Content="Check if the launched app is running every" Margin="5,7,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"/>
<ComboBox x:Name="seconds_comboBox" Margin="0,10,10,0" VerticalAlignment="Top" Height="31" Grid.Column="3" HorizontalAlignment="Right" Width="93" Grid.Row="1"/> <ComboBox x:Name="seconds_comboBox" Margin="0,7,10,0" VerticalAlignment="Top" Height="31" Grid.Column="3" HorizontalAlignment="Right" Width="93" Grid.Row="1"/>
<Button x:Name="update_button" Click="update_button_Click" Content="Check for updates" Grid.Column="1" Margin="0,0,5,10" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="162"/> <Button x:Name="update_button" Click="update_button_Click" Content="Check for updates" Margin="0,0,8,9" Grid.Row="5" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="162" Grid.Column="1"/>
<Button x:Name="help_button" Click="help_button_Click" Content="Get help at our Reddit" Grid.Column="2" Margin="8,0,0,10" Grid.Row="2" VerticalAlignment="Bottom" Grid.ColumnSpan="2" HorizontalAlignment="Left" Width="163"/> <Button x:Name="help_button" Click="help_button_Click" Content="Get help at our Reddit" Grid.Column="2" Margin="0,0,0,9" Grid.Row="5" VerticalAlignment="Bottom" Grid.ColumnSpan="2" HorizontalAlignment="Left" Width="163"/>
<ToggleButton x:Name="streaming_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="0,17,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" Grid.Row="2" /> <ToggleButton x:Name="streaming_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="0,12,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" Grid.Row="2" />
<Label ToolTip="This fixes Steam in-home Streaming, set this in the host computer." x:Name="label1_Copy" Content="Enable streaming mode" Margin="5,10,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2"/> <Label ToolTip="This fixes Steam in-home Streaming, set this in the host computer." x:Name="label1_Copy" Content="Enable streaming mode" Margin="5,5,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2"/>
<Label ToolTip="SteamGridDB API key used to download Steam's library artwork. Leave it blank if you don't want to download artwork." x:Name="label1_Copy1" Content="SteamGridDB API key" Margin="5,6,0,0" VerticalAlignment="Top" Height="29" Grid.Row="3" Grid.Column="1"/>
<TextBox x:Name="steamgriddb_api_key" Grid.Column="2" Height="29" Margin="0,6,10,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
<TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="5,40,0,0" Grid.Row="3" TextWrapping="Wrap" Text="To get an api key, visit https://www.steamgriddb.com and create an account. You'll be able to generate a key in your account preferences." VerticalAlignment="Top" Grid.ColumnSpan="3" Height="32" Width="399" FontSize="11"/>
</Grid> </Grid>
<Grid Margin="9.8,9.6,9.6,0.4" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2"> <Grid Margin="9.8,9.6,9.6,0.4" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>

@ -32,6 +32,7 @@ namespace UWPHook
cultures_comboBox.SelectedItem = Properties.Settings.Default.TargetLanguage; cultures_comboBox.SelectedItem = Properties.Settings.Default.TargetLanguage;
language_toggle.IsChecked = Properties.Settings.Default.ChangeLanguage; language_toggle.IsChecked = Properties.Settings.Default.ChangeLanguage;
streaming_toggle.IsChecked = Properties.Settings.Default.StreamMode; streaming_toggle.IsChecked = Properties.Settings.Default.StreamMode;
steamgriddb_api_key.Text = Properties.Settings.Default.SteamGridDbApiKey;
} }
private void saveButton_Click(object sender, RoutedEventArgs e) private void saveButton_Click(object sender, RoutedEventArgs e)
@ -40,6 +41,7 @@ namespace UWPHook
Properties.Settings.Default.TargetLanguage = cultures_comboBox.SelectedItem.ToString(); Properties.Settings.Default.TargetLanguage = cultures_comboBox.SelectedItem.ToString();
Properties.Settings.Default.Seconds = Int32.Parse(seconds_comboBox.SelectedItem.ToString().Substring(0, 1)); Properties.Settings.Default.Seconds = Int32.Parse(seconds_comboBox.SelectedItem.ToString().Substring(0, 1));
Properties.Settings.Default.StreamMode = (bool)streaming_toggle.IsChecked; Properties.Settings.Default.StreamMode = (bool)streaming_toggle.IsChecked;
Properties.Settings.Default.SteamGridDbApiKey = steamgriddb_api_key.Text;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
this.Close(); this.Close();
} }

Loading…
Cancel
Save