mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Removed the entry counter from the media viewer and added an option for whether to display the media types
This commit is contained in:
parent
cfdfe8c565
commit
1c7a18830e
|
@ -15,6 +15,7 @@
|
||||||
MediaViewer::MediaViewer()
|
MediaViewer::MediaViewer()
|
||||||
: mRenderer {Renderer::getInstance()}
|
: mRenderer {Renderer::getInstance()}
|
||||||
, mGame {nullptr}
|
, mGame {nullptr}
|
||||||
|
, mShowMediaTypes {false}
|
||||||
, mFrameHeight {0.0f}
|
, mFrameHeight {0.0f}
|
||||||
, mHelpInfoPosition {HelpInfoPosition::TOP}
|
, mHelpInfoPosition {HelpInfoPosition::TOP}
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,8 @@ bool MediaViewer::startMediaViewer(FileData* game)
|
||||||
mScreenshotIndex = -1;
|
mScreenshotIndex = -1;
|
||||||
mTitleScreenIndex = -1;
|
mTitleScreenIndex = -1;
|
||||||
|
|
||||||
|
mShowMediaTypes = Settings::getInstance()->getBool("MediaViewerShowTypes");
|
||||||
|
|
||||||
if (Settings::getInstance()->getString("MediaViewerHelpPrompts") == "disabled")
|
if (Settings::getInstance()->getString("MediaViewerHelpPrompts") == "disabled")
|
||||||
mHelpInfoPosition = HelpInfoPosition::DISABLED;
|
mHelpInfoPosition = HelpInfoPosition::DISABLED;
|
||||||
else if (Settings::getInstance()->getString("MediaViewerHelpPrompts") == "bottom")
|
else if (Settings::getInstance()->getString("MediaViewerHelpPrompts") == "bottom")
|
||||||
|
@ -57,18 +60,18 @@ bool MediaViewer::startMediaViewer(FileData* game)
|
||||||
|
|
||||||
mEntryCount = std::to_string(mImages.size() + (mVideo == nullptr ? 0 : 1));
|
mEntryCount = std::to_string(mImages.size() + (mVideo == nullptr ? 0 : 1));
|
||||||
|
|
||||||
mEntryNumText = std::make_unique<TextComponent>(
|
mMediaType =
|
||||||
"1/" + mEntryCount + (mHasVideo ? " VIDEO" : mImageFiles[0].second),
|
std::make_unique<TextComponent>((mHasVideo ? "VIDEO" : mImageFiles[0].second),
|
||||||
Font::get(FONT_SIZE_MINI, FONT_PATH_REGULAR), 0xAAAAAAFF);
|
Font::get(FONT_SIZE_MINI, FONT_PATH_REGULAR), 0xAAAAAAFF);
|
||||||
mEntryNumText->setOrigin(0.0f, 0.5f);
|
mMediaType->setOrigin(0.0f, 0.5f);
|
||||||
|
|
||||||
if (mHelpInfoPosition == HelpInfoPosition::TOP) {
|
if (mHelpInfoPosition == HelpInfoPosition::TOP) {
|
||||||
mEntryNumText->setPosition(mRenderer->getScreenWidth() * 0.01f, mFrameHeight / 2.0f);
|
mMediaType->setPosition(mRenderer->getScreenWidth() * 0.01f, mFrameHeight / 2.0f);
|
||||||
style.position = glm::vec2 {mRenderer->getScreenWidth() / 2.0f, mFrameHeight / 2.0f};
|
style.position = glm::vec2 {mRenderer->getScreenWidth() / 2.0f, mFrameHeight / 2.0f};
|
||||||
}
|
}
|
||||||
else if (mHelpInfoPosition == HelpInfoPosition::BOTTOM) {
|
else if (mHelpInfoPosition == HelpInfoPosition::BOTTOM) {
|
||||||
mEntryNumText->setPosition(mRenderer->getScreenWidth() * 0.01f,
|
mMediaType->setPosition(mRenderer->getScreenWidth() * 0.01f,
|
||||||
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f));
|
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f));
|
||||||
style.position = glm::vec2 {mRenderer->getScreenWidth() / 2.0f,
|
style.position = glm::vec2 {mRenderer->getScreenWidth() / 2.0f,
|
||||||
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f)};
|
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f)};
|
||||||
}
|
}
|
||||||
|
@ -171,7 +174,8 @@ void MediaViewer::render(const glm::mat4& /*parentTrans*/)
|
||||||
Renderer::getScreenHeight() - mFrameHeight),
|
Renderer::getScreenHeight() - mFrameHeight),
|
||||||
Renderer::getScreenWidth(), mFrameHeight, 0x222222FF, 0x222222FF);
|
Renderer::getScreenWidth(), mFrameHeight, 0x222222FF, 0x222222FF);
|
||||||
mHelp->render(trans);
|
mHelp->render(trans);
|
||||||
mEntryNumText->render(trans);
|
if (mShowMediaTypes)
|
||||||
|
mMediaType->render(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,31 +216,31 @@ void MediaViewer::findMedia()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mHasVideo && (mediaFile = mGame->getScreenshotPath()) != "") {
|
if (!mHasVideo && (mediaFile = mGame->getScreenshotPath()) != "") {
|
||||||
mImageFiles.push_back(std::make_pair(mediaFile, " SCREENSHOT"));
|
mImageFiles.push_back(std::make_pair(mediaFile, "SCREENSHOT"));
|
||||||
mScreenshotIndex = 0;
|
mScreenshotIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mediaFile = mGame->getCoverPath()) != "")
|
if ((mediaFile = mGame->getCoverPath()) != "")
|
||||||
mImageFiles.push_back(std::make_pair(mediaFile, " BOX COVER"));
|
mImageFiles.push_back(std::make_pair(mediaFile, "BOX COVER"));
|
||||||
|
|
||||||
if ((mediaFile = mGame->getBackCoverPath()) != "")
|
if ((mediaFile = mGame->getBackCoverPath()) != "")
|
||||||
mImageFiles.push_back(std::make_pair(mediaFile, " BOX BACK COVER"));
|
mImageFiles.push_back(std::make_pair(mediaFile, "BOX BACK COVER"));
|
||||||
|
|
||||||
if ((mediaFile = mGame->getTitleScreenPath()) != "") {
|
if ((mediaFile = mGame->getTitleScreenPath()) != "") {
|
||||||
mImageFiles.push_back(std::make_pair(mediaFile, " TITLE SCREEN"));
|
mImageFiles.push_back(std::make_pair(mediaFile, "TITLE SCREEN"));
|
||||||
mTitleScreenIndex = static_cast<int>(mImageFiles.size() - 1);
|
mTitleScreenIndex = static_cast<int>(mImageFiles.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHasVideo && (mediaFile = mGame->getScreenshotPath()) != "") {
|
if (mHasVideo && (mediaFile = mGame->getScreenshotPath()) != "") {
|
||||||
mImageFiles.push_back(std::make_pair(mediaFile, " SCREENSHOT"));
|
mImageFiles.push_back(std::make_pair(mediaFile, "SCREENSHOT"));
|
||||||
mScreenshotIndex = static_cast<int>(mImageFiles.size() - 1);
|
mScreenshotIndex = static_cast<int>(mImageFiles.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mediaFile = mGame->getFanArtPath()) != "")
|
if ((mediaFile = mGame->getFanArtPath()) != "")
|
||||||
mImageFiles.push_back(std::make_pair(mediaFile, " FAN ART"));
|
mImageFiles.push_back(std::make_pair(mediaFile, "FAN ART"));
|
||||||
|
|
||||||
if ((mediaFile = mGame->getMiximagePath()) != "")
|
if ((mediaFile = mGame->getMiximagePath()) != "")
|
||||||
mImageFiles.push_back(std::make_pair(mediaFile, " MIXIMAGE"));
|
mImageFiles.push_back(std::make_pair(mediaFile, "MIXIMAGE"));
|
||||||
|
|
||||||
if (!mImageFiles.empty())
|
if (!mImageFiles.empty())
|
||||||
mHasImages = true;
|
mHasImages = true;
|
||||||
|
@ -322,8 +326,7 @@ void MediaViewer::showNext()
|
||||||
++mCurrentImageIndex;
|
++mCurrentImageIndex;
|
||||||
|
|
||||||
mDisplayingImage = true;
|
mDisplayingImage = true;
|
||||||
mEntryNumText->setText(std::to_string(mCurrentImageIndex + 1 + (mHasVideo ? 1 : 0)) + "/" +
|
mMediaType->setText(mImageFiles[mCurrentImageIndex].second);
|
||||||
mEntryCount + mImageFiles[mCurrentImageIndex].second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaViewer::showPrevious()
|
void MediaViewer::showPrevious()
|
||||||
|
@ -336,13 +339,12 @@ void MediaViewer::showPrevious()
|
||||||
}
|
}
|
||||||
else if (mCurrentImageIndex == 0 && mHasVideo) {
|
else if (mCurrentImageIndex == 0 && mHasVideo) {
|
||||||
mDisplayingImage = false;
|
mDisplayingImage = false;
|
||||||
mEntryNumText->setText("1/" + mEntryCount + " VIDEO");
|
mMediaType->setText("VIDEO");
|
||||||
playVideo();
|
playVideo();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mEntryNumText->setText(std::to_string(mCurrentImageIndex + (mHasVideo ? 1 : 0)) + "/" +
|
mMediaType->setText(mImageFiles[mCurrentImageIndex - 1].second);
|
||||||
mEntryCount + mImageFiles[mCurrentImageIndex - 1].second);
|
|
||||||
--mCurrentImageIndex;
|
--mCurrentImageIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,8 +358,7 @@ void MediaViewer::showFirst()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mCurrentImageIndex = 0;
|
mCurrentImageIndex = 0;
|
||||||
mEntryNumText->setText("1/" + mEntryCount +
|
mMediaType->setText((mHasVideo ? "VIDEO" : mImageFiles[mCurrentImageIndex].second));
|
||||||
(mHasVideo ? " VIDEO" : mImageFiles[mCurrentImageIndex].second));
|
|
||||||
|
|
||||||
if (mHasVideo) {
|
if (mHasVideo) {
|
||||||
mDisplayingImage = false;
|
mDisplayingImage = false;
|
||||||
|
@ -375,8 +376,7 @@ void MediaViewer::showLast()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mCurrentImageIndex = static_cast<int>(mImages.size()) - 1;
|
mCurrentImageIndex = static_cast<int>(mImages.size()) - 1;
|
||||||
mEntryNumText->setText(mEntryCount + "/" + mEntryCount +
|
mMediaType->setText(mImageFiles[mCurrentImageIndex].second);
|
||||||
mImageFiles[mCurrentImageIndex].second);
|
|
||||||
mDisplayingImage = true;
|
mDisplayingImage = true;
|
||||||
|
|
||||||
if (mVideo && !Settings::getInstance()->getBool("MediaViewerKeepVideoRunning"))
|
if (mVideo && !Settings::getInstance()->getBool("MediaViewerKeepVideoRunning"))
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
bool mHasImages;
|
bool mHasImages;
|
||||||
bool mDisplayingImage;
|
bool mDisplayingImage;
|
||||||
bool mHasManual;
|
bool mHasManual;
|
||||||
|
bool mShowMediaTypes;
|
||||||
|
|
||||||
float mFrameHeight;
|
float mFrameHeight;
|
||||||
int mCurrentImageIndex;
|
int mCurrentImageIndex;
|
||||||
|
@ -66,7 +67,7 @@ private:
|
||||||
std::vector<std::unique_ptr<ImageComponent>> mImages;
|
std::vector<std::unique_ptr<ImageComponent>> mImages;
|
||||||
|
|
||||||
std::unique_ptr<HelpComponent> mHelp;
|
std::unique_ptr<HelpComponent> mHelp;
|
||||||
std::unique_ptr<TextComponent> mEntryNumText;
|
std::unique_ptr<TextComponent> mMediaType;
|
||||||
std::string mEntryCount;
|
std::string mEntryCount;
|
||||||
HelpInfoPosition mHelpInfoPosition;
|
HelpInfoPosition mHelpInfoPosition;
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,6 +38,19 @@ GuiMediaViewerOptions::GuiMediaViewerOptions(const std::string& title)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Display media types.
|
||||||
|
auto mediaViewerShowTypes = std::make_shared<SwitchComponent>();
|
||||||
|
mediaViewerShowTypes->setState(Settings::getInstance()->getBool("MediaViewerShowTypes"));
|
||||||
|
addWithLabel("DISPLAY MEDIA TYPES", mediaViewerShowTypes);
|
||||||
|
addSaveFunc([mediaViewerShowTypes, this] {
|
||||||
|
if (mediaViewerShowTypes->getState() !=
|
||||||
|
Settings::getInstance()->getBool("MediaViewerShowTypes")) {
|
||||||
|
Settings::getInstance()->setBool("MediaViewerShowTypes",
|
||||||
|
mediaViewerShowTypes->getState());
|
||||||
|
setNeedsSaving();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Keep videos running when viewing images.
|
// Keep videos running when viewing images.
|
||||||
auto keepVideoRunning = std::make_shared<SwitchComponent>();
|
auto keepVideoRunning = std::make_shared<SwitchComponent>();
|
||||||
keepVideoRunning->setState(Settings::getInstance()->getBool("MediaViewerKeepVideoRunning"));
|
keepVideoRunning->setState(Settings::getInstance()->getBool("MediaViewerKeepVideoRunning"));
|
||||||
|
|
|
@ -173,6 +173,7 @@ void Settings::setDefaults()
|
||||||
|
|
||||||
// UI settings -> media viewer settings.
|
// UI settings -> media viewer settings.
|
||||||
mStringMap["MediaViewerHelpPrompts"] = {"top", "top"};
|
mStringMap["MediaViewerHelpPrompts"] = {"top", "top"};
|
||||||
|
mBoolMap["MediaViewerShowTypes"] = {false, false};
|
||||||
mBoolMap["MediaViewerKeepVideoRunning"] = {true, true};
|
mBoolMap["MediaViewerKeepVideoRunning"] = {true, true};
|
||||||
mBoolMap["MediaViewerStretchVideos"] = {false, false};
|
mBoolMap["MediaViewerStretchVideos"] = {false, false};
|
||||||
#if defined(RASPBERRY_PI)
|
#if defined(RASPBERRY_PI)
|
||||||
|
|
Loading…
Reference in a new issue