2009-05-27 10:51:39 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* libwiigui
|
|
|
|
*
|
|
|
|
* gui_gamecarousel.cpp
|
|
|
|
*
|
|
|
|
* GUI class definitions
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gui.h"
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
#include "wpad.h"
|
|
|
|
#include "menu.h"
|
2009-05-27 10:51:39 +02:00
|
|
|
|
|
|
|
#include <unistd.h>
|
2009-09-27 20:19:53 +02:00
|
|
|
#include "gui_image_async.h"
|
2009-05-27 10:51:39 +02:00
|
|
|
#include "gui_gamecarousel.h"
|
2010-09-18 13:46:25 +02:00
|
|
|
#include "usbloader/GameList.h"
|
2010-10-28 11:00:52 +02:00
|
|
|
#include "settings/GameTitles.h"
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
#include "settings/CSettings.h"
|
|
|
|
#include "libwiigui/LoadCoverImage.h"
|
2010-09-24 19:58:56 +02:00
|
|
|
#include "themes/CTheme.h"
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
#include "main.h"
|
2009-05-27 10:51:39 +02:00
|
|
|
|
|
|
|
#include <string.h>
|
**Changes
*Fixed effect GOROUND so that it doesn't cause alignment issues anymore (the format for this effect is very different than it originally was, if you plan on using it for something, look at the documentation in gui.h.
*Major revamp of gui_gamecarousel (everything is awesome and perfect, except it still can't launch games, and thus it is still not in the gui).
**gui_gamecarousel Notes:
*You can use the same technique as last time to test the carousel (except I recommend adding startat and offset to the line since I added support for it).
*I realized not everyone will agree for my choice of curvature and spacing for the games on the carousel, so I made them variable. At the top of gui_gamecarousel.cpp are a bunch of definitions that set up these values.
*SCALE determines the size of the game boxes.
*DEG_OFFSET is the number of degrees between the boxes (remember, changing the RADIUS will affect the linear distance each degree represents).
*RADIUS determines the curvature of the arc (higher radius makes it less curved).
*IN_SPEED determines the speed at which the boxes come in (higher number makes it faster).
*SHFIT_SPEED determines the speed at which the boxes move when you turn the carousel.
*PAGESIZE determines how many boxes are drawn (remember, the number of visible boxes is determined by DEG_OFFSET and RADIUS, with the default values you can see 7).
*Everything eles (the animations, position of the movement buttons, etc.) is automatically determined from these values (my 8th grade math teacher was right, trig isn't totally worthless), so you shouldn't need to change anything at all, except the aforementioned values (or the b0rken game launching code).
*If you find a set of values you think looks better than mine, post a picture and the list of values in an issue or on IRC.
*These will probably become theamable at some point, but I figure we should get this added to the gui first (I was hoping to do it tonight, but some stuff came up, and I need to go to bed).
Wow I write really long commit notes.
2009-05-29 07:27:29 +02:00
|
|
|
#include <math.h>
|
2009-05-27 10:51:39 +02:00
|
|
|
#include <sstream>
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
#define SCALE 0.8f
|
|
|
|
#define DEG_OFFSET 7
|
|
|
|
#define RADIUS 780
|
|
|
|
#define IN_SPEED 175
|
|
|
|
#define SHIFT_SPEED 75
|
|
|
|
#define SPEED_STEP 4
|
|
|
|
#define SPEED_LIMIT 250
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
static inline int OFFSETLIMIT(int Offset, int gameCnt)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
while (Offset < 0)
|
|
|
|
Offset += gameCnt;
|
2010-09-19 01:16:05 +02:00
|
|
|
return Offset % gameCnt;
|
2009-09-27 20:19:53 +02:00
|
|
|
}
|
|
|
|
#define GetGameIndex(pageEntry, listOffset, gameCnt) OFFSETLIMIT(listOffset+pageEntry, gameCnt)
|
2010-09-24 02:48:03 +02:00
|
|
|
static GuiImageData *GameCarouselLoadCoverImage(void * Arg)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
return LoadCoverImage((struct discHdr *) Arg, true, false);
|
2009-09-27 20:19:53 +02:00
|
|
|
}
|
2009-05-27 10:51:39 +02:00
|
|
|
/**
|
|
|
|
* Constructor for the GuiGameCarousel class.
|
|
|
|
*/
|
2011-01-08 13:35:41 +01:00
|
|
|
GuiGameCarousel::GuiGameCarousel(int w, int h, const char *themePath, int selectedGame) :
|
2010-12-28 18:02:10 +01:00
|
|
|
noCover(Resources::GetFile("nocover.png"), Resources::GetFileSize("nocover.png"))
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
width = w;
|
|
|
|
height = h;
|
2010-09-24 02:48:03 +02:00
|
|
|
pagesize = (gameList.size() < 11) ? gameList.size() : 11;
|
2011-02-12 19:26:18 +01:00
|
|
|
listOffset = (gameList.size() < 11) ? 0 : gameList.size()-2;
|
2010-09-19 01:16:05 +02:00
|
|
|
selectable = true;
|
|
|
|
selectedItem = -1;
|
2010-09-24 02:48:03 +02:00
|
|
|
focus = 1; // allow focus
|
2010-09-19 01:16:05 +02:00
|
|
|
clickedItem = -1;
|
|
|
|
|
|
|
|
speed = 0;
|
|
|
|
|
|
|
|
trigA = new GuiTrigger;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
2010-09-19 01:16:05 +02:00
|
|
|
trigL = new GuiTrigger;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigL->SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
|
2010-09-19 01:16:05 +02:00
|
|
|
trigR = new GuiTrigger;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigR->SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
|
2010-09-19 01:16:05 +02:00
|
|
|
trigPlus = new GuiTrigger;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigPlus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
|
2010-09-19 01:16:05 +02:00
|
|
|
trigMinus = new GuiTrigger;
|
2010-09-24 02:48:03 +02:00
|
|
|
trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
|
|
|
|
|
2010-09-26 10:33:43 +02:00
|
|
|
imgLeft = Resources::GetImageData("startgame_arrow_left.png");
|
|
|
|
imgRight = Resources::GetImageData("startgame_arrow_right.png");
|
2010-09-24 02:48:03 +02:00
|
|
|
|
|
|
|
btnLeftImg = new GuiImage(imgLeft);
|
2010-10-27 16:45:27 +02:00
|
|
|
if (Settings.wsprompt == ON) btnLeftImg->SetWidescreen(Settings.widescreen);
|
2010-09-24 02:48:03 +02:00
|
|
|
btnLeft = new GuiButton(imgLeft->GetWidth(), imgLeft->GetHeight());
|
2011-01-17 23:03:14 +01:00
|
|
|
btnLeft->SetAlignment(thAlign("left - carousel layout left arrow align hor"), thAlign("top - carousel layout left arrow align ver"));
|
|
|
|
btnLeft->SetPosition(thInt("20 - carousel layout left arrow pos x"), thInt("65 - carousel layout left arrow pos y"));
|
2010-09-24 02:48:03 +02:00
|
|
|
btnLeft->SetParent(this);
|
|
|
|
btnLeft->SetImage(btnLeftImg);
|
|
|
|
btnLeft->SetSoundOver(btnSoundOver);
|
|
|
|
btnLeft->SetTrigger(trigA);
|
|
|
|
btnLeft->SetTrigger(trigL);
|
|
|
|
btnLeft->SetTrigger(trigMinus);
|
2010-09-19 01:16:05 +02:00
|
|
|
btnLeft->SetEffectGrow();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
btnRightImg = new GuiImage(imgRight);
|
2010-10-27 16:45:27 +02:00
|
|
|
if (Settings.wsprompt == ON) btnRightImg->SetWidescreen(Settings.widescreen);
|
2010-09-24 02:48:03 +02:00
|
|
|
btnRight = new GuiButton(imgRight->GetWidth(), imgRight->GetHeight());
|
|
|
|
btnRight->SetParent(this);
|
2011-01-17 23:03:14 +01:00
|
|
|
btnRight->SetAlignment(thAlign("right - carousel layout right arrow align hor"), thAlign("top - carousel layout right arrow align ver"));
|
|
|
|
btnRight->SetPosition(thInt("-20 - carousel layout right arrow pos x"), thInt("65 - carousel layout right arrow pos y"));
|
2010-09-24 02:48:03 +02:00
|
|
|
btnRight->SetImage(btnRightImg);
|
|
|
|
btnRight->SetSoundOver(btnSoundOver);
|
|
|
|
btnRight->SetTrigger(trigA);
|
|
|
|
btnRight->SetTrigger(trigR);
|
|
|
|
btnRight->SetTrigger(trigPlus);
|
2010-09-19 01:16:05 +02:00
|
|
|
btnRight->SetEffectGrow();
|
|
|
|
|
2010-12-26 18:02:14 +01:00
|
|
|
gamename = new GuiText(" ", 18, thColor("r=55 g=190 b=237 a=255 - carousel game name text color"));
|
2010-09-24 02:48:03 +02:00
|
|
|
gamename->SetParent(this);
|
|
|
|
gamename->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
|
|
|
|
gamename->SetPosition(0, 330);
|
|
|
|
gamename->SetMaxWidth(280, DOTTED);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
gameIndex = new int[pagesize];
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
game.resize(pagesize);
|
|
|
|
coverImg.resize(pagesize);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
//------------------------
|
|
|
|
// Index
|
|
|
|
//------------------------
|
|
|
|
gameIndex[i] = GetGameIndex( i, listOffset, gameList.size() );
|
|
|
|
|
|
|
|
//------------------------
|
|
|
|
// Image
|
|
|
|
//------------------------
|
2010-09-24 02:48:03 +02:00
|
|
|
coverImg[i] = new (std::nothrow) GuiImageAsync(GameCarouselLoadCoverImage, gameList[gameIndex[i]],
|
|
|
|
sizeof(struct discHdr), &noCover);
|
|
|
|
if (coverImg[i]) coverImg[i]->SetWidescreen(Settings.widescreen);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
//------------------------
|
|
|
|
// GameButton
|
|
|
|
//------------------------
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
game[i] = new GuiButton(122, 244);
|
|
|
|
game[i]->SetParent(this);
|
|
|
|
game[i]->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
|
|
|
game[i]->SetPosition(0, 740);
|
|
|
|
game[i]->SetImage(coverImg[i]);
|
|
|
|
game[i]->SetScale(SCALE);
|
|
|
|
game[i]->SetRumble(false);
|
|
|
|
game[i]->SetTrigger(trigA);
|
|
|
|
game[i]->SetSoundClick(btnSoundClick);
|
|
|
|
game[i]->SetClickable(true);
|
|
|
|
game[i]->SetEffect(EFFECT_GOROUND, IN_SPEED, 90 - (pagesize - 2 * i - 1) * DEG_OFFSET / 2, RADIUS, 180, 1, 0,
|
|
|
|
RADIUS);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor for the GuiGameCarousel class.
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
GuiGameCarousel::~GuiGameCarousel()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
delete imgRight;
|
|
|
|
delete imgLeft;
|
|
|
|
delete btnLeftImg;
|
|
|
|
delete btnRightImg;
|
|
|
|
delete btnRight;
|
|
|
|
delete btnLeft;
|
|
|
|
|
|
|
|
delete trigA;
|
|
|
|
delete trigL;
|
|
|
|
delete trigR;
|
|
|
|
delete trigPlus;
|
|
|
|
delete trigMinus;
|
2009-08-01 16:42:12 +02:00
|
|
|
delete gamename;
|
2009-05-27 10:51:39 +02:00
|
|
|
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
GuiImageAsync::ClearQueue();
|
|
|
|
|
|
|
|
for (u32 i = 0; i < game.size(); ++i)
|
2010-09-19 01:16:05 +02:00
|
|
|
delete coverImg[i];
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
for (u32 i = 0; i < game.size(); ++i)
|
2010-09-19 01:16:05 +02:00
|
|
|
delete game[i];
|
*Completely rewrote the asynchron GuiImageData class (problems from switch Carousel<->Grid layour should be fixed now)
*Fixed bug mounting a wbfs partition which was formatted from an ext partition
*Rewrote the parental control feature. Removed loading pin or settings from the Wii Settings. Parental control is now completely managed in the loader from the settings selected and the password set.
*Saving password in config file is now encrypted
*Added loop to wait for usb when reloading the cIOS before game start
The parental control feature is filtering games like following when usb loader is locked:
level 0 (everyone 0+) > shows only games with lvl 0
level 1 (childs 7+) > shows games with lvl 0, 1
level 2 (teens 12+) > shows games with lvl 0, 1, 2
level 3 (mature 16+) > shows games with lvl 0, 1, 2, 3
level 4 (adults only 18+) > shows all games (lvl 0, 1, 2, 3, 4)
level 4 is default when creating new configs
2010-12-19 19:20:33 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
delete[] gameIndex;
|
2009-09-27 20:19:53 +02:00
|
|
|
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiGameCarousel::SetFocus(int f)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!gameList.size()) return;
|
2009-08-01 16:42:12 +02:00
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
focus = f;
|
2009-05-27 10:51:39 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
game[i]->ResetState();
|
2009-05-27 10:51:39 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (f == 1 && selectedItem >= 0) game[selectedItem]->SetState(STATE_SELECTED);
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
void GuiGameCarousel::ResetState()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if (state != STATE_DISABLED)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
state = STATE_DEFAULT;
|
|
|
|
stateChan = -1;
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
game[i]->ResetState();
|
|
|
|
}
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
int GuiGameCarousel::GetOffset()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
return listOffset;
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
int GuiGameCarousel::GetClickedOption()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
int found = -1;
|
2010-09-24 02:48:03 +02:00
|
|
|
if (clickedItem >= 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
game[clickedItem]->SetState(STATE_SELECTED);
|
2010-09-19 01:16:05 +02:00
|
|
|
found = gameIndex[clickedItem];
|
|
|
|
clickedItem = -1;
|
|
|
|
}
|
|
|
|
return found;
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
int GuiGameCarousel::GetSelectedOption()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
|
|
|
int found = -1;
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (game[i]->GetState() == STATE_SELECTED)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
game[i]->SetState(STATE_SELECTED);
|
2010-09-19 01:16:05 +02:00
|
|
|
found = gameIndex[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw the button on screen
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
void GuiGameCarousel::Draw()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!this->IsVisible() || !gameList.size()) return;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
game[i]->Draw();
|
|
|
|
|
|
|
|
gamename->Draw();
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (gameList.size() > 6)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
btnRight->Draw();
|
|
|
|
btnLeft->Draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
//!Draw tooltip after the Images to have it on top
|
2010-10-27 16:45:27 +02:00
|
|
|
if (focus && Settings.tooltips == ON) for (int i = 0; i < pagesize; i++)
|
2010-09-24 02:48:03 +02:00
|
|
|
game[i]->DrawTooltip();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
this->UpdateEffects();
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void GuiGameCarousel::Update(GuiTrigger * t)
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
LOCK( this );
|
2011-01-30 17:22:16 +01:00
|
|
|
if (state == STATE_DISABLED || !t || !gameList.size() || !pagesize) return;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
btnRight->Update(t);
|
|
|
|
btnLeft->Update(t);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (game[0]->GetEffect() & EFFECT_GOROUND || game[pagesize - 1]->GetEffect() & EFFECT_GOROUND)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
return; // skip when rotate
|
|
|
|
}
|
|
|
|
|
|
|
|
// find selected + clicked
|
|
|
|
int selectedItem_old = selectedItem;
|
|
|
|
selectedItem = -1;
|
|
|
|
clickedItem = -1;
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = pagesize - 1; i >= 0; i--)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
game[i]->Update(t);
|
|
|
|
if (game[i]->GetState() == STATE_SELECTED)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
selectedItem = i;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
if (game[i]->GetState() == STATE_CLICKED)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
clickedItem = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// OnOver-Effect + GameText + Tooltop
|
2010-09-24 02:48:03 +02:00
|
|
|
if (selectedItem_old != selectedItem)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (selectedItem >= 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
game[selectedItem]->SetEffect(EFFECT_SCALE, 1, 130);
|
2010-10-28 11:00:52 +02:00
|
|
|
gamename->SetText(GameTitles.GetTitle(gameList[gameIndex[selectedItem]]));
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else gamename->SetText((char*) NULL);
|
|
|
|
if (selectedItem_old >= 0) game[selectedItem_old]->SetEffect(EFFECT_SCALE, -1, 100);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
// navigation
|
2010-09-24 02:48:03 +02:00
|
|
|
if (focus && gameList.size() > 6)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
int newspeed = 0;
|
|
|
|
// Left/Right Navigation
|
2010-09-24 02:48:03 +02:00
|
|
|
if (btnLeft->GetState() == STATE_CLICKED)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
WPAD_ScanPads();
|
|
|
|
u16 buttons = 0;
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
buttons |= WPAD_ButtonsHeld(i);
|
|
|
|
if (!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_MINUS) || t->Left()))
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
btnLeft->ResetState();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-27 16:45:27 +02:00
|
|
|
if (Settings.xflip == XFLIP_SYSMENU || Settings.xflip == XFLIP_YES || Settings.xflip == XFLIP_DISK3D)
|
2010-09-24 02:48:03 +02:00
|
|
|
newspeed = SHIFT_SPEED;
|
|
|
|
else newspeed = -SHIFT_SPEED;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (btnRight->GetState() == STATE_CLICKED)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
WPAD_ScanPads();
|
|
|
|
u16 buttons = 0;
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
buttons |= WPAD_ButtonsHeld(i);
|
|
|
|
if (!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_PLUS) || t->Right()))
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
btnRight->ResetState();
|
|
|
|
return;
|
|
|
|
}
|
2010-10-27 16:45:27 +02:00
|
|
|
if (Settings.xflip == XFLIP_SYSMENU || Settings.xflip == XFLIP_YES || Settings.xflip == XFLIP_DISK3D)
|
2010-09-24 02:48:03 +02:00
|
|
|
newspeed = -SHIFT_SPEED;
|
|
|
|
else newspeed = SHIFT_SPEED;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
if (newspeed)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (speed == 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
speed = newspeed;
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (speed > 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((speed += SPEED_STEP) > SPEED_LIMIT) speed = SPEED_LIMIT;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((speed -= SPEED_STEP) < -SPEED_LIMIT) speed = -SPEED_LIMIT;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else speed = 0;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (speed > 0) // rotate right
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
GuiButton *tmpButton;
|
2010-09-24 02:48:03 +02:00
|
|
|
listOffset = OFFSETLIMIT(listOffset - 1, gameList.size()); // set the new listOffset
|
2010-09-19 01:16:05 +02:00
|
|
|
// Save right Button + TollTip and destroy right Image + Image-Data
|
2010-09-24 02:48:03 +02:00
|
|
|
delete coverImg[pagesize - 1];
|
|
|
|
coverImg[pagesize - 1] = NULL;
|
|
|
|
game[pagesize - 1]->SetImage(NULL);
|
|
|
|
tmpButton = game[pagesize - 1];
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
// Move all Page-Entries one step right
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = pagesize - 1; i >= 1; i--)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
coverImg[i] = coverImg[i - 1];
|
|
|
|
game[i] = game[i - 1];
|
|
|
|
gameIndex[i] = gameIndex[i - 1];
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
// set saved Button & gameIndex to right
|
2010-09-24 02:48:03 +02:00
|
|
|
gameIndex[0] = listOffset;
|
|
|
|
coverImg[0] = new GuiImageAsync(GameCarouselLoadCoverImage, gameList[gameIndex[0]], sizeof(struct discHdr),
|
|
|
|
&noCover);
|
|
|
|
coverImg[0] ->SetWidescreen(Settings.widescreen);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
game[0] = tmpButton;
|
|
|
|
game[0] ->SetImage(coverImg[0]);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
game[i]->StopEffect();
|
|
|
|
game[i]->ResetState();
|
2010-09-24 02:48:03 +02:00
|
|
|
game[i]->SetEffect(EFFECT_GOROUND, speed, DEG_OFFSET, RADIUS, 270 - (pagesize - 2 * i + 1) * DEG_OFFSET
|
|
|
|
/ 2, 1, 0, RADIUS);
|
2010-09-19 01:16:05 +02:00
|
|
|
game[i]->UpdateEffects(); // rotate one step for liquid scrolling
|
|
|
|
}
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (speed < 0) // rotate left
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
GuiButton *tmpButton;
|
2010-09-24 02:48:03 +02:00
|
|
|
listOffset = OFFSETLIMIT(listOffset + 1, gameList.size()); // set the new listOffset
|
2010-09-19 01:16:05 +02:00
|
|
|
// Save left Button + TollTip and destroy left Image + Image-Data
|
2010-09-24 02:48:03 +02:00
|
|
|
delete coverImg[0];
|
|
|
|
coverImg[0] = NULL;
|
|
|
|
game[0]->SetImage(NULL);
|
|
|
|
tmpButton = game[0];
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
// Move all Page-Entries one step left
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < (pagesize - 1); i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
coverImg[i] = coverImg[i + 1];
|
|
|
|
game[i] = game[i + 1];
|
|
|
|
gameIndex[i] = gameIndex[i + 1];
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
// set saved Button & gameIndex to right
|
|
|
|
int ii = pagesize - 1;
|
2010-09-24 02:48:03 +02:00
|
|
|
gameIndex[ii] = OFFSETLIMIT(listOffset + ii, gameList.size());
|
|
|
|
coverImg[ii] = new GuiImageAsync(GameCarouselLoadCoverImage, gameList[gameIndex[ii]],
|
|
|
|
sizeof(struct discHdr), &noCover);
|
|
|
|
coverImg[ii] ->SetWidescreen(Settings.widescreen);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
game[ii] = tmpButton;
|
|
|
|
game[ii] ->SetImage(coverImg[ii]);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < pagesize; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
game[i]->StopEffect();
|
|
|
|
game[i]->ResetState();
|
2010-09-24 02:48:03 +02:00
|
|
|
game[i]->SetEffect(EFFECT_GOROUND, speed, DEG_OFFSET, RADIUS, 270 - (pagesize - 2 * i - 3) * DEG_OFFSET
|
|
|
|
/ 2, 1, 0, RADIUS);
|
2010-09-19 01:16:05 +02:00
|
|
|
game[i]->UpdateEffects(); // rotate one step for liquid scrolling
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
if (updateCB) updateCB(this);
|
2009-05-27 10:51:39 +02:00
|
|
|
}
|
|
|
|
|