Add menu entry "Gen 3 Transfer Info" which leads to a screen referencing Poke Transporter GB (#5)

This commit is contained in:
Philippe Symons 2024-08-27 20:21:57 +02:00 committed by GitHub
parent 8e556391f3
commit b87b1ac093
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 189 additions and 4 deletions

BIN
assets/fennel-picture.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

View File

@ -17,6 +17,7 @@ void activateFrameLog(void* context, const void* param);
void advanceDialog(void* context, const void* param);
void goToTestScene(void* context, const void* param);
void goToPokeTransporterGBRef(void* context, const void* param);
void goToAboutScene(void* context, const void* param);
void goToGen1DistributionPokemonMenu(void* context, const void* param);

View File

@ -31,6 +31,7 @@ private:
sprite_t* logoPKHEX_;
sprite_t* logoGBDevIO_;
sprite_t* logoNESDevWiki_;
sprite_t* logoPokeTransporterGB_;
ScrollWidget scrollWidget_;
TextWidget headerText_;
ImageWidget imgDragonWidget_;
@ -44,6 +45,7 @@ private:
ImageWidget imgGBDevIO_;
TextWidget gbDevIOText_;
ImageWidget imgNESDevWiki_;
ImageWidget imgPokeTransporterGB_;
TextWidget otherCreditsText_;
WidgetFocusChainSegment scrollFocusSegment_;
bool bButtonPressed_;

View File

@ -19,6 +19,7 @@ enum class SceneType
DISTRIBUTION_POKEMON_LIST,
STATS,
TEST,
POKETRANSPORTER_GB_REF,
ABOUT
};

View File

@ -0,0 +1,29 @@
#ifndef _POKETRANSPORTERGBREFSCENE_H
#define _POKETRANSPORTERGBREFSCENE_H
#include "scenes/SceneWithDialogWidget.h"
class PokeTransporterGBRefScene : public SceneWithDialogWidget
{
public:
PokeTransporterGBRefScene(SceneDependencies& deps, void* context);
virtual ~PokeTransporterGBRefScene();
void init() override;
void destroy() override;
void render(RDPQGraphics& gfx, const Rectangle& sceneBounds) override;
void onDialogDone();
protected:
void setupDialog(DialogWidgetStyle& style) override;
private:
sprite_t* menu9SliceSprite_;
sprite_t* pokeTransporterGBLogoSprite_;
sprite_t* qrCodeSprite_;
sprite_t* fennelPictureSprite_;
uint8_t fontArialSmallId_;
uint8_t fontArialSmallWhiteId_;
};
#endif

View File

