Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpstyle: fix remaining inconsistent layout alignment and styling #873

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion es-app/src/components/ScraperSearchComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#include "components/TextComponent.h"
#include "guis/GuiMsgBox.h"
#include "guis/GuiTextEditPopup.h"
#include "views/ViewController.h"
#include "resources/Font.h"
#include "utils/StringUtil.h"
#include "FileData.h"
#include "Log.h"
#include "SystemData.h"
#include "Window.h"

ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window),
Expand Down Expand Up @@ -456,7 +458,8 @@ void ScraperSearchComponent::openInputScreen(ScraperSearchParams& params)
mWindow->pushGui(new GuiTextEditPopup(mWindow, "SEARCH FOR",
// initial value is last search if there was one, otherwise the clean path name
params.nameOverride.empty() ? params.game->getCleanName() : params.nameOverride,
searchForFunc, false, "SEARCH"));
searchForFunc, false, "SEARCH",
ViewController::get()->getState().getSystem()->getTheme()));
}

std::vector<HelpPrompt> ScraperSearchComponent::getHelpPrompts()
Expand Down
17 changes: 16 additions & 1 deletion es-app/src/guis/GuiCollectionSystemsOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "utils/StringUtil.h"
#include "views/ViewController.h"
#include "CollectionSystemManager.h"
#include "SystemData.h"
#include "Window.h"

GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window) : GuiComponent(window), mMenu(window, "GAME COLLECTION SETTINGS")
Expand Down Expand Up @@ -64,7 +65,14 @@ void GuiCollectionSystemsOptions::initializeMenu()
createCollection(name);
};
row.makeAcceptInputHandler([this, createCustomCollection] {
mWindow->pushGui(new GuiTextEditPopup(mWindow, "New Collection Name", "", createCustomCollection, false));
mWindow->pushGui(new GuiTextEditPopup(
mWindow,
"New Collection Name",
"",
createCustomCollection,
false, "OK",
ViewController::get()->getState().getSystem()->getTheme()
));
});

mMenu.addRow(row);
Expand Down Expand Up @@ -276,6 +284,13 @@ bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input)
return false;
}

HelpStyle GuiCollectionSystemsOptions::getHelpStyle()
{
HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
return style;
}

std::vector<HelpPrompt> GuiCollectionSystemsOptions::getHelpPrompts()
{
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
Expand Down
1 change: 1 addition & 0 deletions es-app/src/guis/GuiCollectionSystemsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GuiCollectionSystemsOptions : public GuiComponent
bool input(InputConfig* config, Input input) override;

virtual std::vector<HelpPrompt> getHelpPrompts() override;
HelpStyle getHelpStyle() override;

private:
void initializeMenu();
Expand Down
45 changes: 37 additions & 8 deletions es-app/src/guis/GuiMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ void GuiMenu::openUISettings()
LOG(LogDebug) << "Setting UI mode to " << selectedMode;
Settings::getInstance()->setString("UIMode", selectedMode);
Settings::getInstance()->saveFile();
}, "NO",nullptr));
}, "NO", nullptr,
"", nullptr, ViewController::get()->getState().getSystem()->getTheme()));
}
});

Expand Down Expand Up @@ -503,10 +504,14 @@ void GuiMenu::openOtherSettings()
void GuiMenu::openConfigInput()
{
Window* window = mWindow;
window->pushGui(new GuiMsgBox(window, "ARE YOU SURE YOU WANT TO CONFIGURE INPUT?", "YES",
window->pushGui(new GuiMsgBox(
window, "ARE YOU SURE YOU WANT TO CONFIGURE INPUT?", "YES",
[window] {
window->pushGui(new GuiDetectDevice(window, false, nullptr));
}, "NO", nullptr)
window->pushGui(new GuiDetectDevice(window, false, nullptr));
},
"NO", nullptr,
"", nullptr,
ViewController::get()->getState().getSystem()->getTheme())
);

}
Expand All @@ -532,7 +537,13 @@ void GuiMenu::openQuitMenu()

