Skip to content

Commit

Permalink
Add buff target filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthox committed May 3, 2024
1 parent 48f0bc2 commit a72a8fd
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 137 deletions.
18 changes: 4 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions src/combat/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use arcdps::{
exports::{Colors, CoreColor},
Profession,
};
use serde::{Deserialize, Serialize};
use strum::{AsRefStr, EnumIter, VariantArray, VariantNames};

// TODO: show id settings?

Expand Down Expand Up @@ -94,3 +96,35 @@ impl From<&Player> for Agent {
Self::new(AgentKind::Player, player.prof, player.name.clone())
}
}

#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
AsRefStr,
VariantArray,
VariantNames,
EnumIter,
Serialize,
Deserialize,
)]
pub enum AgentFilter {
All,
Player,
Npc,
}

impl AgentFilter {
pub fn matches(&self, agent: &Agent) -> bool {
match self {
Self::All => true,
Self::Player => agent.is_player(),
Self::Npc => !agent.is_player(),
}
}
}
6 changes: 3 additions & 3 deletions src/data/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ impl SkillHits {
} else if hits >= expected {
SkillHitCount::Expected
} else {
SkillHitCount::Missed
SkillHitCount::Miss
}
} else if hits > 0 {
SkillHitCount::Expected
} else {
SkillHitCount::Missed
SkillHitCount::Miss
}
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum SkillHitCount {
Missed,
Miss,
Expected,
Max,
OverMax,
Expand Down
55 changes: 26 additions & 29 deletions src/ui/breakbar_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,41 +48,38 @@ impl Component<BreakbarLogProps<'_>> for BreakbarLog {
fn render(&mut self, ui: &Ui, props: BreakbarLogProps) {
let BreakbarLogProps { history } = props;

match history.viewed_fight() {
Some(fight) if !fight.data.breakbar.is_empty() => {
let colors = exports::colors();
let grey = colors.core(CoreColor::MediumGrey).unwrap_or(GREY);
let blue = colors.core(CoreColor::LightTeal).unwrap_or(CYAN);

for hit in fight
.data
.breakbar
.iter()
.filter(|hit| hit.is_own || self.display_others)
{
if self.display_time {
ui.text_colored(grey, format_time(hit.time));
ui.same_line();
}

ui.text_colored(blue, format!("{}.{}", hit.damage / 10, hit.damage % 10));

if let Some(fight) = history.viewed_fight() {
let colors = exports::colors();
let grey = colors.core(CoreColor::MediumGrey).unwrap_or(GREY);
let blue = colors.core(CoreColor::LightTeal).unwrap_or(CYAN);

for hit in fight
.data
.breakbar
.iter()
.filter(|hit| hit.is_own || self.display_others)
{
if self.display_time {
ui.text_colored(grey, format_time(hit.time));
ui.same_line();
ui.text(&hit.skill.name);
}

if self.display_others {
ui.same_line();
ui.text_colored(hit.attacker.friendly_color(&colors), &hit.attacker.name);
}
ui.text_colored(blue, format!("{}.{}", hit.damage / 10, hit.damage % 10));

ui.same_line();
ui.text(&hit.skill.name);

if self.display_others {
ui.same_line();
ui.text_colored(
hit.target.enemy_color(&colors, fight.target),
&hit.target.name,
);
ui.text_colored(hit.attacker.friendly_color(&colors), &hit.attacker.name);
}

ui.same_line();
ui.text_colored(
hit.target.enemy_color(&colors, fight.target),
&hit.target.name,
);
}
_ => ui.text("No breakbar damage"),
}

self.scroll.update(ui);
Expand Down
25 changes: 16 additions & 9 deletions src/ui/buff_log.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use crate::{
combat::CombatData,
combat::{agent::AgentFilter, CombatData},
history::History,
ui::{format_time, scroll::AutoScroll},
};
use arc_util::{
colors::{GREY, YELLOW},
settings::HasSettings,
ui::{Component, Windowable},
ui::{
render::{ch_width, enum_combo_array},
Component, Windowable,
},
};
use arcdps::{
exports::{self, CoreColor},
Expand All @@ -19,6 +22,7 @@ use serde::{Deserialize, Serialize};
pub struct BuffLog {
display_time: bool,
display_duration: bool,
target_filter: AgentFilter,

#[serde(skip)]
scroll: AutoScroll,
Expand All @@ -29,13 +33,17 @@ impl BuffLog {
Self {
display_time: true,
display_duration: true,
target_filter: AgentFilter::All,
scroll: AutoScroll::new(),
}
}

pub fn render_display(&mut self, ui: &Ui) {
ui.checkbox("Display time", &mut self.display_time);
ui.checkbox("Display duration", &mut self.display_duration);

ui.set_next_item_width(ch_width(ui, 16));
enum_combo_array(ui, "Targets", &mut self.target_filter);
}
}

Expand All @@ -48,13 +56,13 @@ impl Component<BuffLogProps<'_>> for BuffLog {
fn render(&mut self, ui: &Ui, props: BuffLogProps) {
let BuffLogProps { history } = props;

match history.viewed_fight() {
Some(fight) if !fight.data.buffs.is_empty() => {
let colors = exports::colors();
let grey = colors.core(CoreColor::MediumGrey).unwrap_or(GREY);
let yellow = colors.core(CoreColor::LightYellow).unwrap_or(YELLOW);
if let Some(fight) = history.viewed_fight() {
let colors = exports::colors();
let grey = colors.core(CoreColor::MediumGrey).unwrap_or(GREY);
let yellow = colors.core(CoreColor::LightYellow).unwrap_or(YELLOW);

for apply in &fight.data.buffs {
for apply in &fight.data.buffs {
if self.target_filter.matches(&apply.target) {
if self.display_time {
ui.text_colored(grey, format_time(apply.time));
ui.same_line();
Expand All @@ -74,7 +82,6 @@ impl Component<BuffLogProps<'_>> for BuffLog {
ui.text_colored(apply.target.friendly_color(&colors), &apply.target.name);
}
}
_ => ui.text("No buffs"),
}

self.scroll.update(ui);
Expand Down
Loading

0 comments on commit a72a8fd

Please sign in to comment.