Added up and down button navigation to switch between the media viewer and the PDF viewer

This commit is contained in:
Leon Styhre 2023-06-25 13:30:49 +02:00
parent 1888ec55f5
commit a964d89b80
5 changed files with 20 additions and 4 deletions

View file

@ -14,6 +14,7 @@
MediaViewer::MediaViewer()
: mRenderer {Renderer::getInstance()}
, mGame {nullptr}
{
Window::getInstance()->setMediaViewer(this);
}

View file

@ -24,6 +24,7 @@
PDFViewer::PDFViewer()
: mRenderer {Renderer::getInstance()}
, mGame {nullptr}
{
Window::getInstance()->setPDFViewer(this);
mTexture = TextureResource::get("");
@ -50,10 +51,11 @@ bool PDFViewer::startPDFViewer(FileData* game)
return false;
}
mManualPath = game->getManualPath();
mGame = game;
mManualPath = mGame->getManualPath();
if (!Utils::FileSystem::exists(mManualPath)) {
LOG(LogError) << "No PDF manual found for game \"" << game->getName() << "\"";
LOG(LogError) << "No PDF manual found for game \"" << mGame->getName() << "\"";
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
ViewController::getInstance()->stopViewVideos();
return false;
@ -136,6 +138,12 @@ void PDFViewer::stopPDFViewer()
mPageImage.reset();
}
void PDFViewer::launchMediaViewer()
{
Window::getInstance()->stopPDFViewer();
Window::getInstance()->startMediaViewer(mGame);
}
bool PDFViewer::getDocumentInfo()
{
std::string commandOutput;

View file

@ -20,6 +20,7 @@ public:
bool startPDFViewer(FileData* game) override;
void stopPDFViewer() override;
void launchMediaViewer() override;
bool getDocumentInfo();
void convertPage(int pageNum);
@ -43,6 +44,7 @@ private:
std::shared_ptr<TextureResource> mTexture;
std::unique_ptr<ImageComponent> mPageImage;
std::map<int, PageEntry> mPages;
FileData* mGame;
std::string mESConvertPath;
std::string mManualPath;

View file

@ -221,7 +221,7 @@ void Window::input(InputConfig* config, Input input)
}
if (mMediaViewer && mRenderMediaViewer) {
if (config->isMappedLike("y", input) && input.value != 0) {
if (config->isMappedLike("up", input) && input.value != 0) {
mMediaViewer->launchPDFViewer();
return;
}
@ -236,7 +236,11 @@ void Window::input(InputConfig* config, Input input)
}
if (mPDFViewer && mRenderPDFViewer) {
if (config->isMappedLike("right", input) && input.value != 0)
if (config->isMappedLike("down", input) && input.value != 0) {
mPDFViewer->launchMediaViewer();
return;
}
else if (config->isMappedLike("right", input) && input.value != 0)
mPDFViewer->showNextPage();
else if (config->isMappedLike("left", input) && input.value != 0)
mPDFViewer->showPreviousPage();

View file

@ -70,6 +70,7 @@ public:
public:
virtual bool startPDFViewer(FileData* game) = 0;
virtual void stopPDFViewer() = 0;
virtual void launchMediaViewer() = 0;
virtual void showNextPage() = 0;
virtual void showPreviousPage() = 0;