if (confirm_quit) {
row.makeAcceptInputHandler([window] {
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES", restart_es_fx, "NO", nullptr));
window->pushGui(new GuiMsgBox(
window, "REALLY RESTART?", "YES",
restart_es_fx,
"NO", nullptr,
"", nullptr,
ViewController::get()->getState().getSystem()->getTheme()
));
});
} else {
row.makeAcceptInputHandler(restart_es_fx);
Expand All @@ -550,7 +561,13 @@ void GuiMenu::openQuitMenu()
row.elements.clear();
if (confirm_quit) {
row.makeAcceptInputHandler([window] {
window->pushGui(new GuiMsgBox(window, "REALLY QUIT?", "YES", quit_es_fx, "NO", nullptr));
window->pushGui(new GuiMsgBox(
window, "REALLY QUIT?", "YES",
quit_es_fx,
"NO", nullptr,
"", nullptr,
ViewController::get()->getState().getSystem()->getTheme()
));
});
} else {
row.makeAcceptInputHandler(quit_es_fx);
Expand All @@ -571,7 +588,13 @@ void GuiMenu::openQuitMenu()
row.elements.clear();
if (confirm_quit) {
row.makeAcceptInputHandler([window] {
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES", {reboot_sys_fx}, "NO", nullptr));
window->pushGui(new GuiMsgBox(
window, "REALLY RESTART?", "YES",
{reboot_sys_fx},
"NO", nullptr,
"", nullptr,
ViewController::get()->getState().getSystem()->getTheme()
));
});
} else {
row.makeAcceptInputHandler(reboot_sys_fx);
Expand All @@ -590,7 +613,13 @@ void GuiMenu::openQuitMenu()
row.elements.clear();
if (confirm_quit) {
row.makeAcceptInputHandler([window] {
window->pushGui(new GuiMsgBox(window, "REALLY SHUTDOWN?", "YES", shutdown_sys_fx, "NO", nullptr));
window->pushGui(new GuiMsgBox(
window, "REALLY SHUTDOWN?", "YES",
shutdown_sys_fx,
"NO", nullptr,
"", nullptr,
ViewController::get()->getState().getSystem()->getTheme()
));
});
} else {
row.makeAcceptInputHandler(shutdown_sys_fx);
Expand Down
7 changes: 7 additions & 0 deletions es-app/src/guis/GuiRandomCollectionOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ bool GuiRandomCollectionOptions::input(InputConfig* config, Input input)
return false;
}

HelpStyle GuiRandomCollectionOptions::getHelpStyle()
{
HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
return style;
}

std::vector<HelpPrompt> GuiRandomCollectionOptions::getHelpPrompts()
{
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
Expand Down
1 change: 1 addition & 0 deletions es-app/src/guis/GuiRandomCollectionOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class GuiRandomCollectionOptions : public GuiComponent
bool input(InputConfig* config, Input input) override;

virtual std::vector<HelpPrompt> getHelpPrompts() override;
HelpStyle getHelpStyle() override;

private:
void initializeMenu();
Expand Down
17 changes: 15 additions & 2 deletions es-app/src/guis/GuiScraperMulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,26 @@ void GuiScraperMulti::finish()
ss << "\n" << mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED.";
}

mWindow->pushGui(new GuiMsgBox(mWindow, ss.str(),
"OK", [&] { delete this; }));
mWindow->pushGui(new GuiMsgBox(
mWindow, ss.str(),
"OK", [&]
{ delete this; },
"", nullptr,
"", nullptr,
ViewController::get()->getState().getSystem()->getTheme()
));

mIsProcessing = false;
PowerSaver::resume();
}

HelpStyle GuiScraperMulti::getHelpStyle()
{
HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
return style;
}

std::vector<HelpPrompt> GuiScraperMulti::getHelpPrompts()
{
return mGrid.getHelpPrompts();
Expand Down
1 change: 1 addition & 0 deletions es-app/src/guis/GuiScraperMulti.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class GuiScraperMulti : public GuiComponent

void onSizeChanged() override;
std::vector<HelpPrompt> getHelpPrompts() override;
HelpStyle getHelpStyle() override;

private:
void acceptResult(const ScraperSearchResult& result);
Expand Down
7 changes: 7 additions & 0 deletions es-app/src/guis/GuiScraperStart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ bool GuiScraperStart::input(InputConfig* config, Input input)
return false;
}

HelpStyle GuiScraperStart::getHelpStyle()
{
HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
return style;
}

std::vector<HelpPrompt> GuiScraperStart::getHelpPrompts()
{
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
Expand Down
1 change: 1 addition & 0 deletions es-app/src/guis/GuiScraperStart.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class GuiScraperStart : public GuiComponent
bool input(InputConfig* config, Input input) override;

virtual std::vector<HelpPrompt> getHelpPrompts() override;
HelpStyle getHelpStyle() override;

private:
void pressedStart();
Expand Down
10 changes: 9 additions & 1 deletion es-app/src/guis/GuiScreensaverOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ void GuiScreensaverOptions::addEditableTextComponent(ComponentListRow row, const

auto updateVal = [ed](const std::string& newVal) { ed->setValue(newVal); }; // ok callback (apply new value to ed)
row.makeAcceptInputHandler([this, label, ed, updateVal] {
mWindow->pushGui(new GuiTextEditPopup(mWindow, label, ed->getValue(), updateVal, false));
mWindow->pushGui(new GuiTextEditPopup(
mWindow,
label,
ed->getValue(),
updateVal,
false,
"OK",
ViewController::get()->getState().getSystem()->getTheme()
));
});
assert(ed);
addRow(row);
Expand Down
18 changes: 18 additions & 0 deletions es-core/src/components/OptionListComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "GuiComponent.h"
#include "Log.h"
#include "Window.h"
#include "SystemData.h"
#include "views/ViewController.h"

//Used to display a list of options.
//Can select one or multiple options.
Expand Down Expand Up @@ -125,6 +127,14 @@ class OptionListComponent : public GuiComponent
return GuiComponent::input(config, input);
}

HelpStyle getHelpStyle() override
{
HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");

return style;
}

std::vector<HelpPrompt> getHelpPrompts() override
{
auto prompts = mMenu.getHelpPrompts();
Expand Down Expand Up @@ -316,6 +326,14 @@ class OptionListComponent : public GuiComponent
}
}

HelpStyle getHelpStyle() override
{
HelpStyle style = HelpStyle();
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");

return style;
}

std::vector<HelpPrompt> getHelpPrompts() override
{
std::vector<HelpPrompt> prompts;
Expand Down
26 changes: 21 additions & 5 deletions es-core/src/guis/GuiMsgBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

#define HORIZONTAL_PADDING_PX 20

GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
const std::string& name1, const std::function<void()>& func1,
const std::string& name2, const std::function<void()>& func2,
const std::string& name3, const std::function<void()>& func3) : GuiComponent(window),
mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 2))
GuiMsgBox::GuiMsgBox(Window *window, const std::string &text,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we revert these types of changes if possible, as they're stylistic but not really functional? Thanks.

const std::string &name1, const std::function<void()> &func1,
const std::string &name2, const std::function<void()> &func2,
const std::string &name3, const std::function<void()> &func3,
const std::shared_ptr<ThemeData> &theme):
GuiComponent(window),
mBackground(window, ":/frame.png"),
mGrid(window, Vector2i(1, 2)),
mTheme(theme)
{
float width = Renderer::getScreenWidth() * 0.6f; // max width
float minWidth = Renderer::getScreenWidth() * 0.3f; // minimum width
Expand Down Expand Up @@ -104,6 +108,18 @@ void GuiMsgBox::deleteMeAndCall(const std::function<void()>& func)

}

