-
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.
- Loading branch information
Showing
5 changed files
with
213 additions
and
15 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,98 @@ | ||
using OpenKh.Kh2; | ||
using OpenKh.Kh2.Battle; | ||
using OpenKh.Tools.Kh2BattleEditor.Extensions; | ||
using OpenKh.Tools.Kh2BattleEditor.Interfaces; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Xe.Tools.Wpf.Models; | ||
|
||
namespace OpenKh.Tools.Kh2BattleEditor.ViewModels | ||
{ | ||
public class LvupViewModel : GenericListModel<LvupViewModel.CharacterViewModel>, IBattleGetChanges | ||
{ | ||
private const int DefaultType = 2; | ||
private const string entryName = "lvup"; | ||
private Lvup _lvup; | ||
public string EntryName => entryName; | ||
|
||
public LvupViewModel(IEnumerable<Bar.Entry> entries) : | ||
this(Lvup.Read(entries.GetBattleStream(entryName))) | ||
{ | ||
} | ||
|
||
public LvupViewModel(Lvup Lvup) : | ||
this(Lvup.Characters) | ||
{ | ||
_lvup = Lvup; | ||
} | ||
|
||
public LvupViewModel(IEnumerable<Lvup.Character> characters) : | ||
base(characters.Select((x, i) => new CharacterViewModel(x, i))) | ||
{ | ||
} | ||
|
||
public LvupViewModel() : | ||
this(new Lvup | ||
{ | ||
MagicCode = DefaultType, | ||
Count = 14, | ||
Unknown08 = new byte[0x30], | ||
Characters = new List<Lvup.Character>() | ||
}) | ||
{ | ||
|
||
} | ||
|
||
public Stream CreateStream() | ||
{ | ||
var stream = new MemoryStream(); | ||
new Lvup | ||
{ | ||
MagicCode = _lvup.MagicCode, | ||
Count = _lvup.Count, | ||
Unknown08 = _lvup.Unknown08, | ||
Characters = Items.Select(x => x.Character).ToList() | ||
}.Write(stream); | ||
|
||
return stream; | ||
} | ||
|
||
public class CharacterViewModel : GenericListModel<CharacterViewModel.LevelViewModel> | ||
{ | ||
private int _index; | ||
public Lvup.Character Character { get; set; } | ||
public string Name => ((Lvup.PlayableCharacterType)_index).ToString(); | ||
|
||
public CharacterViewModel(Lvup.Character character, int index) : | ||
base(character.Levels.Select((x, i) => new LevelViewModel(x, i))) | ||
{ | ||
_index = index; | ||
Character = character; | ||
} | ||
|
||
public class LevelViewModel | ||
{ | ||
private Lvup.Character.Level _level; | ||
private int _index; | ||
|
||
public string Name => $"Level {_index + 1}"; | ||
|
||
public LevelViewModel(Lvup.Character.Level level, int index) | ||
{ | ||
_level = level; | ||
_index = index; | ||
} | ||
|
||
public int Exp { get => _level.Exp; set => _level.Exp = value; } | ||
public byte Strength { get => _level.Strength; set => _level.Strength = value; } | ||
public byte Magic { get => _level.Magic; set => _level.Magic = value; } | ||
public byte Defense { get => _level.Defense; set => _level.Defense = value; } | ||
public byte Ap { get => _level.Ap; set => _level.Ap = value; } | ||
public short SwordAbility { get => _level.SwordAbility; set => _level.SwordAbility = value; } | ||
public short ShieldAbility { get => _level.ShieldAbility; set => _level.ShieldAbility = value; } | ||
public short StaffAbility { get => _level.StaffAbility; set => _level.StaffAbility = value; } | ||
} | ||
} | ||
} | ||
} |
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,62 @@ | ||
<UserControl x:Class="OpenKh.Tools.Kh2BattleEditor.Views.LvupView" | ||
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:controls="clr-namespace:Xe.Tools.Wpf.Controls;assembly=Xe.Tools.Wpf" | ||
xmlns:local="clr-namespace:OpenKh.Tools.Kh2BattleEditor.Views" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="10"/> | ||
<RowDefinition Height="2*"/> | ||
</Grid.RowDefinitions> | ||
<StackPanel Orientation="Horizontal" Grid.Row="0" VerticalAlignment="Center"> | ||
<TextBlock Text="Character" Margin="0 2 5 0"/> | ||
<ComboBox Width="200" | ||
ItemsSource="{Binding Items}" | ||
SelectedIndex="{Binding SelectedIndex}" | ||
SelectedItem="{Binding SelectedItem}" | ||
DisplayMemberPath="Name"/> | ||
</StackPanel> | ||
<Grid Grid.Row="2"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="100"/> | ||
<ColumnDefinition Width="10"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<ListBox Grid.Column="0" | ||
ItemsSource="{Binding SelectedItem.Items}" | ||
SelectedIndex="{Binding SelectedItem.SelectedIndex}" | ||
SelectedItem="{Binding SelectedItem.SelectedItem}" | ||
DisplayMemberPath="Name" /> | ||
<controls:TwoColumnsPanel Grid.Column="2" RowSpacing="3" DataContext="{Binding SelectedItem.SelectedItem}"> | ||
<TextBlock Text="EXP for Level Up" /> | ||
<TextBox Text="{Binding Exp, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<TextBlock Text="Strength" /> | ||
<TextBox Text="{Binding Strength, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<TextBlock Text="Magic" /> | ||
<TextBox Text="{Binding Magic, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<TextBlock Text="Defense" /> | ||
<TextBox Text="{Binding Defense, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<TextBlock Text="AP" /> | ||
<TextBox Text="{Binding Ap, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<TextBlock Text="Sword ability" /> | ||
<TextBox Text="{Binding SwordAbility, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<TextBlock Text="Shield ability" /> | ||
<TextBox Text="{Binding ShieldAbility, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<TextBlock Text="Staff ability" /> | ||
<TextBox Text="{Binding StaffAbility, UpdateSourceTrigger=PropertyChanged}" /> | ||
</controls:TwoColumnsPanel> | ||
</Grid> | ||
</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,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace OpenKh.Tools.Kh2BattleEditor.Views | ||
{ | ||
/// <summary> | ||
/// Interaction logic for LvupView.xaml | ||
/// </summary> | ||
public partial class LvupView : UserControl | ||
{ | ||
public LvupView() | ||
{ | ||
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