mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-25 12:17:22 +00:00
Add toggle to enable/disable sound
This commit is contained in:
22
dist/web/birb.embed.js
vendored
22
dist/web/birb.embed.js
vendored
@@ -1194,7 +1194,7 @@
|
||||
|
||||
class MenuItem {
|
||||
/**
|
||||
* @param {string} text
|
||||
* @param {string|(() => string)} text
|
||||
* @param {() => void} action
|
||||
* @param {boolean} [removeMenu]
|
||||
*/
|
||||
@@ -1243,7 +1243,7 @@
|
||||
if (item instanceof Separator) {
|
||||
return makeElement("birb-window-separator");
|
||||
}
|
||||
let menuItem = makeElement("birb-menu-item", item.text);
|
||||
let menuItem = makeElement("birb-menu-item", typeof item.text === "function" ? item.text() : item.text);
|
||||
onClick(menuItem, () => {
|
||||
if (item.removeMenu) {
|
||||
removeMenuCallback();
|
||||
@@ -1350,7 +1350,8 @@
|
||||
* @typedef {typeof DEFAULT_SETTINGS} Settings
|
||||
*/
|
||||
const DEFAULT_SETTINGS = {
|
||||
birbMode: false
|
||||
birbMode: false,
|
||||
soundEnabled: true
|
||||
};
|
||||
|
||||
// Rendering constants
|
||||
@@ -1563,6 +1564,7 @@
|
||||
|
||||
.birb-menu-item {
|
||||
width: calc(100% - var(--birb-double-border-size));
|
||||
white-space: nowrap;
|
||||
font-size: 14px;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
@@ -1835,7 +1837,11 @@
|
||||
const settingsItems = [
|
||||
new MenuItem("Go Back", () => switchMenuItems(menuItems, updateMenuLocation), false),
|
||||
new Separator(),
|
||||
new MenuItem("Toggle Birb Mode", () => {
|
||||
new MenuItem(() => `${userSettings.soundEnabled ? "Disable" : "Enable"} Sound`, () => {
|
||||
userSettings.soundEnabled = !userSettings.soundEnabled;
|
||||
save();
|
||||
}),
|
||||
new MenuItem(() => `Toggle ${birdBirb(true)} Mode`, () => {
|
||||
userSettings.birbMode = !userSettings.birbMode;
|
||||
save();
|
||||
const message = makeElement("birb-message-content");
|
||||
@@ -1954,8 +1960,8 @@
|
||||
/**
|
||||
* Bird or birb, you decide
|
||||
*/
|
||||
function birdBirb() {
|
||||
return settings().birbMode ? "Birb" : "Bird";
|
||||
function birdBirb(invert = false) {
|
||||
return settings().birbMode !== invert ? "Birb" : "Bird";
|
||||
}
|
||||
|
||||
function init() {
|
||||
@@ -2544,7 +2550,9 @@
|
||||
|
||||
function pet() {
|
||||
if (currentState === States.IDLE && birb.getCurrentAnimation() !== Animations.HEART) {
|
||||
birdsong.chirp();
|
||||
if (settings().soundEnabled) {
|
||||
birdsong.chirp();
|
||||
}
|
||||
birb.setAnimation(Animations.HEART);
|
||||
lastPetTimestamp = Date.now();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user