Update integer conversion

This commit is contained in:
RayD 2024-09-23 18:16:03 +00:00
parent fd22a86dfa
commit dba542d6b0
5 changed files with 111 additions and 153 deletions

View File

@ -1,5 +1,5 @@
FROM ghcr.io/wiiu-env/devkitppc:20240704 FROM ghcr.io/wiiu-env/devkitppc:20240704
COPY --from=wiiuenv/libgui:20220109 /artifacts $DEVKITPRO COPY --from=wiiuenv/libgui:2022020513505562e265 /artifacts $DEVKITPRO
WORKDIR project WORKDIR project

View File

@ -154,11 +154,12 @@ void initExternalStorage() {
nn::spm::Finalize(); nn::spm::Finalize();
} }
Application * Application::applicationInstance = nullptr; Application *Application::applicationInstance = nullptr;
bool Application::exitApplication = false; bool Application::exitApplication = false;
bool Application::quitRequest = false; bool Application::quitRequest = false;
Application::Application(): CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x800000), bgMusic(nullptr), video(nullptr), mainWindow(nullptr), fontSystem(nullptr), exitCode(0) { Application::Application()
: 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[0] = new VPadController(GuiTrigger::CHANNEL_1);
controller[1] = new WPadController(GuiTrigger::CHANNEL_2); controller[1] = new WPadController(GuiTrigger::CHANNEL_2);
controller[2] = new WPadController(GuiTrigger::CHANNEL_3); controller[2] = new WPadController(GuiTrigger::CHANNEL_3);
@ -167,13 +168,11 @@ Application::Application(): CThread(CThread::eAttributeAffCore1 | CThread::eAttr
//! create bgMusic //! create bgMusic
bgMusic = new GuiSound(Resources::GetFile("bgMusic.ogg"), Resources::GetFileSize("bgMusic.ogg")); bgMusic = new GuiSound(Resources::GetFile("bgMusic.ogg"), Resources::GetFileSize("bgMusic.ogg"));
bgMusic -> SetLoop(true); bgMusic->SetLoop(true);
bgMusic -> Play(); bgMusic->Play();
bgMusic -> SetVolume(50); bgMusic->SetVolume(50);
AsyncExecutor::execute([] { AsyncExecutor::execute([] { DEBUG_FUNCTION_LINE("Hello"); });
DEBUG_FUNCTION_LINE("Hello");
});
exitApplication = false; exitApplication = false;
@ -186,7 +185,7 @@ Application::~Application() {
DEBUG_FUNCTION_LINE("Destroy controller"); DEBUG_FUNCTION_LINE("Destroy controller");
for (auto & i: controller) { for (auto &i : controller) {
delete i; delete i;
} }
@ -212,20 +211,13 @@ int32_t Application::exec() {
} }
void Application::quit(int32_t code) { void Application::quit(int32_t code) {
exitCode = code; exitCode = code;
exitApplication = true; exitApplication = true;
quitRequest = true; quitRequest = true;
} }
void Application::fadeOut() { void Application::fadeOut() {
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color) { GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){0, 0, 0, 255});
0,
0,
0,
255
});
glm::mat4 identityMatrix(1.0f);
for (int32_t i = 0; i < 255; i += 10) { for (int32_t i = 0; i < 255; i += 10) {
if (i > 255) if (i > 255)
@ -234,30 +226,30 @@ glm::mat4 identityMatrix(1.0f);
fadeOut.setAlpha(i / 255.0f); fadeOut.setAlpha(i / 255.0f);
//! start rendering DRC //! start rendering DRC
video -> prepareDrcRendering(); video->prepareDrcRendering();
mainWindow -> drawDrc(video); mainWindow->drawDrc(video);
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_ALWAYS); GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_ALWAYS);
fadeOut.draw(video, identityMatrix); fadeOut.draw(video);
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL);
video -> drcDrawDone(); video->drcDrawDone();
//! start rendering TV //! start rendering TV
video -> prepareTvRendering(); video->prepareTvRendering();
mainWindow -> drawTv(video); mainWindow->drawTv(video);
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_ALWAYS); GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_ALWAYS);
fadeOut.draw(video, identityMatrix); fadeOut.draw(video);
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL);
video -> tvDrawDone(); video->tvDrawDone();
//! as last point update the effects as it can drop elements //! as last point update the effects as it can drop elements
mainWindow -> updateEffects(); mainWindow->updateEffects();
video -> waitForVSync(); video->waitForVSync();
} }
} }
@ -265,63 +257,63 @@ bool Application::procUI() {
bool executeProcess = false; bool executeProcess = false;
switch (ProcUIProcessMessages(true)) { switch (ProcUIProcessMessages(true)) {
case PROCUI_STATUS_EXITING: { case PROCUI_STATUS_EXITING: {
DEBUG_FUNCTION_LINE("PROCUI_STATUS_EXITING"); DEBUG_FUNCTION_LINE("PROCUI_STATUS_EXITING");
exitCode = EXIT_SUCCESS; exitCode = EXIT_SUCCESS;
exitApplication = true; exitApplication = true;
break; break;
}
case PROCUI_STATUS_RELEASE_FOREGROUND: {
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");
delete fontSystem;
fontSystem = nullptr;
DEBUG_FUNCTION_LINE("delete video");
delete video;
video = nullptr;
DEBUG_FUNCTION_LINE("deinitialze memory");
libgui_memoryRelease();
ProcUIDrawDoneRelease();
} else {
ProcUIDrawDoneRelease();
} }
break; case PROCUI_STATUS_RELEASE_FOREGROUND: {
} DEBUG_FUNCTION_LINE("PROCUI_STATUS_RELEASE_FOREGROUND");
case PROCUI_STATUS_IN_FOREGROUND: { if (video != nullptr) {
if (!quitRequest) { // we can turn ofF the screen but we don't need to and it will display the last image
if (video == nullptr) { video->tvEnable(true);
DEBUG_FUNCTION_LINE("PROCUI_STATUS_IN_FOREGROUND"); video->drcEnable(true);
DEBUG_FUNCTION_LINE("initialze memory");
libgui_memoryInitialize();
DEBUG_FUNCTION_LINE("Initialize video"); DEBUG_FUNCTION_LINE("delete fontSystem");
video = new CVideo(GX2_TV_SCAN_MODE_720P, GX2_DRC_RENDER_MODE_SINGLE); delete fontSystem;
DEBUG_FUNCTION_LINE("Video size %i x %i", video -> getTvWidth(), video -> getTvHeight()); fontSystem = nullptr;
//! setup default Font DEBUG_FUNCTION_LINE("delete video");
DEBUG_FUNCTION_LINE("Initialize main font system"); delete video;
auto * fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true); video = nullptr;
GuiText::setPresetFont(fontSystem);
if (mainWindow == nullptr) { DEBUG_FUNCTION_LINE("deinitialze memory");
DEBUG_FUNCTION_LINE("Initialize main window"); libgui_memoryRelease();
mainWindow = new MainWindow(video -> getTvWidth(), video -> getTvHeight()); ProcUIDrawDoneRelease();
} } else {
ProcUIDrawDoneRelease();
} }
executeProcess = true; break;
} }
break; case PROCUI_STATUS_IN_FOREGROUND: {
} if (!quitRequest) {
case PROCUI_STATUS_IN_BACKGROUND: if (video == nullptr) {
default: DEBUG_FUNCTION_LINE("PROCUI_STATUS_IN_FOREGROUND");
break; DEBUG_FUNCTION_LINE("initialze memory");
libgui_memoryInitialize();
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", video->getTvWidth(), video->getTvHeight());
//! setup default Font
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 == nullptr) {
DEBUG_FUNCTION_LINE("Initialize main window");
mainWindow = new MainWindow(video->getTvWidth(), video->getTvHeight());
}
}
executeProcess = true;
}
break;
}
case PROCUI_STATUS_IN_BACKGROUND:
default:
break;
} }
return executeProcess; return executeProcess;
@ -336,43 +328,43 @@ void Application::executeThread() {
continue; continue;
} }
mainWindow -> lockGUI(); mainWindow->lockGUI();
mainWindow -> process(); mainWindow->process();
//! Read out inputs //! Read out inputs
for (auto & i: controller) { for (auto &i : controller) {
if (!i -> update(video -> getTvWidth(), video -> getTvHeight())) if (!i->update(video->getTvWidth(), video->getTvHeight()))
continue; continue;
//! update controller states //! update controller states
mainWindow -> update(i); mainWindow->update(i);
} }
//! start rendering DRC //! start rendering DRC
video -> prepareDrcRendering(); video->prepareDrcRendering();
mainWindow -> drawDrc(video); mainWindow->drawDrc(video);
video -> drcDrawDone(); video->drcDrawDone();
//! start rendering TV //! start rendering TV
video -> prepareTvRendering(); video->prepareTvRendering();
mainWindow -> drawTv(video); mainWindow->drawTv(video);
video -> tvDrawDone(); video->tvDrawDone();
//! enable screen after first frame render //! enable screen after first frame render
if (video -> getFrameCount() == 0) { if (video->getFrameCount() == 0) {
video -> tvEnable(true); video->tvEnable(true);
video -> drcEnable(true); video->drcEnable(true);
} }
//! as last point update the effects as it can drop elements //! as last point update the effects as it can drop elements
mainWindow -> updateEffects(); mainWindow->updateEffects();
mainWindow -> unlockGUI(); mainWindow->unlockGUI();
video -> waitForVSync(); video->waitForVSync();
} }
if (bgMusic) { if (bgMusic) {
bgMusic -> SetVolume(0); bgMusic->SetVolume(0);
} }
DEBUG_FUNCTION_LINE("delete mainWindow"); DEBUG_FUNCTION_LINE("delete mainWindow");
@ -389,5 +381,4 @@ void Application::executeThread() {
DEBUG_FUNCTION_LINE("deinitialize memory"); DEBUG_FUNCTION_LINE("deinitialize memory");
libgui_memoryRelease(); libgui_memoryRelease();
} }

