Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a simple menu message #1142

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Admiral-Billy
Copy link
Contributor

@Admiral-Billy Admiral-Billy commented May 19, 2024

As the title implies, this adds support for a basic menu message that can be used to alert players of shiny events, special updates, giveaways, etc.

If the message is an empty string, it just won't show up at all. If the background color is blank, there will be no background color. if the text color is blank, it'll default to white.

For example this is the result of this code:

export const MENU_MESSAGE: string = "Admiral Billy cool mode active!";
export const MENU_MESSAGE_TEXT_COLOR: string = "#FFD700";
export const MENU_MESSAGE_BACKGROUND_COLOR: string = "#FF69B4";

image

Feel free to move the variables wherever seems most appropriate; currently they're just at the top of overrides.

@bennybroseph bennybroseph added the enhancement New feature or request label May 19, 2024
Copy link
Collaborator

@brain-frog brain-frog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a great idea, very simple way to display events
one small suggestion

src/overrides.ts Outdated Show resolved Hide resolved
src/overrides.ts Outdated
@@ -12,6 +12,13 @@ import { Stat } from './data/pokemon-stat';
import { PokeballCounts } from './battle-scene';
import { PokeballType } from './data/pokeball';

export const MENU_MESSAGE: { active: boolean, text: string, textColor: string, backgroundColor: string } = {
active: true,
text: "Shiny event active!",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts on localization ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how the localization is handled normally; presumably the text here can be handled the same way as other localization strings if needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code wise it's pretty straightforward, an example from the current code can be seen here:

export function getPokeballName(type: PokeballType): string {

import i18next from '../plugins/i18n'; gives access to the localization library
i18next.t('pokeball:greatBall'); means get the translation with the name "greatBall" from the file "pokeball"

Personally I think all texts should be localizable, buuut maybe this one doesn't make sense to do since it's a sort of "admin" message that would require admins to be able to translate into 10+ languages ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to be able to translate it, we'd have to run it by a native speaker or hope for the best with google translate or something
I think for an initial implementation english should be okay until we figure out a process for all translations

@Admiral-Billy
Copy link
Contributor Author

The PR still said the changes were needed so I went ahead and re-requested the review.

I can also change the current settings if needed, but they do at least accurately describe what's currently going on even if it isn't pretty.

@@ -41,6 +42,16 @@ export default class TitleUiHandler extends OptionSelectUiHandler {
this.playerCountLabel = addTextObject(this.scene, (this.scene.game.canvas.width / 6) - 2, (this.scene.game.canvas.height / 6) - 90, `? ${i18next.t("menu:playersOnline")}`, TextStyle.MESSAGE, { fontSize: '54px' });
this.playerCountLabel.setOrigin(1, 0);
this.titleContainer.add(this.playerCountLabel);

if (Overrides.MENU_MESSAGE.active) {
this.menuMessage = addTextObject(this.scene, (this.scene.game.canvas.width / 6) - 2, (this.scene.game.canvas.height / 6) - 100, Overrides.MENU_MESSAGE.text, TextStyle.MESSAGE, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to add menuMessage as a property of titleuihandler

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you'd rather have it there instead of in the overrides? I can make that work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants