-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf4f308
commit e17da4b
Showing
6 changed files
with
176 additions
and
0 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,16 @@ | ||
namespace Yura.Formats | ||
{ | ||
public enum Language | ||
{ | ||
English, | ||
French, | ||
German, | ||
Italian, | ||
Spanish, | ||
Japanese, | ||
Portugese, | ||
Polish, | ||
British, | ||
Russian | ||
} | ||
} |
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,38 @@ | ||
using System.Collections.Generic; | ||
using StreamReader = Yura.IO.StreamReader; | ||
|
||
namespace Yura.Formats | ||
{ | ||
class LocaleFile | ||
{ | ||
public Language Language { get; private set; } | ||
public List<string> Entries { get; private set; } | ||
|
||
public LocaleFile(byte[] data, bool litteEndian) | ||
{ | ||
var reader = new StreamReader(data, litteEndian); | ||
|
||
Entries = new List<string>(); | ||
Language = (Language)reader.ReadUInt32(); | ||
|
||
// read all strings | ||
var numStrings = reader.ReadUInt32(); | ||
|
||
for (int i = 0; i < numStrings; i++) | ||
{ | ||
// offset of the string | ||
var offset = reader.ReadUInt32(); | ||
|
||
// preserve current cursor position | ||
var cursor = reader.BaseStream.Position; | ||
reader.BaseStream.Position = offset; | ||
|
||
// read the string | ||
var str = reader.ReadString(); | ||
Entries.Add(str); | ||
|
||
reader.BaseStream.Position = cursor; | ||
} | ||
} | ||
} | ||
} |
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,36 @@ | ||
<Window x:Class="Yura.LocaleViewer" | ||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:Yura" | ||
mc:Ignorable="d" | ||
Icon="Yura.ico" | ||
Title="locals.bin" Height="450" Width="800"> | ||
<Window.CommandBindings> | ||
<CommandBinding Command="Save" Executed="ExportCommand_Executed"/> | ||
</Window.CommandBindings> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
|
||
<Menu Grid.Row="0"> | ||
<MenuItem Header="_File"> | ||
<MenuItem Command="Save"></MenuItem> | ||
</MenuItem> | ||
</Menu> | ||
|
||
<ListView Grid.Row="1" Name="Entries"> | ||
<ListView.View> | ||
<GridView> | ||
<GridViewColumn Width="100" Header="Id" DisplayMemberBinding="{Binding Index}"/> | ||
<GridViewColumn Width="600" Header="Value" DisplayMemberBinding="{Binding Value}"/> | ||
</GridView> | ||
</ListView.View> | ||
</ListView> | ||
|
||
</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,56 @@ | ||
using Microsoft.Win32; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Input; | ||
using Yura.Formats; | ||
|
||
namespace Yura | ||
{ | ||
/// <summary> | ||
/// Interaction logic for LocaleViewer.xaml | ||
/// </summary> | ||
public partial class LocaleViewer : Window | ||
{ | ||
private LocaleFile _locale; | ||
|
||
public LocaleViewer() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public bool LittleEndian { get; set; } | ||
|
||
public byte[] Data | ||
{ | ||
set | ||
{ | ||
_locale = new LocaleFile(value, LittleEndian); | ||
|
||
// append current language to title | ||
Title += " - " + _locale.Language.ToString(); | ||
|
||
// add all locale entries | ||
Entries.ItemsSource = _locale.Entries.Select((x, i) => new LocaleViewerEntry { Index = i, Value = x }); | ||
} | ||
} | ||
|
||
private void ExportCommand_Executed(object sender, ExecutedRoutedEventArgs e) | ||
{ | ||
var dialog = new SaveFileDialog(); | ||
dialog.Filter = "Text Files (*.txt)|*.txt"; | ||
|
||
if (dialog.ShowDialog() == true) | ||
{ | ||
// write all entries 'index = value' seperated by empty line | ||
File.WriteAllLines(dialog.FileName, _locale.Entries.Select((x, i) => $"{i} = {x}\n")); | ||
} | ||
} | ||
|
||
class LocaleViewerEntry | ||
{ | ||
public int Index { get; set; } | ||
public string Value { get; set; } | ||
} | ||
} | ||
} |
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