mirror of
https://github.com/risingPhil/PokeMe64.git
synced 2026-03-21 18:04:15 -05:00
* Feature/add support for other game languages (#13) * Add support for other game localizations/languages * Increase PokeMe64 version to v0.3 * Update README.md * Slightly improve the text in docs/Why_I_Had_To_Give_Up_On_Batteryless_Repros.md * Update libpokemegb submodule to commit 3d86aa8 * Add Japanese characters to the fonts * Make validating Japanese save files work correctly Turns out these Japanese cartridges are using an MBC1 controller. There's a notable difference between it and MBC3: by default it is doing banking mode 0. But in this mode, you can't switch SRAM banks! So in order to make japanese cartridges work, we must switch to mode 1. * Update Arial font: add Japanese glyphs from Osaka Regular-Mono.ttf In order to render japanese characters, we need to have a font which has japanese characters and make sure they are added to the .font64 file with mkfont during compilation. I wrote a small program before to figure out which Japanese characters are actually used in the Japanese gameboy cartridges. I only added those unicode ranges to the fonts to keep them small. There was no easy way to have a font that has both latin and Japanese characters, especially not free. So I used FontForge to merge the japanese glyphs from Osaka Regular-Mono into Arial.ttf * Update libpokemegb to commit 0ef7a3a * Update libpokemegb submodule * Update libpokemegb submodule to commit d6f3423 * Various changes - Upgrade libpokemegb to commit c47f8b3 - [Korean gen II games]: Make the UI show Trainer and Pokémon instead of the actual trainer name and pokémon name. This is needed because our font does not include the necessary characters for the Korean games. And while I could attempt to add them, I don't sufficiently care to do so. - Attempt to randomize random values. This is needed for random IVs and shininess chances. It's not entirely clear to me whether the rand() function would actually return random values in previous versions of PokeMe64. While libdragon does gather entropy at bootup and implements a getentropy() function, I don't see this function referenced anywhere. That being said, it DOES look like libstdc++ would call a getentropy() function, so perhaps this is a way in which getentropy() from libdragon would get called. But I'm not using libstdc++'s functionality to obtain random values, I'm using libc's rand() function. And I don't see any reference from libc (for rand()) to getentropy(), so... At the very least we might need to use values from getentropy() to seed with srand(). But because I have trust issues with randomizing pseudo-random values in a system that doesn't have a system clock, I also added trainerID, trainerName and the number of elapsed cpu cycles until we are going to the main menu to the seed. I might consider adding the RTC values for gen II games to the seed as well later. * Update README.md * More README.md * Update libpokemegb to commit 17232c4 * Feature/automatically reset rtc in backed up save file for gen2 (#14) * Add support for other game localizations/languages * Increase PokeMe64 version to v0.3 * Update README.md * Slightly improve the text in docs/Why_I_Had_To_Give_Up_On_Batteryless_Repros.md * Update libpokemegb submodule to commit 3d86aa8 * Set the flag to reconfigure RTC in the backed up save file when backing up the save of a cartridge. * Update libpokemegb submodule to commit 5037690 * Update libpokemegb submodule to commit 8ff128c * Add support for Pokémon Green (JPN) * Update libpokemegb submodule to commit 1897845 * Update README.md -> japanese pokemon fallback OT name change -> PokeMe64 -> PM64 * Add gen I move delete feature. (Idea by /u/ImranFZakhaev on Reddit) * Add check to make sure the player is in a pokémon center before allowing him/her to delete a pokémon move. The reason behind this check is to avoid getting the player stuck on a map after deleting an HM. * Forgot to add the actual check in the last commit * Feature/implement gen1 move deleter (#15) * Add gen I move delete feature. (Idea by /u/ImranFZakhaev on Reddit) * Add check to make sure the player is in a pokémon center before allowing him/her to delete a pokémon move. The reason behind this check is to avoid getting the player stuck on a map after deleting an HM. * Update screenshots * Update CREDITS and add some people as Testing/Validation credits in the AboutScene These people have been a great help in getting PokeMe64 to work correctly. Thank you, everyone! * Fix whitespace issues * Update libpokemegb to commit aedb588
161 lines
4.5 KiB
C++
161 lines
4.5 KiB
C++
#ifndef _POKEMONPARTYICONWIDGET_H
|
|
#define _POKEMONPARTYICONWIDGET_H
|
|
|
|
#include "widget/IWidget.h"
|
|
#include "core/Sprite.h"
|
|
#include "gen1/Gen1Common.h"
|
|
#include "gen2/Gen2Common.h"
|
|
|
|
class IRomReader;
|
|
class ISaveManager;
|
|
|
|
/**
|
|
* This factory class provides a function to obtain a surface_t instance for a given icon.
|
|
* It acts as a form of cache to prevent decoding/allocating the same icon more than once if multiple
|
|
* instances of PokemonPartyIconWidget are created.
|
|
*/
|
|
class PokemonPartyIconFactory
|
|
{
|
|
public:
|
|
typedef struct IconMapEntry
|
|
{
|
|
surface_t frame1;
|
|
surface_t frame2;
|
|
} IconMapEntry;
|
|
|
|
PokemonPartyIconFactory(IRomReader& romReader);
|
|
~PokemonPartyIconFactory();
|
|
|
|
surface_t getIcon(uint8_t generation, uint8_t specificGenType, uint8_t localization, uint8_t iconType, bool firstFrame);
|
|
protected:
|
|
private:
|
|
// This is the map of icons. Gen2 has the most icons, that's why I'm using GEN2_ICONTYPE_MAX as the array size
|
|
IconMapEntry iconMap_[(unsigned)Gen2PokemonIconType::GEN2_ICONTYPE_MAX];
|
|
IRomReader& romReader_;
|
|
};
|
|
|
|
typedef struct PokemonPartyIconWidgetStyle
|
|
{
|
|
struct {
|
|
/**
|
|
* (optional) background sprite
|
|
*/
|
|
sprite_t* sprite;
|
|
/*
|
|
* RenderSettings that influence how the backgroundSprite is
|
|
* being rendered
|
|
*/
|
|
SpriteRenderSettings spriteSettings;
|
|
} background;
|
|
struct {
|
|
Rectangle bounds;
|
|
int8_t yOffsetWhenTheresNoFrame2;
|
|
} icon;
|
|
uint8_t fpsWhenFocused;
|
|
uint8_t fpsWhenNotFocused;
|
|
} PokemonPartyIconWidgetStyle;
|
|
|
|
typedef struct PokemonPartyIconWidgetData
|
|
{
|
|
PokemonPartyIconFactory* iconFactory;
|
|
/**
|
|
* The generation of the pokemon game (gen 1/2)
|
|
*/
|
|
uint8_t generation;
|
|
/**
|
|
* The specific variant of the game
|
|
*/
|
|
uint8_t specificGenVersion;
|
|
|
|
/**
|
|
* @brief The specific localization of the game
|
|
*/
|
|
uint8_t localization;
|
|
/**
|
|
* The pokemon icon type we need to display
|
|
*/
|
|
uint8_t iconType;
|
|
} PokemonPartyIconWidgetData;
|
|
|
|
class PokemonPartyIconWidget : public IWidget
|
|
{
|
|
public:
|
|
PokemonPartyIconWidget();
|
|
virtual ~PokemonPartyIconWidget();
|
|
|
|
void setStyle(const PokemonPartyIconWidgetStyle& style);
|
|
void setData(const PokemonPartyIconWidgetData& data);
|
|
|
|
/**
|
|
* @brief Returns whether the widget is currently focused
|
|
*/
|
|
bool isFocused() const override;
|
|
|
|
/**
|
|
* @brief Sets whether the widget is currently focused
|
|
*
|
|
*/
|
|
void setFocused(bool isFocused) override;
|
|
|
|
/**
|
|
* @brief Returns whether the widget is currently visible
|
|
*/
|
|
bool isVisible() const override;
|
|
|
|
/**
|
|
* @brief Changes the visibility of the widget
|
|
*/
|
|
void setVisible(bool visible) override;
|
|
|
|
/**
|
|
* @brief Returns the current (relative) bounds of the widget
|
|
*/
|
|
Rectangle getBounds() const override;
|
|
|
|
/**
|
|
* @brief Changes the current (relative) bounds of the widget
|
|
*/
|
|
void setBounds(const Rectangle& bounds) override;
|
|
|
|
/**
|
|
* @brief Returns the size (width/height) of the widget
|
|
*/
|
|
Dimensions getSize() const override;
|
|
|
|
/**
|
|
* @brief Handles user input
|
|
*
|
|
* For button presses, it is advised to track button release situations instead of
|
|
* button presses for executing an action. Otherwise the key press might be handled again immediately
|
|
* in the next scene/widget because the user wouldn't have had the time to actually release the key.
|
|
*/
|
|
bool handleUserInput(const joypad_inputs_t& userInput) override;
|
|
|
|
/**
|
|
* @brief Renders the widget
|
|
*
|
|
* @param gfx The graphics instance that must be used to render the widget
|
|
* @param parentBounds The bounds of the parent widget or scene. You must add the x,y offset of your own bounds
|
|
* to the parentBounds to get the absolute bounds for rendering.
|
|
*
|
|
* Getting the parentBounds as an argument of this function was done because a parent widget may be
|
|
* animated or change positions independent of the child widget. But when the parent widget moves, the child must as well!
|
|
*/
|
|
void render(RDPQGraphics& gfx, const Rectangle& parentBounds) override;
|
|
protected:
|
|
private:
|
|
void reset();
|
|
|
|
PokemonPartyIconWidgetStyle style_;
|
|
PokemonPartyIconWidgetData data_;
|
|
surface_t iconFrame1_;
|
|
surface_t iconFrame2_;
|
|
Rectangle bounds_;
|
|
uint32_t frameSwitchTimeoutInTicks_;
|
|
uint64_t nextFrameSwitchTime_;
|
|
bool focused_;
|
|
bool visible_;
|
|
bool showFirstIconFrame_;
|
|
};
|
|
|
|
#endif |