mirror of
https://github.com/wiiu-env/launchiine.git
synced 2024-11-22 09:49:17 +01:00
Option to sort the game list by name
This commit is contained in:
parent
c36dcb6728
commit
57a1a34bea
@ -14,6 +14,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
#include <gui/GuiIconGrid.h>
|
#include <gui/GuiIconGrid.h>
|
||||||
#include <gui/GuiController.h>
|
#include <gui/GuiController.h>
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
@ -23,8 +25,9 @@
|
|||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "gui/GameIcon.h"
|
#include "gui/GameIcon.h"
|
||||||
|
|
||||||
GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex)
|
GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex,bool sortByName)
|
||||||
: GuiTitleBrowser(w, h, GameIndex),
|
: GuiTitleBrowser(w, h, GameIndex),
|
||||||
|
sortByName(sortByName),
|
||||||
particleBgImage(w, h, 50, 60.0f, 90.0f, 0.6f, 1.0f)
|
particleBgImage(w, h, 50, 60.0f, 90.0f, 0.6f, 1.0f)
|
||||||
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
|
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
|
||||||
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
|
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
|
||||||
@ -57,7 +60,7 @@ void GuiIconGrid::setSelectedGame(uint64_t idx) {
|
|||||||
container = x.second;
|
container = x.second;
|
||||||
if(x.first == idx) {
|
if(x.first == idx) {
|
||||||
container->image->setSelected(true);
|
container->image->setSelected(true);
|
||||||
}else{
|
} else {
|
||||||
container->image->setSelected(false);
|
container->image->setSelected(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,9 +200,28 @@ void GuiIconGrid::updateButtonPositions() {
|
|||||||
int32_t col = 0, row = 0, listOff = 0;
|
int32_t col = 0, row = 0, listOff = 0;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
containerMutex.lock();
|
// create an empty vector of pairs
|
||||||
for (auto const& x : gameInfoContainers) {
|
std::vector<std::pair<uint64_t,GameInfoContainer*>> vec;
|
||||||
|
|
||||||
|
containerMutex.lock();
|
||||||
|
|
||||||
|
// copy key-value pairs from the map to the vector
|
||||||
|
std::copy(gameInfoContainers.begin(), gameInfoContainers.end(), std::back_inserter<std::vector<std::pair<uint64_t,GameInfoContainer*>>>(vec));
|
||||||
|
|
||||||
|
containerMutex.unlock();
|
||||||
|
|
||||||
|
if(sortByName) {
|
||||||
|
std::sort(vec.begin(), vec.end(),
|
||||||
|
[](const std::pair<uint64_t,GameInfoContainer*>& l, const std::pair<uint64_t,GameInfoContainer*>& r) {
|
||||||
|
if (l.second != r.second)
|
||||||
|
return l.second->info->name.compare(r.second->info->name) <0;
|
||||||
|
|
||||||
|
return l.first < r.first;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (auto const& x : vec) {
|
||||||
listOff = i / (MAX_COLS * MAX_ROWS);
|
listOff = i / (MAX_COLS * MAX_ROWS);
|
||||||
|
|
||||||
float posX = currentLeftPosition + listOff * width + ( col * (noIcon.getWidth() + noIcon.getWidth() * 0.5f) - (MAX_COLS * 0.5f - 0.5f) * (noIcon.getWidth() + noIcon.getWidth() * 0.5f) );
|
float posX = currentLeftPosition + listOff * width + ( col * (noIcon.getWidth() + noIcon.getWidth() * 0.5f) - (MAX_COLS * 0.5f - 0.5f) * (noIcon.getWidth() + noIcon.getWidth() * 0.5f) );
|
||||||
@ -219,7 +241,7 @@ void GuiIconGrid::updateButtonPositions() {
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
containerMutex.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiIconGrid::draw(CVideo *pVideo) {
|
void GuiIconGrid::draw(CVideo *pVideo) {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
class GuiIconGrid : public GuiTitleBrowser, public sigslot::has_slots<> {
|
class GuiIconGrid : public GuiTitleBrowser, public sigslot::has_slots<> {
|
||||||
public:
|
public:
|
||||||
GuiIconGrid(int32_t w, int32_t h, uint64_t selectedTitleId);
|
GuiIconGrid(int32_t w, int32_t h, uint64_t selectedTitleId, bool sortByName);
|
||||||
virtual ~GuiIconGrid();
|
virtual ~GuiIconGrid();
|
||||||
|
|
||||||
void setSelectedGame(uint64_t idx);
|
void setSelectedGame(uint64_t idx);
|
||||||
@ -62,6 +62,7 @@ private:
|
|||||||
int32_t targetLeftPosition;
|
int32_t targetLeftPosition;
|
||||||
uint32_t gameLaunchTimer;
|
uint32_t gameLaunchTimer;
|
||||||
bool bUpdatePositions = false;
|
bool bUpdatePositions = false;
|
||||||
|
bool sortByName = false;
|
||||||
|
|
||||||
class GameInfoContainer {
|
class GameInfoContainer {
|
||||||
public:
|
public:
|
||||||
|
@ -202,7 +202,7 @@ void MainWindow::drawTv(CVideo *video) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::SetupMainView() {
|
void MainWindow::SetupMainView() {
|
||||||
currentTvFrame = new GuiIconGrid(width, height,0);
|
currentTvFrame = new GuiIconGrid(width, height,0, true);
|
||||||
|
|
||||||
currentTvFrame->setEffect(EFFECT_FADE, 10, 255);
|
currentTvFrame->setEffect(EFFECT_FADE, 10, 255);
|
||||||
currentTvFrame->setState(GuiElement::STATE_DISABLED);
|
currentTvFrame->setState(GuiElement::STATE_DISABLED);
|
||||||
@ -210,7 +210,7 @@ void MainWindow::SetupMainView() {
|
|||||||
|
|
||||||
appendTv(currentTvFrame);
|
appendTv(currentTvFrame);
|
||||||
|
|
||||||
currentDrcFrame = new GuiIconGrid(width, height,0);
|
currentDrcFrame = new GuiIconGrid(width, height,0, false);
|
||||||
currentDrcFrame->setEffect(EFFECT_FADE, 10, 255);
|
currentDrcFrame->setEffect(EFFECT_FADE, 10, 255);
|
||||||
currentDrcFrame->setState(GuiElement::STATE_DISABLED);
|
currentDrcFrame->setState(GuiElement::STATE_DISABLED);
|
||||||
currentDrcFrame->effectFinished.connect(this, &MainWindow::OnOpenEffectFinish);
|
currentDrcFrame->effectFinished.connect(this, &MainWindow::OnOpenEffectFinish);
|
||||||
@ -239,6 +239,7 @@ void MainWindow::SetupMainView() {
|
|||||||
mainSwitchButtonFrame = new MainDrcButtonsFrame(width, height);
|
mainSwitchButtonFrame = new MainDrcButtonsFrame(width, height);
|
||||||
mainSwitchButtonFrame->settingsButtonClicked.connect(this, &MainWindow::OnSettingsButtonClicked);
|
mainSwitchButtonFrame->settingsButtonClicked.connect(this, &MainWindow::OnSettingsButtonClicked);
|
||||||
mainSwitchButtonFrame->layoutSwitchClicked.connect(this, &MainWindow::OnLayoutSwitchClicked);
|
mainSwitchButtonFrame->layoutSwitchClicked.connect(this, &MainWindow::OnLayoutSwitchClicked);
|
||||||
|
mainSwitchButtonFrame->gameListFilterClicked.connect(this, &MainWindow::OnGameListFilterButtonClicked);
|
||||||
mainSwitchButtonFrame->setState(GuiElement::STATE_DISABLED);
|
mainSwitchButtonFrame->setState(GuiElement::STATE_DISABLED);
|
||||||
mainSwitchButtonFrame->setEffect(EFFECT_FADE, 10, 255);
|
mainSwitchButtonFrame->setEffect(EFFECT_FADE, 10, 255);
|
||||||
mainSwitchButtonFrame->setState(GuiElement::STATE_DISABLED);
|
mainSwitchButtonFrame->setState(GuiElement::STATE_DISABLED);
|
||||||
|
Loading…
Reference in New Issue
Block a user