@ -16,6 +16,10 @@ MenuItemData gen1MenuEntries[] = {
.onConfirmAction = gen1PrepareToTeachPikachu,
.itemParam = &MOVE_FLY
},
{
.title = "Gen 3 Transfer Info",
.onConfirmAction = goToPokeTransporterGBRef
},
{
.title = "About",
.onConfirmAction = goToAboutScene
@ -37,6 +41,10 @@ MenuItemData gen2MenuEntries[] = {
.title = "Unlock Decoration",
.onConfirmAction = goToGen2DecorationMenu
},
{
.title = "Gen 3 Transfer Info",
.onConfirmAction = goToPokeTransporterGBRef
},
{
.title = "About",
.onConfirmAction = goToAboutScene
@ -62,6 +70,10 @@ MenuItemData gen2CrystalMenuEntries[] = {
.title = "Unlock Decoration",
.onConfirmAction = goToGen2DecorationMenu
},
{
.title = "Gen 3 Transfer Info",
.onConfirmAction = goToPokeTransporterGBRef
},
{
.title = "About",
.onConfirmAction = goToAboutScene

View File

@ -116,6 +116,14 @@ void goToTestScene(void* context, const void* param)
sceneManager.switchScene(SceneType::TEST);
}
void goToPokeTransporterGBRef(void* context, const void* param)
{
MenuScene* scene = static_cast<MenuScene*>(context);
SceneManager& sceneManager = scene->getDependencies().sceneManager;
sceneManager.switchScene(SceneType::POKETRANSPORTER_GB_REF);
}
void goToAboutScene(void* context, const void* param)
{
MenuScene* scene = static_cast<MenuScene*>(context);

View File

@ -21,7 +21,8 @@ static const Rectangle pretPokeCrystalTextBounds = {153, 248, 175, 16};
static const Rectangle imgGBDevIoBounds = {28, 280, 34, 55};
static const Rectangle gbDevIOTextBounds = {68, 300, 75, 16};
static const Rectangle imgNESDevWikiBounds = {163, 280, 96, 60};
static const Rectangle otherCreditsTextBounds = {5, 350, 310, 80};
static const Rectangle imgPokeTransporterGBBounds = {96, 350, 128, 39};
static const Rectangle otherCreditsTextBounds = {5, 400, 310, 80};
static const char* otherCreditsString = R"delim(github.com/magical/pokemon-sprites-rby
glitchcity.wiki
@ -34,7 +35,7 @@ static const char* headerTextString = R"delim(PokeMe64 Version 0.1
by risingPhil
SPECIAL THANKS TO:
(For docs, tools and/or inspiration)
(For docs, tools, assets and/or inspiration)
)delim";
AboutScene::AboutScene(SceneDependencies& deps, void*)
@ -48,6 +49,7 @@ AboutScene::AboutScene(SceneDependencies& deps, void*)
, logoPKHEX_(nullptr)
, logoGBDevIO_(nullptr)
, logoNESDevWiki_(nullptr)
, logoPokeTransporterGB_(nullptr)
, scrollWidget_(deps.animationManager)
, headerText_()
, imgDragonWidget_()
@ -61,6 +63,7 @@ AboutScene::AboutScene(SceneDependencies& deps, void*)
, imgGBDevIO_()
, gbDevIOText_()
, imgNESDevWiki_()
, imgPokeTransporterGB_()
, otherCreditsText_()
, scrollFocusSegment_(WidgetFocusChainSegment{
.current = &scrollWidget_
@ -90,6 +93,7 @@ void AboutScene::init()
logoPKHEX_ = sprite_load("rom://logo-pkhex.sprite");
logoGBDevIO_ = sprite_load("rom://logo-gbdevio.sprite");
logoNESDevWiki_ = sprite_load("rom://logo-nesdevwiki.sprite");
logoPokeTransporterGB_ = sprite_load("rom://logo-poketransporter-gb.sprite");
scrollWidget_.setBounds(scrollWidgetBounds);
scrollWidget_.setStyle(scrollWidgetStyle);
@ -220,6 +224,17 @@ void AboutScene::init()
imgNESDevWiki_.setStyle(imgNESDevWikiStyle);
scrollWidget_.addWidget(&imgNESDevWiki_);
const ImageWidgetStyle imgPokeTransporterGBStyle = {
.image = {
.sprite = logoPokeTransporterGB_,
.spriteBounds = Rectangle{0, 0, imgPokeTransporterGBBounds.width, imgPokeTransporterGBBounds.height}
}
};
imgPokeTransporterGB_.setBounds(imgPokeTransporterGBBounds);
imgPokeTransporterGB_.setStyle(imgPokeTransporterGBStyle);
scrollWidget_.addWidget(&imgPokeTransporterGB_);
otherCreditsText_.setBounds(otherCreditsTextBounds);
otherCreditsText_.setStyle(commonCenterAlignedTextStyle);
otherCreditsText_.setData(otherCreditsString);
@ -244,6 +259,8 @@ void AboutScene::destroy()
logoGBDevIO_ = nullptr;
sprite_free(logoNESDevWiki_);
logoNESDevWiki_ = nullptr;
sprite_free(logoPokeTransporterGB_);
logoPokeTransporterGB_ = nullptr;
}
bool AboutScene::handleUserInput(joypad_port_t port, const joypad_inputs_t& inputs)

View File

@ -7,7 +7,7 @@
#include <cstdio>
#include <cmath>
static const Rectangle menuListBounds = {100, 30, 150, 0};
static const Rectangle menuListBounds = {100, 30, 160, 0};
static const Rectangle imgScrollArrowUpBounds = {.x = 170, .y = 24, .width = 11, .height = 6};
static const Rectangle imgScrollArrowDownBounds = {.x = 170, .y = 180, .width = 11, .height = 6};
@ -205,7 +205,7 @@ void MenuScene::setupMenu()
menuList_.registerScrollWindowListener(this);
const MenuItemStyle itemStyle = {
.size = {150, 16},
.size = {160, 16},
.titleNotFocused = {
.fontId = arialId_,
.fontStyleId = fontStyleWhiteId_

View File

@ -0,0 +1,111 @@
#include "scenes/PokeTransporterGBRefScene.h"
#include "scenes/SceneManager.h"
#include "core/RDPQGraphics.h"
#include "core/FontManager.h"
static const Rectangle logoRectangle = {96, 10, 128, 39};
static const Rectangle fennelPictureRectangle = {20, 60, 62, 110};
static const Rectangle qrCodeRectangle = {160, 65, 66, 66};
static const Rectangle urlRectangle = {100, 140, 210, 32};
static void dialogFinishedCallback(void* context)
{
PokeTransporterGBRefScene* scene = (PokeTransporterGBRefScene*)context;
scene->onDialogDone();
}
PokeTransporterGBRefScene::PokeTransporterGBRefScene(SceneDependencies& deps, void* context)
: SceneWithDialogWidget(deps)
, menu9SliceSprite_(nullptr)
, pokeTransporterGBLogoSprite_(nullptr)
, qrCodeSprite_(nullptr)
, fennelPictureSprite_(nullptr)
, fontArialSmallId_(0)
, fontArialSmallWhiteId_(0)
{
}
PokeTransporterGBRefScene::~PokeTransporterGBRefScene()
{
}
void PokeTransporterGBRefScene::init()
{
menu9SliceSprite_ = sprite_load("rom://menu-bg-9slice.sprite");
pokeTransporterGBLogoSprite_ = sprite_load("rom://logo-poketransporter-gb.sprite");
qrCodeSprite_ = sprite_load("rom://qrcode-poketransporter-gb.sprite");
fennelPictureSprite_ = sprite_load("rom://fennel-picture.sprite");
fontArialSmallId_ = deps_.fontManager.getFont("rom://Arial-small.font64");
const rdpq_fontstyle_t arialWhite = {
.color = RGBA32(0xFF, 0xFF, 0xFF, 0xFF),
.outline_color = RGBA32(0, 0, 0, 0xFF)
};
deps_.fontManager.registerFontStyle(fontArialSmallId_, fontArialSmallWhiteId_, arialWhite);
SceneWithDialogWidget::init();
auto diag2 = new DialogData{
.shouldDeleteWhenDone = true
};
auto diag1 = new DialogData {
.next = diag2,
.shouldDeleteWhenDone = true
};
setDialogDataText(*diag1, "So you want to transfer your pokémon to\nGen 3? You should go see professor Fennel!");
setDialogDataText(*diag2, "You can find the address above or you can scan the QR code with your phone!");
showDialog(diag1);
}
void PokeTransporterGBRefScene::destroy()
{
sprite_free(fennelPictureSprite_);
fennelPictureSprite_ = nullptr;
sprite_free(qrCodeSprite_);
qrCodeSprite_ = nullptr;
sprite_free(pokeTransporterGBLogoSprite_);
pokeTransporterGBLogoSprite_ = nullptr;
sprite_free(menu9SliceSprite_);
menu9SliceSprite_ = nullptr;
}
void PokeTransporterGBRefScene::render(RDPQGraphics& gfx, const Rectangle& sceneBounds)
{
SpriteRenderSettings renderSettings = {
.renderMode = SpriteRenderMode::NORMAL
};
TextRenderSettings textSettings = {
.fontId = fontArialSmallId_,
.fontStyleId = fontArialSmallWhiteId_
};
gfx.drawSprite(logoRectangle, pokeTransporterGBLogoSprite_, renderSettings);
gfx.drawSprite(fennelPictureRectangle, fennelPictureSprite_, renderSettings);
gfx.drawSprite(qrCodeRectangle, qrCodeSprite_, renderSettings);
gfx.drawText(urlRectangle, "https://github.com/GearsProgress\n/Poke_Transporter_GB", textSettings);
SceneWithDialogWidget::render(gfx, sceneBounds);
}
void PokeTransporterGBRefScene::onDialogDone()
{
deps_.sceneManager.goBackToPreviousScene();
}
void PokeTransporterGBRefScene::setupDialog(DialogWidgetStyle& style)
{
style.background.sprite = menu9SliceSprite_;
style.background.spriteSettings = {
.renderMode = SpriteRenderMode::NINESLICE,
.srcRect = { 6, 6, 6, 6 }
};
SceneWithDialogWidget::setupDialog(style);
dialogWidget_.setOnDialogFinishedCallback(dialogFinishedCallback, this);
}

View File

@ -1,6 +1,7 @@
#include "scenes/SceneManager.h"
#include "scenes/TestScene.h"
#include "scenes/StatsScene.h"
#include "scenes/PokeTransporterGBRefScene.h"
#include "scenes/AboutScene.h"
#include "scenes/InitTransferPakScene.h"
#include "scenes/DistributionPokemonListScene.h"
@ -136,6 +137,9 @@ void SceneManager::loadScene()
case SceneType::TEST:
scene_ = new TestScene(sceneDeps_, newSceneContext_);
break;
case SceneType::POKETRANSPORTER_GB_REF:
scene_ = new PokeTransporterGBRefScene(sceneDeps_, newSceneContext_);
break;
case SceneType::ABOUT:
scene_ = new AboutScene(sceneDeps_, newSceneContext_);
break;