*Added "Remember Unlock" option. If set to OFF the loader is locked on startup if a parental password was setup. (Issue 1954)

*Added hide of password when entering unlock password. (Issue 1847)
*Added Priiloader override on returning to Wii System Menu
*Fixed issue with filebrowser not jumping back to first directory entry on directory change.
This commit is contained in:
dimok321 2011-09-10 20:08:12 +00:00
parent bb0ab04e51
commit 6718070812
36 changed files with 1859 additions and 121 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>2.2 r1111</version>
<release_date>201109040858</release_date>
<version>2.2 r1112</version>
<release_date>201109041418</release_date>
<!-- // remove this line to enable arguments
<arguments>
<arg>--ios=250</arg>

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: David Jelinek (djelinek@hotmail.com) e->e,r->r,u->u, c->c \n"
"Language-Team: r1056 - last version on http://djelinek.sweb.cz/_USBLoderGX/czech.lang \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Uvolnil"
msgid "Reload SD"
msgstr "Znovunactení SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Odstranit aktualizaci"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: Fox888[dk]\n"
"Language-Team: [dk]\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Udkommet"
msgid "Reload SD"
msgstr "Genindlæs SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Fjern opdatering"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2011-06-30 14:22+0100\n"
"Last-Translator: glowy\n"
"Language-Team: tj_cool, glowy\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Uitgegeven"
msgid "Reload SD"
msgstr "SD herladen"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Verwijder update"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr ""
msgid "Reload SD"
msgstr ""
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: c64rmx\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Julkaistu"
msgid "Reload SD"
msgstr "Uudelleenlataa SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: Cyan, Kin8\n"
"Language-Team: Badablek, Amour, ikya, Cyan & Kin8\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Date de sortie"
msgid "Reload SD"
msgstr "Recharger la SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Supprimer MàJ"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2010-07-03 17:35-0800\n"
"Last-Translator: TheRealVisitor\n"
"Language-Team: Bertilax, Snoozer, wishmasterf, ZEN.13, TheRealVisitor\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Erschienen am"
msgid "Reload SD"
msgstr "SD Karte neuladen"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Update entfernen"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-12-29 11:05+0100\n"
"Last-Translator: Springdale\n"
"Language-Team: Tusk, Springdale\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Kiadva"
msgid "Reload SD"
msgstr "SD Újratöltése"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2011-06-27 01:00+0200\n"
"Last-Translator: Cambo \n"
"Language-Team: Cambo\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Rilasciato"
msgid "Reload SD"
msgstr "Ricarica SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Rimuovi Agg."

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: hosigumayuugi\n"
"Language-Team: hosigumayuugi, papa, ichiroling\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "発売日"
msgid "Reload SD"
msgstr "SDを再読み込み"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "更新を取り除く"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: nextos@korea.com\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "릴리즈됨"
msgid "Reload SD"
msgstr "SD카드 읽기"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: raschi\n"
"Language-Team: raschi\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Utgitt"
msgid "Reload SD"
msgstr "Les SD på nytt"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Fjern oppdatering"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: ziom666 (zadania_prog@vp.pl)\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr ""
msgid "Reload SD"
msgstr "Przeladuj SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-23 18:52+0200\n"
"Last-Translator: aniemotion\n"
"Language-Team: boto12, aniemotion\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Lançamento"
msgid "Reload SD"
msgstr "Atualizar do cartão SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Remover atualização"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2011-07-30 19:45+0100\n"
"Last-Translator: pplucky <pplucky@gmail.com>\n"
"Language-Team: Sky8000, pplucky\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Lançamento"
msgid "Reload SD"
msgstr "Ler cartão SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Remover actualização"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: nikolai_ca\n"
"Language-Team: Kir, alendit, nikolai_ca\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Выпущено:"
msgid "Reload SD"
msgstr "Перечитать SD карту"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: knife.hu kavid emul8ion\n"
"Language-Team: kavid\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "放出"
msgid "Reload SD"
msgstr "重新载入 SD 卡"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "删除更新"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2011-07-25 16:40+0200\n"
"Last-Translator: hvy109\n"
"Language-Team: Penn, SirPalax, hvy109\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Comercializado el"
msgid "Reload SD"
msgstr "Recargar SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "Quitar actualización"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2010-01-19 17:39+0200\n"
"Last-Translator: Katsurou\n"
"Language-Team: Katsurou, pirateX\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Släppt"
msgid "Reload SD"
msgstr "Ladda om SD"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2010-02-15 21:00+0800\n"
"Last-Translator: Jane.H\n"
"Language-Team: kyogc, Miller, Mika Li, Jane.H\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "發行"
msgid "Reload SD"
msgstr "重新載入 SD 卡"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr "移除更新"

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: Nitro_subzero \n"
"Language-Team: Nitro_subzero\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "ปล่อย"
msgid "Reload SD"
msgstr "โหลด SD ใหม่"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

View File

@ -5,10 +5,11 @@ msgid ""
msgstr ""
"Project-Id-Version: USB Loader GX\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-09-04 11:18+0200\n"
"POT-Creation-Date: 2011-09-10 22:02+0200\n"
"PO-Revision-Date: 2009-10-01 01:00+0200\n"
"Last-Translator: omercigingelini\n"
"Language-Team: omercigingelini\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -1224,6 +1225,9 @@ msgstr "Çıktı"
msgid "Reload SD"
msgstr "SD'yi yeniden yükle"
msgid "Remember Unlock"
msgstr ""
msgid "Remove update"
msgstr ""

987
gui.h Executable file
View File

