Skip to content

Commit

Permalink
Localize parts of the MainWindow as a test
Browse files Browse the repository at this point in the history
  • Loading branch information
taubenangriff committed Jun 12, 2023
1 parent fbdf9db commit dfa6d61
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 19 deletions.
20 changes: 19 additions & 1 deletion AnnoMapEditor/UI/Windows/Main/DataPathStatus.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
using System.Windows;
using System;
using System.Windows;

namespace AnnoMapEditor.UI.Windows.Main
{
public enum DataPathStatusType {
LoadingRDA,
GamePathSet,
ExtractedRdaPathSet,
GamePathInvalid
}

public enum ConfigureType {
Change,
Select
}

public class DataPathStatus
{
[Obsolete]
public string Status { get; set; } = string.Empty;

public DataPathStatusType StatusType { get; set; }

public string? ToolTip { get; set; }

public Visibility AutoDetect { get; set; } = Visibility.Collapsed;

public Visibility Configure { get; set; } = Visibility.Visible;

[Obsolete]
public string ConfigureText { get; set; } = string.Empty;
public ConfigureType ConfigureType { get; set; }
}
}
14 changes: 13 additions & 1 deletion AnnoMapEditor/UI/Windows/Main/ExportStatus.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
namespace AnnoMapEditor.UI.Windows.Main
using System;

