Files
sphaira/sphaira/source/ui/menus/file_viewer.cpp
Yorunokyujitsu c8ae2a7872 Almost all strings for translation. (#32)
* Almost all strings for translation

* Remove nonexistent strings.

---------

Co-authored-by: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com>
2024-12-21 16:49:48 +00:00

48 lines
1.1 KiB
C++

#include "ui/menus/file_viewer.hpp"
#include "i18n.hpp"
namespace sphaira::ui::menu::fileview {
namespace {
} // namespace
Menu::Menu(const fs::FsPath& path) : MenuBase{path}, m_path{path} {
SetAction(Button::B, Action{"Back"_i18n, [this](){
SetPop();
}});
std::string buf;
if (R_SUCCEEDED(m_fs.OpenFile(m_path, FsOpenMode_Read, &m_file))) {
fsFileGetSize(&m_file, &m_file_size);
buf.resize(m_file_size + 1);
u64 read_bytes;
fsFileRead(&m_file, m_file_offset, buf.data(), buf.size(), 0, &read_bytes);
buf[m_file_size] = '\0';
}
m_scroll_text = std::make_unique<ScrollableText>(buf, 0, 120, 500, 1150-110, 18);
}
Menu::~Menu() {
fsFileClose(&m_file);
}
void Menu::Update(Controller* controller, TouchInfo* touch) {
MenuBase::Update(controller, touch);
m_scroll_text->Update(controller, touch);
}
void Menu::Draw(NVGcontext* vg, Theme* theme) {
MenuBase::Draw(vg, theme);
m_scroll_text->Draw(vg, theme);
}
void Menu::OnFocusGained() {
MenuBase::OnFocusGained();
}
} // namespace sphaira::ui::menu::fileview