@ -0,0 +1,987 @@
/****************************************************************************
* LibWiiGui by Tantric (C) 2009
* USB Loader GX Team (C) 2009-2011
*
* The LibWiiGui library was used as the base for the creation of
* the GUI in USB Loader GX.
* Several modifications and additions were made to the library
* It does no longer match the original LibWiiGui implementation.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef LIBWIIGUI_H
#define LIBWIIGUI_H
#include <gccore.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <vector>
#include <math.h>
#include <asndlib.h>
#include <wiiuse/wpad.h>
#include "gui_imagedata.h"
#include "FreeTypeGX.h"
#include "video.h"
#include "input.h"
#include "OptionList.hpp"
#include "SoundOperations/gui_sound.h"
#include "SoundOperations/gui_bgm.h"
#include "sigslot.h"
//! Frequently used variables
extern FreeTypeGX *fontSystem;
extern GuiSound *btnSoundClick;
extern GuiSound *btnSoundClick2;
extern GuiSound *btnSoundOver;
extern GuiBGM *bgMusic;
#define SCROLL_INITIAL_DELAY 20
#define SCROLL_LOOP_DELAY 3
#define PAGESIZE 9
#define FILEBROWSERSIZE 8
#define MAX_OPTIONS 170
typedef void (*UpdateCallback)(void * e);
enum
{
ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE, ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE
};
#define ALIGN_CENTER ALIGN_CENTRE
enum
{
STATE_DEFAULT, STATE_SELECTED, STATE_CLICKED, STATE_HELD, STATE_DISABLED
};
enum
{
IMAGE_TEXTURE, IMAGE_COLOR, IMAGE_DATA, IMAGE_COPY
};
enum
{
TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS
};
enum
{
WRAP, DOTTED, SCROLL_HORIZONTAL, SCROLL_NONE
};
typedef struct _POINT {
s16 x;
s16 y;
} POINT;
typedef struct _paddata
{
u16 btns_d;
u16 btns_u;
u16 btns_h;
s8 stickX;
s8 stickY;
s8 substickX;
s8 substickY;
u8 triggerL;
u8 triggerR;
} PADData;
#define EFFECT_SLIDE_TOP 1
#define EFFECT_SLIDE_BOTTOM 2
#define EFFECT_SLIDE_RIGHT 4
#define EFFECT_SLIDE_LEFT 8
#define EFFECT_SLIDE_IN 16
#define EFFECT_SLIDE_OUT 32
#define EFFECT_FADE 64
#define EFFECT_SCALE 128
#define EFFECT_COLOR_TRANSITION 256
#define EFFECT_PULSE 512
#define EFFECT_ROCK_VERTICLE 1024
#define EFFECT_GOROUND 2048
//!Menu input trigger management. Determine if action is neccessary based on input data by comparing controller input data to a specific trigger element.
class GuiTrigger
{
public:
//!Constructor
GuiTrigger();
//!Destructor
virtual ~GuiTrigger();
//!Sets a simple trigger. Requires: element is selected, and trigger button is pressed
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s)
void SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
//!Sets a held trigger. Requires: element is selected, and trigger button is pressed
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s)
void SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
//!Sets a button-only trigger. Requires: Trigger button is pressed
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s)
void SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
//!Sets a button-only trigger. Requires: trigger button is pressed and parent window of element is in focus
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s)
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
//!Get X/Y value from Wii Joystick (classic, nunchuk) input
//!\param right Controller stick (left = 0, right = 1)
//!\param axis Controller stick axis (x-axis = 0, y-axis = 1)
//!\return Stick value
s8 WPAD_Stick(u8 right, int axis);
//!Move menu selection left (via pad/joystick). Allows scroll delay and button overriding
//!\return true if selection should be moved left, false otherwise
bool Left();
//!Move menu selection right (via pad/joystick). Allows scroll delay and button overriding
//!\return true if selection should be moved right, false otherwise
bool Right();
//!Move menu selection up (via pad/joystick). Allows scroll delay and button overriding
//!\return true if selection should be moved up, false otherwise
bool Up();
//!Move menu selection down (via pad/joystick). Allows scroll delay and button overriding
//!\return true if selection should be moved down, false otherwise
bool Down();
u8 type; //!< trigger type (TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS)
s32 chan; //!< Trigger controller channel (0-3, -1 for all)
WPADData wpad; //!< Wii controller trigger data
PADData pad; //!< GameCube controller trigger data
};
extern GuiTrigger userInput[4];
//!Primary GUI class. Most other classes inherit from this class.
class GuiElement
{
public:
//!Constructor
GuiElement();
//!Destructor
virtual ~GuiElement();
//!Set the element's parent
//!\param e Pointer to parent element
void SetParent(GuiElement * e);
//!Gets the element's parent
//!\return Pointer to parent element
GuiElement * GetParent();
//!Gets the current leftmost coordinate of the element
//!Considers horizontal alignment, x offset, width, and parent element's GetLeft() / GetWidth() values
//!\return left coordinate
int GetLeft();
//!Gets the current topmost coordinate of the element
//!Considers vertical alignment, y offset, height, and parent element's GetTop() / GetHeight() values
//!\return top coordinate
int GetTop();
//!Sets the minimum y offset of the element
//!\param y Y offset
void SetMinY(int y);
//!Gets the minimum y offset of the element
//!\return Minimum Y offset
int GetMinY();
//!Sets the maximum y offset of the element
//!\param y Y offset
void SetMaxY(int y);
//!Gets the maximum y offset of the element
//!\return Maximum Y offset
int GetMaxY();
//!Sets the minimum x offset of the element
//!\param x X offset
void SetMinX(int x);
//!Gets the minimum x offset of the element
//!\return Minimum X offset
int GetMinX();
//!Sets the maximum x offset of the element
//!\param x X offset
void SetMaxX(int x);
//!Gets the maximum x offset of the element
//!\return Maximum X offset
int GetMaxX();
//!Gets the current width of the element. Does not currently consider the scale
//!\return width
virtual int GetWidth();
//!Gets the height of the element. Does not currently consider the scale
//!\return height
virtual int GetHeight();
//!Sets the size (width/height) of the element
//!\param w Width of element
//!\param h Height of element
void SetSize(int w, int h);
//!Checks whether or not the element is visible
//!\return true if visible, false otherwise
bool IsVisible();
//!Checks whether or not the element is selectable
//!\return true if selectable, false otherwise
bool IsSelectable();
//!Checks whether or not the element is clickable
//!\return true if clickable, false otherwise
bool IsClickable();
//!Checks whether or not the element is holdable
//!\return true if holdable, false otherwise
bool IsHoldable();
//!Sets whether or not the element is selectable
//!\param s Selectable
void SetSelectable(bool s);
//!Sets whether or not the element is clickable
//!\param c Clickable
void SetClickable(bool c);
//!Sets whether or not the element is holdable
//!\param c Holdable
void SetHoldable(bool d);
//!Gets the element's current state
//!\return state
int GetState();
//!Gets the controller channel that last changed the element's state
//!\return Channel number (0-3, -1 = no channel)
int GetStateChan();
//!Sets the element's alpha value
//!\param a alpha value
void SetAlpha(int a);
//!Gets the element's alpha value
//!Considers alpha, alphaDyn, and the parent element's GetAlpha() value
//!\return alpha
int GetAlpha();
//!Gets the element's AngleDyn value
//!\return alpha
float GetAngleDyn();
//!Sets the element's scale
//!\param s scale (1 is 100%)
void SetScale(float s);
//!Gets the element's current scale
//!Considers scale, scaleDyn, and the parent element's GetScale() value
virtual float GetScale();
//!Set a new GuiTrigger for the element
//!\param t Pointer to GuiTrigger
void SetTrigger(GuiTrigger * t);
//!\overload
//!\param i Index of trigger array to set
//!\param t Pointer to GuiTrigger
void SetTrigger(u8 i, GuiTrigger * t);
//!Remove GuiTrigger for the element
//!\param i Index of trigger array to set
void RemoveTrigger(u8 i);
//!Checks whether rumble was requested by the element
//!\return true is rumble was requested, false otherwise
bool Rumble();
//!Sets whether or not the element is requesting a rumble event
//!\param r true if requesting rumble, false if not
void SetRumble(bool r);
//!Set an effect for the element
//!\param e Effect to enable
//!\param a Amount of the effect (usage varies on effect)
//!\param t Target amount of the effect (usage varies on effect)
void SetEffect(int e, int a, int t = 0);
//!This SetEffect is for EFFECT_GOROUND only
//!\param e Effect to enable
//!\param speed is for Circlespeed
//!\param circles Circleamount in degree ike 180 for 1/2 circle or 720 for 2 circles
//!\param r Circle Radius in pixel
//!\param startdegree Degree where to start circling
//!\param anglespeedset Set the speed of Angle rotating make 1 for same speed as Circlespeed
//! or 0.5 for half the speed of the circlingspeed. Turn Anglecircling off by 0 to this param.
//!\param center_x x co-ordinate of the center of circle.
//!\param center_y y co-ordinate of the center of circle.
void SetEffect(int e, int speed, f32 circles, int r, f32 startdegree, f32 anglespeedset, int center_x,
int center_y);
//!Gets the frequency from the above effect
//!\return element frequency
float GetFrequency();
//!Sets an effect to be enabled on wiimote cursor over
//!\param e Effect to enable
//!\param a Amount of the effect (usage varies on effect)
//!\param t Target amount of the effect (usage varies on effect)
void SetEffectOnOver(int e, int a, int t = 0);
//!Shortcut to SetEffectOnOver(EFFECT_SCALE, 4, 110)
void SetEffectGrow();
//!Stops the current element effect
void StopEffect();
//!Gets the current element effects
//!\return element effects
int GetEffect();
//!Gets the current element on over effects
//!\return element on over effects
int GetEffectOnOver();
//!Checks whether the specified coordinates are within the element's boundaries
//!\param x X coordinate
//!\param y Y coordinate
//!\return true if contained within, false otherwise
bool IsInside(int x, int y);
//!Sets the element's position
//!\param x X coordinate
//!\param y Y coordinate
void SetPosition(int x, int y, int z = 0);
//!Sets the element's relative position
int GetRelLeft();
int GetRelTop();
//!Sets the element's setup position
int GetLeftPos() const { return xoffset; }
int GetTopPos() const { return yoffset; }
//!Updates the element's effects (dynamic values)
//!Called by Draw(), used for animation purposes
void UpdateEffects();
//!Sets a function to called after after Update()
//!Callback function can be used to response to changes in the state of the element, and/or update the element's attributes
void SetUpdateCallback(UpdateCallback u);
//!Checks whether the element is in focus
//!\return true if element is in focus, false otherwise
int IsFocused();
//!Sets the element's visibility
//!\param v Visibility (true = visible)
virtual void SetVisible(bool v);
//!Sets the element's focus
//!\param f Focus (true = in focus)
virtual void SetFocus(int f);
//!Sets the element's state
//!\param s State (STATE_DEFAULT, STATE_SELECTED, STATE_CLICKED, STATE_DISABLED)
//!\param c Controller channel (0-3, -1 = none)
virtual void SetState(int s, int c = -1);
//!Resets the element's state to STATE_DEFAULT
virtual void ResetState();
//!Gets whether or not the element is in STATE_SELECTED
//!\return true if selected, false otherwise
virtual int GetSelected();
//!Sets the element's alignment respective to its parent element
//!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE)
//!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE)
virtual void SetAlignment(int hor, int vert);
//!Called constantly to allow the element to respond to the current input data
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
virtual void Update(GuiTrigger * t);
//!Called constantly to redraw the element
virtual void Draw();
virtual void DrawTooltip();
protected:
void LockElement();
void UnlockElement();
// static mutex_t mutex;
static mutex_t _lock_mutex;
lwp_t _lock_thread;
u16 _lock_count;
lwpq_t _lock_queue;
friend class SimpleLock;
//int position2; //! B Scrollbariable
bool visible; //!< Visibility of the element. If false, Draw() is skipped
int focus; //!< Element focus (-1 = focus disabled, 0 = not focused, 1 = focused)
int dontsetfocus; //!<If 0 games dont set the focus
int width; //!< Element width
int height; //!< Element height
int xoffset; //!< Element X offset
int yoffset; //!< Element Y offset
int zoffset; //!< Element Z offset
int ymin; //!< Element's min Y offset allowed
int ymax; //!< Element's max Y offset allowed
int xmin; //!< Element's min X offset allowed
int xmax; //!< Element's max X offset allowed
int xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects)
int yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects)
int temp_xoffset; //!< Element Temp X offset
int temp_yoffset; //!< Element Temp Y offset
f32 degree; //!< Degree where to start for EFFECT_GOROUND enter it in ° like 60°
f32 frequency; //!< Speed for EFFECT_GOROUND || can also be negative for other direction
int Radius; //!< The radius in which the Element goes round for EFFECT_GOROUND
f32 circleamount; //!< Circleamount for the EFFECT_GOROUND effect
f32 xoffsetDynFloat; //!< Integer sucks float is need by some parts
f32 yoffsetDynFloat; //!< Integer sucks float is need by some parts
int changervar; //!< Changervariable for some stuff
int alpha; //!< Element alpha value (0-255)
f32 scale; //!< Element scale (1 = 100%)
f32 angleDyn; //!< AngleDyn for EFFECT_GOROUND
f32 anglespeed; //!<Anglespeedvariable for EFFECT_GOROUND
int alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
f32 scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects)
bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event
int effects; //!< Currently enabled effect(s). 0 when no effects are enabled
int effectAmount; //!< Effect amount. Used by different effects for different purposes
int effectTarget; //!< Effect target amount. Used by different effects for different purposes
int effectsOver; //!< Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event
int effectAmountOver; //!< EffectAmount to set when wiimote cursor is over this element
int effectTargetOver; //!< EffectTarget to set when wiimote cursor is over this element
int alignmentHor; //!< Horizontal element alignment, respective to parent element (LEFT, RIGHT, CENTRE)
int alignmentVert; //!< Horizontal element alignment, respective to parent element (TOP, BOTTOM, MIDDLE)
int state; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
int stateChan; //!< Which controller channel is responsible for the last change in state
bool selectable; //!< Whether or not this element selectable (can change to SELECTED state)
bool clickable; //!< Whether or not this element is clickable (can change to CLICKED state)
bool holdable; //!< Whether or not this element is holdable (can change to HELD state)
GuiTrigger * trigger[6]; //!< GuiTriggers (input actions) that this element responds to
GuiElement * parentElement; //!< Parent element
UpdateCallback updateCB; //!< Callback function to call when this element is updated
};
class SimpleLock
{
public:
SimpleLock(GuiElement *e);
~SimpleLock();
private:
GuiElement *element;
};
#define LOCK(e) SimpleLock LOCK(e)
//!Allows GuiElements to be grouped together into a "window"
class GuiWindow: public GuiElement
{
public:
//!Constructor
GuiWindow();
//!\overload
//!\param w Width of window
//!\param h Height of window
GuiWindow(int w, int h);
//!Destructor
virtual ~GuiWindow();
//!Appends a GuiElement to the GuiWindow
//!\param e The GuiElement to append. If it is already in the GuiWindow, it is removed first
void Append(GuiElement* e);
//!Inserts a GuiElement into the GuiWindow at the specified index
//!\param e The GuiElement to insert. If it is already in the GuiWindow, it is removed first
//!\param i Index in which to insert the element
void Insert(GuiElement* e, u32 i);
//!Removes the specified GuiElement from the GuiWindow
//!\param e GuiElement to be removed
void Remove(GuiElement* e);
//!Removes all GuiElements
void RemoveAll();
//!Returns the GuiElement at the specified index
//!\param index The index of the element
//!\return A pointer to the element at the index, NULL on error (eg: out of bounds)
GuiElement* GetGuiElementAt(u32 index) const;
//!Returns the size of the list of elements
//!\return The size of the current element list
u32 GetSize();
//!Sets the visibility of the window
//!\param v visibility (true = visible)
void SetVisible(bool v);
//!Resets the window's state to STATE_DEFAULT
void ResetState();
//!Sets the window's state
//!\param s State
void SetState(int s);
//!Gets the index of the GuiElement inside the window that is currently selected
//!\return index of selected GuiElement
int GetSelected();
//!Sets the window focus
//!\param f Focus
void SetFocus(int f);
//!Change the focus to the specified element
//!This is intended for the primary GuiWindow only
//!\param e GuiElement that should have focus
void ChangeFocus(GuiElement * e);
//!Changes window focus to the next focusable window or element
//!If no element is in focus, changes focus to the first available element
//!If B or 1 button is pressed, changes focus to the next available element
//!This is intended for the primary GuiWindow only
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
void ToggleFocus(GuiTrigger * t);
//!Moves the selected element to the element to the left or right
//!\param d Direction to move (-1 = left, 1 = right)
void MoveSelectionHor(int d);
//!Moves the selected element to the element above or below
//!\param d Direction to move (-1 = up, 1 = down)
void MoveSelectionVert(int d);
//!Allow dim of screen on disable or not
void SetAllowDim(bool d) { allowDim = d; }
void SetDimScreen(bool d) { forceDim = d; }
//!Draws all the elements in this GuiWindow
void Draw();
void DrawTooltip();
//!Updates the window and all elements contains within
//!Allows the GuiWindow and all elements to respond to the input data specified
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
void Update(GuiTrigger * t);
protected:
bool forceDim;
bool allowDim;
std::vector<GuiElement*> _elements; //!< Contains all elements within the GuiWindow
};
//!Display, manage, and manipulate images in the GUI
class GuiImage: public GuiElement
{
public:
//!Constructor
GuiImage();
//!\overload
//!\param img Pointer to GuiImageData element
GuiImage(GuiImageData * img);
//!\overload
//!Sets up a new image from the image data specified
//!\param img
//!\param w Image width
//!\param h Image height
GuiImage(u8 * img, int w, int h);
//!\overload
//!Creates an image filled with the specified color
//!\param w Image width
//!\param h Image height
//!\param c Image color
GuiImage(int w, int h, GXColor c);
//! Copy Constructor
GuiImage(GuiImage &srcimage);
GuiImage(GuiImage *srcimage);
//! = operator for copying images
GuiImage &operator=(GuiImage &srcimage);
//!Destructor
virtual ~GuiImage();
//!Sets the image rotation angle for drawing
//!\param a Angle (in degrees)
void SetAngle(float a);
//!Gets the image rotation angle for drawing
float GetAngle();
//!Sets the number of times to draw the image horizontally
//!\param t Number of times to draw the image
void SetTileHorizontal(int t);
void SetTileVertical(int t);
// true set horizontal scale to 0.8 //added
void SetWidescreen(bool w);
//!Constantly called to draw the image
void Draw();
//!Gets the image data
//!\return pointer to image data
u8 * GetImage();
//!Sets up a new image using the GuiImageData object specified
//!\param img Pointer to GuiImageData object
void SetImage(GuiImageData * img);
//!\overload
//!\param img Pointer to image data
//!\param w Width
//!\param h Height
void SetImage(u8 * img, int w, int h);
//!Gets the pixel color at the specified coordinates of the image
//!\param x X coordinate
//!\param y Y coordinate
GXColor GetPixel(int x, int y);
//!Sets the pixel color at the specified coordinates of the image
//!\param x X coordinate
//!\param y Y coordinate
//!\param color Pixel color
void SetPixel(int x, int y, GXColor color);
//!Sets the image to grayscale
void SetGrayscale(void);
//!Set/disable the use of parentelement angle (default true)
void SetParentAngle(bool a);
//!Directly modifies the image data to create a color-striped effect
//!Alters the RGB values by the specified amount
//!\param s Amount to increment/decrement the RGB values in the image
void ColorStripe(int s);
//!Sets a stripe effect on the image, overlaying alpha blended rectangles
//!Does not alter the image data
//!\param s Alpha amount to draw over the image
void SetStripe(int s);
s32 z;
void SetSkew(int XX1, int YY1, int XX2, int YY2, int XX3, int YY3, int XX4, int YY4);
void SetSkew(int *skew /* int skew[8] */);
int xx1;
int yy1;
int xx2;
int yy2;
int xx3;
int yy3;
int xx4;
int yy4;
int rxx1;
int ryy1;
int rxx2;
int ryy2;
int rxx3;
int ryy3;
int rxx4;
int ryy4;
protected:
int imgType; //!< Type of image data (IMAGE_TEXTURE, IMAGE_COLOR, IMAGE_DATA)
u8 * image; //!< Poiner to image data. May be shared with GuiImageData data
f32 imageangle; //!< Angle to draw the image
int tileHorizontal; //!< Number of times to draw (tile) the image horizontally
int tileVertical; //!< Number of times to draw (tile) the image vertically
int stripe; //!< Alpha value (0-255) to apply a stripe effect to the texture
short widescreen; //added
bool parentangle;
};
//!Display, manage, and manipulate text in the GUI
class GuiText: public GuiElement
{
public:
//!Constructor
//!\param t Text
//!\param s Font size
//!\param c Font color
GuiText(const char * t, int s, GXColor c);
//!\overload
//!\param t Text
//!\param s Font size
//!\param c Font color
GuiText(const wchar_t * t, int s, GXColor c);
//!\overload
//!\Assumes SetPresets() has been called to setup preferred text attributes
//!\param t Text
GuiText(const char * t);
//!Destructor
virtual ~GuiText();
//!Sets the text of the GuiText element
//!\param t Text
virtual void SetText(const char * t);
virtual void SetText(const wchar_t * t);
virtual void SetTextf(const char *format, ...) __attribute__( ( format( printf, 2, 3 ) ) );
//!Sets up preset values to be used by GuiText(t)
//!Useful when printing multiple text elements, all with the same attributes set
//!\param sz Font size
//!\param c Font color
//!\param w Maximum width of texture image (for text wrapping)
//!\param wrap Wrapmode when w>0
//!\param s Font style
//!\param h Text alignment (horizontal)
//!\param v Text alignment (vertical)
static void SetPresets(int sz, GXColor c, int w, u16 s, int h, int v);
//!Sets the font size
//!\param s Font size
void SetFontSize(int s);
//!Sets the maximum width of the drawn texture image
//!If the text exceeds this, it is wrapped to the next line
//!\param w Maximum width
//!\param m WrapMode
void SetMaxWidth(int w = 0, int m = WRAP);
//!Sets the font color
//!\param c Font color
void SetColor(GXColor c);
//!Sets the FreeTypeGX style attributes
//!\param s Style attributes
//!\param m Style-Mask attributes
void SetStyle(u16 s);
//!Sets the text alignment
//!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE)
//!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE)
void SetAlignment(int hor, int vert);
//!Set PassChar
void SetPassChar(wchar_t p);
//!Sets the font
//!\param f Font
void SetFont(FreeTypeGX *f);
//!Get the original text as char
virtual const wchar_t * GetText();
//!Overload for GetWidth()
int GetWidth() { return GetTextWidth(); }
//!Get the Horizontal Size of Text
int GetTextWidth();
int GetTextWidth(int ind);
//!Get the max textwidth
int GetTextMaxWidth();
//!Gets the total line number
virtual int GetLinesCount() { return 1; }
//!Get fontsize
int GetFontSize() { return size; }
//!Set max lines to draw
void SetLinesToDraw(int l);
void SetWidescreen(bool b) { widescreen = b; }
//!Get current Textline (for position calculation)
const wchar_t * GetDynText(int ind = 0);
virtual const wchar_t * GetTextLine(int ind) { return GetDynText(ind); }
//!Change the font
//!\param font bufferblock
//!\param font filesize
bool SetFont(const u8 *font, const u32 filesize);
//!Constantly called to draw the text
void Draw();
protected:
//!Clear the dynamic text
void ClearDynamicText();
//!Create a dynamic dotted text if the text is too long
void MakeDottedText();
//!Scroll the text once
void ScrollText();
//!Wrap the text to several lines
void WrapText();
wchar_t *text;
std::vector<wchar_t *> textDyn;
int wrapMode; //!< Wrapping toggle
int textScrollPos; //!< Current starting index of text string for scrolling
int textScrollInitialDelay; //!< Delay to wait before starting to scroll
int textScrollDelay; //!< Scrolling speed
int size; //!< Font size
int maxWidth; //!< Maximum width of the generated text object (for text wrapping)
u16 style; //!< FreeTypeGX style attributes
GXColor color; //!< Font color
FreeTypeGX *font;
int textWidth;
int currentSize;
int linestodraw;
wchar_t passChar;
bool widescreen;
};
//!Display, manage, and manipulate tooltips in the GUI.
class GuiTooltip: public GuiElement
{
public:
//!Constructor
//!\param t Text
GuiTooltip(const char *t, int Alpha = 255);
//!Destructor
virtual ~GuiTooltip();
//!Gets the element's current scale
//!Considers scale, scaleDyn, and the parent element's GetScale() value
float GetScale();
//!Sets the text of the GuiTooltip element
//!\param t Text
void SetText(const char * t);
void SetWidescreen(bool w); // timely a dummy
//!Constantly called to draw the GuiButton
void Draw();
protected:
GuiImageData * tooltipLeft;
GuiImageData * tooltipTile;
GuiImageData * tooltipRight;
GuiImage * leftImage; //!< Tooltip left-image
GuiImage * tileImage; //!< Tooltip tile-image
GuiImage * rightImage; //!< Tooltip right-image
GuiText *text;
};
//!Display, manage, and manipulate buttons in the GUI. Buttons can have images, icons, text, and sound set (all of which are optional)
class GuiButton: public GuiElement
{
public:
//!Constructor
//!\param w Width
//!\param h Height
GuiButton(int w, int h);
//!\param img is the button GuiImage. it uses the height & width of this image for the button
//!\param imgOver is the button's over GuiImage
//!\param hor is horizontal alingment of the button
//!\param vert is verticle alignment of the button
//!\param x is xposition of the button
//!\param y is yposition of the button
//!\param trig is a GuiTrigger to assign to this button
//!\param sndOver is a GuiSound used for soundOnOver for this button
//!\param sndClick is a GuiSound used for clickSound of this button
//!\param grow sets effect grow for this button. 1 for yes ;0 for no
GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x, int y, GuiTrigger* trig,
GuiSound* sndOver, GuiSound* sndClick, u8 grow);
//!\param same as all the parameters for the above button plus the following
//!\param tt is a GuiTooltip assigned to this button
//!\param ttx and tty are the xPOS and yPOS for this tooltip in relationship to the button
//!\param h_align and v_align are horizontal and verticle alignment for the tooltip in relationship to the button
GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x, int y, GuiTrigger* trig,
GuiSound* sndOver, GuiSound* sndClick, u8 grow, GuiTooltip* tt, int ttx, int tty, int h_align,
int v_align);
//!Destructor
virtual ~GuiButton();
//!Sets the button's image
//!\param i Pointer to GuiImage object
void SetImage(GuiImage* i);
//!Sets the button's image on over
//!\param i Pointer to GuiImage object
void SetImageOver(GuiImage* i);
//!Sets the button's image on hold
//!\param i Pointer to GuiImage object
void SetAngle(float a);
void SetImageHold(GuiImage* i);
//!Sets the button's image on click
//!\param i Pointer to GuiImage object
void SetImageClick(GuiImage* i);
//!Sets the button's icon
//!\param i Pointer to GuiImage object
void SetIcon(GuiImage* i);
//!Sets the button's icon on over
//!\param i Pointer to GuiImage object
void SetIconOver(GuiImage* i);
//!Sets the button's icon on hold
//!\param i Pointer to GuiImage object
void SetIconHold(GuiImage* i);
//!Sets the button's icon on click
//!\param i Pointer to GuiImage object
void SetIconClick(GuiImage* i);
//!Sets the button's label
//!\param t Pointer to GuiText object
//!\param n Index of label to set (optional, default is 0)
void SetLabel(GuiText* t, int n = 0);
//!Sets the button's label on over (eg: different colored text)
//!\param t Pointer to GuiText object
//!\param n Index of label to set (optional, default is 0)
void SetLabelOver(GuiText* t, int n = 0);
//!Sets the button's label on hold
//!\param t Pointer to GuiText object
//!\param n Index of label to set (optional, default is 0)
void SetLabelHold(GuiText* t, int n = 0);
//!Sets the button's label on click
//!\param t Pointer to GuiText object
//!\param n Index of label to set (optional, default is 0)
void SetLabelClick(GuiText* t, int n = 0);
//!Sets the sound to play on over
//!\param s Pointer to GuiSound object
void SetSoundOver(GuiSound * s);
//!Sets the sound to play on hold
//!\param s Pointer to GuiSound object
void SetSoundHold(GuiSound * s);
//!Sets the sound to play on click
//!\param s Pointer to GuiSound object
void SetSoundClick(GuiSound * s);
//!\param reset the soundover to NULL
void RemoveSoundOver();
//!\param reset the soundclick to NULL
void RemoveSoundClick();
//!Constantly called to draw the GuiButtons ToolTip
//!Sets the button's Tooltip on over
//!\param tt Pointer to GuiElement object, x & y Positioning, h & v Align
void SetToolTip(GuiTooltip* tt, int x, int y, int h = ALIGN_RIGHT, int v = ALIGN_TOP);
void RemoveToolTip();
//!Constantly called to draw the GuiButton
void Draw();
void DrawTooltip();
//!Constantly called to allow the GuiButton to respond to updated input data
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
void Update(GuiTrigger * t);
//!Deactivate/Activate pointing on Games while B scrolling
void ScrollIsOn(int f);
void SetSkew(int XX1, int YY1, int XX2, int YY2, int XX3, int YY3, int XX4, int YY4);
void SetSkew(int *skew /* int skew[8] */);
virtual void SetState(int s, int c = -1);
sigslot::signal3<GuiButton *, int, const POINT&> Clicked;
sigslot::signal3<GuiButton *, int, const POINT&> Held;
protected:
GuiImage * image; //!< Button image (default)
GuiImage * imageOver; //!< Button image for STATE_SELECTED
GuiImage * imageHold; //!< Button image for STATE_HELD
GuiImage * imageClick; //!< Button image for STATE_CLICKED
GuiImage * icon; //!< Button icon (drawn after button image)
GuiImage * iconOver; //!< Button icon for STATE_SELECTED
GuiImage * iconHold; //!< Button icon for STATE_HELD
GuiImage * iconClick; //!< Button icon for STATE_CLICKED
GuiTooltip *toolTip;
time_t time1, time2;//!< Tooltip timeconstants
GuiText * label[3]; //!< Label(s) to display (default)
GuiText * labelOver[3]; //!< Label(s) to display for STATE_SELECTED
GuiText * labelHold[3]; //!< Label(s) to display for STATE_HELD
GuiText * labelClick[3]; //!< Label(s) to display for STATE_CLICKED
GuiSound * soundOver; //!< Sound to play for STATE_SELECTED
GuiSound * soundHold; //!< Sound to play for STATE_HELD
GuiSound * soundClick; //!< Sound to play for STATE_CLICKED
};
typedef struct _keytype
{
char ch, chShift, chalt, chalt2;
} Key;
//!On-screen keyboard
class GuiKeyboard: public GuiWindow
{
public:
GuiKeyboard(char * t, u32 m, int min, int lang);
virtual ~GuiKeyboard();
void SetVisibleText(bool v) { textVisible = v; }
const char *GetText() { return kbtextstr; }
void Update(GuiTrigger * t);
protected:
void SetDisplayText(const char *text);
bool textVisible;
char kbtextstr[256];
u32 kbtextmaxlen;
Key keys[4][11];
int shift;
int caps;
int alt;
int alt2;
int min;
GuiText * kbText;
GuiImage * keyTextboxImg;
GuiText * keyCapsText;
GuiImage * keyCapsImg;
GuiImage * keyCapsOverImg;
GuiButton * keyCaps;
GuiText * keyAltText;
GuiImage * keyAltImg;
GuiImage * keyAltOverImg;
GuiButton * keyAlt;
GuiText * keyAlt2Text;
GuiImage * keyAlt2Img;
GuiImage * keyAlt2OverImg;
GuiButton * keyAlt2;
GuiText * keyShiftText;
GuiImage * keyShiftImg;
GuiImage * keyShiftOverImg;
GuiButton * keyShift;
GuiText * keyBackText;
GuiImage * keyBackImg;
GuiImage * keyBackOverImg;
GuiButton * keyBack;
GuiText * keyClearText;
GuiImage * keyClearImg;
GuiImage * keyClearOverImg;
GuiButton * keyClear;
GuiImage * keySpaceImg;
GuiImage * keySpaceOverImg;
GuiButton * keySpace;
GuiButton * keyBtn[4][11];
GuiImage * keyImg[4][11];
GuiImage * keyImgOver[4][11];
GuiText * keyTxt[4][11];
GuiImageData * keyTextbox;
GuiImageData * key;
GuiImageData * keyOver;
GuiImageData * keyMedium;
GuiImageData * keyLarge;
GuiTrigger * trigA;
GuiTrigger * trigB;
};
//!On-screen keyboard
class GuiNumpad: public GuiWindow
{
public:
GuiNumpad(char * t, u32 max);
virtual ~GuiNumpad();
void Update(GuiTrigger * t);
char kbtextstr[256];
protected:
u32 kbtextmaxlen;
char keys[11];
GuiText * kbText;
GuiImage * keyTextboxImg;
GuiText * keyBackText;
GuiImage * keyBackImg;
GuiImage * keyBackOverImg;
GuiButton * keyBack;
GuiText * keyClearText;
GuiImage * keyClearImg;
GuiImage * keyClearOverImg;
GuiButton * keyClear;
GuiButton * keyBtn[11];
GuiImage * keyImg[11];
GuiImage * keyImgOver[11];
GuiText * keyTxt[11];
GuiImageData * keyTextbox;
GuiImageData * keyMedium;
GuiTrigger * trigA;
GuiTrigger * trigB;
};
#endif

