Skip to content

Commit

Permalink
Merge pull request #785 from wowsims/feature/port-cata-improvements
Browse files Browse the repository at this point in the history
Port ilvl changes from cata repo
  • Loading branch information
kayla-glick authored Jun 10, 2024
2 parents 8a66046 + f5d86c4 commit 19b58ff
Show file tree
Hide file tree
Showing 13 changed files with 519 additions and 411 deletions.
4 changes: 3 additions & 1 deletion proto/ui.proto
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,16 @@ enum RaidFilterOption {
RaidNaxxramas = 3456;
}

// Next tag: 22
// Next tag: 24
message DatabaseFilters {
repeated ArmorType armor_types = 1;
repeated WeaponType weapon_types = 2;
repeated RangedWeaponType ranged_weapon_types = 16;
repeated SourceFilterOption sources = 17;
repeated RaidFilterOption raids = 18;
UIItem.FactionRestriction faction_restriction = 19;
int32 min_ilvl = 22;
int32 max_ilvl = 23;

double min_mh_weapon_speed = 4;
double max_mh_weapon_speed = 5;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Player } from '../player.js';
import { ArmorType, ItemSlot } from '../proto/common.js';
import { SourceFilterOption, UIItem_FactionRestriction } from '../proto/ui.js';
import { armorTypeNames, rangedWeaponTypeNames, sourceNames, weaponTypeNames } from '../proto_utils/names.js';
import { canDualWield, classToEligibleRangedWeaponTypes, classToEligibleWeaponTypes, classToMaxArmorType } from '../proto_utils/utils.js';
import { Sim } from '../sim.js';
import { EventID } from '../typed_event.js';
import { getEnumValues } from '../utils.js';
import { BaseModal } from './base_modal.js';
import { BooleanPicker } from './boolean_picker.js';
import { EnumPicker } from './enum_picker.js';
import { NumberPicker } from './number_picker.js';
import { Player } from '../../player.js';
import { ArmorType, ItemSlot } from '../../proto/common.js';
import { SourceFilterOption, UIItem_FactionRestriction } from '../../proto/ui.js';
import { armorTypeNames, rangedWeaponTypeNames, sourceNames, weaponTypeNames } from '../../proto_utils/names.js';
import { canDualWield, classToEligibleRangedWeaponTypes, classToEligibleWeaponTypes, classToMaxArmorType } from '../../proto_utils/utils.js';
import { Sim } from '../../sim.js';
import { EventID } from '../../typed_event.js';
import { getEnumValues } from '../../utils.js';
import { BaseModal } from '../base_modal.jsx';
import { BooleanPicker } from '../boolean_picker.js';
import { EnumPicker } from '../enum_picker.js';
import { NumberPicker } from '../number_picker.js';

