From f1bf01686c236c23334fe4ea69db492587366e7d Mon Sep 17 00:00:00 2001 From: Slushie Date: Thu, 13 Apr 2023 03:19:37 +0100 Subject: [PATCH] Screenshot page --- app/social/generators/EggstraWorkStatus.mjs | 48 ++++++++++++ .../generators/EggstraWorkUpcomingStatus.mjs | 73 +++++++++++++++++++ app/social/index.mjs | 4 + .../salmonrun/ExpandedSalmonRunRow.vue | 2 +- src/views/screenshots/SalmonRunView.vue | 2 +- 5 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 app/social/generators/EggstraWorkStatus.mjs create mode 100644 app/social/generators/EggstraWorkUpcomingStatus.mjs diff --git a/app/social/generators/EggstraWorkStatus.mjs b/app/social/generators/EggstraWorkStatus.mjs new file mode 100644 index 0000000..1038f24 --- /dev/null +++ b/app/social/generators/EggstraWorkStatus.mjs @@ -0,0 +1,48 @@ +import StatusGenerator from "./StatusGenerator.mjs"; +import Media from "../Media.mjs"; +import { useEggstraWorkSchedulesStore } from "../../../src/stores/schedules.mjs"; + +export default class EggstraWorkStatus extends StatusGenerator +{ + key = 'eggstrawork'; + name = 'Eggstra Work'; + + async getActiveSchedule() { + await this.preparePinia(); + + return useEggstraWorkSchedulesStore().activeSchedule; + } + + async getDataTime() { + let schedule = await this.getActiveSchedule(); + + return Date.parse(schedule.startTime); + } + + async _getStatus() { + let schedule = await this.getActiveSchedule(); + + let lines = []; + + let mode = 'Eggstra Work' + + lines.push(`${mode} is now open on ${schedule.settings.coopStage.name}! #salmonrun #splatoon3`); + + lines.push(''); + + lines.push('Current weapons:'); + lines.push(...schedule.settings.weapons.map(w => `– ${w.name}`)); + + return lines.join('\n'); + } + + /** @param {ScreenshotHelper} screenshotHelper */ + async _getMedia(screenshotHelper) { + let media = new Media; + media.file = await screenshotHelper.capture('salmonrun', { + params: {eggstra: "true"} + }); + + return media; + } +} diff --git a/app/social/generators/EggstraWorkUpcomingStatus.mjs b/app/social/generators/EggstraWorkUpcomingStatus.mjs new file mode 100644 index 0000000..e9da812 --- /dev/null +++ b/app/social/generators/EggstraWorkUpcomingStatus.mjs @@ -0,0 +1,73 @@ +import StatusGenerator from "./StatusGenerator.mjs"; +import Media from "../Media.mjs"; +import { useEggstraWorkSchedulesStore } from "../../../src/stores/schedules.mjs"; +import { useTimeStore } from "../../../src/stores/time.mjs"; + +export default class EggstraWorkUpcomingStatus extends StatusGenerator +{ + key = 'eggstrawork.upcoming'; + name = 'Upcoming Eggstra Work'; + + async getActiveSchedule() { + await this.preparePinia(); + + // Look for any upcoming schedules + return useEggstraWorkSchedulesStore().upcomingSchedules[0]; + } + + async getDataTime() { + let schedule = await this.getActiveSchedule(); + + return schedule + ? Date.parse(schedule.startTime) + : false; + } + + _getDescription(schedule) { + let stageName = schedule.settings.coopStage.name || '???'; + + return `An Eggstra Work shift on ${stageName} has been added to the schedule! #salmonrun #splatoon3`; + } + + async _getStatus() { + let schedule = await this.getActiveSchedule(); + + if (!schedule) { + return false; + } + + let lines = []; + + lines.push(this._getDescription(schedule)); + lines.push(''); + + let startTime = Date.parse(schedule.startTime); + let now = useTimeStore().now; + let hours = Math.floor((startTime - now) / (1000 * 60 * 60)); + + let formattedTime; + if (hours >= 24) { + let days = Math.round(hours / 24); + formattedTime = days === 1 ? '1 day' : `${days} days`; + } else { + formattedTime = hours === 1 ? '1 hour' : `${hours} hours`; + } + + lines.push(`This shift will start in ${formattedTime} with these weapons:`); + lines.push(...schedule.settings.weapons.map(w => `– ${w.name}`)); + + return lines.join('\n'); + } + + /** @param {ScreenshotHelper} screenshotHelper */ + async _getMedia(screenshotHelper) { + let schedule = await this.getActiveSchedule(); + + let media = new Media; + media.file = await screenshotHelper.capture('salmonRun', { + params: { startTime: schedule?.startTime, eggstra: "true" }, + }); + + return media; + } +} diff --git a/app/social/index.mjs b/app/social/index.mjs index 0b367da..64af772 100644 --- a/app/social/index.mjs +++ b/app/social/index.mjs @@ -11,6 +11,8 @@ import SplatfestStatus from "./generators/SplatfestStatus.mjs"; import SplatfestResultsStatus from "./generators/SplatfestResultsStatus.mjs"; import StatusGeneratorManager from "./StatusGeneratorManager.mjs" import SalmonRunUpcomingStatus from "./generators/SalmonRunUpcomingStatus.mjs"; +import EggstraWorkStatus from "./generators/EggstraWorkStatus.mjs"; +import EggstraWorkUpcomingStatus from "./generators/EggstraWorkUpcomingStatus.mjs"; function defaultStatusGenerators() { return [ @@ -22,6 +24,8 @@ function defaultStatusGenerators() { new SalmonRunGearStatus, new SplatfestStatus, new SplatfestResultsStatus, + new EggstraWorkStatus, + new EggstraWorkUpcomingStatus, ]; } diff --git a/src/components/salmonrun/ExpandedSalmonRunRow.vue b/src/components/salmonrun/ExpandedSalmonRunRow.vue index b37c008..a61f1ef 100644 --- a/src/components/salmonrun/ExpandedSalmonRunRow.vue +++ b/src/components/salmonrun/ExpandedSalmonRunRow.vue @@ -8,7 +8,7 @@