Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions src/XIVLauncher/Windows/SettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,22 @@

<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0, 20, 0, 0"
Foreground="{DynamicResource MaterialDesignBody}" Text="{Binding ChooseLauncherLanguageLoc}" />
<ComboBox SelectedIndex="1" Margin="0, 3, 0, 0" x:Name="LauncherLanguageComboBox"
Foreground="{DynamicResource MaterialDesignBody}" SelectionChanged="LauncherLanguageCombo_SelectionChanged">
<ComboBoxItem>日本語</ComboBoxItem>
<ComboBoxItem>English</ComboBoxItem>
<ComboBoxItem>Deutsch</ComboBoxItem>
<ComboBoxItem>Français</ComboBoxItem>
<ComboBoxItem>Italiano</ComboBoxItem>
<ComboBoxItem>Español</ComboBoxItem>
<ComboBoxItem>Português</ComboBoxItem>
<ComboBoxItem>한국어</ComboBoxItem>
<ComboBoxItem>Norsk</ComboBoxItem>
<ComboBoxItem>русский</ComboBoxItem>
<ComboBoxItem>简体中文</ComboBoxItem>
<ComboBoxItem>繁體中文</ComboBoxItem>
<ComboBoxItem>svenska</ComboBoxItem>
</ComboBox>
<ComboBox
Margin="0,3,0,0"
DisplayMemberPath="Display"
Foreground="{DynamicResource MaterialDesignBody}"
ItemsSource="{Binding LauncherLanguageList}"
SelectedValue="{Binding LauncherLanguage}"
SelectedValuePath="Value" />
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0, 20, 0, 0"
Foreground="{DynamicResource MaterialDesignBody}" Text="{Binding LauncherLanguageHelpCtaLoc}" TextDecorations="Underline" MouseLeftButtonUp="OpenI18nLabel_OnClick" Cursor="Hand"/>
<TextBlock x:Name="LauncherLanguageNoticeTextBlock" Visibility="Hidden"
HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="OrangeRed"
Margin="0,0,0,0" Text="{Binding LauncherLanguageNoticeLoc}" />
<TextBlock
Margin="0,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Foreground="OrangeRed"
Text="{Binding LauncherLanguageNoticeLoc}"
Visibility="{Binding LauncherLanguageNoticeVisiable}" />
</StackPanel>
</TabItem>
<TabItem Header="{Binding SettingsAutoLaunchLoc}">
Expand Down
16 changes: 3 additions & 13 deletions src/XIVLauncher/Windows/SettingsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public void ReloadSettings()
ViewModel.PatchPath = App.Settings.PatchPath.FullName;

LanguageComboBox.SelectedIndex = (int) App.Settings.Language.GetValueOrDefault(ClientLanguage.English);
LauncherLanguageComboBox.SelectedIndex = (int) App.Settings.LauncherLanguage.GetValueOrDefault(LauncherLanguage.English);
LauncherLanguageNoticeTextBlock.Visibility = Visibility.Hidden;
ViewModel.LauncherLanguage = App.Settings.LauncherLanguage.GetValueOrDefault(LauncherLanguage.English);
ViewModel.LauncherLanguageNoticeVisiable = Visibility.Hidden;
AddonListView.ItemsSource = App.Settings.AddonList ??= new List<AddonEntry>();
AskBeforePatchingCheckBox.IsChecked = App.Settings.AskBeforePatchInstall;
KeepPatchesCheckBox.IsChecked = App.Settings.KeepPatches;
Expand Down Expand Up @@ -104,9 +104,7 @@ private void AcceptButton_Click(object sender, RoutedEventArgs e)

App.Settings.Language = (ClientLanguage)LanguageComboBox.SelectedIndex;
// Keep the notice visible if LauncherLanguage has changed
if (App.Settings.LauncherLanguage == (LauncherLanguage)LauncherLanguageComboBox.SelectedIndex)
LauncherLanguageNoticeTextBlock.Visibility = Visibility.Hidden;
App.Settings.LauncherLanguage = (LauncherLanguage)LauncherLanguageComboBox.SelectedIndex;
App.Settings.LauncherLanguage = ViewModel.LauncherLanguage;

App.Settings.AddonList = (List<AddonEntry>)AddonListView.ItemsSource;
App.Settings.AskBeforePatchInstall = AskBeforePatchingCheckBox.IsChecked == true;
Expand Down Expand Up @@ -289,14 +287,6 @@ private void RunIntegrityCheck_OnClick(object s, RoutedEventArgs e)
window.ShowDialog();
}

private void LauncherLanguageCombo_SelectionChanged(object sender, RoutedEventArgs e)
{
if (LauncherLanguageNoticeTextBlock != null)
{
LauncherLanguageNoticeTextBlock.Visibility = Visibility.Visible;
}
}

private void EnableHooksCheckBox_OnChecked(object sender, RoutedEventArgs e)
{
try
Expand Down
64 changes: 64 additions & 0 deletions src/XIVLauncher/Windows/ViewModel/SettingsControlViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,53 @@ public string PatchPath
}
}

private static List<string> LauncherLanguageStrings { get; } =
[
"日本語",
"English",
"Deutsch",
"Français",
"Italiano",
"Español",
"Português",
"한국어",
"Norsk",
"русский",
"简体中文",
"繁體中文",
"svenska"
];

public List<GenericCombinedData<LauncherLanguage>> LauncherLanguageList { get; } = LauncherLanguageStrings
.Zip(Enum.GetValues(typeof(LauncherLanguage)).Cast<LauncherLanguage>())
.Select(pair => new GenericCombinedData<LauncherLanguage>() { Display = pair.First, Value = pair.Second })
.ToList();

private LauncherLanguage _launcherLanguage = LauncherLanguage.Japanese;

public LauncherLanguage LauncherLanguage
{
get => _launcherLanguage;
set
{
LauncherLanguageNoticeVisiable = App.Settings.LauncherLanguage == value ? Visibility.Hidden : Visibility.Visible;
_launcherLanguage = value;
OnPropertyChanged(nameof(LauncherLanguage));
}
}

public Visibility _launcherLanguageNoticeVisiable = Visibility.Hidden;

public Visibility LauncherLanguageNoticeVisiable
{
get => _launcherLanguageNoticeVisiable;
set
{
_launcherLanguageNoticeVisiable = value;
OnPropertyChanged(nameof(LauncherLanguageNoticeVisiable));
}
}

private void SetupLoc()
{
OpenPluginsFolderLoc = Loc.Localize("OpenPluginsFolder", "Open Plugins Folder");
Expand Down Expand Up @@ -248,4 +295,21 @@ private void SetupLoc()

public string PluginDisabledTagLoc { get; private set; }
}

/// <summary>
/// Generic combined data class.
/// </summary>
/// <typeparam name="TValueType">The type of value.</typeparam>
public class GenericCombinedData<TValueType>
{
/// <summary>
/// Gets or sets the name displayed.
/// </summary>
public string Display { get; set; }

/// <summary>
/// Gets or sets the value.
/// </summary>
public TValueType Value { get; set; }
}
}