[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>
This commit is contained in:
Mumble 2024-09-01 12:18:40 -07:00 committed by GitHub
parent 85a8abc0e8
commit de66b450a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 68 additions and 61 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -7666,7 +7666,7 @@ export function initBiomes() {
if (biome === Biome.END) { if (biome === Biome.END) {
const biomeList = Object.keys(Biome).filter(key => !isNaN(Number(key))); const biomeList = Object.keys(Biome).filter(key => !isNaN(Number(key)));
biomeList.pop(); // Removes Biome.END from the list 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]]; biome = Biome[biomeList[randIndex]];
} }
const linkedBiomes: (Biome | [ Biome, integer ])[] = Array.isArray(biomeLinks[biome]) const linkedBiomes: (Biome | [ Biome, integer ])[] = Array.isArray(biomeLinks[biome])

View File

@ -41,8 +41,6 @@ export class LoadingScene extends SceneBase {
this.loadImage("loading_bg", "arenas"); this.loadImage("loading_bg", "arenas");
this.loadImage("logo", ""); this.loadImage("logo", "");
// this.loadImage("pride-update", "events");
this.loadImage("august-variant-update", "events");
// Load menu images // Load menu images
this.loadAtlas("bg", "ui"); this.loadAtlas("bg", "ui");
@ -246,7 +244,12 @@ export class LoadingScene extends SceneBase {
} else { } else {
this.loadAtlas("types", ""); 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("statuses", "");
this.loadAtlas("categories", ""); this.loadAtlas("categories", "");

View File

@ -1,35 +1,39 @@
import BattleScene from "#app/battle-scene.js"; import BattleScene from "#app/battle-scene";
import { TextStyle, addTextObject } from "#app/ui/text.js"; import { TextStyle, addTextObject } from "#app/ui/text";
import i18next from "i18next";
export enum EventType { export enum EventType {
SHINY SHINY,
GENERIC
} }
interface TimedEvent { interface EventBanner {
name: string; bannerKey?: string;
eventType: EventType; xPosition?: number;
shinyMultiplier?: number; yPosition?: number;
startDate: Date; scale?: number;
endDate: Date; availableLangs?: string[];
bannerFilename?: string }
interface TimedEvent extends EventBanner {
name: string;
eventType: EventType;
shinyMultiplier?: number;
startDate: Date;
endDate: Date;
} }
const timedEvents: TimedEvent[] = [ const timedEvents: TimedEvent[] = [
{ {
name: "Pride Update", name: "September Update",
eventType: EventType.SHINY, eventType: EventType.GENERIC,
shinyMultiplier: 2, startDate: new Date(Date.UTC(2024, 7, 28, 0)),
startDate: new Date(Date.UTC(2024, 5, 14, 0)), endDate: new Date(Date.UTC(2024, 8, 15, 0)),
endDate: new Date(Date.UTC(2024, 5, 23, 0)), bannerKey: "september-update",
bannerFilename: "pride-update" xPosition: 19,
}, yPosition: 115,
{ scale: 0.30,
name: "August Variant Update", availableLangs: ["en", "de", "it", "fr", "ja", "ko", "es", "pt_BR", "zh_CN"]
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"
} }
]; ];
@ -67,7 +71,7 @@ export class TimedEventManager {
} }
getEventBannerFilename(): string { 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() { setup() {
console.log(this.event?.bannerFilename); const lang = i18next.resolvedLanguage;
this.banner = new Phaser.GameObjects.Image(this.scene, 29, 64, this.event!.bannerFilename!); // TODO: are the bangs correct here? if (this.event && this.event.bannerKey) {
this.banner.setName("img-event-banner"); if (lang && this.event.availableLangs && this.event.availableLangs.length > 0) {
this.banner.setOrigin(0.08, -0.35); if (this.event.availableLangs.includes(lang)) {
this.banner.setScale(0.18); this.event.bannerKey += "-"+lang;
// this.bannerShadow = new Phaser.GameObjects.Rectangle( } else {
// this.scene, this.event.bannerKey += "-en";
// this.banner.x - 2, }
// this.banner.y + 2, }
// this.banner.width, console.log(this.event.bannerKey);
// this.banner.height, this.banner = new Phaser.GameObjects.Image(this.scene, this.event.xPosition ?? 29, this.event.yPosition ?? 64, this.event.bannerKey);
// 0x484848 this.banner.setName("img-event-banner");
// ); this.banner.setOrigin(0.08, -0.35);
// this.bannerShadow.setName("rect-event-banner-shadow"); this.banner.setScale(this.event.scale ?? 0.18);
// this.bannerShadow.setScale(0.07); if (this.event.eventType !== EventType.GENERIC) {
// this.bannerShadow.setAlpha(0.5); this.eventTimerText = addTextObject(
// this.bannerShadow.setOrigin(0,0); this.scene,
this.eventTimerText = addTextObject( this.banner.x + 8,
this.scene, this.banner.y + 100,
this.banner.x + 8, this.timeToGo(this.event.endDate),
this.banner.y + 100, TextStyle.WINDOW
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.setName("text-event-timer"); this.eventTimerText.setOrigin(0, 0);
this.eventTimerText.setScale(0.15);
this.eventTimerText.setOrigin(0, 0);
this.add([ this.add(this.eventTimerText);
this.eventTimerText, }
// this.bannerShadow, this.add(this.banner);
this.banner]); }
} }
show() { show() {
@ -157,6 +159,8 @@ export class TimedEventDisplay extends Phaser.GameObjects.Container {
} }
updateCountdown() { 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));
}
} }
} }