diff --git a/birb.js b/birb.js
index 1b0d192..c6750fd 100644
--- a/birb.js
+++ b/birb.js
@@ -35,6 +35,17 @@ const MENU_EXIT_ID = "birb-menu-exit";
const FIELD_GUIDE_ID = "birb-field-guide";
const FEATHER_ID = "birb-feather";
+
+const DEFAULT_SETTINGS = {
+ birbMode: false
+};
+
+/**
+ * @typedef {typeof DEFAULT_SETTINGS} Settings
+ */
+
+let userSettings = {};
+
const styles = `
@font-face {
font-family: Monocraft;
@@ -845,11 +856,11 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
}
const menuItems = [
- new MenuItem("Pet Birb", pet),
+ new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide),
// new MenuItem("Decorations", insertDecoration),
new DebugMenuItem("Applications", () => switchMenuItems(otherItems), false),
- new MenuItem("Hide Birb", hideBirb),
+ new MenuItem(`Hide ${birdBirb()}`, hideBirb),
new DebugMenuItem("Reset Data", resetSaveData),
new DebugMenuItem("Unlock All", () => {
for (let type in species) {
@@ -952,7 +963,11 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
} else {
log("Not a UserScript");
}
- log("Loaded data: " + JSON.stringify(saveData));
+ debug("Loaded data: " + JSON.stringify(saveData));
+ if (!saveData.settings) {
+ log("No user settings found in save data, starting fresh");
+ }
+ userSettings = saveData.settings ?? {};
unlockedSpecies = saveData.unlockedSpecies ?? [DEFAULT_BIRD];
currentSpecies = saveData.currentSpecies ?? DEFAULT_BIRD;
switchSpecies(currentSpecies);
@@ -962,6 +977,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
let saveData = {
unlockedSpecies: unlockedSpecies,
currentSpecies: currentSpecies,
+ settings: userSettings
};
if (isUserScript()) {
log("Saving data to UserScript storage");
@@ -989,6 +1005,21 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
load();
}
+ /**
+ * Get the user settings merged with default settings
+ * @returns {Settings} The merged settings
+ */
+ function settings() {
+ return { ...DEFAULT_SETTINGS, ...userSettings };
+ }
+
+ /**
+ * Bird or birb, you decide
+ */
+ function birdBirb() {
+ return settings().birbMode ? "Birb" : "Bird";
+ }
+
function init() {
if (window !== window.top) {
// Skip installation if within an iframe
@@ -1446,7 +1477,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
}
let menu = makeElement("birb-window", undefined, MENU_ID);
let header = makeElement("birb-window-header");
- header.innerHTML = '
birbOS
';
+ header.innerHTML = `${birdBirb().toLowerCase()}OS
`;
let content = makeElement("birb-window-content");
for (const item of menuItems) {
if (!item.isDebug || debugMode) {
@@ -1856,6 +1887,12 @@ function log() {
console.log("Birb: ", ...arguments);
}
+function debug() {
+ if (debugMode) {
+ console.debug("Birb: ", ...arguments);
+ }
+}
+
function error() {
console.error("Birb: ", ...arguments);
}
\ No newline at end of file
diff --git a/dist/birb.js b/dist/birb.js
index ea56b3a..0b246c0 100644
--- a/dist/birb.js
+++ b/dist/birb.js
@@ -35,6 +35,17 @@ const MENU_EXIT_ID = "birb-menu-exit";
const FIELD_GUIDE_ID = "birb-field-guide";
const FEATHER_ID = "birb-feather";
+
+const DEFAULT_SETTINGS = {
+ birbMode: false
+};
+
+/**
+ * @typedef {typeof DEFAULT_SETTINGS} Settings
+ */
+
+let userSettings = {};
+
const styles = `
@font-face {
font-family: Monocraft;
@@ -845,11 +856,11 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
}
const menuItems = [
- new MenuItem("Pet Birb", pet),
+ new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide),
// new MenuItem("Decorations", insertDecoration),
new DebugMenuItem("Applications", () => switchMenuItems(otherItems), false),
- new MenuItem("Hide Birb", hideBirb),
+ new MenuItem(`Hide ${birdBirb()}`, hideBirb),
new DebugMenuItem("Reset Data", resetSaveData),
new DebugMenuItem("Unlock All", () => {
for (let type in species) {
@@ -952,7 +963,11 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
} else {
log("Not a UserScript");
}
- log("Loaded data: " + JSON.stringify(saveData));
+ debug("Loaded data: " + JSON.stringify(saveData));
+ if (!saveData.settings) {
+ log("No user settings found in save data, starting fresh");
+ }
+ userSettings = saveData.settings ?? {};
unlockedSpecies = saveData.unlockedSpecies ?? [DEFAULT_BIRD];
currentSpecies = saveData.currentSpecies ?? DEFAULT_BIRD;
switchSpecies(currentSpecies);
@@ -962,6 +977,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
let saveData = {
unlockedSpecies: unlockedSpecies,
currentSpecies: currentSpecies,
+ settings: userSettings
};
if (isUserScript()) {
log("Saving data to UserScript storage");
@@ -989,6 +1005,21 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
load();
}
+ /**
+ * Get the user settings merged with default settings
+ * @returns {Settings} The merged settings
+ */
+ function settings() {
+ return { ...DEFAULT_SETTINGS, ...userSettings };
+ }
+
+ /**
+ * Bird or birb, you decide
+ */
+ function birdBirb() {
+ return settings().birbMode ? "Birb" : "Bird";
+ }
+
function init() {
if (window !== window.top) {
// Skip installation if within an iframe
@@ -1446,7 +1477,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
}
let menu = makeElement("birb-window", undefined, MENU_ID);
let header = makeElement("birb-window-header");
- header.innerHTML = 'birbOS
';
+ header.innerHTML = `${birdBirb().toLowerCase()}OS
`;
let content = makeElement("birb-window-content");
for (const item of menuItems) {
if (!item.isDebug || debugMode) {
@@ -1856,6 +1887,12 @@ function log() {
console.log("Birb: ", ...arguments);
}
+function debug() {
+ if (debugMode) {
+ console.debug("Birb: ", ...arguments);
+ }
+}
+
function error() {
console.error("Birb: ", ...arguments);
}
\ No newline at end of file
diff --git a/dist/birb.user.js b/dist/birb.user.js
index ed7d25c..627800e 100644
--- a/dist/birb.user.js
+++ b/dist/birb.user.js
@@ -48,6 +48,17 @@ const MENU_EXIT_ID = "birb-menu-exit";
const FIELD_GUIDE_ID = "birb-field-guide";
const FEATHER_ID = "birb-feather";
+
+const DEFAULT_SETTINGS = {
+ birbMode: false
+};
+
+/**
+ * @typedef {typeof DEFAULT_SETTINGS} Settings
+ */
+
+let userSettings = {};
+
const styles = `
@font-face {
font-family: Monocraft;
@@ -858,11 +869,11 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
}
const menuItems = [
- new MenuItem("Pet Birb", pet),
+ new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide),
// new MenuItem("Decorations", insertDecoration),
new DebugMenuItem("Applications", () => switchMenuItems(otherItems), false),
- new MenuItem("Hide Birb", hideBirb),
+ new MenuItem(`Hide ${birdBirb()}`, hideBirb),
new DebugMenuItem("Reset Data", resetSaveData),
new DebugMenuItem("Unlock All", () => {
for (let type in species) {
@@ -965,7 +976,11 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
} else {
log("Not a UserScript");
}
- log("Loaded data: " + JSON.stringify(saveData));
+ debug("Loaded data: " + JSON.stringify(saveData));
+ if (!saveData.settings) {
+ log("No user settings found in save data, starting fresh");
+ }
+ userSettings = saveData.settings ?? {};
unlockedSpecies = saveData.unlockedSpecies ?? [DEFAULT_BIRD];
currentSpecies = saveData.currentSpecies ?? DEFAULT_BIRD;
switchSpecies(currentSpecies);
@@ -975,6 +990,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
let saveData = {
unlockedSpecies: unlockedSpecies,
currentSpecies: currentSpecies,
+ settings: userSettings
};
if (isUserScript()) {
log("Saving data to UserScript storage");
@@ -1002,6 +1018,21 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
load();
}
+ /**
+ * Get the user settings merged with default settings
+ * @returns {Settings} The merged settings
+ */
+ function settings() {
+ return { ...DEFAULT_SETTINGS, ...userSettings };
+ }
+
+ /**
+ * Bird or birb, you decide
+ */
+ function birdBirb() {
+ return settings().birbMode ? "Birb" : "Bird";
+ }
+
function init() {
if (window !== window.top) {
// Skip installation if within an iframe
@@ -1459,7 +1490,7 @@ Promise.all([loadSpriteSheetPixels(SPRITE_SHEET), loadSpriteSheetPixels(DECORATI
}
let menu = makeElement("birb-window", undefined, MENU_ID);
let header = makeElement("birb-window-header");
- header.innerHTML = 'birbOS
';
+ header.innerHTML = `${birdBirb().toLowerCase()}OS
`;
let content = makeElement("birb-window-content");
for (const item of menuItems) {
if (!item.isDebug || debugMode) {
@@ -1869,6 +1900,12 @@ function log() {
console.log("Birb: ", ...arguments);
}
+function debug() {
+ if (debugMode) {
+ console.debug("Birb: ", ...arguments);
+ }
+}
+
function error() {
console.error("Birb: ", ...arguments);
}
\ No newline at end of file