HelpStyle GuiMsgBox::getHelpStyle()
{
if (mTheme)
{
HelpStyle style = HelpStyle();
style.applyTheme(mTheme, "system");
return style;
}

return GuiComponent::getHelpStyle();
}

std::vector<HelpPrompt> GuiMsgBox::getHelpPrompts()
{
return mGrid.getHelpPrompts();
Expand Down
9 changes: 6 additions & 3 deletions es-core/src/guis/GuiMsgBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ class GuiMsgBox : public GuiComponent
{
public:
GuiMsgBox(Window* window, const std::string& text,
const std::string& name1 = "OK", const std::function<void()>& func1 = nullptr,
const std::string& name2 = "", const std::function<void()>& func2 = nullptr,
const std::string& name3 = "", const std::function<void()>& func3 = nullptr);
const std::string &name1 = "OK", const std::function<void()> &func1 = nullptr,
const std::string &name2 = "", const std::function<void()> &func2 = nullptr,
const std::string &name3 = "", const std::function<void()> &func3 = nullptr,
const std::shared_ptr<ThemeData> &theme = NULL);

bool input(InputConfig* config, Input input) override;
void onSizeChanged() override;
std::vector<HelpPrompt> getHelpPrompts() override;
HelpStyle getHelpStyle() override;

private:
void deleteMeAndCall(const std::function<void()>& func);
Expand All @@ -32,6 +34,7 @@ class GuiMsgBox : public GuiComponent
std::vector< std::shared_ptr<ButtonComponent> > mButtons;
std::shared_ptr<ComponentGrid> mButtonGrid;
std::function<void()> mAcceleratorFunc;
std::shared_ptr<ThemeData> mTheme;
};

#endif // ES_CORE_GUIS_GUI_MSG_BOX_H
17 changes: 14 additions & 3 deletions es-core/src/guis/GuiTextEditPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include "components/MenuComponent.h"
#include "components/TextEditComponent.h"

GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue,
const std::function<void(const std::string&)>& okCallback, bool multiLine, const char* acceptBtnText)
: GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 3)), mMultiLine(multiLine)
GuiTextEditPopup::GuiTextEditPopup(Window *window, const std::string &title, const std::string &initValue,
const std::function<void(const std::string &)> &okCallback, bool multiLine, const char *acceptBtnText, const std::shared_ptr<ThemeData> &theme)
: GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 3)), mMultiLine(multiLine), mTheme(theme)
{
addChild(&mBackground);
addChild(&mGrid);
Expand Down Expand Up @@ -65,6 +65,17 @@ bool GuiTextEditPopup::input(InputConfig* config, Input input)
return false;
}

HelpStyle GuiTextEditPopup::getHelpStyle()
{
if (mTheme) {
HelpStyle style = HelpStyle();
style.applyTheme(mTheme, "system");
return style;
}

return GuiComponent::getHelpStyle();
}

std::vector<HelpPrompt> GuiTextEditPopup::getHelpPrompts()
{
std::vector<HelpPrompt> prompts = mGrid.getHelpPrompts();
Expand Down
Loading