[Beta][Misc] Banner (#3926)
* Initial work - does not work. * Revert * image replacement * better scaling * Removing most of the bangs * no more bangs * Update src/timed-event-manager.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Implemented Torranx's suggestion * Ready for Translations * Delete Picture * Localized banners * Biomes fix * Corrections * Update src/timed-event-manager.ts Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt> --------- Co-authored-by: frutescens <info@laptop> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt>
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 38 KiB |
|
@ -7666,7 +7666,7 @@ export function initBiomes() {
|
|||
if (biome === Biome.END) {
|
||||
const biomeList = Object.keys(Biome).filter(key => !isNaN(Number(key)));
|
||||
biomeList.pop(); // Removes Biome.END from the list
|
||||
const randIndex = Utils.randInt(biomeList.length, 2); // Will never be Biome.TOWN or Biome.PLAINS
|
||||
const randIndex = Utils.randInt(biomeList.length, 1); // Will never be Biome.TOWN
|
||||
biome = Biome[biomeList[randIndex]];
|
||||
}
|
||||
const linkedBiomes: (Biome | [ Biome, integer ])[] = Array.isArray(biomeLinks[biome])
|
||||
|
|
|
@ -41,8 +41,6 @@ export class LoadingScene extends SceneBase {
|
|||
|
||||
this.loadImage("loading_bg", "arenas");
|
||||
this.loadImage("logo", "");
|
||||
// this.loadImage("pride-update", "events");
|
||||
this.loadImage("august-variant-update", "events");
|
||||
|
||||
// Load menu images
|
||||
this.loadAtlas("bg", "ui");
|
||||
|
@ -246,7 +244,12 @@ export class LoadingScene extends SceneBase {
|
|||
} else {
|
||||
this.loadAtlas("types", "");
|
||||
}
|
||||
|
||||
const availableLangs = ["en", "de", "it", "fr", "ja", "ko", "es", "pt_BR", "zh_CN"];
|
||||
if (lang && availableLangs.includes(lang)) {
|
||||
this.loadImage("september-update-"+lang, "events");
|
||||
} else {
|
||||
this.loadImage("september-update-en", "events");
|
||||
}
|
||||
|
||||
this.loadAtlas("statuses", "");
|
||||
this.loadAtlas("categories", "");
|
||||
|
|
|
@ -1,35 +1,39 @@
|
|||
import BattleScene from "#app/battle-scene.js";
|
||||
import { TextStyle, addTextObject } from "#app/ui/text.js";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { TextStyle, addTextObject } from "#app/ui/text";
|
||||
import i18next from "i18next";
|
||||
|
||||
export enum EventType {
|
||||
SHINY
|
||||
SHINY,
|
||||
GENERIC
|
||||
}
|
||||
|
||||
interface TimedEvent {
|
||||
name: string;
|
||||
eventType: EventType;
|
||||
shinyMultiplier?: number;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
bannerFilename?: string
|
||||
interface EventBanner {
|
||||
bannerKey?: string;
|
||||
xPosition?: number;
|
||||
yPosition?: number;
|
||||
scale?: number;
|
||||
availableLangs?: string[];
|
||||
}
|
||||
|
||||
interface TimedEvent extends EventBanner {
|
||||
name: string;
|
||||
eventType: EventType;
|
||||
shinyMultiplier?: number;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
}
|
||||
|
||||
const timedEvents: TimedEvent[] = [
|
||||
{
|
||||
name: "Pride Update",
|
||||
eventType: EventType.SHINY,
|
||||
shinyMultiplier: 2,
|
||||
startDate: new Date(Date.UTC(2024, 5, 14, 0)),
|
||||
endDate: new Date(Date.UTC(2024, 5, 23, 0)),
|
||||
bannerFilename: "pride-update"
|
||||
},
|
||||
{
|
||||
name: "August Variant Update",
|
||||
eventType: EventType.SHINY,
|
||||
shinyMultiplier: 2,
|
||||
startDate: new Date(Date.UTC(2024, 7, 16, 0)),
|
||||
endDate: new Date(Date.UTC(2024, 7, 22, 0)),
|
||||
bannerFilename: "august-variant-update"
|
||||
name: "September Update",
|
||||
eventType: EventType.GENERIC,
|
||||
startDate: new Date(Date.UTC(2024, 7, 28, 0)),
|
||||
endDate: new Date(Date.UTC(2024, 8, 15, 0)),
|
||||
bannerKey: "september-update",
|
||||
xPosition: 19,
|
||||
yPosition: 115,
|
||||
scale: 0.30,
|
||||
availableLangs: ["en", "de", "it", "fr", "ja", "ko", "es", "pt_BR", "zh_CN"]
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -67,7 +71,7 @@ export class TimedEventManager {
|
|||
}
|
||||
|
||||
getEventBannerFilename(): string {
|
||||
return timedEvents.find((te: TimedEvent) => this.isActive(te))?.bannerFilename!; // TODO: is this bang correct?
|
||||
return timedEvents.find((te: TimedEvent) => this.isActive(te))?.bannerKey!; // TODO: is this bang correct?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,38 +89,36 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container {
|
|||
}
|
||||
|
||||
setup() {
|
||||
console.log(this.event?.bannerFilename);
|
||||
this.banner = new Phaser.GameObjects.Image(this.scene, 29, 64, this.event!.bannerFilename!); // TODO: are the bangs correct here?
|
||||
this.banner.setName("img-event-banner");
|
||||
this.banner.setOrigin(0.08, -0.35);
|
||||
this.banner.setScale(0.18);
|
||||
// this.bannerShadow = new Phaser.GameObjects.Rectangle(
|
||||
// this.scene,
|
||||
// this.banner.x - 2,
|
||||
// this.banner.y + 2,
|
||||
// this.banner.width,
|
||||
// this.banner.height,
|
||||
// 0x484848
|
||||
// );
|
||||
// this.bannerShadow.setName("rect-event-banner-shadow");
|
||||
// this.bannerShadow.setScale(0.07);
|
||||
// this.bannerShadow.setAlpha(0.5);
|
||||
// this.bannerShadow.setOrigin(0,0);
|
||||
this.eventTimerText = addTextObject(
|
||||
this.scene,
|
||||
this.banner.x + 8,
|
||||
this.banner.y + 100,
|
||||
this.timeToGo(this.event!.endDate), // TODO: is the bang correct here?
|
||||
TextStyle.WINDOW
|
||||
);
|
||||
this.eventTimerText.setName("text-event-timer");
|
||||
this.eventTimerText.setScale(0.15);
|
||||
this.eventTimerText.setOrigin(0, 0);
|
||||
const lang = i18next.resolvedLanguage;
|
||||
if (this.event && this.event.bannerKey) {
|
||||
if (lang && this.event.availableLangs && this.event.availableLangs.length > 0) {
|
||||
if (this.event.availableLangs.includes(lang)) {
|
||||
this.event.bannerKey += "-"+lang;
|
||||
} else {
|
||||
this.event.bannerKey += "-en";
|
||||
}
|
||||
}
|
||||
console.log(this.event.bannerKey);
|
||||
this.banner = new Phaser.GameObjects.Image(this.scene, this.event.xPosition ?? 29, this.event.yPosition ?? 64, this.event.bannerKey);
|
||||
this.banner.setName("img-event-banner");
|
||||
this.banner.setOrigin(0.08, -0.35);
|
||||
this.banner.setScale(this.event.scale ?? 0.18);
|
||||
if (this.event.eventType !== EventType.GENERIC) {
|
||||
this.eventTimerText = addTextObject(
|
||||
this.scene,
|
||||
this.banner.x + 8,
|
||||
this.banner.y + 100,
|
||||
this.timeToGo(this.event.endDate),
|
||||
TextStyle.WINDOW
|
||||
);
|
||||
this.eventTimerText.setName("text-event-timer");
|
||||
this.eventTimerText.setScale(0.15);
|
||||
this.eventTimerText.setOrigin(0, 0);
|
||||
|
||||
this.add([
|
||||
this.eventTimerText,
|
||||
// this.bannerShadow,
|
||||
this.banner]);
|
||||
this.add(this.eventTimerText);
|
||||
}
|
||||
this.add(this.banner);
|
||||
}
|
||||
}
|
||||
|
||||
show() {
|
||||
|
@ -157,6 +159,8 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container {
|
|||
}
|
||||
|
||||
updateCountdown() {
|
||||
this.eventTimerText.setText(this.timeToGo(this.event!.endDate)); // TODO: is the bang correct here?
|
||||
if (this.event && this.event.eventType !== EventType.GENERIC) {
|
||||
this.eventTimerText.setText(this.timeToGo(this.event.endDate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|