mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-30 12:05:39 +00:00
Added a fullscreen screenshot viewer to GuiThemeDownloader
Also added proper helpsystem entries
This commit is contained in:
parent
b64f0a2d9e
commit
a4cf1c6bac
|
@ -24,6 +24,8 @@ GuiThemeDownloader::GuiThemeDownloader()
|
||||||
, mRepositoryError {RepositoryError::NO_REPO_ERROR}
|
, mRepositoryError {RepositoryError::NO_REPO_ERROR}
|
||||||
, mFetching {false}
|
, mFetching {false}
|
||||||
, mLatestThemesList {false}
|
, mLatestThemesList {false}
|
||||||
|
, mFullscreenViewing {false}
|
||||||
|
, mFullscreenViewerIndex {0}
|
||||||
{
|
{
|
||||||
addChild(&mBackground);
|
addChild(&mBackground);
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
@ -87,6 +89,7 @@ GuiThemeDownloader::GuiThemeDownloader()
|
||||||
mGrid.setEntry(mLocalChanges, glm::ivec2 {3, 4}, false, true, glm::ivec2 {2, 1});
|
mGrid.setEntry(mLocalChanges, glm::ivec2 {3, 4}, false, true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
mScreenshot = std::make_shared<ImageComponent>();
|
mScreenshot = std::make_shared<ImageComponent>();
|
||||||
|
mScreenshot->setLinearInterpolation(true);
|
||||||
mGrid.setEntry(mScreenshot, glm::ivec2 {1, 5}, false, true, glm::ivec2 {4, 1});
|
mGrid.setEntry(mScreenshot, glm::ivec2 {1, 5}, false, true, glm::ivec2 {4, 1});
|
||||||
|
|
||||||
mAuthor = std::make_shared<TextComponent>("", Font::get(FONT_SIZE_MINI, FONT_PATH_LIGHT),
|
mAuthor = std::make_shared<TextComponent>("", Font::get(FONT_SIZE_MINI, FONT_PATH_LIGHT),
|
||||||
|
@ -139,6 +142,12 @@ GuiThemeDownloader::GuiThemeDownloader()
|
||||||
updateInfoPane();
|
updateInfoPane();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mViewerIndicatorLeft = std::make_shared<TextComponent>(
|
||||||
|
"\uf104", Font::get(FONT_SIZE_LARGE * 1.2f, FONT_PATH_BOLD), 0xCCCCCCFF, ALIGN_CENTER);
|
||||||
|
|
||||||
|
mViewerIndicatorRight = std::make_shared<TextComponent>(
|
||||||
|
"\uf105", Font::get(FONT_SIZE_LARGE * 1.2f, FONT_PATH_BOLD), 0xCCCCCCFF, ALIGN_CENTER);
|
||||||
|
|
||||||
git_libgit2_init();
|
git_libgit2_init();
|
||||||
|
|
||||||
// The promise/future mechanism is used as signaling for the thread to indicate that
|
// The promise/future mechanism is used as signaling for the thread to indicate that
|
||||||
|
@ -687,6 +696,50 @@ void GuiThemeDownloader::updateInfoPane()
|
||||||
Utils::String::toUpper(mThemeSets[mList->getCursorId()].author));
|
Utils::String::toUpper(mThemeSets[mList->getCursorId()].author));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiThemeDownloader::setupFullscreenViewer()
|
||||||
|
{
|
||||||
|
if (mThemeSets.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mViewerScreenshots.clear();
|
||||||
|
mViewerCaptions.clear();
|
||||||
|
mFullscreenViewerIndex = 0;
|
||||||
|
mFullscreenViewing = true;
|
||||||
|
|
||||||
|
for (auto& screenshot : mThemeSets[mList->getCursorId()].screenshots) {
|
||||||
|
auto image = std::make_shared<ImageComponent>(false, false);
|
||||||
|
image->setLinearInterpolation(true);
|
||||||
|
image->setMaxSize(mRenderer->getScreenWidth() * 0.86f,
|
||||||
|
mRenderer->getScreenHeight() * 0.86f);
|
||||||
|
image->setImage(mThemeDirectory + "themes-list/" + screenshot.image);
|
||||||
|
// Center image on screen.
|
||||||
|
glm::vec3 imagePos {image->getPosition()};
|
||||||
|
imagePos.x = (mRenderer->getScreenWidth() - image->getSize().x) / 2.0f;
|
||||||
|
imagePos.y = (mRenderer->getScreenHeight() - image->getSize().y) / 2.0f;
|
||||||
|
image->setPosition(imagePos);
|
||||||
|
mViewerScreenshots.emplace_back(image);
|
||||||
|
auto caption = std::make_shared<TextComponent>(screenshot.caption,
|
||||||
|
Font::get(FONT_SIZE_MINI, FONT_PATH_REGULAR),
|
||||||
|
0xCCCCCCFF, ALIGN_LEFT);
|
||||||
|
glm::vec3 textPos {image->getPosition()};
|
||||||
|
textPos.y += image->getSize().y;
|
||||||
|
caption->setPosition(textPos);
|
||||||
|
mViewerCaptions.emplace_back(caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mViewerScreenshots.size() > 0) {
|
||||||
|
// Navigation indicators to the left and right of the screenshot.
|
||||||
|
glm::vec3 indicatorPos {mViewerScreenshots.front()->getPosition()};
|
||||||
|
indicatorPos.x -= mViewerIndicatorLeft->getSize().x * 2.0f;
|
||||||
|
indicatorPos.y += (mViewerScreenshots.front()->getSize().y / 2.0f) -
|
||||||
|
(mViewerIndicatorLeft->getSize().y / 2.0f);
|
||||||
|
mViewerIndicatorLeft->setPosition(indicatorPos);
|
||||||
|
indicatorPos.x +=
|
||||||
|
mViewerScreenshots.front()->getSize().x + (mViewerIndicatorRight->getSize().x * 3.0f);
|
||||||
|
mViewerIndicatorRight->setPosition(indicatorPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GuiThemeDownloader::update(int deltaTime)
|
void GuiThemeDownloader::update(int deltaTime)
|
||||||
{
|
{
|
||||||
if (mFuture.valid()) {
|
if (mFuture.valid()) {
|
||||||
|
@ -766,6 +819,18 @@ void GuiThemeDownloader::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
if (mFetching)
|
if (mFetching)
|
||||||
mBusyAnim.render(trans);
|
mBusyAnim.render(trans);
|
||||||
|
|
||||||
|
if (mFullscreenViewing && mViewerScreenshots.size() > 0) {
|
||||||
|
mRenderer->setMatrix(parentTrans);
|
||||||
|
mRenderer->drawRect(0.0f, 0.0f, mRenderer->getScreenWidth(), mRenderer->getScreenHeight(),
|
||||||
|
0x222222FF, 0x222222FF);
|
||||||
|
mViewerScreenshots[mFullscreenViewerIndex]->render(parentTrans);
|
||||||
|
mViewerCaptions[mFullscreenViewerIndex]->render(parentTrans);
|
||||||
|
if (mFullscreenViewerIndex != 0)
|
||||||
|
mViewerIndicatorLeft->render(parentTrans);
|
||||||
|
if (mFullscreenViewerIndex != mViewerCaptions.size() - 1)
|
||||||
|
mViewerIndicatorRight->render(parentTrans);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiThemeDownloader::onSizeChanged()
|
void GuiThemeDownloader::onSizeChanged()
|
||||||
|
@ -812,18 +877,53 @@ void GuiThemeDownloader::onSizeChanged()
|
||||||
|
|
||||||
bool GuiThemeDownloader::input(InputConfig* config, Input input)
|
bool GuiThemeDownloader::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
|
if (mFullscreenViewing && input.value) {
|
||||||
|
if (config->isMappedLike("left", input)) {
|
||||||
|
if (mFullscreenViewerIndex > 0)
|
||||||
|
--mFullscreenViewerIndex;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (config->isMappedLike("right", input)) {
|
||||||
|
if (mViewerScreenshots.size() > mFullscreenViewerIndex + 1)
|
||||||
|
++mFullscreenViewerIndex;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mViewerScreenshots.clear();
|
||||||
|
mViewerCaptions.clear();
|
||||||
|
mFullscreenViewing = false;
|
||||||
|
mFullscreenViewerIndex = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (config->isMappedTo("b", input) && input.value) {
|
if (config->isMappedTo("b", input) && input.value) {
|
||||||
delete this;
|
delete this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config->isMappedTo("x", input) && input.value && mGrid.getSelectedComponent() == mList) {
|
||||||
|
setupFullscreenViewer();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return GuiComponent::input(config, input);
|
return GuiComponent::input(config, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HelpPrompt> GuiThemeDownloader::getHelpPrompts()
|
std::vector<HelpPrompt> GuiThemeDownloader::getHelpPrompts()
|
||||||
{
|
{
|
||||||
std::vector<HelpPrompt> prompts {mGrid.getHelpPrompts()};
|
std::vector<HelpPrompt> prompts {mGrid.getHelpPrompts()};
|
||||||
prompts.push_back(HelpPrompt("b", "exit"));
|
prompts.push_back(HelpPrompt("b", "close"));
|
||||||
|
|
||||||
|
if (mList->size() > 0) {
|
||||||
|
if (mGrid.getSelectedComponent() == mList)
|
||||||
|
prompts.push_back(HelpPrompt("x", "view screenshots"));
|
||||||
|
|
||||||
|
if (mThemeSets[mList->getCursorId()].isCloned)
|
||||||
|
prompts.push_back(HelpPrompt("a", "fetch updates"));
|
||||||
|
else
|
||||||
|
prompts.push_back(HelpPrompt("a", "download"));
|
||||||
|
}
|
||||||
|
|
||||||
return prompts;
|
return prompts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ private:
|
||||||
void populateGUI();
|
void populateGUI();
|
||||||
void updateGUI();
|
void updateGUI();
|
||||||
void updateInfoPane();
|
void updateInfoPane();
|
||||||
|
void setupFullscreenViewer();
|
||||||
|
|
||||||
Renderer* mRenderer;
|
Renderer* mRenderer;
|
||||||
NinePatchComponent mBackground;
|
NinePatchComponent mBackground;
|
||||||
|
@ -138,6 +139,8 @@ private:
|
||||||
std::vector<ThemeEntry> mThemeSets;
|
std::vector<ThemeEntry> mThemeSets;
|
||||||
StatusType mStatusType;
|
StatusType mStatusType;
|
||||||
std::string mStatusText;
|
std::string mStatusText;
|
||||||
|
bool mFullscreenViewing;
|
||||||
|
size_t mFullscreenViewerIndex;
|
||||||
|
|
||||||
std::shared_ptr<ImageComponent> mScrollUp;
|
std::shared_ptr<ImageComponent> mScrollUp;
|
||||||
std::shared_ptr<ImageComponent> mScrollDown;
|
std::shared_ptr<ImageComponent> mScrollDown;
|
||||||
|
@ -145,6 +148,10 @@ private:
|
||||||
std::vector<float> mGrayRectangleCoords;
|
std::vector<float> mGrayRectangleCoords;
|
||||||
|
|
||||||
std::shared_ptr<ImageComponent> mScreenshot;
|
std::shared_ptr<ImageComponent> mScreenshot;
|
||||||
|
std::vector<std::shared_ptr<ImageComponent>> mViewerScreenshots;
|
||||||
|
std::vector<std::shared_ptr<TextComponent>> mViewerCaptions;
|
||||||
|
std::shared_ptr<TextComponent> mViewerIndicatorLeft;
|
||||||
|
std::shared_ptr<TextComponent> mViewerIndicatorRight;
|
||||||
std::shared_ptr<TextComponent> mDownloadStatus;
|
std::shared_ptr<TextComponent> mDownloadStatus;
|
||||||
std::shared_ptr<TextComponent> mLocalChanges;
|
std::shared_ptr<TextComponent> mLocalChanges;
|
||||||
std::shared_ptr<TextComponent> mTitle;
|
std::shared_ptr<TextComponent> mTitle;
|
||||||
|
|
Loading…
Reference in a new issue