618
gui_keyboard.cpp Executable file
View File

@ -0,0 +1,618 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_keyboard.cpp
*
* GUI class definitions
***************************************************************************/
#include "gui.h"
#include "../main.h"
#include "../settings/CSettings.h"
#include <stdio.h>
#include <string.h>
#include "themes/CTheme.h"
#include "menu.h"
/**
* Constructor for the GuiKeyboard class.
*/
//const Key thekeys;
GuiKeyboard::GuiKeyboard(char * t, u32 max, int minimum, int lang)
{
width = 540;
height = 400;
shift = 0;
caps = 0;
alt = 0;
alt2 = 0;
min = minimum;
int mode = lang;
textVisible = true;
selectable = true;
focus = 0; // allow focus
alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE;
kbtextmaxlen = max > sizeof(kbtextstr) ? sizeof(kbtextstr) : max; // limit max up to sizeof(kbtextstr)
memset(kbtextstr, 0, sizeof(kbtextstr));
strncpy(kbtextstr, t, kbtextmaxlen); // strncpy is needed to fill the rest with \0
kbtextstr[sizeof(kbtextstr) - 1] = 0; // terminate with \0
//QWERTY//
if (mode == 0)
{
Key thekeys[4][11] = {
{
{ '1', '!', '\0', '\0' },
{ '2', '@', '\0', '\0' },
{ '3', '#', '\0', '\0' },
{ '4', '$', '\0', '\0' },
{ '5', '%', '\0', '\0' },
{ '6', '^', '\0', '\0' },
{ '7', '&', '\0', '\0' },
{ '8', '*', '\0', '\0' },
{ '9', '(', '\0', '\0' },
{ '0', ')', '\0', '\0' },
{ '\0', '\0', '\0', '\0' }
},
{
{ 'q', 'Q', '\0', '\0' },
{ 'w', 'W', '\0', '\0' },
{ 'e', 'E', '\0', '\0' },
{ 'r', 'R', '\0', '\0' },
{ 't', 'T', '\0', '\0' },
{ 'y', 'Y', '\0', '\0' },
{ 'u', 'U', '\0', '\0' },
{ 'i', 'I', '\0', '\0' },
{ 'o', 'O', '\0', '\0' },
{ 'p', 'P', '\0', '\0' },
{ '-', '_', '\0', '\0' }
},
{
{ 'a', 'A', '\0', '\0' },
{ 's', 'S', '\0', '\0' },
{ 'd', 'D', '\0', '\0' },
{ 'f', 'F', '\0', '\0' },
{ 'g', 'G', '\0', '\0' },
{ 'h', 'H', '\0', '\0' },
{ 'j', 'J', '\0', '\0' },
{ 'k', 'K', '\0', '\0' },
{ 'l', 'L', '\0', '\0' },
{ ':', ';', '\0', '\0' },
{ '\'', '"', '\0', '\0' }
},
{
{ 'z', 'Z', '\0', '\0' },
{ 'x', 'X', '\0', '\0' },
{ 'c', 'C', '\0', '\0' },
{ 'v', 'V', '\0', '\0' },
{ 'b', 'B', '\0', '\0' },
{ 'n', 'N', '\0', '\0' },
{ 'm', 'M', '\0', '\0' },
{ ',', '<', '\0', '\0' },
{ '.', '>', '\0', '\0' },
{ '/', '?', '\0', '\0' },
{ '\0', '\0', '\0', '\0' }
}
};
memcpy(keys, thekeys, sizeof(thekeys));
}
//DVORAK//
if (mode == 1)
{
Key thekeys[4][11] = {
{
{ '1', '!', '\0', '\0' },
{ '2', '@', '\0', '\0' },
{ '3', '#', '\0', '\0' },
{ '4', '$', '\0', '\0' },
{ '5', '%', '\0', '\0' },
{ '6', '^', '\0', '\0' },
{ '7', '&', '\0', '\0' },
{ '8', '*', '\0', '\0' },
{ '9', '(', '\0', '\0' },
{ '0', ')', '\0', '\0' },
{ '\0', '\0', '\0', '\0' }
},
{
{ '\'', '"', '\0', '\0' },
{ ',', '<', '\0', '\0' },
{ '.', '>', '\0', '\0' },
{ 'p', 'P', '\0', '\0' },
{ 'y', 'Y', '\0', '\0' },
{ 'f', 'F', '\0', '\0' },
{ 'g', 'G', '\0', '\0' },
{ 'c', 'C', '\0', '\0' },
{ 'r', 'R', '\0', '\0' },
{ 'l', 'L', '\0', '\0' },
{ '/', '?', '\0', '\0' }
},
{
{ 'a', 'A', 'm', '\0' },
{ 'o', 'O', 'm', '\0' },
{ 'e', 'E', 'm', '\0' },
{ 'u', 'U', 'm', '\0' },
{ 'i', 'I', 'm', '\0' },
{ 'd', 'D', 'm', '\0' },
{ 'h', 'H', 'm', '\0' },
{ 't', 'T', 'm', '\0' },
{ 'n', 'N', 'm', '\0' },
{ 's', 'S', 'm', '\0' },
{ '-', '_', 'm', '\0' }
},
{
{ ';', ':', '\0', '\0' },
{ 'q', 'Q', '\0', '\0' },
{ 'j', 'J', '\0', '\0' },
{ 'k', 'K', '\0', '\0' },
{ 'x', 'X', '\0', '\0' },
{ 'b', 'B', '\0', '\0' },
{ 'm', 'M', '\0', '\0' },
{ 'w', 'W', '\0', '\0' },
{ 'v', 'V', '\0', '\0' },
{ 'z', 'Z', '\0', '\0' },
{ '\0', '\0', '\0', '\0' }
}
};
memcpy(keys, thekeys, sizeof(thekeys));
}
//QWETRZ//
if (mode == 2)
{
Key thekeys[4][11] = { { { '1', '!', '^', 'À' }, { '2', '"', '²', 'à' }, { '3', '#', '³', 'È' }, { '4', '$',
'«', 'è' }, { '5', '%', '»', 'Ì' }, { '6', '&', '„', 'ì' }, { '7', '/', '”', 'Ò' }, { '8', '(', '[',
'ò' }, { '9', ')', ']', 'Ù' }, { '0', '=', '§', 'ù' }, { 'ß', '?', '\'', 'Ý' } }, { { 'q', 'Q', '@',
'Á' }, { 'w', 'W', '\0', 'á' }, { 'e', 'E', '€', 'É' }, { 'r', 'R', '\0', 'é' },
{ 't', 'T', '\0', 'Í' }, { 'z', 'Z', '\0', 'í' }, { 'u', 'U', '\0', 'Ó' }, { 'i', 'I', '\0', 'ó' }, {
'o', 'O', '\0', 'Ú' }, { 'p', 'P', '\0', 'ú' }, { 'ü', 'Ü', '\0', 'ý' } }, { { 'a', 'A', '\0',
'Â' }, { 's', 'S', '\0', 'â' }, { 'd', 'D', '\0', 'Ê' }, { 'f', 'F', '\0', 'ê' },
{ 'g', 'G', '\0', 'Î' }, { 'h', 'H', '\0', 'î' }, { 'j', 'J', '\0', 'Ô' }, { 'k', 'K', '\0', 'ô' }, {
'l', 'L', '\0', 'Û' }, { 'ö', 'Ö', '\0', 'û' }, { 'ä', 'Ä', '\0', 'Ÿ' } }, { { '<', '>', '|',
'Ã' }, { 'y', 'Y', '\0', 'ã' }, { 'x', 'X', '\0', 'Ñ' }, { 'c', 'C', 'ç', 'ñ' },
{ 'v', 'V', '©', 'Ï' }, { 'b', 'B', '\0', 'ï' }, { 'n', 'N', '\0', 'Õ' }, { 'm', 'M', 'µ', 'õ' }, {
',', ';', '\0', 'ÿ' }, { '.', ':', '\0', '\0' }, { '-', '_', '\0', '\0' } } };
memcpy(keys, thekeys, sizeof(thekeys));
}
//AZERTY//
if (mode == 3)
{
Key thekeys[4][11] = { { { '1', '&', '²', 'À' }, { '2', '~', '³', 'é' }, { '3', '"', '#', 'È' }, { '4', '`',
'«', 'ù' }, { '5', '(', '[', 'Ì' }, { '6', '-', '|', 'ì' }, { '7', 'µ', '»', 'è' }, { '8', '_', '\'',
'ò' }, { '9', '+', '^', 'ç' }, { '0', '=', '@', 'à' }, { '°', ')', ']', 'Ý' } }, {
{ 'a', 'A', 'Æ', 'Á' }, { 'z', 'Z', 'Œ', 'á' }, { 'e', 'E', '€', 'É' }, { 'r', 'R', '®', 'ë' }, { 't',
'T', '†', 'Í' }, { 'y', 'Y', 'ÿ', 'í' }, { 'u', 'U', 'Õ', 'Ó' }, { 'i', 'I', 'õ', 'Ò' }, { 'o',
'O', 'Ø', 'Ú' }, { 'p', 'P', 'ø', 'ú' }, { '$', '£', '¤', 'ý' } }, { { 'q', 'Q', 'æ', 'Â' }, {
's', 'S', 'œ', 'â' }, { 'd', 'D', '\0', 'Ê' }, { 'f', 'F', 'ß', 'ê' }, { 'g', 'G', '\0', 'Î' }, { 'h',
'H', '\0', 'î' }, { 'j', 'J', '\0', 'Ô' }, { 'k', 'K', '\0', 'ô' }, { 'l', 'L', '\0', 'Û' }, { 'm',
'M', '\0', 'û' }, { '*', '%', '¬', 'Ù' } }, { { '<', '>', '\0', 'Ã' }, { 'w', 'W', '\0', 'Ä' }, { 'x',
'X', '\0', 'Ë' }, { 'c', 'C', '©', 'Ç' }, { 'v', 'V', '“', 'Ï' }, { 'b', 'B', '”', 'ï' }, { 'n', 'N',
'\0', 'Ñ' }, { '?', ',', '?', 'ñ' }, { '.', ';', '.', 'ó' }, { '/', ':', '/', 'ö' }, { '§', '!', '!',
'Ö' } } };
memcpy(keys, thekeys, sizeof(thekeys));
}
//QWERTY 2//
if (mode == 4)
{
Key thekeys[4][11] = { { { '1', '!', '|', 'Á' }, { '2', '"', '@', 'á' }, { '3', '·', '#', 'À' }, { '4', '$',
'£', 'à' }, { '5', '%', '~', 'É' }, { '6', '&', '¬', 'é' }, { '7', '/', '\'', 'È' }, { '8', '(', '[',
'è' }, { '9', ')', ']', 'Í' }, { '0', '=', '¤', 'í' }, { '¡', '?', '¿', 'Ï' } }, { { 'q', 'Q', '\0',
'ï' }, { 'w', 'W', '\0', 'Ó' }, { 'e', 'E', '€', 'ó' }, { 'r', 'R', '®', 'Ò' }, { 't', 'T', '†', 'ò' },
{ 'y', 'Y', 'ÿ', 'Ú' }, { 'u', 'U', '“', 'ú' }, { 'i', 'I', '”', 'Ü' }, { 'o', 'O', 'Ø', 'ü' }, { 'p',
'P', 'ø', 'Ù' }, { '+', '*', '\0', 'ù' } }, { { 'a', 'A', '^', 'Ã' }, { 's', 'S', '²', 'ã' }, {
'd', 'D', '³', 'Õ' }, { 'f', 'F', '«', 'õ' }, { 'g', 'G', '»', 'Ñ' }, { 'h', 'H', '§', 'ñ' }, { 'j',
'J', 'µ', 'Ç' }, { 'k', 'K', '¤', 'ç' }, { 'l', 'L', '„', '\0' }, { 'ñ', 'Ñ', '+', '\0' }, { 'ç', 'Ç',
'°', '\0' } }, { { '<', '>', '\0', 'Ä' }, { 'z', 'Z', '\0', 'ä' }, { 'x', 'X', '\0', 'Â' }, { 'c', 'C',
'©', 'â' }, { 'v', 'V', '\0', 'å' }, { 'b', 'B', 'ß', 'Ë' }, { 'n', 'N', '\0', 'ë' }, { 'm', 'M', '\0',
'Ê' }, { ',', ';', '\0', 'ê' }, { '.', ':', '\0', '\0' }, { '-', '_', '\0', '\0' } } };
memcpy(keys, thekeys, sizeof(thekeys));
}
keyTextbox = Resources::GetImageData("keyboard_textbox.png");
keyTextboxImg = new GuiImage(keyTextbox);
keyTextboxImg->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
keyTextboxImg->SetPosition(0, 40);//(0,0);
this->Append(keyTextboxImg);
kbText = new GuiText(kbtextstr, 20, ( GXColor ) {0, 0, 0, 0xff});
kbText->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
kbText->SetPosition(0, 53);//(0, 13);
this->Append(kbText);
key = Resources::GetImageData("keyboard_key.png");
keyOver = Resources::GetImageData("keyboard_key_over.png");
keyMedium = Resources::GetImageData("keyboard_mediumkey_over.png");
keyLarge = Resources::GetImageData("keyboard_largekey_over.png");
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB = new GuiTrigger;
trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
int eurocheck = 0;
if (mode > 1)
{
eurocheck = -20;
}
keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMedium);
if (mode == 3)
{
keyBackText = new GuiText("Retour", 20, ( GXColor )
{ 0, 0, 0, 0xff});
}
else
{
keyBackText = new GuiText("Back", 20, ( GXColor )
{ 0, 0, 0, 0xff});
}
//keyBack = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
keyBack = new GuiButton(keyBackImg, keyBackOverImg, 0, 3, 11 * 42 + 40 + eurocheck, 0 * 42 + 120, trigA,
btnSoundOver, btnSoundClick, 1);
//keyBack->SetImage(keyBackImg);
//keyBack->SetImageOver(keyBackOverImg);
keyBack->SetLabel(keyBackText);
//keyBack->SetSoundOver(btnSoundOver);
//keyBack->SetSoundClick(btnSoundClick);
//keyBack->SetTrigger(trigA);
keyBack->SetTrigger(trigB);
if (mode > 1)
{
keyBack->SetPosition(11 * 42 + 40 + eurocheck, 0 * 42 + 120);
}
else
{
keyBack->SetPosition(10 * 42 + 40 + eurocheck, 0 * 42 + 120);
}//(10*42+40, 0*42+80);
//keyBack->SetEffectGrow();
this->Append(keyBack);
keyClearImg = new GuiImage(keyMedium);
keyClearOverImg = new GuiImage(keyMedium);
if (mode == 3)
{
keyClearText = new GuiText("Effacer", 20, ( GXColor )
{ 0, 0, 0, 0xff});
}
else
{
keyClearText = new GuiText("Clear", 20, ( GXColor )
{ 0, 0, 0, 0xff});
}
keyClear = new GuiButton(keyClearImg, keyClearOverImg, 0, 3, (10 * 42 + 40) + eurocheck, 4 * 42 + 120, trigA,
btnSoundOver, btnSoundClick, 1);
//keyClear = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyClear->SetImage(keyClearImg);
//keyClear->SetImageOver(keyClearOverImg);
keyClear->SetLabel(keyClearText);
//keyClear->SetSoundOver(btnSoundOver);
//keyClear->SetSoundClick(btnSoundClick);
//keyClear->SetTrigger(trigA);
//keyClear->SetPosition((10*42+40)+eurocheck, 4*42+120);//(10*42+40, 0*42+80);
//keyClear->SetEffectGrow();
this->Append(keyClear);
keyAltImg = new GuiImage(keyMedium);
keyAltOverImg = new GuiImage(keyMedium);
keyAltText = new GuiText("Alt Gr", 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyAlt = new GuiButton(keyAltImg, keyAltOverImg, 0, 3, 84 + eurocheck, 4 * 42 + 120, trigA, btnSoundOver,
btnSoundClick, 1);
//keyAlt = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyAlt->SetImage(keyAltImg);
//keyAlt->SetImageOver(keyAltOverImg);
keyAlt->SetLabel(keyAltText);
//keyAlt->SetSoundOver(btnSoundOver);
//keyAlt->SetSoundClick(btnSoundClick);
//keyAlt->SetTrigger(trigA);
//keyAlt->SetPosition(84+eurocheck, 4*42+120);//(10*42+40, 4*42+120);
//keyAlt->SetEffectGrow();
if (mode > 1)
{
this->Append(keyAlt);
}
keyAlt2Img = new GuiImage(keyMedium);
keyAlt2OverImg = new GuiImage(keyMedium);
keyAlt2Text = new GuiText("Accent", 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyAlt2 = new GuiButton(keyAlt2Img, keyAlt2OverImg, 0, 3, (8 * 42 + 40) + eurocheck, 4 * 42 + 120, trigA,
btnSoundOver, btnSoundClick, 1);
//keyAlt2 = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyAlt2->SetImage(keyAlt2Img);
//keyAlt2->SetImageOver(keyAlt2OverImg);
keyAlt2->SetLabel(keyAlt2Text);
//keyAlt2->SetSoundOver(btnSoundOver);
//keyAlt2->SetSoundClick(btnSoundClick);
//keyAlt2->SetTrigger(trigA);
//keyAlt2->SetPosition((8*42+40)+eurocheck, 4*42+120);//(10*42+40, 4*42+120);
//keyAlt2->SetEffectGrow();
if (mode > 1)
{
this->Append(keyAlt2);
}
keyCapsImg = new GuiImage(keyMedium);
keyCapsOverImg = new GuiImage(keyMedium);
keyCapsText = new GuiText("Caps", 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyCaps = new GuiButton(keyCapsImg, keyCapsOverImg, 0, 3, 0 + eurocheck, 2 * 42 + 120, trigA, btnSoundOver,
btnSoundClick, 1);
//keyCaps = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyCaps->SetImage(keyCapsImg);
//keyCaps->SetImageOver(keyCapsOverImg);
keyCaps->SetLabel(keyCapsText);
//keyCaps->SetSoundOver(btnSoundOver);
//keyCaps->SetSoundClick(btnSoundClick);
//keyCaps->SetTrigger(trigA);
//keyCaps->SetPosition(0+eurocheck, 2*42+120);//(0, 2*42+80);
//keyCaps->SetEffectGrow();
this->Append(keyCaps);
keyShiftImg = new GuiImage(keyMedium);
keyShiftOverImg = new GuiImage(keyMedium);
keyShiftText = new GuiText("Shift", 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyShift = new GuiButton(keyShiftImg, keyShiftOverImg, 0, 3, 21 + eurocheck, 3 * 42 + 120, trigA, btnSoundOver,
btnSoundClick, 1);
//keyShift = new GuiButton(keyMedium->GetWidth(), keyMedium->GetHeight());
//keyShift->SetImage(keyShiftImg);
//keyShift->SetImageOver(keyShiftOverImg);
keyShift->SetLabel(keyShiftText);
//keyShift->SetSoundOver(btnSoundOver);
//keyShift->SetSoundClick(btnSoundClick);
//keyShift->SetTrigger(trigA);
//keyShift->SetPosition(21+eurocheck, 3*42+120);//(21, 3*42+80);
//keyShift->SetEffectGrow();
this->Append(keyShift);
keySpaceImg = new GuiImage(keyLarge);
keySpaceOverImg = new GuiImage(keyLarge);
keySpace = new GuiButton(keySpaceImg, keySpaceOverImg, 2, 3, 0 + eurocheck, 4 * 42 + 120, trigA, btnSoundOver,
btnSoundClick, 1);
//keySpace = new GuiButton(keyLarge->GetWidth(), keyLarge->GetHeight());
//keySpace->SetImage(keySpaceImg);
//keySpace->SetImageOver(keySpaceOverImg);
//keySpace->SetSoundOver(btnSoundOver);
//keySpace->SetSoundClick(btnSoundClick);
//keySpace->SetTrigger(trigA);
//keySpace->SetPosition(0+eurocheck, 4*42+120);//(0, 4*42+80);
//keySpace->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
//keySpace->SetEffectGrow();
this->Append(keySpace);
char txt[2] = { 0, 0 };
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 11; j++)
{
if (keys[i][j].ch != '\0')
{
keyImg[i][j] = new GuiImage(key);
keyImgOver[i][j] = new GuiImage(keyOver);
txt[0] = keys[i][j].ch;
keyTxt[i][j] = new GuiText(txt, 20, ( GXColor )
{ 0, 0, 0, 0xff});
keyTxt[i][j]->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
keyTxt[i][j]->SetPosition(0, -10);
keyBtn[i][j] = new GuiButton(keyImg[i][j], keyImgOver[i][j], 0, 3, (j * 42 + 21 * i + 40) + eurocheck,
i * 42 + 120, trigA, btnSoundOver, btnSoundClick, 1);
//keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight());
//keyBtn[i][j]->SetImage(keyImg[i][j]);
//keyBtn[i][j]->SetImageOver(keyImgOver[i][j]);
//keyBtn[i][j]->SetSoundOver(btnSoundOver);
//keyBtn[i][j]->SetSoundClick(btnSoundClick);
//keyBtn[i][j]->SetTrigger(trigA);
keyBtn[i][j]->SetLabel(keyTxt[i][j]);
//keyBtn[i][j]->SetPosition((j*42+21*i+40)+eurocheck, i*42+120);//SetPosition(j*42+21*i+40, i*42+80);
//keyBtn[i][j]->SetEffectGrow();
this->Append(keyBtn[i][j]);
}
}
}
}
/**
* Destructor for the GuiKeyboard class.
*/
GuiKeyboard::~GuiKeyboard()
{
delete kbText;
delete keyTextbox;
delete keyTextboxImg;
delete keyCapsText;
delete keyCapsImg;
delete keyCapsOverImg;
delete keyCaps;
delete keyShiftText;
delete keyShiftImg;
delete keyShiftOverImg;
delete keyShift;
if (keyAlt)
{
delete keyAlt;
}
if (keyAlt2)
{
delete keyAlt2;
}
delete keyBackText;
delete keyBackImg;
delete keyBackOverImg;
delete keyBack;
delete keySpaceImg;
delete keySpaceOverImg;
delete keySpace;
delete key;
delete keyOver;
delete keyMedium;
delete keyLarge;
delete trigA;
delete trigB;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 11; j++)
{
if (keys[i][j].ch != '\0')
{
delete keyImg[i][j];
delete keyImgOver[i][j];
delete keyTxt[i][j];
delete keyBtn[i][j];
}
}
}
}
void GuiKeyboard::SetDisplayText(const char *text)
{
if(!text || textVisible)
{
kbText->SetText(text);
}
else
{
std::string asterix(strlen(text), '*');
kbText->SetText(asterix.c_str());
}
}
void GuiKeyboard::Update(GuiTrigger * t)
{
LOCK( this );
if (_elements.size() == 0 || (state == STATE_DISABLED && parentElement)) return;
for (u8 i = 0; i < _elements.size(); i++)
{
try
{
_elements.at(i)->Update(t);
}
catch (const std::exception& e)
{
}
}
bool changedShiftKey = false;
if (keySpace->GetState() == STATE_CLICKED)
{
if (strlen(kbtextstr) < kbtextmaxlen - 1) // -1 --> kbtextmaxlen means with terminating '\0'
{
kbtextstr[strlen(kbtextstr)] = ' ';
SetDisplayText(kbtextstr);
}
keySpace->SetState(STATE_SELECTED, t->chan);
}
else if (keyBack->GetState() == STATE_CLICKED)
{
if (strlen(kbtextstr) > min)
{
kbtextstr[strlen(kbtextstr) - 1] = 0;
SetDisplayText(kbtextstr);
}
keyBack->SetState(STATE_SELECTED, t->chan);
}
else if (keyClear->GetState() == STATE_CLICKED)
{
while (strlen(kbtextstr) > min)
{
kbtextstr[strlen(kbtextstr) - 1] = 0;
}
SetDisplayText(kbtextstr);
keyClear->SetState(STATE_SELECTED, t->chan);
}
else if (keyShift->GetState() == STATE_CLICKED)
{
changedShiftKey = true;
shift ^= 1;
if (alt) alt ^= 1;
if (alt2) alt2 ^= 1;
keyShift->SetState(STATE_SELECTED, t->chan);
}
else if (keyAlt->GetState() == STATE_CLICKED)
{
changedShiftKey = true;
alt ^= 1;
if (shift) shift ^= 1;
if (alt2) alt2 ^= 1;
keyAlt->SetState(STATE_SELECTED, t->chan);
}
else if (keyAlt2->GetState() == STATE_CLICKED)
{
changedShiftKey = true;
alt2 ^= 1;
if (shift) shift ^= 1;
if (alt) alt ^= 1;
keyAlt2->SetState(STATE_SELECTED, t->chan);
}
else if (keyCaps->GetState() == STATE_CLICKED)
{
changedShiftKey = true;
caps ^= 1;
keyCaps->SetState(STATE_SELECTED, t->chan);
}
bool update = false;
char txt[2] = { 0, 0 };
do
{
update = false;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 11; j++)
{
if (keys[i][j].ch != '\0')
{
if (shift || caps)
txt[0] = keys[i][j].chShift;
else if (alt)
txt[0] = keys[i][j].chalt;
else if (alt2)
txt[0] = keys[i][j].chalt2;
else txt[0] = keys[i][j].ch;
if (changedShiftKey) // change text only if needed
keyTxt[i][j]->SetText(txt);
if (keyBtn[i][j]->GetState() == STATE_CLICKED)
{
if (strlen(kbtextstr) < kbtextmaxlen - 1) // -1 --> kbtextmaxlen means with term. '\0'
{
kbtextstr[strlen(kbtextstr)] = txt[0];
SetDisplayText(kbtextstr);
}
keyBtn[i][j]->SetState(STATE_SELECTED, t->chan);
if (shift || alt || alt2)
{
if (shift) shift ^= 1;
if (alt) alt ^= 1;
if (alt2) alt2 ^= 1;
update = true;
changedShiftKey = true;
}
}
}
}
}
} while (update);
this->ToggleFocus(t);
if (focus) // only send actions to this window if it's in focus
{
// pad/joystick navigation
if (t->Right())
this->MoveSelectionHor(1);
else if (t->Left())
this->MoveSelectionHor(-1);
else if (t->Down())
this->MoveSelectionVert(1);
else if (t->Up()) this->MoveSelectionVert(-1);
}
}

