mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-17 13:52:18 +02:00
Select banner texture based on bannerFilename
This commit is contained in:
parent
06e8de245d
commit
f50a9e4c4f
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
@ -31,7 +31,7 @@ export class LoadingScene extends SceneBase {
|
|||||||
// Load menu images
|
// Load menu images
|
||||||
this.loadAtlas('bg', 'ui');
|
this.loadAtlas('bg', 'ui');
|
||||||
if (new TimedEventManager().isEventActive()) {
|
if (new TimedEventManager().isEventActive()) {
|
||||||
this.loadImage('banner', 'events')
|
this.loadImage(new TimedEventManager().getEventBannerFilename(), 'events')
|
||||||
}
|
}
|
||||||
this.loadImage('command_fight_labels', 'ui');
|
this.loadImage('command_fight_labels', 'ui');
|
||||||
this.loadAtlas('prompt', 'ui');
|
this.loadAtlas('prompt', 'ui');
|
||||||
|
@ -4,11 +4,17 @@ interface TimedEvent {
|
|||||||
value: number;
|
value: number;
|
||||||
startDate: string;
|
startDate: string;
|
||||||
endDate: string;
|
endDate: string;
|
||||||
|
bannerFilename: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
example:
|
||||||
|
{"name": "3x Shiny Weekend", "eventType": "shiny", "value": 3,
|
||||||
|
"startDate": "2024-05-18", "endDate": "2024-05-21", "bannerFilename": "5-18-banner"},
|
||||||
|
*/
|
||||||
const timedEvents: TimedEvent[] = [
|
const timedEvents: TimedEvent[] = [
|
||||||
{"name": "3x Shiny Weekend", "eventType": "shiny", "value": 3,
|
{"name": "3x Shiny Weekend", "eventType": "shiny", "value": 3,
|
||||||
"startDate": "2024-05-18", "endDate": "2024-05-21"},
|
"startDate": "2024-05-17", "endDate": "2024-05-21", "bannerFilename": "5-18-banner"},
|
||||||
];
|
];
|
||||||
|
|
||||||
export class TimedEventManager {
|
export class TimedEventManager {
|
||||||
@ -38,4 +44,17 @@ export class TimedEventManager {
|
|||||||
}
|
}
|
||||||
return multiplier;
|
return multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getEventBannerFilename(): string {
|
||||||
|
for (const timedEvent of timedEvents) {
|
||||||
|
const eventStart = new Date(timedEvent.startDate);
|
||||||
|
const now = new Date();
|
||||||
|
const eventEnd = new Date(timedEvent.endDate);
|
||||||
|
|
||||||
|
if (eventStart < now && now < eventEnd) {
|
||||||
|
return timedEvent.bannerFilename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
|
|||||||
this.titleContainer.add(logo);
|
this.titleContainer.add(logo);
|
||||||
|
|
||||||
if (new TimedEventManager().isEventActive()) {
|
if (new TimedEventManager().isEventActive()) {
|
||||||
const banner = this.scene.add.image((this.scene.game.canvas.width / 6.5) / 2, (this.scene.game.canvas.height / 4.65) / 2, 'banner');
|
const banner = this.scene.add.image((this.scene.game.canvas.width / 6.5) / 2, (this.scene.game.canvas.height / 4.65) / 2, new TimedEventManager().getEventBannerFilename());
|
||||||
banner.displayWidth = this.scene.game.canvas.width / 18.33
|
banner.displayWidth = this.scene.game.canvas.width / 18.33
|
||||||
banner.displayHeight = banner.displayWidth / 3
|
banner.displayHeight = banner.displayWidth / 3
|
||||||
banner.setOrigin(0.315, -0.8);
|
banner.setOrigin(0.315, -0.8);
|
||||||
|
Loading…
Reference in New Issue
Block a user