@kitten-science/kitten-scientists
Version:
Add-on for the wonderful incremental browser game: https://kittensgame.com/web/
36 lines • 1.62 kB
JavaScript
import { Dialog } from "../Dialog.js";
import { TextButton } from "../TextButton.js";
import styles from "./SellButton.module.css";
export class SellButton extends TextButton {
setting;
constructor(parent, setting, locale, options) {
super(parent, undefined, {
onClick: async () => {
const value = await Dialog.prompt(parent, parent.host.engine.i18n("blackcoin.sell.prompt"), parent.host.engine.i18n("blackcoin.sell.promptTitle", [
parent.host.renderAbsolute(setting.sell, locale.selected),
]), parent.host.renderAbsolute(setting.sell), parent.host.engine.i18n("blackcoin.sell.promptExplainer"));
if (value === undefined) {
return;
}
if (value === "" || value.startsWith("-")) {
setting.sell = -1;
return;
}
setting.sell = parent.host.parseAbsolute(value) ?? setting.sell;
},
onRefresh: () => {
this.element.prop("title", this.host.engine.i18n("blackcoin.sell.title", [
this.host.renderAbsolute(this.setting.sell),
]));
this.element.text(this.host.engine.i18n("blackcoin.sell", [this.host.renderAbsolute(this.setting.sell)]));
options?.onRefresh?.();
},
});
this.element.addClass(styles.sellButton);
this.setting = setting;
}
toString() {
return `[${SellButton.name}#${this.componentId}]`;
}
}
//# sourceMappingURL=SellButton.js.map