mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-09-12 12:35:26 -05:00
Commit since everything seems like it's working.
This commit is contained in:
@@ -14,47 +14,41 @@
|
||||
#include "strings.hpp"
|
||||
|
||||
MainMenuState::MainMenuState(void)
|
||||
: m_renderTarget(sdl::TextureManager::create_load_texture("MainMenuTarget",
|
||||
: m_renderTarget(sdl::TextureManager::create_load_texture("mainMenuTarget",
|
||||
200,
|
||||
555,
|
||||
SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET)),
|
||||
m_background(
|
||||
sdl::TextureManager::create_load_texture("MainMenuBackground", "romfs:/Textures/MenuBackground.png")),
|
||||
m_background(sdl::TextureManager::create_load_texture("mainBackground", "romfs:/Textures/MenuBackground.png")),
|
||||
m_settingsIcon(sdl::TextureManager::create_load_texture("settingsIcon", "romfs:/Textures/SettingsIcon.png")),
|
||||
m_extrasIcon(sdl::TextureManager::create_load_texture("extrasIcon", "romfs:/Textures/ExtrasIcon.png")),
|
||||
m_mainMenu(50, 15, 555), m_controlGuide(strings::get_by_name(strings::names::CONTROL_GUIDES, 0)),
|
||||
m_controlGuideX(1220 - sdl::text::get_width(22, m_controlGuide))
|
||||
{
|
||||
// Fetch user list.
|
||||
if (!sm_settingsState || !sm_extrasState)
|
||||
{
|
||||
sm_settingsState = std::make_shared<SettingsState>();
|
||||
sm_extrasState = std::make_shared<ExtrasMenuState>();
|
||||
}
|
||||
|
||||
// Grab the users and setup the main menu. Users shouldn't change.
|
||||
data::get_users(sm_users);
|
||||
|
||||
// Loop through add user's icon to menu and create states.
|
||||
for (size_t i = 0; i < sm_users.size(); i++)
|
||||
for (data::User *user : sm_users)
|
||||
{
|
||||
m_mainMenu.add_option(sm_users.at(i)->get_shared_icon());
|
||||
|
||||
if (config::get_by_key(config::keys::JKSM_TEXT_MODE))
|
||||
{
|
||||
sm_states.push_back(std::make_shared<TextTitleSelectState>(sm_users.at(i)));
|
||||
}
|
||||
else
|
||||
{
|
||||
sm_states.push_back(std::make_shared<TitleSelectState>(sm_users.at(i)));
|
||||
}
|
||||
m_mainMenu.add_option(user->get_shared_icon());
|
||||
}
|
||||
// Add the settings and extras.
|
||||
sm_states.push_back(std::make_shared<SettingsState>());
|
||||
sm_states.push_back(std::make_shared<ExtrasMenuState>());
|
||||
|
||||
// Create icons for the other two.
|
||||
m_settingsIcon = sdl::TextureManager::create_load_texture("SettingsIcon", "romfs:/Textures/SettingsIcon.png");
|
||||
m_extrasIcon = sdl::TextureManager::create_load_texture("ExtrasIcon", "romfs:/Textures/ExtrasIcon.png");
|
||||
|
||||
// Finally add them to the end.
|
||||
// Add the last two.
|
||||
m_mainMenu.add_option(m_settingsIcon);
|
||||
m_mainMenu.add_option(m_extrasIcon);
|
||||
|
||||
// Just call this.
|
||||
MainMenuState::initialize_view_states();
|
||||
}
|
||||
|
||||
void MainMenuState::update(void)
|
||||
{
|
||||
// Update the main menu.
|
||||
m_mainMenu.update(AppState::has_focus());
|
||||
|
||||
int selected = m_mainMenu.get_selected();
|
||||
@@ -97,11 +91,37 @@ void MainMenuState::render(void)
|
||||
}
|
||||
}
|
||||
|
||||
void MainMenuState::initialize_view_states(void)
|
||||
{
|
||||
// Constructor should have taken care of the menu and user list.
|
||||
// Start by clearing the vector.
|
||||
sm_states.clear();
|
||||
|
||||
// Grab this from config instead of calling it every loop.
|
||||
bool textMode = config::get_by_key(config::keys::JKSM_TEXT_MODE);
|
||||
|
||||
// Loop through users.
|
||||
for (data::User *user : sm_users)
|
||||
{
|
||||
if (textMode)
|
||||
{
|
||||
sm_states.push_back(std::make_shared<TextTitleSelectState>(user));
|
||||
}
|
||||
else
|
||||
{
|
||||
sm_states.push_back(std::make_shared<TitleSelectState>(user));
|
||||
}
|
||||
}
|
||||
sm_states.push_back(sm_settingsState);
|
||||
sm_states.push_back(sm_extrasState);
|
||||
}
|
||||
|
||||
void MainMenuState::refresh_view_states(void)
|
||||
{
|
||||
for (size_t i = 0; i < sm_users.size(); i++)
|
||||
// For this, we're only looping through the user states to be extra careful because the last two don't have the refresh() function.
|
||||
int userCount = sm_users.size();
|
||||
for (int i = 0; i < userCount; i++)
|
||||
{
|
||||
sm_users.at(i)->sort_data();
|
||||
std::static_pointer_cast<TitleSelectCommon>(sm_states.at(i))->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user