Skip to content

Commit

Permalink
rework some warrior class window logic
Browse files Browse the repository at this point in the history
  • Loading branch information
foglio1024 committed Apr 9, 2024
1 parent 44a8b78 commit 81653fc
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 46 deletions.
3 changes: 3 additions & 0 deletions TCC.Core/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ static void StartDispatcherWatcher()
public static bool FI { get; } = DateTime.Now >= TimeUtils.FromUnixTime(1567123200) &&
DateTime.Now < TimeUtils.FromUnixTime(1567209600);

public static bool FO { get; } = DateTime.Now >= TimeUtils.FromUnixTime(1712613600) &&
DateTime.Now < TimeUtils.FromUnixTime(1712872800);

public static void FUBH()
{
BaseDispatcher.InvokeAsync(() =>
Expand Down
2 changes: 0 additions & 2 deletions TCC.Core/Data/Pc/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ public bool Arcane
get => _arcane;
set => RaiseAndSetIfChanged(value, ref _arcane);
}
public Counter StacksCounter { get; set; } = new(10, true); // todo: move class-specific stuff away from here
public StanceTracker<WarriorStance> WarriorStance { get; set; } = new(); // todo: move class-specific stuff away from here
public ThreadSafeObservableCollection<AbnormalityDuration> Buffs
{
get
Expand Down
10 changes: 5 additions & 5 deletions TCC.Core/Debugging/DebugWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,19 @@ void ButtonBase_OnClick(object sender, RoutedEventArgs e)

void SetStance(object sender, RoutedEventArgs e)
{
Game.Me.WarriorStance.CurrentStance = ((Button)sender).Content.ToString() switch
TccUtils.CurrentClassVM<WarriorLayoutViewModel>().StanceTracker.CurrentStance = ((Button)sender).Content.ToString() switch
{
"Assault" => WarriorStance.Assault,
"Defensive" => WarriorStance.Defensive,
"None" => WarriorStance.None,
_ => Game.Me.WarriorStance.CurrentStance
_ => WarriorStance.None,
};
}

void IncreaseEdge(object sender, RoutedEventArgs e)
{
if (Game.Me.StacksCounter.IsMaxed) Game.Me.StacksCounter.Val = 0;
Game.Me.StacksCounter.Val++;
var edge = TccUtils.CurrentClassVM<WarriorLayoutViewModel>().EdgeCounter;
if (edge.IsMaxed) edge.Val = 0;
edge.Val++;

}

Expand Down
12 changes: 7 additions & 5 deletions TCC.Core/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,6 @@ static void OnPlayerStatUpdate(S_PLAYER_STAT_UPDATE m)
Me.Ice = m.Ice;
Me.Arcane = m.Arcane;
break;

case Class.Warrior:
Me.StacksCounter.Val = m.Edge;
break;
}
}

Expand Down Expand Up @@ -791,6 +787,13 @@ static void OnSpawnMe(S_SPAWN_ME p)
SystemMessagesProcessor.AnalyzeMessage($"@0\vAbnormalName\v{ab.Name}", "SMT_BATTLE_BUFF_DEBUFF");
}
if (App.FO)
{
var ab = DB!.AbnormalityDatabase.Abnormalities[11042024];
Me.UpdateAbnormality(ab, int.MaxValue, 1);
SystemMessagesProcessor.AnalyzeMessage($"@0\vAbnormalName\v{ab.Name}", "SMT_BATTLE_BUFF_DEBUFF");
}
#endregion Fear Inoculum
#region Lockdown
Expand Down Expand Up @@ -1002,7 +1005,6 @@ static async Task OnLogin(S_LOGIN m)
Me.ServerId = m.ServerId;
Me.Laurel = GetLaurel(Me.PlayerId);
Me.ClearAbnormalities();
Me.StacksCounter.SetClass(m.CharacterClass);

