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
Ani-ki committed Aug 23, 2022
2 parents d7e4381 + f734b2d commit 854fac5
Show file tree
Hide file tree
Showing 18 changed files with 269 additions and 132 deletions.
18 changes: 18 additions & 0 deletions Anamnesis/Actor/Pages/ActionPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<XivToolsWpf:TextBlock Key="Character_Action_GlobalFreezeWorldPositions"
Expand Down Expand Up @@ -428,6 +429,23 @@
<fa:IconBlock Icon="Stopwatch" FontSize="10"/>
</ToggleButton>

<XivToolsWpf:TextBlock Key="Character_Action_GlobalAllActorSpeedControl"
Grid.Row="2"
Grid.Column="0"
Style="{StaticResource Label}" />

<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center" IsEnabled="{Binding GposeService.IsGpose}">
<Button Style="{StaticResource TransparentButton}" Click="OnResumeAll">
<XivToolsWpf:IconBlock Icon="Play"/>
</Button>

<Separator Opacity="0" Width="5"/>

<Button Style="{StaticResource TransparentButton}" Click="OnPauseAll">
<XivToolsWpf:IconBlock Icon="Pause"/>
</Button>
</StackPanel>

</Grid>
</GroupBox>

Expand Down
28 changes: 28 additions & 0 deletions Anamnesis/Actor/Pages/ActionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,34 @@ private void OnResetOverrideAnimation(object sender, RoutedEventArgs e)
this.AnimationService.ResetAnimationOverride(this.Actor);
}

private void OnResumeAll(object sender, RoutedEventArgs e)
{
AnimationService.Instance.SpeedControlEnabled = true;

foreach(var target in TargetService.Instance.PinnedActors)
{
if(target.IsValid && target.Memory != null && target.Memory.IsValid)
{
target.Memory.Animation!.LinkSpeeds = true;
target.Memory.Animation!.Speeds![0]!.Value = 1.0f;
}
}
}

private void OnPauseAll(object sender, RoutedEventArgs e)
{
AnimationService.Instance.SpeedControlEnabled = true;

foreach (var target in TargetService.Instance.PinnedActors)
{
if (target.IsValid && target.Memory != null && target.Memory.IsValid)
{
target.Memory.Animation!.LinkSpeeds = true;
target.Memory.Animation!.Speeds![0]!.Value = 0.0f;
}
}
}

[AddINotifyPropertyChangedInterface]
public class UserAnimationOverride
{
Expand Down
50 changes: 28 additions & 22 deletions Anamnesis/Actor/Posing/Views/Pose3DView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,37 @@
</Viewport3D>
</Grid>

<Grid Grid.Column="1" Grid.RowSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="{Binding Skeleton.BoneSearch, UpdateSourceTrigger=PropertyChanged}" Margin="6" Style="{StaticResource MaterialDesignTextBox}"/>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding Skeleton.BoneSearchResult}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Disabled" Grid.RowSpan="2">
<ItemsControl ItemsSource="{Binding Skeleton.AllBones}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<views:BoneView Grid.Column="0" />

<views:BoneView Grid.Column="0" />

<XivToolsWpf:TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontSize="11"
FontWeight="Light"
Text="{Binding Tooltip}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<XivToolsWpf:TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontSize="11"
FontWeight="Light"
Text="{Binding Tooltip}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

</Grid>
</Grid>
</Grid>
</UserControl>
6 changes: 6 additions & 0 deletions Anamnesis/Actor/Posing/Visuals/SkeletonVisual3d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Anamnesis.Actor;
using PropertyChanged;
using Serilog;
using XivToolsWpf;
using System.Linq;
using System.IO.Enumeration;

using AnQuaternion = Anamnesis.Memory.Quaternion;

Expand Down Expand Up @@ -65,6 +67,10 @@ public enum SelectMode
public IEnumerable<BoneVisual3d> MainHandBones => this.mainHandBones;
public IEnumerable<BoneVisual3d> OffHandBones => this.offHandBones;

public string BoneSearch { get; set; } = string.Empty;

public IEnumerable<BoneVisual3d> BoneSearchResult => string.IsNullOrWhiteSpace(this.BoneSearch) ? this.AllBones : this.AllBones.Where(b => FileSystemName.MatchesSimpleExpression($"*{this.BoneSearch}*", b.BoneName) || FileSystemName.MatchesSimpleExpression($"*{this.BoneSearch}*", b.Tooltip));

