mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-09-12 20:45:11 -05:00
Initial commit. Needs debugging.
This commit is contained in:
@@ -7,58 +7,63 @@
|
||||
#include "config/config.hpp"
|
||||
#include "fs/save_mount.hpp"
|
||||
#include "fslib.hpp"
|
||||
#include "graphics/ScopedRender.hpp"
|
||||
#include "graphics/colors.hpp"
|
||||
#include "input.hpp"
|
||||
#include "graphics/targets.hpp"
|
||||
#include "logging/logger.hpp"
|
||||
#include "sdl.hpp"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace
|
||||
{
|
||||
// All of these states share this same target.
|
||||
constexpr std::string_view SECONDARY_TARGET = "SecondaryTarget";
|
||||
} // namespace
|
||||
|
||||
// ---- Construction ----
|
||||
|
||||
TextTitleSelectState::TextTitleSelectState(data::User *user)
|
||||
: TitleSelectCommon()
|
||||
, m_user(user)
|
||||
, m_titleSelectMenu(ui::Menu::create(32, 10, 1000, 23, 555))
|
||||
, m_renderTarget(sdl::TextureManager::load(SECONDARY_TARGET, 1080, 555, SDL_TEXTUREACCESS_TARGET))
|
||||
{
|
||||
TextTitleSelectState::refresh();
|
||||
}
|
||||
, m_renderTarget(sdl2::TextureManager::create_load_resource(graphics::targets::names::SECONDARY,
|
||||
graphics::targets::dims::SECONDARY_WIDTH,
|
||||
graphics::targets::dims::SECONDARY_HEIGHT,
|
||||
SDL_TEXTUREACCESS_TARGET))
|
||||
{ TextTitleSelectState::refresh(); }
|
||||
|
||||
// ---- Public functions ----
|
||||
|
||||
void TextTitleSelectState::update()
|
||||
void TextTitleSelectState::update(const sdl2::Input &input)
|
||||
{
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
const bool aPressed = input::button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input::button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input::button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input::button_pressed(HidNpadButton_Y);
|
||||
const bool aPressed = input.button_pressed(HidNpadButton_A);
|
||||
const bool bPressed = input.button_pressed(HidNpadButton_B);
|
||||
const bool xPressed = input.button_pressed(HidNpadButton_X);
|
||||
const bool yPressed = input.button_pressed(HidNpadButton_Y);
|
||||
|
||||
m_titleSelectMenu->update(hasFocus);
|
||||
m_titleSelectMenu->update(input, hasFocus);
|
||||
|
||||
if (aPressed) { TextTitleSelectState::create_backup_menu(); }
|
||||
else if (xPressed) { TextTitleSelectState::create_title_option_menu(); }
|
||||
else if (yPressed) { TextTitleSelectState::add_remove_favorite(); }
|
||||
else if (bPressed) { BaseState::deactivate(); }
|
||||
|
||||
sm_controlGuide->update(hasFocus);
|
||||
sm_controlGuide->update(input, hasFocus);
|
||||
}
|
||||
|
||||
void TextTitleSelectState::render()
|
||||
void TextTitleSelectState::render(sdl2::Renderer &renderer)
|
||||
{
|
||||
// Grab focus.
|
||||
const bool hasFocus = BaseState::has_focus();
|
||||
|
||||
m_renderTarget->clear(colors::TRANSPARENT);
|
||||
m_titleSelectMenu->render(m_renderTarget, hasFocus);
|
||||
sm_controlGuide->render(sdl::Texture::Null, hasFocus);
|
||||
m_renderTarget->render(sdl::Texture::Null, 201, 91);
|
||||
{
|
||||
// Switch targets, clear.
|
||||
graphics::ScopedRender scopedRender{renderer, m_renderTarget};
|
||||
renderer.frame_begin(colors::TRANSPARENT);
|
||||
|
||||
// Render menu to target.
|
||||
m_titleSelectMenu->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
// Switch back, render target and guide.
|
||||
m_renderTarget->render(201, 91);
|
||||
sm_controlGuide->render(renderer, hasFocus);
|
||||
}
|
||||
|
||||
void TextTitleSelectState::refresh()
|
||||
@@ -77,7 +82,10 @@ void TextTitleSelectState::refresh()
|
||||
|
||||
std::string option{};
|
||||
if (favorite) { option = std::string{STRING_HEART} + title; }
|
||||
else { option = title; }
|
||||
else
|
||||
{
|
||||
option = title;
|
||||
}
|
||||
|
||||
m_titleSelectMenu->add_option(option);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user