namespace AnnoMapEditor.UI.Windows.Main
{
public enum ExportAsModStatus {
LoadingRDA,
ExportOnlyOldWorld,
SetGamePath,
AsPlayableMod
}
public class ExportStatus
{
public bool CanExportAsMod { get; set; }

[Obsolete]
public string ExportAsModText { get; set; } = "";

public ExportAsModStatus TextStatus { get; set; } = ExportAsModStatus.LoadingRDA;
}
}
24 changes: 15 additions & 9 deletions AnnoMapEditor/UI/Windows/Main/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
xmlns:islandProperties="clr-namespace:AnnoMapEditor.UI.Controls.IslandProperties"
xmlns:local="clr-namespace:AnnoMapEditor.UI.Windows.Main"
xmlns:overlays="clr-namespace:AnnoMapEditor.UI.Overlays"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
lex:LocalizeDictionary.DesignCulture="en"
lex:ResxLocalizationProvider.DefaultAssembly="AnnoMapEditor"
lex:ResxLocalizationProvider.DefaultDictionary="Texts"
d:DataContext="{d:DesignInstance Type=local:MainWindowViewModel}"
mc:Ignorable="d"
Title="MainWindow" Height="900" Width="1440"
Expand Down Expand Up @@ -53,21 +57,21 @@
<TextBlock
Style="{StaticResource HeaderLabelStyle}"
HorizontalAlignment="Left"
Text="Session"/>
Text="{lex:Loc Key=Session}"/>
<StackPanel Margin="0,0,0,4" VerticalAlignment="Top" Orientation="Horizontal">
<controls:DropDownButton HorizontalAlignment="Left">
<ContentControl Content="Open" />
<ContentControl Content="{lex:Loc Key=OpenFile}" />
<controls:DropDownButton.Menu>
<ContextMenu Name="openMapMenu" />
</controls:DropDownButton.Menu>
</controls:DropDownButton>
<controls:DropDownButton HorizontalAlignment="Left"
IsEnabled="{Binding SessionChecker.HasErrors, Converter={StaticResource booleanNot}}">
<ContentControl Content="Save" />
<ContentControl Content="{lex:Loc Key=SaveFile}" />
<controls:DropDownButton.Menu>
<ContextMenu>
<MenuItem Header="As map template..." Click="ExportMap_Click"/>
<MenuItem Header="{Binding ExportStatus.ExportAsModText, UpdateSourceTrigger=PropertyChanged}" Click="ExportMod_Click" IsEnabled="{Binding ExportStatus.CanExportAsMod, UpdateSourceTrigger=PropertyChanged}" />
<MenuItem Header="{lex:Loc Key=SaveAsMapTemplate}" Click="ExportMap_Click"/>
<MenuItem Header="{lex:Loc {Binding Path=ExportStatus.TextStatus, UpdateSourceTrigger=PropertyChanged, Converter={lex:PrependTypeConverter}}}" Click="ExportMod_Click" IsEnabled="{Binding ExportStatus.CanExportAsMod, UpdateSourceTrigger=PropertyChanged}" />
</ContextMenu>
</controls:DropDownButton.Menu>
</controls:DropDownButton>
Expand All @@ -94,14 +98,16 @@
Orientation="Horizontal"
VerticalAlignment="Bottom"
Margin="8,0,0,0">
<emoji:TextBlock Text="{Binding DataPathStatus.Status, UpdateSourceTrigger=PropertyChanged}"
<emoji:TextBlock Text="{lex:Loc {Binding Path=DataPathStatus.StatusType, UpdateSourceTrigger=PropertyChanged, Converter={lex:PrependTypeConverter}}}"
ToolTip="{Binding DataPathStatus.ToolTip, UpdateSourceTrigger=PropertyChanged}" />
<Button Click="Configure_Click" HorizontalAlignment="Left"
Visibility="{Binding DataPathStatus.Configure, UpdateSourceTrigger=PropertyChanged}">
<TextBlock Text="{Binding DataPathStatus.ConfigureText, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="{lex:Loc {Binding DataPathStatus.ConfigureType, UpdateSourceTrigger=PropertyChanged, Converter={lex:PrependTypeConverter}}}"/>
</Button>
<Button Click="AutoDetect_Click" HorizontalAlignment="Left"
Visibility="{Binding DataPathStatus.AutoDetect, UpdateSourceTrigger=PropertyChanged}">Auto detect</Button>
<Button Click="AutoDetect_Click"
HorizontalAlignment="Left"
Visibility="{Binding DataPathStatus.AutoDetect, UpdateSourceTrigger=PropertyChanged}"
Content="{lex:Loc Key=AutoDetect}"></Button>
</StackPanel>
<TextBlock Grid.Column="2"
Grid.Row="1"
Expand Down
16 changes: 8 additions & 8 deletions AnnoMapEditor/UI/Windows/Main/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void UpdateExportStatus()
ExportStatus = new ExportStatus()
{
CanExportAsMod = false,
ExportAsModText = "(loading RDA...)"
TextStatus = ExportAsModStatus.LoadingRDA
};
}
else if (Settings.IsValidDataPath)
Expand All @@ -218,14 +218,14 @@ private void UpdateExportStatus()
ExportStatus = new ExportStatus()
{
CanExportAsMod = archiveReady && supportedFormat,
ExportAsModText = archiveReady ? supportedFormat ? "As playable mod..." : "As mod: only works with Old World maps currently" : "As mod: set game path to save"
TextStatus = archiveReady ? supportedFormat ? ExportAsModStatus.AsPlayableMod : ExportAsModStatus.ExportOnlyOldWorld : ExportAsModStatus.SetGamePath
};
}
else
{
ExportStatus = new ExportStatus()
{
ExportAsModText = "As mod: set game path to save",
TextStatus = ExportAsModStatus.SetGamePath,
CanExportAsMod = false
};
}
Expand All @@ -238,7 +238,7 @@ private void UpdateStatusAndMenus()
// still loading
DataPathStatus = new DataPathStatus()
{
Status = "loading RDA...",
StatusType = DataPathStatusType.LoadingRDA,
ToolTip = "",
Configure = Visibility.Collapsed,
AutoDetect = Visibility.Collapsed,
Expand All @@ -248,9 +248,9 @@ private void UpdateStatusAndMenus()
{
DataPathStatus = new DataPathStatus()
{
Status = Settings.DataArchive is RdaDataArchive ? "Game path set ✔" : "Extracted RDA path set ✔",
StatusType = Settings.DataArchive is RdaDataArchive ? DataPathStatusType.GamePathSet : DataPathStatusType.ExtractedRdaPathSet,
ToolTip = Settings.DataArchive.DataPath,
ConfigureText = "Change...",
ConfigureType = ConfigureType.Change,
AutoDetect = Settings.DataArchive is RdaDataArchive ? Visibility.Collapsed : Visibility.Visible,
};

Expand Down Expand Up @@ -283,9 +283,9 @@ private void UpdateStatusAndMenus()
{
DataPathStatus = new DataPathStatus()
{
Status = "⚠ Game or RDA path not valid.",
StatusType = DataPathStatusType.GamePathInvalid,
ToolTip = null,
ConfigureText = "Select...",
ConfigureType = ConfigureType.Select,
AutoDetect = Visibility.Visible,
};

Expand Down

0 comments on commit dfa6d61

Please sign in to comment.