View File

@ -1,31 +1,23 @@
/****************************************************************************
* Copyright (C) 2015 Dimok
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef _APPLICATION_H #ifndef _APPLICATION_H
#define _APPLICATION_H #define _APPLICATION_H
#include "menu/MainWindow.h" #include "menu/MainWindow.h"
#include "system/CThread.h" #include "system/CThread.h"
#include <gui/video/CVideo.h> #include "gui/video/CVideo.h"
// forward declaration // forward declaration
class FreeTypeGX; class FreeTypeGX;
class Application : public CThread { class Application : public CThread {
public: public:
Application();
virtual ~Application();
static Application *applicationInstance;
static bool exitApplication;
static bool quitRequest;
static Application *instance() { static Application *instance() {
if (!applicationInstance) if (!applicationInstance)
applicationInstance = new Application(); applicationInstance = new Application();
@ -58,16 +50,9 @@ public:
void quit(int code); void quit(int code);
private: private:
Application();
virtual ~Application();
bool procUI(void); bool procUI(void);
static Application *applicationInstance;
static bool exitApplication;
static bool quitRequest;
void executeThread(void); void executeThread(void);
GuiSound *bgMusic; GuiSound *bgMusic;

View File

@ -1,24 +1,7 @@
/****************************************************************************
* Copyright (C) 2015 Dimok
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "MainWindow.h" #include "MainWindow.h"
#include "Application.h" #include "Application.h"
#include "utils/StringTools.h" #include "utils/StringTools.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "GameSplashScreen.h" #include "GameSplashScreen.h"
#include "gui/GuiIconGrid.h" #include "gui/GuiIconGrid.h"
#include "gui/GuiTitleBrowser.h" #include "gui/GuiTitleBrowser.h"
@ -27,7 +10,9 @@
#include <coreinit/title.h> #include <coreinit/title.h>
#include <future> #include <future>
#include <nn/acp/title.h> #include <nn/acp/title.h>
#include <sysapp/args.h>
#include <sysapp/launch.h> #include <sysapp/launch.h>
#include <sysapp/switch.h>
MainWindow::MainWindow(int32_t w, int32_t h) MainWindow::MainWindow(int32_t w, int32_t h)
: width(w), height(h), gameClickSound(Resources::GetSound("game_click.mp3")), mainSwitchButtonFrame(nullptr), currentTvFrame(nullptr), currentDrcFrame(nullptr) { : width(w), height(h), gameClickSound(Resources::GetSound("game_click.mp3")), mainSwitchButtonFrame(nullptr), currentTvFrame(nullptr), currentDrcFrame(nullptr) {
@ -401,9 +386,6 @@ void MainWindow::OnGameLaunchSplashScreenFinished(GuiElement *element, gameInfo
} }
} }
extern "C" int32_t SYSSwitchToBrowser(void *);
extern "C" int32_t SYSSwitchToEShop(void *);
extern "C" int32_t _SYSSwitchTo(uint32_t pfid);
void MainWindow::OnGameLaunch(uint64_t titleId) { void MainWindow::OnGameLaunch(uint64_t titleId) {
DEBUG_FUNCTION_LINE("Launch GAME!!"); DEBUG_FUNCTION_LINE("Launch GAME!!");
@ -434,28 +416,28 @@ void MainWindow::OnGameLaunch(uint64_t titleId) {
titleId == 0x000500301001810AL || titleId == 0x000500301001810AL ||
titleId == 0x000500301001820AL) { titleId == 0x000500301001820AL) {
DEBUG_FUNCTION_LINE("Launching the Download Management"); DEBUG_FUNCTION_LINE("Launching the Download Management");
_SYSSwitchTo(12); _SYSSwitchTo(SYSAPP_PFID_DOWNLOAD_MANAGEMENT);
return; return;
} }
if (titleId == 0x000500301001600AL || if (titleId == 0x000500301001600AL ||
titleId == 0x000500301001610AL || titleId == 0x000500301001610AL ||
titleId == 0x000500301001620AL) { titleId == 0x000500301001620AL) {
DEBUG_FUNCTION_LINE("Launching Miiverse"); DEBUG_FUNCTION_LINE("Launching Miiverse");
_SYSSwitchTo(9); _SYSSwitchTo(SYSAPP_PFID_MIIVERSE);
return; return;
} }
if (titleId == 0x000500301001500AL || if (titleId == 0x000500301001500AL ||
titleId == 0x000500301001510AL || titleId == 0x000500301001510AL ||
titleId == 0x000500301001520AL) { titleId == 0x000500301001520AL) {
DEBUG_FUNCTION_LINE("Launching Friendlist"); DEBUG_FUNCTION_LINE("Launching Friendlist");
_SYSSwitchTo(11); _SYSSwitchTo(SYSAPP_PFID_FRIENDLIST);
return; return;
} }
if (titleId == 0x000500301001300AL || if (titleId == 0x000500301001300AL ||
titleId == 0x000500301001310AL || titleId == 0x000500301001310AL ||
titleId == 0x000500301001320AL) { titleId == 0x000500301001320AL) {
DEBUG_FUNCTION_LINE("Launching TVii"); DEBUG_FUNCTION_LINE("Launching TVii");
_SYSSwitchTo(3); _SYSSwitchTo(SYSAPP_PFID_TVII);
return; return;
} }

View File

@ -21,7 +21,7 @@
#include "MainDrcButtonsFrame.h" #include "MainDrcButtonsFrame.h"
#include "game/GameList.h" #include "game/GameList.h"
#include "gui/GuiTitleBrowser.h" #include "gui/GuiTitleBrowser.h"
#include <gui/Gui.h> #include "gui/Gui.h"
#include <queue> #include <queue>
#include <vector> #include <vector>