-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4061 from wowsims/gem-summary-ui
Gem summary UI
- Loading branch information
Showing
12 changed files
with
173 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { SimUI } from "../../sim_ui"; | ||
import { Component } from "../../components/component"; | ||
import { Player } from "../../player"; | ||
import { setItemQualityCssClass } from "../../css_utils"; | ||
import { ActionId } from "../../proto_utils/action_id"; | ||
import { UIGem as Gem } from '../../proto/ui.js'; | ||
import { ContentBlock } from "../content_block"; | ||
|
||
interface GemSummaryData { | ||
gem: Gem | ||
count: number | ||
} | ||
|
||
export class GemSummary extends Component { | ||
private readonly simUI: SimUI; | ||
private readonly player: Player<any>; | ||
|
||
private readonly container: ContentBlock; | ||
|
||
constructor(parent: HTMLElement, simUI: SimUI, player: Player<any>) { | ||
super(parent, 'gem-summary-root'); | ||
this.simUI = simUI; | ||
this.player = player; | ||
|
||
this.container = new ContentBlock(this.rootElem, 'gem-summary-container', { | ||
header: {title: 'Gem Summary'} | ||
}); | ||
player.gearChangeEmitter.on(() => this.updateTable()); | ||
} | ||
|
||
private updateTable() { | ||
this.container.bodyElement.innerHTML = ``; | ||
const fullGemList = this.player.getGear().getAllGems(this.player.isBlacksmithing()); | ||
const gemCounts: Record<string, GemSummaryData> = {}; | ||
|
||
for (const gem of fullGemList) { | ||
if (gemCounts[gem.name]) { | ||
gemCounts[gem.name].count += 1 | ||
} else { | ||
gemCounts[gem.name] = { | ||
gem: gem, | ||
count: 1, | ||
} | ||
} | ||
} | ||
|
||
for (const gemName of Object.keys(gemCounts)) { | ||
const gemData = gemCounts[gemName] | ||
const row = document.createElement('div'); | ||
row.classList.add('d-flex', 'align-items-center', 'justify-content-between') | ||
row.innerHTML = ` | ||
<a class="gem-summary-link"> | ||
<img class="gem-icon"/> | ||
<div>${gemName}</div> | ||
</a> | ||
<div>${gemData.count.toFixed(0)}</div> | ||
`; | ||
|
||
const gemLinkElem = row.querySelector('.gem-summary-link') as HTMLAnchorElement; | ||
const gemIconElem = row.querySelector('.gem-icon') as HTMLImageElement; | ||
|
||
setItemQualityCssClass(gemLinkElem, gemData.gem.quality); | ||
|
||
ActionId.fromItemId(gemData.gem.id).fill().then(filledId => { | ||
gemIconElem.src = filledId.iconUrl; | ||
filledId.setWowheadHref(gemLinkElem); | ||
}); | ||
|
||
this.container.bodyElement.appendChild(row); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#gear-tab { | ||
.tab-pane-content-container { | ||
.gear-tab-left { | ||
flex-direction: column; | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
ui/scss/core/components/individual_sim_ui/_gem_summary.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.gem-summary-root { | ||
width: 50%; | ||
|
||
.gem-summary-link { | ||
--gem-width: 2rem; | ||
|
||
display: flex; | ||
align-items: center; | ||
|
||
.gem-icon { | ||
position: unset; | ||
margin-right: map-get($spacers, 1); | ||
border-radius: 0; | ||
border: $border-default; | ||
} | ||
|
||
&:not(:last-child) { | ||
margin-bottom: map-get($spacers, 1); | ||
} | ||
} | ||
} | ||
|
||
@include media-breakpoint-down(xl) { | ||
.gem-summary-root { | ||
margin-bottom: var(--container-padding); | ||
} | ||
} | ||
|
||
@include media-breakpoint-down(md) { | ||
.gem-summary-root { | ||
width: 100%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters