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

Add unequip all gems button to gem summary #4266

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Component } from '../../components/component';
import { setItemQualityCssClass } from '../../css_utils';
import { Player } from '../../player';
import { UIGem as Gem } from '../../proto/ui.js';
import { ActionId } from '../../proto_utils/action_id';
import { SimUI } from '../../sim_ui';
import { TypedEvent } from '../../typed_event';
import { Component } from '../component';
import { ContentBlock } from '../content_block';

interface GemSummaryData {
Expand All @@ -26,6 +27,20 @@ export class GemSummary extends Component {
header: { title: 'Gem Summary' },
});
player.gearChangeEmitter.on(() => this.updateTable());

const headerElement = this.container.headerElement;
if (headerElement) {
const unequipButton = document.createElement('button');
unequipButton.innerHTML = `<i class="fas fa-times me-1"></i> Unequip All Gems`;
unequipButton.classList.add('btn', 'btn-sm', 'btn-link', 'gem-reset-button');
unequipButton.id = 'unequip-all-gems-btn';
unequipButton.onclick = () => this.unequipAllGems();
headerElement.appendChild(unequipButton);
Copy link
Contributor

@1337LutZ 1337LutZ Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this logic can become a jsx element;

const unequipButton = <button
			className="btn btn-sm btn-link gem-reset-button"
			onclick={() => {
				this.unequipAllGems();
			}}>
			<i className="fas fa-times me-1"></i>
			Unequip All Gems
		</button>
headerElement.appendChild(unequipButton);

and make sure to import on top:

import { element, jsx } from 'tsx-vanilla'

}
}

private unequipAllGems() {
this.player.setGear(TypedEvent.nextEventID(), this.player.getGear().withoutGems());
}

private updateTable() {
Expand Down
10 changes: 9 additions & 1 deletion ui/scss/shared/_gems.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
position: relative;
width: var(--gem-width);
height: var(--gem-width);

&:not(:last-child) {
margin-right: 1px;
}
Expand All @@ -30,3 +30,11 @@
height: 100%;
inset: 0;
}

.gem-reset-button {
margin-left: auto;
display: flex;
align-items: center;
padding: 0;
color: $link-danger-color;
}