Skip to content

Commit

Permalink
Merge pull request #8 from wowsims/buff-debuff-consumes-levels
Browse files Browse the repository at this point in the history
Implement programmatic ActionID level filtering for pickers
kayla-glick authored Feb 2, 2024

Verified

This commit was signed with the committer’s verified signature.
ElDavoo Davide Palma
2 parents 1017523 + be3e63b commit fde8927
Showing 39 changed files with 1,279 additions and 682 deletions.
5 changes: 3 additions & 2 deletions proto/common.proto
Original file line number Diff line number Diff line change
@@ -252,7 +252,6 @@ enum Explosive {
ExplosiveUnknown = 0;
ExplosiveDenseDynamite = 1;
ExplosiveThoriumGrenade = 2;
ExplosiveCoarseDynamite = 3;
}

enum Potions {
@@ -374,6 +373,7 @@ enum SaygesFortune {
}

// Buffs that affect the entire raid.
// NextIndex: 35
message RaidBuffs {
// +Stats
TristateEffect gift_of_the_wild = 1;
@@ -417,12 +417,13 @@ message RaidBuffs {
bool frost_resistance_aura = 19;
bool frost_resistance_totem = 20;
bool fire_resistance_totem = 21;
bool fire_resistance_aura = 35;

// Miscellaneous
TristateEffect thorns = 22;
TristateEffect devotion_aura = 23;
TristateEffect stoneskin_totem = 24;
bool retribution_aura = 25;
TristateEffect retribution_aura = 25;

// Scroll
bool scroll_of_protection = 26;
6 changes: 3 additions & 3 deletions sim/_paladin/paladin.go
Original file line number Diff line number Diff line change
@@ -91,9 +91,9 @@ func (paladin *Paladin) AddRaidBuffs(raidBuffs *proto.RaidBuffs) {
paladin.PaladinAura == proto.PaladinAura_DevotionAura,
paladin.Talents.ImprovedDevotionAura == 5))

if paladin.PaladinAura == proto.PaladinAura_RetributionAura {
raidBuffs.RetributionAura = true
}
raidBuffs.RetributionAura = max(raidBuffs.RetributionAura, core.MakeTristateValue(
paladin.PaladinAura == proto.PaladinAura_RetributionAura,
paladin.Talents.ImprovedRetributionAura == 2))

if paladin.Talents.SanctifiedRetribution {
raidBuffs.SanctifiedRetribution = true
2 changes: 0 additions & 2 deletions ui/balance_druid/presets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Consumes,
Debuffs,
Explosive,
Flask,
Food,
IndividualBuffs,
@@ -52,7 +51,6 @@ export const DefaultOptions = BalanceDruidOptions.create({
});

export const DefaultConsumes = Consumes.create({
fillerExplosive: Explosive.ExplosiveCoarseDynamite,
flask: Flask.FlaskUnknown,
food: Food.FoodUnknown,
mainHandImbue: WeaponImbue.BlackfathomManaOil,
2 changes: 1 addition & 1 deletion ui/core/components/fire_elemental_inputs.ts
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ export function FireElementalSection(parentElem: HTMLElement, simUI: IndividualS
player.rotationChangeEmitter.emit(eventID)
},
changeEmitter: (player: Player<ShamanSpecs>) => player.specOptionsChangeEmitter,
}, ActionId.fromSpellId(2894), "useFireElemental");
}, () => ActionId.fromSpellId(2894), "useFireElemental");

new IconPicker(fireElementalIconContainer, simUI.player, fireElementalBooleanIconInput);

89 changes: 48 additions & 41 deletions ui/core/components/icon_enum_picker.tsx
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ export interface IconEnumValueConfig<ModObject, T> {
// If actionId is set, shows the icon for that id.
// If color is set, shows that color.
// If iconUrl is set, shows that icon as grayscale
actionId?: ActionId,
actionId?: (modObj: ModObject) => ActionId | null,
color?: string,
iconUrl?: string,
// Text to be displayed on the icon.
@@ -61,20 +61,21 @@ export class IconEnumPicker<ModObject, T> extends Input<ModObject, T> {
this.config = config;
this.currentValue = this.config.zeroValue;

if (config.showWhen) {
config.changedEvent(this.modObject).on(_ => {
const show = config.showWhen && config.showWhen(this.modObject);
if (!show)
this.rootElem.classList.add('hide');
});
}
this.config.changedEvent(this.modObject).on(_ => {
if (this.showWhen()) {
this.rootElem.classList.remove('hide');
} else {
this.rootElem.classList.add('hide');
}
});

if (config.tooltip) {
Tooltip.getOrCreateInstance(this.rootElem, {
html: true,
title: config.tooltip
});
}

this.rootElem.appendChild(
<>
<a
@@ -106,7 +107,7 @@ export class IconEnumPicker<ModObject, T> extends Input<ModObject, T> {
if (this.config.direction == IconEnumPickerDirection.Horizontal)
dropdownMenu.style.gridAutoFlow = 'column';

config.values.forEach((valueConfig, _) => {
this.config.values.forEach((valueConfig, _) => {
const optionContainer = document.createElement('li');
optionContainer.classList.add('icon-dropdown-option', 'dropdown-option')
dropdownMenu.appendChild(optionContainer);
@@ -115,45 +116,32 @@ export class IconEnumPicker<ModObject, T> extends Input<ModObject, T> {
option.classList.add('icon-picker-button');
option.dataset.disableWowheadTouchTooltip='true';
optionContainer.appendChild(option);
this.setImage(option, valueConfig);

if (valueConfig.tooltip) {
Tooltip.getOrCreateInstance(option, {
html: true,
title: valueConfig.tooltip
});
}
const updateOption = () => {
this.setImage(option, valueConfig);
if (this.showValueWhen(valueConfig)) {
optionContainer.classList.remove('hide');
} else {
optionContainer.classList.add('hide');
}
};

const show = !valueConfig.showWhen || valueConfig.showWhen(this.modObject);
if (!show) optionContainer.classList.add('hide')

if (valueConfig.showWhen) {
config.changedEvent(this.modObject).on(_ => {
const show = valueConfig.showWhen && valueConfig.showWhen(this.modObject);
const isShown = !optionContainer.classList.contains('hide');
if (show) {
if (!isShown) {
optionContainer.classList.remove('hide');
if (this.storedValue == valueConfig.value) {
this.restoreValue();
}
this.setImage(option, valueConfig);
}
} else if (isShown) {
if (this.getInputValue() == valueConfig.value){
this.storeValue();
}
optionContainer.classList.add('hide');
}
});
}
this.config.changedEvent(this.modObject).on(updateOption)
updateOption();

option.addEventListener('click', event => {
event.preventDefault();
this.currentValue = valueConfig.value;
this.storedValue = undefined;
this.inputChanged(TypedEvent.nextEventID());
});

if (valueConfig.tooltip) {
Tooltip.getOrCreateInstance(option, {
html: true,
title: valueConfig.tooltip
});
}
});

this.init();
@@ -191,8 +179,9 @@ export class IconEnumPicker<ModObject, T> extends Input<ModObject, T> {
return;
}

if (valueConfig.actionId) {
this.setActionImage(elem, valueConfig.actionId);
const actionId = valueConfig.actionId?.(this.modObject)
if (actionId) {
this.setActionImage(elem, actionId);
elem.style.filter = ''
} else if (valueConfig.iconUrl) {
elem.style.backgroundImage = `url(${valueConfig.iconUrl})`
@@ -244,4 +233,22 @@ export class IconEnumPicker<ModObject, T> extends Input<ModObject, T> {
else
this.buttonElem.classList.remove('active');
}

showWhen(): boolean {
return (
(!this.config.showWhen || this.config.showWhen(this.modObject)) &&
!!this.config.values.find(valueConfig =>
valueConfig.actionId &&
valueConfig.actionId(this.modObject) != null &&
(!valueConfig.showWhen || valueConfig.showWhen(this.modObject))
)
);
}

showValueWhen(valueConfig: IconEnumValueConfig<ModObject, T>): boolean {
return (
(!valueConfig.actionId || valueConfig.actionId?.(this.modObject) != null) &&
(!valueConfig.showWhen || valueConfig.showWhen(this.modObject))
);
}
}
Loading

0 comments on commit fde8927

Please sign in to comment.