View File

@ -895,15 +895,21 @@ class GuiKeyboard: public GuiWindow
public:
GuiKeyboard(char * t, u32 m, int min, int lang);
virtual ~GuiKeyboard();
void SetVisibleText(bool v) { textVisible = v; }
const char *GetText() { return kbtextstr; }
void Update(GuiTrigger * t);
char kbtextstr[256];
protected:
void SetDisplayText(const char *text);
bool textVisible;
char kbtextstr[256];
u32 kbtextmaxlen;
Key keys[4][11];
int shift;
int caps;
int alt;
int alt2;
u16 min;
GuiText * kbText;
GuiImage * keyTextboxImg;
GuiText * keyCapsText;

View File

@ -18,9 +18,8 @@
/**
* Constructor for the GuiKeyboard class.
*/
unsigned int m;
//const Key thekeys;
GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
GuiKeyboard::GuiKeyboard(char * t, u32 max, int minimum, int lang)
{
width = 540;
height = 400;
@ -28,14 +27,15 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
caps = 0;
alt = 0;
alt2 = 0;
m = min;
min = minimum;
int mode = lang;
textVisible = true;
selectable = true;
focus = 0; // allow focus
alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE;
kbtextmaxlen = max > sizeof(kbtextstr) ? sizeof(kbtextstr) : max; // limit max up to sizeof(kbtextstr)
// strlcpy(kbtextstr, t, kbtextmaxlen);
memset(kbtextstr, 0, sizeof(kbtextstr));
strncpy(kbtextstr, t, kbtextmaxlen); // strncpy is needed to fill the rest with \0
kbtextstr[sizeof(kbtextstr) - 1] = 0; // terminate with \0
//QWERTY//
@ -214,8 +214,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
keyTextboxImg->SetPosition(0, 40);//(0,0);
this->Append(keyTextboxImg);
kbText = new GuiText(kbtextstr, 20, ( GXColor )
{ 0, 0, 0, 0xff});
kbText = new GuiText(kbtextstr, 20, ( GXColor ) {0, 0, 0, 0xff});
kbText->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
kbText->SetPosition(0, 53);//(0, 13);
this->Append(kbText);
@ -467,6 +466,19 @@ GuiKeyboard::~GuiKeyboard()
}
}
void GuiKeyboard::SetDisplayText(const char *text)
{
if(!text || textVisible)
{
kbText->SetText(text);
}
else
{
std::string asterix(strlen(text), '*');
kbText->SetText(asterix.c_str());
}
}
void GuiKeyboard::Update(GuiTrigger * t)
{
LOCK( this );
@ -490,26 +502,26 @@ void GuiKeyboard::Update(GuiTrigger * t)
if (strlen(kbtextstr) < kbtextmaxlen - 1) // -1 --> kbtextmaxlen means with terminating '\0'
{
kbtextstr[strlen(kbtextstr)] = ' ';
kbText->SetText(kbtextstr);
SetDisplayText(kbtextstr);
}
keySpace->SetState(STATE_SELECTED, t->chan);
}
else if (keyBack->GetState() == STATE_CLICKED)
{
if (strlen(kbtextstr) > (m))
if (strlen(kbtextstr) > min)
{
kbtextstr[strlen(kbtextstr) - 1] = 0;
kbText->SetText(kbtextstr);
SetDisplayText(kbtextstr);
}
keyBack->SetState(STATE_SELECTED, t->chan);
}
else if (keyClear->GetState() == STATE_CLICKED)
{
while (strlen(kbtextstr) > (m))
while (strlen(kbtextstr) > min)
{
kbtextstr[strlen(kbtextstr) - 1] = 0;
kbText->SetText(kbtextstr);
}
SetDisplayText(kbtextstr);
keyClear->SetState(STATE_SELECTED, t->chan);
}
else if (keyShift->GetState() == STATE_CLICKED)
@ -572,7 +584,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
if (strlen(kbtextstr) < kbtextmaxlen - 1) // -1 --> kbtextmaxlen means with term. '\0'
{
kbtextstr[strlen(kbtextstr)] = txt[0];
kbText->SetText(kbtextstr);
SetDisplayText(kbtextstr);
}
keyBtn[i][j]->SetState(STATE_SELECTED, t->chan);
@ -590,8 +602,6 @@ void GuiKeyboard::Update(GuiTrigger * t)
}
} while (update);
kbText->SetPosition(0, 53);
this->ToggleFocus(t);
if (focus) // only send actions to this window if it's in focus

