mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-12-25 01:21:57 +01:00
[Loader] Code formatting and minor logging improvements.
This commit is contained in:
parent
409527fb21
commit
55dd57d62f
4
.gitignore
vendored
4
.gitignore
vendored
@ -8,7 +8,11 @@ plugins/*/bin/*
|
||||
plugins/*/build/*
|
||||
loader/WiiUPluginLoader.cscope_file_list
|
||||
loader/WiiUPluginLoader.layout
|
||||
loader/screenshots/*
|
||||
release/*
|
||||
|
||||
*.mod
|
||||
*.cbp
|
||||
*.id*
|
||||
*.nam
|
||||
*.til
|
||||
|
@ -34,8 +34,7 @@ Application::Application()
|
||||
, bgMusic(NULL)
|
||||
, video(NULL)
|
||||
, mainWindow(NULL)
|
||||
, exitCode(EXIT_RELAUNCH_ON_LOAD)
|
||||
{
|
||||
, exitCode(EXIT_RELAUNCH_ON_LOAD) {
|
||||
controller[0] = new VPadController(GuiTrigger::CHANNEL_1);
|
||||
controller[1] = new WPadController(GuiTrigger::CHANNEL_2);
|
||||
controller[2] = new WPadController(GuiTrigger::CHANNEL_3);
|
||||
@ -54,18 +53,18 @@ Application::Application()
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
log_printf("Application::~Application(line %d): Destroy music\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Destroy music\n");
|
||||
delete bgMusic;
|
||||
|
||||
log_printf("Application::~Application(line %d): Destroy controller\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Destroy controller\n");
|
||||
|
||||
for(s32 i = 0; i < 5; i++)
|
||||
delete controller[i];
|
||||
|
||||
//We may have to handle Asyncdelete in the Destructors.
|
||||
log_printf("Application::~Application(line %d): Destroy async deleter\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Destroy async deleter\n");
|
||||
do {
|
||||
log_printf("Application::~Application(line %d): Triggering AsyncDeleter\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Triggering AsyncDeleter\n");
|
||||
AsyncDeleter::triggerDeleteProcess();
|
||||
while(!AsyncDeleter::realListEmpty()) {
|
||||
os_usleep(1000);
|
||||
@ -73,10 +72,10 @@ Application::~Application(){
|
||||
} while(!AsyncDeleter::deleteListEmpty());
|
||||
AsyncDeleter::destroyInstance();
|
||||
|
||||
log_printf("Application::~Application(line %d): Clear resources\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Clear resources\n");
|
||||
Resources::Clear();
|
||||
|
||||
log_printf("Application::~Application(line %d): Stop sound handler\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Stop sound handler\n");
|
||||
SoundHandler::DestroyInstance();
|
||||
|
||||
}
|
||||
@ -94,10 +93,11 @@ void Application::reloadUI(){
|
||||
reloadUIflag = true;
|
||||
}
|
||||
void Application::fadeOut() {
|
||||
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){ 0, 0, 0, 255 });
|
||||
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color) {
|
||||
0, 0, 0, 255
|
||||
});
|
||||
|
||||
for(s32 i = 0; i < 255; i += 10)
|
||||
{
|
||||
for(s32 i = 0; i < 255; i += 10) {
|
||||
if(i > 255)
|
||||
i = 255;
|
||||
|
||||
@ -141,13 +141,13 @@ void Application::fadeOut(){
|
||||
}
|
||||
|
||||
void Application::executeThread(void) {
|
||||
log_printf("Application::executeThread(line %d): Initialize video\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Initialize video\n");
|
||||
video = new CVideo(GX2_TV_SCAN_MODE_720P, GX2_DRC_SINGLE);
|
||||
|
||||
log_printf("Application::executeThread(line %d): Video size %i x %i\n",__LINE__, video->getTvWidth(), video->getTvHeight());
|
||||
DEBUG_FUNCTION_LINE("Video size %i x %i\n", video->getTvWidth(), video->getTvHeight());
|
||||
|
||||
//! setup default Font
|
||||
log_printf("Application::executeThread(line %d): Initialize main font system\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Initialize main font system\n");
|
||||
FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true);
|
||||
GuiText::setPresetFont(fontSystem);
|
||||
|
||||
@ -161,18 +161,17 @@ void Application::executeThread(void){
|
||||
while(reloadUIflag) {
|
||||
reloadUIflag = false;
|
||||
exitCode = EXIT_RELAUNCH_ON_LOAD;
|
||||
log_printf("Application::executeThread(line %d): Initialize the language\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Initialize the language\n");
|
||||
loadLanguageFromConfig();
|
||||
log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Initialize main window\n");
|
||||
mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight());
|
||||
|
||||
log_printf("Application::executeThread(line %d): Entering main loop\n",__LINE__);
|
||||
DEBUG_FUNCTION_LINE("Entering main loop\n");
|
||||
exitApplication = false;
|
||||
//! main GX2 loop (60 Hz cycle with max priority on core 1)
|
||||
while(!exitApplication && !reloadUIflag) {
|
||||
//! Read out inputs
|
||||
for(s32 i = 0; i < 5; i++)
|
||||
{
|
||||
for(s32 i = 0; i < 5; i++) {
|
||||
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
|
||||
continue;
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
#define APPLICATION_CLOSE_APPLY 1
|
||||
#define APPLICATION_CLOSE_MIIMAKER 2
|
||||
|
||||
class Application : public CThread
|
||||
{
|
||||
class Application : public CThread {
|
||||
public:
|
||||
static Application * instance() {
|
||||
if(!applicationInstance)
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include <string.h>
|
||||
#include "main.h"
|
||||
|
||||
int __entry_menu(int argc, char **argv)
|
||||
{
|
||||
int __entry_menu(int argc, char **argv) {
|
||||
//! *******************************************************************
|
||||
//! * Jump to our application *
|
||||
//! *******************************************************************
|
||||
|
@ -196,8 +196,7 @@ s32 isInMiiMakerHBL(){
|
||||
OSGetTitleID() == 0x000500101004A200 || // mii maker eur
|
||||
OSGetTitleID() == 0x000500101004A100 || // mii maker usa
|
||||
OSGetTitleID() == 0x000500101004A000 ||// mii maker jpn
|
||||
OSGetTitleID() == 0x0005000013374842))
|
||||
{
|
||||
OSGetTitleID() == 0x0005000013374842)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -29,8 +29,7 @@ MainWindow * MainWindow::instance = NULL;
|
||||
|
||||
MainWindow::MainWindow(s32 w, s32 h)
|
||||
: width(w)
|
||||
, height(h)
|
||||
{
|
||||
, height(h) {
|
||||
for(s32 i = 0; i < 4; i++) {
|
||||
std::string filename = StringTools::strfmt("player%i_point.png", i+1);
|
||||
pointerImgData[i] = Resources::GetImageData(filename.c_str());
|
||||
@ -42,100 +41,80 @@ MainWindow::MainWindow(s32 w, s32 h)
|
||||
SetupMainView();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
MainWindow::~MainWindow() {
|
||||
|
||||
while(!tvElements.empty())
|
||||
{
|
||||
while(!tvElements.empty()) {
|
||||
delete tvElements[0];
|
||||
remove(tvElements[0]);
|
||||
}
|
||||
while(!drcElements.empty())
|
||||
{
|
||||
while(!drcElements.empty()) {
|
||||
delete drcElements[0];
|
||||
remove(drcElements[0]);
|
||||
}
|
||||
for(s32 i = 0; i < 4; i++)
|
||||
{
|
||||
for(s32 i = 0; i < 4; i++) {
|
||||
delete pointerImg[i];
|
||||
Resources::RemoveImageData(pointerImgData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateEffects()
|
||||
{
|
||||
void MainWindow::updateEffects() {
|
||||
//! dont read behind the initial elements in case one was added
|
||||
u32 tvSize = tvElements.size();
|
||||
u32 drcSize = drcElements.size();
|
||||
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->updateEffects();
|
||||
}
|
||||
|
||||
//! only update TV elements that are not updated yet because they are on DRC
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
u32 n;
|
||||
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++)
|
||||
{
|
||||
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++) {
|
||||
if(tvElements[i] == drcElements[n])
|
||||
break;
|
||||
}
|
||||
if(n == drcElements.size())
|
||||
{
|
||||
if(n == drcElements.size()) {
|
||||
tvElements[i]->updateEffects();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::process()
|
||||
{
|
||||
void MainWindow::process() {
|
||||
//! dont read behind the initial elements in case one was added
|
||||
u32 tvSize = tvElements.size();
|
||||
u32 drcSize = drcElements.size();
|
||||
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->process();
|
||||
}
|
||||
|
||||
//! only update TV elements that are not updated yet because they are on DRC
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
u32 n;
|
||||
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++)
|
||||
{
|
||||
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++) {
|
||||
if(tvElements[i] == drcElements[n])
|
||||
break;
|
||||
}
|
||||
if(n == drcElements.size())
|
||||
{
|
||||
if(n == drcElements.size()) {
|
||||
tvElements[i]->process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::update(GuiController *controller)
|
||||
{
|
||||
void MainWindow::update(GuiController *controller) {
|
||||
//! dont read behind the initial elements in case one was added
|
||||
//u32 tvSize = tvElements.size();
|
||||
|
||||
if(controller->chan & GuiTrigger::CHANNEL_1)
|
||||
{
|
||||
if(controller->chan & GuiTrigger::CHANNEL_1) {
|
||||
u32 drcSize = drcElements.size();
|
||||
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->update(controller);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
u32 tvSize = tvElements.size();
|
||||
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
tvElements[i]->update(controller);
|
||||
}
|
||||
}
|
||||
@ -155,8 +134,7 @@ void MainWindow::update(GuiController *controller)
|
||||
// }
|
||||
// }
|
||||
|
||||
if(controller->chanIdx >= 1 && controller->chanIdx <= 4 && controller->data.validPointer)
|
||||
{
|
||||
if(controller->chanIdx >= 1 && controller->chanIdx <= 4 && controller->data.validPointer) {
|
||||
s32 wpadIdx = controller->chanIdx - 1;
|
||||
f32 posX = controller->data.x;
|
||||
f32 posY = controller->data.y;
|
||||
@ -166,17 +144,13 @@ void MainWindow::update(GuiController *controller)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::drawDrc(CVideo *video)
|
||||
{
|
||||
for(u32 i = 0; i < drcElements.size(); ++i)
|
||||
{
|
||||
void MainWindow::drawDrc(CVideo *video) {
|
||||
for(u32 i = 0; i < drcElements.size(); ++i) {
|
||||
drcElements[i]->draw(video);
|
||||
}
|
||||
|
||||
for(s32 i = 0; i < 4; i++)
|
||||
{
|
||||
if(pointerValid[i])
|
||||
{
|
||||
for(s32 i = 0; i < 4; i++) {
|
||||
if(pointerValid[i]) {
|
||||
pointerImg[i]->setAlpha(0.5f);
|
||||
pointerImg[i]->draw(video);
|
||||
pointerImg[i]->setAlpha(1.0f);
|
||||
@ -184,17 +158,13 @@ void MainWindow::drawDrc(CVideo *video)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::drawTv(CVideo *video)
|
||||
{
|
||||
for(u32 i = 0; i < tvElements.size(); ++i)
|
||||
{
|
||||
void MainWindow::drawTv(CVideo *video) {
|
||||
for(u32 i = 0; i < tvElements.size(); ++i) {
|
||||
tvElements[i]->draw(video);
|
||||
}
|
||||
|
||||
for(s32 i = 0; i < 4; i++)
|
||||
{
|
||||
if(pointerValid[i])
|
||||
{
|
||||
for(s32 i = 0; i < 4; i++) {
|
||||
if(pointerValid[i]) {
|
||||
pointerImg[i]->draw(video);
|
||||
pointerValid[i] = false;
|
||||
}
|
||||
@ -208,8 +178,7 @@ void MainWindow::SetupMainView(){
|
||||
appendDrc(DrcFrame);
|
||||
}
|
||||
|
||||
void MainWindow::OnOpenEffectFinish(GuiElement *element)
|
||||
{
|
||||
void MainWindow::OnOpenEffectFinish(GuiElement *element) {
|
||||
//! once the menu is open reset its state and allow it to be "clicked/hold"
|
||||
element->effectFinished.disconnect(this);
|
||||
element->clearState(GuiElement::STATE_DISABLED);
|
||||
@ -217,8 +186,7 @@ void MainWindow::OnOpenEffectFinish(GuiElement *element)
|
||||
|
||||
void MainWindow::appendToAllElements(GuiElement * element) {
|
||||
u32 drcSize = drcElements.size();
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
GuiFrame * realElement = dynamic_cast<GuiFrame*>(drcElements[i]);
|
||||
if(realElement != NULL) {
|
||||
realElement->append(element);
|
||||
@ -226,8 +194,7 @@ void MainWindow::appendToAllElements(GuiElement * element){
|
||||
}
|
||||
|
||||
u32 tvSize = tvElements.size();
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
GuiFrame * realElement = dynamic_cast<GuiFrame*>(tvElements[i]);
|
||||
if(realElement != NULL) {
|
||||
realElement->append(element);
|
||||
@ -237,8 +204,7 @@ void MainWindow::appendToAllElements(GuiElement * element){
|
||||
|
||||
void MainWindow::removeFromAllElements(GuiElement * element) {
|
||||
u32 drcSize = drcElements.size();
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
GuiFrame * realElement = dynamic_cast<GuiFrame*>(drcElements[i]);
|
||||
if(realElement != NULL) {
|
||||
realElement->remove(element);
|
||||
@ -246,8 +212,7 @@ void MainWindow::removeFromAllElements(GuiElement * element){
|
||||
}
|
||||
|
||||
u32 tvSize = tvElements.size();
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
GuiFrame * realElement = dynamic_cast<GuiFrame*>(tvElements[i]);
|
||||
if(realElement != NULL) {
|
||||
realElement->remove(element);
|
||||
@ -258,28 +223,24 @@ void MainWindow::removeFromAllElements(GuiElement * element){
|
||||
|
||||
void MainWindow::setState(s32 val, s32 c) {
|
||||
u32 drcSize = drcElements.size();
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->setState(val,c);
|
||||
}
|
||||
|
||||
u32 tvSize = tvElements.size();
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
tvElements[i]->setState(val,c);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::clearState(s32 val, s32 c) {
|
||||
u32 drcSize = drcElements.size();
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) {
|
||||
drcElements[i]->clearState(val,c);
|
||||
}
|
||||
|
||||
u32 tvSize = tvElements.size();
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||
{
|
||||
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i) {
|
||||
tvElements[i]->clearState(val,c);
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,7 @@
|
||||
|
||||
class CVideo;
|
||||
|
||||
class MainWindow : public sigslot::has_slots<>
|
||||
{
|
||||
class MainWindow : public sigslot::has_slots<> {
|
||||
public:
|
||||
virtual ~MainWindow();
|
||||
|
||||
@ -49,16 +48,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void appendTv(GuiElement *e)
|
||||
{
|
||||
void appendTv(GuiElement *e) {
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
removeTv(e);
|
||||
tvElements.push_back(e);
|
||||
}
|
||||
void appendDrc(GuiElement *e)
|
||||
{
|
||||
void appendDrc(GuiElement *e) {
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
@ -66,22 +63,19 @@ public:
|
||||
drcElements.push_back(e);
|
||||
}
|
||||
|
||||
void append(GuiElement *e)
|
||||
{
|
||||
void append(GuiElement *e) {
|
||||
appendTv(e);
|
||||
appendDrc(e);
|
||||
}
|
||||
|
||||
void insertTv(u32 pos, GuiElement *e)
|
||||
{
|
||||
void insertTv(u32 pos, GuiElement *e) {
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
removeTv(e);
|
||||
tvElements.insert(tvElements.begin() + pos, e);
|
||||
}
|
||||
void insertDrc(u32 pos, GuiElement *e)
|
||||
{
|
||||
void insertDrc(u32 pos, GuiElement *e) {
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
@ -89,42 +83,33 @@ public:
|
||||
drcElements.insert(drcElements.begin() + pos, e);
|
||||
}
|
||||
|
||||
void insert(u32 pos, GuiElement *e)
|
||||
{
|
||||
void insert(u32 pos, GuiElement *e) {
|
||||
insertTv(pos, e);
|
||||
insertDrc(pos, e);
|
||||
}
|
||||
|
||||
void removeTv(GuiElement *e)
|
||||
{
|
||||
for(u32 i = 0; i < tvElements.size(); ++i)
|
||||
{
|
||||
if(e == tvElements[i])
|
||||
{
|
||||
void removeTv(GuiElement *e) {
|
||||
for(u32 i = 0; i < tvElements.size(); ++i) {
|
||||
if(e == tvElements[i]) {
|
||||
tvElements.erase(tvElements.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void removeDrc(GuiElement *e)
|
||||
{
|
||||
for(u32 i = 0; i < drcElements.size(); ++i)
|
||||
{
|
||||
if(e == drcElements[i])
|
||||
{
|
||||
void removeDrc(GuiElement *e) {
|
||||
for(u32 i = 0; i < drcElements.size(); ++i) {
|
||||
if(e == drcElements[i]) {
|
||||
drcElements.erase(drcElements.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void remove(GuiElement *e)
|
||||
{
|
||||
void remove(GuiElement *e) {
|
||||
removeTv(e);
|
||||
removeDrc(e);
|
||||
}
|
||||
void removeAll()
|
||||
{
|
||||
void removeAll() {
|
||||
tvElements.clear();
|
||||
drcElements.clear();
|
||||
}
|
||||
|
@ -20,12 +20,21 @@ MainWindowContent::MainWindowContent(s32 w, s32 h)
|
||||
: GuiFrame(w, h)
|
||||
, width(w)
|
||||
, height(h)
|
||||
, bgImageColor(w, h, (GX2Color){ 0, 0, 0, 0 })
|
||||
{
|
||||
bgImageColor.setImageColor((GX2Color){ 248, 249, 248, 255 }, 0);
|
||||
bgImageColor.setImageColor((GX2Color){ 248, 249, 248, 255 }, 1);
|
||||
bgImageColor.setImageColor((GX2Color){ 248, 249, 248, 255 }, 2);
|
||||
bgImageColor.setImageColor((GX2Color){ 248, 249, 248, 255 }, 3);
|
||||
, bgImageColor(w, h, (GX2Color) {
|
||||
0, 0, 0, 0
|
||||
}) {
|
||||
bgImageColor.setImageColor((GX2Color) {
|
||||
248, 249, 248, 255
|
||||
}, 0);
|
||||
bgImageColor.setImageColor((GX2Color) {
|
||||
248, 249, 248, 255
|
||||
}, 1);
|
||||
bgImageColor.setImageColor((GX2Color) {
|
||||
248, 249, 248, 255
|
||||
}, 2);
|
||||
bgImageColor.setImageColor((GX2Color) {
|
||||
248, 249, 248, 255
|
||||
}, 3);
|
||||
|
||||
append(&bgImageColor);
|
||||
}
|
||||
|
@ -41,8 +41,12 @@ public:
|
||||
//If you call this function, please also delete the object. This class isn't taking care of it
|
||||
static ContentTemplate * createNewContent(eContentNames contentName) {
|
||||
switch(contentName) {
|
||||
case CONTENT_HOME: { return new ContentHome(); break;}
|
||||
default: return NULL;
|
||||
case CONTENT_HOME: {
|
||||
return new ContentHome();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,7 @@ ContentHome::ContentHome():ContentTemplate()
|
||||
, exitHome(gettext("Exit to HBL "))
|
||||
, plusbutton_imgdata(Resources::GetImageData("PlusButtonIcon.png"))
|
||||
, plusbutton_img(plusbutton_imgdata)
|
||||
, exitPlus(gettext("Apply Patches"))
|
||||
{
|
||||
, exitPlus(gettext("Apply Patches")) {
|
||||
glm::vec4 textColor = glm::vec4(1.0f,1.0f,1.0f,1.0f);
|
||||
|
||||
homebutton_img.setAlignment(ALIGN_LEFT);
|
||||
|
@ -24,12 +24,21 @@ class ContentTemplate : public GuiFrame, public sigslot::has_slots<>{
|
||||
|
||||
public:
|
||||
ContentTemplate() : GuiFrame(SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
, bgImageColor(SCREEN_WIDTH, SCREEN_HEIGHT, (GX2Color){ 0, 0, 0, 0 })
|
||||
{
|
||||
bgImageColor.setImageColor((GX2Color){ 42, 42, 42, 255 }, 0);
|
||||
bgImageColor.setImageColor((GX2Color){ 42, 42, 42, 255 }, 1);
|
||||
bgImageColor.setImageColor((GX2Color){ 42, 42, 42, 255 }, 2);
|
||||
bgImageColor.setImageColor((GX2Color){ 42, 42, 42, 255 }, 3);
|
||||
, bgImageColor(SCREEN_WIDTH, SCREEN_HEIGHT, (GX2Color) {
|
||||
0, 0, 0, 0
|
||||
}) {
|
||||
bgImageColor.setImageColor((GX2Color) {
|
||||
42, 42, 42, 255
|
||||
}, 0);
|
||||
bgImageColor.setImageColor((GX2Color) {
|
||||
42, 42, 42, 255
|
||||
}, 1);
|
||||
bgImageColor.setImageColor((GX2Color) {
|
||||
42, 42, 42, 255
|
||||
}, 2);
|
||||
bgImageColor.setImageColor((GX2Color) {
|
||||
42, 42, 42, 255
|
||||
}, 3);
|
||||
append(&bgImageColor);
|
||||
}
|
||||
|
||||
|
@ -119,10 +119,10 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data){
|
||||
DEBUG_FUNCTION_LINE("Patching %s ...\n",function_data->function_name);
|
||||
if(function_data->functionType == STATIC_FUNCTION && function_data->alreadyPatched == 1) {
|
||||
if(new_isDynamicFunction((u32)OSEffectiveToPhysical((void*)function_data->realAddr))) {
|
||||
log_printf("The function %s is a dynamic function. Please fix that <3\n", function_data->function_name);
|
||||
DEBUG_FUNCTION_LINE("INFO: The function %s is a dynamic function.\n", function_data->function_name);
|
||||
function_data->functionType = DYNAMIC_FUNCTION;
|
||||
} else {
|
||||
log_printf("Skipping %s, its already patched\n", function_data->function_name);
|
||||
DEBUG_FUNCTION_LINE("Skipping %s, its already patched\n", function_data->function_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,9 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("%s is located at %08X!\n", function_data->function_name,real_addr);}
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("%s is located at %08X!\n", function_data->function_name,real_addr);
|
||||
}
|
||||
|
||||
physical = (u32)OSEffectiveToPhysical((void*)real_addr);
|
||||
if(!physical) {
|
||||
@ -147,7 +149,9 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("%s physical is located at %08X!\n", function_data->function_name,physical);}
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("%s physical is located at %08X!\n", function_data->function_name,physical);
|
||||
}
|
||||
|
||||
*(volatile u32 *)(call_addr) = (u32)(space);
|
||||
|
||||
@ -160,10 +164,13 @@ void new_PatchInvidualMethodHooks(replacement_data_plugin_t * plugin_data){
|
||||
// fill the restore instruction section
|
||||
function_data->realAddr = real_addr;
|
||||
function_data->restoreInstruction = *(space-1);
|
||||
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("function_data->realAddr = %08X!\n", function_data->realAddr);}
|
||||
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("function_data->restoreInstruction = %08X!\n",function_data->restoreInstruction) ;}
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("function_data->realAddr = %08X!\n", function_data->realAddr);
|
||||
}
|
||||
else{
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("function_data->restoreInstruction = %08X!\n",function_data->restoreInstruction) ;
|
||||
}
|
||||
} else {
|
||||
log_printf("Error. Can't save %s for restoring!\n", function_data->function_name);
|
||||
}
|
||||
|
||||
@ -242,9 +249,13 @@ void new_RestoreInvidualInstructions(replacement_data_plugin_t * plugin_data){
|
||||
log_printf("Its a dynamic function. We don't need to restore it!\n",function_data->function_name);
|
||||
} else {
|
||||
physical = (u32)OSEffectiveToPhysical((void*)function_data->realAddr); //When its an static function, we need to use the old location
|
||||
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("Restoring %08X to %08X\n",(u32)function_data->restoreInstruction,physical);}
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("Restoring %08X to %08X\n",(u32)function_data->restoreInstruction,physical);
|
||||
}
|
||||
SC0x25_KernelCopyData(physical,(u32)&function_data->restoreInstruction, 4);
|
||||
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("ICInvalidateRange %08X\n",(void*)function_data->realAddr);}
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("ICInvalidateRange %08X\n",(void*)function_data->realAddr);
|
||||
}
|
||||
ICInvalidateRange((void*)function_data->realAddr, 4);
|
||||
DCFlushRange((void*)function_data->realAddr, 4);
|
||||
log_printf("done\n");
|
||||
@ -265,18 +276,13 @@ s32 new_isDynamicFunction(u32 physicalAddress){
|
||||
u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_t library) {
|
||||
u32 real_addr = 0;
|
||||
|
||||
if(strcmp(functionName, "OSDynLoad_Acquire") == 0)
|
||||
{
|
||||
if(strcmp(functionName, "OSDynLoad_Acquire") == 0) {
|
||||
memcpy(&real_addr, &OSDynLoad_Acquire, 4);
|
||||
return real_addr;
|
||||
}
|
||||
else if(strcmp(functionName, "LiWaitOneChunk") == 0)
|
||||
{
|
||||
} else if(strcmp(functionName, "LiWaitOneChunk") == 0) {
|
||||
real_addr = (u32)addr_LiWaitOneChunk;
|
||||
return real_addr;
|
||||
}
|
||||
else if(strcmp(functionName, "LiBounceOneChunk") == 0)
|
||||
{
|
||||
} else if(strcmp(functionName, "LiBounceOneChunk") == 0) {
|
||||
//! not required on firmwares above 3.1.0
|
||||
if(OS_FIRMWARE >= 400)
|
||||
return 0;
|
||||
@ -296,7 +302,10 @@ u32 new_GetAddressOfFunction(const char * functionName,wups_loader_library_type_
|
||||
DEBUG_FUNCTION_LINE("Lets acquire handle for rpl: %s\n",rpl_handles[i].rplname);
|
||||
OSDynLoad_Acquire(rpl_handles[i].rplname, &rpl_handles[i].handle);
|
||||
}
|
||||
if(rpl_handles[i].handle == 0){log_printf("%s failed to acquire\n",rpl_handles[i].rplname); return 0;}
|
||||
if(rpl_handles[i].handle == 0) {
|
||||
log_printf("%s failed to acquire\n",rpl_handles[i].rplname);
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = rpl_handles[i].handle;
|
||||
break;
|
||||
}
|
||||
|
@ -30,7 +30,9 @@
|
||||
#include <utils/logger.h>
|
||||
|
||||
bool ElfTools::elfLoadSection(const Elf *elf, Elf_Scn *scn, const Elf32_Shdr *shdr,void *destination) {
|
||||
if (destination == NULL) { return false; }
|
||||
if (destination == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (shdr->sh_type) {
|
||||
case SHT_SYMTAB:
|
||||
@ -44,10 +46,12 @@ bool ElfTools::elfLoadSection(const Elf *elf, Elf_Scn *scn, const Elf32_Shdr *sh
|
||||
n += data->d_size;
|
||||
}
|
||||
return true;
|
||||
} case SHT_NOBITS: {
|
||||
}
|
||||
case SHT_NOBITS: {
|
||||
memset(destination, 0, shdr->sh_size);
|
||||
return true;
|
||||
} default:
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -158,9 +162,11 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
|
||||
case SHN_ABS: {
|
||||
symbol_addr = symtab[symbol].st_value;
|
||||
break;
|
||||
} case SHN_COMMON: {
|
||||
}
|
||||
case SHN_COMMON: {
|
||||
return false;
|
||||
} case SHN_UNDEF: {
|
||||
}
|
||||
case SHN_UNDEF: {
|
||||
|
||||
if (allow_globals) {
|
||||
DEBUG_FUNCTION_LINE("The elf still have unresolved relocations. This is not supported.");
|
||||
@ -205,7 +211,8 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} default: {
|
||||
}
|
||||
default: {
|
||||
if (symtab[symbol].st_other != 1) {
|
||||
return false;
|
||||
}
|
||||
@ -220,7 +227,8 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
|
||||
}
|
||||
}
|
||||
break;
|
||||
} case SHT_RELA: {
|
||||
}
|
||||
case SHT_RELA: {
|
||||
const Elf32_Rela *rela;
|
||||
Elf_Data *data;
|
||||
size_t i;
|
||||
@ -247,9 +255,11 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
|
||||
case SHN_ABS: {
|
||||
symbol_addr = symtab[symbol].st_value;
|
||||
break;
|
||||
} case SHN_COMMON: {
|
||||
}
|
||||
case SHN_COMMON: {
|
||||
return false;
|
||||
} case SHN_UNDEF: {
|
||||
}
|
||||
case SHN_UNDEF: {
|
||||
if (allow_globals) {
|
||||
DEBUG_FUNCTION_LINE("The elf still have unresolved relocations. This is not supported.");
|
||||
/*
|
||||
@ -292,7 +302,8 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
} default: {
|
||||
}
|
||||
default: {
|
||||
|
||||
if (symtab[symbol].st_other != 1) {
|
||||
return false;
|
||||
@ -333,7 +344,8 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
|
||||
case R_PPC_UADDR16: {
|
||||
value = (int)symbol_addr + addend;
|
||||
break;
|
||||
} case R_PPC_REL24:
|
||||
}
|
||||
case R_PPC_REL24:
|
||||
case R_PPC_PLTREL24:
|
||||
case R_PPC_LOCAL24PC:
|
||||
case R_PPC_REL14:
|
||||
@ -343,20 +355,23 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
|
||||
case R_PPC_ADDR30: {
|
||||
value = (int)symbol_addr + addend - (int)target;
|
||||
break;
|
||||
} case R_PPC_SECTOFF:
|
||||
}
|
||||
case R_PPC_SECTOFF:
|
||||
case R_PPC_SECTOFF_LO:
|
||||
case R_PPC_SECTOFF_HI:
|
||||
case R_PPC_SECTOFF_HA: {
|
||||
value = offset + addend;
|
||||
break;
|
||||
} case R_PPC_EMB_NADDR32:
|
||||
}
|
||||
case R_PPC_EMB_NADDR32:
|
||||
case R_PPC_EMB_NADDR16:
|
||||
case R_PPC_EMB_NADDR16_LO:
|
||||
case R_PPC_EMB_NADDR16_HI:
|
||||
case R_PPC_EMB_NADDR16_HA: {
|
||||
value = addend - (int)symbol_addr;
|
||||
break;
|
||||
} default:
|
||||
}
|
||||
default:
|
||||
DEBUG_FUNCTION_LINE("Unknown relocation type: %02X\n",type);
|
||||
goto exit_error;
|
||||
}
|
||||
@ -369,54 +384,64 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int addend, void *destinatio
|
||||
case R_PPC_EMB_NADDR32: {
|
||||
*(int *)target = value;
|
||||
break;
|
||||
} case R_PPC_ADDR24:
|
||||
}
|
||||
case R_PPC_ADDR24:
|
||||
case R_PPC_PLTREL24:
|
||||
case R_PPC_LOCAL24PC:
|
||||
case R_PPC_REL24: {
|
||||
*(int *)target =
|
||||
(*(int *)target & 0xfc000003) | (value & 0x03fffffc);
|
||||
break;
|
||||
} case R_PPC_ADDR16:
|
||||
}
|
||||
case R_PPC_ADDR16:
|
||||
case R_PPC_UADDR16:
|
||||
case R_PPC_EMB_NADDR16: {
|
||||
*(short *)target = value;
|
||||
break;
|
||||
} case R_PPC_ADDR16_HI:
|
||||
}
|
||||
case R_PPC_ADDR16_HI:
|
||||
case R_PPC_SECTOFF_HI:
|
||||
case R_PPC_EMB_NADDR16_HI: {
|
||||
*(short *)target = value >> 16;
|
||||
break;
|
||||
} case R_PPC_ADDR16_HA:
|
||||
}
|
||||
case R_PPC_ADDR16_HA:
|
||||
case R_PPC_SECTOFF_HA:
|
||||
case R_PPC_EMB_NADDR16_HA: {
|
||||
*(short *)target = (value >> 16) + ((value >> 15) & 1);
|
||||
break;
|
||||
} case R_PPC_ADDR16_LO:
|
||||
}
|
||||
case R_PPC_ADDR16_LO:
|
||||
case R_PPC_SECTOFF_LO:
|
||||
case R_PPC_EMB_NADDR16_LO: {
|
||||
*(short *)target = value & 0xffff;
|
||||
break;
|
||||
} case R_PPC_ADDR14:
|
||||
}
|
||||
case R_PPC_ADDR14:
|
||||
case R_PPC_REL14: {
|
||||
*(int *)target =
|
||||
(*(int *)target & 0xffff0003) | (value & 0x0000fffc);
|
||||
break;
|
||||
} case R_PPC_ADDR14_BRTAKEN:
|
||||
}
|
||||
case R_PPC_ADDR14_BRTAKEN:
|
||||
case R_PPC_REL14_BRTAKEN: {
|
||||
*(int *)target =
|
||||
(*(int *)target & 0xffdf0003) | (value & 0x0000fffc) |
|
||||
0x00200000;
|
||||
break;
|
||||
} case R_PPC_ADDR14_BRNTAKEN:
|
||||
}
|
||||
case R_PPC_ADDR14_BRNTAKEN:
|
||||
case R_PPC_REL14_BRNTAKEN: {
|
||||
*(int *)target =
|
||||
(*(int *)target & 0xffdf0003) | (value & 0x0000fffc);
|
||||
break;
|
||||
} case R_PPC_ADDR30: {
|
||||
}
|
||||
case R_PPC_ADDR30: {
|
||||
*(int *)target =
|
||||
(*(int *)target & 0x00000003) | (value & 0xfffffffc);
|
||||
break;
|
||||
}default:
|
||||
}
|
||||
default:
|
||||
goto exit_error;
|
||||
}
|
||||
|
||||
|
@ -122,8 +122,12 @@ bool PluginInformation::parseElf( Elf *elf) {
|
||||
|
||||
const char * path_c = getPath().c_str();
|
||||
|
||||
if(elf == NULL){ goto exit_error; }
|
||||
if(elf_kind(elf) != ELF_K_ELF){ goto exit_error; }
|
||||
if(elf == NULL) {
|
||||
goto exit_error;
|
||||
}
|
||||
if(elf_kind(elf) != ELF_K_ELF) {
|
||||
goto exit_error;
|
||||
}
|
||||
|
||||
ident = elf_getident(elf, &sz);
|
||||
|
||||
@ -172,7 +176,9 @@ bool PluginInformation::parseElf( Elf *elf) {
|
||||
goto exit_error;
|
||||
}
|
||||
|
||||
if(symtab == NULL){ goto exit_error; }
|
||||
if(symtab == NULL) {
|
||||
goto exit_error;
|
||||
}
|
||||
|
||||
if(!metadataRead(elf, symtab, symtab_count, symtab_strndx)) {
|
||||
goto exit_error;
|
||||
|
@ -42,18 +42,15 @@ CSettings::CSettings(){
|
||||
}
|
||||
|
||||
CSettings::~CSettings() {
|
||||
for(u32 i = 0; i < settingsValues.size(); i++)
|
||||
{
|
||||
for(u32 i = 0; i < settingsValues.size(); i++) {
|
||||
if(settingsValues[i].dataType == TypeString)
|
||||
delete settingsValues[i].strValue;
|
||||
}
|
||||
delete nullValue.strValue;
|
||||
}
|
||||
|
||||
void CSettings::SetDefault()
|
||||
{
|
||||
for(u32 i = 0; i < settingsValues.size(); i++)
|
||||
{
|
||||
void CSettings::SetDefault() {
|
||||
for(u32 i = 0; i < settingsValues.size(); i++) {
|
||||
if(settingsValues[i].dataType == TypeString)
|
||||
delete settingsValues[i].strValue;
|
||||
}
|
||||
@ -89,8 +86,7 @@ bool CSettings::Load(){
|
||||
|
||||
//! remove all windows crap signs
|
||||
size_t position;
|
||||
while(1 && !strBuffer.empty())
|
||||
{
|
||||
while(1 && !strBuffer.empty()) {
|
||||
position = strBuffer.find('\r');
|
||||
if(position == std::string::npos)
|
||||
break;
|
||||
@ -104,8 +100,7 @@ bool CSettings::Load(){
|
||||
if(lines.empty() || !ValidVersion(lines[0]))
|
||||
return false;
|
||||
|
||||
for(u32 i = 0; i < lines.size(); ++i)
|
||||
{
|
||||
for(u32 i = 0; i < lines.size(); ++i) {
|
||||
std::vector<std::string> valueSplit = StringTools::stringSplit(lines[i], "=");
|
||||
if(valueSplit.size() != 2)
|
||||
continue;
|
||||
@ -116,15 +111,12 @@ bool CSettings::Load(){
|
||||
while((valueSplit[1].size() > 0) && valueSplit[1][ valueSplit[1].size() - 1 ] == ' ')
|
||||
valueSplit[1].resize(valueSplit[1].size() - 1);
|
||||
|
||||
for(u32 n = 0; n < settingsNames.size(); n++)
|
||||
{
|
||||
for(u32 n = 0; n < settingsNames.size(); n++) {
|
||||
if(!settingsNames[n])
|
||||
continue;
|
||||
|
||||
if(valueSplit[0] == settingsNames[n])
|
||||
{
|
||||
switch(settingsValues[n].dataType)
|
||||
{
|
||||
if(valueSplit[0] == settingsNames[n]) {
|
||||
switch(settingsValues[n].dataType) {
|
||||
case TypeBool:
|
||||
settingsValues[n].bValue = atoi(valueSplit[1].c_str());
|
||||
break;
|
||||
@ -201,10 +193,8 @@ bool CSettings::Save(){
|
||||
|
||||
file.fwrite("%s%i\n", VERSION_LINE, VALID_VERSION);
|
||||
|
||||
for(u32 i = 0; i < settingsValues.size(); i++)
|
||||
{
|
||||
switch(settingsValues[i].dataType)
|
||||
{
|
||||
for(u32 i = 0; i < settingsValues.size(); i++) {
|
||||
switch(settingsValues[i].dataType) {
|
||||
case TypeBool:
|
||||
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].bValue);
|
||||
break;
|
||||
|
@ -25,8 +25,7 @@
|
||||
#include <vector>
|
||||
#include "SettingsEnums.h"
|
||||
|
||||
class CSettings
|
||||
{
|
||||
class CSettings {
|
||||
public:
|
||||
static CSettings *instance() {
|
||||
if(!settingsInstance)
|
||||
@ -71,146 +70,118 @@ public:
|
||||
MAX_VALUE
|
||||
};
|
||||
|
||||
static const u8 & getDataType(int idx)
|
||||
{
|
||||
static const u8 & getDataType(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE)
|
||||
return instance()->settingsValues[idx].dataType;
|
||||
|
||||
return instance()->nullValue.dataType;
|
||||
}
|
||||
|
||||
static const bool & getValueAsBool(int idx)
|
||||
{
|
||||
static const bool & getValueAsBool(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeBool)
|
||||
return instance()->settingsValues[idx].bValue;
|
||||
|
||||
return instance()->nullValue.bValue;
|
||||
}
|
||||
static const s8 & getValueAsS8(int idx)
|
||||
{
|
||||
static const s8 & getValueAsS8(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS8)
|
||||
return instance()->settingsValues[idx].cValue;
|
||||
|
||||
return instance()->nullValue.cValue;
|
||||
}
|
||||
static const u8 & getValueAsU8(int idx)
|
||||
{
|
||||
static const u8 & getValueAsU8(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU8)
|
||||
return instance()->settingsValues[idx].ucValue;
|
||||
|
||||
return instance()->nullValue.ucValue;
|
||||
}
|
||||
static const s16 & getValueAsS16(int idx)
|
||||
{
|
||||
static const s16 & getValueAsS16(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS16)
|
||||
return instance()->settingsValues[idx].sValue;
|
||||
|
||||
return instance()->nullValue.sValue;
|
||||
}
|
||||
static const u16 & getValueAsU16(int idx)
|
||||
{
|
||||
static const u16 & getValueAsU16(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU16)
|
||||
return instance()->settingsValues[idx].usValue;
|
||||
|
||||
return instance()->nullValue.usValue;
|
||||
}
|
||||
static const s32 & getValueAsS32(int idx)
|
||||
{
|
||||
static const s32 & getValueAsS32(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS32)
|
||||
return instance()->settingsValues[idx].iValue;
|
||||
|
||||
return instance()->nullValue.iValue;
|
||||
}
|
||||
static const u32 & getValueAsU32(int idx)
|
||||
{
|
||||
static const u32 & getValueAsU32(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU32)
|
||||
return instance()->settingsValues[idx].uiValue;
|
||||
|
||||
return instance()->nullValue.uiValue;
|
||||
}
|
||||
static const f32 & getValueAsF32(int idx)
|
||||
{
|
||||
static const f32 & getValueAsF32(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeF32)
|
||||
return instance()->settingsValues[idx].fValue;
|
||||
|
||||
return instance()->nullValue.fValue;
|
||||
}
|
||||
static const std::string & getValueAsString(int idx)
|
||||
{
|
||||
static const std::string & getValueAsString(int idx) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeString && instance()->settingsValues[idx].strValue)
|
||||
return *(instance()->settingsValues[idx].strValue);
|
||||
|
||||
return *(instance()->nullValue.strValue);
|
||||
}
|
||||
|
||||
static void setValueAsBool(int idx, const bool & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeBool)
|
||||
{
|
||||
static void setValueAsBool(int idx, const bool & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeBool) {
|
||||
instance()->settingsValues[idx].bValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsS8(int idx, const s8 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS8)
|
||||
{
|
||||
static void setValueAsS8(int idx, const s8 & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS8) {
|
||||
instance()->settingsValues[idx].cValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsU8(int idx, const u8 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU8)
|
||||
{
|
||||
static void setValueAsU8(int idx, const u8 & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU8) {
|
||||
instance()->settingsValues[idx].ucValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsS16(int idx, const s16 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS16)
|
||||
{
|
||||
static void setValueAsS16(int idx, const s16 & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS16) {
|
||||
instance()->settingsValues[idx].sValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsU16(int idx, const u16 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU16)
|
||||
{
|
||||
static void setValueAsU16(int idx, const u16 & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU16) {
|
||||
instance()->settingsValues[idx].usValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsS32(int idx, const s32 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS32)
|
||||
{
|
||||
static void setValueAsS32(int idx, const s32 & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeS32) {
|
||||
instance()->settingsValues[idx].iValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsU32(int idx, const u32 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU32)
|
||||
{
|
||||
static void setValueAsU32(int idx, const u32 & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeU32) {
|
||||
instance()->settingsValues[idx].uiValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsF32(int idx, const f32 & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeF32)
|
||||
{
|
||||
static void setValueAsF32(int idx, const f32 & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeF32) {
|
||||
instance()->settingsValues[idx].fValue = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
}
|
||||
static void setValueAsString(int idx, const std::string & val)
|
||||
{
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeString && instance()->settingsValues[idx].strValue)
|
||||
{
|
||||
static void setValueAsString(int idx, const std::string & val) {
|
||||
if(idx > INVALID && idx < MAX_VALUE && instance()->settingsValues[idx].dataType == TypeString && instance()->settingsValues[idx].strValue) {
|
||||
*(instance()->settingsValues[idx].strValue) = val;
|
||||
instance()->bChanged = true;
|
||||
}
|
||||
@ -225,12 +196,10 @@ protected:
|
||||
|
||||
static CSettings *settingsInstance;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
u8 dataType;
|
||||
|
||||
union
|
||||
{
|
||||
union {
|
||||
bool bValue;
|
||||
s8 cValue;
|
||||
u8 ucValue;
|
||||
|
@ -19,19 +19,16 @@
|
||||
#ifndef __SETTINGS_DEFS_
|
||||
#define __SETTINGS_DEFS_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int value;
|
||||
const char *name;
|
||||
} ValueString;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const ValueString *valueStrings;
|
||||
int type;
|
||||
int index;
|
||||
} SettingType;
|
||||
|
||||
|
||||
#endif // __SETTINGS_DEFS_
|
||||
|
Loading…
Reference in New Issue
Block a user