-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add skeleton for 00battle editing support
- Loading branch information
Showing
7 changed files
with
134 additions
and
4 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,14 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using OpenKh.Kh2; | ||
|
||
namespace OpenKh.Tools.Kh2BattleEditor.Extensions | ||
{ | ||
public static class BarExtensions | ||
{ | ||
public static Stream GetBattleStream(this IEnumerable<Bar.Entry> entries, string name) => | ||
// TODO throws exception if that entry is not found | ||
entries.First(x => x.Name == name && x.Index == 0 && x.Type == Bar.EntryType.Binary).Stream; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
OpenKh.Tools.Kh2BattleEditor/Interfaces/IBattleGetChanges.cs
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,11 @@ | ||
using System.IO; | ||
|
||
namespace OpenKh.Tools.Kh2BattleEditor.Interfaces | ||
{ | ||
public interface IBattleGetChanges | ||
{ | ||
string EntryName { get; } | ||
|
||
Stream CreateStream(); | ||
} | ||
} |
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,40 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using OpenKh.Kh2; | ||
using OpenKh.Kh2.Battle; | ||
using OpenKh.Tools.Kh2BattleEditor.Extensions; | ||
using OpenKh.Tools.Kh2BattleEditor.Interfaces; | ||
using Xe.Tools; | ||
|
||
namespace OpenKh.Tools.Kh2BattleEditor.ViewModels | ||
{ | ||
public class EnmpViewModel : BaseNotifyPropertyChanged, IBattleGetChanges | ||
{ | ||
private readonly BaseBattle<Enmp> _enmp; | ||
|
||
public EnmpViewModel(IEnumerable<Bar.Entry> entries) | ||
{ | ||
_enmp = Enmp.Read(entries.GetBattleStream(EntryName)); | ||
} | ||
|
||
public EnmpViewModel() | ||
{ | ||
_enmp = new BaseBattle<Enmp> | ||
{ | ||
Items = new Enmp[0] | ||
}; | ||
} | ||
|
||
public string EntryName => "enmp"; | ||
|
||
public Stream CreateStream() | ||
{ | ||
var stream = new MemoryStream(); | ||
_enmp.Write(stream); | ||
|
||
return stream; | ||
} | ||
|
||
public string Foo { get; set; } = "Hello world!"; | ||
} | ||
} |
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,12 @@ | ||
<UserControl x:Class="OpenKh.Tools.Kh2BattleEditor.Views.EnmpView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:OpenKh.Tools.Kh2BattleEditor.Views" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid> | ||
<TextBlock Text="{Binding Foo}"/> | ||
</Grid> | ||
</UserControl> |
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,15 @@ | ||
using System.Windows.Controls; | ||
|
||
namespace OpenKh.Tools.Kh2BattleEditor.Views | ||
{ | ||
/// <summary> | ||
/// Interaction logic for EnmpView.xaml | ||
/// </summary> | ||
public partial class EnmpView : UserControl | ||
{ | ||
public EnmpView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
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