View File

@ -336,7 +336,6 @@ void GuiScrollbar::SetSelectedItem(int pos)
return;
SelItem = pos;
listChanged(SelItem, SelInd);
}
void GuiScrollbar::SetSelectedIndex(int pos)

View File

@ -117,7 +117,7 @@ int OnScreenNumpad(char * var, u32 maxlen)
* Opens an on-screen keyboard window, with the data entered being stored
* into the specified variable.
***************************************************************************/
int OnScreenKeyboard(char * var, u32 maxlen, int min)
int OnScreenKeyboard(char * var, u32 maxlen, int min, bool hide)
{
int save = -1;
@ -125,6 +125,7 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min)
gprintf("\nOnScreenKeyboard(%s, %i, %i) \n\tkeyset = %i", var, maxlen, min, Settings.keyset);
GuiKeyboard keyboard(var, maxlen, min, Settings.keyset);
keyboard.SetVisibleText(!hide);
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
@ -173,7 +174,7 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min)
if (save)
{
snprintf(var, maxlen, "%s", keyboard.kbtextstr);
snprintf(var, maxlen, "%s", keyboard.GetText());
}
HaltGui();

View File

@ -14,7 +14,7 @@ int WindowPrompt(const char *title, const char *msg = NULL, const char * btn1Lab
NULL, const char * btn3Label = NULL, const char * btn4Label = NULL, int wait = -1);
void WindowCredits();
int OnScreenKeyboard(char * var, u32 maxlen, int min);
int OnScreenKeyboard(char * var, u32 maxlen, int min, bool hide = false);
int OnScreenNumpad(char * var, u32 maxlen);
int WindowExitPrompt();
int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait);

