-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/imchillin/Anamnesis
- Loading branch information
Showing
113 changed files
with
6,980 additions
and
4,451 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,158 @@ | ||
// © Anamnesis. | ||
// Licensed under the MIT license. | ||
|
||
namespace Anamnesis.Actor; | ||
|
||
using Anamnesis.Memory; | ||
using Anamnesis.Services; | ||
using PropertyChanged; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
|
||
[AddINotifyPropertyChangedInterface] | ||
public class Names : INotifyPropertyChanged | ||
{ | ||
private readonly ActorBasicMemory actor; | ||
private string? nickname; | ||
|
||
public Names(ActorBasicMemory owner) | ||
{ | ||
this.actor = owner; | ||
this.actor.PropertyChanged += this.OnActorPropertyChanged; | ||
|
||
this.Update(); | ||
} | ||
|
||
public event PropertyChangedEventHandler? PropertyChanged; | ||
|
||
public enum DisplayModes | ||
{ | ||
FullName, | ||
Initials, | ||
SurnameAbreviated, | ||
ForenameAbreviated, | ||
} | ||
|
||
public string? Nickname | ||
{ | ||
get => this.nickname; | ||
set | ||
{ | ||
this.nickname = value; | ||
this.Update(); | ||
} | ||
} | ||
|
||
public string FullName { get; private set; } = string.Empty; | ||
public string DisplayName => this.Nickname ?? this.FullName; | ||
|
||
public string Initials { get; private set; } = string.Empty; | ||
public string SurnameAbreviated { get; private set; } = string.Empty; | ||
public string ForenameAbreviated { get; private set; } = string.Empty; | ||
|
||
public string Text | ||
{ | ||
get | ||
{ | ||
switch (this.DisplayMode) | ||
{ | ||
case DisplayModes.FullName: return this.DisplayName; | ||
case DisplayModes.Initials: return this.Initials; | ||
case DisplayModes.SurnameAbreviated: return this.SurnameAbreviated; | ||
case DisplayModes.ForenameAbreviated: return this.ForenameAbreviated; | ||
} | ||
|
||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
// Should be a setting. | ||
private DisplayModes DisplayMode => DisplayModes.FullName; | ||
|
||
public void Update() | ||
{ | ||
this.FullName = this.actor.NameBytes.ToString(); | ||
|
||
this.Initials = string.Empty; | ||
this.SurnameAbreviated = string.Empty; | ||
this.ForenameAbreviated = string.Empty; | ||
|
||
if (string.IsNullOrEmpty(this.FullName) && string.IsNullOrEmpty(this.Nickname)) | ||
return; | ||
|
||
string[] spaceSeperatedParts; | ||
|
||
if (this.Nickname == null) | ||
{ | ||
// Remove anything after '(' for game names. | ||
string[] parts = this.FullName.Split('(', StringSplitOptions.RemoveEmptyEntries); | ||
spaceSeperatedParts = parts[0].Split(' ', StringSplitOptions.RemoveEmptyEntries); | ||
} | ||
else | ||
{ | ||
spaceSeperatedParts = this.Nickname.Split(' ', StringSplitOptions.RemoveEmptyEntries); | ||
} | ||
|
||
for (int i = 0; i < spaceSeperatedParts.Length; i++) | ||
{ | ||
if (spaceSeperatedParts[i].Length <= 0 || string.IsNullOrWhiteSpace(spaceSeperatedParts[i])) | ||
continue; | ||
|
||
char initial = spaceSeperatedParts[i][0]; | ||
|
||
this.Initials += " ." + initial; | ||
|
||
if (i == 0) | ||
{ | ||
this.SurnameAbreviated += " ." + spaceSeperatedParts[i]; | ||
} | ||
else | ||
{ | ||
this.SurnameAbreviated += " ." + initial; | ||
} | ||
|
||
if (i == spaceSeperatedParts.Length - 1) | ||
{ | ||
this.ForenameAbreviated += ". " + spaceSeperatedParts[i]; | ||
} | ||
else | ||
{ | ||
this.ForenameAbreviated += " ." + initial; | ||
} | ||
} | ||
|
||
this.Initials = this.Initials.Trim(' ').Trim('.'); | ||
this.SurnameAbreviated = this.SurnameAbreviated.Trim(' ').Trim('.'); | ||
this.ForenameAbreviated = this.ForenameAbreviated.Trim(' ').Trim('.'); | ||
} | ||
|
||
public void GenerateRandomName() | ||
{ | ||
List<string> keys = new(); | ||
LocalizationService.Locale? english = LocalizationService.GetLocale(LocalizationService.FallbackCulture); | ||
|
||
if (english == null) | ||
return; | ||
|
||
foreach ((string pKey, string pValue) in english.Entries) | ||
{ | ||
if (pValue.Contains(' ')) | ||
continue; | ||
|
||
keys.Add(pKey); | ||
} | ||
|
||
string first = english.Entries[keys[Random.Shared.Next(keys.Count)]]; | ||
string last = english.Entries[keys[Random.Shared.Next(keys.Count)]]; | ||
this.Nickname = first + " " + last; | ||
} | ||
|
||
private void OnActorPropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName != nameof(ActorBasicMemory.NameBytes)) | ||
return; | ||
|
||
this.Update(); | ||
} | ||
} |
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
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,128 @@ | ||
<local:ActorPanelBase | ||
x:Class="Anamnesis.Actor.Panels.ActorInfoPanel" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:XivToolsWpf="clr-namespace:XivToolsWpf.Controls;assembly=XivToolsWpf" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Anamnesis.Actor.Panels" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:panels="clr-namespace:Anamnesis.Panels" | ||
xmlns:views="clr-namespace:Anamnesis.Actor.Views" | ||
Width="256" | ||
Icon="Pen" | ||
TitleKey="Naviagation_Actor_Info" | ||
mc:Ignorable="d"> | ||
|
||
<Grid | ||
x:Name="ContentArea" | ||
Margin="6"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
</Grid.RowDefinitions> | ||
|
||
<XivToolsWpf:TextBlock | ||
Key="Character_Actor_Nickname" | ||
Grid.Row="0" | ||
Grid.Column="0" | ||
Style="{StaticResource Label}" /> | ||
|
||
<TextBox | ||
Grid.Row="0" | ||
Grid.Column="1" | ||
Grid.ColumnSpan="2" | ||
Style="{StaticResource MaterialDesignTextBox}" | ||
Text="{Binding Actor.Names.Nickname, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<XivToolsWpf:TextBlock | ||
Key="Character_Actor_Alpha" | ||
Grid.Row="4" | ||
Grid.Column="0" | ||
Style="{StaticResource Label}" /> | ||
<XivToolsWpf:NumberBox | ||
Grid.Row="4" | ||
Grid.Column="1" | ||
Maximum="1" | ||
Minimum="0.01" | ||
Slider="Absolute" | ||
TickFrequency="0.1" | ||
Value="{Binding Actor.Transparency}" /> | ||
|
||
<XivToolsWpf:TextBlock | ||
Key="Character_Actor_Voice" | ||
Grid.Row="5" | ||
Grid.Column="0" | ||
Style="{StaticResource Label}" /> | ||
<ComboBox | ||
Grid.Row="5" | ||
Grid.Column="1" | ||
IsEnabled="{Binding Actor.IsPlayer}" | ||
ItemsSource="{Binding VoiceEntries, Mode=OneTime}" | ||
SelectedValue="{Binding Actor.Voice, Mode=TwoWay}" | ||
SelectedValuePath="VoiceId"> | ||
<ComboBox.GroupStyle> | ||
<GroupStyle> | ||
<GroupStyle.HeaderTemplate> | ||
<DataTemplate> | ||
<XivToolsWpf:TextBlock | ||
Padding="10,5" | ||
HorizontalAlignment="Left" | ||
FontSize="13" | ||
FontStyle="Italic" | ||
FontWeight="Bold" | ||
Style="{StaticResource Label}" | ||
Text="{Binding Name}" /> | ||
|
||
</DataTemplate> | ||
</GroupStyle.HeaderTemplate> | ||
</GroupStyle> | ||
</ComboBox.GroupStyle> | ||
<ComboBox.ItemTemplate> | ||
<DataTemplate> | ||
<TextBlock Text="{Binding VoiceName}" /> | ||
</DataTemplate> | ||
</ComboBox.ItemTemplate> | ||
</ComboBox> | ||
|
||
|
||
<XivToolsWpf:TextBlock | ||
Key="SubActor_Title" | ||
Grid.Row="6" | ||
Grid.Column="0" | ||
Style="{StaticResource Label}" /> | ||
|
||
<StackPanel | ||
Grid.Row="6" | ||
Grid.Column="1" | ||
Margin="0,6,0,0" | ||
Orientation="Horizontal"> | ||
<views:SubActorEditor | ||
Margin="3,0" | ||
Actor="{Binding Actor}" | ||
SubActor="{Binding Actor.Mount}" | ||
SubActorType="Mount" /> | ||
<views:SubActorEditor | ||
Margin="3,0" | ||
Actor="{Binding Actor}" | ||
SubActor="{Binding Actor.Companion}" | ||
SubActorType="Companion" /> | ||
<views:SubActorEditor | ||
Margin="3,0" | ||
Actor="{Binding Actor}" | ||
SubActor="{Binding Actor.Ornament}" | ||
SubActorType="Ornament" /> | ||
</StackPanel> | ||
|
||
</Grid> | ||
|
||
</local:ActorPanelBase> |
Oops, something went wrong.