Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit 0312ef4

Browse files
committed
Dual Blades helper
1 parent f325548 commit 0312ef4

File tree

9 files changed

+264
-9
lines changed

9 files changed

+264
-9
lines changed

HunterPie/Core/Client/UserSettings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public class AbnormalityBar {
174174

175175
public class ClassesWidget
176176
{
177+
public DualBladesHelper DualBladesHelper { get; set; } = new DualBladesHelper();
177178
public LongSwordHelper LongSwordHelper { get; set; } = new LongSwordHelper();
178179
public HammerHelper HammerHelper { get; set; } = new HammerHelper();
179180
public ChargeBladeHelper ChargeBladeHelper { get; set; } = new ChargeBladeHelper();
@@ -197,6 +198,8 @@ public class LongSwordHelper : WeaponHelperStructure { }
197198

198199
public class BowHelper : WeaponHelperStructure { }
199200

201+
public class DualBladesHelper : WeaponHelperStructure { }
202+
200203
public class WeaponHelperStructure
201204
{
202205
public bool Enabled { get; set; } = true;

HunterPie/Core/LPlayer/Player.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ private void GetGreatswordInformation(long weaponAddress)
879879

880880
private void GetDualBladesInformation(long weaponAddress)
881881
{
882-
bool inDemonMode = Scanner.Read<bool>(weaponAddress - 0x4);
882+
bool inDemonMode = Scanner.Read<byte>(weaponAddress - 0x4) == 1;
883883
float demonGauge = Scanner.Read<float>(weaponAddress);
884884
DualBlades.InDemonMode = inDemonMode;
885885
DualBlades.DemonGauge = demonGauge;

HunterPie/GUI/Widgets/ClassWidget/ClassWidgetContainer.xaml.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ private void ApplySettingsBasedOnClass()
5959
UserSettings.Config.WeaponHelperStructure config;
6060
switch((Classes)Context.Player.WeaponID)
6161
{
62+
case Classes.DualBlades:
63+
config = classesConfig.DualBladesHelper;
64+
break;
6265
case Classes.LongSword:
6366
config = classesConfig.LongSwordHelper;
6467
break;
@@ -96,6 +99,9 @@ private void SaveSettingsBasedOnClass()
9699
UserSettings.Config.WeaponHelperStructure config;
97100
switch ((Classes)Context.Player.WeaponID)
98101
{
102+
case Classes.DualBlades:
103+
config = classesConfig.DualBladesHelper;
104+
break;
99105
case Classes.LongSword:
100106
config = classesConfig.LongSwordHelper;
101107
break;
@@ -178,6 +184,9 @@ private void OnClassChange(object source, EventArgs args)
178184
WidgetHasContent = !Context.Player.InHarvestZone;
179185
switch ((Classes)Context.Player.WeaponID)
180186
{
187+
case Classes.DualBlades:
188+
SetClassToDualBlades();
189+
break;
181190
case Classes.LongSword:
182191
SetClassLongSword();
183192
break;
@@ -207,6 +216,15 @@ private void OnClassChange(object source, EventArgs args)
207216

208217
}
209218

219+
private void SetClassToDualBlades()
220+
{
221+
var control = new DualBladeControl();
222+
control.SetContext(Context.Player.DualBlades);
223+
Container.Children.Add(control);
224+
225+
ApplySettings();
226+
}
227+
210228
private void SetClassToHammer()
211229
{
212230
var control = new HammerControl();
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<local:ClassControl x:Name="DBControl" x:Class="HunterPie.GUI.Widgets.ClassWidget.Parts.DualBladeControl"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:HunterPie.GUI.Widgets.ClassWidget.Parts"
7+
mc:Ignorable="d"
8+
>
9+
<Grid Width="250" Height="100">
10+
<Canvas Opacity="0" HorizontalAlignment="Left" Width="46" Height="46" VerticalAlignment="Top" Margin="112,34,0,0">
11+
<Rectangle Height="31" Width="31" VerticalAlignment="Top" HorizontalAlignment="Left" StrokeThickness="1.5" Canvas.Left="24" Canvas.Top="1" Opacity="0.5">
12+
<Rectangle.Stroke>
13+
<LinearGradientBrush EndPoint="0,0.6" StartPoint="1,0.5">
14+
<GradientStop Color="#00000000" Offset="0"/>
15+
<GradientStop Color="#FF6F3AFF" Offset="1"/>
16+
</LinearGradientBrush>
17+
</Rectangle.Stroke>
18+
<Rectangle.Fill>
19+
<RadialGradientBrush>
20+
<GradientStop Color="#E5191623"/>
21+
<GradientStop Color="#E51A181D" Offset="1"/>
22+
</RadialGradientBrush>
23+
</Rectangle.Fill>
24+
<Rectangle.RenderTransform>
25+
<TransformGroup>
26+
<ScaleTransform/>
27+
<SkewTransform/>
28+
<RotateTransform Angle="45"/>
29+
<TranslateTransform/>
30+
</TransformGroup>
31+
</Rectangle.RenderTransform>
32+
</Rectangle>
33+
<Image Source="{StaticResource ICON_SAFISKILL}" Width="18" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="15" Canvas.Top="9"/>
34+
<TextBlock TextOptions.TextRenderingMode="ClearType" Text="{Binding ElementName=DBControl, Path=SafiCounter}" Height="16" VerticalAlignment="Top" HorizontalAlignment="Left" Width="28" Foreground="White" FontSize="13" TextAlignment="Center" FontWeight="Light" Canvas.Top="23" Canvas.Left="10"/>
35+
<Canvas.Style>
36+
<Style TargetType="Canvas">
37+
<Style.Triggers>
38+
<DataTrigger Binding="{Binding ElementName=DBControl, Path=HasSafiBuff}" Value="True">
39+
<DataTrigger.EnterActions>
40+
<BeginStoryboard>
41+
<Storyboard Storyboard.TargetProperty="Opacity">
42+
<DoubleAnimation To="1" Duration="0:0:0.2"/>
43+
</Storyboard>
44+
</BeginStoryboard>
45+
</DataTrigger.EnterActions>
46+
<DataTrigger.ExitActions>
47+
<BeginStoryboard>
48+
<Storyboard Storyboard.TargetProperty="Opacity">
49+
<DoubleAnimation To="0" Duration="0:0:0.2"/>
50+
</Storyboard>
51+
</BeginStoryboard>
52+
</DataTrigger.ExitActions>
53+
</DataTrigger>
54+
</Style.Triggers>
55+
</Style>
56+
</Canvas.Style>
57+
</Canvas>
58+
59+
<Image Source="{StaticResource ICON_DUALBLADES}" Opacity="0" HorizontalAlignment="Left" Width="22" Height="20" VerticalAlignment="Top" Margin="127,14,0,0">
60+
<Image.Effect>
61+
<DropShadowEffect Color="White" ShadowDepth="0"/>
62+
</Image.Effect>
63+
<Image.Style>
64+
<Style TargetType="Image">
65+
<Style.Triggers>
66+
<DataTrigger Binding="{Binding ElementName=DBControl, Path=IsDemonModeActive}" Value="True">
67+
<DataTrigger.EnterActions>
68+
<BeginStoryboard>
69+
<Storyboard>
70+
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2"/>
71+
</Storyboard>
72+
</BeginStoryboard>
73+
</DataTrigger.EnterActions>
74+
<DataTrigger.ExitActions>
75+
<BeginStoryboard>
76+
<Storyboard>
77+
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.2"/>
78+
</Storyboard>
79+
</BeginStoryboard>
80+
</DataTrigger.ExitActions>
81+
</DataTrigger>
82+
</Style.Triggers>
83+
</Style>
84+
</Image.Style>
85+
</Image>
86+
<Image HorizontalAlignment="Left" Width="125" Height="34" VerticalAlignment="Top" Source="pack://siteoforigin:,,,/HunterPie.Resources/UI/Class/DualBladesGauge.png" Margin="1,24,0,0" />
87+
<Rectangle HorizontalAlignment="Left" Width="{Binding ElementName=DBControl, Path=GaugePercentage}" Height="25" VerticalAlignment="Top" Margin="29,31,0,0">
88+
<Rectangle.Fill>
89+
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
90+
<GradientStop Color="#FF781313"/>
91+
<GradientStop Color="#FFC93737" Offset="0.594"/>
92+
<GradientStop Color="#FF830A0A" Offset="1"/>
93+
</LinearGradientBrush>
94+
</Rectangle.Fill>
95+
<Rectangle.OpacityMask>
96+
<ImageBrush ImageSource="pack://siteoforigin:,,,/HunterPie.Resources/UI/Class/DualBladesGaugeMask.png"/>
97+
</Rectangle.OpacityMask>
98+
</Rectangle>
99+
<TextBlock Text="{Binding DemonGauge, ElementName=DBControl, StringFormat=\{0:P0\}}" Height="18" VerticalAlignment="Top" HorizontalAlignment="Left" Width="46" Margin="46,34,0,0" TextAlignment="Center">
100+
<TextBlock.Foreground>
101+
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
102+
<GradientStop Color="#FFD8D8D8" Offset="0"/>
103+
<GradientStop Color="#FFAAAAAA" Offset="1"/>
104+
</LinearGradientBrush>
105+
</TextBlock.Foreground>
106+
</TextBlock>
107+
</Grid>
108+
</local:ClassControl>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using DualBlades = HunterPie.Core.LPlayer.Jobs.DualBlades;
10+
using DualBladesEventArgs = HunterPie.Core.LPlayer.Jobs.DualBladesEventArgs;
11+
using JobEventArgs = HunterPie.Core.LPlayer.Jobs.JobEventArgs;
12+
13+
namespace HunterPie.GUI.Widgets.ClassWidget.Parts
14+
{
15+
/// <summary>
16+
/// Interaction logic for DualBladeControl.xaml
17+
/// </summary>
18+
public partial class DualBladeControl : ClassControl
19+
{
20+
21+
DualBlades Context;
22+
23+
24+
25+
public bool IsDemonModeActive
26+
{
27+
get { return (bool)GetValue(IsDemonModeActiveProperty); }
28+
set { SetValue(IsDemonModeActiveProperty, value); }
29+
}
30+
public static readonly DependencyProperty IsDemonModeActiveProperty =
31+
DependencyProperty.Register("IsDemonModeActive", typeof(bool), typeof(DualBladeControl));
32+
33+
public float GaugePercentage
34+
{
35+
get { return (float)GetValue(GaugePercentageProperty); }
36+
set { SetValue(GaugePercentageProperty, value); }
37+
}
38+
public static readonly DependencyProperty GaugePercentageProperty =
39+
DependencyProperty.Register("GaugePercentage", typeof(float), typeof(DualBladeControl));
40+
41+
public float DemonGauge
42+
{
43+
get { return (float)GetValue(DemonGaugeProperty); }
44+
set { SetValue(DemonGaugeProperty, value); }
45+
}
46+
public static readonly DependencyProperty DemonGaugeProperty =
47+
DependencyProperty.Register("DemonGauge", typeof(float), typeof(DualBladeControl));
48+
49+
50+
51+
public DualBladeControl()
52+
{
53+
InitializeComponent();
54+
}
55+
56+
public void SetContext(DualBlades ctx)
57+
{
58+
Context = ctx;
59+
UpdateInformation();
60+
HookEvents();
61+
}
62+
63+
private void HookEvents()
64+
{
65+
Context.OnDemonGaugeChange += OnDemonGaugeChange;
66+
Context.OnDemonModeToggle += OnDemonModeToggle;
67+
Context.OnSafijiivaCounterUpdate += OnSafijiivaCounterUpdate;
68+
}
69+
70+
public override void UnhookEvents()
71+
{
72+
Context.OnDemonGaugeChange -= OnDemonGaugeChange;
73+
Context.OnDemonModeToggle -= OnDemonModeToggle;
74+
Context.OnSafijiivaCounterUpdate -= OnSafijiivaCounterUpdate;
75+
}
76+
77+
private void UpdateInformation()
78+
{
79+
DualBladesEventArgs dummyArgs = new DualBladesEventArgs(Context);
80+
OnDemonGaugeChange(this, dummyArgs);
81+
OnDemonModeToggle(this, dummyArgs);
82+
OnSafijiivaCounterUpdate(this, new JobEventArgs(Context));
83+
}
84+
85+
#region Game Events
86+
87+
private void OnSafijiivaCounterUpdate(object source, JobEventArgs args)
88+
{
89+
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
90+
{
91+
HasSafiBuff = args.SafijiivaRegenCounter != -1;
92+
SafiCounter = args.SafijiivaMaxHits - args.SafijiivaRegenCounter;
93+
}));
94+
}
95+
96+
private void OnDemonModeToggle(object source, DualBladesEventArgs args)
97+
{
98+
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
99+
{
100+
IsDemonModeActive = args.InDemonMode;
101+
}));
102+
}
103+
104+
private void OnDemonGaugeChange(object source, DualBladesEventArgs args)
105+
{
106+
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
107+
{
108+
GaugePercentage = 103 * args.DemonGauge;
109+
DemonGauge = args.DemonGauge;
110+
}));
111+
}
112+
113+
#endregion
114+
}
115+
}
3.25 KB
Loading
836 Bytes
Loading

HunterPie/HunterPie.csproj

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1414
<WarningLevel>4</WarningLevel>
1515
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<IsWebBootstrapper>false</IsWebBootstrapper>
17+
<TargetFrameworkProfile />
18+
<NuGetPackageImportStamp>
19+
</NuGetPackageImportStamp>
1620
<PublishUrl>publish\</PublishUrl>
1721
<Install>true</Install>
1822
<InstallFrom>Disk</InstallFrom>
@@ -25,12 +29,8 @@
2529
<MapFileExtensions>true</MapFileExtensions>
2630
<ApplicationRevision>0</ApplicationRevision>
2731
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
28-
<IsWebBootstrapper>false</IsWebBootstrapper>
2932
<UseApplicationTrust>false</UseApplicationTrust>
3033
<BootstrapperEnabled>true</BootstrapperEnabled>
31-
<TargetFrameworkProfile />
32-
<NuGetPackageImportStamp>
33-
</NuGetPackageImportStamp>
3434
</PropertyGroup>
3535
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
3636
<PlatformTarget>x64</PlatformTarget>
@@ -302,6 +302,10 @@
302302
<SubType>Designer</SubType>
303303
<Generator>MSBuild:Compile</Generator>
304304
</Page>
305+
<Page Include="GUI\Widgets\ClassWidget\Parts\DualBladeControl.xaml">
306+
<SubType>Designer</SubType>
307+
<Generator>MSBuild:Compile</Generator>
308+
</Page>
305309
<Page Include="GUI\Widgets\ClassWidget\Parts\GunLanceControl.xaml">
306310
<SubType>Designer</SubType>
307311
<Generator>MSBuild:Compile</Generator>
@@ -407,6 +411,9 @@
407411
<DependentUpon>ChargeBladeControl.xaml</DependentUpon>
408412
</Compile>
409413
<Compile Include="GUI\Widgets\ClassWidget\Parts\ClassControl.cs" />
414+
<Compile Include="GUI\Widgets\ClassWidget\Parts\DualBladeControl.xaml.cs">
415+
<DependentUpon>DualBladeControl.xaml</DependentUpon>
416+
</Compile>
410417
<Compile Include="GUI\Widgets\ClassWidget\Parts\GunLanceControl.xaml.cs">
411418
<DependentUpon>GunLanceControl.xaml</DependentUpon>
412419
</Compile>
@@ -915,6 +922,14 @@
915922
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
916923
</None>
917924
</ItemGroup>
925+
<ItemGroup>
926+
<None Include="HunterPie.Resources\UI\Class\DualBladesGauge.png">
927+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
928+
</None>
929+
<None Include="HunterPie.Resources\UI\Class\DualBladesGaugeMask.png">
930+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
931+
</None>
932+
</ItemGroup>
918933
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
919934
<Import Project="..\packages\jnm2.ReferenceAssemblies.net35.1.0.1\build\jnm2.ReferenceAssemblies.net35.targets" Condition="Exists('..\packages\jnm2.ReferenceAssemblies.net35.1.0.1\build\jnm2.ReferenceAssemblies.net35.targets')" />
920935
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

HunterPie/Memory/WindowsHelper.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62
using System.Runtime.InteropServices;
73

84
namespace HunterPie.Memory

0 commit comments

Comments
 (0)