-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added equipped gem summary feature based on commmunity requests.
Changes to be committed: new file: ui/core/components/gem_summary_action.ts modified: ui/core/individual_sim_ui.ts
- Loading branch information
NerdEgghead
committed
Nov 17, 2023
1 parent
4fb6b24
commit 831e4d9
Showing
2 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { IndividualSimUI } from '../individual_sim_ui.js'; | ||
import { BaseModal } from './base_modal.js'; | ||
import { Player } from '../core/player.js'; | ||
|
||
export function addGemSummaryAction(simUI: IndividualSimUI<any>) { | ||
simUI.addAction('Gem Summary', 'gem-summary-action', () => { | ||
new GemSummaryMenu(simUI); | ||
}); | ||
} | ||
|
||
class GemSummaryMenu extends BaseModal { | ||
private readonly simUI: IndividualSimUI<any>; | ||
private readonly tableBody: HTMLElement; | ||
private readonly player: Player<any>; | ||
|
||
constructor(simUI: IndividualSimUI<any>) { | ||
super(simUI.rootElem, 'gem-summary-menu', { scrollContents: true, size: 'md' }); | ||
this.simUI = simUI; | ||
this.player = simUI.player; | ||
|
||
this.header?.insertAdjacentHTML('afterbegin', '<h5 class="modal-title">Currently Socketed Gems</h5>'); | ||
this.body.innerHTML = ` | ||
<div class="gem-summary-table-container modal-scroll-table"> | ||
<table class="gem-summary-table" style="width: 100%"> | ||
<thead> | ||
<tr> | ||
<th>Gem Type</th> | ||
<th style="text-align: right"> | ||
<span>Quantity</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody></tbody> | ||
</table> | ||
</div> | ||
`; | ||
|
||
this.tableBody = this.rootElem.querySelector('.gem-summary-table tbody') as HTMLElement; | ||
this.updateTable(); | ||
} | ||
|
||
private updateTable() { | ||
this.tableBody.innerHTML = ``; | ||
const fullGemList = this.player.getGear().getAllGems(this.player.isBlacksmithing()); | ||
const gemCounts = {}; | ||
|
||
for (const gem of fullGemList) { | ||
gemCounts[gem.name] = gemCounts[gem.name] ? gemCounts[gem.name] + 1 : 1; | ||
} | ||
|
||
for (const gemName of Object.keys(gemCounts)) { | ||
const row = document.createElement('tr'); | ||
row.innerHTML = ` | ||
<td>${gemName}</td> | ||
<td style="text-align: right">${gemCounts[gemName].toFixed(0)}</td> | ||
`; | ||
this.tableBody.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