Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wowhead importer fix #3816

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/core/components/detailed_results/resource_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ResourceMetricsTable extends ResultComponent {
orderedResourceTypes.forEach(resourceType => {
const containerElem = document.createElement('div');
containerElem.classList.add('resource-metrics-table-container', 'hide');
containerElem.innerHTML = `<span class="resource-metrics-table-title">${resourceNames[resourceType]}</span>`;
containerElem.innerHTML = `<span class="resource-metrics-table-title">${resourceNames.get(resourceType)}</span>`;
this.rootElem.appendChild(containerElem);

const childConfig = config;
Expand Down
6 changes: 3 additions & 3 deletions ui/core/components/detailed_results/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ export class Timeline extends ResultComponent {
<a className="rotation-label-icon" style={{
backgroundImage:`url('${resourceTypeToIcon[resourceType]}')`
}}></a>
<span className="rotation-label-text">{resourceNames[resourceType]}</span>
<span className="rotation-label-text">{resourceNames.get(resourceType)}</span>
</div>
);

Expand All @@ -717,7 +717,7 @@ export class Timeline extends ResultComponent {
)

resourceLogs.forEach((resourceLogGroup, i) => {
const cNames = resourceNames[resourceType].toLowerCase().replaceAll(' ', '-');
const cNames = resourceNames.get(resourceType)!.toLowerCase().replaceAll(' ', '-');
const resourceElem = (
<div className={`rotation-timeline-resource series-color ${cNames}`}
style={{
Expand Down Expand Up @@ -991,7 +991,7 @@ export class Timeline extends ResultComponent {
: (val: number) => `${val.toFixed(1)}`;

return (
<div className={`timeline-tooltip ${resourceNames[log.resourceType].toLowerCase().replaceAll(' ', '-')}`}>
<div className={`timeline-tooltip ${resourceNames.get(log.resourceType)!.toLowerCase().replaceAll(' ', '-')}`}>
<div className="timeline-tooltip-header">
<span className="bold">{log.timestamp.toFixed(2)}s</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/core/components/encounter_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class TargetPicker extends Input<Encounter, TargetProto> {
return new NumberPicker(section2, null, {
inline: true,
extraCssClasses: statData.extraCssClasses,
label: statNames[stat],
label: statNames.get(stat),
labelTooltip: statData.tooltip,
changedEvent: () => encounter.targetsChangeEmitter,
getValue: () => this.getTarget().stats[stat],
Expand Down
8 changes: 4 additions & 4 deletions ui/core/components/exporters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export abstract class Exporter extends BaseModal {
super(parent, 'exporter', { title: title, footer: true });

this.body.innerHTML = `
<textarea class="exporter-textarea form-control"></textarea>
<textarea spellCheck="false" class="exporter-textarea form-control"></textarea>
`;
this.footer!.innerHTML = `
<button class="exporter-button btn btn-primary clipboard-button me-2">
Expand Down Expand Up @@ -127,8 +127,8 @@ export class IndividualWowheadGearPlannerExporter<SpecType extends Spec> extends
getData(): string {
const player = this.simUI.player;

const classStr = classNames[player.getClass()].replaceAll(' ', '-').toLowerCase();
const raceStr = raceNames[player.getRace()].replaceAll(' ', '-').toLowerCase();
const classStr = classNames.get(player.getClass())!.replaceAll(' ', '-').toLowerCase();
const raceStr = raceNames.get(player.getRace())!.replaceAll(' ', '-').toLowerCase();
let url = `https://www.wowhead.com/wotlk/gear-planner/${classStr}/${raceStr}/`;

// See comments on the importer for how the binary formatting is structured.
Expand Down Expand Up @@ -347,7 +347,7 @@ export class IndividualPawnEPExporter<SpecType extends Spec> extends Exporter {
}
});

return `( Pawn: v1: "${specNames[player.spec]} WoWSims Weights": Class=${classNames[player.getClass()]},` +
return `( Pawn: v1: "${specNames[player.spec]} WoWSims Weights": Class=${classNames.get(player.getClass())},` +
Object.keys(namesToWeights)
.map(statName => `${statName}=${namesToWeights[statName].toFixed(3)}`).join(',') +
' )';
Expand Down
10 changes: 5 additions & 5 deletions ui/core/components/filters_menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class FiltersMenu extends BaseModal {
const sources = Sim.ALL_SOURCES.filter(s => s != SourceFilterOption.SourceUnknown);
sources.forEach(source => {
new BooleanPicker<Sim>(section, player.sim, {
label: sourceNames[source],
label: sourceNames.get(source),
inline: true,
changedEvent: (sim: Sim) => sim.filtersChangeEmitter,
getValue: (sim: Sim) => sim.getFilters().sources.includes(source),
Expand All @@ -89,7 +89,7 @@ export class FiltersMenu extends BaseModal {
const raids = Sim.ALL_RAIDS.filter(s => s != RaidFilterOption.RaidUnknown);
raids.forEach(raid => {
new BooleanPicker<Sim>(section, player.sim, {
label: raidNames[raid],
label: raidNames.get(raid),
inline: true,
changedEvent: (sim: Sim) => sim.filtersChangeEmitter,
getValue: (sim: Sim) => sim.getFilters().raids.includes(raid),
Expand All @@ -116,7 +116,7 @@ export class FiltersMenu extends BaseModal {

armorTypes.forEach(armorType => {
new BooleanPicker<Sim>(section, player.sim, {
label: armorTypeNames[armorType],
label: armorTypeNames.get(armorType),
inline: true,
changedEvent: (sim: Sim) => sim.filtersChangeEmitter,
getValue: (sim: Sim) => sim.getFilters().armorTypes.includes(armorType),
Expand All @@ -139,7 +139,7 @@ export class FiltersMenu extends BaseModal {

weaponTypes.forEach(weaponType => {
new BooleanPicker<Sim>(weaponTypeSection, player.sim, {
label: weaponTypeNames[weaponType],
label: weaponTypeNames.get(weaponType),
inline: true,
changedEvent: (sim: Sim) => sim.filtersChangeEmitter,
getValue: (sim: Sim) => sim.getFilters().weaponTypes.includes(weaponType),
Expand Down Expand Up @@ -221,7 +221,7 @@ export class FiltersMenu extends BaseModal {

rangedWeaponTypes.forEach(rangedWeaponType => {
new BooleanPicker<Sim>(rangedWeaponTypeSection, player.sim, {
label: rangedWeaponTypeNames[rangedWeaponType],
label: rangedWeaponTypeNames.get(rangedWeaponType),
inline: true,
changedEvent: (sim: Sim) => sim.filtersChangeEmitter,
getValue: (sim: Sim) => sim.getFilters().rangedWeaponTypes.includes(rangedWeaponType),
Expand Down
6 changes: 3 additions & 3 deletions ui/core/components/gear_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class ItemPicker extends Component {
set item(newItem: EquippedItem | null) {
// Clear everything first
this.itemElem.clear();
this.itemElem.nameElem.textContent = slotNames[this.slot];
this.itemElem.nameElem.textContent = slotNames.get(this.slot) ?? '';
setItemQualityCssClass(this.itemElem.nameElem, null);

if (newItem != null) {
Expand Down Expand Up @@ -1273,7 +1273,7 @@ export class ItemList<T> {
const source = item.sources[0];
if (source.source.oneofKind == 'crafted') {
const src = source.source.crafted;
return makeAnchor( ActionId.makeSpellUrl(src.spellId), professionNames[src.profession]);
return makeAnchor( ActionId.makeSpellUrl(src.spellId), professionNames.get(src.profession) ?? 'Unknown');
} else if (source.source.oneofKind == 'drop') {
const src = source.source.drop;
const zone = sim.db.getZone(src.zoneId);
Expand All @@ -1282,7 +1282,7 @@ export class ItemList<T> {
throw new Error('No zone found for item: ' + item);
}

let rtnEl = makeAnchor( ActionId.makeZoneUrl(zone.id), `${zone.name} (${difficultyNames[src.difficulty]})`);
let rtnEl = makeAnchor( ActionId.makeZoneUrl(zone.id), `${zone.name} (${difficultyNames.get(src.difficulty) ?? 'Unknown'})`);

const category = src.category ? ` - ${src.category}` : '';
if (npc) {
Expand Down
8 changes: 4 additions & 4 deletions ui/core/components/importers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export abstract class Importer extends BaseModal {

this.body.innerHTML = `
<div class="import-description"></div>
<textarea class="importer-textarea form-control"></textarea>
<textarea spellCheck="false" class="importer-textarea form-control"></textarea>
`;
this.footer!.innerHTML = `
${this.includeFile ? `
Expand Down Expand Up @@ -76,7 +76,7 @@ export abstract class Importer extends BaseModal {
protected async finishIndividualImport<SpecType extends Spec>(simUI: IndividualSimUI<SpecType>, charClass: Class, race: Race, equipmentSpec: EquipmentSpec, talentsStr: string, glyphs: Glyphs | null, professions: Array<Profession>): Promise<void> {
const playerClass = simUI.player.getClass();
if (charClass != playerClass) {
throw new Error(`Wrong Class! Expected ${classNames[playerClass]} but found ${classNames[charClass]}!`);
throw new Error(`Wrong Class! Expected ${classNames.get(playerClass)} but found ${classNames.get(charClass)}!`);
}

await Database.loadLeftoversIfNecessary(equipmentSpec);
Expand Down Expand Up @@ -231,12 +231,12 @@ export class IndividualWowheadGearPlannerImporter<SpecType extends Spec> extends
}

// Parse all the settings.
const charClass = nameToClass(match[1].replaceAll('-', ' '));
const charClass = nameToClass(match[1].replaceAll('-', ''));
if (charClass == Class.ClassUnknown) {
throw new Error('Could not parse Class: ' + match[1]);
}

const race = nameToRace(match[2].replaceAll('-', ' '));
const race = nameToRace(match[2].replaceAll('-', ''));
if (race == Race.RaceUnknown) {
throw new Error('Could not parse Race: ' + match[2]);
}
Expand Down
6 changes: 3 additions & 3 deletions ui/core/components/individual_sim_ui/settings_tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class SettingsTab extends SimTab {
label: 'Race',
values: races.map(race => {
return {
name: raceNames[race],
name: raceNames.get(race)!,
value: race,
};
}),
Expand All @@ -179,7 +179,7 @@ export class SettingsTab extends SimTab {
label: 'Profession 1',
values: professions.map(p => {
return {
name: professionNames[p],
name: professionNames.get(p)!,
value: p,
};
}),
Expand All @@ -192,7 +192,7 @@ export class SettingsTab extends SimTab {
label: 'Profession 2',
values: professions.map(p => {
return {
name: professionNames[p],
name: professionNames.get(p)!,
value: p,
};
}),
Expand Down
2 changes: 1 addition & 1 deletion ui/core/individual_sim_ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export abstract class IndividualSimUI<SpecType extends Spec> extends SimUI {
return '';
}

return failedProfReqs.map(fpr => `${fpr.name} requires ${professionNames[fpr.requiredProfession]}, but it is not selected.`);
return failedProfReqs.map(fpr => `${fpr.name} requires ${professionNames.get(fpr.requiredProfession)!}, but it is not selected.`);
},
});
this.addWarning({
Expand Down
4 changes: 2 additions & 2 deletions ui/core/proto_utils/logs_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ export class ResourceChangedLog extends SimLog {
const isHealth = this.resourceType == ResourceType.ResourceTypeHealth;
const verb = isHealth ? (this.isSpend ? 'Lost' : 'Recovered') : (this.isSpend ? 'Spent' : 'Gained');

return `${this.toStringPrefix()} ${verb} ${signedDiff.toFixed(1)} ${resourceNames[this.resourceType]} from ${this.actionId!.name}. (${this.valueBefore.toFixed(1)} --> ${this.valueAfter.toFixed(1)})`;
return `${this.toStringPrefix()} ${verb} ${signedDiff.toFixed(1)} ${resourceNames.get(this.resourceType)} from ${this.actionId!.name}. (${this.valueBefore.toFixed(1)} --> ${this.valueAfter.toFixed(1)})`;
}

resultString(): string {
Expand Down Expand Up @@ -638,7 +638,7 @@ export class ResourceChangedLogGroup extends SimLog {
}

toString(): string {
return `${this.toStringPrefix()} ${resourceNames[this.resourceType]}: ${this.valueBefore.toFixed(1)} --> ${this.valueAfter.toFixed(1)}`;
return `${this.toStringPrefix()} ${resourceNames.get(this.resourceType)}: ${this.valueBefore.toFixed(1)} --> ${this.valueAfter.toFixed(1)}`;
}

static fromLogs(logs: Array<SimLog>): Record<ResourceType, Array<ResourceChangedLogGroup>> {
Expand Down
Loading
Loading