Implement basic title loading

This commit is contained in:
Maschell 2020-02-21 21:37:32 +01:00
parent 6c0c6387b6
commit 1cced24ea6
2 changed files with 32 additions and 6 deletions

View File

@ -211,6 +211,7 @@ void GuiIconGrid::OnGameTitleListUpdated(GameList * gameList) {
gameList->unlock();
setSelectedGame(0);
gameSelectionChanged(this, selectedGame);
curPage = 0;
currentLeftPosition = 0;
bUpdatePositions = true;
@ -230,7 +231,7 @@ void GuiIconGrid::OnRightArrowClick(GuiButton *button, const GuiController *cont
void GuiIconGrid::OnLeftClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
int32_t offset = offsetForTitleId(getSelectedGame());
if(offset < 0){
if(offset < 0) {
return;
}
if((offset % MAX_COLS) == 0) {
@ -244,13 +245,14 @@ void GuiIconGrid::OnLeftClick(GuiButton *button, const GuiController *controller
uint64_t newTitleId = position.at(offset);
if(newTitleId > 0) {
setSelectedGame(newTitleId);
gameSelectionChanged(this, selectedGame);
}
}
void GuiIconGrid::OnRightClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
int32_t offset = offsetForTitleId(getSelectedGame());
if(offset < 0){
if(offset < 0) {
return;
}
if((offset % MAX_COLS) == MAX_COLS - 1) {
@ -264,12 +266,13 @@ void GuiIconGrid::OnRightClick(GuiButton *button, const GuiController *controlle
uint64_t newTitleId = position.at(offset);
if(newTitleId > 0) {
setSelectedGame(newTitleId);
gameSelectionChanged(this, selectedGame);
}
}
void GuiIconGrid::OnDownClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
int32_t offset = offsetForTitleId(getSelectedGame());
if(offset < 0){
if(offset < 0) {
return;
}
if(offset % (MAX_COLS * MAX_ROWS) < (MAX_COLS * MAX_ROWS) - MAX_COLS) {
@ -284,11 +287,12 @@ void GuiIconGrid::OnDownClick(GuiButton *button, const GuiController *controller
uint64_t newTitleId = position.at(offset);
if(newTitleId > 0) {
setSelectedGame(newTitleId);
gameSelectionChanged(this, selectedGame);
}
}
void GuiIconGrid::OnUpClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
int32_t offset = offsetForTitleId(getSelectedGame());
if(offset < 0){
if(offset < 0) {
return;
}
if(offset % (MAX_COLS * MAX_ROWS) >= MAX_COLS) {
@ -303,6 +307,7 @@ void GuiIconGrid::OnUpClick(GuiButton *button, const GuiController *controller,
uint64_t newTitleId = position.at(offset);
if(newTitleId > 0) {
setSelectedGame(newTitleId);
gameSelectionChanged(this, selectedGame);
}
}

View File

@ -24,6 +24,7 @@
#include "gui/GuiIconGrid.h"
#include <sysapp/launch.h>
#include <future>
#include <coreinit/title.h>
#include "utils/AsyncExecutor.h"
MainWindow::MainWindow(int32_t w, int32_t h)
@ -120,7 +121,7 @@ void MainWindow::process() {
mainSwitchButtonFrame->clearState(GuiElement::STATE_DISABLED);
gameList.filterList(result.c_str());
}else{
} else {
}
}
}
@ -371,6 +372,26 @@ void MainWindow::OnGameSelectionChange(GuiTitleBrowser *element, uint64_t select
}
}
void MainWindow::OnGameLaunch(GuiTitleBrowser *element, uint64_t selectedIdx) {
#define HBL_TITLE_ID (0x0005000013374842)
#define MII_MAKER_JPN_TITLE_ID (0x000500101004A000)
#define MII_MAKER_USA_TITLE_ID (0x000500101004A100)
#define MII_MAKER_EUR_TITLE_ID (0x000500101004A200)
extern "C" void _SYSLaunchTitleByPathFromLauncher(const char * path, int len, int);
void MainWindow::OnGameLaunch(GuiTitleBrowser *element, uint64_t titleID) {
gameInfo * info = gameList.getGameInfo(titleID);
if(info != NULL) {
uint64_t titleID = OSGetTitleID();
if (titleID == HBL_TITLE_ID ||
titleID == MII_MAKER_JPN_TITLE_ID ||
titleID == MII_MAKER_USA_TITLE_ID ||
titleID == MII_MAKER_EUR_TITLE_ID) {
SYSLaunchTitle(info->titleId);
} else {
const char* path = info->gamePath.c_str();
_SYSLaunchTitleByPathFromLauncher(path, strlen(path),0);
}
}
}