mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-25 22:46:15 -04:00
Build 29059721
This commit is contained in:
parent
1cf82d6641
commit
a3ff7d81ad
13 changed files with 148 additions and 157 deletions
|
@ -1,54 +1,54 @@
|
|||
import {asyncAlert} from "./asyncAlert";
|
||||
import {PerkId, Upgrade} from "./types";
|
||||
import {t} from "./i18n/i18n";
|
||||
import {icons, upgrades} from "./loadGameData";
|
||||
import {getSettingValue, getTotalScore, setSettingValue} from "./settings";
|
||||
import { asyncAlert } from "./asyncAlert";
|
||||
import { PerkId, Upgrade } from "./types";
|
||||
import { t } from "./i18n/i18n";
|
||||
import { icons, upgrades } from "./loadGameData";
|
||||
import { getSettingValue, getTotalScore, setSettingValue } from "./settings";
|
||||
|
||||
export function startingPerkMenuButton() {
|
||||
return {
|
||||
icon: icons["icon:starting_perks"],
|
||||
text: t("main_menu.starting_perks"),
|
||||
help: t("main_menu.starting_perks_help"),
|
||||
async value() {
|
||||
await openStartingPerksEditor();
|
||||
},
|
||||
};
|
||||
}
|
||||
function isChecked(u: Upgrade): boolean {
|
||||
return getSettingValue("start_with_" + u.id, u.giftable);
|
||||
}
|
||||
|
||||
export function startingPerkMenuButton(){
|
||||
export async function openStartingPerksEditor() {
|
||||
const ts = getTotalScore();
|
||||
const avaliable = upgrades.filter(
|
||||
(u) =>
|
||||
!u.requires && !["instant_upgrade"].includes(u.id) && u.threshold <= ts,
|
||||
);
|
||||
const starting = avaliable.filter((u) => isChecked(u));
|
||||
const buttons = avaliable.map((u) => {
|
||||
const checked = isChecked(u);
|
||||
return {
|
||||
icon:icons['icon:starting_perks'],
|
||||
text:t('main_menu.starting_perks'),
|
||||
help:t('main_menu.starting_perks_help'),
|
||||
async value(){
|
||||
await openStartingPerksEditor()
|
||||
}
|
||||
}
|
||||
icon: u.icon,
|
||||
text: u.name,
|
||||
tooltip: u.help(1),
|
||||
value: u,
|
||||
disabled: checked && starting.length < 2,
|
||||
checked,
|
||||
};
|
||||
});
|
||||
|
||||
const perk: Upgrade | null | void = await asyncAlert({
|
||||
title: t("main_menu.starting_perks"),
|
||||
actionsAsGrid: true,
|
||||
content: [
|
||||
t("main_menu.starting_perks_checked"),
|
||||
...buttons.filter((b) => b.checked),
|
||||
t("main_menu.starting_perks_unchecked"),
|
||||
...buttons.filter((b) => !b.checked),
|
||||
],
|
||||
});
|
||||
if (perk) {
|
||||
setSettingValue("start_with_" + perk.id, !isChecked(perk));
|
||||
openStartingPerksEditor();
|
||||
}
|
||||
}
|
||||
function isChecked(u:Upgrade):boolean{
|
||||
return getSettingValue('start_with_'+u.id, u.giftable)
|
||||
}
|
||||
|
||||
export async function openStartingPerksEditor(){
|
||||
const ts=getTotalScore()
|
||||
const avaliable=upgrades.filter(u=>!u.requires && !['instant_upgrade'].includes(u.id) && u.threshold<=ts)
|
||||
const starting = avaliable.filter(u=>isChecked(u))
|
||||
const buttons=avaliable
|
||||
.map(u=> {
|
||||
const checked = isChecked(u);
|
||||
return {
|
||||
icon: u.icon,
|
||||
text: u.name,
|
||||
tooltip: u.help(1),
|
||||
value:u,
|
||||
disabled:checked && starting.length<2,
|
||||
checked
|
||||
}
|
||||
})
|
||||
|
||||
const perk :Upgrade|null|void= await asyncAlert({
|
||||
title:t('main_menu.starting_perks'),
|
||||
actionsAsGrid:true,
|
||||
content:[
|
||||
t('main_menu.starting_perks_checked'),
|
||||
...buttons.filter(b=>b.checked),
|
||||
t('main_menu.starting_perks_unchecked'),
|
||||
...buttons.filter(b=>!b.checked),
|
||||
|
||||
]
|
||||
})
|
||||
if(perk){
|
||||
setSettingValue('start_with_'+perk.id,!isChecked(perk))
|
||||
openStartingPerksEditor()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue