Skip to content

Commit

Permalink
Another way to help users with program configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Khudyakov committed Aug 5, 2024
1 parent 82c4e4f commit 0fac272
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 85 deletions.
5 changes: 5 additions & 0 deletions SPT-AKI Profile Editor.Tests/Hepers/TestsDialogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public Task HideProgressDialog()
return Task.CompletedTask;
}

public Task OpenServerSelectHelpAsync(AppSettings appSettings)
{
return Task.CompletedTask;
}

public Task ShowAddMoneyDialog(AddableItem money, RelayCommand addCommand)
{
addCommand.Execute(null);
Expand Down
8 changes: 8 additions & 0 deletions SPT-AKI Profile Editor/Helpers/MetroDialogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public Task ShowProgressDialog(string title,
MetroDialogSettings dialogSettings = null);

public Task HideProgressDialog();

public Task OpenServerSelectHelpAsync(AppSettings appSettings);
}

public class MetroDialogManager : IDialogManager
Expand Down Expand Up @@ -230,6 +232,12 @@ public async Task HideProgressDialog()
progressDialog = null;
}

public async Task OpenServerSelectHelpAsync(AppSettings appSettings)
{
CustomDialog helpDialog = CustomDialog(AppData.AppLocalization.GetLocalizedString("server_select_help"), 500);
await ShowCustomDialog<ServerSelectHelpDialog>(viewModel, helpDialog, new ServerSelectHelpDialogViewModel(appSettings, viewModel));
}

private static CustomDialog CustomDialog(string title, double width) => new()
{
Title = title,
Expand Down
Binary file modified SPT-AKI Profile Editor/Resources/Images/server_folder.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions SPT-AKI Profile Editor/Resources/Labels.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="TitleLabel" TargetType="Label">
<Label
Margin="10,0,0,0"
Expand All @@ -12,6 +11,19 @@
</Label.Content>
</Label>
</ControlTemplate>
<ControlTemplate x:Key="ValidationLabel" TargetType="Label">
<Label
Margin="10,-5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
FontSize="12"
FontWeight="Bold"
Foreground="{DynamicResource MahApps.Brushes.ValidationSummary1}">
<Label.Content>
<TextBlock Text="{TemplateBinding Content}" TextWrapping="Wrap" />
</Label.Content>
</Label>
</ControlTemplate>
<Style
x:Key="DescriptionHeaderStyle"
BasedOn="{StaticResource {x:Type Label}}"
Expand Down
3 changes: 2 additions & 1 deletion SPT-AKI Profile Editor/Resources/Localizations/ch.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
"tab_quests_add_all_missing_event_quests": "添加所有缺失的活动任务",
"migration_to_3.9.0_title": "当前设置与 SPT 3.9.0 及更高版本不兼容",
"migration_to_3.9.0_message": "进行自动修正吗?\n\n服务器文件的相对路径将会更正\n本地化文件也会重置\n程序会在执行上述动作后自动重新启动",
"checkbox_dont_ask_again": "不再询问"
"checkbox_dont_ask_again": "不再询问",
"server_select_help": "Need help?"
}
}
3 changes: 2 additions & 1 deletion SPT-AKI Profile Editor/Resources/Localizations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
"tab_quests_add_all_missing_event_quests": "Add all missing event quests",
"migration_to_3.9.0_title": "Current settings are not compatible with SPT version 3.9.0 and higher",
"migration_to_3.9.0_message": "Make the required changes?\n\nRelative paths to server files will be corrected\nLocalization files will be reset\nThe program will automatically restart",
"checkbox_dont_ask_again": "Don't ask again"
"checkbox_dont_ask_again": "Don't ask again",
"server_select_help": "Need help?"
}
}
3 changes: 2 additions & 1 deletion SPT-AKI Profile Editor/Resources/Localizations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
"tab_quests_add_all_missing_event_quests": "Добавить все отсутствующие ивент квесты",
"migration_to_3.9.0_title": "Текущие настройки несовместимы с SPT версии 3.9.0 и выше",
"migration_to_3.9.0_message": "Внести требуемые изменения?\n\nОтносительные пути к файлам сервера будут исправлены\nФайлы локализации будут сброшены\nПрограмма автоматически перезапустится",
"checkbox_dont_ask_again": "Больше не спрашивать"
"checkbox_dont_ask_again": "Больше не спрашивать",
"server_select_help": "Нужна помощь?"
}
}
39 changes: 39 additions & 0 deletions SPT-AKI Profile Editor/Views/ServerSelectHelpDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<UserControl
x:Class="SPT_AKI_Profile_Editor.Views.ServerSelectHelpDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SPT_AKI_Profile_Editor.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:Background="White"
d:DataContext="{d:DesignInstance Type=local:ServerSelectHelpDialogViewModel}"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="85" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
Margin="0,10,0,0"
Orientation="Vertical">
<Image Height="320">
<Image.Source>
<BitmapImage UriSource="/Resources/Images/server_folder.jpg" />
</Image.Source>
</Image>
<Label
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Content="{Binding WhatIsServerFolder, FallbackValue=WhatIsServerFolder}"
Template="{StaticResource TitleLabel}" />
</StackPanel>
<Button
Grid.Row="1"
Margin="5,0,5,0"
HorizontalAlignment="Right"
Command="{Binding CancelCommand}"
Content="{Binding AppLocalization.Translations[save_profile_dialog_ok], FallbackValue=save_profile_dialog_ok}"
Style="{DynamicResource MahApps.Styles.Button.Dialogs.Accent}" />
</Grid>
</UserControl>
12 changes: 12 additions & 0 deletions SPT-AKI Profile Editor/Views/ServerSelectHelpDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Windows.Controls;