WindowManager.ReloadPositions();
GameEventManager.Instance.SetServerTimeZone(App.Settings.LastLanguage);
Expand Down
20 changes: 10 additions & 10 deletions TCC.Core/UI/Controls/Classes/WarriorLayout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
<UserControl.Resources>
<ControlTemplate x:Key="EdgeArrowLayout">
<elements:EdgeArrowLayout EdgeCounter="{Binding EdgeCounter}" Margin="0 -40"
FillBrush="{Binding Stance.CurrentStance, Converter={conv:WarriorStanceToColorConverter Light=True, Fallback=True}}"
GlowColor="{Binding Stance.CurrentStance, Converter={conv:WarriorStanceToColorConverter Fallback=True}}"/>
FillBrush="{Binding StanceTracker.CurrentStance, Converter={conv:WarriorStanceToColorConverter Light=True, Fallback=True}}"
GlowColor="{Binding StanceTracker.CurrentStance, Converter={conv:WarriorStanceToColorConverter Fallback=True}}"/>
</ControlTemplate>
<ControlTemplate x:Key="EdgeRhombLayout" >
<elements:EdgeRhombControl EdgeCounter="{Binding EdgeCounter}"
FillBrush="{Binding Stance.CurrentStance, Converter={conv:WarriorStanceToColorConverter Light=True, Fallback=True}}"
GlowColor="{Binding Stance.CurrentStance, Converter={conv:WarriorStanceToColorConverter Fallback=True}}"/>
FillBrush="{Binding StanceTracker.CurrentStance, Converter={conv:WarriorStanceToColorConverter Light=True, Fallback=True}}"
GlowColor="{Binding StanceTracker.CurrentStance, Converter={conv:WarriorStanceToColorConverter Fallback=True}}"/>
</ControlTemplate>
<ControlTemplate x:Key="EdgeBarLayout">
<elements:EdgeBarLayout VerticalAlignment="Center"
Height="12"
EdgeCounter="{Binding EdgeCounter}"
FillBrush="{Binding Stance.CurrentStance, Converter={conv:WarriorStanceToColorConverter Light=True, Fallback=True}}"
GlowColor="{Binding Stance.CurrentStance, Converter={conv:WarriorStanceToColorConverter Fallback=True}}">
FillBrush="{Binding StanceTracker.CurrentStance, Converter={conv:WarriorStanceToColorConverter Light=True, Fallback=True}}"
GlowColor="{Binding StanceTracker.CurrentStance, Converter={conv:WarriorStanceToColorConverter Fallback=True}}">
<FrameworkElement.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="1"/>
Expand All @@ -54,10 +54,10 @@
<Setter Property="EndAngle" Value="123"/>
<Setter Property="Margin" Value="-14"/>
<Setter Property="RenderTransformOrigin" Value=".5 .5"/>
<Setter Property="Stroke" Value="{Binding Stance.CurrentStance, Converter={conv:WarriorStanceToColorConverter}}"/>
<Setter Property="Stroke" Value="{Binding StanceTracker.CurrentStance, Converter={conv:WarriorStanceToColorConverter}}"/>
<Setter Property="Effect" >
<Setter.Value>
<DropShadowEffect Color="{Binding Stance.CurrentStance, Converter={conv:WarriorStanceToColorConverter}}" ShadowDepth="0" BlurRadius="15"/>
<DropShadowEffect Color="{Binding StanceTracker.CurrentStance, Converter={conv:WarriorStanceToColorConverter}}" ShadowDepth="0" BlurRadius="15"/>
</Setter.Value>
</Setter>
</Style>
Expand Down Expand Up @@ -176,7 +176,7 @@
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Stance.CurrentStance}"
<Condition Binding="{Binding StanceTracker.CurrentStance}"
Value="{x:Static tcc:WarriorStance.Defensive}"/>
<Condition Binding="{Binding ShowInfuriate}" Value="True"/>
</MultiDataTrigger.Conditions>
Expand Down Expand Up @@ -283,7 +283,7 @@
</FrameworkElement.RenderTransform>
</Border>
<elements:TraverseCutControl Tracker="{Binding TraverseCut}"
IconName="{Binding Stance.CurrentStance, Converter={StaticResource WarriorStanceToTraverseCutIconName}}"
IconName="{Binding StanceTracker.CurrentStance, Converter={StaticResource WarriorStanceToTraverseCutIconName}}"
HorizontalAlignment="Center"
VerticalAlignment="Center" IsHitTestVisible="False">
<FrameworkElement.RenderTransform>
Expand Down
5 changes: 4 additions & 1 deletion TCC.Core/UI/Windows/SplashScreenViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public SplashScreenViewModel()
if (File.Exists(path))
{
bm.BeginInit();
bm.UriSource = new Uri(App.FI ? "pack://application:,,,/resources/images/10kdays.jpg" : path,
bm.UriSource = new Uri(
App.FI ? "pack://application:,,,/resources/images/10kdays.jpg"
: App.FO ? "pack://application:,,,/resources/images/pleasestandby.jpg"
: path,
UriKind.Absolute);
bm.CacheOption = BitmapCacheOption.OnLoad;
bm.EndInit();
Expand Down
43 changes: 20 additions & 23 deletions TCC.Core/ViewModels/ClassManagers/WarriorLayoutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace TCC.ViewModels.ClassManagers;

public class WarriorLayoutViewModel : BaseClassLayoutViewModel
{

public SkillWithEffect DeadlyGamble { get; set; }
public SkillWithEffect AdrenalineRush { get; set; }
public SkillWithEffect Swift { get; set; }
Expand All @@ -21,10 +20,11 @@ public class WarriorLayoutViewModel : BaseClassLayoutViewModel
public Cooldown AerialScythe { get; }
#endif

public StanceTracker<WarriorStance> Stance => Game.Me.WarriorStance; //for binding
public Counter EdgeCounter => Game.Me.StacksCounter; //for binding
public Counter EdgeCounter { get; set; } = new(10, true);
public StanceTracker<WarriorStance> StanceTracker { get; } = new();

bool _warningStance;

public bool WarningStance
{
get => _warningStance;
Expand All @@ -33,12 +33,16 @@ public bool WarningStance

public bool AtkSpeedProc => !(Swift.Effect.IsAvailable && AdrenalineRush.Effect.IsAvailable);

public bool ShowEdge => App.Settings.ClassWindowSettings.WarriorShowEdge;
public bool ShowInfuriate => App.Settings.ClassWindowSettings.WarriorShowInfuriate;
public bool ShowTraverseCut => App.Settings.ClassWindowSettings.WarriorShowTraverseCut;
public WarriorEdgeMode WarriorEdgeMode => App.Settings.ClassWindowSettings.WarriorEdgeMode;

public WarriorLayoutViewModel()
{
TraverseCut = new StatTracker { Max = 13, Val = 0 };
Game.Me.Death += OnDeath;
Game.CombatChanged += CheckStanceWarning;
Stance.PropertyChanged += OnStanceOnPropertyChanged; // StanceTracker has only one prop

Game.DB!.SkillsDatabase.TryGetSkill(200200, Class.Warrior, out var dg);
DeadlyGamble = new SkillWithEffect(_dispatcher, dg);
Expand All @@ -57,35 +61,17 @@ public WarriorLayoutViewModel()
#endif
var ab = Game.DB.AbnormalityDatabase.Abnormalities[21010];
Swift = new SkillWithEffect(_dispatcher, new Skill(ab), false);

}

void OnDeath()
{
DeadlyGamble.StopEffect();
}

public bool ShowEdge => App.Settings.ClassWindowSettings.WarriorShowEdge;
public bool ShowInfuriate => App.Settings.ClassWindowSettings.WarriorShowInfuriate;
public bool ShowTraverseCut => App.Settings.ClassWindowSettings.WarriorShowTraverseCut;
public WarriorEdgeMode WarriorEdgeMode => App.Settings.ClassWindowSettings.WarriorEdgeMode;


public override void Dispose()
{
Game.Me.Death -= OnDeath;
Game.CombatChanged -= CheckStanceWarning;
Stance.PropertyChanged -= OnStanceOnPropertyChanged;
DeadlyGamble.Dispose();
Infuriate.Dispose();
Swift.Dispose();
}

void OnStanceOnPropertyChanged(object? _, PropertyChangedEventArgs __)
{
CheckStanceWarning();
}

protected override bool StartSpecialSkillImpl(Cooldown sk)
{
if (sk.Skill.IconName == DeadlyGamble.Cooldown.Skill.IconName)
Expand Down Expand Up @@ -117,7 +103,7 @@ protected override bool StartSpecialSkillImpl(Cooldown sk)

void CheckStanceWarning()
{
WarningStance = Game.Me.WarriorStance.CurrentStance == WarriorStance.None && Game.Combat;
WarningStance = StanceTracker.CurrentStance == WarriorStance.None && Game.Combat;
}

public void SetSwift(uint duration)
Expand Down Expand Up @@ -145,4 +131,15 @@ public void SetArush(uint duration)
}
InvokePropertyChanged(nameof(AtkSpeedProc));
}

public void SetStance(WarriorStance stance)
{
StanceTracker.CurrentStance = stance;
CheckStanceWarning();
}

void OnDeath()
{
DeadlyGamble.StopEffect();
}
}
9 changes: 9 additions & 0 deletions TCC.Core/ViewModels/Widgets/ClassWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ void OnLogin(S_LOGIN m)
_dispatcher.InvokeAsync(() =>
{
CurrentClass = m.CharacterClass;
if(m.CharacterClass is Class.Warrior)
{
TccUtils.CurrentClassVM<WarriorLayoutViewModel>()?.EdgeCounter.SetClass(m.CharacterClass);
}
});

if (m.CharacterClass == Class.Valkyrie)
PacketAnalyzer.Processor.Hook<S_WEAK_POINT>(OnWeakPoint);
else
Expand All @@ -169,6 +175,9 @@ void OnPlayerStatUpdate(S_PLAYER_STAT_UPDATE m)
case Class.Sorcerer when CurrentManager is SorcererLayoutViewModel sm:
sm.NotifyElementChanged();
break;
case Class.Warrior when CurrentManager is WarriorLayoutViewModel wm:
wm.EdgeCounter.Val = m.Edge;
break;
}
}

Expand Down

0 comments on commit 81653fc

Please sign in to comment.