-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
2bc7fb2
to
13922aa
Compare
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!", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any thoughts on localization ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
pokerogue/src/data/pokeball.ts
Line 30 in 3671fe4
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 ?
There was a problem hiding this comment.
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
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. |
src/ui/title-ui-handler.ts
Outdated
@@ -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, { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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:
Feel free to move the variables wherever seems most appropriate; currently they're just at the top of overrides.