namespace SPT_AKI_Profile_Editor.Views
{
/// <summary>
/// Логика взаимодействия для ServerSelectHelpDialog.xaml
/// </summary>
public partial class ServerSelectHelpDialog : UserControl
{
public ServerSelectHelpDialog() => InitializeComponent();
}
}
28 changes: 28 additions & 0 deletions SPT-AKI Profile Editor/Views/ServerSelectHelpDialogViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using SPT_AKI_Profile_Editor.Core;
using SPT_AKI_Profile_Editor.Core.HelperClasses;
using SPT_AKI_Profile_Editor.Helpers;

namespace SPT_AKI_Profile_Editor.Views
{
public class ServerSelectHelpDialogViewModel : ClosableDialogViewModel
{
private readonly AppSettings AppSettings;

public ServerSelectHelpDialogViewModel(AppSettings appSettings, object context) : base(context)
{
AppSettings = appSettings;
}

public string WhatIsServerFolder
{
get
{
var prefix = AppLocalization.GetLocalizedString("tab_settings_server") + " - ";
var serverExe = AppSettings.FilesList.ContainsKey(SPTServerFile.serverexe)
? AppSettings.FilesList[SPTServerFile.serverexe]
: "\"settings file corrupted\"";
return prefix + AppLocalization.GetLocalizedString("what_is_server_folder", serverExe);
}
}
}
}
110 changes: 41 additions & 69 deletions SPT-AKI Profile Editor/Views/SettingsDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160" />
<ColumnDefinition Width="40" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label
Expand All @@ -63,7 +64,7 @@
Template="{StaticResource TitleLabel}" />
<Grid
Grid.Row="0"
Grid.Column="2"
Grid.Column="1"
Margin="0,5,0,0"
VerticalAlignment="Top">
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -108,59 +109,17 @@
</Button.CommandParameter>
</extendedcontrols:ButtonFontAwesomeIcon>
</Grid>
<Grid
<Label
Grid.Row="1"
Grid.Column="0"
Margin="0,5,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
Content="{Binding AppLocalization.Translations[tab_settings_server], FallbackValue=tab_settings_server}"
Template="{StaticResource TitleLabel}" />
<iconPacks:PackIconFontAwesome
Grid.Column="1"
Width="24"
Height="24"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{DynamicResource MahApps.Brushes.Accent}"
Kind="QuestionCircleSolid">
<iconPacks:PackIconFontAwesome.ToolTip>
<StackPanel Orientation="Vertical">
<Image>
<Image.Source>
<BitmapImage UriSource="/Resources/Images/server_folder.jpg" />
</Image.Source>
</Image>
<Label
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Content="{Binding WhatIsServerFolder}"
FontWeight="Bold" />
</StackPanel>
</iconPacks:PackIconFontAwesome.ToolTip>
</iconPacks:PackIconFontAwesome>
</Grid>
<iconPacks:PackIconFontAwesome
Grid.Row="1"
Grid.Column="1"
Width="24"
Height="24"
Margin="0,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Foreground="{DynamicResource MahApps.Brushes.Control.Validation}"
Kind="ExclamationTriangleSolid"
ToolTip="{Binding AppLocalization.Translations[invalid_server_location_text]}"
Visibility="{Binding ServerPathValid, Converter={StaticResource FalseToVisibleConverter}}" />
Content="{Binding AppLocalization.Translations[tab_settings_server], FallbackValue=tab_settings_server}"
Template="{StaticResource TitleLabel}" />
<Grid
Grid.Row="1"
Grid.Column="2"
Grid.Column="1"
Margin="10,5,10,0"
VerticalAlignment="Center">
VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="80" />
Expand All @@ -176,27 +135,33 @@
Command="{Binding ServerSelect}"
Content="{Binding AppLocalization.Translations[button_select], FallbackValue=button_select}" />
</Grid>
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="15,0,0,5">
<Hyperlink
Command="{Binding ServerSelectHelp}"
FontSize="12"
Style="{DynamicResource LinkStyle}">
<TextBlock Text="{Binding AppLocalization.Translations[server_select_help], FallbackValue=server_select_help}" />
</Hyperlink>
</TextBlock>
<Label
Grid.Row="2"
Grid.Column="1"
d:Visibility="Visible"
Content="{Binding AppLocalization.Translations[invalid_server_location_text], FallbackValue=invalid_server_location_text}"
Template="{StaticResource ValidationLabel}"
Visibility="{Binding ServerPathValid, Converter={StaticResource FalseToVisibleConverter}}" />
<Label
Grid.Row="3"
Grid.Column="0"
Margin="0,5,0,0"
Content="{Binding AppLocalization.Translations[tab_settings_account], FallbackValue=tab_settings_account}"
Template="{StaticResource TitleLabel}" />
<iconPacks:PackIconFontAwesome
Grid.Row="2"
Grid.Column="1"
Width="24"
Height="24"
Margin="0,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Foreground="{DynamicResource MahApps.Brushes.Control.Validation}"
Kind="ExclamationTriangleSolid"
ToolTip="{Binding AppLocalization.Translations[no_accounts]}"
Visibility="{Binding ServerHasAccounts, Converter={StaticResource FalseToVisibleConverter}}" />
<ComboBox
Grid.Row="2"
Grid.Column="2"
Grid.Row="3"
Grid.Column="1"
Margin="10,5,10,0"
VerticalAlignment="Top"
DisplayMemberPath="Value"
Expand All @@ -205,14 +170,21 @@
SelectedValue="{Binding AppSettings.DefaultProfile}"
SelectedValuePath="Key" />
<Label
Grid.Row="3"
Grid.Row="4"
Grid.Column="1"
d:Visibility="Visible"
Content="{Binding AppLocalization.Translations[no_accounts], FallbackValue=no_accounts}"
Template="{StaticResource ValidationLabel}"
Visibility="{Binding ServerHasAccounts, Converter={StaticResource FalseToVisibleConverter}}" />
<Label
Grid.Row="5"
Grid.Column="0"
Margin="0,5,0,0"
Content="{Binding AppLocalization.Translations[tab_settings_color_scheme], FallbackValue=tab_settings_color_scheme}"
Template="{StaticResource TitleLabel}" />
<ComboBox
Grid.Row="3"
Grid.Column="2"
Grid.Row="5"
Grid.Column="1"
Margin="10,5,10,0"
VerticalAlignment="Top"
ItemsSource="{Binding ColorSchemes}"
Expand All @@ -231,14 +203,14 @@
</ComboBox.ItemTemplate>
</ComboBox>
<Label
Grid.Row="4"
Grid.Row="6"
Grid.Column="0"
Margin="0,5,0,0"
Content="{Binding AppLocalization.Translations[tab_settings_check_updates], FallbackValue=tab_settings_check_updates}"
Template="{StaticResource TitleLabel}" />
<mah:ToggleSwitch
Grid.Row="4"
Grid.Column="2"
Grid.Row="6"
Grid.Column="1"
Margin="12,5,0,0"
VerticalAlignment="Top"
IsOn="{Binding AppSettings.CheckUpdates}"
Expand Down
13 changes: 2 additions & 11 deletions SPT-AKI Profile Editor/Views/SettingsDialogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,9 @@ public SettingsDialogViewModel(RelayCommand closeCommand,

public RelayCommand OpenAppData => new(obj => _applicationManager.OpenUrl(DefaultValues.AppDataFolder));

public RelayCommand QuitCommand => _applicationManager.CloseApplication;
public RelayCommand ServerSelectHelp => new(obj => _dialogManager.OpenServerSelectHelpAsync(AppSettings));

public string WhatIsServerFolder
{
get
{
var serverExe = AppSettings.FilesList.ContainsKey(SPTServerFile.serverexe)
? AppSettings.FilesList[SPTServerFile.serverexe]
: "\"settings file corrupted\"";
return AppLocalization.GetLocalizedString("what_is_server_folder", serverExe);
}
}
public RelayCommand QuitCommand => _applicationManager.CloseApplication;

public RelayCommand ResetAndReload => new(async obj =>
{
Expand Down

0 comments on commit 0fac272

Please sign in to comment.