View File

@ -87,7 +87,7 @@ int InitBrowsers()
{
closedir(dir);
BROWSERINFO browser;
browser.dir[0] = '\0';
memset(&browser, 0, sizeof(BROWSERINFO));
strcpy(browser.rootdir, rootdir);
ResetBrowser(&browser);
browsers.push_back(browser);

View File

@ -133,6 +133,7 @@ void CSettings::SetDefault()
WiirdDebugger = OFF;
WiirdDebuggerPause = OFF;
ShowPlayCount = ON;
RememberUnlock = ON;
}
bool CSettings::Load()
@ -224,6 +225,7 @@ bool CSettings::Save()
fprintf(file, "sfxvolume = %d\n", sfxvolume);
fprintf(file, "gamesoundvolume = %d\n", gamesoundvolume);
fprintf(file, "tooltips = %d\n", tooltips);
fprintf(file, "RememberUnlock = %d\n", RememberUnlock);
char EncryptedTxt[50];
EncryptString(unlockCode, EncryptedTxt);
fprintf(file, "password = %s\n", EncryptedTxt);
@ -404,11 +406,22 @@ bool CSettings::SetSetting(char *name, char *value)
}
return true;
}
else if (strcmp(name, "RememberUnlock") == 0)
{
if (sscanf(value, "%d", &i) == 1)
{
RememberUnlock = i;
}
return true;
}
else if (strcmp(name, "password") == 0)
{
char EncryptedTxt[50];
strcpy(EncryptedTxt, value);
DecryptString(EncryptedTxt, unlockCode);
if(!RememberUnlock && strlen(unlockCode) > 0 && strcmp(unlockCode, "not set") != 0)
godmode = 0;
return true;
}
else if (strcmp(name, "GameSort") == 0)

