mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-26 05:04:16 +01:00
070b77548a
Changelog since last revision: - add banner/icon animation support for wii games / channels / gamecube - add custom banner for gamecube which loads the gamecube internal opening.bnr information (it is much better than the generic one of the system menu) (big thanks to diddy from the wiithemeteam for creating the brlyt/brlan for the banner) - add gamecube banner of system menu (not used right now since it sucks) - add banner grid of the system menu (resources loaded from nand) (with button highliter) - add big banner frame window of the system menu (resources loaded from nand). the banner window has buttons "Settings" and "Start" by default. if parental control is enabled the "Settings" button is replaced by "Back" - add play count text to the banner frame window (can be disabled as up until now in the gui settings) - add zoom in/out/scroll animations to banner grid and change into big frame window - add loading gc banners from ISO and DVD - add loading wii banners from DVD discs even if the game is not installed - add favorite level setting to the game settings since it is no longer on the banner frame window - add new settings section for banner settings - add option to choose between disc window and banner window - added back ehci module to support 2 usb drives and re-enabled the option - add option for 2 usb drives for d2x cIOS as well (will be supported in the future, not yet) - exchanged "GC Games" and "EmuNand Channels" on the game selection screen (more space for translators) - add and fixed gui numpad for entering numbers of any kind - add setting for tooltip delay time - fix reload of cover image on game list when only 1 item is left after a change (e.g. sort) - add use of old build in font for credits window because it doesnt look good with the system menu one - fixed effect bug when scrolling buttons in the settings and the wiimote is over button 1 - fixed bug where entering -1 (Use global) for cIOS was not possible in game settings - many source cleanups - add bnr chace setting - add DML configuration from the loader - removed creation of temporary "boot.bin" file - DML custom game paths. Additionally i added support for following forms of paths: 1. configpath/gamepath/game.iso 2. configpath/gamepath/game.gcm 3. configpath/gamepath/GAMEID6.iso 4. configpath/gamepath/GAMEID6.gcm Where gamepath can be anything you want inside the configure path in the custom path settings. I don't know if GCM files are allowed by DML but i just added support for it just in case. Changing path to USB is not blocked currently but games won't run from USB just keep that in mind. The "copy to SD before start" feature is not added yet. Listing the games should work though - DML cheats now work the same way as for wii, gct goes to "Cheatcode Path" as GAMEID.gct (same as on wii) - several DML internal configs are added as per game/global settings - added load of last cheat configuration from GCT files - added init of network into background thread so it is cancelable and has a timeout - added gc games copy from USB to SD on demand with choice menu to delete SD games to make space, SD games path can be chosen seperately from main gc path. all dupicate sd games are prefered then the main path to allow direct boot of games that are already on sd. main path can be on USB or anywhere else. - added gc disc dump functionality with multidisc, compress and align support (thanks to FIX94 and Overjoy for their disc dump source on which this is based) - added selection menu for gc multidisc which game to install - fixed loading game ID when it can't be read from path for GC games and with that loading the titles from GameTDB for them - lots of string handling improvements (thanks to gerbilsoft for his patch) - added gamecube banner cache loading (only loading) if available with GAMEID6.bnr or ID3.bnr in the banner cache path. wii games/channels also accept now ID3.bnr. - added several progress bar cancel buttons on some missing progress windows - improved calculation of progress speed. now it is always the last 15 secs average instead of overall progress speed. - added pulsing new icon on banner grid layout for new games - added resize of widescreen screenshots to 768 width - added mii extract on save game extract if the file does not yet exists - added mii extractor and SYSCONF extractor that always extracts and overwrites old files - changed wifi gecko to UDP socket - support for DML v1.2+ NOTE: Banner animation support requires AHBPROT flag to be enabled. If you use old HBC you should use our forwarder or update the HBC otherwise you wont have that support. I am hoping that now the themers and the translators can catch up with their stuff for the next upcomming official release.
460 lines
12 KiB
C++
460 lines
12 KiB
C++
/****************************************************************************
|
|
* libwiigui
|
|
*
|
|
* gui_gamecarousel.cpp
|
|
*
|
|
* GUI class definitions
|
|
***************************************************************************/
|
|
|
|
#include "gui.h"
|
|
#include "wpad.h"
|
|
#include "menu.h"
|
|
|
|
#include <unistd.h>
|
|
#include "gui_image_async.h"
|
|
#include "gui_gamecarousel.h"
|
|
#include "usbloader/GameList.h"
|
|
#include "settings/GameTitles.h"
|
|
#include "settings/CSettings.h"
|
|
#include "GUI/LoadCoverImage.h"
|
|
#include "themes/CTheme.h"
|
|
#include "utils/tools.h"
|
|
#include "main.h"
|
|
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <sstream>
|
|
|
|
#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
|
|
|
|
static inline int OFFSETLIMIT(int Offset, int gameCnt)
|
|
{
|
|
while (Offset < 0)
|
|
Offset += gameCnt;
|
|
return Offset % gameCnt;
|
|
}
|
|
#define GetGameIndex(pageEntry, listOffset, gameCnt) OFFSETLIMIT(listOffset+pageEntry, gameCnt)
|
|
static GuiImageData *GameCarouselLoadCoverImage(void * Arg)
|
|
{
|
|
return LoadCoverImage((struct discHdr *) Arg, true, false);
|
|
}
|
|
/**
|
|
* Constructor for the GuiGameCarousel class.
|
|
*/
|
|
GuiGameCarousel::GuiGameCarousel(int w, int h, const char *themePath, int offset) :
|
|
noCover(Resources::GetFile("nocover.png"), Resources::GetFileSize("nocover.png"))
|
|
{
|
|
width = w;
|
|
height = h;
|
|
pagesize = (gameList.size() < 11) ? gameList.size() : 11;
|
|
listOffset = (gameList.size() < 11) ? LIMIT(offset, 0, MAX(0, gameList.size()-1)) : LIMIT(offset, 0, MAX(0, gameList.size()-1))-2;
|
|
selectable = true;
|
|
selectedItem = -1;
|
|
clickedItem = -1;
|
|
|
|
speed = 0;
|
|
|
|
trigA = new GuiTrigger;
|
|
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
|
trigL = new GuiTrigger;
|
|
trigL->SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
|
|
trigR = new GuiTrigger;
|
|
trigR->SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
|
|
trigPlus = new GuiTrigger;
|
|
trigPlus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
|
|
trigMinus = new GuiTrigger;
|
|
trigMinus->SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
|
|
|
|
imgLeft = Resources::GetImageData("startgame_arrow_left.png");
|
|
imgRight = Resources::GetImageData("startgame_arrow_right.png");
|
|
|
|
btnLeftImg = new GuiImage(imgLeft);
|
|
if (Settings.wsprompt == ON) btnLeftImg->SetWidescreen(Settings.widescreen);
|
|
btnLeft = new GuiButton(imgLeft->GetWidth(), imgLeft->GetHeight());
|
|
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"));
|
|
btnLeft->SetParent(this);
|
|
btnLeft->SetImage(btnLeftImg);
|
|
btnLeft->SetSoundOver(btnSoundOver);
|
|
btnLeft->SetTrigger(trigA);
|
|
btnLeft->SetTrigger(trigL);
|
|
btnLeft->SetTrigger(trigMinus);
|
|
btnLeft->SetEffectGrow();
|
|
|
|
btnRightImg = new GuiImage(imgRight);
|
|
if (Settings.wsprompt == ON) btnRightImg->SetWidescreen(Settings.widescreen);
|
|
btnRight = new GuiButton(imgRight->GetWidth(), imgRight->GetHeight());
|
|
btnRight->SetParent(this);
|
|
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"));
|
|
btnRight->SetImage(btnRightImg);
|
|
btnRight->SetSoundOver(btnSoundOver);
|
|
btnRight->SetTrigger(trigA);
|
|
btnRight->SetTrigger(trigR);
|
|
btnRight->SetTrigger(trigPlus);
|
|
btnRight->SetEffectGrow();
|
|
|
|
gamename = new GuiText(" ", 18, thColor("r=55 g=190 b=237 a=255 - carousel game name text color"));
|
|
gamename->SetParent(this);
|
|
gamename->SetAlignment(ALIGN_CENTER, ALIGN_TOP);
|
|
gamename->SetPosition(0, 330);
|
|
gamename->SetMaxWidth(280, DOTTED);
|
|
|
|
gameIndex = new int[pagesize];
|
|
game.resize(pagesize);
|
|
coverImg.resize(pagesize);
|
|
|
|
Refresh();
|
|
}
|
|
|
|
/**
|
|
* Destructor for the GuiGameCarousel class.
|
|
*/
|
|
GuiGameCarousel::~GuiGameCarousel()
|
|
{
|
|
delete imgRight;
|
|
delete imgLeft;
|
|
delete btnLeftImg;
|
|
delete btnRightImg;
|
|
delete btnRight;
|
|
delete btnLeft;
|
|
|
|
delete trigA;
|
|
delete trigL;
|
|
delete trigR;
|
|
delete trigPlus;
|
|
delete trigMinus;
|
|
delete gamename;
|
|
|
|
GuiImageAsync::ClearQueue();
|
|
|
|
for (u32 i = 0; i < game.size(); ++i)
|
|
delete coverImg[i];
|
|
for (u32 i = 0; i < game.size(); ++i)
|
|
delete game[i];
|
|
|
|
delete[] gameIndex;
|
|
|
|
}
|
|
|
|
void GuiGameCarousel::setListOffset(int off)
|
|
{
|
|
LOCK( this );
|
|
if(gameList.size() < 11)
|
|
listOffset = MIN(off, gameList.size()-1);
|
|
else
|
|
listOffset = MIN(off, gameList.size()) - 2;
|
|
|
|
Refresh();
|
|
}
|
|
|
|
int GuiGameCarousel::getListOffset() const
|
|
{
|
|
if(gameList.size() < 11)
|
|
return listOffset;
|
|
else
|
|
return (listOffset + 2) % gameList.size();
|
|
}
|
|
|
|
void GuiGameCarousel::SetSelectedOption(int ind)
|
|
{
|
|
LOCK(this);
|
|
selectedItem = LIMIT(ind, 0, MIN(pagesize, MAX(0, gameList.size()-1)));
|
|
}
|
|
|
|
void GuiGameCarousel::Refresh()
|
|
{
|
|
for (int i = 0; i < pagesize; i++)
|
|
{
|
|
//------------------------
|
|
// Index
|
|
//------------------------
|
|
gameIndex[i] = GetGameIndex( i, listOffset, gameList.size() );
|
|
|
|
//------------------------
|
|
// Image
|
|
//------------------------
|
|
delete coverImg[i];
|
|
coverImg[i] = new (std::nothrow) GuiImageAsync(GameCarouselLoadCoverImage, gameList[gameIndex[i]], sizeof(struct discHdr), &noCover);
|
|
if (coverImg[i]) coverImg[i]->SetWidescreen(Settings.widescreen);
|
|
|
|
//------------------------
|
|
// GameButton
|
|
//------------------------
|
|
delete game[i];
|
|
game[i] = new GuiButton(122, 244);
|
|
game[i]->SetParent(this);
|
|
game[i]->SetAlignment(ALIGN_CENTER, 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);
|
|
}
|
|
}
|
|
|
|
void GuiGameCarousel::SetFocus(int f)
|
|
{
|
|
LOCK( this );
|
|
if (!gameList.size()) return;
|
|
|
|
for (int i = 0; i < pagesize; i++)
|
|
game[i]->ResetState();
|
|
|
|
if (f == 1 && selectedItem >= 0) game[selectedItem]->SetState(STATE_SELECTED);
|
|
}
|
|
|
|
void GuiGameCarousel::ResetState()
|
|
{
|
|
LOCK( this );
|
|
if (state != STATE_DISABLED)
|
|
{
|
|
state = STATE_DEFAULT;
|
|
stateChan = -1;
|
|
}
|
|
|
|
for (int i = 0; i < pagesize; i++)
|
|
{
|
|
game[i]->ResetState();
|
|
}
|
|
}
|
|
|
|
int GuiGameCarousel::GetClickedOption()
|
|
{
|
|
LOCK( this );
|
|
int found = -1;
|
|
if (clickedItem >= 0)
|
|
{
|
|
for (int i = pagesize - 1; i >= 0; i--)
|
|
game[i]->ResetState();
|
|
|
|
game[clickedItem]->SetState(STATE_SELECTED);
|
|
found = gameIndex[clickedItem];
|
|
clickedItem = -1;
|
|
}
|
|
return found;
|
|
}
|
|
|
|
int GuiGameCarousel::GetSelectedOption()
|
|
{
|
|
LOCK( this );
|
|
int found = -1;
|
|
for (int i = 0; i < pagesize; i++)
|
|
{
|
|
if (game[i]->GetState() == STATE_SELECTED)
|
|
{
|
|
game[i]->SetState(STATE_SELECTED);
|
|
found = gameIndex[i];
|
|
break;
|
|
}
|
|
}
|
|
return found;
|
|
}
|
|
|
|
/**
|
|
* Draw the button on screen
|
|
*/
|
|
void GuiGameCarousel::Draw()
|
|
{
|
|
LOCK( this );
|
|
if (!this->IsVisible() || !gameList.size()) return;
|
|
|
|
for (int i = 0; i < pagesize; i++)
|
|
game[i]->Draw();
|
|
|
|
gamename->Draw();
|
|
|
|
if (gameList.size() > 6)
|
|
{
|
|
btnRight->Draw();
|
|
btnLeft->Draw();
|
|
}
|
|
|
|
//!Draw tooltip after the Images to have it on top
|
|
if (Settings.tooltips == ON)
|
|
for (int i = 0; i < pagesize; i++)
|
|
game[i]->DrawTooltip();
|
|
|
|
this->UpdateEffects();
|
|
}
|
|
|
|
void GuiGameCarousel::Update(GuiTrigger * t)
|
|
{
|
|
LOCK( this );
|
|
if (state == STATE_DISABLED || !t || !gameList.size() || !pagesize) return;
|
|
|
|
btnRight->Update(t);
|
|
btnLeft->Update(t);
|
|
|
|
if ((game[0]->GetEffect() & EFFECT_GOROUND) || (game[pagesize - 1]->GetEffect() & EFFECT_GOROUND))
|
|
{
|
|
return; // skip when rotate
|
|
}
|
|
|
|
// find selected + clicked
|
|
int selectedItem_old = selectedItem;
|
|
selectedItem = -1;
|
|
clickedItem = -1;
|
|
for (int i = pagesize - 1; i >= 0; i--)
|
|
{
|
|
game[i]->Update(t);
|
|
if (game[i]->GetState() == STATE_SELECTED)
|
|
{
|
|
selectedItem = i;
|
|
}
|
|
if (game[i]->GetState() == STATE_CLICKED)
|
|
{
|
|
clickedItem = i;
|
|
}
|
|
|
|
}
|
|
|
|
/// OnOver-Effect + GameText + Tooltop
|
|
if (selectedItem_old != selectedItem)
|
|
{
|
|
if (selectedItem >= 0)
|
|
{
|
|
game[selectedItem]->SetEffect(EFFECT_SCALE, 1, 130);
|
|
gamename->SetText(GameTitles.GetTitle(gameList[gameIndex[selectedItem]]));
|
|
}
|
|
else gamename->SetText((char*) NULL);
|
|
if (selectedItem_old >= 0) game[selectedItem_old]->SetEffect(EFFECT_SCALE, -1, 100);
|
|
}
|
|
// navigation
|
|
if (gameList.size() > 6)
|
|
{
|
|
|
|
int newspeed = 0;
|
|
// Left/Right Navigation
|
|
if (btnLeft->GetState() == STATE_CLICKED)
|
|
{
|
|
WPAD_ScanPads();
|
|
u16 buttons = 0;
|
|
for (int i = 0; i < 4; i++)
|
|
buttons |= WPAD_ButtonsHeld(i);
|
|
if (!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_MINUS) || t->Left()))
|
|
{
|
|
btnLeft->ResetState();
|
|
return;
|
|
}
|
|
|
|
if (Settings.xflip == XFLIP_SYSMENU || Settings.xflip == XFLIP_YES || Settings.xflip == XFLIP_DISK3D)
|
|
newspeed = SHIFT_SPEED;
|
|
else newspeed = -SHIFT_SPEED;
|
|
}
|
|
else if (btnRight->GetState() == STATE_CLICKED)
|
|
{
|
|
WPAD_ScanPads();
|
|
u16 buttons = 0;
|
|
for (int i = 0; i < 4; i++)
|
|
buttons |= WPAD_ButtonsHeld(i);
|
|
if (!((buttons & WPAD_BUTTON_A) || (buttons & WPAD_BUTTON_PLUS) || t->Right()))
|
|
{
|
|
btnRight->ResetState();
|
|
return;
|
|
}
|
|
if (Settings.xflip == XFLIP_SYSMENU || Settings.xflip == XFLIP_YES || Settings.xflip == XFLIP_DISK3D)
|
|
newspeed = -SHIFT_SPEED;
|
|
else newspeed = SHIFT_SPEED;
|
|
}
|
|
if (newspeed)
|
|
{
|
|
if (speed == 0)
|
|
speed = newspeed;
|
|
else if (speed > 0)
|
|
{
|
|
if ((speed += SPEED_STEP) > SPEED_LIMIT) speed = SPEED_LIMIT;
|
|
}
|
|
else
|
|
{
|
|
if ((speed -= SPEED_STEP) < -SPEED_LIMIT) speed = -SPEED_LIMIT;
|
|
}
|
|
}
|
|
else speed = 0;
|
|
|
|
if (speed > 0) // rotate right
|
|
{
|
|
GuiButton *tmpButton;
|
|
listOffset = OFFSETLIMIT(listOffset - 1, gameList.size()); // set the new listOffset
|
|
// Save right Button + TollTip and destroy right Image + Image-Data
|
|
delete coverImg[pagesize - 1];
|
|
coverImg[pagesize - 1] = NULL;
|
|
game[pagesize - 1]->SetImage(NULL);
|
|
tmpButton = game[pagesize - 1];
|
|
|
|
// Move all Page-Entries one step right
|
|
for (int i = pagesize - 1; i >= 1; i--)
|
|
{
|
|
coverImg[i] = coverImg[i - 1];
|
|
game[i] = game[i - 1];
|
|
gameIndex[i] = gameIndex[i - 1];
|
|
}
|
|
// set saved Button & gameIndex to right
|
|
gameIndex[0] = listOffset;
|
|
coverImg[0] = new GuiImageAsync(GameCarouselLoadCoverImage, gameList[gameIndex[0]], sizeof(struct discHdr),
|
|
&noCover);
|
|
coverImg[0] ->SetWidescreen(Settings.widescreen);
|
|
|
|
game[0] = tmpButton;
|
|
game[0] ->SetImage(coverImg[0]);
|
|
|
|
for (int i = 0; i < pagesize; i++)
|
|
{
|
|
game[i]->StopEffect();
|
|
game[i]->ResetState();
|
|
game[i]->SetEffect(EFFECT_GOROUND, speed, DEG_OFFSET, RADIUS, 270 - (pagesize - 2 * i + 1) * DEG_OFFSET
|
|
/ 2, 1, 0, RADIUS);
|
|
game[i]->UpdateEffects(); // rotate one step for liquid scrolling
|
|
}
|
|
}
|
|
else if (speed < 0) // rotate left
|
|
{
|
|
GuiButton *tmpButton;
|
|
listOffset = OFFSETLIMIT(listOffset + 1, gameList.size()); // set the new listOffset
|
|
// Save left Button + TollTip and destroy left Image + Image-Data
|
|
delete coverImg[0];
|
|
coverImg[0] = NULL;
|
|
game[0]->SetImage(NULL);
|
|
tmpButton = game[0];
|
|
|
|
// Move all Page-Entries one step left
|
|
for (int i = 0; i < (pagesize - 1); i++)
|
|
{
|
|
coverImg[i] = coverImg[i + 1];
|
|
game[i] = game[i + 1];
|
|
gameIndex[i] = gameIndex[i + 1];
|
|
}
|
|
// set saved Button & gameIndex to right
|
|
int ii = pagesize - 1;
|
|
gameIndex[ii] = OFFSETLIMIT(listOffset + ii, gameList.size());
|
|
coverImg[ii] = new GuiImageAsync(GameCarouselLoadCoverImage, gameList[gameIndex[ii]],
|
|
sizeof(struct discHdr), &noCover);
|
|
coverImg[ii] ->SetWidescreen(Settings.widescreen);
|
|
|
|
game[ii] = tmpButton;
|
|
game[ii] ->SetImage(coverImg[ii]);
|
|
|
|
for (int i = 0; i < pagesize; i++)
|
|
{
|
|
game[i]->StopEffect();
|
|
game[i]->ResetState();
|
|
game[i]->SetEffect(EFFECT_GOROUND, speed, DEG_OFFSET, RADIUS, 270 - (pagesize - 2 * i - 3) * DEG_OFFSET
|
|
/ 2, 1, 0, RADIUS);
|
|
game[i]->UpdateEffects(); // rotate one step for liquid scrolling
|
|
}
|
|
}
|
|
|
|
}
|
|
if (updateCB) updateCB(this);
|
|
}
|
|
|