const factionRestrictionsToLabels: Record<UIItem_FactionRestriction, string> = {
[UIItem_FactionRestriction.UNSPECIFIED]: 'None',
Expand All @@ -21,11 +21,42 @@ export class FiltersMenu extends BaseModal {
constructor(rootElem: HTMLElement, player: Player<any>, slot: ItemSlot) {
super(rootElem, 'filters-menu', { size: 'md', title: 'Filters' });

let section = this.newSection('Factions');
const generalSection = this.newSection('General');

new EnumPicker(section, player.sim, {
const ilvlFiltersContainer = (<div className="ilvl-filters" />) as HTMLElement;
generalSection.appendChild(ilvlFiltersContainer);

new NumberPicker(ilvlFiltersContainer, player.sim, {
id: 'filters-min-ilvl',
label: 'Min ILvl',
showZeroes: false,
changedEvent: sim => sim.filtersChangeEmitter,
getValue: (sim: Sim) => sim.getFilters().minIlvl,
setValue: (eventID: EventID, sim: Sim, newValue: number) => {
const newFilters = sim.getFilters();
newFilters.minIlvl = newValue;
sim.setFilters(eventID, newFilters);
},
});

ilvlFiltersContainer.appendChild(<span className="ilvl-filters-separator">-</span>);

new NumberPicker(ilvlFiltersContainer, player.sim, {
id: 'filters-max-ilvl',
label: 'Max ILvl',
showZeroes: false,
changedEvent: sim => sim.filtersChangeEmitter,
getValue: (sim: Sim) => sim.getFilters().maxIlvl,
setValue: (eventID: EventID, sim: Sim, newValue: number) => {
const newFilters = sim.getFilters();
newFilters.maxIlvl = newValue;
sim.setFilters(eventID, newFilters);
},
});

new EnumPicker(generalSection, player.sim, {
id: 'filters-faction-restriction',
extraCssClasses: ['w-50'],
label: 'Faction Restrictions',
values: [UIItem_FactionRestriction.UNSPECIFIED, UIItem_FactionRestriction.ALLIANCE_ONLY, UIItem_FactionRestriction.HORDE_ONLY].map(restriction => {
return {
name: factionRestrictionsToLabels[restriction],
Expand All @@ -41,11 +72,11 @@ export class FiltersMenu extends BaseModal {
},
});

section = this.newSection('Source');
section.classList.add('filters-menu-section-bool-list');
const sourceSection = this.newSection('Source');
sourceSection.classList.add('filters-menu-section-bool-list');
const sources = Sim.ALL_SOURCES.filter(s => s != SourceFilterOption.SourceUnknown);
sources.forEach(source => {
new BooleanPicker<Sim>(section, player.sim, {
new BooleanPicker<Sim>(sourceSection, player.sim, {
id: `filters-source-${source}`,
label: sourceNames.get(source),
inline: true,
Expand Down
6 changes: 6 additions & 0 deletions ui/core/components/gear_picker/gear_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class ItemRenderer extends Component {

readonly iconElem: HTMLAnchorElement;
readonly nameElem: HTMLAnchorElement;
readonly ilvlElem: HTMLSpanElement;
readonly enchantElem: HTMLAnchorElement;
readonly runeElem: HTMLAnchorElement;

Expand All @@ -75,12 +76,14 @@ export class ItemRenderer extends Component {

const iconElem = ref<HTMLAnchorElement>();
const nameElem = ref<HTMLAnchorElement>();
const ilvlElem = ref<HTMLSpanElement>();
const enchantElem = ref<HTMLAnchorElement>();
const runeElem = ref<HTMLAnchorElement>();
const sce = ref<HTMLDivElement>();
this.rootElem.appendChild(
<>
<div className="item-picker-icon-wrapper">
<span className="item-picker-ilvl" ref={ilvlElem} />
<a ref={iconElem} className="item-picker-icon" href="javascript:void(0)" attributes={{ role: 'button' }}></a>
<div ref={sce} className="item-picker-sockets-container"></div>
</div>
Expand All @@ -94,6 +97,7 @@ export class ItemRenderer extends Component {

this.iconElem = iconElem.value!;
this.nameElem = nameElem.value!;
this.ilvlElem = ilvlElem.value!;
this.enchantElem = enchantElem.value!;
this.runeElem = runeElem.value!;
}
Expand All @@ -111,13 +115,15 @@ export class ItemRenderer extends Component {
this.runeElem.classList.add('hide');

this.iconElem.style.backgroundImage = '';

this.nameElem.innerText = '';
this.enchantElem.innerText = '';
this.runeElem.innerText = '';
}

update(newItem: EquippedItem) {
this.nameElem.textContent = newItem.item.name;
this.ilvlElem.textContent = newItem.item.ilvl.toString();

if (newItem.randomSuffix) {
this.nameElem.textContent += ' ' + newItem.randomSuffix.name;
Expand Down
2 changes: 1 addition & 1 deletion ui/core/components/gear_picker/item_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { Sim } from '../../sim';
import { SimUI } from '../../sim_ui';
import { EventID, TypedEvent } from '../../typed_event';
import { formatDeltaTextElem } from '../../utils';
import { FiltersMenu } from '../filters_menu';
import { makeShow1hWeaponsSelector, makeShow2hWeaponsSelector, makeShowEPValuesSelector } from '../other_inputs';
import Toast from '../toast';
import { Clusterize } from '../virtual_scroll/clusterize';
import { FiltersMenu } from './filters_menu';
import { SelectorModalTabs } from './selector_modal';

export interface ItemData<T> {
Expand Down
Loading

0 comments on commit 19b58ff

Please sign in to comment.