Skip to content

Commit 8cd5562

Browse files
committed
Add player model selection
1 parent 1d9f3e8 commit 8cd5562

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

Loki/MainWindow.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<RowDefinition Height="Auto" />
112112
<RowDefinition Height="Auto" />
113113
<RowDefinition Height="Auto" />
114+
<RowDefinition Height="Auto" />
114115
</Grid.RowDefinitions>
115116

116117
<!-- Player Name -->
@@ -160,6 +161,14 @@
160161
<TextBlock
161162
FontStyle="Italic" Foreground="Gray"
162163
Grid.Column="3" Grid.Row="5" VerticalAlignment="Center" Margin="6" Text="Experimental! Scales colour for godly radiance"/>
164+
165+
<!-- Player model selection -->
166+
<TextBlock Grid.Column="0" Grid.Row="6" VerticalAlignment="Center" Margin="6">Model</TextBlock>
167+
<ComboBox Grid.Column="1" Grid.Row="6" Width="120"
168+
HorizontalAlignment="Left" VerticalAlignment="Center"
169+
ItemsSource="{x:Static loki:Model.Models}"
170+
SelectedItem="{Binding Profile.Player.Model}"
171+
DisplayMemberPath="DisplayName" />
163172
</Grid>
164173
</TabItem>
165174

Loki/Model.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.CodeDom;
3+
using System.Linq;
4+
5+
namespace Loki
6+
{
7+
public class Model
8+
{
9+
/// <summary>
10+
/// Display name for this model
11+
/// </summary>
12+
public string DisplayName { get; set; }
13+
14+
/// <summary>
15+
/// Internal index for the model.
16+
/// </summary>
17+
public int Index { get; set; }
18+
19+
/// <summary>
20+
/// Creates a model from in internal player model index value.
21+
/// </summary>
22+
/// <param name="modelIndex">Internal index for the player model as stored in the character file.</param>
23+
/// <returns>A model that represents the internal <paramref name="modelIndex"/> provided</returns>
24+
public static Model FromIndex(int modelIndex) =>
25+
Models.FirstOrDefault(m => m.Index == modelIndex) ??
26+
throw new ArgumentOutOfRangeException(nameof(modelIndex),
27+
"Model index out of range of known player models");
28+
29+
/// <summary>
30+
/// All the models that we know about in the game right now.
31+
/// </summary>
32+
public static Model[] Models =
33+
{
34+
new Model {Index = 0, DisplayName = "Male"},
35+
new Model {Index = 1, DisplayName = "Female"},
36+
};
37+
}
38+
}

Loki/Player.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public Hair Hair
5656
set => _hair = value.Code;
5757
}
5858

59+
public Model Model
60+
{
61+
get => Model.FromIndex(_modelIndex);
62+
set => _modelIndex = value.Index;
63+
}
64+
5965
public Color HairColour
6066
{
6167
get => Color.FromScRgb(1.0f, _hairColour.X, _hairColour.Y, _hairColour.Z);

0 commit comments

Comments
 (0)