mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-11-16 15:49:23 +01:00
[Loader] Added simple, initial gui.
- Added all files for creating a gui. - Moved some of the module related into an own sub folder
This commit is contained in:
parent
b5153953de
commit
de95b2e599
@ -25,6 +25,7 @@ before_install:
|
|||||||
- wget https://download.sourceforge.net/devkitpro/devkitARM_r47-x86_64-linux.tar.bz2 -O devkitARM-linux.tar.bz2
|
- wget https://download.sourceforge.net/devkitpro/devkitARM_r47-x86_64-linux.tar.bz2 -O devkitARM-linux.tar.bz2
|
||||||
- wget https://github.com/Maschell/dynamic_libs/archive/lib.tar.gz -O dynamic_libs.tar.gz
|
- wget https://github.com/Maschell/dynamic_libs/archive/lib.tar.gz -O dynamic_libs.tar.gz
|
||||||
- wget https://github.com/Maschell/libutils/archive/master.tar.gz -O libutils.tar.gz
|
- wget https://github.com/Maschell/libutils/archive/master.tar.gz -O libutils.tar.gz
|
||||||
|
- wget https://github.com/Maschell/libgui/archive/master.tar.gz -O libgui.tar.gz
|
||||||
- wget https://github.com/aliaspider/libfat/archive/master.tar.gz -O libfat.tar.gz
|
- wget https://github.com/aliaspider/libfat/archive/master.tar.gz -O libfat.tar.gz
|
||||||
- wget https://github.com/dimok789/libiosuhax/archive/master.tar.gz -O libiosuhax.tar.gz
|
- wget https://github.com/dimok789/libiosuhax/archive/master.tar.gz -O libiosuhax.tar.gz
|
||||||
- wget https://github.com/Maschell/libntfs-wiiu/archive/master.tar.gz -O libntfs.tar.gz
|
- wget https://github.com/Maschell/libntfs-wiiu/archive/master.tar.gz -O libntfs.tar.gz
|
||||||
@ -36,6 +37,7 @@ install:
|
|||||||
- tar -xjf devkitARM-linux.tar.bz2 -C ${DEVKITPRO}/
|
- tar -xjf devkitARM-linux.tar.bz2 -C ${DEVKITPRO}/
|
||||||
- tar -xzvf dynamic_libs.tar.gz
|
- tar -xzvf dynamic_libs.tar.gz
|
||||||
- tar -xzvf libutils.tar.gz
|
- tar -xzvf libutils.tar.gz
|
||||||
|
- tar -xzvf libgui.tar.gz
|
||||||
- tar -xzvf libfat.tar.gz
|
- tar -xzvf libfat.tar.gz
|
||||||
- tar -xzvf libiosuhax.tar.gz
|
- tar -xzvf libiosuhax.tar.gz
|
||||||
- tar -xzvf libntfs.tar.gz
|
- tar -xzvf libntfs.tar.gz
|
||||||
@ -48,6 +50,7 @@ install:
|
|||||||
- (cd libntfs-wiiu-master && make wiiu-install)
|
- (cd libntfs-wiiu-master && make wiiu-install)
|
||||||
- (cd dynamic_libs-lib && make -j8 && make install)
|
- (cd dynamic_libs-lib && make -j8 && make install)
|
||||||
- (cd libutils-master && make -j8 && make install)
|
- (cd libutils-master && make -j8 && make install)
|
||||||
|
- (cd libgui-master && make -j8 && make install)
|
||||||
- (cd fs_wrapper-master && make -j8 && make install)
|
- (cd fs_wrapper-master && make -j8 && make install)
|
||||||
- (cd controller_patcher-master && make -j8 && make install)
|
- (cd controller_patcher-master && make -j8 && make install)
|
||||||
|
|
||||||
|
@ -33,13 +33,20 @@ print-% : ; @echo $* = $($*)
|
|||||||
TARGET := wiiupluginloader
|
TARGET := wiiupluginloader
|
||||||
BUILD := build
|
BUILD := build
|
||||||
BUILD_DBG := $(TARGET)_dbg
|
BUILD_DBG := $(TARGET)_dbg
|
||||||
SOURCES := src/libelf \
|
SOURCES := src/common \
|
||||||
SOURCES := src/patcher \
|
src/libelf \
|
||||||
src/common \
|
src/menu/content \
|
||||||
|
src/menu \
|
||||||
|
src/modules \
|
||||||
src/myutils \
|
src/myutils \
|
||||||
|
src/patcher \
|
||||||
|
src/resources \
|
||||||
|
src/settings \
|
||||||
src/
|
src/
|
||||||
|
|
||||||
DATA :=
|
DATA := data/images \
|
||||||
|
data/sounds \
|
||||||
|
data/fonts \
|
||||||
|
|
||||||
INCLUDES := src/libelf \
|
INCLUDES := src/libelf \
|
||||||
src/
|
src/
|
||||||
@ -66,7 +73,7 @@ MAKEFLAGS += --no-print-directory
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with the project
|
# any extra libraries we wish to link with the project
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -lm -lgcc -lfat -lntfs -liosuhax -lutils -ldynamiclibs
|
LIBS := -lgui -lm -lgcc -lfat -lntfs -liosuhax -lutils -ldynamiclibs -lfreetype -lgd -lpng -ljpeg -lz -lmad -lvorbisidec
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
@ -93,6 +100,8 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# automatically build a list of object files for our project
|
# automatically build a list of object files for our project
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
FILELIST := $(shell bash ./filelist.sh)
|
||||||
|
LANGUAGES := $(shell bash ./updatelang.sh)
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
@ -120,7 +129,8 @@ export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
|||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
-I$(PORTLIBS)/include -I$(CURDIR)/$(BUILD) \
|
-I$(PORTLIBS)/include -I$(CURDIR)/$(BUILD) \
|
||||||
-I$(PORTLIBS)/include/libutils
|
-I$(PORTLIBS)/include/libutils \
|
||||||
|
-I$(PORTLIBS)/include/freetype2 -I$(PORTLIBS)/include/libgui
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
BIN
loader/data/fonts/font.ttf
Normal file
BIN
loader/data/fonts/font.ttf
Normal file
Binary file not shown.
BIN
loader/data/images/GithubIcon.png
Normal file
BIN
loader/data/images/GithubIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 795 B |
BIN
loader/data/images/HomeButtonIcon.png
Normal file
BIN
loader/data/images/HomeButtonIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
BIN
loader/data/images/PlusButtonIcon.png
Normal file
BIN
loader/data/images/PlusButtonIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
loader/data/images/TwitterIcon.png
Normal file
BIN
loader/data/images/TwitterIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
70
loader/filelist.sh
Normal file
70
loader/filelist.sh
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
#
|
||||||
|
# Automatic resource file list generation
|
||||||
|
# Created by Dimok
|
||||||
|
|
||||||
|
outFile="./src/resources/filelist.cpp"
|
||||||
|
count_old=$(cat $outFile 2>/dev/null | tr -d '\n\n' | sed 's/[^0-9]*\([0-9]*\).*/\1/')
|
||||||
|
|
||||||
|
count=0
|
||||||
|
if [[ $OSTYPE == darwin* ]];
|
||||||
|
then
|
||||||
|
|
||||||
|
for i in $(gfind ./data/images/ ./data/sounds/ ./data/fonts/ -maxdepth 1 -type f \( ! -printf "%f\n" \) | sort -f)
|
||||||
|
do
|
||||||
|
files[count]=$i
|
||||||
|
count=$((count+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
for i in $(find ./data/images/ ./data/sounds/ ./data/fonts/ -maxdepth 1 -type f \( ! -printf "%f\n" \) | sort -f)
|
||||||
|
do
|
||||||
|
files[count]=$i
|
||||||
|
count=$((count+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$count_old" != "$count" ] || [ ! -f $outFile ]
|
||||||
|
then
|
||||||
|
|
||||||
|
echo "Generating filelist.c for $count files." >&2
|
||||||
|
cat <<EOF > $outFile
|
||||||
|
/****************************************************************************
|
||||||
|
* Resource files.
|
||||||
|
* This file is generated automatically.
|
||||||
|
* Includes $count files.
|
||||||
|
*
|
||||||
|
* NOTE:
|
||||||
|
* Any manual modification of this file will be overwriten by the generation.
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <resources/filelist.h>
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
for i in ${files[@]}
|
||||||
|
do
|
||||||
|
filename=${i%.*}
|
||||||
|
extension=${i##*.}
|
||||||
|
echo 'extern const u8 '$filename'_'$extension'[];' >> $outFile
|
||||||
|
echo 'extern const u32 '$filename'_'$extension'_size;' >> $outFile
|
||||||
|
echo '' >> $outFile
|
||||||
|
done
|
||||||
|
|
||||||
|
echo 'static ResourceFile ResourceList[] =' >> $outFile
|
||||||
|
echo '{' >> $outFile
|
||||||
|
|
||||||
|
for i in ${files[@]}
|
||||||
|
do
|
||||||
|
filename=${i%.*}
|
||||||
|
extension=${i##*.}
|
||||||
|
echo -e '\t{"'$i'", '$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile
|
||||||
|
echo '};' >> $outFile
|
||||||
|
echo '' >> $outFile
|
||||||
|
echo 'ResourceFile * getResourceList(){ return ResourceList; }' >> $outFile
|
||||||
|
echo '' >> $outFile
|
||||||
|
fi
|
26
loader/languages/english.lang
Normal file
26
loader/languages/english.lang
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# English translations for Wii U Plugin System loader
|
||||||
|
# This file is distributed under the same license as the PACKAGE package.
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-05-08 17:13+0200\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"Language: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
#: src/menu/content/ContentHome.cpp:20
|
||||||
|
msgid "Welcome to the Wii U plugin loader"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/menu/content/ContentHome.cpp:29
|
||||||
|
msgid "Exit to HBL "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/menu/content/ContentHome.cpp:32
|
||||||
|
msgid "Apply Patches"
|
||||||
|
msgstr ""
|
236
loader/src/Application.cpp
Normal file
236
loader/src/Application.cpp
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
* Modified by Maschell, 2018 for Wii U Plugin System loader
|
||||||
|
*
|
||||||
|
* 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 "Application.h"
|
||||||
|
#include "common/common.h"
|
||||||
|
#include <dynamic_libs/os_functions.h>
|
||||||
|
#include <gui/FreeTypeGX.h>
|
||||||
|
#include <gui/VPadController.h>
|
||||||
|
#include <gui/WPadController.h>
|
||||||
|
#include "resources/Resources.h"
|
||||||
|
#include <sounds/SoundHandler.hpp>
|
||||||
|
#include <utils/logger.h>
|
||||||
|
#include "settings/CSettings.h"
|
||||||
|
|
||||||
|
Application *Application::applicationInstance = NULL;
|
||||||
|
bool Application::exitApplication = false;
|
||||||
|
|
||||||
|
Application::Application()
|
||||||
|
: CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x20000)
|
||||||
|
, bgMusic(NULL)
|
||||||
|
, video(NULL)
|
||||||
|
, mainWindow(NULL)
|
||||||
|
, 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);
|
||||||
|
controller[3] = new WPadController(GuiTrigger::CHANNEL_4);
|
||||||
|
controller[4] = new WPadController(GuiTrigger::CHANNEL_5);
|
||||||
|
|
||||||
|
CSettings::instance()->Load();
|
||||||
|
|
||||||
|
//! create bgMusic
|
||||||
|
bgMusic = new GuiSound(Resources::GetFile("bgMusic.mp3"), Resources::GetFileSize("bgMusic.mp3"));
|
||||||
|
|
||||||
|
//! load language
|
||||||
|
loadLanguageFromConfig();
|
||||||
|
|
||||||
|
exitApplication = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Application::~Application(){
|
||||||
|
log_printf("Application::~Application(line %d): Destroy music\n",__LINE__);
|
||||||
|
delete bgMusic;
|
||||||
|
|
||||||
|
log_printf("Application::~Application(line %d): Destroy controller\n",__LINE__);
|
||||||
|
|
||||||
|
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__);
|
||||||
|
do{
|
||||||
|
log_printf("Application::~Application(line %d): Triggering AsyncDeleter\n",__LINE__);
|
||||||
|
AsyncDeleter::triggerDeleteProcess();
|
||||||
|
while(!AsyncDeleter::realListEmpty()){
|
||||||
|
os_usleep(1000);
|
||||||
|
}
|
||||||
|
}while(!AsyncDeleter::deleteListEmpty());
|
||||||
|
AsyncDeleter::destroyInstance();
|
||||||
|
|
||||||
|
log_printf("Application::~Application(line %d): Clear resources\n",__LINE__);
|
||||||
|
Resources::Clear();
|
||||||
|
|
||||||
|
log_printf("Application::~Application(line %d): Stop sound handler\n",__LINE__);
|
||||||
|
SoundHandler::DestroyInstance();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 Application::exec(){
|
||||||
|
//! start main GX2 thread
|
||||||
|
resumeThread();
|
||||||
|
//! now wait for thread to finish
|
||||||
|
shutdownThread();
|
||||||
|
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::reloadUI(){
|
||||||
|
reloadUIflag = true;
|
||||||
|
}
|
||||||
|
void Application::fadeOut(){
|
||||||
|
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){ 0, 0, 0, 255 });
|
||||||
|
|
||||||
|
for(s32 i = 0; i < 255; i += 10)
|
||||||
|
{
|
||||||
|
if(i > 255)
|
||||||
|
i = 255;
|
||||||
|
|
||||||
|
fadeOut.setAlpha(i / 255.0f);
|
||||||
|
|
||||||
|
//! start rendering DRC
|
||||||
|
video->prepareDrcRendering();
|
||||||
|
mainWindow->drawDrc(video);
|
||||||
|
|
||||||
|
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_ALWAYS);
|
||||||
|
fadeOut.draw(video);
|
||||||
|
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL);
|
||||||
|
|
||||||
|
video->drcDrawDone();
|
||||||
|
|
||||||
|
//! start rendering TV
|
||||||
|
video->prepareTvRendering();
|
||||||
|
|
||||||
|
mainWindow->drawTv(video);
|
||||||
|
|
||||||
|
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_ALWAYS);
|
||||||
|
fadeOut.draw(video);
|
||||||
|
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL);
|
||||||
|
|
||||||
|
video->tvDrawDone();
|
||||||
|
|
||||||
|
//! as last point update the effects as it can drop elements
|
||||||
|
mainWindow->updateEffects();
|
||||||
|
|
||||||
|
video->waitForVSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! one last cleared black screen
|
||||||
|
video->prepareDrcRendering();
|
||||||
|
video->drcDrawDone();
|
||||||
|
video->prepareTvRendering();
|
||||||
|
video->tvDrawDone();
|
||||||
|
video->waitForVSync();
|
||||||
|
video->tvEnable(false);
|
||||||
|
video->drcEnable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::executeThread(void){
|
||||||
|
log_printf("Application::executeThread(line %d): Initialize video\n",__LINE__);
|
||||||
|
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());
|
||||||
|
|
||||||
|
//! setup default Font
|
||||||
|
log_printf("Application::executeThread(line %d): Initialize main font system\n",__LINE__);
|
||||||
|
FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true);
|
||||||
|
GuiText::setPresetFont(fontSystem);
|
||||||
|
|
||||||
|
reloadUIflag = true;
|
||||||
|
if(bgMusic != NULL){
|
||||||
|
bgMusic->SetLoop(true);
|
||||||
|
bgMusic->SetVolume(50);
|
||||||
|
bgMusic->Stop(); //CHANG MEEEEEEEEEEEEEEEEEEE
|
||||||
|
}
|
||||||
|
|
||||||
|
while(reloadUIflag){
|
||||||
|
reloadUIflag = false;
|
||||||
|
exitCode = EXIT_RELAUNCH_ON_LOAD;
|
||||||
|
log_printf("Application::executeThread(line %d): Initialize the language\n",__LINE__);
|
||||||
|
loadLanguageFromConfig();
|
||||||
|
log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__);
|
||||||
|
mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight());
|
||||||
|
|
||||||
|
log_printf("Application::executeThread(line %d): Entering main loop\n",__LINE__);
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(controller[i]->data.buttons_d & VPAD_BUTTON_PLUS){
|
||||||
|
exitCode = APPLICATION_CLOSE_APPLY;
|
||||||
|
exitApplication = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(controller[i]->data.buttons_d & VPAD_BUTTON_HOME){
|
||||||
|
exitCode = APPLICATION_CLOSE_MIIMAKER;
|
||||||
|
exitApplication = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! update controller states
|
||||||
|
mainWindow->update(controller[i]);
|
||||||
|
}
|
||||||
|
mainWindow->process();
|
||||||
|
|
||||||
|
//! start rendering DRC
|
||||||
|
video->prepareDrcRendering();
|
||||||
|
mainWindow->drawDrc(video);
|
||||||
|
video->drcDrawDone();
|
||||||
|
|
||||||
|
//! start rendering TV
|
||||||
|
video->prepareTvRendering();
|
||||||
|
mainWindow->drawTv(video);
|
||||||
|
video->tvDrawDone();
|
||||||
|
|
||||||
|
//! enable screen after first frame render
|
||||||
|
if(video->getFrameCount() == 0) {
|
||||||
|
video->tvEnable(true);
|
||||||
|
video->drcEnable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! as last point update the effects as it can drop elements
|
||||||
|
mainWindow->updateEffects();
|
||||||
|
|
||||||
|
video->waitForVSync();
|
||||||
|
|
||||||
|
//! transfer elements to real delete list here after all processes are finished
|
||||||
|
//! the elements are transfered to another list to delete the elements in a separate thread
|
||||||
|
//! and avoid blocking the GUI thread
|
||||||
|
AsyncDeleter::triggerDeleteProcess();
|
||||||
|
}
|
||||||
|
DEBUG_FUNCTION_LINE("fadeOut\n");
|
||||||
|
fadeOut();
|
||||||
|
DEBUG_FUNCTION_LINE("MainWindow::destroyInstance();\n");
|
||||||
|
MainWindow::destroyInstance();
|
||||||
|
}
|
||||||
|
DEBUG_FUNCTION_LINE("Delete fontSystem\n");
|
||||||
|
delete fontSystem;
|
||||||
|
DEBUG_FUNCTION_LINE("Delete video\n");
|
||||||
|
delete video;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::loadLanguageFromConfig(){
|
||||||
|
if(!CSettings::getValueAsString(CSettings::AppLanguage).empty()){
|
||||||
|
std::string languagePath = std::string(DEFAULT_LANG_PATH) + "/" + CSettings::getValueAsString(CSettings::AppLanguage) + std::string(LANGUAGE_FILE_EXT);
|
||||||
|
gettextLoadLanguage(languagePath.c_str());
|
||||||
|
}
|
||||||
|
}
|
85
loader/src/Application.h
Normal file
85
loader/src/Application.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
* Modified by Maschell, 2018 for Wii U Plugin System loader
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
#define _APPLICATION_H
|
||||||
|
|
||||||
|
#include "menu/MainWindow.h"
|
||||||
|
#include <video/CVideo.h>
|
||||||
|
#include <system/CThread.h>
|
||||||
|
#include <language/gettext.h>
|
||||||
|
|
||||||
|
#define APPLICATION_CLOSE_APPLY 1
|
||||||
|
#define APPLICATION_CLOSE_MIIMAKER 2
|
||||||
|
|
||||||
|
class Application : public CThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Application * instance() {
|
||||||
|
if(!applicationInstance)
|
||||||
|
applicationInstance = new Application();
|
||||||
|
return applicationInstance;
|
||||||
|
}
|
||||||
|
static void destroyInstance() {
|
||||||
|
if(applicationInstance) {
|
||||||
|
delete applicationInstance;
|
||||||
|
applicationInstance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CVideo *getVideo(void) const {
|
||||||
|
return video;
|
||||||
|
}
|
||||||
|
MainWindow *getMainWindow(void) const {
|
||||||
|
return mainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiSound *getBgMusic(void) const {
|
||||||
|
return bgMusic;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 exec(void);
|
||||||
|
void fadeOut(void);
|
||||||
|
|
||||||
|
void reloadUI(void);
|
||||||
|
|
||||||
|
void quit(s32 code) {
|
||||||
|
exitCode = code;
|
||||||
|
exitApplication = true;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Application();
|
||||||
|
|
||||||
|
virtual ~Application();
|
||||||
|
|
||||||
|
static Application *applicationInstance;
|
||||||
|
static bool exitApplication;
|
||||||
|
|
||||||
|
void executeThread(void);
|
||||||
|
|
||||||
|
void loadLanguageFromConfig();
|
||||||
|
|
||||||
|
bool reloadUIflag = false;
|
||||||
|
|
||||||
|
GuiSound *bgMusic;
|
||||||
|
CVideo *video;
|
||||||
|
MainWindow *mainWindow;
|
||||||
|
GuiController *controller[5];
|
||||||
|
s32 exitCode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_APPLICATION_H
|
@ -8,7 +8,7 @@ extern "C" {
|
|||||||
#include <dynamic_libs/os_defs.h>
|
#include <dynamic_libs/os_defs.h>
|
||||||
|
|
||||||
#define CAFE_OS_SD_PATH "/vol/external01"
|
#define CAFE_OS_SD_PATH "/vol/external01"
|
||||||
#define GAME_MOD_FOLDER "/sdcafiine"
|
#define WIIU_PATH "/wiiu"
|
||||||
#define SD_PATH "sd:"
|
#define SD_PATH "sd:"
|
||||||
#define USB_PATH "usb:"
|
#define USB_PATH "usb:"
|
||||||
#define DEFAULT_NAME_PACKAGE "DEFAULT"
|
#define DEFAULT_NAME_PACKAGE "DEFAULT"
|
||||||
@ -25,6 +25,10 @@ extern "C" {
|
|||||||
#define EXIT_HBL_EXIT 0xFFFFFFFE
|
#define EXIT_HBL_EXIT 0xFFFFFFFE
|
||||||
#define EXIT_RELAUNCH_ON_LOAD 0xFFFFFFFD
|
#define EXIT_RELAUNCH_ON_LOAD 0xFFFFFFFD
|
||||||
|
|
||||||
|
#define DEFAULT_WUPSLOADER_PATH SD_PATH WIIU_PATH "/apps/wiiupluginsystem"
|
||||||
|
#define DEFAULT_LANG_PATH DEFAULT_WUPSLOADER_PATH "/languages"
|
||||||
|
#define LANGUAGE_FILE_EXT ".lang"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,20 +10,27 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <dynamic_libs/os_functions.h>
|
#include "dynamic_libs/os_functions.h"
|
||||||
#include <dynamic_libs/socket_functions.h>
|
#include "dynamic_libs/gx2_functions.h"
|
||||||
#include <dynamic_libs/sys_functions.h>
|
#include "dynamic_libs/ax_functions.h"
|
||||||
#include <dynamic_libs/fs_functions.h>
|
#include "dynamic_libs/socket_functions.h"
|
||||||
#include <dynamic_libs/vpad_functions.h>
|
#include "dynamic_libs/sys_functions.h"
|
||||||
|
#include "dynamic_libs/fs_functions.h"
|
||||||
|
#include "dynamic_libs/nn_nim_functions.h"
|
||||||
|
#include "dynamic_libs/vpad_functions.h"
|
||||||
|
#include "dynamic_libs/padscore_functions.h"
|
||||||
|
#include "dynamic_libs/proc_ui_functions.h"
|
||||||
|
|
||||||
#include <utils/logger.h>
|
#include <utils/logger.h>
|
||||||
#include <fs/FSUtils.h>
|
#include <fs/FSUtils.h>
|
||||||
#include <fs/sd_fat_devoptab.h>
|
#include <fs/sd_fat_devoptab.h>
|
||||||
#include <utils/utils.h>
|
#include <utils/utils.h>
|
||||||
#include <system/exception_handler.h>
|
#include <system/exception_handler.h>
|
||||||
|
#include <system/memory.h>
|
||||||
|
|
||||||
#include "common/retain_vars.h"
|
#include "common/retain_vars.h"
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "ModuleData.h"
|
#include "modules/ModuleData.h"
|
||||||
|
|
||||||
#include <utils/function_patcher.h>
|
#include <utils/function_patcher.h>
|
||||||
|
|
||||||
@ -34,12 +41,14 @@
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "Application.h"
|
||||||
#include "patcher/function_patcher.h"
|
#include "patcher/function_patcher.h"
|
||||||
#include "patcher/hooks_patcher.h"
|
#include "patcher/hooks_patcher.h"
|
||||||
#include "myutils/mocha.h"
|
#include "myutils/mocha.h"
|
||||||
#include "myutils/libntfs.h"
|
#include "myutils/libntfs.h"
|
||||||
#include "myutils/libfat.h"
|
#include "myutils/libfat.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "settings/CSettings.h"
|
||||||
|
|
||||||
static bool loadSamplePlugins();
|
static bool loadSamplePlugins();
|
||||||
static void ApplyPatches();
|
static void ApplyPatches();
|
||||||
@ -52,6 +61,8 @@ static void loadElf(std::vector<ModuleData *>* modules, const char * elfPath, ui
|
|||||||
|
|
||||||
u8 isFirstBoot __attribute__((section(".data"))) = 1;
|
u8 isFirstBoot __attribute__((section(".data"))) = 1;
|
||||||
|
|
||||||
|
#define PLUGIN_LOCATION_END_ADDRESS 0x01000000
|
||||||
|
|
||||||
/* Entry point */
|
/* Entry point */
|
||||||
extern "C" int Menu_Main(int argc, char **argv){
|
extern "C" int Menu_Main(int argc, char **argv){
|
||||||
if(gAppStatus == 2){
|
if(gAppStatus == 2){
|
||||||
@ -62,9 +73,17 @@ extern "C" int Menu_Main(int argc, char **argv){
|
|||||||
InitSocketFunctionPointers(); //For logging
|
InitSocketFunctionPointers(); //For logging
|
||||||
InitSysFunctionPointers();
|
InitSysFunctionPointers();
|
||||||
InitFSFunctionPointers();
|
InitFSFunctionPointers();
|
||||||
|
InitGX2FunctionPointers();
|
||||||
|
InitSysFunctionPointers();
|
||||||
|
InitVPadFunctionPointers();
|
||||||
|
InitPad ScoreFunctionPointers();
|
||||||
|
InitAXFunctionPointers();
|
||||||
|
InitProcUIFunctionPointers();
|
||||||
|
|
||||||
log_init();
|
log_init();
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE("We have %d kb for plugins.\n",(PLUGIN_LOCATION_END_ADDRESS-getApplicationEndAddr())/1024);
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION);
|
DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION);
|
||||||
|
|
||||||
//setup_os_exceptions();
|
//setup_os_exceptions();
|
||||||
@ -77,7 +96,27 @@ extern "C" int Menu_Main(int argc, char **argv){
|
|||||||
if(!loadSamplePlugins()){
|
if(!loadSamplePlugins()){
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!*******************************************************************
|
||||||
|
//! Initialize heap memory *
|
||||||
|
//!*******************************************************************
|
||||||
|
DEBUG_FUNCTION_LINE("Initialize memory management\n");
|
||||||
|
memoryInitialize();
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE("Start main application\n");
|
||||||
|
s32 result = Application::instance()->exec();
|
||||||
|
DEBUG_FUNCTION_LINE("Main application stopped result: %d\n",result);
|
||||||
|
Application::destroyInstance();
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE("Release memory\n");
|
||||||
|
memoryRelease();
|
||||||
|
CSettings::destroyInstance();
|
||||||
|
if(result == APPLICATION_CLOSE_MIIMAKER){
|
||||||
|
DeInit();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Reset everything when were going back to the Mii Maker
|
//Reset everything when were going back to the Mii Maker
|
||||||
if(!isFirstBoot && isInMiiMakerHBL()){
|
if(!isFirstBoot && isInMiiMakerHBL()){
|
||||||
@ -182,8 +221,6 @@ s32 isInMiiMakerHBL(){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PLUGIN_LOCATION_END_ADDRESS 0x01000000
|
|
||||||
|
|
||||||
bool loadSamplePlugins(){
|
bool loadSamplePlugins(){
|
||||||
if((gSDInitDone & WUPS_SD_MOUNTED) > 0){
|
if((gSDInitDone & WUPS_SD_MOUNTED) > 0){
|
||||||
DEBUG_FUNCTION_LINE("Mounting successful. Loading modules\n");
|
DEBUG_FUNCTION_LINE("Mounting successful. Loading modules\n");
|
||||||
|
294
loader/src/menu/MainWindow.cpp
Normal file
294
loader/src/menu/MainWindow.cpp
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
* Modified by Maschell, 2018 for Wii U Plugin System loader
|
||||||
|
*
|
||||||
|
* 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 <dynamic_libs/os_functions.h>
|
||||||
|
#include <dynamic_libs/socket_functions.h>
|
||||||
|
#include <dynamic_libs/padscore_functions.h>
|
||||||
|
#include <utils/StringTools.h>
|
||||||
|
#include <utils/logger.h>
|
||||||
|
#include "MainWindow.h"
|
||||||
|
#include "MainWindowGUI.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
MainWindow * MainWindow::instance = NULL;
|
||||||
|
|
||||||
|
MainWindow::MainWindow(s32 w, s32 h)
|
||||||
|
: width(w)
|
||||||
|
, 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());
|
||||||
|
pointerImg[i] = new GuiImage(pointerImgData[i]);
|
||||||
|
pointerImg[i]->setScale(1.5f);
|
||||||
|
pointerValid[i] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetupMainView();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
|
||||||
|
while(!tvElements.empty())
|
||||||
|
{
|
||||||
|
delete tvElements[0];
|
||||||
|
remove(tvElements[0]);
|
||||||
|
}
|
||||||
|
while(!drcElements.empty())
|
||||||
|
{
|
||||||
|
delete drcElements[0];
|
||||||
|
remove(drcElements[0]);
|
||||||
|
}
|
||||||
|
for(s32 i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
delete pointerImg[i];
|
||||||
|
Resources::RemoveImageData(pointerImgData[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
u32 n;
|
||||||
|
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++)
|
||||||
|
{
|
||||||
|
if(tvElements[i] == drcElements[n])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(n == drcElements.size())
|
||||||
|
{
|
||||||
|
tvElements[i]->updateEffects();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
u32 n;
|
||||||
|
for(n = 0; (n < drcSize) && (n < drcElements.size()); n++)
|
||||||
|
{
|
||||||
|
if(tvElements[i] == drcElements[n])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(n == drcElements.size())
|
||||||
|
{
|
||||||
|
tvElements[i]->process();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
u32 drcSize = drcElements.size();
|
||||||
|
|
||||||
|
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||||
|
{
|
||||||
|
drcElements[i]->update(controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
u32 tvSize = tvElements.size();
|
||||||
|
|
||||||
|
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||||
|
{
|
||||||
|
tvElements[i]->update(controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// //! only update TV elements that are not updated yet because they are on DRC
|
||||||
|
// for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||||
|
// {
|
||||||
|
// u32 n;
|
||||||
|
// for(n = 0; (n < drcSize) && (n < drcElements.size()); n++)
|
||||||
|
// {
|
||||||
|
// if(tvElements[i] == drcElements[n])
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// if(n == drcElements.size())
|
||||||
|
// {
|
||||||
|
// tvElements[i]->update(controller);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
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;
|
||||||
|
pointerImg[wpadIdx]->setPosition(posX, posY);
|
||||||
|
pointerImg[wpadIdx]->setAngle(controller->data.pointerAngle);
|
||||||
|
pointerValid[wpadIdx] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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])
|
||||||
|
{
|
||||||
|
pointerImg[i]->setAlpha(0.5f);
|
||||||
|
pointerImg[i]->draw(video);
|
||||||
|
pointerImg[i]->setAlpha(1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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])
|
||||||
|
{
|
||||||
|
pointerImg[i]->draw(video);
|
||||||
|
pointerValid[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::SetupMainView(){
|
||||||
|
DrcFrame = new MainWindowGUI(width,height);
|
||||||
|
TvFrame = DrcFrame;
|
||||||
|
appendTv(TvFrame);
|
||||||
|
appendDrc(DrcFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::appendToAllElements(GuiElement * element){
|
||||||
|
u32 drcSize = drcElements.size();
|
||||||
|
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||||
|
{
|
||||||
|
GuiFrame * realElement = dynamic_cast<GuiFrame*>(drcElements[i]);
|
||||||
|
if(realElement != NULL){
|
||||||
|
realElement->append(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 tvSize = tvElements.size();
|
||||||
|
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||||
|
{
|
||||||
|
GuiFrame * realElement = dynamic_cast<GuiFrame*>(tvElements[i]);
|
||||||
|
if(realElement != NULL){
|
||||||
|
realElement->append(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::removeFromAllElements(GuiElement * element){
|
||||||
|
u32 drcSize = drcElements.size();
|
||||||
|
for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i)
|
||||||
|
{
|
||||||
|
GuiFrame * realElement = dynamic_cast<GuiFrame*>(drcElements[i]);
|
||||||
|
if(realElement != NULL){
|
||||||
|
realElement->remove(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 tvSize = tvElements.size();
|
||||||
|
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||||
|
{
|
||||||
|
GuiFrame * realElement = dynamic_cast<GuiFrame*>(tvElements[i]);
|
||||||
|
if(realElement != NULL){
|
||||||
|
realElement->remove(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::setState(s32 val, s32 c){
|
||||||
|
u32 drcSize = drcElements.size();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
drcElements[i]->clearState(val,c);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 tvSize = tvElements.size();
|
||||||
|
for(u32 i = 0; (i < tvSize) && (i < tvElements.size()); ++i)
|
||||||
|
{
|
||||||
|
tvElements[i]->clearState(val,c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::OnCloseEffectFinish(GuiElement *element){
|
||||||
|
//! remove element from draw list and push to delete queue
|
||||||
|
remove(element);
|
||||||
|
|
||||||
|
AsyncDeleter::pushForDelete(element);
|
||||||
|
|
||||||
|
clearState(GuiElement::STATE_DISABLE_INPUT);
|
||||||
|
}
|
173
loader/src/menu/MainWindow.h
Normal file
173
loader/src/menu/MainWindow.h
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 _MAIN_WINDOW_H_
|
||||||
|
#define _MAIN_WINDOW_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <queue>
|
||||||
|
#include <gui/Gui.h>
|
||||||
|
#include <system/CMutex.h>
|
||||||
|
|
||||||
|
class CVideo;
|
||||||
|
|
||||||
|
class MainWindow : public sigslot::has_slots<>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~MainWindow();
|
||||||
|
|
||||||
|
static MainWindow *instance;
|
||||||
|
|
||||||
|
static MainWindow *getInstance(s32 w,s32 h) {
|
||||||
|
if(!instance){
|
||||||
|
instance = new MainWindow(w, h);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MainWindow *getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void destroyInstance() {
|
||||||
|
if(instance){
|
||||||
|
delete instance;
|
||||||
|
instance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void appendTv(GuiElement *e)
|
||||||
|
{
|
||||||
|
if(!e)
|
||||||
|
return;
|
||||||
|
|
||||||
|
removeTv(e);
|
||||||
|
tvElements.push_back(e);
|
||||||
|
}
|
||||||
|
void appendDrc(GuiElement *e)
|
||||||
|
{
|
||||||
|
if(!e)
|
||||||
|
return;
|
||||||
|
|
||||||
|
removeDrc(e);
|
||||||
|
drcElements.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void append(GuiElement *e)
|
||||||
|
{
|
||||||
|
appendTv(e);
|
||||||
|
appendDrc(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void insertTv(u32 pos, GuiElement *e)
|
||||||
|
{
|
||||||
|
if(!e)
|
||||||
|
return;
|
||||||
|
|
||||||
|
removeTv(e);
|
||||||
|
tvElements.insert(tvElements.begin() + pos, e);
|
||||||
|
}
|
||||||
|
void insertDrc(u32 pos, GuiElement *e)
|
||||||
|
{
|
||||||
|
if(!e)
|
||||||
|
return;
|
||||||
|
|
||||||
|
removeDrc(e);
|
||||||
|
drcElements.insert(drcElements.begin() + pos, 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])
|
||||||
|
{
|
||||||
|
tvElements.erase(tvElements.begin() + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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 appendToAllElements(GuiElement * element);
|
||||||
|
void removeFromAllElements(GuiElement * element);
|
||||||
|
void setState(s32 i, s32 c = -1 );
|
||||||
|
void clearState(s32 i, s32 c = -1);
|
||||||
|
|
||||||
|
void lockGUI(){
|
||||||
|
guiMutex.lock();
|
||||||
|
}
|
||||||
|
void unlockGUI(){
|
||||||
|
guiMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MainWindow(s32 w, s32 h);
|
||||||
|
void SetupMainView(void);
|
||||||
|
|
||||||
|
void OnOpenEffectFinish(GuiElement *element);
|
||||||
|
void OnCloseEffectFinish(GuiElement *element);
|
||||||
|
|
||||||
|
s32 width, height;
|
||||||
|
std::vector<GuiElement *> drcElements;
|
||||||
|
std::vector<GuiElement *> tvElements;
|
||||||
|
|
||||||
|
GuiSound *ClickSound;
|
||||||
|
|
||||||
|
GuiFrame * TvFrame;
|
||||||
|
GuiFrame * DrcFrame;
|
||||||
|
|
||||||
|
GuiImageData *pointerImgData[4];
|
||||||
|
GuiImage *pointerImg[4];
|
||||||
|
bool pointerValid[4];
|
||||||
|
|
||||||
|
CMutex guiMutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_MAIN_WINDOW_H_
|
62
loader/src/menu/MainWindowContent.cpp
Normal file
62
loader/src/menu/MainWindowContent.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2016-2018 Maschell
|
||||||
|
*
|
||||||
|
* 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 "MainWindowContent.h"
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
append(&bgImageColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentTemplate * MainWindowContent::getContent(){
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindowContent::SetScreen(ContentTemplate * new_content){
|
||||||
|
RemoveScreen();
|
||||||
|
if(new_content){
|
||||||
|
//while(content != NULL); //hopefully this shit don't kill us.
|
||||||
|
|
||||||
|
content = new_content;
|
||||||
|
append(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowContent::RemoveScreen(){
|
||||||
|
remove(content);
|
||||||
|
delete content;
|
||||||
|
content = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowContent::OnCloseEffectFinish(GuiElement *element){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindowContent::~MainWindowContent(){
|
||||||
|
remove(&bgImageColor);
|
||||||
|
RemoveScreen();
|
||||||
|
}
|
58
loader/src/menu/MainWindowContent.h
Normal file
58
loader/src/menu/MainWindowContent.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2016-2018 Maschell
|
||||||
|
*
|
||||||
|
* 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 _MAIN_WINDOW_CONTENT_H_
|
||||||
|
#define _MAIN_WINDOW_CONTENT_H_
|
||||||
|
|
||||||
|
#include <gui/Gui.h>
|
||||||
|
#include <language/gettext.h>
|
||||||
|
#include <system/AsyncDeleter.h>
|
||||||
|
|
||||||
|
#include "content/ContentTemplate.h"
|
||||||
|
#include "content/ContentHome.h"
|
||||||
|
#include "MainWindowContent.h"
|
||||||
|
|
||||||
|
class MainWindowContent : public GuiFrame, public sigslot::has_slots<>{
|
||||||
|
public:
|
||||||
|
enum eContentNames{
|
||||||
|
CONTENT_HOME,
|
||||||
|
};
|
||||||
|
|
||||||
|
MainWindowContent(s32 w, s32 h);
|
||||||
|
virtual ~MainWindowContent();
|
||||||
|
|
||||||
|
void SetScreen(ContentTemplate * new_content);
|
||||||
|
void RemoveScreen();
|
||||||
|
ContentTemplate * getContent();
|
||||||
|
|
||||||
|
//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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
s32 width, height;
|
||||||
|
GuiImage bgImageColor;
|
||||||
|
|
||||||
|
ContentTemplate * content = NULL;
|
||||||
|
|
||||||
|
void OnCloseEffectFinish(GuiElement *element);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_MAIN_WINDOW_CONTENT_H_
|
42
loader/src/menu/MainWindowGUI.cpp
Normal file
42
loader/src/menu/MainWindowGUI.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2016-2018 Maschell
|
||||||
|
*
|
||||||
|
* 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 "MainWindowGUI.h"
|
||||||
|
#include "MenuCommon.h"
|
||||||
|
|
||||||
|
MainWindowGUI::MainWindowGUI(s32 w, s32 h)
|
||||||
|
: GuiFrame(w, h)
|
||||||
|
, width(w)
|
||||||
|
, height(h)
|
||||||
|
, content(SCREEN_WIDTH,h){
|
||||||
|
ContentTemplate * curTemplate = content.createNewContent(MainWindowContent::CONTENT_HOME);
|
||||||
|
content.SetScreen(curTemplate);
|
||||||
|
append(&content);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowGUI::setState(s32 i, s32 c){
|
||||||
|
GuiFrame::setState(i,c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowGUI::process(){
|
||||||
|
GuiFrame::process();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindowGUI::~MainWindowGUI(){
|
||||||
|
content.RemoveScreen();
|
||||||
|
remove(&content);
|
||||||
|
}
|
||||||
|
|
38
loader/src/menu/MainWindowGUI.h
Normal file
38
loader/src/menu/MainWindowGUI.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2016-2018 Maschell
|
||||||
|
*
|
||||||
|
* 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 _MAIN_WINDOW_GUI_H_
|
||||||
|
#define _MAIN_WINDOW_GUI_H_
|
||||||
|
|
||||||
|
#include <gui/Gui.h>
|
||||||
|
#include "MainWindowContent.h"
|
||||||
|
#include "menu/MainWindow.h"
|
||||||
|
#include "menu/content/ContentTemplate.h"
|
||||||
|
#include <language/gettext.h>
|
||||||
|
|
||||||
|
class MainWindowGUI : public GuiFrame, public sigslot::has_slots<>{
|
||||||
|
public:
|
||||||
|
MainWindowGUI(s32 w, s32 h);
|
||||||
|
virtual ~MainWindowGUI();
|
||||||
|
private:
|
||||||
|
s32 width, height;
|
||||||
|
MainWindowContent content;
|
||||||
|
|
||||||
|
void setState(s32 i, s32 c);
|
||||||
|
void process();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_MAIN_WINDOW_GUI_H_
|
31
loader/src/menu/MenuCommon.h
Normal file
31
loader/src/menu/MenuCommon.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2016-2018 Maschell
|
||||||
|
*
|
||||||
|
* 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 _MENU_COMMON_H_
|
||||||
|
#define _MENU_COMMON_H_
|
||||||
|
|
||||||
|
#define SCREEN_WIDTH 1280
|
||||||
|
#define SCREEN_HEIGHT 720
|
||||||
|
|
||||||
|
#define CONTENT_WIDTH (1280 - 260)
|
||||||
|
|
||||||
|
#define CONTENT_EXPANDABLE_FRAME_HEADER_HEIGHT 60
|
||||||
|
|
||||||
|
|
||||||
|
#define MENU_LIST_WIDTH 260
|
||||||
|
#define MENU_LIST_ELEMENT_HEIGHT 70
|
||||||
|
|
||||||
|
#endif
|
95
loader/src/menu/content/ContentHome.cpp
Normal file
95
loader/src/menu/content/ContentHome.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2016-2018 Maschell
|
||||||
|
*
|
||||||
|
* 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 "ContentHome.h"
|
||||||
|
|
||||||
|
ContentHome::ContentHome():ContentTemplate()
|
||||||
|
, welcomeHeadLineLabel(gettext("Welcome to the Wii U plugin loader"))
|
||||||
|
, twitterLogoImageData(Resources::GetImageData("TwitterIcon.png"))
|
||||||
|
, twitterLogoImage(twitterLogoImageData)
|
||||||
|
, githubLogoImageData(Resources::GetImageData("GithubIcon.png"))
|
||||||
|
, githubLogoImage(githubLogoImageData)
|
||||||
|
, twitterLabel("MaschellDev")
|
||||||
|
, URLLabel("github.com/Maschell/WiiUPluginSystem")
|
||||||
|
, homebutton_imgdata(Resources::GetImageData("HomeButtonIcon.png"))
|
||||||
|
, homebutton_img(homebutton_imgdata)
|
||||||
|
, exitHome(gettext("Exit to HBL "))
|
||||||
|
, plusbutton_imgdata(Resources::GetImageData("PlusButtonIcon.png"))
|
||||||
|
, plusbutton_img(plusbutton_imgdata)
|
||||||
|
, exitPlus(gettext("Apply Patches"))
|
||||||
|
{
|
||||||
|
glm::vec4 textColor = glm::vec4(1.0f,1.0f,1.0f,1.0f);
|
||||||
|
|
||||||
|
homebutton_img.setAlignment(ALIGN_LEFT);
|
||||||
|
exitHome.setPosition(46,-8);
|
||||||
|
exitHome.setFontSize(35);
|
||||||
|
exitHome.setColor(textColor);
|
||||||
|
exitHome.setAlignment(ALIGN_LEFT);
|
||||||
|
exitHomeFrame.setAlignment(ALIGN_BOTTOM|ALIGN_RIGHT);
|
||||||
|
exitHomeFrame.setPosition(-250,40);
|
||||||
|
exitHomeFrame.append(&homebutton_img);
|
||||||
|
exitHomeFrame.append(&exitHome);
|
||||||
|
exitHomeFrame.setScale(0.7f);
|
||||||
|
|
||||||
|
plusbutton_img.setAlignment(ALIGN_LEFT);
|
||||||
|
exitPlus.setPosition(46,-8);
|
||||||
|
exitPlus.setFontSize(35);
|
||||||
|
exitPlus.setColor(textColor);
|
||||||
|
exitPlus.setAlignment(ALIGN_LEFT);
|
||||||
|
exitPlusFrame.setAlignment(ALIGN_BOTTOM|ALIGN_RIGHT);
|
||||||
|
exitPlusFrame.setPosition(-250,80);
|
||||||
|
exitPlusFrame.append(&plusbutton_img);
|
||||||
|
exitPlusFrame.append(&exitPlus);
|
||||||
|
exitPlusFrame.setScale(0.7f);
|
||||||
|
|
||||||
|
welcomeHeadLineLabel.setColor(textColor);
|
||||||
|
welcomeHeadLineLabel.setAlignment(ALIGN_MIDDLE|ALIGN_TOP);
|
||||||
|
welcomeHeadLineLabel.setFontSize(40);
|
||||||
|
welcomeHeadLineLabel.setPosition(-330,-50);
|
||||||
|
|
||||||
|
twitterLogoImage.setAlignment(ALIGN_BOTTOM|ALIGN_LEFT);
|
||||||
|
twitterLogoImage.setPosition(10,20);
|
||||||
|
twitterLabel.setAlignment(ALIGN_BOTTOM|ALIGN_LEFT);
|
||||||
|
twitterLabel.setColor(textColor);
|
||||||
|
twitterLabel.setPosition(52,50);
|
||||||
|
|
||||||
|
githubLogoImage.setAlignment(ALIGN_BOTTOM|ALIGN_LEFT);
|
||||||
|
githubLogoImage.setPosition(240,20);
|
||||||
|
|
||||||
|
URLLabel.setColor(textColor);
|
||||||
|
URLLabel.setAlignment(ALIGN_BOTTOM|ALIGN_LEFT);
|
||||||
|
URLLabel.setPosition(280,50);
|
||||||
|
|
||||||
|
append(&welcomeHeadLineLabel);
|
||||||
|
append(&twitterLogoImage);
|
||||||
|
append(&githubLogoImage);
|
||||||
|
append(&twitterLabel);
|
||||||
|
append(&URLLabel);
|
||||||
|
append(&exitHomeFrame);
|
||||||
|
append(&exitPlusFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentHome::~ContentHome(){
|
||||||
|
//Resources::RemoveImageData(logoImageData); <-- will reduce lag. Will be deleted at the end anyway
|
||||||
|
remove(&bgImageColor);
|
||||||
|
remove(&welcomeHeadLineLabel);
|
||||||
|
remove(&twitterLogoImage);
|
||||||
|
remove(&githubLogoImage);
|
||||||
|
remove(&twitterLabel);
|
||||||
|
remove(&URLLabel);
|
||||||
|
remove(&exitHomeFrame);
|
||||||
|
remove(&exitPlusFrame);
|
||||||
|
}
|
57
loader/src/menu/content/ContentHome.h
Normal file
57
loader/src/menu/content/ContentHome.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2016-2018 Maschell
|
||||||
|
*
|
||||||
|
* 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 _CONTENT_HOME_H
|
||||||
|
#define _CONTENT_HOME_H
|
||||||
|
|
||||||
|
#include "gui/Gui.h"
|
||||||
|
#include "ContentTemplate.h"
|
||||||
|
#include "language/gettext.h"
|
||||||
|
|
||||||
|
class ContentHome : public ContentTemplate{
|
||||||
|
public:
|
||||||
|
ContentHome();
|
||||||
|
virtual ~ContentHome();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
GuiText welcomeHeadLineLabel;
|
||||||
|
|
||||||
|
GuiImageData *twitterLogoImageData;
|
||||||
|
GuiImage twitterLogoImage;
|
||||||
|
|
||||||
|
GuiImageData *githubLogoImageData;
|
||||||
|
GuiImage githubLogoImage;
|
||||||
|
|
||||||
|
GuiText twitterLabel;
|
||||||
|
|
||||||
|
GuiText URLLabel;
|
||||||
|
|
||||||
|
GuiImageData * homebutton_imgdata;
|
||||||
|
GuiImage homebutton_img;
|
||||||
|
|
||||||
|
GuiText exitHome;
|
||||||
|
GuiFrame exitHomeFrame;
|
||||||
|
|
||||||
|
GuiImageData * plusbutton_imgdata;
|
||||||
|
GuiImage plusbutton_img;
|
||||||
|
|
||||||
|
GuiText exitPlus;
|
||||||
|
GuiFrame exitPlusFrame;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_CONTENT_HOME_H
|
41
loader/src/menu/content/ContentTemplate.h
Normal file
41
loader/src/menu/content/ContentTemplate.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2016-2018 Maschell
|
||||||
|
*
|
||||||
|
* 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 _CONTENT_TEMPLATE_H_
|
||||||
|
#define _CONTENT_TEMPLATE_H_
|
||||||
|
|
||||||
|
#include "gui/Gui.h"
|
||||||
|
#include "menu/MenuCommon.h"
|
||||||
|
|
||||||
|
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);
|
||||||
|
append(&bgImageColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~ContentTemplate() {}
|
||||||
|
protected:
|
||||||
|
GuiImage bgImageColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* CONTENT_TEMPLATE_H_ */
|
@ -57,13 +57,13 @@ class ModuleData{
|
|||||||
~ModuleData(){
|
~ModuleData(){
|
||||||
for(size_t i = 0;i< entry_data_list.size();i++){
|
for(size_t i = 0;i< entry_data_list.size();i++){
|
||||||
if(entry_data_list[i] != NULL){
|
if(entry_data_list[i] != NULL){
|
||||||
free(entry_data_list[i]);
|
delete entry_data_list[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0;i< hook_data_list.size();i++){
|
for(size_t i = 0;i< hook_data_list.size();i++){
|
||||||
if(hook_data_list[i] != NULL){
|
if(hook_data_list[i] != NULL){
|
||||||
free(hook_data_list[i]);
|
delete hook_data_list[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
37
loader/src/resources/filelist.cpp
Normal file
37
loader/src/resources/filelist.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Resource files.
|
||||||
|
* This file is generated automatically.
|
||||||
|
* Includes 5 files.
|
||||||
|
*
|
||||||
|
* NOTE:
|
||||||
|
* Any manual modification of this file will be overwriten by the generation.
|
||||||
|
*****************************************************************************/
|
||||||
|
#include <resources/filelist.h>
|
||||||
|
|
||||||
|
extern const u8 font_ttf[];
|
||||||
|
extern const u32 font_ttf_size;
|
||||||
|
|
||||||
|
extern const u8 GithubIcon_png[];
|
||||||
|
extern const u32 GithubIcon_png_size;
|
||||||
|
|
||||||
|
extern const u8 HomeButtonIcon_png[];
|
||||||
|
extern const u32 HomeButtonIcon_png_size;
|
||||||
|
|
||||||
|
extern const u8 PlusButtonIcon_png[];
|
||||||
|
extern const u32 PlusButtonIcon_png_size;
|
||||||
|
|
||||||
|
extern const u8 TwitterIcon_png[];
|
||||||
|
extern const u32 TwitterIcon_png_size;
|
||||||
|
|
||||||
|
static ResourceFile ResourceList[] =
|
||||||
|
{
|
||||||
|
{"font.ttf", font_ttf, font_ttf_size, NULL, 0},
|
||||||
|
{"GithubIcon.png", GithubIcon_png, GithubIcon_png_size, NULL, 0},
|
||||||
|
{"HomeButtonIcon.png", HomeButtonIcon_png, HomeButtonIcon_png_size, NULL, 0},
|
||||||
|
{"PlusButtonIcon.png", PlusButtonIcon_png, PlusButtonIcon_png_size, NULL, 0},
|
||||||
|
{"TwitterIcon.png", TwitterIcon_png, TwitterIcon_png_size, NULL, 0},
|
||||||
|
{NULL, NULL, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
ResourceFile * getResourceList(){ return ResourceList; }
|
||||||
|
|
245
loader/src/settings/CSettings.cpp
Normal file
245
loader/src/settings/CSettings.cpp
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "common/common.h"
|
||||||
|
#include "CSettings.h"
|
||||||
|
#include "SettingsEnums.h"
|
||||||
|
#include <fs/CFile.hpp>
|
||||||
|
#include <fs/FSUtils.h>
|
||||||
|
#include <utils/StringTools.h>
|
||||||
|
#include <utils/logger.h>
|
||||||
|
#include <language/gettext.h>
|
||||||
|
|
||||||
|
#define VERSION_LINE "# WiiUPluginSystem - Main settings file v"
|
||||||
|
#define VALID_VERSION 1
|
||||||
|
#define CONFIG_FILENAME "/wups.cfg"
|
||||||
|
|
||||||
|
CSettings *CSettings::settingsInstance = NULL;
|
||||||
|
|
||||||
|
CSettings::CSettings(){
|
||||||
|
bChanged = false;
|
||||||
|
memset(&nullValue, 0, sizeof(nullValue));
|
||||||
|
nullValue.strValue = new std::string();
|
||||||
|
configPath = DEFAULT_WUPSLOADER_PATH;
|
||||||
|
this->SetDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
CSettings::~CSettings(){
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
if(settingsValues[i].dataType == TypeString)
|
||||||
|
delete settingsValues[i].strValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
settingsNames.resize(MAX_VALUE);
|
||||||
|
settingsValues.resize(MAX_VALUE);
|
||||||
|
|
||||||
|
settingsNames[AppLanguage] = "AppLanguage";
|
||||||
|
settingsValues[AppLanguage].dataType = TypeString;
|
||||||
|
settingsValues[AppLanguage].strValue = new std::string();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSettings::Load(){
|
||||||
|
//! Reset default path variables to the right device
|
||||||
|
SetDefault();
|
||||||
|
|
||||||
|
std::string filepath = configPath;
|
||||||
|
filepath += CONFIG_FILENAME;
|
||||||
|
|
||||||
|
log_printf("CSettings::Load(line %d): Loading Configuration from %s\n",__LINE__,filepath.c_str());
|
||||||
|
|
||||||
|
CFile file(filepath, CFile::ReadOnly);
|
||||||
|
if (!file.isOpen())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
std::string strBuffer;
|
||||||
|
strBuffer.resize(file.size());
|
||||||
|
file.read((u8 *) &strBuffer[0], strBuffer.size());
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
|
||||||
|
//! remove all windows crap signs
|
||||||
|
size_t position;
|
||||||
|
while(1 && !strBuffer.empty())
|
||||||
|
{
|
||||||
|
position = strBuffer.find('\r');
|
||||||
|
if(position == std::string::npos)
|
||||||
|
break;
|
||||||
|
|
||||||
|
strBuffer.erase(position, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> lines = StringTools::stringSplit(strBuffer, "\n");
|
||||||
|
|
||||||
|
|
||||||
|
if(lines.empty() || !ValidVersion(lines[0]))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for(u32 i = 0; i < lines.size(); ++i)
|
||||||
|
{
|
||||||
|
std::vector<std::string> valueSplit = StringTools::stringSplit(lines[i], "=");
|
||||||
|
if(valueSplit.size() != 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
while((valueSplit[0].size() > 0) && valueSplit[0][0] == ' ')
|
||||||
|
valueSplit[0].erase(0, 1);
|
||||||
|
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
if(!settingsNames[n])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(valueSplit[0] == settingsNames[n])
|
||||||
|
{
|
||||||
|
switch(settingsValues[n].dataType)
|
||||||
|
{
|
||||||
|
case TypeBool:
|
||||||
|
settingsValues[n].bValue = atoi(valueSplit[1].c_str());
|
||||||
|
break;
|
||||||
|
case TypeS8:
|
||||||
|
settingsValues[n].cValue = atoi(valueSplit[1].c_str());
|
||||||
|
break;
|
||||||
|
case TypeU8:
|
||||||
|
settingsValues[n].ucValue = atoi(valueSplit[1].c_str());
|
||||||
|
break;
|
||||||
|
case TypeS16:
|
||||||
|
settingsValues[n].sValue = atoi(valueSplit[1].c_str());
|
||||||
|
break;
|
||||||
|
case TypeU16:
|
||||||
|
settingsValues[n].usValue = atoi(valueSplit[1].c_str());
|
||||||
|
break;
|
||||||
|
case TypeS32:
|
||||||
|
settingsValues[n].iValue = atoi(valueSplit[1].c_str());
|
||||||
|
break;
|
||||||
|
case TypeU32:
|
||||||
|
settingsValues[n].uiValue = strtoul(valueSplit[1].c_str(), 0, 10);
|
||||||
|
break;
|
||||||
|
case TypeF32:
|
||||||
|
settingsValues[n].fValue = atof(valueSplit[1].c_str());
|
||||||
|
break;
|
||||||
|
case TypeString:
|
||||||
|
if(settingsValues[n].strValue == NULL)
|
||||||
|
settingsValues[n].strValue = new std::string();
|
||||||
|
|
||||||
|
*settingsValues[n].strValue = valueSplit[1];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSettings::ValidVersion(const std::string & versionString){
|
||||||
|
int version = 0;
|
||||||
|
|
||||||
|
if(versionString.find(VERSION_LINE) != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
version = atoi(versionString.c_str() + strlen(VERSION_LINE));
|
||||||
|
|
||||||
|
return version == VALID_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSettings::Reset(){
|
||||||
|
this->SetDefault();
|
||||||
|
bChanged = true;
|
||||||
|
|
||||||
|
if (this->Save())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSettings::Save(){
|
||||||
|
if(!bChanged)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
FSUtils::CreateSubfolder(configPath.c_str());
|
||||||
|
|
||||||
|
std::string filepath = configPath;
|
||||||
|
filepath += CONFIG_FILENAME;
|
||||||
|
|
||||||
|
CFile file(filepath, CFile::WriteOnly);
|
||||||
|
if (!file.isOpen())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
file.fwrite("%s%i\n", VERSION_LINE, VALID_VERSION);
|
||||||
|
|
||||||
|
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;
|
||||||
|
case TypeS8:
|
||||||
|
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].cValue);
|
||||||
|
break;
|
||||||
|
case TypeU8:
|
||||||
|
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].ucValue);
|
||||||
|
break;
|
||||||
|
case TypeS16:
|
||||||
|
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].sValue);
|
||||||
|
break;
|
||||||
|
case TypeU16:
|
||||||
|
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].usValue);
|
||||||
|
break;
|
||||||
|
case TypeS32:
|
||||||
|
file.fwrite("%s=%i\n", settingsNames[i], settingsValues[i].iValue);
|
||||||
|
break;
|
||||||
|
case TypeU32:
|
||||||
|
file.fwrite("%s=%u\n", settingsNames[i], settingsValues[i].uiValue);
|
||||||
|
break;
|
||||||
|
case TypeF32:
|
||||||
|
file.fwrite("%s=%f\n", settingsNames[i], settingsValues[i].fValue);
|
||||||
|
break;
|
||||||
|
case TypeString:
|
||||||
|
if(settingsValues[i].strValue != NULL)
|
||||||
|
file.fwrite("%s=%s\n", settingsNames[i], settingsValues[i].strValue->c_str());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
bChanged = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
254
loader/src/settings/CSettings.h
Normal file
254
loader/src/settings/CSettings.h
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
*
|
||||||
|
* Modified by Maschell, 2018 for WiiU plugin system loader
|
||||||
|
*
|
||||||
|
* 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 _CSETTINGS_H_
|
||||||
|
#define _CSETTINGS_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <dynamic_libs/os_types.h>
|
||||||
|
#include <vector>
|
||||||
|
#include "SettingsEnums.h"
|
||||||
|
|
||||||
|
class CSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static CSettings *instance() {
|
||||||
|
if(!settingsInstance)
|
||||||
|
settingsInstance = new CSettings();
|
||||||
|
|
||||||
|
return settingsInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void destroyInstance() {
|
||||||
|
if(settingsInstance){
|
||||||
|
delete settingsInstance;
|
||||||
|
settingsInstance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Set Default Settings
|
||||||
|
void SetDefault();
|
||||||
|
//!Load Settings
|
||||||
|
bool Load();
|
||||||
|
//!Save Settings
|
||||||
|
bool Save();
|
||||||
|
//!Reset Settings
|
||||||
|
bool Reset();
|
||||||
|
|
||||||
|
enum DataTypes{
|
||||||
|
TypeNone,
|
||||||
|
TypeBool,
|
||||||
|
TypeS8,
|
||||||
|
TypeU8,
|
||||||
|
TypeS16,
|
||||||
|
TypeU16,
|
||||||
|
TypeS32,
|
||||||
|
TypeU32,
|
||||||
|
TypeF32,
|
||||||
|
TypeString
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum SettingsIdx{
|
||||||
|
INVALID = -1,
|
||||||
|
AppLanguage,
|
||||||
|
MAX_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
*(instance()->settingsValues[idx].strValue) = val;
|
||||||
|
instance()->bChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
//!Constructor
|
||||||
|
CSettings();
|
||||||
|
//!Destructor
|
||||||
|
~CSettings();
|
||||||
|
|
||||||
|
bool ValidVersion(const std::string & versionString);
|
||||||
|
|
||||||
|
static CSettings *settingsInstance;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u8 dataType;
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
bool bValue;
|
||||||
|
s8 cValue;
|
||||||
|
u8 ucValue;
|
||||||
|
s16 sValue;
|
||||||
|
u16 usValue;
|
||||||
|
s32 iValue;
|
||||||
|
u32 uiValue;
|
||||||
|
f32 fValue;
|
||||||
|
std::string *strValue;
|
||||||
|
};
|
||||||
|
} SettingValue;
|
||||||
|
|
||||||
|
SettingValue nullValue;
|
||||||
|
std::string configPath;
|
||||||
|
std::vector<SettingValue> settingsValues;
|
||||||
|
std::vector<const char*> settingsNames;
|
||||||
|
|
||||||
|
bool bChanged;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
37
loader/src/settings/SettingsDefs.h
Normal file
37
loader/src/settings/SettingsDefs.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
*
|
||||||
|
* Modified by Maschell, 2018 for WiiU plugin system loader
|
||||||
|
*
|
||||||
|
* 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 __SETTINGS_DEFS_
|
||||||
|
#define __SETTINGS_DEFS_
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
const char *name;
|
||||||
|
} ValueString;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
const ValueString *valueStrings;
|
||||||
|
int type;
|
||||||
|
int index;
|
||||||
|
} SettingType;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __SETTINGS_DEFS_
|
9
loader/src/settings/SettingsEnums.h
Normal file
9
loader/src/settings/SettingsEnums.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef SETTINGS_ENUMS_H_
|
||||||
|
#define SETTINGS_ENUMS_H_
|
||||||
|
|
||||||
|
enum eOnOff{
|
||||||
|
SETTING_OFF,
|
||||||
|
SETTING_ON
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SETTINGS_ENUMS_H_
|
14
loader/updatelang.sh
Normal file
14
loader/updatelang.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
#
|
||||||
|
find . -iname "*.cpp" -or -iname "*.c" | xargs xgettext --no-wrap -ktr -ktrNOOP -o languages/english.lang -j --no-location --omit-header
|
||||||
|
echo "Updated lang"
|
||||||
|
find . -iname "*.cpp" -or -iname "*.c" | xargs xgettext --no-wrap -ktr -ktrNOOP -o languages/english.lang -j --omit-header --sort-by-file
|
||||||
|
|
||||||
|
|
||||||
|
for fn in `find languages/*.lang`; do
|
||||||
|
if [ "$fn" != "languages/english.lang" ]; then
|
||||||
|
echo "Updated $fn"
|
||||||
|
msgmerge --output-file=$fn $fn languages/english.lang --no-wrap
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user