Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/imchillin/Anamnesis
Browse files Browse the repository at this point in the history
  • Loading branch information
Luminiari committed Jul 13, 2022
2 parents adf4caa + cda0df3 commit 2ad2d2f
Show file tree
Hide file tree
Showing 113 changed files with 6,980 additions and 4,451 deletions.
158 changes: 158 additions & 0 deletions Anamnesis/Actor/Names.cs
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();
}
}
12 changes: 8 additions & 4 deletions Anamnesis/Actor/Pages/ActionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Anamnesis.Actor.Pages;
using Anamnesis.Styles;
using Anamnesis.Styles.Drawers;
using PropertyChanged;
using System;

[AddINotifyPropertyChangedInterface]
public partial class ActionPage : UserControl
Expand Down Expand Up @@ -90,7 +91,8 @@ private void OnBaseAnimationSearchClicked(object sender, RoutedEventArgs e)
if (this.Actor == null)
return;

AnimationSelector animSelector = SelectorDrawer.Show<AnimationSelector, IAnimation>(null, (animation) =>
throw new NotImplementedException();
/*AnimationSelector animSelector = SelectorControl.Show<AnimationSelector, IAnimation>(null, (animation) =>
{
if (animation == null || animation.Timeline == null)
return;
Expand All @@ -103,15 +105,17 @@ private void OnBaseAnimationSearchClicked(object sender, RoutedEventArgs e)
IncludeBlendable = false,
IncludeFullBody = true,
SlotsLocked = true,
};
};*/
}

private void OnBlendAnimationSearchClicked(object sender, RoutedEventArgs e)
{
if (this.Actor == null)
return;

AnimationSelector animSelector = SelectorDrawer.Show<AnimationSelector, IAnimation>(null, (animation) =>
throw new NotImplementedException();

/*AnimationSelector animSelector = SelectorControl.Show<AnimationSelector, IAnimation>(null, (animation) =>
{
if (animation == null || animation.Timeline == null)
return;
Expand All @@ -124,7 +128,7 @@ private void OnBlendAnimationSearchClicked(object sender, RoutedEventArgs e)
IncludeBlendable = true,
IncludeFullBody = true,
SlotsLocked = false,
};
};*/
}

private void OnApplyOverrideAnimation(object sender, RoutedEventArgs e)
Expand Down
7 changes: 4 additions & 3 deletions Anamnesis/Actor/Pages/CharacterPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace Anamnesis.Actor.Pages;
using Anamnesis.Files;
using Anamnesis.GameData;
using Anamnesis.GameData.Excel;
using Anamnesis.GUI.Dialogs;
using Anamnesis.Keyboard;
using Anamnesis.Memory;
using Anamnesis.Services;
using Anamnesis.Styles;
using Anamnesis.Styles.Drawers;
using Anamnesis.Windows;
using PropertyChanged;
using Serilog;

Expand Down Expand Up @@ -244,13 +244,14 @@ private void OnImportNpcWeaponsClicked(object sender, RoutedEventArgs e)

private void ImportNpc(CharacterFile.SaveModes mode)
{
SelectorDrawer.Show<NpcSelector, INpcBase>(null, (npc) =>
throw new NotImplementedException();
/*SelectorControl.Show<NpcSelector, INpcBase>(null, (npc) =>
{
if (npc == null)
return;
Task.Run(() => this.ApplyNpc(npc, mode));
});
});*/
}

private async Task ApplyNpc(INpcBase? npc, CharacterFile.SaveModes mode = CharacterFile.SaveModes.All)
Expand Down
2 changes: 1 addition & 1 deletion Anamnesis/Actor/Pages/PosePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ namespace Anamnesis.Actor.Pages;
using System.Windows.Input;
using System.Windows.Media.Media3D;
using Anamnesis.Files;
using Anamnesis.GUI.Dialogs;
using Anamnesis.Memory;
using Anamnesis.Actor.Views;
using Anamnesis.Services;
using PropertyChanged;
using Serilog;
using XivToolsWpf;
using CmQuaternion = Anamnesis.Memory.Quaternion;
using Anamnesis.Windows;

/// <summary>
/// Interaction logic for CharacterPoseView.xaml.
Expand Down
128 changes: 128 additions & 0 deletions Anamnesis/Actor/Panels/ActorInfoPanel.xaml
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>
Loading

0 comments on commit 2ad2d2f

Please sign in to comment.