mirror of
https://github.com/wiiu-env/launchiine.git
synced 2024-11-21 17:29:18 +01:00
Fix compiling with latest wut, formatting, remove hbl support
This commit is contained in:
parent
ed61489bda
commit
02d34db212
2
Makefile
2
Makefile
@ -17,7 +17,7 @@ include $(DEVKITPRO)/wut/share/wut_rules
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#-------------------------------------------------------------------------------
|
||||
TARGET := launchiine
|
||||
TARGET := men
|
||||
BUILD := build
|
||||
SOURCES := src \
|
||||
src/fs \
|
||||
|
@ -31,22 +31,12 @@
|
||||
#include "utils/AsyncExecutor.h"
|
||||
#include <thread>
|
||||
|
||||
#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)
|
||||
|
||||
Application *Application::applicationInstance = NULL;
|
||||
Application *Application::applicationInstance = nullptr;
|
||||
bool Application::exitApplication = false;
|
||||
bool Application::quitRequest = false;
|
||||
|
||||
Application::Application()
|
||||
: CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x800000)
|
||||
, bgMusic(NULL)
|
||||
, video(NULL)
|
||||
, mainWindow(NULL)
|
||||
, fontSystem(NULL)
|
||||
, exitCode(0) {
|
||||
: CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x800000), bgMusic(nullptr), video(nullptr), mainWindow(nullptr), fontSystem(nullptr), exitCode(0) {
|
||||
controller[0] = new VPadController(GuiTrigger::CHANNEL_1);
|
||||
controller[1] = new WPadController(GuiTrigger::CHANNEL_2);
|
||||
controller[2] = new WPadController(GuiTrigger::CHANNEL_3);
|
||||
@ -59,43 +49,30 @@ Application::Application()
|
||||
bgMusic->Play();
|
||||
bgMusic->SetVolume(50);
|
||||
|
||||
AsyncExecutor::execute([] {DEBUG_FUNCTION_LINE("Hello\n");});
|
||||
AsyncExecutor::execute([] { DEBUG_FUNCTION_LINE("Hello"); });
|
||||
|
||||
exitApplication = false;
|
||||
|
||||
uint64_t titleID = OSGetTitleID();
|
||||
|
||||
// Homebrew Launcher does not like the standard ProcUI application loop,
|
||||
// so instead we disable the home buttom menu and use the home button
|
||||
// to trigger an exit.
|
||||
if (titleID == HBL_TITLE_ID ||
|
||||
titleID == MII_MAKER_JPN_TITLE_ID ||
|
||||
titleID == MII_MAKER_USA_TITLE_ID ||
|
||||
titleID == MII_MAKER_EUR_TITLE_ID) {
|
||||
// Important: OSEnableHomeButtonMenu must come before ProcUIInitEx.
|
||||
OSEnableHomeButtonMenu(FALSE);
|
||||
sFromHBL = TRUE;
|
||||
}
|
||||
|
||||
ProcUIInit(OSSavesDone_ReadyToRelease);
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
DEBUG_FUNCTION_LINE("Destroy music\n");
|
||||
DEBUG_FUNCTION_LINE("Destroy music");
|
||||
delete bgMusic;
|
||||
|
||||
DEBUG_FUNCTION_LINE("Destroy controller\n");
|
||||
DEBUG_FUNCTION_LINE("Destroy controller");
|
||||
|
||||
for(int32_t i = 0; i < 5; i++)
|
||||
delete controller[i];
|
||||
for (auto &i: controller) {
|
||||
delete i;
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Clear resources\n");
|
||||
DEBUG_FUNCTION_LINE("Clear resources");
|
||||
Resources::Clear();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Stop sound handler\n");
|
||||
DEBUG_FUNCTION_LINE("Stop sound handler");
|
||||
SoundHandler::DestroyInstance();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Clear AsyncExecutor\n");
|
||||
DEBUG_FUNCTION_LINE("Clear AsyncExecutor");
|
||||
AsyncExecutor::destroyInstance();
|
||||
|
||||
ProcUIShutdown();
|
||||
@ -155,32 +132,32 @@ void Application::fadeOut() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Application::procUI(void) {
|
||||
bool Application::procUI() {
|
||||
bool executeProcess = false;
|
||||
|
||||
switch (ProcUIProcessMessages(true)) {
|
||||
case PROCUI_STATUS_EXITING: {
|
||||
DEBUG_FUNCTION_LINE("PROCUI_STATUS_EXITING\n");
|
||||
DEBUG_FUNCTION_LINE("PROCUI_STATUS_EXITING");
|
||||
exitCode = EXIT_SUCCESS;
|
||||
exitApplication = true;
|
||||
break;
|
||||
}
|
||||
case PROCUI_STATUS_RELEASE_FOREGROUND: {
|
||||
DEBUG_FUNCTION_LINE("PROCUI_STATUS_RELEASE_FOREGROUND\n");
|
||||
if(video != NULL) {
|
||||
DEBUG_FUNCTION_LINE("PROCUI_STATUS_RELEASE_FOREGROUND");
|
||||
if (video != nullptr) {
|
||||
// we can turn ofF the screen but we don't need to and it will display the last image
|
||||
video->tvEnable(true);
|
||||
video->drcEnable(true);
|
||||
|
||||
DEBUG_FUNCTION_LINE("delete fontSystem\n");
|
||||
DEBUG_FUNCTION_LINE("delete fontSystem");
|
||||
delete fontSystem;
|
||||
fontSystem = NULL;
|
||||
fontSystem = nullptr;
|
||||
|
||||
DEBUG_FUNCTION_LINE("delete video\n");
|
||||
DEBUG_FUNCTION_LINE("delete video");
|
||||
delete video;
|
||||
video = NULL;
|
||||
video = nullptr;
|
||||
|
||||
DEBUG_FUNCTION_LINE("deinitialze memory\n");
|
||||
DEBUG_FUNCTION_LINE("deinitialze memory");
|
||||
libgui_memoryRelease();
|
||||
ProcUIDrawDoneRelease();
|
||||
} else {
|
||||
@ -190,22 +167,22 @@ bool Application::procUI(void) {
|
||||
}
|
||||
case PROCUI_STATUS_IN_FOREGROUND: {
|
||||
if (!quitRequest) {
|
||||
if(video == NULL) {
|
||||
DEBUG_FUNCTION_LINE("PROCUI_STATUS_IN_FOREGROUND\n");
|
||||
DEBUG_FUNCTION_LINE("initialze memory\n");
|
||||
if (video == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("PROCUI_STATUS_IN_FOREGROUND");
|
||||
DEBUG_FUNCTION_LINE("initialze memory");
|
||||
libgui_memoryInitialize();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Initialize video\n");
|
||||
DEBUG_FUNCTION_LINE("Initialize video");
|
||||
video = new CVideo(GX2_TV_SCAN_MODE_720P, GX2_DRC_RENDER_MODE_SINGLE);
|
||||
DEBUG_FUNCTION_LINE("Video size %i x %i\n", video->getTvWidth(), video->getTvHeight());
|
||||
DEBUG_FUNCTION_LINE("Video size %i x %i", video->getTvWidth(), video->getTvHeight());
|
||||
|
||||
//! setup default Font
|
||||
DEBUG_FUNCTION_LINE("Initialize main font system\n");
|
||||
FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true);
|
||||
DEBUG_FUNCTION_LINE("Initialize main font system");
|
||||
auto *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true);
|
||||
GuiText::setPresetFont(fontSystem);
|
||||
|
||||
if(mainWindow == NULL) {
|
||||
DEBUG_FUNCTION_LINE("Initialize main window\n");
|
||||
if (mainWindow == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Initialize main window");
|
||||
mainWindow = new MainWindow(video->getTvWidth(), video->getTvHeight());
|
||||
}
|
||||
|
||||
@ -222,12 +199,12 @@ bool Application::procUI(void) {
|
||||
return executeProcess;
|
||||
}
|
||||
|
||||
void Application::executeThread(void) {
|
||||
DEBUG_FUNCTION_LINE("Entering main loop\n");
|
||||
void Application::executeThread() {
|
||||
DEBUG_FUNCTION_LINE("Entering main loop");
|
||||
|
||||
//! main GX2 loop (60 Hz cycle with max priority on core 1)
|
||||
while (!exitApplication) {
|
||||
if(procUI() == false) {
|
||||
if (!procUI()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -235,20 +212,12 @@ void Application::executeThread(void) {
|
||||
mainWindow->process();
|
||||
|
||||
//! Read out inputs
|
||||
for(int32_t i = 0; i < 5; i++) {
|
||||
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
|
||||
for (auto &i: controller) {
|
||||
if (!i->update(video->getTvWidth(), video->getTvHeight()))
|
||||
continue;
|
||||
|
||||
//! update controller states
|
||||
mainWindow->update(controller[i]);
|
||||
|
||||
if(controller[i]->data.buttons_d & VPAD_BUTTON_HOME) {
|
||||
if (sFromHBL) {
|
||||
fadeOut();
|
||||
SYSRelaunchTitle(0, NULL);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
mainWindow->update(i);
|
||||
}
|
||||
|
||||
//! start rendering DRC
|
||||
@ -278,29 +247,18 @@ void Application::executeThread(void) {
|
||||
bgMusic->SetVolume(0);
|
||||
}
|
||||
|
||||
//! in case we exit to a homebrew let's smoothly fade out
|
||||
if(video) {
|
||||
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) {
|
||||
fadeOut();
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("delete mainWindow\n");
|
||||
DEBUG_FUNCTION_LINE("delete mainWindow");
|
||||
delete mainWindow;
|
||||
mainWindow = NULL;
|
||||
mainWindow = nullptr;
|
||||
|
||||
DEBUG_FUNCTION_LINE("delete fontSystem\n");
|
||||
DEBUG_FUNCTION_LINE("delete fontSystem");
|
||||
delete fontSystem;
|
||||
fontSystem = NULL;
|
||||
fontSystem = nullptr;
|
||||
|
||||
DEBUG_FUNCTION_LINE("delete video\n");
|
||||
DEBUG_FUNCTION_LINE("delete video");
|
||||
delete video;
|
||||
video = NULL;
|
||||
video = nullptr;
|
||||
|
||||
DEBUG_FUNCTION_LINE("deinitialize memory\n");
|
||||
DEBUG_FUNCTION_LINE("deinitialize memory");
|
||||
libgui_memoryRelease();
|
||||
}
|
||||
|
@ -31,16 +31,18 @@ public:
|
||||
applicationInstance = new Application();
|
||||
return applicationInstance;
|
||||
}
|
||||
|
||||
static void destroyInstance() {
|
||||
if (applicationInstance) {
|
||||
delete applicationInstance;
|
||||
applicationInstance = NULL;
|
||||
applicationInstance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
CVideo *getVideo(void) const {
|
||||
return video;
|
||||
}
|
||||
|
||||
MainWindow *getMainWindow(void) const {
|
||||
return mainWindow;
|
||||
}
|
||||
@ -50,12 +52,14 @@ public:
|
||||
}
|
||||
|
||||
int exec(void);
|
||||
|
||||
void fadeOut(void);
|
||||
|
||||
void quit(int code);
|
||||
|
||||
private:
|
||||
Application();
|
||||
|
||||
virtual ~Application();
|
||||
|
||||
bool procUI(void);
|
||||
@ -70,7 +74,7 @@ private:
|
||||
CVideo *video;
|
||||
MainWindow *mainWindow;
|
||||
FreeTypeGX *fontSystem;
|
||||
GuiController *controller[5];
|
||||
GuiController *controller[5]{};
|
||||
int exitCode;
|
||||
BOOL sFromHBL = FALSE;
|
||||
|
||||
|
@ -1,20 +1,39 @@
|
||||
#include <string.h>
|
||||
#include <nsysnet/socket.h>
|
||||
#include "utils/logger.h"
|
||||
#include "common/common.h"
|
||||
#include <whb/log_cafe.h>
|
||||
#include <whb/log_udp.h>
|
||||
#include <whb/log_module.h>
|
||||
#include "utils/logger.h"
|
||||
#include "Application.h"
|
||||
|
||||
int32_t main(int32_t argc, char **argv) {
|
||||
socket_lib_init();
|
||||
log_init();
|
||||
DEBUG_FUNCTION_LINE("Starting launchiine " LAUNCHIINE_VERSION "\n");
|
||||
bool moduleInit;
|
||||
bool cafeInit = false;
|
||||
bool udpInit = false;
|
||||
|
||||
DEBUG_FUNCTION_LINE("Start main application\n");
|
||||
if (!(moduleInit = WHBLogModuleInit())) {
|
||||
cafeInit = WHBLogCafeInit();
|
||||
udpInit = WHBLogUdpInit();
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Starting launchiine " LAUNCHIINE_VERSION "");
|
||||
|
||||
DEBUG_FUNCTION_LINE("Start main application");
|
||||
Application::instance()->exec();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Main application stopped\n");
|
||||
DEBUG_FUNCTION_LINE("Main application stopped");
|
||||
Application::destroyInstance();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Peace out...\n");
|
||||
DEBUG_FUNCTION_LINE("Peace out...");
|
||||
|
||||
if (cafeInit) {
|
||||
WHBLogCafeDeinit();
|
||||
}
|
||||
|
||||
if (udpInit) {
|
||||
WHBLogUdpDeinit();
|
||||
}
|
||||
|
||||
if (moduleInit) {
|
||||
WHBLogModuleDeinit();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
CFile::CFile() {
|
||||
iFd = -1;
|
||||
mem_file = NULL;
|
||||
mem_file = nullptr;
|
||||
filesize = 0;
|
||||
pos = 0;
|
||||
}
|
||||
@ -78,7 +78,7 @@ void CFile::close() {
|
||||
::close(iFd);
|
||||
|
||||
iFd = -1;
|
||||
mem_file = NULL;
|
||||
mem_file = nullptr;
|
||||
filesize = 0;
|
||||
pos = 0;
|
||||
}
|
||||
@ -99,7 +99,7 @@ int32_t CFile::read(uint8_t * ptr, size_t size) {
|
||||
if (readsize <= 0)
|
||||
return readsize;
|
||||
|
||||
if(mem_file != NULL) {
|
||||
if (mem_file != nullptr) {
|
||||
memcpy(ptr, mem_file + pos, readsize);
|
||||
pos += readsize;
|
||||
return readsize;
|
||||
@ -147,7 +147,7 @@ int32_t CFile::seek(long int offset, int32_t origin) {
|
||||
if (iFd >= 0)
|
||||
ret = ::lseek(iFd, pos, SEEK_SET);
|
||||
|
||||
if(mem_file != NULL) {
|
||||
if (mem_file != nullptr) {
|
||||
if (pos > filesize) {
|
||||
pos = filesize;
|
||||
}
|
||||
|
@ -18,11 +18,15 @@ public:
|
||||
};
|
||||
|
||||
CFile();
|
||||
|
||||
CFile(const std::string &filepath, eOpenTypes mode);
|
||||
|
||||
CFile(const uint8_t *memory, int32_t memsize);
|
||||
|
||||
virtual ~CFile();
|
||||
|
||||
int32_t open(const std::string &filepath, eOpenTypes mode);
|
||||
|
||||
int32_t open(const uint8_t *memory, int32_t memsize);
|
||||
|
||||
BOOL isOpen() const {
|
||||
@ -38,15 +42,21 @@ public:
|
||||
void close();
|
||||
|
||||
int32_t read(uint8_t *ptr, size_t size);
|
||||
|
||||
int32_t write(const uint8_t *ptr, size_t size);
|
||||
|
||||
int32_t fwrite(const char *format, ...);
|
||||
|
||||
int32_t seek(long int offset, int32_t origin);
|
||||
|
||||
uint64_t tell() {
|
||||
return pos;
|
||||
};
|
||||
|
||||
uint64_t size() {
|
||||
return filesize;
|
||||
};
|
||||
|
||||
void rewind() {
|
||||
this->seek(0, SEEK_SET);
|
||||
};
|
||||
|
@ -81,11 +81,11 @@ BOOL DirList::InternalLoadPath(std::string &folderpath) {
|
||||
if (folderpath.size() < 3)
|
||||
return false;
|
||||
|
||||
struct dirent *dirent = NULL;
|
||||
DIR *dir = NULL;
|
||||
struct dirent *dirent = nullptr;
|
||||
DIR *dir = nullptr;
|
||||
|
||||
dir = opendir(folderpath.c_str());
|
||||
if (dir == NULL)
|
||||
if (dir == nullptr)
|
||||
return false;
|
||||
|
||||
while ((dirent = readdir(dir)) != 0) {
|
||||
@ -153,7 +153,7 @@ void DirList::ClearList() {
|
||||
for (uint32_t i = 0; i < FileInfo.size(); ++i) {
|
||||
if (FileInfo[i].FilePath) {
|
||||
free(FileInfo[i].FilePath);
|
||||
FileInfo[i].FilePath = NULL;
|
||||
FileInfo[i].FilePath = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,17 +40,22 @@ class DirList {
|
||||
public:
|
||||
//!Constructor
|
||||
DirList(void);
|
||||
|
||||
//!\param path Path from where to load the filelist of all files
|
||||
//!\param filter A fileext that needs to be filtered
|
||||
//!\param flags search/filter flags from the enum
|
||||
DirList(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
||||
DirList(const std::string &path, const char *filter = nullptr, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
||||
|
||||
//!Destructor
|
||||
virtual ~DirList();
|
||||
|
||||
//! Load all the files from a directory
|
||||
BOOL LoadPath(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
||||
BOOL LoadPath(const std::string &path, const char *filter = nullptr, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
||||
|
||||
//! Get a filename of the list
|
||||
//!\param list index
|
||||
const char *GetFilename(int32_t index) const;
|
||||
|
||||
//! Get the a filepath of the list
|
||||
//!\param list index
|
||||
const char *GetFilepath(int32_t index) const {
|
||||
@ -59,9 +64,11 @@ public:
|
||||
else
|
||||
return FileInfo[index].FilePath;
|
||||
}
|
||||
|
||||
//! Get the a filesize of the list
|
||||
//!\param list index
|
||||
uint64_t GetFilesize(int32_t index) const;
|
||||
|
||||
//! Is index a dir or a file
|
||||
//!\param list index
|
||||
BOOL IsDir(int32_t index) const {
|
||||
@ -69,16 +76,21 @@ public:
|
||||
return false;
|
||||
return FileInfo[index].isDir;
|
||||
};
|
||||
|
||||
//! Get the filecount of the whole list
|
||||
int32_t GetFilecount() const {
|
||||
return FileInfo.size();
|
||||
};
|
||||
|
||||
//! Sort list by filepath
|
||||
void SortList();
|
||||
|
||||
//! Custom sort command for custom sort functions definitions
|
||||
void SortList(BOOL (*SortFunc)(const DirEntry &a, const DirEntry &b));
|
||||
|
||||
//! Get the index of the specified filename
|
||||
int32_t GetFileIndex(const char *filename) const;
|
||||
|
||||
//! Enum for search/filter flags
|
||||
enum {
|
||||
Files = 0x01,
|
||||
@ -88,10 +100,13 @@ public:
|
||||
protected:
|
||||
// Internal parser
|
||||
BOOL InternalLoadPath(std::string &path);
|
||||
|
||||
//!Add a list entrie
|
||||
void AddEntrie(const std::string &filepath, const char *filename, BOOL isDir);
|
||||
|
||||
//! Clear the list
|
||||
void ClearList();
|
||||
|
||||
//! Check if valid pos is requested
|
||||
inline BOOL valid(uint32_t pos) const {
|
||||
return (pos < FileInfo.size());
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
|
||||
//! always initialze input
|
||||
*inbuffer = NULL;
|
||||
*inbuffer = nullptr;
|
||||
if (size)
|
||||
*size = 0;
|
||||
|
||||
@ -21,7 +21,7 @@ int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_
|
||||
lseek(iFd, 0, SEEK_SET);
|
||||
|
||||
uint8_t *buffer = (uint8_t *) malloc(filesize);
|
||||
if (buffer == NULL) {
|
||||
if (buffer == nullptr) {
|
||||
close(iFd);
|
||||
return -2;
|
||||
}
|
||||
@ -44,7 +44,7 @@ int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_
|
||||
|
||||
if (done != filesize) {
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
buffer = nullptr;
|
||||
return -3;
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ int32_t FSUtils::CreateSubfolder(const char * fullpath) {
|
||||
int32_t FSUtils::saveBufferToFile(const char *path, void *buffer, uint32_t size) {
|
||||
CFile file(path, CFile::WriteOnly);
|
||||
if (!file.isOpen()) {
|
||||
DEBUG_FUNCTION_LINE("Failed to open %s\n",path);
|
||||
DEBUG_FUNCTION_LINE("Failed to open %s", path);
|
||||
return 0;
|
||||
}
|
||||
int32_t written = file.write((const uint8_t *) buffer, size);
|
||||
|
@ -9,7 +9,9 @@ public:
|
||||
|
||||
//! todo: C++ class
|
||||
static int32_t CreateSubfolder(const char *fullpath);
|
||||
|
||||
static int32_t CheckFile(const char *filepath);
|
||||
|
||||
static int32_t saveBufferToFile(const char *path, void *buffer, uint32_t size);
|
||||
};
|
||||
|
||||
|
@ -25,10 +25,10 @@ GameList::~GameList() {
|
||||
void GameList::clear() {
|
||||
lock();
|
||||
for (auto const &x: fullGameList) {
|
||||
if(x != NULL) {
|
||||
if(x->imageData != NULL) {
|
||||
if (x != nullptr) {
|
||||
if (x->imageData != nullptr) {
|
||||
AsyncExecutor::pushForDelete(x->imageData);
|
||||
x->imageData = NULL;
|
||||
x->imageData = nullptr;
|
||||
}
|
||||
delete x;
|
||||
}
|
||||
@ -41,7 +41,7 @@ void GameList::clear() {
|
||||
}
|
||||
|
||||
gameInfo *GameList::getGameInfo(uint64_t titleId) {
|
||||
gameInfo * result = NULL;
|
||||
gameInfo *result = nullptr;
|
||||
lock();
|
||||
for (uint32_t i = 0; i < fullGameList.size(); ++i) {
|
||||
if (titleId == fullGameList[i]->titleId) {
|
||||
@ -107,12 +107,12 @@ int32_t GameList::readGameList() {
|
||||
}
|
||||
|
||||
for (auto title_candidate: titles) {
|
||||
gameInfo* newGameInfo = new gameInfo;
|
||||
auto *newGameInfo = new gameInfo;
|
||||
newGameInfo->titleId = title_candidate.titleId;
|
||||
newGameInfo->appType = title_candidate.appType;
|
||||
newGameInfo->gamePath = title_candidate.path;
|
||||
newGameInfo->name = "<unknown>";
|
||||
newGameInfo->imageData = NULL;
|
||||
newGameInfo->imageData = nullptr;
|
||||
DCFlushRange(newGameInfo, sizeof(gameInfo));
|
||||
|
||||
fullGameList.push_back(newGameInfo);
|
||||
@ -122,17 +122,15 @@ int32_t GameList::readGameList() {
|
||||
|
||||
AsyncExecutor::execute([this] {
|
||||
lock();
|
||||
for (uint32_t i = 0; i < fullGameList.size(); ++i) {
|
||||
gameInfo *header = fullGameList[i];
|
||||
|
||||
for (auto header : fullGameList) {
|
||||
DCFlushRange(&stopAsyncLoading, sizeof(stopAsyncLoading));
|
||||
if (stopAsyncLoading) {
|
||||
DEBUG_FUNCTION_LINE("Stop async title loading\n");
|
||||
DEBUG_FUNCTION_LINE("Stop async title loading");
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Load extra infos of %016llX\n",header->titleId);
|
||||
ACPMetaXml* meta = (ACPMetaXml*)calloc(1, 0x4000); //TODO fix wut
|
||||
DEBUG_FUNCTION_LINE("Load extra infos of %016llX", header->titleId);
|
||||
auto *meta = (ACPMetaXml *) calloc(1, 0x4000); //TODO fix wut
|
||||
if (meta) {
|
||||
auto acp = ACPGetTitleMetaXml(header->titleId, meta);
|
||||
if (acp >= 0) {
|
||||
@ -141,16 +139,14 @@ int32_t GameList::readGameList() {
|
||||
free(meta);
|
||||
}
|
||||
|
||||
if(header->imageData == NULL) {
|
||||
if (header->imageData == nullptr) {
|
||||
std::string filepath = "fs:" + header->gamePath + META_PATH + "/iconTex.tga";
|
||||
uint8_t *buffer = NULL;
|
||||
uint8_t *buffer = nullptr;
|
||||
uint32_t bufferSize = 0;
|
||||
int iResult = FSUtils::LoadFileToMem(filepath.c_str(), &buffer, &bufferSize);
|
||||
if (iResult > 0) {
|
||||
GuiImageData * imageData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR);
|
||||
if(imageData) {
|
||||
auto *imageData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR);
|
||||
header->imageData = imageData;
|
||||
}
|
||||
|
||||
//! free original image buffer which is converted to texture now and not needed anymore
|
||||
free(buffer);
|
||||
@ -172,7 +168,7 @@ void GameList::updateTitleInfo() {
|
||||
bool hasChanged = false;
|
||||
|
||||
if (newHeader->name.empty()) {
|
||||
ACPMetaXml* meta = (ACPMetaXml*)calloc(1, 0x4000); //TODO fix wut
|
||||
auto *meta = (ACPMetaXml *) calloc(1, 0x4000); //TODO fix wut
|
||||
if (meta) {
|
||||
auto acp = ACPGetTitleMetaXml(newHeader->titleId, meta);
|
||||
if (acp >= 0) {
|
||||
@ -183,18 +179,16 @@ void GameList::updateTitleInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
if(newHeader->imageData == NULL) {
|
||||
if (newHeader->imageData == nullptr) {
|
||||
std::string filepath = "fs:" + newHeader->gamePath + META_PATH + "/iconTex.tga";
|
||||
uint8_t *buffer = NULL;
|
||||
uint8_t *buffer = nullptr;
|
||||
uint32_t bufferSize = 0;
|
||||
int iResult = FSUtils::LoadFileToMem(filepath.c_str(), &buffer, &bufferSize);
|
||||
|
||||
if (iResult > 0) {
|
||||
GuiImageData * imageData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR);
|
||||
if(imageData) {
|
||||
auto *imageData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR);
|
||||
newHeader->imageData = imageData;
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
//! free original image buffer which is converted to texture now and not needed anymore
|
||||
free(buffer);
|
||||
@ -209,7 +203,7 @@ void GameList::updateTitleInfo() {
|
||||
|
||||
int32_t GameList::load() {
|
||||
lock();
|
||||
if(fullGameList.size() == 0) {
|
||||
if (fullGameList.empty()) {
|
||||
readGameList();
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ typedef struct _gameInfo {
|
||||
class GameList {
|
||||
public:
|
||||
GameList();
|
||||
|
||||
~GameList();
|
||||
|
||||
int32_t size() {
|
||||
@ -28,6 +29,7 @@ public:
|
||||
unlock();
|
||||
return res;
|
||||
}
|
||||
|
||||
int32_t gameCount() {
|
||||
lock();
|
||||
int32_t res = fullGameList.size();
|
||||
@ -38,17 +40,19 @@ public:
|
||||
gameInfo *at(int32_t i) {
|
||||
return operator[](i);
|
||||
}
|
||||
|
||||
gameInfo *operator[](int32_t i) {
|
||||
lock();
|
||||
gameInfo * res = NULL;
|
||||
gameInfo *res = nullptr;
|
||||
if (i < 0 || i >= (int32_t) fullGameList.size()) {
|
||||
res = NULL;
|
||||
res = nullptr;
|
||||
} else {
|
||||
res = fullGameList[i];
|
||||
}
|
||||
unlock();
|
||||
return res;
|
||||
}
|
||||
|
||||
gameInfo *getGameInfo(uint64_t titleId);
|
||||
|
||||
void clear();
|
||||
@ -66,11 +70,14 @@ public:
|
||||
void lock() {
|
||||
_lock.lock();
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
_lock.unlock();
|
||||
}
|
||||
|
||||
protected:
|
||||
int32_t readGameList();
|
||||
|
||||
void updateTitleInfo();
|
||||
|
||||
std::vector<gameInfo *> fullGameList;
|
||||
|
@ -83,34 +83,34 @@ GameIcon::GameIcon(GuiImageData *preloadImage)
|
||||
|
||||
GameIcon::~GameIcon() {
|
||||
//! remove image so it can not be drawn anymore from this point on
|
||||
imageData = NULL;
|
||||
imageData = nullptr;
|
||||
|
||||
//! main image vertexes
|
||||
if (posVtxs) {
|
||||
free((void *) posVtxs);
|
||||
posVtxs = NULL;
|
||||
posVtxs = nullptr;
|
||||
}
|
||||
if (texCoords) {
|
||||
free((void *) texCoords);
|
||||
texCoords = NULL;
|
||||
texCoords = nullptr;
|
||||
}
|
||||
//! mirror image vertexes
|
||||
if (texCoordsMirror) {
|
||||
free(texCoordsMirror);
|
||||
texCoordsMirror = NULL;
|
||||
texCoordsMirror = nullptr;
|
||||
}
|
||||
//! stroke image vertexes
|
||||
if (strokePosVtxs) {
|
||||
free(strokePosVtxs);
|
||||
strokePosVtxs = NULL;
|
||||
strokePosVtxs = nullptr;
|
||||
}
|
||||
if (strokeTexCoords) {
|
||||
free(strokeTexCoords);
|
||||
strokeTexCoords = NULL;
|
||||
strokeTexCoords = nullptr;
|
||||
}
|
||||
if (strokeColorVtxs) {
|
||||
free(strokeColorVtxs);
|
||||
strokeColorVtxs = NULL;
|
||||
strokeColorVtxs = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ bool GameIcon::checkRayIntersection(const glm::vec3 & rayOrigin, const glm::vec3
|
||||
}
|
||||
|
||||
void GameIcon::draw(CVideo *pVideo, const glm::mat4 &projectionMtx, const glm::mat4 &viewMtx, const glm::mat4 &modelView) {
|
||||
if(imageData == NULL){
|
||||
if (imageData == nullptr) {
|
||||
return;
|
||||
}
|
||||
//! first setup 2D GUI positions
|
||||
|
@ -4,52 +4,62 @@
|
||||
#include <gui/GuiImageAsync.h>
|
||||
#include <gui/video/shaders/Shader3D.h>
|
||||
|
||||
class GameIcon : public GuiImage
|
||||
{
|
||||
class GameIcon : public GuiImage {
|
||||
public:
|
||||
GameIcon(GuiImageData *preloadImage);
|
||||
|
||||
virtual ~GameIcon();
|
||||
|
||||
void setRotationX(float r) {
|
||||
rotationX = r;
|
||||
}
|
||||
|
||||
void setColorIntensity(const glm::vec4 &color) {
|
||||
colorIntensity = color;
|
||||
colorIntensityMirror = colorIntensity;
|
||||
selectionBlurOuterColorIntensity = color * glm::vec4(0.09411764f * 1.15f, 0.56862745f * 1.15f, 0.96862745098f * 1.15f, 1.0f);
|
||||
selectionBlurInnerColorIntensity = color * glm::vec4(0.46666667f, 0.90588235f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
const glm::vec4 &getColorIntensity() const {
|
||||
return colorIntensity;
|
||||
}
|
||||
|
||||
void setAlphaFadeOutNorm(const glm::vec4 &a) {
|
||||
alphaFadeOutNorm = a;
|
||||
}
|
||||
|
||||
void setAlphaFadeOutRefl(const glm::vec4 &a) {
|
||||
alphaFadeOutRefl = a;
|
||||
}
|
||||
|
||||
void setRenderReflection(bool enable) {
|
||||
bRenderReflection = enable;
|
||||
}
|
||||
|
||||
void setSelected(bool enable) {
|
||||
bSelected = enable;
|
||||
}
|
||||
|
||||
void setStrokeRender(bool enable) {
|
||||
bRenderStroke = enable;
|
||||
}
|
||||
|
||||
void setRenderIconLast(bool enable) {
|
||||
bIconLast = enable;
|
||||
}
|
||||
|
||||
void draw(CVideo *pVideo) {
|
||||
static const glm::mat4 identity(1.0f);
|
||||
draw(pVideo, identity, identity, identity);
|
||||
}
|
||||
|
||||
void draw(CVideo *pVideo, const glm::mat4 &projection, const glm::mat4 &view, const glm::mat4 &modelView);
|
||||
|
||||
bool checkRayIntersection(const glm::vec3 &rayOrigin, const glm::vec3 &rayDirFrac);
|
||||
|
||||
private:
|
||||
enum eRenderState
|
||||
{
|
||||
enum eRenderState {
|
||||
RENDER_REFLECTION,
|
||||
RENDER_NORMAL
|
||||
};
|
||||
|
@ -28,32 +28,18 @@
|
||||
GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex, bool sortByName)
|
||||
: GuiTitleBrowser(w, h, GameIndex),
|
||||
sortByName(sortByName),
|
||||
particleBgImage(w, h, 50, 60.0f, 90.0f, 0.6f, 1.0f)
|
||||
, buttonClickSound(Resources::GetSound("button_click.mp3"))
|
||||
, gameTitle((char*)NULL, 52, glm::vec4(1.0f))
|
||||
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
|
||||
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
|
||||
, leftTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_LEFT | GuiTrigger::STICK_L_LEFT, true)
|
||||
, rightTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_RIGHT | GuiTrigger::STICK_L_RIGHT, true)
|
||||
, downTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true)
|
||||
, upTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true)
|
||||
, buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true)
|
||||
, buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L, true)
|
||||
, buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R, true)
|
||||
, leftButton(w, h)
|
||||
, rightButton(w, h)
|
||||
, downButton(w, h)
|
||||
, upButton(w, h)
|
||||
, launchButton(w, h)
|
||||
, arrowRightImageData(Resources::GetImageData("rightArrow.png"))
|
||||
, arrowLeftImageData(Resources::GetImageData("leftArrow.png"))
|
||||
, arrowRightImage(arrowRightImageData)
|
||||
, arrowLeftImage(arrowLeftImageData)
|
||||
, arrowRightButton(arrowRightImage.getWidth(), arrowRightImage.getHeight())
|
||||
, arrowLeftButton(arrowLeftImage.getWidth(), arrowLeftImage.getHeight())
|
||||
, noIcon(Resources::GetFile("noGameIcon.png"), Resources::GetFileSize("noGameIcon.png"), GX2_TEX_CLAMP_MODE_MIRROR)
|
||||
, emptyIcon(Resources::GetFile("iconEmpty.png"), Resources::GetFileSize("iconEmpty.png"), GX2_TEX_CLAMP_MODE_MIRROR)
|
||||
, dragListener(w,h) {
|
||||
particleBgImage(w, h, 50, 60.0f, 90.0f, 0.6f, 1.0f), buttonClickSound(Resources::GetSound("button_click.mp3")), gameTitle((char *) nullptr, 52, glm::vec4(1.0f)),
|
||||
touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH),
|
||||
wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A),
|
||||
leftTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_LEFT | GuiTrigger::STICK_L_LEFT, true),
|
||||
rightTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_RIGHT | GuiTrigger::STICK_L_RIGHT, true),
|
||||
downTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true), upTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true),
|
||||
buttonATrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_A, true), buttonLTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_L, true),
|
||||
buttonRTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_R, true), leftButton(w, h), rightButton(w, h), downButton(w, h), upButton(w, h), launchButton(w, h),
|
||||
arrowRightImageData(Resources::GetImageData("rightArrow.png")), arrowLeftImageData(Resources::GetImageData("leftArrow.png")), arrowRightImage(arrowRightImageData),
|
||||
arrowLeftImage(arrowLeftImageData), arrowRightButton(arrowRightImage.getWidth(), arrowRightImage.getHeight()), arrowLeftButton(arrowLeftImage.getWidth(), arrowLeftImage.getHeight()),
|
||||
noIcon(Resources::GetFile("noGameIcon.png"), Resources::GetFileSize("noGameIcon.png"), GX2_TEX_CLAMP_MODE_MIRROR),
|
||||
emptyIcon(Resources::GetFile("iconEmpty.png"), Resources::GetFileSize("iconEmpty.png"), GX2_TEX_CLAMP_MODE_MIRROR), dragListener(w, h) {
|
||||
|
||||
particleBgImage.setParent(this);
|
||||
setSelectedGame(GameIndex);
|
||||
@ -176,7 +162,7 @@ void GuiIconGrid::setSelectedGame(uint64_t idx) {
|
||||
this->selectedGame = idx;
|
||||
|
||||
containerMutex.lock();
|
||||
GameInfoContainer * container = NULL;
|
||||
GameInfoContainer *container = nullptr;
|
||||
for (auto const &x: gameInfoContainers) {
|
||||
container = x.second;
|
||||
if (x.first == idx) {
|
||||
@ -212,14 +198,14 @@ void GuiIconGrid::OnGameTitleListUpdated(GameList * gameList) {
|
||||
bool wasFound = false;
|
||||
for (int32_t i = 0; i < gameList->size(); i++) {
|
||||
gameInfo *info = gameList->at(i);
|
||||
if(info != NULL && info->titleId == it->first) {
|
||||
if (info != nullptr && info->titleId == it->first) {
|
||||
wasFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasFound) {
|
||||
DEBUG_FUNCTION_LINE("Removing %016llX\n", it->first);
|
||||
DEBUG_FUNCTION_LINE("Removing %016llX", it->first);
|
||||
remove(it->second->button);
|
||||
delete it->second;
|
||||
it = gameInfoContainers.erase(it);
|
||||
@ -230,7 +216,7 @@ void GuiIconGrid::OnGameTitleListUpdated(GameList * gameList) {
|
||||
|
||||
for (int32_t i = 0; i < gameList->size(); i++) {
|
||||
gameInfo *info = gameList->at(i);
|
||||
GameInfoContainer * container = NULL;
|
||||
GameInfoContainer *container = nullptr;
|
||||
|
||||
for (auto const &x: gameInfoContainers) {
|
||||
if (info->titleId == x.first) {
|
||||
@ -238,7 +224,7 @@ void GuiIconGrid::OnGameTitleListUpdated(GameList * gameList) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(container == NULL) {
|
||||
if (container == nullptr) {
|
||||
OnGameTitleAdded(info);
|
||||
}
|
||||
}
|
||||
@ -325,6 +311,7 @@ void GuiIconGrid::OnDownClick(GuiButton *button, const GuiController *controller
|
||||
gameSelectionChanged(this, selectedGame);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiIconGrid::OnUpClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
|
||||
int32_t offset = offsetForTitleId(getSelectedGame());
|
||||
if (offset < 0) {
|
||||
@ -351,13 +338,13 @@ void GuiIconGrid::OnLaunchClick(GuiButton *button, const GuiController *controll
|
||||
if ((trigger == &buttonATrigger) && (controller->chan & (GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5)) && controller->data.validPointer) {
|
||||
return;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Tried to launch %s (%016llX)\n", gameInfoContainers[getSelectedGame()]->info->name.c_str(),getSelectedGame());
|
||||
DEBUG_FUNCTION_LINE("Tried to launch %s (%016llX)", gameInfoContainers[getSelectedGame()]->info->name.c_str(), getSelectedGame());
|
||||
gameLaunchClicked(this, getSelectedGame());
|
||||
}
|
||||
|
||||
|
||||
void GuiIconGrid::OnLeftArrowHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
|
||||
if(currentlyHeld != NULL) {
|
||||
if (currentlyHeld != nullptr) {
|
||||
if (lArrowHeldCounter++ > 30) {
|
||||
OnLeftArrowClick(button, controller, trigger);
|
||||
lArrowHeldCounter = 0;
|
||||
@ -372,9 +359,9 @@ void GuiIconGrid::OnLeftArrowReleased(GuiButton *button, const GuiController *co
|
||||
}
|
||||
|
||||
void GuiIconGrid::OnRightArrowHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
|
||||
if(currentlyHeld != NULL) {
|
||||
if (currentlyHeld != nullptr) {
|
||||
if (rArrowHeldCounter++ > 30) {
|
||||
DEBUG_FUNCTION_LINE("CLICK\n");
|
||||
DEBUG_FUNCTION_LINE("CLICK");
|
||||
OnRightArrowClick(button, controller, trigger);
|
||||
rArrowHeldCounter = 0;
|
||||
}
|
||||
@ -389,7 +376,7 @@ void GuiIconGrid::OnRightArrowReleased(GuiButton *button, const GuiController *c
|
||||
|
||||
|
||||
void GuiIconGrid::OnGameButtonHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
|
||||
if(currentlyHeld == NULL) {
|
||||
if (currentlyHeld == nullptr) {
|
||||
bool found = false;
|
||||
// We don't want to drag empty buttons
|
||||
for (auto const &x: emptyButtons) {
|
||||
@ -402,7 +389,7 @@ void GuiIconGrid::OnGameButtonHeld(GuiButton *button, const GuiController *contr
|
||||
currentlyHeld = button;
|
||||
}
|
||||
}
|
||||
if(currentlyHeld != NULL && currentlyHeld != button) {
|
||||
if (currentlyHeld != nullptr && currentlyHeld != button) {
|
||||
dragTarget = button;
|
||||
}
|
||||
}
|
||||
@ -416,11 +403,11 @@ void GuiIconGrid::OnGameButtonPointedOff(GuiButton *button, const GuiController
|
||||
}
|
||||
|
||||
void GuiIconGrid::OnDrag(GuiDragListener *element, const GuiController *controller, GuiTrigger *trigger, int32_t dx, int32_t dy) {
|
||||
if(currentlyHeld != NULL) {
|
||||
if (currentlyHeld != nullptr) {
|
||||
currentlyHeld->setPosition(currentlyHeld->getOffsetX() + dx, currentlyHeld->getOffsetY() + dy);
|
||||
}
|
||||
// reset the target when we move.
|
||||
dragTarget = NULL;
|
||||
dragTarget = nullptr;
|
||||
}
|
||||
|
||||
void GuiIconGrid::OnGameButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
|
||||
@ -442,9 +429,9 @@ void GuiIconGrid::OnGameButtonClick(GuiButton *button, const GuiController *cont
|
||||
}
|
||||
|
||||
void GuiIconGrid::OnGameTitleAdded(gameInfo *info) {
|
||||
DEBUG_FUNCTION_LINE("Adding %016llX\n", info->titleId);
|
||||
DEBUG_FUNCTION_LINE("Adding %016llX", info->titleId);
|
||||
GuiImageData *imageData = &noIcon;
|
||||
if(info->imageData != NULL) {
|
||||
if (info->imageData != nullptr) {
|
||||
imageData = info->imageData;
|
||||
}
|
||||
GameIcon *image = new GameIcon(imageData);
|
||||
@ -491,9 +478,10 @@ void GuiIconGrid::OnGameTitleAdded(gameInfo * info) {
|
||||
|
||||
bUpdatePositions = true;
|
||||
}
|
||||
|
||||
void GuiIconGrid::OnGameTitleUpdated(gameInfo *info) {
|
||||
DEBUG_FUNCTION_LINE("Updating infos of %016llX\n", info->titleId);
|
||||
GameInfoContainer * container = NULL;
|
||||
DEBUG_FUNCTION_LINE("Updating infos of %016llX", info->titleId);
|
||||
GameInfoContainer *container = nullptr;
|
||||
containerMutex.lock();
|
||||
for (auto const &x: gameInfoContainers) {
|
||||
if (info->titleId == x.first) {
|
||||
@ -503,7 +491,7 @@ void GuiIconGrid::OnGameTitleUpdated(gameInfo * info) {
|
||||
}
|
||||
|
||||
// keep the lock to delay the draw() until the image data is ready.
|
||||
if(container != NULL) {
|
||||
if (container != nullptr) {
|
||||
container->updateImageData();
|
||||
}
|
||||
|
||||
@ -513,12 +501,12 @@ void GuiIconGrid::OnGameTitleUpdated(gameInfo * info) {
|
||||
}
|
||||
|
||||
void GuiIconGrid::process() {
|
||||
if(currentlyHeld != NULL) {
|
||||
if (currentlyHeld != nullptr) {
|
||||
if (!currentlyHeld->isStateSet(GuiElement::STATE_HELD)) {
|
||||
DEBUG_FUNCTION_LINE("Not held anymore\n");
|
||||
DEBUG_FUNCTION_LINE("Not held anymore");
|
||||
positionMutex.lock();
|
||||
if (dragTarget) {
|
||||
DEBUG_FUNCTION_LINE("Let's swap\n");
|
||||
DEBUG_FUNCTION_LINE("Let's swap");
|
||||
|
||||
std::vector<std::pair<uint64_t, GameInfoContainer *>> vec;
|
||||
containerMutex.lock();
|
||||
@ -534,9 +522,9 @@ void GuiIconGrid::process() {
|
||||
}
|
||||
for (uint32_t i = 0; i < positionButtons.size(); i++) {
|
||||
if (positionButtons[i] == dragTarget) {
|
||||
if(i < position.size() && i != currentlyHeldPosition) {
|
||||
if (i < position.size() && (int32_t) i != currentlyHeldPosition) {
|
||||
position[i] = currentlyHeldTitleId;
|
||||
DEBUG_FUNCTION_LINE("Set position to title id to %d\n", i, currentlyHeldPosition);
|
||||
DEBUG_FUNCTION_LINE("Set position to title id to %d", i, currentlyHeldPosition);
|
||||
} else {
|
||||
targetTitleId = currentlyHeldTitleId;
|
||||
}
|
||||
@ -548,20 +536,20 @@ void GuiIconGrid::process() {
|
||||
position[currentlyHeldPosition] = targetTitleId;
|
||||
}
|
||||
|
||||
dragTarget = NULL;
|
||||
dragTarget = nullptr;
|
||||
} else {
|
||||
if (currentlyHeldPosition >= 0 && currentlyHeldPosition <= (int32_t) position.size()) {
|
||||
position[currentlyHeldPosition] = currentlyHeldTitleId;
|
||||
}
|
||||
}
|
||||
positionMutex.unlock();
|
||||
currentlyHeld = NULL;
|
||||
currentlyHeld = nullptr;
|
||||
currentlyHeldTitleId = 0;
|
||||
|
||||
currentlyHeldPosition = -1;
|
||||
bUpdatePositions = true;
|
||||
} else {
|
||||
//DEBUG_FUNCTION_LINE("Holding it\n");
|
||||
//DEBUG_FUNCTION_LINE("Holding it");
|
||||
bUpdatePositions = true;
|
||||
}
|
||||
}
|
||||
@ -693,31 +681,31 @@ void GuiIconGrid::updateButtonPositions() {
|
||||
|
||||
positionButtons.clear();
|
||||
for (uint32_t i = 0; i < startValue; i++) {
|
||||
positionButtons.push_back(NULL);
|
||||
positionButtons.push_back(nullptr);
|
||||
}
|
||||
|
||||
for (uint32_t i = startPage * (MAX_COLS * MAX_ROWS); i < (endPage + 1) * (MAX_COLS * MAX_ROWS); i++) {
|
||||
listOff = i / (MAX_COLS * MAX_ROWS);
|
||||
GuiButton * element = NULL;
|
||||
GuiButton *element = nullptr;
|
||||
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 posY = -row * (noIcon.getHeight() + noIcon.getHeight() * 0.5f) + (MAX_ROWS * 0.5f - 0.5f) * (noIcon.getHeight() + noIcon.getHeight() * 0.5f) + 30.0f;
|
||||
|
||||
if (i < position.size()) {
|
||||
uint64_t titleID = position.at(i);
|
||||
if (titleID > 0) {
|
||||
GameInfoContainer * container = NULL;
|
||||
GameInfoContainer *container = nullptr;
|
||||
containerMutex.lock();
|
||||
if (gameInfoContainers.find(titleID) != gameInfoContainers.end()) {
|
||||
container = gameInfoContainers[titleID];
|
||||
}
|
||||
containerMutex.unlock();
|
||||
if(container != NULL) {
|
||||
if (container != nullptr) {
|
||||
element = container->button;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(element == NULL) {
|
||||
if (element == nullptr) {
|
||||
if (emptyButtons.size() <= emptyIconUse) {
|
||||
break;
|
||||
}
|
||||
@ -737,7 +725,7 @@ void GuiIconGrid::updateButtonPositions() {
|
||||
row = 0;
|
||||
}
|
||||
}
|
||||
if(currentlyHeld != NULL) {
|
||||
if (currentlyHeld != nullptr) {
|
||||
append(currentlyHeld);
|
||||
}
|
||||
if (positionButtons.size() > position.size() && targetLeftPosition == currentLeftPosition) {
|
||||
|
@ -27,19 +27,27 @@
|
||||
class GuiIconGrid : public GuiTitleBrowser, public sigslot::has_slots<> {
|
||||
public:
|
||||
GuiIconGrid(int32_t w, int32_t h, uint64_t selectedTitleId, bool sortByName);
|
||||
|
||||
virtual ~GuiIconGrid();
|
||||
|
||||
void setSelectedGame(uint64_t idx);
|
||||
|
||||
uint64_t getSelectedGame(void);
|
||||
|
||||
void update(GuiController *t);
|
||||
|
||||
void draw(CVideo *pVideo);
|
||||
|
||||
void process();
|
||||
|
||||
void OnGameTitleListUpdated(GameList *list);
|
||||
|
||||
void OnAddGameTitle(gameInfo *info);
|
||||
|
||||
void OnGameTitleUpdated(gameInfo *info);
|
||||
|
||||
void OnGameTitleAdded(gameInfo *info);
|
||||
|
||||
private:
|
||||
static const int32_t MAX_ROWS = 3;
|
||||
static const int32_t MAX_COLS = 5;
|
||||
@ -79,23 +87,35 @@ private:
|
||||
GuiDragListener dragListener;
|
||||
|
||||
void OnLeftArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnRightArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnLeftClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnRightClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnDownClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnUpClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnLaunchClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnGameButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnGameButtonHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnGameButtonPointedOn(GuiButton *button, const GuiController *controller);
|
||||
|
||||
void OnGameButtonPointedOff(GuiButton *button, const GuiController *controller);
|
||||
|
||||
void OnDrag(GuiDragListener *button, const GuiController *controller, GuiTrigger *trigger, int32_t dx, int32_t dy);
|
||||
|
||||
void OnLeftArrowHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnRightArrowHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnLeftArrowReleased(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void OnRightArrowReleased(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
|
||||
|
||||
void updateButtonPositions();
|
||||
@ -112,10 +132,10 @@ private:
|
||||
int32_t targetLeftPosition;
|
||||
uint32_t gameLaunchTimer;
|
||||
bool bUpdatePositions = false;
|
||||
GuiButton * currentlyHeld = NULL;
|
||||
GuiButton *currentlyHeld = nullptr;
|
||||
uint64_t currentlyHeldTitleId = 0;
|
||||
int32_t currentlyHeldPosition = -1;
|
||||
GuiButton * dragTarget = NULL;
|
||||
GuiButton *dragTarget = nullptr;
|
||||
|
||||
class GameInfoContainer {
|
||||
public:
|
||||
@ -126,16 +146,16 @@ private:
|
||||
}
|
||||
|
||||
~GameInfoContainer() {
|
||||
if(button != NULL) {
|
||||
if (button != nullptr) {
|
||||
AsyncExecutor::pushForDelete(button);
|
||||
}
|
||||
if(image != NULL) {
|
||||
if (image != nullptr) {
|
||||
AsyncExecutor::pushForDelete(image);
|
||||
}
|
||||
}
|
||||
|
||||
void updateImageData() {
|
||||
if(image != NULL && info != NULL && info->imageData != NULL) {
|
||||
if (image != nullptr && info != nullptr && info->imageData != nullptr) {
|
||||
image->setImageData(info->imageData);
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,17 @@
|
||||
class GuiTitleBrowser : public GuiFrame {
|
||||
public:
|
||||
GuiTitleBrowser(int32_t w, int32_t h, uint64_t GameIndex) : GuiFrame(w, h) {}
|
||||
|
||||
virtual ~GuiTitleBrowser() {}
|
||||
|
||||
virtual void setSelectedGame(uint64_t idx) = 0;
|
||||
|
||||
virtual uint64_t getSelectedGame(void) = 0;
|
||||
|
||||
virtual void OnGameTitleListUpdated(GameList *list) = 0;
|
||||
|
||||
virtual void OnGameTitleUpdated(gameInfo *info) = 0;
|
||||
|
||||
virtual void OnGameTitleAdded(gameInfo *info) = 0;
|
||||
|
||||
sigslot::signal2<GuiTitleBrowser *, uint64_t> gameLaunchClicked;
|
||||
|
@ -28,7 +28,7 @@ GameSplashScreen::GameSplashScreen(int32_t w, int32_t h, gameInfo * info, bool o
|
||||
if (onTV) {
|
||||
filepath = "fs:" + info->gamePath + META_PATH + "/bootTVTex.tga";
|
||||
}
|
||||
uint8_t *buffer = NULL;
|
||||
uint8_t *buffer = nullptr;
|
||||
uint32_t bufferSize = 0;
|
||||
int iResult = FSUtils::LoadFileToMem(filepath.c_str(), &buffer, &bufferSize);
|
||||
if (iResult > 0) {
|
||||
|
@ -1,18 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "game/GameList.h"
|
||||
#include <gui/GuiImage.h>
|
||||
#include <gui/GuiFrame.h>
|
||||
|
||||
class GameSplashScreen : public GuiFrame, public sigslot::has_slots<> {
|
||||
public:
|
||||
GameSplashScreen(int32_t w, int32_t h, gameInfo *info, bool onTV);
|
||||
|
||||
virtual ~GameSplashScreen();
|
||||
|
||||
void OnSplashScreenFadeInDone(GuiElement *element);
|
||||
|
||||
virtual void draw(CVideo *v);
|
||||
|
||||
sigslot::signal3<GuiElement *, gameInfo *, bool> gameGameSplashScreenFinished;
|
||||
private:
|
||||
GuiImage bgImageColor;
|
||||
GuiImageData* splashScreenData = NULL;
|
||||
gameInfo * info = NULL;
|
||||
GuiImageData *splashScreenData = nullptr;
|
||||
gameInfo *info = nullptr;
|
||||
bool launchGame = false;
|
||||
uint32_t frameCounter = 0;
|
||||
bool onTV = false;
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <coreinit/memdefaultheap.h>
|
||||
|
||||
KeyboardHelper::KeyboardHelper() {
|
||||
FSClient *fsClient = (FSClient *)MEMAllocFromDefaultHeap(sizeof(FSClient));
|
||||
FSAddClient(fsClient, 0);
|
||||
auto *_fsClient = (FSClient *) MEMAllocFromDefaultHeap(sizeof(FSClient));
|
||||
FSAddClient(_fsClient, FS_ERROR_FLAG_ALL);
|
||||
|
||||
// Create swkbd
|
||||
nn::swkbd::CreateArg createArg;
|
||||
@ -13,11 +13,11 @@ KeyboardHelper::KeyboardHelper() {
|
||||
createArg.workMemory = MEMAllocFromDefaultHeap(nn::swkbd::GetWorkMemorySize(0));
|
||||
memset(createArg.workMemory, 0, sizeof(nn::swkbd::GetWorkMemorySize(0)));
|
||||
this->workMemory = createArg.workMemory;
|
||||
createArg.fsClient = fsClient;
|
||||
createArg.fsClient = _fsClient;
|
||||
this->fsClient = createArg.fsClient;
|
||||
DEBUG_FUNCTION_LINE("Calling create\n");
|
||||
DEBUG_FUNCTION_LINE("Calling create");
|
||||
if (!nn::swkbd::Create(createArg)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to create keyboard\n");
|
||||
DEBUG_FUNCTION_LINE("Failed to create keyboard");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -28,9 +28,9 @@ KeyboardHelper::~KeyboardHelper() {
|
||||
if (keyboardCreated) {
|
||||
nn::swkbd::Destroy();
|
||||
MEMFreeToDefaultHeap(this->workMemory);
|
||||
this->workMemory = NULL;
|
||||
this->workMemory = nullptr;
|
||||
|
||||
FSDelClient(fsClient, 0);
|
||||
FSDelClient(fsClient, FS_ERROR_FLAG_ALL);
|
||||
MEMFreeToDefaultHeap(this->fsClient);
|
||||
keyboardCreated = false;
|
||||
}
|
||||
@ -42,7 +42,7 @@ bool KeyboardHelper::openKeyboard() {
|
||||
nn::swkbd::AppearArg appearArg;
|
||||
appearArg.keyboardArg.configArg.languageType = nn::swkbd::LanguageType::English;
|
||||
if (!nn::swkbd::AppearInputForm(appearArg)) {
|
||||
DEBUG_FUNCTION_LINE("nn::swkbd::AppearInputForm failed\n");
|
||||
DEBUG_FUNCTION_LINE("nn::swkbd::AppearInputForm failed");
|
||||
return false;
|
||||
}
|
||||
keyboardOpen = true;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <coreinit/filesystem.h>
|
||||
|
||||
@ -10,9 +11,9 @@ public:
|
||||
|
||||
bool checkResult();
|
||||
|
||||
void drawTV();
|
||||
static void drawTV();
|
||||
|
||||
void drawDRC();
|
||||
static void drawDRC();
|
||||
|
||||
bool openKeyboard();
|
||||
|
||||
@ -24,8 +25,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void * workMemory = NULL;
|
||||
FSClient * fsClient = NULL;
|
||||
void *workMemory = nullptr;
|
||||
FSClient *fsClient = nullptr;
|
||||
bool keyboardOpen = false;
|
||||
bool keyboardCreated = false;
|
||||
std::string resultStr = "";
|
||||
|
@ -20,26 +20,16 @@
|
||||
#include "gui/Gui.h"
|
||||
#include "resources/Resources.h"
|
||||
|
||||
class MainDrcButtonsFrame : public GuiFrame, public sigslot::has_slots<>
|
||||
{
|
||||
class MainDrcButtonsFrame : public GuiFrame, public sigslot::has_slots<> {
|
||||
public:
|
||||
MainDrcButtonsFrame(int32_t w, int32_t h)
|
||||
: GuiFrame(w, h)
|
||||
, buttonClickSound(Resources::GetSound("settings_click_2.mp3"))
|
||||
, screenSwitchSound(Resources::GetSound("screenSwitchSound.mp3"))
|
||||
, switchIconData(Resources::GetImageData("layoutSwitchButton.png"))
|
||||
, settingsIconData(Resources::GetImageData("settingsButton.png"))
|
||||
, switchIcon(switchIconData)
|
||||
, settingsIcon(settingsIconData)
|
||||
, switchLayoutButton(switchIcon.getWidth(), switchIcon.getHeight())
|
||||
, settingsButton(settingsIcon.getWidth(), settingsIcon.getHeight())
|
||||
, gameListFilterButton(w, h)
|
||||
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
|
||||
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
|
||||
, settingsTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_ZL, true)
|
||||
, switchLayoutTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_ZR, true)
|
||||
, plusTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_PLUS, true)
|
||||
{
|
||||
: GuiFrame(w, h), buttonClickSound(Resources::GetSound("settings_click_2.mp3")), screenSwitchSound(Resources::GetSound("screenSwitchSound.mp3")),
|
||||
switchIconData(Resources::GetImageData("layoutSwitchButton.png")), settingsIconData(Resources::GetImageData("settingsButton.png")), switchIcon(switchIconData),
|
||||
settingsIcon(settingsIconData), switchLayoutButton(switchIcon.getWidth(), switchIcon.getHeight()), settingsButton(settingsIcon.getWidth(), settingsIcon.getHeight()),
|
||||
gameListFilterButton(w, h), touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH),
|
||||
wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A),
|
||||
settingsTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_ZL, true), switchLayoutTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_ZR, true),
|
||||
plusTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_PLUS, true) {
|
||||
settingsButton.setClickable(true);
|
||||
settingsButton.setImage(&settingsIcon);
|
||||
settingsButton.setTrigger(&touchTrigger);
|
||||
@ -68,8 +58,8 @@ public:
|
||||
gameListFilterButton.clicked.connect(this, &MainDrcButtonsFrame::OnGameListFilterButtonClicked);
|
||||
append(&gameListFilterButton);
|
||||
}
|
||||
virtual ~MainDrcButtonsFrame()
|
||||
{
|
||||
|
||||
virtual ~MainDrcButtonsFrame() {
|
||||
Resources::RemoveImageData(switchIconData);
|
||||
Resources::RemoveImageData(settingsIconData);
|
||||
Resources::RemoveSound(buttonClickSound);
|
||||
@ -83,9 +73,11 @@ private:
|
||||
void OnSettingsButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *) {
|
||||
settingsButtonClicked(this);
|
||||
}
|
||||
|
||||
void OnLayoutSwithClick(GuiButton *button, const GuiController *controller, GuiTrigger *) {
|
||||
layoutSwitchClicked(this);
|
||||
}
|
||||
|
||||
void OnGameListFilterButtonClicked(GuiButton *button, const GuiController *controller, GuiTrigger *) {
|
||||
gameListFilterClicked(this);
|
||||
}
|
||||
|
@ -29,12 +29,7 @@
|
||||
#include "GameSplashScreen.h"
|
||||
|
||||
MainWindow::MainWindow(int32_t w, int32_t h)
|
||||
: width(w)
|
||||
, height(h)
|
||||
, gameClickSound(Resources::GetSound("game_click.mp3"))
|
||||
, mainSwitchButtonFrame(NULL)
|
||||
, currentTvFrame(NULL)
|
||||
, currentDrcFrame(NULL) {
|
||||
: width(w), height(h), gameClickSound(Resources::GetSound("game_click.mp3")), mainSwitchButtonFrame(nullptr), currentTvFrame(nullptr), currentDrcFrame(nullptr) {
|
||||
for (int32_t i = 0; i < 4; i++) {
|
||||
std::string filename = StringTools::strfmt("player%i_point.png", i + 1);
|
||||
pointerImgData[i] = Resources::GetImageData(filename.c_str());
|
||||
@ -113,7 +108,7 @@ void MainWindow::process() {
|
||||
}
|
||||
}
|
||||
|
||||
if(keyboardInstance != NULL) {
|
||||
if (keyboardInstance != nullptr) {
|
||||
if (keyboardInstance->checkResult()) {
|
||||
std::string result = keyboardInstance->getResult();
|
||||
|
||||
@ -202,7 +197,7 @@ void MainWindow::drawDrc(CVideo *video) {
|
||||
}
|
||||
}
|
||||
|
||||
if(keyboardInstance != NULL) {
|
||||
if (keyboardInstance != nullptr) {
|
||||
keyboardInstance->drawDRC();
|
||||
}
|
||||
}
|
||||
@ -218,7 +213,7 @@ void MainWindow::drawTv(CVideo *video) {
|
||||
pointerValid[i] = false;
|
||||
}
|
||||
}
|
||||
if(keyboardInstance != NULL) {
|
||||
if (keyboardInstance != nullptr) {
|
||||
keyboardInstance->drawTV();
|
||||
}
|
||||
}
|
||||
@ -295,7 +290,7 @@ void MainWindow::OnGameListFilterButtonClicked(GuiElement *element) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(keyboardInstance == NULL) {
|
||||
if (keyboardInstance == nullptr) {
|
||||
keyboardInstance = new KeyboardHelper();
|
||||
}
|
||||
if (keyboardInstance->isReady()) {
|
||||
@ -380,7 +375,7 @@ extern "C" void _SYSLaunchTitleByPathFromLauncher(const char * path, int len, in
|
||||
|
||||
void MainWindow::OnGameLaunchSplashScreen(GuiTitleBrowser *element, uint64_t titleID) {
|
||||
gameInfo *info = gameList.getGameInfo(titleID);
|
||||
if(info != NULL) {
|
||||
if (info != nullptr) {
|
||||
uint64_t ownTitleId = OSGetTitleID();
|
||||
if (ownTitleId == HBL_TITLE_ID ||
|
||||
ownTitleId == MII_MAKER_JPN_TITLE_ID ||
|
||||
@ -408,7 +403,7 @@ void MainWindow::OnGameLaunchSplashScreen(GuiTitleBrowser * element, uint64_t ti
|
||||
}
|
||||
|
||||
void MainWindow::OnGameLaunchSplashScreenFinished(GuiElement *element, gameInfo *info, bool launchGame) {
|
||||
if(info == NULL) {
|
||||
if (info == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (launchGame) {
|
||||
@ -420,9 +415,10 @@ void MainWindow::OnGameLaunchSplashScreenFinished(GuiElement * element, gameInfo
|
||||
element->effectFinished.connect(this, &MainWindow::OnCloseEffectFinish);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OnGameLaunch(uint64_t titleID) {
|
||||
gameInfo *info = gameList.getGameInfo(titleID);
|
||||
if(info != NULL) {
|
||||
if (info != nullptr) {
|
||||
uint64_t titleID = OSGetTitleID();
|
||||
if (titleID == HBL_TITLE_ID ||
|
||||
titleID == MII_MAKER_JPN_TITLE_ID ||
|
||||
|
@ -30,6 +30,7 @@ class CVideo;
|
||||
class MainWindow : public sigslot::has_slots<> {
|
||||
public:
|
||||
MainWindow(int32_t w, int32_t h);
|
||||
|
||||
virtual ~MainWindow();
|
||||
|
||||
void appendTv(GuiElement *e) {
|
||||
@ -39,6 +40,7 @@ public:
|
||||
removeTv(e);
|
||||
tvElements.push_back(e);
|
||||
}
|
||||
|
||||
void appendDrc(GuiElement *e) {
|
||||
if (!e)
|
||||
return;
|
||||
@ -59,6 +61,7 @@ public:
|
||||
removeTv(e);
|
||||
tvElements.insert(tvElements.begin() + pos, e);
|
||||
}
|
||||
|
||||
void insertDrc(uint32_t pos, GuiElement *e) {
|
||||
if (!e)
|
||||
return;
|
||||
@ -80,6 +83,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeDrc(GuiElement *e) {
|
||||
for (uint32_t i = 0; i < drcElements.size(); ++i) {
|
||||
if (e == drcElements[i]) {
|
||||
@ -93,20 +97,26 @@ public:
|
||||
removeTv(e);
|
||||
removeDrc(e);
|
||||
}
|
||||
|
||||
void removeAll() {
|
||||
tvElements.clear();
|
||||
drcElements.clear();
|
||||
}
|
||||
|
||||
void drawDrc(CVideo *video);
|
||||
|
||||
void drawTv(CVideo *video);
|
||||
|
||||
void update(GuiController *controller);
|
||||
|
||||
void updateEffects();
|
||||
|
||||
void process();
|
||||
|
||||
void lockGUI() {
|
||||
guiMutex.lock();
|
||||
}
|
||||
|
||||
void unlockGUI() {
|
||||
guiMutex.unlock();
|
||||
}
|
||||
@ -115,21 +125,29 @@ private:
|
||||
void SetupMainView(void);
|
||||
|
||||
void OnOpenEffectFinish(GuiElement *element);
|
||||
|
||||
void OnCloseEffectFinish(GuiElement *element);
|
||||
|
||||
void OnGameLaunch(uint64_t titleId);
|
||||
|
||||
void OnGameLaunchSplashScreenFinished(GuiElement *element, gameInfo *info, bool launchGame);
|
||||
|
||||
void OnGameLaunchSplashScreen(GuiTitleBrowser *element, uint64_t titleId);
|
||||
|
||||
void OnGameSelectionChange(GuiTitleBrowser *element, uint64_t titleId);
|
||||
|
||||
void OnSettingsButtonClicked(GuiElement *element);
|
||||
|
||||
void OnLayoutSwitchClicked(GuiElement *element);
|
||||
|
||||
void OnLayoutSwitchEffectFinish(GuiElement *element);
|
||||
|
||||
void OnGameListFilterButtonClicked(GuiElement *element);
|
||||
|
||||
void OnGameTitleListChanged(GameList *list);
|
||||
|
||||
void OnGameTitleUpdated(gameInfo *info);
|
||||
|
||||
void OnGameTitleAdded(gameInfo *info);
|
||||
|
||||
int32_t width, height;
|
||||
@ -150,7 +168,7 @@ private:
|
||||
GameList gameList;
|
||||
|
||||
std::recursive_mutex guiMutex;
|
||||
KeyboardHelper * keyboardInstance = NULL;
|
||||
KeyboardHelper *keyboardInstance = nullptr;
|
||||
};
|
||||
|
||||
#endif //_MAIN_WINDOW_H_
|
||||
|
@ -15,13 +15,13 @@
|
||||
#include <strings.h>
|
||||
|
||||
|
||||
Resources * Resources::instance = NULL;
|
||||
Resources *Resources::instance = nullptr;
|
||||
|
||||
void Resources::Clear() {
|
||||
for(int32_t i = 0; RecourceList[i].filename != NULL; ++i) {
|
||||
for (int32_t i = 0; RecourceList[i].filename != nullptr; ++i) {
|
||||
if (RecourceList[i].CustomFile) {
|
||||
free(RecourceList[i].CustomFile);
|
||||
RecourceList[i].CustomFile = NULL;
|
||||
RecourceList[i].CustomFile = nullptr;
|
||||
}
|
||||
|
||||
if (RecourceList[i].CustomFileSize != 0)
|
||||
@ -31,7 +31,7 @@ void Resources::Clear() {
|
||||
if (instance)
|
||||
delete instance;
|
||||
|
||||
instance = NULL;
|
||||
instance = nullptr;
|
||||
}
|
||||
|
||||
bool Resources::LoadFiles(const char *path) {
|
||||
@ -41,12 +41,12 @@ bool Resources::LoadFiles(const char * path) {
|
||||
bool result = false;
|
||||
Clear();
|
||||
|
||||
for(int32_t i = 0; RecourceList[i].filename != NULL; ++i) {
|
||||
for (int32_t i = 0; RecourceList[i].filename != nullptr; ++i) {
|
||||
std::string fullpath(path);
|
||||
fullpath += "/";
|
||||
fullpath += RecourceList[i].filename;
|
||||
|
||||
uint8_t * buffer = NULL;
|
||||
uint8_t *buffer = nullptr;
|
||||
uint32_t filesize = 0;
|
||||
|
||||
FSUtils::LoadFileToMem(fullpath.c_str(), &buffer, &filesize);
|
||||
@ -60,17 +60,17 @@ bool Resources::LoadFiles(const char * path) {
|
||||
}
|
||||
|
||||
const uint8_t *Resources::GetFile(const char *filename) {
|
||||
for(int32_t i = 0; RecourceList[i].filename != NULL; ++i) {
|
||||
for (int32_t i = 0; RecourceList[i].filename != nullptr; ++i) {
|
||||
if (strcasecmp(filename, RecourceList[i].filename) == 0) {
|
||||
return (RecourceList[i].CustomFile ? RecourceList[i].CustomFile : RecourceList[i].DefaultFile);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t Resources::GetFileSize(const char *filename) {
|
||||
for(int32_t i = 0; RecourceList[i].filename != NULL; ++i) {
|
||||
for (int32_t i = 0; RecourceList[i].filename != nullptr; ++i) {
|
||||
if (strcasecmp(filename, RecourceList[i].filename) == 0) {
|
||||
return (RecourceList[i].CustomFile ? RecourceList[i].CustomFileSize : RecourceList[i].DefaultFileSize);
|
||||
}
|
||||
@ -88,13 +88,13 @@ GuiImageData * Resources::GetImageData(const char * filename) {
|
||||
return itr->second.second;
|
||||
}
|
||||
|
||||
for(int32_t i = 0; RecourceList[i].filename != NULL; ++i) {
|
||||
for (int32_t i = 0; RecourceList[i].filename != nullptr; ++i) {
|
||||
if (strcasecmp(filename, RecourceList[i].filename) == 0) {
|
||||
const uint8_t *buff = RecourceList[i].CustomFile ? RecourceList[i].CustomFile : RecourceList[i].DefaultFile;
|
||||
const uint32_t size = RecourceList[i].CustomFile ? RecourceList[i].CustomFileSize : RecourceList[i].DefaultFileSize;
|
||||
|
||||
if(buff == NULL)
|
||||
return NULL;
|
||||
if (buff == nullptr)
|
||||
return nullptr;
|
||||
|
||||
GuiImageData *image = new GuiImageData(buff, size);
|
||||
instance->imageDataMap[std::string(filename)].first = 1;
|
||||
@ -104,7 +104,7 @@ GuiImageData * Resources::GetImageData(const char * filename) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Resources::RemoveImageData(GuiImageData *image) {
|
||||
@ -134,13 +134,13 @@ GuiSound * Resources::GetSound(const char * filename) {
|
||||
return itr->second.second;
|
||||
}
|
||||
|
||||
for(int32_t i = 0; RecourceList[i].filename != NULL; ++i) {
|
||||
for (int32_t i = 0; RecourceList[i].filename != nullptr; ++i) {
|
||||
if (strcasecmp(filename, RecourceList[i].filename) == 0) {
|
||||
const uint8_t *buff = RecourceList[i].CustomFile ? RecourceList[i].CustomFile : RecourceList[i].DefaultFile;
|
||||
const uint32_t size = RecourceList[i].CustomFile ? RecourceList[i].CustomFileSize : RecourceList[i].DefaultFileSize;
|
||||
|
||||
if(buff == NULL)
|
||||
return NULL;
|
||||
if (buff == nullptr)
|
||||
return nullptr;
|
||||
|
||||
GuiSound *sound = new GuiSound(buff, size);
|
||||
instance->soundDataMap[std::string(filename)].first = 1;
|
||||
@ -150,7 +150,7 @@ GuiSound * Resources::GetSound(const char * filename) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Resources::RemoveSound(GuiSound *sound) {
|
||||
|
@ -5,24 +5,32 @@
|
||||
|
||||
//! forward declaration
|
||||
class GuiImageData;
|
||||
|
||||
class GuiSound;
|
||||
|
||||
class Resources {
|
||||
public:
|
||||
static void Clear();
|
||||
|
||||
static bool LoadFiles(const char *path);
|
||||
|
||||
static const uint8_t *GetFile(const char *filename);
|
||||
|
||||
static uint32_t GetFileSize(const char *filename);
|
||||
|
||||
static GuiImageData *GetImageData(const char *filename);
|
||||
|
||||
static void RemoveImageData(GuiImageData *image);
|
||||
|
||||
static GuiSound *GetSound(const char *filename);
|
||||
|
||||
static void RemoveSound(GuiSound *sound);
|
||||
|
||||
private:
|
||||
static Resources *instance;
|
||||
|
||||
Resources() {}
|
||||
|
||||
~Resources() {}
|
||||
|
||||
std::map<std::string, std::pair<uint32_t, GuiImageData *> > imageDataMap;
|
||||
|
@ -26,9 +26,9 @@ public:
|
||||
typedef void (* Callback)(CThread *thread, void *arg);
|
||||
|
||||
//! constructor
|
||||
CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL)
|
||||
: pThread(NULL)
|
||||
, pThreadStack(NULL)
|
||||
CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
|
||||
: pThread(nullptr)
|
||||
, pThreadStack(nullptr)
|
||||
, pCallback(callback)
|
||||
, pCallbackArg(callbackArg) {
|
||||
//! save attribute assignment
|
||||
@ -102,7 +102,7 @@ public:
|
||||
if(isThreadSuspended())
|
||||
resumeThread();
|
||||
|
||||
OSJoinThread(pThread, NULL);
|
||||
OSJoinThread(pThread, nullptr);
|
||||
}
|
||||
//! free the thread stack buffer
|
||||
if(pThreadStack)
|
||||
@ -110,8 +110,8 @@ public:
|
||||
if(pThread)
|
||||
free(pThread);
|
||||
|
||||
pThread = NULL;
|
||||
pThreadStack = NULL;
|
||||
pThread = nullptr;
|
||||
pThreadStack = nullptr;
|
||||
}
|
||||
//! Thread attributes
|
||||
enum eCThreadAttributes {
|
||||
|
@ -1,13 +1,14 @@
|
||||
#include "AsyncExecutor.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
AsyncExecutor * AsyncExecutor::instance = NULL;
|
||||
AsyncExecutor *AsyncExecutor::instance = nullptr;
|
||||
|
||||
void AsyncExecutor::pushForDeleteInternal(GuiElement *ptr) {
|
||||
deleteListMutex.lock();
|
||||
deleteList.push(ptr);
|
||||
deleteListMutex.unlock();
|
||||
}
|
||||
|
||||
AsyncExecutor::AsyncExecutor() {
|
||||
thread = new std::thread([&]() {
|
||||
while (!exitThread) {
|
||||
@ -24,7 +25,7 @@ AsyncExecutor::AsyncExecutor() {
|
||||
}
|
||||
}
|
||||
if (!emptyList && elements.empty()) {
|
||||
DEBUG_FUNCTION_LINE("All tasks are done\n");
|
||||
DEBUG_FUNCTION_LINE("All tasks are done");
|
||||
}
|
||||
mutex.unlock();
|
||||
deleteListMutex.lock();
|
||||
@ -49,10 +50,10 @@ AsyncExecutor::~AsyncExecutor() {
|
||||
|
||||
void AsyncExecutor::executeInternal(std::function<void()> func) {
|
||||
if (elements.size() > 10) {
|
||||
DEBUG_FUNCTION_LINE("Warning, many tasks running currently\n");
|
||||
DEBUG_FUNCTION_LINE("Warning, many tasks running currently");
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Add new task\n");
|
||||
DEBUG_FUNCTION_LINE("Add new task");
|
||||
mutex.lock();
|
||||
elements.push_back(std::async(std::launch::async, func));
|
||||
mutex.unlock();
|
||||
|
@ -16,6 +16,7 @@ public:
|
||||
}
|
||||
instance->pushForDeleteInternal(element);
|
||||
}
|
||||
|
||||
static void execute(std::function<void()> func) {
|
||||
if (!instance) {
|
||||
instance = new AsyncExecutor();
|
||||
@ -26,7 +27,7 @@ public:
|
||||
static void destroyInstance() {
|
||||
if (instance) {
|
||||
delete instance;
|
||||
instance = NULL;
|
||||
instance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,9 +35,11 @@ private:
|
||||
static AsyncExecutor *instance;
|
||||
|
||||
AsyncExecutor();
|
||||
|
||||
~AsyncExecutor();
|
||||
|
||||
void pushForDeleteInternal(GuiElement *element);
|
||||
|
||||
void executeInternal(std::function<void()> func);
|
||||
|
||||
std::recursive_mutex mutex;
|
||||
|
@ -78,7 +78,7 @@ const char * StringTools::fmt(const char * format, ...) {
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const wchar_t *StringTools::wfmt(const char *format, ...) {
|
||||
@ -107,7 +107,7 @@ const wchar_t * StringTools::wfmt(const char * format, ...) {
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t StringTools::strprintf(std::string &str, const char *format, ...) {
|
||||
@ -165,11 +165,11 @@ int32_t StringTools::strtokcmp(const char * string, const char * compare, const
|
||||
|
||||
char *strTok = strtok(TokCopy, separator);
|
||||
|
||||
while (strTok != NULL) {
|
||||
while (strTok != nullptr) {
|
||||
if (strcasecmp(string, strTok) == 0) {
|
||||
return 0;
|
||||
}
|
||||
strTok = strtok(NULL,separator);
|
||||
strTok = strtok(nullptr, separator);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -210,8 +210,7 @@ std::vector<std::string> StringTools::stringSplit(const std::string & inValue, c
|
||||
return result;
|
||||
}
|
||||
|
||||
bool StringTools::findStringIC(const std::string & strHaystack, const std::string & strNeedle)
|
||||
{
|
||||
bool StringTools::findStringIC(const std::string &strHaystack, const std::string &strNeedle) {
|
||||
auto it = std::search(
|
||||
strHaystack.begin(), strHaystack.end(),
|
||||
strNeedle.begin(), strNeedle.end(),
|
||||
|
@ -35,14 +35,23 @@
|
||||
class StringTools {
|
||||
public:
|
||||
static BOOL EndsWith(const std::string &a, const std::string &b);
|
||||
|
||||
static const char *byte_to_binary(int32_t x);
|
||||
|
||||
static std::string removeCharFromString(std::string &input, char toBeRemoved);
|
||||
|
||||
static const char *fmt(const char *format, ...);
|
||||
|
||||
static const wchar_t *wfmt(const char *format, ...);
|
||||
|
||||
static int32_t strprintf(std::string &str, const char *format, ...);
|
||||
|
||||
static std::string strfmt(const char *format, ...);
|
||||
|
||||
static BOOL char2wchar_t(const char *src, wchar_t *dest);
|
||||
|
||||
static int32_t strtokcmp(const char *string, const char *compare, const char *separator);
|
||||
|
||||
static int32_t strextcmp(const char *string, const char *extension, char seperator);
|
||||
|
||||
static const char *FullpathToFilename(const char *path) {
|
||||
|
@ -1,83 +0,0 @@
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <utils/logger.h>
|
||||
#include <nsysnet/socket.h>
|
||||
#include <coreinit/debug.h>
|
||||
|
||||
#include <coreinit/systeminfo.h>
|
||||
#include <coreinit/thread.h>
|
||||
|
||||
static int32_t log_socket __attribute__((section(".data")))= -1;
|
||||
static struct sockaddr_in connect_addr __attribute__((section(".data")));
|
||||
static volatile int32_t log_lock __attribute__((section(".data"))) = 0;
|
||||
static std::recursive_mutex _lock;
|
||||
|
||||
void log_init_() {
|
||||
int32_t broadcastEnable = 1;
|
||||
log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (log_socket < 0)
|
||||
return;
|
||||
|
||||
setsockopt(log_socket, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
|
||||
|
||||
memset(&connect_addr, 0, sizeof(struct sockaddr_in));
|
||||
connect_addr.sin_family = AF_INET;
|
||||
connect_addr.sin_port = 4405;
|
||||
connect_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
|
||||
}
|
||||
|
||||
void log_print_(const char *str) {
|
||||
// socket is always 0 initially as it is in the BSS
|
||||
if(log_socket < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_lock.lock();
|
||||
|
||||
int32_t len = strlen(str);
|
||||
int32_t ret;
|
||||
while (len > 0) {
|
||||
int32_t block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet
|
||||
ret = sendto(log_socket, str, block, 0, (struct sockaddr *)&connect_addr, sizeof(struct sockaddr_in));
|
||||
if(ret < 0)
|
||||
break;
|
||||
|
||||
len -= ret;
|
||||
str += ret;
|
||||
}
|
||||
|
||||
_lock.unlock();
|
||||
}
|
||||
|
||||
void OSFatal_printf(const char *format, ...) {
|
||||
char tmp[512];
|
||||
tmp[0] = 0;
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
if((vsprintf(tmp, format, va) >= 0)) {
|
||||
OSFatal(tmp);
|
||||
}
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void log_printf_(const char *format, ...) {
|
||||
if(log_socket < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char tmp[512];
|
||||
tmp[0] = 0;
|
||||
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
if((vsprintf(tmp, format, va) >= 0)) {
|
||||
log_print_(tmp);
|
||||
}
|
||||
va_end(va);
|
||||
}
|
||||
|
@ -1,38 +1,24 @@
|
||||
#ifndef __LOGGER_H_
|
||||
#define __LOGGER_H_
|
||||
#pragma once
|
||||
|
||||
#include <whb/log.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void log_init_();
|
||||
//void log_deinit_(void);
|
||||
void log_print_(const char *str);
|
||||
void log_printf_(const char *format, ...);
|
||||
void OSFatal_printf(const char *format, ...);
|
||||
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
|
||||
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
#define log_init() log_init_()
|
||||
//#define log_deinit() log_deinit_()
|
||||
#define log_print(str) log_print_(str)
|
||||
#define log_printf(FMT, ARGS...) log_printf_(FMT, ## ARGS);
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
log_printf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
|
||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -11,30 +11,30 @@ void dumpHex(const void* data, size_t size) {
|
||||
char ascii[17];
|
||||
size_t i, j;
|
||||
ascii[16] = '\0';
|
||||
DEBUG_FUNCTION_LINE("0x%08X (0x0000): ", data);
|
||||
DEBUG_FUNCTION_LINE_WRITE("0x%08X (0x0000): ", data);
|
||||
for (i = 0; i < size; ++i) {
|
||||
log_printf("%02X ", ((unsigned char*)data)[i]);
|
||||
WHBLogWritef("%02X ", ((unsigned char *) data)[i]);
|
||||
if (((unsigned char *) data)[i] >= ' ' && ((unsigned char *) data)[i] <= '~') {
|
||||
ascii[i % 16] = ((unsigned char *) data)[i];
|
||||
} else {
|
||||
ascii[i % 16] = '.';
|
||||
}
|
||||
if ((i + 1) % 8 == 0 || i + 1 == size) {
|
||||
log_printf(" ");
|
||||
WHBLogWritef(" ");
|
||||
if ((i + 1) % 16 == 0) {
|
||||
log_printf("| %s \n", ascii);
|
||||
WHBLogWritef("| %s \n", ascii);
|
||||
if (i + 1 < size) {
|
||||
DEBUG_FUNCTION_LINE("0x%08X (0x%04X); ", data + i + 1,i+1);
|
||||
WHBLogWritef("0x%08X (0x%04X); ", data + i + 1, i + 1);
|
||||
}
|
||||
} else if (i + 1 == size) {
|
||||
ascii[(i + 1) % 16] = '\0';
|
||||
if ((i + 1) % 16 <= 8) {
|
||||
log_printf(" ");
|
||||
WHBLogWritef(" ");
|
||||
}
|
||||
for (j = (i + 1) % 16; j < 16; ++j) {
|
||||
log_printf(" ");
|
||||
WHBLogWritef(" ");
|
||||
}
|
||||
log_printf("| %s \n", ascii);
|
||||
WHBLogWritef("| %s \n", ascii);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user