Rewrote the logic for the 'none' value for the helpsystem element scope property

This commit is contained in:
Leon Styhre 2025-02-05 21:05:54 +01:00
parent 57815f6633
commit db2b00a49e
4 changed files with 11 additions and 13 deletions

View file

@ -352,8 +352,6 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
else if (element.second.type == "helpsystem") {
mHelpComponents.emplace_back(std::make_unique<HelpComponent>());
mHelpComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
if (mHelpComponents.back()->getHelpComponentScope() == HelpComponentScope::NONE)
mHelpComponents.pop_back();
}
}
}

View file

@ -726,10 +726,6 @@ void SystemView::populate()
elements.helpComponents.emplace_back(std::make_unique<HelpComponent>());
elements.helpComponents.back()->applyTheme(theme, "system", element.first,
ThemeFlags::ALL);
if (elements.helpComponents.back()->getHelpComponentScope() ==
HelpComponentScope::NONE) {
elements.helpComponents.pop_back();
}
}
}
}

View file

@ -608,6 +608,8 @@ void Window::render()
if (!mRenderedHelpPrompts) {
if (mHelpComponents != nullptr) {
for (auto& helpComponent : *mHelpComponents) {
if (helpComponent->getHelpComponentScope() == HelpComponentScope::NONE)
continue;
if (helpComponent->getHelpComponentScope() != HelpComponentScope::VIEW) {
helpComponent->setVisible(true);
helpComponent->render(trans);
@ -773,6 +775,8 @@ void Window::renderHelpPromptsEarly()
{
if (mHelpComponents != nullptr) {
for (auto& helpComponent : *mHelpComponents) {
if (helpComponent->getHelpComponentScope() == HelpComponentScope::NONE)
continue;
if (helpComponent->getHelpComponentScope() != HelpComponentScope::MENU) {
helpComponent->setVisible(true);
helpComponent->render(mRenderer->getIdentity());
@ -855,10 +859,12 @@ void Window::setHelpPrompts(const std::vector<HelpPrompt>& prompts)
if (mHelpComponents != nullptr) {
for (auto& helpComponent : *mHelpComponents) {
if (helpComponent->getHelpComponentScope() == HelpComponentScope::NONE)
continue;
if (mGuiStack.size() == 1 &&
helpComponent->getHelpComponentScope() == HelpComponentScope::MENU)
continue;
else if (mGuiStack.size() > 1 &&
if (mGuiStack.size() > 1 &&
helpComponent->getHelpComponentScope() == HelpComponentScope::VIEW)
continue;
helpComponent->clearPrompts();

View file

@ -270,11 +270,6 @@ void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (!elem)
return;
if (elem->has("scope") && elem->get<std::string>("scope") == "none") {
mHelpComponentScope = HelpComponentScope::NONE;
return;
}
if (elem->has("pos"))
mStylePosition = elem->get<glm::vec2>("pos") *
glm::vec2 {Renderer::getScreenWidth(), Renderer::getScreenHeight()};
@ -329,6 +324,9 @@ void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
else if (scope == "menu") {
mHelpComponentScope = HelpComponentScope::MENU;
}
else if (scope == "none") {
mHelpComponentScope = HelpComponentScope::NONE;
}
else {
LOG(LogWarning) << "HelpComponent: Invalid theme configuration, property "
"\"scope\" for element \""