Some cosmetic code changes.

This commit is contained in:
Leon Styhre 2020-07-13 20:58:25 +02:00
parent 40be69cd64
commit 57d6dab2cc
34 changed files with 142 additions and 152 deletions

View file

@ -17,9 +17,7 @@
class GuiGameScraper : public GuiComponent
{
public:
GuiGameScraper(
Window* window,
ScraperSearchParams params,
GuiGameScraper(Window* window, ScraperSearchParams params,
std::function<void(const ScraperSearchResult&)> doneFunc);
void onSizeChanged() override;

View file

@ -82,20 +82,17 @@ void BasicGameListView::setCursor(FileData* cursor)
// Update our cursor stack in case our cursor just
// got set to some folder we weren't in before.
if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent())
{
if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent()) {
std::stack<FileData*> tmp;
FileData* ptr = cursor->getParent();
while (ptr && ptr != mRoot)
{
while (ptr && ptr != mRoot) {
tmp.push(ptr);
ptr = ptr->getParent();
}
// Flip the stack and put it in mCursorStack.
mCursorStack = std::stack<FileData*>();
while (!tmp.empty())
{
while (!tmp.empty()) {
mCursorStack.push(tmp.top());
tmp.pop();
}
@ -205,8 +202,7 @@ std::vector<HelpPrompt> BasicGameListView::getHelpPrompts()
prompts.push_back(HelpPrompt("select", "options"));
if (mRoot->getSystem()->isGameSystem())
prompts.push_back(HelpPrompt("x", "random"));
if (mRoot->getSystem()->isGameSystem() && !UIModeController::getInstance()->isUIModeKid())
{
if (mRoot->getSystem()->isGameSystem() && !UIModeController::getInstance()->isUIModeKid()) {
std::string prompt = CollectionSystemManager::get()->getEditingCollection();
prompts.push_back(HelpPrompt("y", prompt));
}

View file

@ -274,8 +274,8 @@ void DetailedGameListView::updateInfoPanel()
for (auto it = comps.cbegin(); it != comps.cend(); it++) {
GuiComponent* comp = *it;
// An animation is playing, then animate if reverse != fadingOut
// An animation is not playing, then animate if opacity != our target opacity
// An animation is playing, then animate if reverse != fadingOut.
// An animation is not playing, then animate if opacity != our target opacity.
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) {

View file

@ -228,16 +228,16 @@ void GridGameListView::populateList(const std::vector<FileData*>& files)
for (auto it = files.cbegin(); it != files.cend(); it++)
mGrid.add((*it)->getName(), getImagePath(*it), *it);
}
else
else {
addPlaceholder();
}
}
void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
{
ISimpleGameListView::onThemeChanged(theme);
using namespace ThemeFlags;
mGrid.applyTheme(theme, getName(), "gamegrid", ALL);
mName.applyTheme(theme, getName(), "md_name", ALL);
mMarquee.applyTheme(theme, getName(), "md_marquee",
@ -354,19 +354,18 @@ void GridGameListView::updateInfoPanel()
FileData* file = (mGrid.size() == 0 || mGrid.isScrolling()) ? nullptr : mGrid.getSelected();
bool fadingOut;
if (file == nullptr)
{
if (file == nullptr) {
mVideo->setVideo("");
mVideo->setImage("");
mVideoPlaying = false;
fadingOut = true;
}else{
// Temporary fix to disable only audio from playing
}
else {
// Temporary fix to disable only audio from playing.
// if (!mVideo->setVideo(file->getVideoPath()))
// {
// mVideo->setDefaultVideo();
// }
// mVideoPlaying = true;
// mVideo->setImage(file->getThumbnailPath());
@ -403,8 +402,8 @@ void GridGameListView::updateInfoPanel()
for (auto it = comps.cbegin(); it != comps.cend(); it++) {
GuiComponent* comp = *it;
// An animation is playing, then animate if reverse != fadingOut
// An animation is not playing, then animate if opacity != our target opacity
// An animation is playing, then animate if reverse != fadingOut.
// An animation is not playing, then animate if opacity != our target opacity.
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) {

View file

@ -55,6 +55,7 @@ public:
virtual HelpStyle getHelpStyle() override;
void render(const Transform4x4f& parentTrans) override;
protected:
FileData* mRoot;
std::shared_ptr<ThemeData> mTheme;

View file

@ -47,8 +47,7 @@ void ISimpleGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme
mHeaderText.applyTheme(theme, getName(), "logoText", ALL);
// Remove old theme extras.
for (auto extra : mThemeExtras)
{
for (auto extra : mThemeExtras) {
removeChild(extra);
delete extra;
}
@ -78,8 +77,7 @@ void ISimpleGameListView::onFileChanged(FileData* /*file*/, FileChangeType /*cha
populateList(cursor->getParent()->getChildrenListToDisplay());
setCursor(cursor);
}
else
{
else {
populateList(mRoot->getChildrenListToDisplay());
setCursor(cursor);
}
@ -118,9 +116,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
onFocusLost();
SystemData* systemToView = getCursor()->getSystem();
if (systemToView->isCollection())
{
systemToView = CollectionSystemManager::get()->getSystemToView(systemToView);
}
ViewController::get()->goToSystemView(systemToView);
}

View file

@ -152,6 +152,6 @@ void AudioManager::stop()
if (sSoundVector.at(i)->isPlaying())
sSoundVector[i]->stop();
}
// Pause audio
// Pause audio.
SDL_PauseAudio(1);
}

View file

@ -379,8 +379,7 @@ void ThemeData::parseViews(const pugi::xml_node& root)
size_t prevOff = nameAttr.find_first_not_of(delim, 0);
size_t off = nameAttr.find_first_of(delim, prevOff);
std::string viewKey;
while (off != std::string::npos || prevOff != std::string::npos)
{
while (off != std::string::npos || prevOff != std::string::npos) {
viewKey = nameAttr.substr(prevOff, off - prevOff);
prevOff = nameAttr.find_first_not_of(delim, off);
off = nameAttr.find_first_of(delim, prevOff);