public bool FlipSides
{
get => SettingsService.Current.FlipPoseGuiSides;
Expand Down
2 changes: 1 addition & 1 deletion Anamnesis/Actor/Utilities/SubActorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static async Task SwitchOrnament(ActorMemory memory, Ornament ornament)
{
if (memory.IsUsingOrnament == true && memory.Ornament != null)
{
memory.CharacterModeInput = (byte)ornament.RowId;
memory.OrnamentId = (ushort)ornament.RowId;
memory.Ornament.AttachmentPoint = (byte)ornament.AttachPoint;
await Apply(ornament, memory.Ornament);
}
Expand Down
4 changes: 2 additions & 2 deletions Anamnesis/Actor/Views/SubActorEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static void OnChanged(SubActorEditor sender, ActorMemory? oldValue, Acto
}
else if (sender.SubActorType == Types.Ornament)
{
sender.Npc = GameDataService.Ornaments.GetRow(sender.Actor.CharacterModeInput);
sender.Npc = GameDataService.Ornaments.GetRow(sender.Actor.OrnamentId);
}
}

Expand All @@ -145,7 +145,7 @@ private static void OnTypeChanged(SubActorEditor sender, Types value)
private async void OnActorPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(ActorMemory.MountId)
|| e.PropertyName == nameof(ActorMemory.CharacterModeInput)
|| e.PropertyName == nameof(ActorMemory.OrnamentId)
|| e.PropertyName == nameof(ActorMemory.DataId))
{
await Dispatch.MainThread();
Expand Down
16 changes: 12 additions & 4 deletions Anamnesis/Core/Memory/MemoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ namespace Anamnesis.Memory;

[AddINotifyPropertyChangedInterface]
public class MemoryService : ServiceBase<MemoryService>
{
{
private const uint VirtualProtectReadWriteExecute = 0x40;

private readonly Dictionary<string, IntPtr> modules = new Dictionary<string, IntPtr>();

public static IntPtr Handle { get; private set; }
Expand Down Expand Up @@ -221,7 +223,7 @@ public static void Write(IntPtr address, object value, Type type, string purpose
}

Log.Verbose($"Writing: {buffer.Length} bytes to {address} for type {type.Name} for reason: {purpose}");
WriteProcessMemory(Handle, address, buffer, buffer.Length, out _);
Write(address, buffer, false);
}

public static bool Read(UIntPtr address, byte[] buffer, UIntPtr size)
Expand All @@ -237,8 +239,11 @@ public static bool Read(IntPtr address, byte[] buffer, int size = -1)
return ReadProcessMemory(Handle, address, buffer, size, out _);
}

public static bool Write(IntPtr address, byte[] buffer)
{
public static bool Write(IntPtr address, byte[] buffer, bool writingCode)
{
if(writingCode)
VirtualProtectEx(Handle, address, buffer.Length, VirtualProtectReadWriteExecute, out _);

return WriteProcessMemory(Handle, address, buffer, buffer.Length, out _);
}

Expand Down Expand Up @@ -357,6 +362,9 @@ public async Task OpenProcess(Process process)
[DllImport("kernel32.dll")]
private static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, int dwSize, out IntPtr lpNumberOfBytesWritten);

[DllImport("kernel32.dll")]
private static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, uint flNewProtect, out uint lpflOldProtect);

[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr GetCurrentProcess();

Expand Down
4 changes: 2 additions & 2 deletions Anamnesis/Core/Memory/NopHookViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public void SetEnabled(bool enabled)
if (enabled)
{
// Write Nop
MemoryService.Write(this.address, this.nopValue);
MemoryService.Write(this.address, this.nopValue, true);
}
else
{
// Write the original value
MemoryService.Write(this.address, this.originalValue);
MemoryService.Write(this.address, this.originalValue, true);
}
}
}
22 changes: 22 additions & 0 deletions Anamnesis/Data/ItemCategories.json
Original file line number Diff line number Diff line change
Expand Up @@ -8321,6 +8321,28 @@
"36338": "Premium",
// Omega-F Earrings
"36339": "Premium",
// Street Cap
"36826": "Premium",
// Street Top
"36827": "Premium",
// Street Handwear
"36828": "Premium",
// Street Cargo Trousers
"36829": "Premium",
// Street High-top Shoes
"36830": "Premium",
// Street Jacket
"36831": "Premium",
// Summer Sunset Bandana
"36832": "Limited",
// Summer Sunset Beach Cover-up
"36833": "Limited",
// Summer Sunset Wrist Torques
"36834": "Limited",
// Summer Sunset Bottoms
"36835": "Limited",
// Summer Sunset Sandals
"36836": "Limited",
// Lyse's Leadership Attire
"36843": "Premium",
// Makai Vanguard's Monocle
Expand Down
2 changes: 1 addition & 1 deletion Anamnesis/GameData/Excel/BattleNpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Anamnesis.GameData.Excel;

using ExcelRow = Anamnesis.GameData.Sheets.ExcelRow;

[Sheet("BNpcBase", 0xfd8e0ebb)]
[Sheet("BNpcBase", 0xe136dda3)]
public class BattleNpc : ExcelRow, INpcBase
{
private string? name;
Expand Down
6 changes: 3 additions & 3 deletions Anamnesis/GameData/Excel/Ornament.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Anamnesis.GameData.Excel;

using ExcelRow = Anamnesis.GameData.Sheets.ExcelRow;

[Sheet("Ornament", 0x72256cce)]
[Sheet("Ornament", 0x3d312c8f)]
public class Ornament : ExcelRow, INpcBase
{
private string? name;
Expand Down Expand Up @@ -42,8 +42,8 @@ public override void PopulateData(RowParser parser, Lumina.GameData gameData, La

this.ModelCharaRow = (uint)parser.ReadColumn<ushort>(0);
this.AttachPoint = parser.ReadColumn<byte>(1);
this.Icon = parser.ReadImageReference<ushort>(7);
this.name = parser.ReadString(9);
this.Icon = parser.ReadImageReference<ushort>(6);
this.name = parser.ReadString(8);
}

public INpcAppearance? GetAppearance()
Expand Down
Loading

0 comments on commit 854fac5

Please sign in to comment.