Skip to content

Commit

Permalink
Add displaying heart on favorite worlds
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmMoltony committed Jan 4, 2024
1 parent 4c9c948 commit a5c8890
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ class Game
*/
WorldManager::WorldList worldSelectWorlds;

/**
* @brief List of favorite worlds
*/
std::vector<std::string> favWorlds;

/**
* @brief Show "Saved!" text or not
*/
Expand Down
12 changes: 11 additions & 1 deletion source/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Game *Game::instance;

Game::Game() : blocks(), entities(), blockParticles(), player(), gameState(State::TitleScreen), camera({0, 0}),
frameCounter(0), saveTextTimer(0), worldSelectSelected(0), langSelectSelected(0),
deleteWorldSelected(0), renameWorldSelected(0), worldSelectWorlds(), showSaveText(false),
deleteWorldSelected(0), renameWorldSelected(0), worldSelectWorlds(), favWorlds(), showSaveText(false),
paused(false), showStats(false), worldName(), createWorldName(), createWorldSeed(), renameWorldName(),
createWorldError(false), renameWorldDuplError(false), settingsSelect(0), settingsPage(1), titleScreenSelect(0),
createWorldShowCursor(false), createWorldSelect(0), worldSettingsSelect(0), currentLocation(0),
Expand Down Expand Up @@ -515,6 +515,7 @@ void Game::enterWorldSelect(void)
glEnd2D();
glFlush(0);
worldSelectWorlds = WorldManager::getWorlds();
favWorlds = WorldManager::getFavoriteWorlds();
}

void Game::loadLocation(s16 oldLocation)
Expand Down Expand Up @@ -866,6 +867,15 @@ void Game::draw(void)
}
glColor(RGB15(31, 31, 31));

if (std::find(favWorlds.begin(), favWorlds.end(), worldInfoName) != favWorlds.end()) {
glPolyFmt(POLY_ALPHA(15) | POLY_CULL_NONE);
glColor(RGB15(0, 0, 0));
glSprite(SCREEN_WIDTH - 22, 48 + i * 40 + 18 - offset + 2, GL_FLIP_NONE, sprHeart);
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
glColor(RGB15(31, 31, 31));
glSprite(SCREEN_WIDTH - 24, 48 + i * 40 + 18 - offset, GL_FLIP_NONE, sprHeart);
}

free(hrfsz);
}
}
Expand Down

0 comments on commit a5c8890

Please sign in to comment.