mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Improved PDF viewer integration
Also fixed a crash on shutdown caused by the PDF viewer
This commit is contained in:
parent
6bf8c5af46
commit
f9780e58d8
|
@ -12,6 +12,7 @@
|
|||
#include "Sound.h"
|
||||
#include "utils/FileSystemUtil.h"
|
||||
#include "utils/StringUtil.h"
|
||||
#include "views/ViewController.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
|
@ -30,6 +31,8 @@ PDFViewer::PDFViewer()
|
|||
|
||||
bool PDFViewer::startPDFViewer(FileData* game)
|
||||
{
|
||||
ViewController::getInstance()->pauseViewVideos();
|
||||
|
||||
#if defined(_WIN64)
|
||||
const std::string convertBinary {"/es-pdf-converter/es-pdf-convert.exe"};
|
||||
#else
|
||||
|
@ -42,6 +45,8 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
|||
#else
|
||||
LOG(LogError) << "Couldn't find PDF conversion binary es-pdf-convert";
|
||||
#endif
|
||||
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
|
||||
ViewController::getInstance()->stopViewVideos();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -49,6 +54,8 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
|||
|
||||
if (!Utils::FileSystem::exists(mManualPath)) {
|
||||
LOG(LogError) << "No PDF manual found for game \"" << game->getName() << "\"";
|
||||
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
|
||||
ViewController::getInstance()->stopViewVideos();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -66,6 +73,8 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
|||
|
||||
if (!getDocumentInfo()) {
|
||||
LOG(LogError) << "PDFViewer: Couldn't load file \"" << mManualPath;
|
||||
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
|
||||
ViewController::getInstance()->stopViewVideos();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -74,6 +83,8 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
|||
for (int i {1}; i <= mPageCount; ++i) {
|
||||
if (mPages.find(i) == mPages.end()) {
|
||||
LOG(LogError) << "Couldn't read information for page " << i << ", invalid PDF file?";
|
||||
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
|
||||
ViewController::getInstance()->stopViewVideos();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -119,6 +130,8 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
|||
void PDFViewer::stopPDFViewer()
|
||||
{
|
||||
NavigationSounds::getInstance().playThemeNavigationSound(SCROLLSOUND);
|
||||
ViewController::getInstance()->stopViewVideos();
|
||||
|
||||
mPages.clear();
|
||||
mPageImage.reset();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ class PDFViewer : public Window::PDFViewer
|
|||
{
|
||||
public:
|
||||
PDFViewer();
|
||||
~PDFViewer() { stopPDFViewer(); }
|
||||
|
||||
bool startPDFViewer(FileData* game) override;
|
||||
void stopPDFViewer() override;
|
||||
|
|
|
@ -477,7 +477,7 @@ void Window::render()
|
|||
auto& bottom = mGuiStack.front();
|
||||
auto& top = mGuiStack.back();
|
||||
|
||||
if (mRenderMediaViewer || mRenderScreensaver) {
|
||||
if (mRenderMediaViewer || mRenderPDFViewer || mRenderScreensaver) {
|
||||
bottom->cancelAllAnimations();
|
||||
bottom->stopAllAnimations();
|
||||
}
|
||||
|
@ -485,8 +485,8 @@ void Window::render()
|
|||
// Don't render the system view or gamelist view if the media viewer is active or if the
|
||||
// video or slideshow screensaver is running. The exception is if the fallback screensaver
|
||||
// is active due to a lack of videos or images.
|
||||
bool renderBottom = true;
|
||||
if (mRenderMediaViewer)
|
||||
bool renderBottom {true};
|
||||
if (mRenderMediaViewer || mRenderPDFViewer)
|
||||
renderBottom = false;
|
||||
else if (mRenderScreensaver && mScreensaver->isFallbackScreensaver())
|
||||
renderBottom = true;
|
||||
|
@ -653,9 +653,9 @@ void Window::render()
|
|||
unsigned int screensaverTimer {
|
||||
static_cast<unsigned int>(Settings::getInstance()->getInt("ScreensaverTimer"))};
|
||||
if (mTimeSinceLastInput >= screensaverTimer && screensaverTimer != 0) {
|
||||
// If the media viewer is running or if a menu is open, reset the screensaver timer so
|
||||
// that the screensaver won't start.
|
||||
if (mRenderMediaViewer || mGuiStack.front() != mGuiStack.back())
|
||||
// If the media viewer or PDF viewer is running, or if a menu is open, then reset the
|
||||
// screensaver timer so that the screensaver won't start.
|
||||
if (mRenderMediaViewer || mRenderPDFViewer || mGuiStack.front() != mGuiStack.back())
|
||||
mTimeSinceLastInput = 0;
|
||||
// If a game has been launched, reset the screensaver timer as we don't want to start
|
||||
// the screensaver in the background when running a game.
|
||||
|
|
Loading…
Reference in a new issue