WiiFlow_Lite/source/gui/coverflow.hpp

372 lines
12 KiB
C++
Raw Normal View History

2012-01-21 21:57:41 +01:00
// Coverflow
#ifndef __COVERFLOW_HPP
#define __COVERFLOW_HPP
#include <ogcsys.h>
#include <gccore.h>
#include <string>
#include "wiiuse/wpad.h"
2012-01-21 21:57:41 +01:00
#include "video.hpp"
#include "FreeTypeGX.h"
#include "text.hpp"
#include "config/config.hpp"
#include "loader/disc.h"
#include "loader/utils.h"
#include "music/gui_sound.h"
2012-01-21 21:57:41 +01:00
using namespace std;
2012-01-21 21:57:41 +01:00
enum Sorting
{
SORT_ALPHA,
SORT_PLAYCOUNT,
SORT_LASTPLAYED,
SORT_GAMEID,
2012-01-21 21:57:41 +01:00
SORT_WIFIPLAYERS,
SORT_PLAYERS,
SORT_MAX,
SORT_ESRB,
SORT_CONTROLLERS,
};
class CCoverFlow
{
public:
CCoverFlow(void);
~CCoverFlow(void);
//
bool init(const u8 *font, const u32 font_size, bool vid_50hz);
2012-01-21 21:57:41 +01:00
// Cover list management
void clear(void);
void shutdown(void);
2012-01-21 21:57:41 +01:00
void reserve(u32 capacity);
void addItem(dir_discHdr *hdr, int playcount = 0, unsigned int lastPlayed = 0);
2012-01-21 21:57:41 +01:00
bool empty(void) const { return m_items.empty(); }
u32 size(void) const { return m_items.size(); }
2012-01-21 21:57:41 +01:00
//
bool start(const string &m_imgsDir);
2012-01-21 21:57:41 +01:00
void stopCoverLoader(bool empty = false);
void startCoverLoader(void);
void defaultLoad(void);
2012-01-21 21:57:41 +01:00
//
void simulateOtherScreenFormat(bool s);
// Commands
void tick(void);
void setSelected(int i);
bool findId(const char *id, bool instant = false, bool path = false);
2012-01-21 21:57:41 +01:00
void pageUp(void);
void pageDown(void);
void nextLetter(wchar_t *c);
void prevLetter(wchar_t *c);
void nextPlayers(bool wifi, wchar_t *c);
void prevPlayers(bool wifi, wchar_t *c);
void nextID(wchar_t *c);
void prevID(wchar_t *c);
void left(void);
void right(void);
void up(void);
void down(void);
bool select(void);
void flip(bool force = false, bool f = true);
void cancel(void);
bool selected(void) const { return m_selected; }
void makeEffectTexture(const TexData * &bg);
2012-01-21 21:57:41 +01:00
void drawText(bool withRectangle = false);
void draw(void);
void drawEffect(void);
void hideCover(void);
void showCover(void);
void mouse(int chan, int x, int y);
bool mouseOver(int x, int y);
2012-01-21 21:57:41 +01:00
// Accessors for settings
void setCompression(bool enable) { m_compressTextures = enable; }
bool getBoxMode(void) const { return m_box;}
void setBufferSize(u32 numCovers);
void setTextures(const string &loadingPic, const string &loadingPicFlat, const string &noCoverPic, const string &noCoverPicFlat);
void setFont(const SFont &font, const CColor &color);
2012-01-21 21:57:41 +01:00
void setRange(u32 rows, u32 columns);
void setBoxMode(bool box);
void setSmallBoxMode(bool smallBox);
void setHQcover(bool HQ);
2012-01-21 21:57:41 +01:00
void setTextureQuality(float lodBias, int aniso, bool edgeLOD);
void setCameraPos(bool selected, const Vector3D &pos, const Vector3D &aim);
void setCameraOsc(bool selected, const Vector3D &speed, const Vector3D &amp);
void setCoverScale(bool selected, const Vector3D &left, const Vector3D &right, const Vector3D &center, const Vector3D &rowCenter);
void setCoverPos(bool selected, const Vector3D &left, const Vector3D &right, const Vector3D &center, const Vector3D &rowCenter);
void setCoverAngleOsc(bool selected, const Vector3D &speed, const Vector3D &amp);
void setCoverPosOsc(bool selected, const Vector3D &speed, const Vector3D &amp);
void setSpacers(bool selected, const Vector3D &left, const Vector3D &right);
void setDeltaAngles(bool selected, const Vector3D &left, const Vector3D &right);
void setAngles(bool selected, const Vector3D &left, const Vector3D &right, const Vector3D &center, const Vector3D &rowCenter);
void setTitleAngles(bool selected, float left, float right, float center);
void setTitlePos(bool selected, const Vector3D &left, const Vector3D &right, const Vector3D &center);
void setTitleWidth(bool selected, float side, float center);
void setTitleStyle(bool selected, u16 side, u16 center);
void setColors(bool selected, const CColor &begColor, const CColor &endColor, const CColor &offColor);
void setShadowColors(bool selected, const CColor &centerColor, const CColor &begColor, const CColor &endColor, const CColor &offColor);
void setShadowPos(float scale, float x, float y);
void setMirrorAlpha(float cover, float title);
void setMirrorBlur(bool blur);
void setRowSpacers(bool selected, const Vector3D &top, const Vector3D &bottom);
void setRowDeltaAngles(bool selected, const Vector3D &top, const Vector3D &bottom);
void setRowAngles(bool selected, const Vector3D &top, const Vector3D &bottom);
void setCoverFlipping(const Vector3D &pos, const Vector3D &angle, const Vector3D &scale);
void setCoverFlipPos(const Vector3D &pos);
2012-01-21 21:57:41 +01:00
void setBlur(u32 blurResolution, u32 blurRadius, float blurFactor);
void setSorting(Sorting sorting);
2012-01-21 21:57:41 +01:00
//
void setSounds(GuiSound *flipSound, GuiSound *hoverSound, GuiSound *selectSound, GuiSound *cancelSound);
2012-01-21 21:57:41 +01:00
void setSoundVolume(u8 vol);
void stopSound(void);
//
void applySettings(void);
void setCachePath(const char *path, bool deleteSource, bool compress, bool pluginCacheFolders);
bool fullCoverCached(const char *wfcPath);
2012-01-21 21:57:41 +01:00
bool preCacheCover(const char *id, const u8 *png, bool full);
bool cacheCover(const char *wfcPath, const char *coverPath, bool full);
2012-01-21 21:57:41 +01:00
//
const char *getId(void) const;
const char *getNextId(void) const;
const dir_discHdr * getHdr(void) const;
const dir_discHdr * getNextHdr(void) const;
const dir_discHdr * getSpecificHdr(u32) const;
2012-01-21 21:57:41 +01:00
wstringEx getTitle(void) const;
u64 getChanTitle(void) const;
const char *getFilenameId(const dir_discHdr *curHdr, bool extension = true);
//
bool getRenderTex(void);
void setRenderTex(bool);
void RenderTex(void);
//
static u32 InternalCoverColor(const char *ID, u32 DefCaseColor);
static bool checkCoverColor(const char *ID, const char *checkID[], u32 len);
2012-01-21 21:57:41 +01:00
private:
enum DrawMode { CFDR_NORMAL, CFDR_STENCIL, CFDR_SHADOW };
struct SLayout
{
Vector3D camera;
Vector3D cameraAim;
Vector3D leftScale;
Vector3D rightScale;
Vector3D centerScale;
Vector3D rowCenterScale;
Vector3D leftPos;
Vector3D rightPos;
Vector3D centerPos;
Vector3D rowCenterPos;
Vector3D leftAngle;
Vector3D rightAngle;
Vector3D centerAngle;
Vector3D rowCenterAngle;
Vector3D leftSpacer;
Vector3D rightSpacer;
Vector3D leftDeltaAngle;
Vector3D rightDeltaAngle;
float txtLeftAngle;
float txtRightAngle;
float txtCenterAngle;
Vector3D txtLeftPos;
Vector3D txtRightPos;
Vector3D txtCenterPos;
float txtSideWidth;
float txtCenterWidth;
u16 txtSideStyle;
u16 txtCenterStyle;
Vector3D cameraOscSpeed;
Vector3D cameraOscAmp;
Vector3D coverOscASpeed;
Vector3D coverOscAAmp;
Vector3D coverOscPSpeed;
Vector3D coverOscPAmp;
CColor begColor;
CColor endColor;
CColor mouseOffColor;
CColor shadowColorCenter;
CColor shadowColorEnd;
CColor shadowColorBeg;
CColor shadowColorOff;
Vector3D topSpacer;
Vector3D bottomSpacer;
Vector3D topAngle;
Vector3D bottomAngle;
Vector3D topDeltaAngle;
Vector3D bottomDeltaAngle;
};
enum TexState { STATE_Loading, STATE_Ready, STATE_NoCover };
struct CItem//should be SItem because it's a struct
2012-01-21 21:57:41 +01:00
{
CItem(dir_discHdr *itemHdr, int playcount, unsigned int lastPlayed);
2012-01-21 21:57:41 +01:00
dir_discHdr *hdr;
int playcount;
unsigned int lastPlayed;
TexData texture;
2012-01-21 21:57:41 +01:00
volatile bool boxTexture;
volatile enum TexState state;
} ATTRIBUTE_PACKED;
struct CCover// should be SCover because it's a struct
2012-01-21 21:57:41 +01:00
{
u32 index;// index is the number of the item in CItem list
2012-01-21 21:57:41 +01:00
Vector3D scale;
Vector3D targetScale;
Vector3D angle;
Vector3D targetAngle;
Vector3D pos;
Vector3D targetPos;
CColor color;
CColor targetColor;
float txtAngle;
float txtTargetAngle;
Vector3D txtPos;
Vector3D txtTargetPos;
-updating wiiflow lite to beta 4.3.0 -fixed using categories to hide GC disc 2's. Apparently this has never really worked right for some time or ever. -fixed deleting the cached cover texture file for plugin games. Delete cover for plugins only deletes the cached texture file (.wfc) -fixed favorites and adultonly (parental lock) for plugin games. Apparently I may have broke this a few revisions back. -favorites and adultonly for plugin games now have their own domains in gamecfg1- [FAVORITES_PLUGINS] and [ADULTONLY_PLUGINS]. just makes it more organized. -only wii, GC, channels are added to [PLAYCOUNT] and [LAST_PLAYED] in gamecfg1. -now loading gamecfg1 at startup and leaving it loaded till exit. no more loading it and unloading all the time. -fixed scrolling for game_info synopsis, credits, and help text. -made source menu buttons wider for wiiflow default. old 80x80, now 100x80. looks better. -display music info now defaults to off -screensaver_disabled now defaults to yes -show GC view button is now on by default no matter what. the only way it is disabled is if you edit wiiflow.ini manually. this is how all the view buttons work. -removed hiding homebrew button but if wiiflow locked it won't work or in sourceflow it won't show. -dump_list is now under [GENERAL] instead of each view. Also only works for Wii, GC, and channels. -sorting only works for Wii, GC, and Channels now. disabled for sourceflow, plugins, homebrew, and combined view. -now if no games are found a message is shown with the current path so you can see where wiiflow is looking. (except for plugins) -removed auto create emuNAND for emuNAND view if gamelist is empty. just go to settings>NAND settings if you want to extract or disable it. -now when no games are found all buttons at bottom are still accessible allowing you to change the view or go to settings and change current partition or path and even extract your NAND to create a EmuNAND. Or go to Home Menu and Install a Wii or GC game. -removed auto extract NAND to emuNAND when launching a Wii game with EmuNAND save. Now a message is diplayed saying 'emuNAND for saves not found - using real NAND'. -made the speed at which cover titles fade in/out almost instantly. -removed update button from Home Menu. online update code is still there but not used and probably won't be used any more as there just isn't a need for it now. -removed ftp button from Home Menu and all code for the FTP server. I just use WiiXplorer's FTP server. it seems to work better for me. -disabled keep USB Alive thread for now. i think there's a possibilty it might be the cause of my SD/USB files getting corrupted. -removed Btn B and - combo to switch partitions. didn't seem useful anymore. -redid nand emulation settings menu. looks like this now: pg1 Select EmuNAND EmuNAND Enulation Select SaveNAND SaveNAND Emulation pg2 Extract Saves All Missing Extract NAND Select Saves Partition -no longer blocking Select Plugin menu and View icons when using source menu combined view -now Select Plugins Menu is like switching to plugin view but you get to choose the plugins first -now [PLUGIN] partition= is the default partition for all plugins. to change individual plugins add 'romPartition=x' to the plugin ini. x is the partition number 0 thru 8 with SD being 0. this is how my usbloadergx plugin mod works.
2016-10-05 01:44:13 +02:00
u8 txtColor;// actually is title alpha (color.a)
u8 txtTargetColor;// title alpha (255 = full show, 0 = no show)
2012-01-21 21:57:41 +01:00
CText title;
CColor shadowColor;
CColor targetShadowColor;
//
CCover(void);
};
enum CLRet { CL_OK, CL_ERROR, CL_NOMEM };
private:
Mtx m_projMtx;
Mtx m_viewMtx;
Vector3D m_cameraPos;
Vector3D m_cameraAim;
Vector3D m_targetCameraPos;
Vector3D m_targetCameraAim;
vector<CItem> m_items;
CCover *m_covers;
2012-01-21 21:57:41 +01:00
int m_delay;
int m_minDelay;
int m_jump;
mutex_t m_mutex;
volatile bool m_loadingCovers;
volatile bool m_coverThrdBusy;
2012-01-21 21:57:41 +01:00
volatile bool m_moved;
//
volatile bool m_renderTex;
TexData *m_renderingTex;
//
2012-01-21 21:57:41 +01:00
bool m_selected;
int m_tickCount;
TexData *m_loadingTexture;
TexData *m_noCoverTexture;
TexData m_flatLoadingTexture;
TexData m_flatNoCoverTexture;
TexData m_boxLoadingTexture;
TexData m_boxNoCoverTexture;
TexData m_dvdSkin;
TexData m_dvdSkin_Red;
TexData m_dvdSkin_Black;
TexData m_dvdSkin_Yellow;
TexData m_dvdSkin_GreenOne;
TexData m_dvdSkin_GreenTwo;
2012-01-21 21:57:41 +01:00
// Settings
string m_pngLoadCover;
string m_pngLoadCoverFlat;
string m_pngNoCover;
string m_pngNoCoverFlat;
2012-01-21 21:57:41 +01:00
u32 m_numBufCovers;
SFont m_font;
CColor m_fontColor;
bool m_box;
bool m_smallBox;
bool m_useHQcover;
bool m_dvdskin_loaded;
bool m_defcovers_loaded;
2012-01-21 21:57:41 +01:00
u32 m_range;
u32 m_rows;
u32 m_columns;
SLayout m_loNormal;
SLayout m_loSelected;
int m_mouse[WPAD_MAX_WIIMOTES];
bool m_hideCover;
bool m_compressTextures;
bool m_compressCache;
string m_cachePath;
2012-01-21 21:57:41 +01:00
bool m_deletePicsAfterCaching;
bool m_pluginCacheFolders;
2012-01-21 21:57:41 +01:00
bool m_mirrorBlur;
float m_mirrorAlpha;
float m_txtMirrorAlpha;
float m_shadowScale;
float m_shadowX;
float m_shadowY;
TexData m_effectTex;
2012-01-21 21:57:41 +01:00
u32 m_blurRadius;
float m_blurFactor;
Vector3D m_flipCoverPos;
Vector3D m_flipCoverAngle;
Vector3D m_flipCoverScale;
u8 sndCopyNum;
GuiSound *m_flipSound;
GuiSound *m_hoverSound;
GuiSound *m_selectSound;
GuiSound *m_cancelSound;
2012-01-21 21:57:41 +01:00
u8 m_soundVolume;
float m_lodBias;
u8 m_aniso;
bool m_edgeLOD;
Sorting m_sorting;
//thread stack
static u8 coverThreadStack[32768];
static const u32 coverThreadStackSize;
2012-01-21 21:57:41 +01:00
private:
void _draw(DrawMode dm = CFDR_NORMAL, bool mirror = false, bool blend = true);
u32 _currentPos(void) const;
void _effectBg(const TexData * &tex);
void _effectBlur(bool vertical);
2012-01-21 21:57:41 +01:00
bool _effectVisible(void);
void _drawMirrorZ(void);
void _drawTitle(int i, bool mirror, bool rectangle);
void _drawCover(int i, bool mirror, CCoverFlow::DrawMode dm);
void _drawCoverFlat(int i, bool mirror, CCoverFlow::DrawMode dm);
void _drawCoverBox(int i, bool mirror, CCoverFlow::DrawMode dm);
void _updateTarget(int i, bool instant = false);
void _updateAllTargets(bool instant = false);
void _loadCover(int i, int item);
void _loadCoverTexture(int i);
void _coverTick(int i);
void _unselect(void);
Vector3D _cameraMoves(void);
Vector3D _coverMovesA(void);
Vector3D _coverMovesP(void);
const TexData *_coverTexture(int i);
2012-01-21 21:57:41 +01:00
void _left(int repeatDelay, u32 step);
void _right(int repeatDelay, u32 step);
void _jump(void);
void _completeJump(void);
void _setJump(int j);
void _loadAllCovers(int i);
static bool _calcTexLQLOD(TexData &tex);
2012-01-21 21:57:41 +01:00
void _dropHQLOD(int i);
bool _loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover);
CLRet _loadCoverTex(u32 i, bool box, bool hq, bool blankBoxCover);
2012-01-21 21:57:41 +01:00
bool _invisibleCover(u32 x, u32 y);
void _instantTarget(int i);
void _transposeCover(CCover* &dst, u32 rows, u32 columns, int pos);
void _stopSound(GuiSound * &snd);
void _playSound(GuiSound * &snd);
2012-01-21 21:57:41 +01:00
static bool _sortByPlayCount(CItem item1, CItem item2);
static bool _sortByLastPlayed(CItem item1, CItem item2);
static bool _sortByGameID(CItem item1, CItem item2);
static bool _sortByAlpha(CItem item1, CItem item2);
static bool _sortByPlayers(CItem item1, CItem item2);
static bool _sortByWifiPlayers(CItem item1, CItem item2);
private:
static void * _coverLoader(void *obj);
2012-01-21 21:57:41 +01:00
static float _step(float cur, float tgt, float spd);
private:
CCoverFlow(const CCoverFlow &);
CCoverFlow &operator=(const CCoverFlow &);
};
extern CCoverFlow CoverFlow;
2012-01-21 21:57:41 +01:00
#endif // !defined(__COVERFLOW_HPP)