Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
Grouped systems : Fix Navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricecaruso committed Feb 29, 2020
1 parent d930fd4 commit 09936b0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
6 changes: 3 additions & 3 deletions es-app/src/views/ViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,12 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
system->updateDisplayedGameCount();

std::shared_ptr<IGameListView> newView = getGameListView(system);

// to counter having come from a placeholder
if (!cursor->isPlaceHolder())
if (cursor != nullptr && !cursor->isPlaceHolder() && system->getName() != "recent")
newView->setCursor(cursor);

if (isCurrent)
if(isCurrent)
mCurrentView = newView;

break;
Expand Down
31 changes: 24 additions & 7 deletions es-app/src/views/gamelist/GridGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,21 @@ const bool GridGameListView::isVirtualFolder(FileData* file)

void GridGameListView::populateList(const std::vector<FileData*>& files)
{
mGrid.clear();
mHeaderText.setText(mRoot->getSystem()->getFullName());
SystemData* system = mCursorStack.size() && mRoot->getSystem()->isGroupSystem() ? mCursorStack.top()->getSystem() : mRoot->getSystem();

auto groupTheme = system->getTheme();
if (groupTheme)
{
const ThemeData::ThemeElement* logoElem = groupTheme->getElement("system", "logo", "image");
if (logoElem && logoElem->has("path") && Utils::FileSystem::exists(logoElem->get<std::string>("path")))
mHeaderImage.setImage(logoElem->get<std::string>("path"));
}

mHeaderText.setText(system->getFullName());

mGrid.resetLastCursor();
mGrid.clear();
mGrid.resetLastCursor();

if (files.size() > 0)
{
Expand Down Expand Up @@ -277,18 +290,18 @@ void GridGameListView::populateList(const std::vector<FileData*>& files)
break;
}
}
}
}
}



FileData* placeholder = new FileData(PLACEHOLDER, "..", this->mRoot->getSystem());
mGrid.add(". .", imagePath, "", "", false, true, displayAsVirtualFolder && !imagePath.empty(), placeholder);
}

std::string systemName = mRoot->getSystem()->getFullName();
std::string systemShortName = mRoot->getSystem()->getName();
std::string systemName = mRoot->getSystem()->getName();

bool favoritesFirst = Settings::getInstance()->getBool("FavoritesFirst");
bool showFavoriteIcon = (systemName != "favorites" && systemShortName != "recent");
bool showFavoriteIcon = (systemName != "favorites" && systemName != "recent");
if (!showFavoriteIcon)
favoritesFirst = false;

Expand Down Expand Up @@ -320,6 +333,10 @@ void GridGameListView::populateList(const std::vector<FileData*>& files)
else
mGrid.add(file->getName(), getImagePath(file), file->getVideoPath(), file->getMarqueePath(), file->getFavorite(), file->getType() != GAME, isVirtualFolder(file), file);
}

// if we have the ".." PLACEHOLDER, then select the first game instead of the placeholder
if (mCursorStack.size() && mGrid.size() > 1 && mGrid.getCursorIndex() == 0)
mGrid.setCursorIndex(1);
}
else
{
Expand Down
13 changes: 6 additions & 7 deletions es-app/src/views/gamelist/ISimpleGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
mCursorStack.pop();

FolderData* folder = top->getParent();
if (folder == nullptr)
if (folder == nullptr && getCursor()->getSystem()->getParentGroupSystem() != nullptr)
folder = getCursor()->getSystem()->getParentGroupSystem()->getRootFolder();

if (folder == nullptr)
return true;

populateList(folder->getChildrenListToDisplay());
setCursor(top);
Sound::getFromTheme(getTheme(), getName(), "back")->play();
Expand Down Expand Up @@ -190,13 +193,9 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
}
else if (config->isMappedTo("y", input) && !UIModeController::getInstance()->isUIModeKid())
{
if(mRoot->getSystem()->isGameSystem())
{
if(CollectionSystemManager::get()->toggleGameInCollection(getCursor()))
{
if (mRoot->getSystem()->isGameSystem() || mRoot->getSystem()->isGroupSystem())
if (CollectionSystemManager::get()->toggleGameInCollection(getCursor()))
return true;
}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions es-core/src/components/ImageGridComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class ImageGridComponent : public IList<ImageGridData, T>

std::shared_ptr<GridTileComponent> getSelectedTile();

void resetLastCursor() { mLastCursor = -1; }

protected:
virtual void onCursorChanged(const CursorState& state) override;
virtual void onScroll(int /*amt*/) { if (!mScrollSound.empty()) Sound::get(mScrollSound)->play(); }
Expand Down

1 comment on commit 09936b0

@fabricecaruso
Copy link
Owner Author

Choose a reason for hiding this comment

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

Why comment an old commit to ask a question which is not related ?

1/ This fork is abandonned. I now work only on batocera-emulationstation fork which has many many evolutions ( for windows too )
2/ I don't use wsystem because it pops a "dos" command window, and will not change that. Instead, maybe there is a need to fix ShellExecute call in some conditions ( with ShellExecuteW ? ).

Please sign in to comment.