From 736e19871fb2b0482ae516e7867b590ee4ae16d3 Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Wed, 12 Oct 2022 18:01:27 -0400
Subject: [PATCH 1/2] holiday effects v2
- Rude config change, `holidayEffects` is now an array of objects instead of an object with bool properties
- name (does nothing other than label in config): string
- enabled: boolean
- images: string[]
- css: 'snow' | 'fireworks'
- startDay: int
- startMonth: int
- endDay: int
- startDay: int
- Enables any amount of images to be put into the effects as well as any amount of custom holiday effects
---
package.json | 2 +-
server/src/configs/default.json | 65 +++++++++++++++++++--
server/src/services/config.js | 12 +++-
src/components/Config.jsx | 4 +-
src/components/HolidayEffects.jsx | 95 +++++++++++++------------------
src/services/HolidayAnimations.js | 15 +++--
6 files changed, 120 insertions(+), 73 deletions(-)
diff --git a/package.json b/package.json
index 962719e78..48989731a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "reactmap",
- "version": "1.5.1",
+ "version": "1.6.0",
"description": "React based frontend map.",
"main": "ReactMap.js",
"author": "TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>",
diff --git a/server/src/configs/default.json b/server/src/configs/default.json
index d302980a8..adac5d4e3 100644
--- a/server/src/configs/default.json
+++ b/server/src/configs/default.json
@@ -137,12 +137,65 @@
"rolesLinkName": "Role Upgrading Info",
"rolesLink": ""
},
- "holidayEffects": {
- "christmasSnow": true,
- "newYearsFireworks": true,
- "valentinesDay": true,
- "internationalWomensDay": true
- },
+ "holidayEffects": [
+ {
+ "name": "Valentine's Day",
+ "enabled": true,
+ "images": [
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/A_perfect_SVG_heart.svg/20px-A_perfect_SVG_heart.svg.png"
+ ],
+ "imageScale": 1.5,
+ "startMonth": 1,
+ "startDay": 14,
+ "endMonth": 1,
+ "endDay": 14
+ },
+ {
+ "name": "International Women's Day",
+ "enabled": true,
+ "images": [
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Emoji_u1f338.svg/20px-Emoji_u1f338.svg.png"
+ ],
+ "imageScale": 1,
+ "startDay": 8,
+ "startMonth": 3,
+ "endDay": 8,
+ "endMonth": 3
+ },
+ {
+ "name": "Halloween",
+ "enabled": true,
+ "images": [
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/Fluent_Emoji_flat_1f383.svg/640px-Fluent_Emoji_flat_1f383.svg.png",
+ "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Ghost.svg/640px-Ghost.svg.png"
+ ],
+ "imageScale": 2,
+ "startDay": 29,
+ "startMonth": 10,
+ "endDay": 31,
+ "endMonth": 10
+ },
+ {
+ "name": "Christmas",
+ "enabled": true,
+ "images": [],
+ "css": "snow",
+ "startDay": 25,
+ "startMonth": 12,
+ "endDay": 26,
+ "endMonth": 12
+ },
+ {
+ "name": "New Years",
+ "enabled": true,
+ "images": [],
+ "css": "fireworks",
+ "startDay": 31,
+ "startMonth": 12,
+ "endDay": 1,
+ "endMonth": 1
+ }
+ ],
"misc": {
"enableMapJsFilter": true,
"fetchLatestInvasions": true,
diff --git a/server/src/services/config.js b/server/src/services/config.js
index 934c72277..3cf103c4f 100644
--- a/server/src/services/config.js
+++ b/server/src/services/config.js
@@ -156,13 +156,22 @@ const mergeMapConfig = (obj) => {
}
})
+ if (
+ obj?.holidayEffects &&
+ !Array.isArray(obj?.holidayEffects) &&
+ typeof obj?.holidayEffects === 'object'
+ ) {
+ console.warn(
+ '[CONFIG] holidayEffects has been changed to an array, please update your config. Check out `server/src/configs/default.json` for an example.',
+ )
+ obj.holidayEffects = []
+ }
return {
localeSelection: obj.localeSelection,
...obj,
...obj.general,
...obj.customRoutes,
...obj.links,
- ...obj.holidayEffects,
...obj.misc,
messageOfTheDay: {
...obj.messageOfTheDay,
@@ -179,7 +188,6 @@ const mergeMapConfig = (obj) => {
general: undefined,
customRoutes: undefined,
links: undefined,
- holidayEffects: undefined,
misc: undefined,
}
}
diff --git a/src/components/Config.jsx b/src/components/Config.jsx
index cb99e0d98..98bdf7fb0 100644
--- a/src/components/Config.jsx
+++ b/src/components/Config.jsx
@@ -66,9 +66,7 @@ export default function Config() {
getServerSettings={getServerSettings}
/>