Skip to content

Commit 967c8c6

Browse files
committed
split auto buy button from sorting group (this feature can run its self)
1 parent 4f09887 commit 967c8c6

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

main.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,6 @@ class PaybackRateMod {
773773
*/
774774
toggleButton(config, text) {
775775
const name = this.getButtonID(config);
776-
const value = this.config[config];
777776
const button = document.createElement("a");
778777
button.id = name;
779778
button.classList.add("smallFancyButton", "prefButton", "option");
@@ -790,6 +789,19 @@ class PaybackRateMod {
790789
const value = this.config[config];
791790
button.classList.toggle("off", !value);
792791
button.textContent = `${text} ${value ? "On" : "Off"}`;
792+
// first button disable rest buttons wit opacity: 0.5
793+
const sort_dependent_configs = ["sortGrandmapocalypse", "sortWizardTower"];
794+
if (config === "enableSort") {
795+
sort_dependent_configs.forEach((buttonId) => {
796+
const button = l(this.getButtonID(buttonId));
797+
if (button) {
798+
button.style.opacity = (this.config[buttonId] && this.config.enableSort) ? "1" : "0.5";
799+
}
800+
});
801+
}
802+
if (sort_dependent_configs.includes(config)) {
803+
button.style.opacity = (value && this.config.enableSort) ? "1" : "0.5";
804+
}
793805
}
794806

795807
sortingDiv() {
@@ -800,15 +812,22 @@ class PaybackRateMod {
800812
{ config: "enableSort", text: "Sort by payback rate" },
801813
{ config: "sortGrandmapocalypse", text: "Grandmapocalypse" },
802814
{ config: "sortWizardTower", text: Game.Objects["Wizard tower"].dname },
803-
{ config: "autoBuy", text: "Auto buy best deal" },
804815
];
805816

806817
toggleButtons.forEach((button) => {
807818
sortingDiv.appendChild(this.toggleButton(button.config, button.text));
808819
});
820+
809821
return sortingDiv;
810822
}
811823

824+
autoBuyDiv() {
825+
/* Auto Buy */
826+
const autoBuyDiv = document.createElement("div");
827+
autoBuyDiv.appendChild(this.toggleButton("autoBuy", "Auto buy best deal"));
828+
return autoBuyDiv;
829+
}
830+
812831
bankingDiv() {
813832
/* Banking */
814833
const bankingSecondsInput = document.createElement("input");
@@ -902,6 +921,8 @@ class PaybackRateMod {
902921
body.classList.add("listing");
903922
body.appendChild(this.sortingDiv());
904923
body.appendChild(document.createElement("br"));
924+
body.appendChild(this.autoBuyDiv());
925+
body.appendChild(document.createElement("br"));
905926
body.appendChild(this.bankingDiv());
906927
body.appendChild(document.createElement("br"));
907928
body.appendChild(this.intervalBoxDiv());

0 commit comments

Comments
 (0)