View File

@ -133,6 +133,7 @@ class CSettings
short WiirdDebugger;
short WiirdDebuggerPause;
short ShowPlayCount;
short RememberUnlock;
protected:
bool ValidVersion(FILE * file);
bool SetSetting(char *name, char *value);

View File

@ -56,6 +56,7 @@ ParentalControlSM::ParentalControlSM()
Options->SetName(Idx++, "%s", tr( "Console" ));
Options->SetName(Idx++, "%s", tr( "Password" ));
Options->SetName(Idx++, "%s", tr( "Controllevel" ));
Options->SetName(Idx++, "%s", tr( "Remember Unlock" ));
Options->SetName(Idx++, "%s", tr( "Block Global Settings" ));
Options->SetName(Idx++, "%s", tr( "Block Gui Settings" ));
Options->SetName(Idx++, "%s", tr( "Block Loader Settings" ));
@ -105,6 +106,9 @@ void ParentalControlSM::SetOptionValues()
//! Settings: Controllevel
Options->SetValue(Idx++, "%s", tr(ParentalText[Settings.parentalcontrol]));
//! Settings: Remember Unlock
Options->SetValue(Idx++, "%s", tr(OnOffText[Settings.RememberUnlock]));
//! Settings: Block Global Settings
Options->SetValue(Idx++, "%s", tr(OnOffText[((Settings.ParentalBlocks & BLOCK_GLOBAL_SETTINGS) != 0)]));
@ -234,6 +238,12 @@ int ParentalControlSM::GetMenuInternal()
if (++Settings.parentalcontrol >= 5) Settings.parentalcontrol = 0;
}
//! Settings: Remember Unlock
else if (ret == ++Idx)
{
if (++Settings.RememberUnlock >= MAX_ON_OFF) Settings.RememberUnlock = 0;
}
//! Settings: Block Global Settings
else if (ret == ++Idx)
{

View File

@ -30,9 +30,9 @@ extern "C"
}
//Wiilight stuff
static vu32 *_wiilight_reg = (u32*) 0xCD0000C0;
void wiilight(int enable) // Toggle wiilight (thanks Bool for wiilight source)
{
static vu32 *_wiilight_reg = (u32*) 0xCD0000C0;
u32 val = (*_wiilight_reg & ~0x20);
if (enable && Settings.wiilight) val |= 0x20;
*_wiilight_reg = val;
@ -168,6 +168,11 @@ void Sys_ShutdownToStandby(void)
void Sys_LoadMenu(void)
{
ExitApp();
// Preloader shutup
*(u32 *)0x8132fffb = 0x50756e65;
DCFlushRange((u32 *)0x8132fffb, 4);
/* Return to the Wii system menu */
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}

View File

@ -8,7 +8,7 @@ int PasswordCheck(const char * password)
char entered[100];
memset(entered, 0, sizeof(entered));
int result = OnScreenKeyboard(entered, 20, 0);
int result = OnScreenKeyboard(entered, 20, 0, true);
if (result == 1)
{
if (strcmp(entered, password) == 0) //if password correct