WiiFlow_Lite/source/gui/coverflow.cpp

2990 lines
91 KiB
C++
Raw Normal View History

2012-01-21 21:57:41 +01:00
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <algorithm>
#include <new>
#include <zlib.h>
#include <cwctype>
#include <sys/stat.h>
2012-01-21 21:57:41 +01:00
#include "coverflow.hpp"
#include "pngu.h"
#include "boxmesh.hpp"
#include "lockMutex.hpp"
#include "fonts.h"
#include "types.h"
#include "gui/fmt.h"
#include "gecko/gecko.hpp"
#include "menu/menu.hpp"
#include "plugin/plugin.hpp"
#include "memory/mem2.hpp"
#include "fileOps/fileOps.h"
#include "wstringEx/wstringEx.hpp"
2012-01-21 21:57:41 +01:00
static const int black_len = 16;
static const char* black[black_len] = {"RZZJEL","RZNJ01","SEKJ99","SX3J01","SX3P01","R5WJA4","RUYJ99","S3HJ08","SJBJ01","CKBE88","CCPE01","SMMP01","MDUE01","SL2J01","APR","AFR"};
static const int red_len = 2;
static const char* red[red_len] = {"SMN","HBW"};
static const int yellow_len = 2;
static const char* yellow[yellow_len] = {"SIIE8P","SIIP8P"};
static const int greenOne_len = 1;
static const char* greenOne[greenOne_len] = {"SF8J01"};
static const int greenTwo_len = 1;
static const char* greenTwo[greenTwo_len] = {"PDUE01"};
2012-01-21 21:57:41 +01:00
static lwp_t coverLoaderThread = LWP_THREAD_NULL;
static inline int loopNum(int i, int s)
{
return i < 0 ? (s - (-i % s)) % s : i % s;
}
CCoverFlow CoverFlow;
u8 CCoverFlow::coverThreadStack[32768] ATTRIBUTE_ALIGN(32);
const u32 CCoverFlow::coverThreadStackSize = 32768;
CCoverFlow::CCover::CCover(void)
2012-01-21 21:57:41 +01:00
{
index = 0;
txtAngle = 0.f;
txtTargetAngle = 0.f;
txtColor = 0;
txtTargetColor = 0;
color = 0x00FFFFFF;
targetColor = 0xFFFFFFFF;
shadowColor = 0x00000000;
targetShadowColor = 0x00000000;
scale = Vector3D(1.f, 1.f, 1.f);
targetScale = Vector3D(1.f, 1.f, 1.f);
}
CCoverFlow::CItem::CItem(dir_discHdr *itemHdr, int playcount, unsigned int lastPlayed) :
2012-01-21 21:57:41 +01:00
hdr(itemHdr),
playcount(playcount),
lastPlayed(lastPlayed),
boxTexture(false),
state(STATE_Loading)
2012-01-21 21:57:41 +01:00
{
2012-01-21 21:57:41 +01:00
}
static inline wchar_t upperCaseWChar(wchar_t c)
{
return c >= L'a' && c <= L'z' ? c & 0x00DF : c;
}
float m_normal_speed;
float m_selected_speed;
2012-01-21 21:57:41 +01:00
CCoverFlow::CCoverFlow(void)
{
m_loNormal.camera = Vector3D(0.f, 1.5f, 5.f);
m_loNormal.cameraAim = Vector3D(0.f, 0.f, -1.f);
m_loNormal.leftScale = Vector3D(1.f, 1.f, 1.f);
m_loNormal.rightScale = Vector3D(1.f, 1.f, 1.f);
m_loNormal.centerScale = Vector3D(1.f, 1.f, 1.f);
m_loNormal.rowCenterScale = Vector3D(1.f, 1.f, 1.f);
m_loNormal.leftPos = Vector3D(-1.6f, 0.f, 0.f);
m_loNormal.rightPos = Vector3D(1.6f, 0.f, 0.f);
m_loNormal.centerPos = Vector3D(0.f, 0.f, 1.f);
m_loNormal.rowCenterPos = Vector3D(0.f, 0.f, 0.f);
m_loNormal.leftAngle = Vector3D(0.f, 70.f, 0.f);
m_loNormal.rightAngle = Vector3D(0.f, -70.f, 0.f);
m_loNormal.centerAngle = Vector3D(0.f, 0.f, 0.f);
m_loNormal.rowCenterAngle = Vector3D(0.f, 0.f, 0.f);
m_loNormal.leftSpacer = Vector3D(-0.35f, 0.f, 0.f);
m_loNormal.rightSpacer = Vector3D(0.35f, 0.f, 0.f);
m_loNormal.leftDeltaAngle = Vector3D(0.f, 0.f, 0.f);
m_loNormal.rightDeltaAngle = Vector3D(0.f, 0.f, 0.f);
m_loNormal.txtLeftAngle = -55.f;
m_loNormal.txtRightAngle = 55.f;
m_loNormal.txtCenterAngle = 0.f;
m_loNormal.txtLeftPos = Vector3D(-4.f, 0.f, 1.3f);
m_loNormal.txtRightPos = Vector3D(4.f, 0.f, 1.3f);
m_loNormal.txtCenterPos = Vector3D(0.f, 0.f, 2.6f);
m_loNormal.txtSideWidth = 500.f;
m_loNormal.txtCenterWidth = 500.f;
m_loNormal.txtSideStyle = FTGX_ALIGN_BOTTOM | FTGX_JUSTIFY_CENTER;
m_loNormal.txtCenterStyle = FTGX_ALIGN_BOTTOM | FTGX_JUSTIFY_CENTER;
m_loNormal.endColor = CColor(0x3FFFFFFF);
m_loNormal.begColor = CColor(0xCFFFFFFF);
m_loNormal.mouseOffColor = CColor(0xFF00FF00);
m_loNormal.shadowColorCenter = CColor(0x00000000);
m_loNormal.shadowColorEnd = CColor(0x00000000);
m_loNormal.shadowColorBeg = CColor(0x00000000);
m_loNormal.shadowColorOff = CColor(0x00000000);
m_loNormal.topSpacer = Vector3D(0.f, 2.f, 0.f);
m_loNormal.bottomSpacer = Vector3D(0.f, -2.f, 0.f);
m_loNormal.topDeltaAngle = Vector3D(0.f, 0.f, 0.f);
m_loNormal.bottomDeltaAngle = Vector3D(0.f, 0.f, 0.f);
m_loNormal.topAngle = Vector3D(0.f, 0.f, 0.f);
m_loNormal.bottomAngle = Vector3D(0.f, 0.f, 0.f);
//
m_loSelected.camera = Vector3D(0.f, 1.5f, 5.f);
m_loSelected.cameraAim = Vector3D(0.f, 0.f, -1.f);
m_loSelected.leftScale = Vector3D(1.f, 1.f, 1.f);
m_loSelected.rightScale = Vector3D(1.f, 1.f, 1.f);
m_loSelected.centerScale = Vector3D(1.f, 1.f, 1.f);
m_loSelected.rowCenterScale = Vector3D(1.f, 1.f, 1.f);
m_loSelected.leftPos = Vector3D(-4.6f, 2.f, 0.f);
m_loSelected.rightPos = Vector3D(4.6f, 2.f, 0.f);
m_loSelected.centerPos = Vector3D(-0.6f, 0.f, 2.6f);
m_loSelected.rowCenterPos = Vector3D(0.f, 0.f, 0.f);
m_loSelected.leftAngle = Vector3D(-45.f, 90.f, 0.f);
m_loSelected.rightAngle = Vector3D(-45.f, -90.f, 0.f);
m_loSelected.centerAngle = Vector3D(0.f, 380.f, 0.f);
m_loSelected.rowCenterAngle = Vector3D(0.f, 0.f, 0.f);
m_loSelected.leftSpacer = Vector3D(-0.35f, 0.f, 0.f);
m_loSelected.rightSpacer = Vector3D(0.35f, 0.f, 0.f);
m_loSelected.leftDeltaAngle = Vector3D(0.f, 0.f, 0.f);
m_loSelected.rightDeltaAngle = Vector3D(0.f, 0.f, 0.f);
m_loSelected.txtLeftAngle = -55.f;
m_loSelected.txtRightAngle = 55.f;
m_loSelected.txtCenterAngle = 0.f;
m_loSelected.txtLeftPos = Vector3D(-4.35f, 0.f, 1.3f);
m_loSelected.txtRightPos = Vector3D(4.35f, 0.f, 1.3f);
m_loSelected.txtCenterPos = Vector3D(2.3f, 1.8f, 1.f);
m_loSelected.txtSideWidth = 500.f;
m_loSelected.txtCenterWidth = 310.f;
m_loSelected.txtSideStyle = FTGX_ALIGN_BOTTOM | FTGX_JUSTIFY_CENTER;
m_loSelected.txtCenterStyle = FTGX_ALIGN_TOP | FTGX_JUSTIFY_RIGHT;
m_loSelected.endColor = CColor(0x3FFFFFFF);
m_loSelected.begColor = CColor(0xCFFFFFFF);
m_loSelected.mouseOffColor = CColor(0xFF00FF00);
m_loSelected.shadowColorCenter = CColor(0x00000000);
m_loSelected.shadowColorEnd = CColor(0x00000000);
m_loSelected.shadowColorBeg = CColor(0x00000000);
m_loSelected.shadowColorOff = CColor(0x00000000);
m_loSelected.topSpacer = Vector3D(0.f, 2.f, 0.f);
m_loSelected.bottomSpacer = Vector3D(0.f, -2.f, 0.f);
m_loSelected.topDeltaAngle = Vector3D(0.f, 0.f, 0.f);
m_loSelected.bottomDeltaAngle = Vector3D(0.f, 0.f, 0.f);
m_loSelected.topAngle = Vector3D(0.f, 0.f, 0.f);
m_loSelected.bottomAngle = Vector3D(0.f, 0.f, 0.f);
//
m_mirrorAlpha = 0.2f;
m_txtMirrorAlpha = 0.2f;
m_delay = 0;
m_minDelay = 5;
m_jump = 0;
m_mutex = 0;
m_dvdskin_loaded = false;
m_defcovers_loaded = false;
2012-01-21 21:57:41 +01:00
m_loadingCovers = false;
m_coverThrdBusy = false;
m_renderTex = false;
m_renderingTex = NULL;
2012-01-21 21:57:41 +01:00
m_moved = false;
m_selected = false;
m_hideCover = false;
m_tickCount = 0;
m_blurRadius = 3;
m_blurFactor = 1.f;
//
m_mirrorBlur = false;
m_effectTex.width = 96;
m_effectTex.height = 72;
m_effectTex.format = GX_TF_RGBA8;
m_shadowScale = 1.f;
m_shadowX = 0.f;
m_shadowY = 0.f;
m_flipCoverPos = Vector3D(0.f, 0.f, 0.f);
m_flipCoverAngle = Vector3D(0.f, 180.f, 0.f);
m_flipCoverScale = Vector3D(1.f, 1.f, 1.f);
// Settings
m_lodBias = -0.3f;
m_aniso = GX_ANISO_1;
m_edgeLOD = false;
m_numBufCovers = 20;
2012-01-21 21:57:41 +01:00
m_compressTextures = true;
m_compressCache = false;
m_deletePicsAfterCaching = false;
m_pluginCacheFolders = false;
2012-01-21 21:57:41 +01:00
m_box = true;
m_smallBox = false;
m_useHQcover = false;
2012-01-21 21:57:41 +01:00
m_rows = 1;
m_columns = 11;
m_range = m_rows * m_columns;
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
m_mouse[chan] = -1;
sndCopyNum = 0;
m_soundVolume = 0xFF;
m_sorting = SORT_ALPHA;
m_normal_speed = 0.1f;
m_selected_speed = 0.07f;
2012-01-21 21:57:41 +01:00
//
m_flipSound = NULL;
m_hoverSound = NULL;
m_selectSound = NULL;
m_cancelSound = NULL;
//
m_loadingTexture = NULL;
m_noCoverTexture = NULL;
//
m_covers = NULL;
2012-01-21 21:57:41 +01:00
LWP_MutexInit(&m_mutex, 0);
}
bool CCoverFlow::init(const u8 *font, const u32 font_size, bool vid_50hz)
2012-01-21 21:57:41 +01:00
{
// Load font
m_font.fromBuffer(font, font_size, TITLEFONT);
m_fontColor = CColor(0xFFFFFFFF);
if(vid_50hz)
{
gprintf("WiiFlow is in 50hz mode\n");
m_normal_speed = 0.12f;
m_selected_speed = 0.084f;
m_minDelay = 4;
}
2012-01-21 21:57:41 +01:00
if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
guPerspective(m_projMtx, 45, 16.f / 9.f, .1f, 300.f);
else
guPerspective(m_projMtx, 45, 4.f / 3.f, .1f, 300.f);
return true;
}
void CCoverFlow::simulateOtherScreenFormat(bool s)
{
if ((CONF_GetAspectRatio() == CONF_ASPECT_16_9) != s)
guPerspective(m_projMtx, 45, 16.f / 9.f, .1f, 300.f);
else
guPerspective(m_projMtx, 45, 4.f / 3.f, .1f, 300.f);
}
CCoverFlow::~CCoverFlow(void)
{
shutdown();
2012-01-21 21:57:41 +01:00
LWP_MutexDestroy(m_mutex);
}
void CCoverFlow::setCachePath(const char *path, bool pluginCacheFolders)
2012-01-21 21:57:41 +01:00
{
m_cachePath = path;
m_pluginCacheFolders = pluginCacheFolders;
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::setTextureQuality(float lodBias, int aniso, bool edgeLOD)
{
m_lodBias = min(max(-3.f, lodBias), 1.f);
switch (aniso)
{
case 1:
m_aniso = GX_ANISO_2;
break;
case 2:
m_aniso = GX_ANISO_4;
break;
default:
m_aniso = GX_ANISO_1;
}
m_edgeLOD = edgeLOD;
}
void CCoverFlow::setBoxMode(bool box)
{
m_box = box;
}
void CCoverFlow::setSmallBoxMode(bool smallBox)
{
m_smallBox = smallBox;
}
void CCoverFlow::setHQcover(bool HQ)
{
m_useHQcover = HQ;
}
2012-01-21 21:57:41 +01:00
void CCoverFlow::setBufferSize(u32 numCovers)
{
if(m_covers != NULL) return;
m_numBufCovers = min(max(4ul, numCovers / 2ul), 40ul);//8 to 80
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::setTextures(const string &loadingPic, const string &loadingPicFlat, const string &noCoverPic, const string &noCoverPicFlat)
{
if (m_covers != NULL) return;
2012-01-21 21:57:41 +01:00
m_pngLoadCover = loadingPic;
m_pngLoadCoverFlat = loadingPicFlat;
m_pngNoCover = noCoverPic;
m_pngNoCoverFlat = noCoverPicFlat;
}
void CCoverFlow::setFont(const SFont &font, const CColor &color)
2012-01-21 21:57:41 +01:00
{
if(m_font.font != NULL)
delete m_font.font;
m_font = font;
2012-01-21 21:57:41 +01:00
m_fontColor = color;
if (m_covers != NULL)
2012-01-21 21:57:41 +01:00
{
for (u32 i = 0; i < m_range; ++i)
_loadCover(i, m_covers[i].index);
_updateAllTargets();
}
}
void CCoverFlow::_transposeCover(CCover* &dst, u32 rows, u32 columns, int pos)
2012-01-21 21:57:41 +01:00
{
int i = pos - (int)(rows * columns / 2);
int j = rows >= 3 ? abs(i) - ((abs(i) + (int)rows / 2) / (int)rows) * 2 : abs(i);
if (m_rows >= 3)
j += ((j + ((int)m_rows - 2) / 2) / ((int)m_rows - 2)) * 2;
int k = m_range / 2 + (i < 0 ? -j : j);
if ((u32)k < m_range)
dst[pos] = m_covers[k];
}
void CCoverFlow::setRange(u32 rows, u32 columns)
{
rows = rows < 3ul ? 1ul : min(rows | 1ul, 9ul) + 2ul;
columns = min(max(3ul, columns | 1ul), 21ul) + 2ul;
2012-01-21 21:57:41 +01:00
u32 range = rows * columns;
if (rows == m_rows && columns == m_columns && range == m_range)
return;
if (m_covers != NULL)
2012-01-21 21:57:41 +01:00
{
stopCoverLoader();
MEM2_free(m_covers);
CCover *tmpCovers = (CCover*)MEM2_alloc(sizeof(CCover) * range);
for(size_t i = 0; i < range; ++i)
{
// does not allocate memory -- calls: operator new (sizeof(CCover), tmpCovers+i)
// only constructs an object at tmpCovers+i
// delete is not needed
// this is the same as CCover tmpCovers[range] except the objects memory address is specified and won't go out of scope
tmpCovers[i] = *(new (tmpCovers+i) CCover);
}
2012-01-21 21:57:41 +01:00
if (rows >= 3)
for (u32 x = 0; x < columns; ++x)
for (u32 y = 1; y < rows - 1; ++y)
_transposeCover(tmpCovers, rows, columns, x * rows + y);
else
for (u32 x = 0; x < range; ++x)
_transposeCover(tmpCovers, rows, columns, x);
m_rows = rows;
m_columns = columns;
m_range = range;
m_covers = tmpCovers;
2012-01-21 21:57:41 +01:00
_loadAllCovers(m_covers[m_range / 2].index);
_updateAllTargets();
startCoverLoader();
}
else
{
m_rows = rows;
m_columns = columns;
m_range = range;
}
}
void CCoverFlow::setCameraPos(bool selected, const Vector3D &pos, const Vector3D &aim)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.camera = pos;
lo.cameraAim = aim;
}
void CCoverFlow::setCameraOsc(bool selected, const Vector3D &speed, const Vector3D &amp)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.cameraOscSpeed = speed;
lo.cameraOscAmp = amp;
}
void CCoverFlow::setCoverScale(bool selected, const Vector3D &left, const Vector3D &right, const Vector3D &center, const Vector3D &rowCenter)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.leftScale = left;
lo.rightScale = right;
lo.centerScale = center;
lo.rowCenterScale = rowCenter;
}
void CCoverFlow::setCoverPos(bool selected, const Vector3D &left, const Vector3D &right, const Vector3D &center, const Vector3D &rowCenter)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.leftPos = left;
lo.rightPos = right;
lo.centerPos = center;
lo.rowCenterPos = rowCenter;
}
void CCoverFlow::setCoverAngleOsc(bool selected, const Vector3D &speed, const Vector3D &amp)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.coverOscASpeed = speed;
lo.coverOscAAmp = amp;
}
void CCoverFlow::setCoverPosOsc(bool selected, const Vector3D &speed, const Vector3D &amp)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.coverOscPSpeed = speed;
lo.coverOscPAmp = amp;
}
void CCoverFlow::setSpacers(bool selected, const Vector3D &left, const Vector3D &right)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.leftSpacer = left;
lo.rightSpacer = right;
}
void CCoverFlow::setDeltaAngles(bool selected, const Vector3D &left, const Vector3D &right)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.leftDeltaAngle = left;
lo.rightDeltaAngle = right;
}
void CCoverFlow::setAngles(bool selected, const Vector3D &left, const Vector3D &right, const Vector3D &center, const Vector3D &rowCenter)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.leftAngle = left;
lo.rightAngle = right;
lo.centerAngle = center;
lo.rowCenterAngle = rowCenter;
}
void CCoverFlow::setTitleAngles(bool selected, float left, float right, float center)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.txtLeftAngle = left;
lo.txtRightAngle = right;
lo.txtCenterAngle = center;
}
void CCoverFlow::setTitlePos(bool selected, const Vector3D &left, const Vector3D &right, const Vector3D &center)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.txtLeftPos = left;
lo.txtRightPos= right;
lo.txtCenterPos= center;
}
void CCoverFlow::setTitleWidth(bool selected, float side, float center)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.txtSideWidth = side;
lo.txtCenterWidth= center;
}
void CCoverFlow::setTitleStyle(bool selected, u16 side, u16 center)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.txtSideStyle = side;
lo.txtCenterStyle = center;
}
void CCoverFlow::setColors(bool selected, const CColor &begColor, const CColor &endColor, const CColor &offColor)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.begColor = begColor;
lo.endColor = endColor;
lo.mouseOffColor = offColor;
}
void CCoverFlow::setMirrorAlpha(float cover, float title)
{
m_mirrorAlpha = cover;
m_txtMirrorAlpha = title;
}
void CCoverFlow::setMirrorBlur(bool blur)
{
m_mirrorBlur = blur;
}
void CCoverFlow::setShadowColors(bool selected, const CColor &centerColor, const CColor &begColor, const CColor &endColor, const CColor &offColor)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.shadowColorCenter = centerColor;
lo.shadowColorBeg = begColor;
lo.shadowColorEnd = endColor;
lo.shadowColorOff = offColor;
}
void CCoverFlow::setShadowPos(float scale, float x, float y)
{
m_shadowScale = scale;
m_shadowX = x;
m_shadowY = y;
}
void CCoverFlow::setRowSpacers(bool selected, const Vector3D &top, const Vector3D &bottom)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.topSpacer = top;
lo.bottomSpacer = bottom;
}
void CCoverFlow::setRowDeltaAngles(bool selected, const Vector3D &top, const Vector3D &bottom)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.topDeltaAngle = top;
lo.bottomDeltaAngle = bottom;
}
void CCoverFlow::setRowAngles(bool selected, const Vector3D &top, const Vector3D &bottom)
{
SLayout &lo = selected ? m_loSelected : m_loNormal;
lo.topAngle = top;
lo.bottomAngle = bottom;
}
void CCoverFlow::setCoverFlipping(const Vector3D &pos, const Vector3D &angle, const Vector3D &scale)
{
m_flipCoverPos = pos;
m_flipCoverAngle = angle;
m_flipCoverScale = scale;
}
void CCoverFlow::setCoverFlipPos(const Vector3D &pos)
{
if(m_covers == NULL || !m_selected) return;
LockMutex lock(m_mutex);
m_covers[m_range / 2].targetPos = m_loSelected.centerPos + pos;
}
2012-01-21 21:57:41 +01:00
void CCoverFlow::setBlur(u32 blurResolution, u32 blurRadius, float blurFactor)
{
static const struct { u32 x; u32 y; } blurRes[] = {
{ 64, 48 }, { 96, 72 }, { 128, 96 }, { 192, 144 }
};
u32 i = min(max(0ul, blurResolution), sizeof blurRes / sizeof blurRes[0] - 1ul);
2012-01-21 21:57:41 +01:00
m_effectTex.width = blurRes[i].x;
m_effectTex.height = blurRes[i].y;
if(m_effectTex.data != NULL)
{
free(m_effectTex.data);
m_effectTex.data = NULL;
}
m_blurRadius = min(max(1ul, blurRadius), 3ul);
2012-01-21 21:57:41 +01:00
m_blurFactor = min(max(1.f, blurFactor), 2.f);
}
void CCoverFlow::setSorting(Sorting sorting)
2012-01-21 21:57:41 +01:00
{
m_sorting = sorting;
}
void CCoverFlow::setSounds(GuiSound *flipSound, GuiSound *hoverSound, GuiSound *selectSound, GuiSound *cancelSound)
2012-01-21 21:57:41 +01:00
{
//for(u8 i = 0; i < 4; i++)
m_flipSound = flipSound;
2012-01-21 21:57:41 +01:00
m_hoverSound = hoverSound;
m_selectSound = selectSound;
m_cancelSound = cancelSound;
}
void CCoverFlow::setSoundVolume(u8 vol)
{
m_soundVolume = vol;
}
void CCoverFlow::_stopSound(GuiSound * &snd)
2012-01-21 21:57:41 +01:00
{
if(snd == NULL) return;
2012-01-21 21:57:41 +01:00
snd->Stop();
}
void CCoverFlow::_playSound(GuiSound * &snd)
2012-01-21 21:57:41 +01:00
{
if(snd == NULL) return;
2012-01-21 21:57:41 +01:00
snd->Play(m_soundVolume);
}
void CCoverFlow::stopSound(void)
{
//for(u8 i = 0; i < 4; i++)
_stopSound(m_flipSound);
2012-01-21 21:57:41 +01:00
_stopSound(m_hoverSound);
_stopSound(m_selectSound);
_stopSound(m_cancelSound);
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::applySettings(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
LockMutex lock(m_mutex);
_updateAllTargets(true);
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::stopCoverLoader(bool empty)
{
m_loadingCovers = false;
m_moved = true;
if(coverLoaderThread != LWP_THREAD_NULL)
2012-01-21 21:57:41 +01:00
{
if(LWP_ThreadIsSuspended(coverLoaderThread))
LWP_ResumeThread(coverLoaderThread);
while(m_coverThrdBusy)
usleep(50);
2012-01-21 21:57:41 +01:00
LWP_JoinThread(coverLoaderThread, NULL);
coverLoaderThread = LWP_THREAD_NULL;
if(empty)
{
for(u32 i = 0; i < m_items.size(); ++i)
2012-01-21 21:57:41 +01:00
{
TexHandle.Cleanup(m_items[i].texture);
m_items[i].state = STATE_Loading;
2012-01-21 21:57:41 +01:00
}
}
//gprintf("Coverflow stopped!\n");
2012-01-21 21:57:41 +01:00
}
}
void CCoverFlow::startCoverLoader(void)
{
if(m_covers == NULL || coverLoaderThread != LWP_THREAD_NULL || m_loadingCovers)
return;
2012-01-21 21:57:41 +01:00
m_loadingCovers = true;
m_moved = true;
2012-01-21 21:57:41 +01:00
LWP_CreateThread(&coverLoaderThread, _coverLoader, this, coverThreadStack, coverThreadStackSize, 30);
//gprintf("Coverflow started!\n");
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::clear(void)
{
stopCoverLoader(true);
if(m_covers != NULL)
MEM2_free(m_covers);
m_covers = NULL;
2012-01-21 21:57:41 +01:00
m_items.clear();
-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
//vector<CItem>().swap(m_items);
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::shutdown(void)
{
gprintf("Cleanup Coverflow\n");
TexHandle.Cleanup(m_dvdSkin);
TexHandle.Cleanup(m_dvdSkin_Red);
TexHandle.Cleanup(m_dvdSkin_Black);
TexHandle.Cleanup(m_dvdSkin_Yellow);
TexHandle.Cleanup(m_dvdSkin_GreenOne);
TexHandle.Cleanup(m_dvdSkin_GreenTwo);
clear();
if(m_flipSound != NULL)
delete m_flipSound;
m_flipSound = NULL;
if(m_cancelSound != NULL)
delete m_cancelSound;
m_cancelSound = NULL;
LWP_MutexDestroy(m_mutex);
}
2012-01-21 21:57:41 +01:00
void CCoverFlow::reserve(u32 capacity)
{
m_items.reserve(capacity);
}
void CCoverFlow::addItem(dir_discHdr *hdr, int playcount, unsigned int lastPlayed)
2012-01-21 21:57:41 +01:00
{
if (m_covers != NULL) return;
m_items.push_back(CCoverFlow::CItem(hdr, playcount, lastPlayed));
2012-01-21 21:57:41 +01:00
}
// Draws a plane in the Z-Buffer only.
void CCoverFlow::_drawMirrorZ(void)
{
GX_LoadPosMtxImm(m_viewMtx, GX_PNMTX0);
// GX setup
GX_SetNumChans(0);
GX_ClearVtxDesc();
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetNumTexGens(0);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_DISABLE, GX_COLORNULL);
GX_SetAlphaUpdate(GX_FALSE);
GX_SetColorUpdate(GX_FALSE);
GX_SetZMode(GX_ENABLE, GX_LEQUAL, GX_TRUE);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(-10000.f, 0.f, -10000.f);
GX_Position3f32(10000.f, 0.f, -10000.f);
GX_Position3f32(10000.f, 0.f, 10000.f);
GX_Position3f32(-10000.f, 0.f, 10000.f);
GX_End();
GX_SetAlphaUpdate(GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
}
void CCoverFlow::_effectBg(const TexData * &tex)
2012-01-21 21:57:41 +01:00
{
Mtx modelViewMtx;
GXTexObj texObj;
if(tex == NULL || tex->data == NULL)
return;
2012-01-21 21:57:41 +01:00
GX_ClearVtxDesc();
GX_SetNumTevStages(1);
GX_SetNumChans(0);
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_SetNumTexGens(1);
GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_TEXC);
GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);
GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
GX_SetBlendMode(GX_BM_NONE, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetAlphaUpdate(GX_TRUE);
GX_SetCullMode(GX_CULL_NONE);
GX_SetZMode(GX_DISABLE, GX_ALWAYS, GX_FALSE);
guMtxIdentity(modelViewMtx);
GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0);
GX_InitTexObj(&texObj, tex->data, tex->width, tex->height, tex->format, GX_CLAMP, GX_CLAMP, GX_FALSE);
2012-01-21 21:57:41 +01:00
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(0.f, 0.f, 0.f);
GX_TexCoord2f32(0.f, 0.f);
GX_Position3f32(640.f, 0.f, 0.f);
GX_TexCoord2f32(1.f, 0.f);
GX_Position3f32(640.f, 480.f, 0.f);
GX_TexCoord2f32(1.f, 1.f);
GX_Position3f32(0.f, 480.f, 0.f);
GX_TexCoord2f32(0.f, 1.f);
GX_End();
}
void CCoverFlow::_effectBlur(bool vertical)
2012-01-21 21:57:41 +01:00
{
int kSize = m_blurRadius * 2 + 1;
GXTexObj texObj;
Mtx mh1;
Mtx mh2;
Mtx mh3;
Mtx mh4;
Mtx mh5;
Mtx mh6;
Mtx modelViewMtx;
float pixDist = m_blurFactor;
float w = (float)m_effectTex.width;
float h = (float)m_effectTex.height;
float x = 0.f;
float y = 0.f;
CColor kGauss7(0xFF * 20 / 64, 0xFF * 15 / 64, 0xFF * 6 / 64, 0xFF * 1 / 64);
CColor kGauss5(0xFF * 6 / 16, 0xFF * 4 / 16, 0xFF * 1 / 16, 0);
CColor kGauss3(0xFF * 2 / 4, 0xFF * 1 / 4, 0, 0);
CColor kBox(0xFF / kSize, 0xFF / kSize, 0xFF / kSize, 0xFF / kSize);
Mtx44 projMtx;
GX_SetScissor(0, 0, m_effectTex.width, m_effectTex.height);
GX_SetPixelFmt(GX_PF_RGBA6_Z24, GX_ZC_LINEAR);
GX_InvVtxCache();
GX_InvalidateTexAll();
GX_InitTexObj(&texObj, m_effectTex.data, m_effectTex.width, m_effectTex.height, m_effectTex.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
2012-01-21 21:57:41 +01:00
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetNumTevStages(kSize);
GX_SetNumTexGens(kSize);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
guMtxIdentity(mh1);
guMtxIdentity(mh2);
guMtxIdentity(mh3);
guMtxIdentity(mh4);
guMtxIdentity(mh5);
guMtxIdentity(mh6);
if (vertical)
{
guMtxRowCol(mh1, 0, 3) = pixDist * -1.f / w;
guMtxRowCol(mh2, 0, 3) = pixDist * 1.f / w;
guMtxRowCol(mh3, 0, 3) = pixDist * -2.f / w;
guMtxRowCol(mh4, 0, 3) = pixDist * 2.f / w;
guMtxRowCol(mh5, 0, 3) = pixDist * -3.f / w;
guMtxRowCol(mh6, 0, 3) = pixDist * 3.f / w;
}
else
{
guMtxRowCol(mh1, 1, 3) = pixDist * -1.f / h;
guMtxRowCol(mh2, 1, 3) = pixDist * 1.f / h;
guMtxRowCol(mh3, 1, 3) = pixDist * -2.f / h;
guMtxRowCol(mh4, 1, 3) = pixDist * 2.f / h;
guMtxRowCol(mh5, 1, 3) = pixDist * -3.f / h;
guMtxRowCol(mh6, 1, 3) = pixDist * 3.f / h;
}
GX_LoadTexMtxImm(mh1, GX_TEXMTX1, GX_MTX2x4);
GX_LoadTexMtxImm(mh2, GX_TEXMTX2, GX_MTX2x4);
GX_LoadTexMtxImm(mh3, GX_TEXMTX3, GX_MTX2x4);
GX_LoadTexMtxImm(mh4, GX_TEXMTX4, GX_MTX2x4);
GX_LoadTexMtxImm(mh3, GX_TEXMTX5, GX_MTX2x4);
GX_LoadTexMtxImm(mh4, GX_TEXMTX6, GX_MTX2x4);
GX_SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX1);
GX_SetTexCoordGen(GX_TEXCOORD2, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX2);
GX_SetTexCoordGen(GX_TEXCOORD3, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX3);
GX_SetTexCoordGen(GX_TEXCOORD4, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX4);
GX_SetTexCoordGen(GX_TEXCOORD5, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX5);
GX_SetTexCoordGen(GX_TEXCOORD6, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX6);
switch (m_blurRadius)
{
case 1:
GX_SetTevKColor(GX_KCOLOR0, kGauss3);
break;
case 2:
GX_SetTevKColor(GX_KCOLOR0, kGauss5);
break;
case 3:
GX_SetTevKColor(GX_KCOLOR0, kGauss7);
break;
default:
GX_SetTevKColor(GX_KCOLOR0, kBox);
}
GX_SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0_R);
GX_SetTevKColorSel(GX_TEVSTAGE1, GX_TEV_KCSEL_K0_G);
GX_SetTevKColorSel(GX_TEVSTAGE2, GX_TEV_KCSEL_K0_G);
GX_SetTevKColorSel(GX_TEVSTAGE3, GX_TEV_KCSEL_K0_B);
GX_SetTevKColorSel(GX_TEVSTAGE4, GX_TEV_KCSEL_K0_B);
GX_SetTevKColorSel(GX_TEVSTAGE5, GX_TEV_KCSEL_K0_A);
GX_SetTevKColorSel(GX_TEVSTAGE6, GX_TEV_KCSEL_K0_A);
GX_SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_R);
GX_SetTevKAlphaSel(GX_TEVSTAGE1, GX_TEV_KASEL_K0_G);
GX_SetTevKAlphaSel(GX_TEVSTAGE2, GX_TEV_KASEL_K0_G);
GX_SetTevKAlphaSel(GX_TEVSTAGE3, GX_TEV_KASEL_K0_B);
GX_SetTevKAlphaSel(GX_TEVSTAGE4, GX_TEV_KASEL_K0_B);
GX_SetTevKAlphaSel(GX_TEVSTAGE5, GX_TEV_KASEL_K0_A);
GX_SetTevKAlphaSel(GX_TEVSTAGE6, GX_TEV_KASEL_K0_A);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_ZERO);
GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_ZERO);
GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
for (int i = 1; i < kSize; ++i)
{
GX_SetTevOrder(GX_TEVSTAGE0 + i, GX_TEXCOORD0 + i, GX_TEXMAP0, GX_COLORNULL);
GX_SetTevColorIn(GX_TEVSTAGE0 + i, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_CPREV);
GX_SetTevAlphaIn(GX_TEVSTAGE0 + i, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_APREV);
GX_SetTevColorOp(GX_TEVSTAGE0 + i, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE0 + i, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
}
GX_SetBlendMode(GX_BM_NONE, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetZMode(GX_DISABLE, GX_ALWAYS, GX_FALSE);
GX_SetViewport(0, 0, 640.f, 480.f, 0.f, 1.f);
guOrtho(projMtx, 0, 480.f + 0, 0, 640.f + 0, 0.f, 1000.0f);
GX_LoadProjectionMtx(projMtx, GX_ORTHOGRAPHIC);
GX_ClearVtxDesc();
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_SetAlphaUpdate(GX_TRUE);
GX_SetCullMode(GX_CULL_NONE);
guMtxIdentity(modelViewMtx);
GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(x, y, 0.f);
GX_TexCoord2f32(0.f, 0.f);
GX_Position3f32(x + w, y, 0.f);
GX_TexCoord2f32(1.f, 0.f);
GX_Position3f32(x + w, y + h, 0.f);
GX_TexCoord2f32(1.f, 1.f);
GX_Position3f32(x, y + h, 0.f);
GX_TexCoord2f32(0.f, 1.f);
GX_End();
m_vid.renderToTexture(m_effectTex, true);
2012-01-21 21:57:41 +01:00
}
bool CCoverFlow::_effectVisible(void)
{
SLayout &lo = m_selected ? m_loSelected : m_loNormal;
return (m_mirrorAlpha > 0.01f && m_mirrorBlur)
|| lo.shadowColorCenter.a > 0 || lo.shadowColorBeg.a > 0
|| lo.shadowColorEnd.a > 0 || lo.shadowColorOff.a > 0;
}
void CCoverFlow::makeEffectTexture(const TexData * &bg)
2012-01-21 21:57:41 +01:00
{
if (!_effectVisible()) return;
int aa = 8;
GX_SetDither(GX_DISABLE);
m_vid.setAA(aa, true, m_effectTex.width, m_effectTex.height);
2012-01-21 21:57:41 +01:00
for (int i = 0; i < aa; ++i)
{
m_vid.prepareAAPass(i);
m_vid.setup2DProjection(false, true);
2012-01-21 21:57:41 +01:00
_effectBg(bg);
if (m_mirrorBlur)
_draw(CCoverFlow::CFDR_NORMAL, true, false);
m_vid.shiftViewPort(m_shadowX, m_shadowY);
2012-01-21 21:57:41 +01:00
_draw(CCoverFlow::CFDR_SHADOW, false, true);
m_vid.renderAAPass(i);
2012-01-21 21:57:41 +01:00
}
GX_SetPixelFmt(GX_PF_RGBA6_Z24, GX_ZC_LINEAR);
GX_InvVtxCache();
GX_InvalidateTexAll();
m_vid.setup2DProjection(false, true);
2012-01-21 21:57:41 +01:00
GX_SetViewport(0.f, 0.f, (float)m_effectTex.width, (float)m_effectTex.height, 0.f, 1.f);
GX_SetScissor(0, 0, m_effectTex.width, m_effectTex.height);
m_vid.drawAAScene();
m_vid.renderToTexture(m_effectTex, true);
_effectBlur(false);
_effectBlur(true);
2012-01-21 21:57:41 +01:00
GX_SetDither(GX_ENABLE);
}
void CCoverFlow::drawEffect(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
if (_effectVisible())
{
Mtx modelViewMtx;
GXTexObj texObj;
float w = 640.f;
float h = 480.f;
float x = 0.f;
float y = 0.f;
GX_SetNumTevStages(1);
GX_SetNumChans(0);
GX_ClearVtxDesc();
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_SetNumTexGens(1);
GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_TEXC);
GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetAlphaUpdate(GX_FALSE);
GX_SetCullMode(GX_CULL_NONE);
GX_SetZMode(GX_ENABLE, GX_LEQUAL, GX_FALSE);
guMtxIdentity(modelViewMtx);
GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0);
GX_InitTexObj(&texObj, m_effectTex.data, m_effectTex.width, m_effectTex.height, m_effectTex.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
2012-01-21 21:57:41 +01:00
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(x, y, -999.f);
GX_TexCoord2f32(0.f, 0.f);
GX_Position3f32(x + w, y, -999.f);
GX_TexCoord2f32(1.f, 0.f);
GX_Position3f32(x + w, y + h, -999.f);
GX_TexCoord2f32(1.f, 1.f);
GX_Position3f32(x, y + h, -999.f);
GX_TexCoord2f32(0.f, 1.f);
GX_End();
}
if (!m_mirrorBlur)
_draw(CCoverFlow::CFDR_NORMAL, true, true);
}
void CCoverFlow::draw(void)
{
_draw();
}
void CCoverFlow::drawText(bool withRectangle)
{
LockMutex lock(m_mutex);
Vector3D up(0.f, 1.f, 0.f);
Vector3D dir(m_cameraAim);
Vector3D pos(m_cameraPos);
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
if (m_fontColor.a == 0) return;
pos += _cameraMoves();
// Camera
GX_LoadProjectionMtx(m_projMtx, GX_PERSPECTIVE);
guLookAt(m_viewMtx, &pos, &up, &dir);
// Text
GX_SetNumChans(1);
GX_SetCullMode(GX_CULL_NONE);
GX_SetZMode(GX_DISABLE, GX_LEQUAL, GX_FALSE);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
for (u32 i = 0; i < m_range; ++i)
{
_drawTitle(loopNum((i & 1) != 0 ? m_range / 2 - (i + 1) / 2 : m_range / 2 + i / 2, m_range), true, withRectangle);
_drawTitle(loopNum((i & 1) != 0 ? m_range / 2 - (i + 1) / 2 : m_range / 2 + i / 2, m_range), false, withRectangle);
}
}
void CCoverFlow::hideCover(void)
{
m_hideCover = true;
}
void CCoverFlow::showCover(void)
{
m_hideCover = false;
}
inline int innerToOuter(int i, int range)
{
return loopNum((i & 1) != 0 ? range / 2 - (i + 1) / 2 : range / 2 + i / 2, range);
}
void CCoverFlow::_draw(DrawMode dm, bool mirror, bool blend)
{
LockMutex lock(m_mutex);
Vector3D up(0.f, 1.f, 0.f);
Vector3D dir(m_cameraAim);
Vector3D pos(m_cameraPos);
if (mirror && m_mirrorAlpha <= 0.f) return;
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
pos += _cameraMoves();
// GX setup
GX_ClearVtxDesc();
GX_SetNumTevStages(1);
if (dm == CCoverFlow::CFDR_NORMAL)
{
GX_SetNumChans(0);
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_SetNumTexGens(1);
GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_KONST, GX_CC_TEXC, GX_CC_ZERO);
GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_KONST, GX_CA_TEXA, GX_CA_ZERO);
GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
}
else
{
GX_SetNumChans(1);
GX_SetNumTexGens(0);
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_KONST);
GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST);
GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLORNULL);
}
GX_SetTevKColor(GX_KCOLOR0, CColor(0xFF, 0xFF, 0xFF, 0xFF));
GX_SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0);
GX_SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A);
if (blend)
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
else
GX_SetBlendMode(GX_BM_NONE, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GX_SetAlphaUpdate(GX_TRUE);
// Camera
GX_LoadProjectionMtx(m_projMtx, GX_PERSPECTIVE);
guLookAt(m_viewMtx, &pos, &up, &dir);
// Covers
GX_SetCullMode(m_box ? (mirror ? GX_CULL_BACK : GX_CULL_FRONT) : GX_CULL_NONE);
if (dm == CCoverFlow::CFDR_SHADOW)
{
// Shadow
GX_SetZMode(GX_DISABLE, GX_LEQUAL, GX_FALSE);
for (int x = (int)m_columns - 3; x >= 0; --x)
{
int xx = innerToOuter(x, m_columns);
if (m_rows >= 3)
for (int y = (int)m_rows - 3; y >= 0; --y)
_drawCover(xx * m_rows + innerToOuter(y, m_rows), mirror, dm);
else
_drawCover(xx, mirror, dm);
}
}
else
{
// Normal
GX_SetZMode(GX_ENABLE, GX_LEQUAL, GX_TRUE);
for (int x = 0; x < (int)m_columns - 2; ++x)
{
int xx = innerToOuter(x, m_columns);
if (m_rows >= 3)
for (int y = 0; y < (int)m_rows - 2; ++y)
_drawCover(xx * m_rows + innerToOuter(y, m_rows), mirror, dm);
else
_drawCover(xx, mirror, dm);
}
// Vanishing covers
GX_SetZMode(GX_ENABLE, GX_LEQUAL, GX_FALSE);
for (u32 y = 0; y < m_rows; ++y)
{
_drawCover(y, mirror, dm);
_drawCover((m_columns - 1) * m_rows + y, mirror, dm);
}
if (m_rows >= 3)
for (u32 x = 1; x < m_columns - 1; ++x)
{
_drawCover(x * m_rows, mirror, dm);
_drawCover(x * m_rows + m_rows - 1, mirror, dm);
}
}
}
Vector3D CCoverFlow::_cameraMoves(void)
{
SLayout &lo = m_selected ? m_loSelected : m_loNormal;
float tick = (float)m_tickCount * 0.005f;
return Vector3D(cos(tick * lo.cameraOscSpeed.x) * lo.cameraOscAmp.x,
cos(tick * lo.cameraOscSpeed.y) * lo.cameraOscAmp.y,
cos(tick * lo.cameraOscSpeed.z) * lo.cameraOscAmp.z);
}
Vector3D CCoverFlow::_coverMovesA(void)//angle
2012-01-21 21:57:41 +01:00
{
SLayout &lo = m_selected ? m_loSelected : m_loNormal;
float tick = (float)m_tickCount * 0.005f;
return Vector3D(cos(tick * lo.coverOscASpeed.x) * lo.coverOscAAmp.x,
sin(tick * lo.coverOscASpeed.y) * lo.coverOscAAmp.y,
cos(tick * lo.coverOscASpeed.z) * lo.coverOscAAmp.z);
}
Vector3D CCoverFlow::_coverMovesP(void)//position
2012-01-21 21:57:41 +01:00
{
SLayout &lo = m_selected ? m_loSelected : m_loNormal;
float tick = (float)m_tickCount * 0.005f;
return Vector3D(cos(tick * lo.coverOscPSpeed.x) * lo.coverOscPAmp.x,
sin(tick * lo.coverOscPSpeed.y) * lo.coverOscPAmp.y,
cos(tick * lo.coverOscPSpeed.z) * lo.coverOscPAmp.z);
}
void CCoverFlow::_drawTitle(int i, bool mirror, bool rectangle)
{
Mtx modelMtx;
Mtx modelViewMtx;
Vector3D rotAxis(0.f, 1.f, 0.f);
CColor color(m_fontColor);
2012-01-21 21:57:41 +01:00
if (m_hideCover) return;
if (m_covers[i].txtColor == 0) return;
color.a = mirror ? (u8)((float)m_covers[i].txtColor * m_txtMirrorAlpha) : m_covers[i].txtColor;
// rectangle is never used. in menu.cpp _mainLoopCommon() adjusting is never set true
// but if it would be. rectangle is the same as using a frame for the text as when the gui draws a label.
// when using a frame the text style is used. otherwise it is not used.
if (rectangle && !mirror)
2012-01-21 21:57:41 +01:00
{
// GX setup
GX_SetNumTevStages(1);
GX_SetNumChans(1);
GX_ClearVtxDesc();
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GX_SetNumTexGens(0);
GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC);
GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_RASA);
GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
//
Mtx rotMtx;
guMtxIdentity(modelMtx);
guMtxScaleApply(modelMtx, modelMtx, 0.005f, 0.005f, 0.005f);
guMtxRotDeg(rotMtx, 'Y', m_covers[i].txtAngle);
guMtxConcat(rotMtx, modelMtx, modelMtx);
guMtxTransApply(modelMtx, modelMtx, m_covers[i].txtPos.x, mirror ? -m_covers[i].txtPos.y : m_covers[i].txtPos.y, m_covers[i].txtPos.z);
guMtxConcat(m_viewMtx, modelMtx, modelViewMtx);
GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0);
const SLayout &lo = m_selected ? m_loSelected : m_loNormal;
u16 s = (u32)i == m_range / 2 ? lo.txtCenterStyle : lo.txtSideStyle;
float x;
float y;
float w = (u32)i == m_range / 2 ? lo.txtCenterWidth : lo.txtSideWidth;
float h = m_font.lineSpacing;
if ((s & FTGX_JUSTIFY_CENTER) != 0)
x = -w * 0.5f;
else if ((s & FTGX_JUSTIFY_RIGHT) != 0)
x = -w;
else
x = 0.f;
if ((s & FTGX_ALIGN_MIDDLE) != 0)
y = -h * 0.5f;
else if ((s & FTGX_ALIGN_TOP) != 0)
y = -h;
else
y = 0.f;
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(x, y, 0.f);
GX_Color4u8(color.r, color.g, color.b, color.a / 2);
GX_Position3f32(x + w, y, 0.f);
GX_Color4u8(color.r, color.g, color.b, color.a / 2);
GX_Position3f32(x + w, y + h, 0.f);
GX_Color4u8(color.r, color.g, color.b, color.a / 2);
GX_Position3f32(x, y + h, 0.f);
GX_Color4u8(color.r, color.g, color.b, color.a / 2);
GX_End();
}
m_covers[i].title.setColor(color);
m_font.font->reset();
m_font.font->setXScale(0.005f);
m_font.font->setYScale(mirror ? 0.005f : -0.005f);
GX_ClearVtxDesc();
GX_SetNumTevStages(1);
GX_SetNumChans(1);
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_SetNumTexGens(1);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
//
guMtxIdentity(modelMtx);
guMtxRotAxisDeg(modelMtx, &rotAxis, m_covers[i].txtAngle);
guMtxTransApply(modelMtx, modelMtx, m_covers[i].txtPos.x, mirror ? -m_covers[i].txtPos.y : m_covers[i].txtPos.y, m_covers[i].txtPos.z);
guMtxConcat(m_viewMtx, modelMtx, modelViewMtx);
GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0);
m_covers[i].title.draw();
}
void CCoverFlow::_drawCover(int i, bool mirror, CCoverFlow::DrawMode dm)
{
Mtx modelMtx;
Mtx rotMtx;
Mtx modelViewMtx;
Vector3D osc;
Vector3D oscP;
if (m_hideCover)
return;
if (m_covers[i].color.a == 0 || (dm == CCoverFlow::CFDR_SHADOW && m_covers[i].shadowColor.a == 0))
return;
if (dm == CCoverFlow::CFDR_STENCIL && (i > 0xFF || _invisibleCover(i / m_rows, i % m_rows)))
return;
if ((u32)i == m_range / 2)
{
osc = _coverMovesA();
oscP = _coverMovesP();
}
//
guMtxIdentity(modelMtx);
guMtxScaleApply(modelMtx, modelMtx, m_covers[i].scale.x, m_covers[i].scale.y, m_covers[i].scale.z);
if (dm == CCoverFlow::CFDR_SHADOW)
guMtxScaleApply(modelMtx, modelMtx, 1.f + (m_shadowScale - 1.f) * g_boxSize.y / g_boxSize.x, m_shadowScale, m_shadowScale);
guMtxRotDeg(rotMtx, 'Z', m_covers[i].angle.z + osc.z);
guMtxConcat(rotMtx, modelMtx, modelMtx);
guMtxRotDeg(rotMtx, 'X', m_covers[i].angle.x + osc.x);
guMtxConcat(rotMtx, modelMtx, modelMtx);
guMtxRotDeg(rotMtx, 'Y', m_covers[i].angle.y + osc.y);
guMtxConcat(rotMtx, modelMtx, modelMtx);
guMtxTransApply(modelMtx, modelMtx, m_covers[i].pos.x + oscP.x, m_covers[i].pos.y + oscP.y + g_coverYCenter, m_covers[i].pos.z + oscP.z);
if (mirror)
guMtxScaleApply(modelMtx, modelMtx, 1.f, -1.f, 1.f);
guMtxConcat(m_viewMtx, modelMtx, modelViewMtx);
GX_LoadPosMtxImm(modelViewMtx, GX_PNMTX0);
// Cover
if (m_box)
_drawCoverBox(i, mirror, dm);
else
_drawCoverFlat(i, mirror, dm);
}
const TexData *CCoverFlow::_coverTexture(int i)
2012-01-21 21:57:41 +01:00
{
if(m_items[i].texture.data == NULL)
return (m_items[i].state == STATE_Loading) ? m_loadingTexture : m_noCoverTexture;
return &m_items[i].texture;
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::_drawCoverFlat(int i, bool mirror, CCoverFlow::DrawMode dm)
{
GXTexObj texObj;
const TexData *tex = _coverTexture(m_covers[i].index);
2012-01-21 21:57:41 +01:00
bool boxTex = m_items[m_covers[i].index].boxTexture && !!m_items[m_covers[i].index].texture.data;
switch (dm)
{
case CCoverFlow::CFDR_NORMAL:
{
CColor color(m_covers[i].color);
if (mirror)
color.a = (u8)((float)color.a * m_mirrorAlpha);
GX_SetTevKColor(GX_KCOLOR0, color);
break;
}
case CCoverFlow::CFDR_STENCIL:
GX_SetTevKColor(GX_KCOLOR0, CColor(i + 1, 0xFF, 0xFF, 0xFF));
break;
case CCoverFlow::CFDR_SHADOW:
{
CColor color(m_covers[i].shadowColor);
if (mirror)
color.a = (u8)((float)color.a * m_mirrorAlpha);
GX_SetTevKColor(GX_KCOLOR0, color);
break;
}
}
if(dm == CCoverFlow::CFDR_NORMAL)
2012-01-21 21:57:41 +01:00
{
GX_InitTexObj(&texObj, tex->data, tex->width, tex->height, tex->format, GX_CLAMP, GX_CLAMP, GX_FALSE);
if(tex->maxLOD > 0)
GX_InitTexObjLOD(&texObj, GX_LIN_MIP_LIN, GX_LINEAR, 0.f, (float)tex->maxLOD, mirror ? 1.f : m_lodBias, GX_FALSE, m_edgeLOD ? GX_TRUE : GX_FALSE, m_aniso);
2012-01-21 21:57:41 +01:00
GX_LoadTexObj(&texObj, GX_TEXMAP0);
}
GX_Begin(GX_QUADS, GX_VTXFMT0, g_flatCoverMeshSize);
for (u32 j = 0; j < g_flatCoverMeshSize; ++j)
{
GX_Position3f32(g_flatCoverMesh[j].pos.x, g_flatCoverMesh[j].pos.y, g_flatCoverMesh[j].pos.z);
if (dm == CCoverFlow::CFDR_NORMAL)
{
if (boxTex)
GX_TexCoord2f32(g_flatCoverBoxTex[j].x, g_flatCoverBoxTex[j].y);
else
GX_TexCoord2f32(g_flatCoverMesh[j].texCoord.x, g_flatCoverMesh[j].texCoord.y);
}
2012-01-21 21:57:41 +01:00
}
GX_End();
2012-01-21 21:57:41 +01:00
}
bool CCoverFlow::checkCoverColor(const char *gameID, const char *checkID[], u32 len)
{
for(u32 num = 0; num < len; ++num)
{
if (strncmp(gameID, checkID[num], strlen(checkID[num])) == 0)
return true;
}
return false;
}
u32 CCoverFlow::InternalCoverColor(const char *ID, u32 DefCaseColor)
{
if(checkCoverColor(ID, red, red_len))
return 0xFF0000;
else if(checkCoverColor(ID, black, black_len))
return 0x000000;
else if(checkCoverColor(ID, yellow, yellow_len))
return 0xFCFF00;
else if(checkCoverColor(ID, greenOne, greenOne_len))
return 0x01A300;
else if(checkCoverColor(ID, greenTwo, greenTwo_len))
return 0x00E360;
return DefCaseColor;
}
2012-01-21 21:57:41 +01:00
void CCoverFlow::_drawCoverBox(int i, bool mirror, CCoverFlow::DrawMode dm)
{
CColor color;
GXTexObj texObj;
const TexData *tex = _coverTexture(m_covers[i].index);
2012-01-21 21:57:41 +01:00
bool flatTex = !m_items[m_covers[i].index].boxTexture && !!m_items[m_covers[i].index].texture.data;
switch (dm)
{
case CCoverFlow::CFDR_NORMAL:
color = m_covers[i].color;
if (mirror)
color.a = (u8)((float)color.a * m_mirrorAlpha);
GX_SetTevKColor(GX_KCOLOR0, color);
break;
case CCoverFlow::CFDR_STENCIL:
GX_SetTevKColor(GX_KCOLOR0, CColor(i + 1, 0xFF, 0xFF, 0xFF));
break;
case CCoverFlow::CFDR_SHADOW:
color = m_covers[i].shadowColor;
if (mirror)
color.a = (u8)((float)color.a * m_mirrorAlpha);
GX_SetTevKColor(GX_KCOLOR0, color);
break;
}
if(dm == CCoverFlow::CFDR_NORMAL)
{
2012-01-21 21:57:41 +01:00
// set dvd box texture, depending on game
switch(m_items[m_covers[i].index].hdr->casecolor)
{
case 0x000000:
case 0x181919:
GX_InitTexObj(&texObj, m_dvdSkin_Black.data, m_dvdSkin_Black.width, m_dvdSkin_Black.height, m_dvdSkin_Black.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
break;
case 0xFF0000:
GX_InitTexObj(&texObj, m_dvdSkin_Red.data, m_dvdSkin_Red.width, m_dvdSkin_Red.height, m_dvdSkin_Red.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
break;
case 0xFCFF00:
GX_InitTexObj(&texObj, m_dvdSkin_Yellow.data, m_dvdSkin_Yellow.width, m_dvdSkin_Yellow.height, m_dvdSkin_Yellow.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
break;
case 0x01A300:
GX_InitTexObj(&texObj, m_dvdSkin_GreenOne.data, m_dvdSkin_GreenOne.width, m_dvdSkin_GreenOne.height, m_dvdSkin_GreenOne.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
break;
case 0x00E360:
GX_InitTexObj(&texObj, m_dvdSkin_GreenTwo.data, m_dvdSkin_GreenTwo.width, m_dvdSkin_GreenTwo.height, m_dvdSkin_GreenTwo.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
break;
default:
GX_InitTexObj(&texObj, m_dvdSkin.data, m_dvdSkin.width, m_dvdSkin.height, m_dvdSkin.format, GX_CLAMP, GX_CLAMP, GX_FALSE);
break;
}
2012-01-21 21:57:41 +01:00
GX_LoadTexObj(&texObj, GX_TEXMAP0);
}
GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxMeshQSize);
for (u32 j = 0; j < g_boxMeshQSize; ++j)
2012-01-21 21:57:41 +01:00
{
GX_Position3f32(g_boxMeshQ[j].pos.x, g_boxMeshQ[j].pos.y, g_boxMeshQ[j].pos.z);
2012-01-21 21:57:41 +01:00
if (dm == CCoverFlow::CFDR_NORMAL)
GX_TexCoord2f32(g_boxMeshQ[j].texCoord.x, g_boxMeshQ[j].texCoord.y);
2012-01-21 21:57:41 +01:00
}
GX_End();
GX_Begin(GX_TRIANGLES, GX_VTXFMT0, g_boxMeshTSize);
for (u32 j = 0; j < g_boxMeshTSize; ++j)
2012-01-21 21:57:41 +01:00
{
GX_Position3f32(g_boxMeshT[j].pos.x, g_boxMeshT[j].pos.y, g_boxMeshT[j].pos.z);
if (dm == CCoverFlow::CFDR_NORMAL)
GX_TexCoord2f32(g_boxMeshT[j].texCoord.x, g_boxMeshT[j].texCoord.y);
}
GX_End();
if (dm == CCoverFlow::CFDR_NORMAL)
{
const TexData *myTex = tex;
if(flatTex)
myTex = m_noCoverTexture;
GX_InitTexObj(&texObj, myTex->data, myTex->width, myTex->height, myTex->format, GX_CLAMP, GX_CLAMP, GX_FALSE);
if (myTex->maxLOD > 0)
GX_InitTexObjLOD(&texObj, GX_LIN_MIP_LIN, GX_LINEAR, 0.f, (float)myTex->maxLOD, mirror ? 1.f : m_lodBias, GX_FALSE, m_edgeLOD ? GX_TRUE : GX_FALSE, m_aniso);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
}
GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxBackCoverMeshSize);
for (u32 j = 0; j < g_boxBackCoverMeshSize; ++j)
{
GX_Position3f32(g_boxBackCoverMesh[j].pos.x, g_boxBackCoverMesh[j].pos.y, g_boxBackCoverMesh[j].pos.z);
if (dm == CCoverFlow::CFDR_NORMAL)
GX_TexCoord2f32(g_boxBackCoverMesh[j].texCoord.x, g_boxBackCoverMesh[j].texCoord.y);
}
GX_End();
if (dm == CCoverFlow::CFDR_NORMAL && flatTex)
{
GX_InitTexObj(&texObj, tex->data, tex->width, tex->height, tex->format, GX_CLAMP, GX_CLAMP, GX_FALSE);
if (tex->maxLOD > 0)
GX_InitTexObjLOD(&texObj, GX_LIN_MIP_LIN, GX_LINEAR, 0.f, (float)tex->maxLOD, mirror ? 1.f : m_lodBias, GX_FALSE, m_edgeLOD ? GX_TRUE : GX_FALSE, m_aniso);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
}
GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxCoverMeshSize);
for (u32 j = 0; j < g_boxCoverMeshSize; ++j)
{
GX_Position3f32(g_boxCoverMesh[j].pos.x, g_boxCoverMesh[j].pos.y, g_boxCoverMesh[j].pos.z);
2012-01-21 21:57:41 +01:00
if (dm == CCoverFlow::CFDR_NORMAL)
{
if (flatTex)
GX_TexCoord2f32(g_boxCoverFlatTex[j].x, g_boxCoverFlatTex[j].y);
else
GX_TexCoord2f32(g_boxCoverMesh[j].texCoord.x, g_boxCoverMesh[j].texCoord.y);
}
2012-01-21 21:57:41 +01:00
}
GX_End();
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::_loadCover(int i, int item)
{
m_covers[i].index = item;
m_covers[i].title.setText(m_font, m_items[item].hdr->title);
}
const char *CCoverFlow::getId(void) const
2012-01-21 21:57:41 +01:00
{
if (m_covers == NULL || m_items.empty()) return "";
return m_items[loopNum(m_covers[m_range / 2].index + m_jump, m_items.size())].hdr->id;
2012-01-21 21:57:41 +01:00
}
const char *CCoverFlow::getNextId(void) const
2012-01-21 21:57:41 +01:00
{
if (m_covers == NULL || m_items.empty()) return "";
return m_items[loopNum(m_covers[m_range / 2].index + m_jump + 1, m_items.size())].hdr->id;
2012-01-21 21:57:41 +01:00
}
const dir_discHdr * CCoverFlow::getHdr(void) const
2012-01-21 21:57:41 +01:00
{
if (m_covers == NULL || m_items.empty()) return NULL;
2012-01-21 21:57:41 +01:00
return m_items[loopNum(m_covers[m_range / 2].index + m_jump, m_items.size())].hdr;
}
const dir_discHdr * CCoverFlow::getNextHdr(void) const
2012-01-21 21:57:41 +01:00
{
if (m_covers == NULL || m_items.empty()) return NULL;
2012-01-21 21:57:41 +01:00
return m_items[loopNum(m_covers[m_range / 2].index + m_jump + 1, m_items.size())].hdr;
}
const dir_discHdr * CCoverFlow::getSpecificHdr(u32 place) const
{
if (m_covers == NULL || m_items.empty() || place >= m_items.size()) return NULL;
return m_items[place].hdr;
}
2012-01-21 21:57:41 +01:00
wstringEx CCoverFlow::getTitle(void) const
{
if (m_covers == NULL) return L"";
2012-01-21 21:57:41 +01:00
return m_items[m_covers[m_range / 2].index].hdr->title;
}
u64 CCoverFlow::getChanTitle(void) const
{
if (m_covers == NULL || m_items.empty()) return 0;
2012-01-21 21:57:41 +01:00
return TITLE_ID(m_items[loopNum(m_covers[m_range / 2].index + m_jump, m_items.size())].hdr->settings[0],
m_items[loopNum(m_covers[m_range / 2].index + m_jump, m_items.size())].hdr->settings[1]);
2012-01-21 21:57:41 +01:00
}
bool CCoverFlow::getRenderTex(void)
{
return m_renderTex;
}
void CCoverFlow::setRenderTex(bool val)
{
m_renderTex = val;
}
void CCoverFlow::RenderTex(void)
{
if(m_renderingTex != NULL && m_renderingTex->data != NULL)
{
LockMutex lock(m_mutex);
DrawTexture(m_renderingTex);
m_vid.renderToTexture(*m_renderingTex, true);
}
setRenderTex(false);
}
2012-01-21 21:57:41 +01:00
bool CCoverFlow::select(void)
{
if (m_covers == NULL || m_jump != 0) return false;
2012-01-21 21:57:41 +01:00
if (m_selected) return true;
LockMutex lock(m_mutex);
int curPos = (int)m_range / 2;
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
if ((u32)m_mouse[chan] < m_range && m_mouse[chan] != curPos)
{
int j;
if (m_rows >= 3)
j = ((m_mouse[chan] / m_rows - 1) * (m_rows - 2) + m_mouse[chan] % m_rows - 1)
- ((curPos / m_rows - 1) * (m_rows - 2) + curPos % m_rows - 1);
else
j = m_mouse[chan] - (int)(m_range / 2);
_setJump(j);
}
m_cameraPos += _cameraMoves();
m_covers[m_range / 2].angle += _coverMovesA();
m_covers[m_range / 2].pos += _coverMovesP();
m_selected = true;
m_covers[m_range / 2].angle -= _coverMovesA();
m_covers[m_range / 2].pos -= _coverMovesP();
m_cameraPos -= _cameraMoves();
_updateAllTargets();
_playSound(m_selectSound);
return true;
}
void CCoverFlow::cancel(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
LockMutex lock(m_mutex);
_unselect();
_updateAllTargets();
_playSound(m_cancelSound);
}
void CCoverFlow::defaultLoad(void)
{
_loadAllCovers(0);
_updateAllTargets(true);
}
2012-01-21 21:57:41 +01:00
void CCoverFlow::_updateAllTargets(bool instant)
{
m_targetCameraPos = m_selected ? m_loSelected.camera : m_loNormal.camera;
m_targetCameraAim = m_selected ? m_loSelected.cameraAim : m_loNormal.cameraAim;
for (u32 i = 0; i < m_range; ++i)
_updateTarget(i, instant);
}
void CCoverFlow::_updateTarget(int i, bool instant)
{
SLayout &lo = m_selected ? m_loSelected : m_loNormal;
int hcenter = m_columns / 2;
int vcenter = m_rows / 2;
int x = i / m_rows;
int y = i % m_rows;
CCover &cvr = m_covers[i];
// Left covers
if (x < hcenter)
{
Vector3D deltaAngle(lo.leftDeltaAngle * (float)(hcenter - 1 - x));
cvr.targetAngle = lo.leftAngle + deltaAngle;
cvr.targetPos = lo.leftPos + lo.leftSpacer.rotateY(deltaAngle.y * 0.5f) * (float)(hcenter - 1 - x);
cvr.targetScale = lo.leftScale;
if (_invisibleCover(x, y))
{
cvr.targetColor = CColor(lo.endColor.r, lo.endColor.g, lo.endColor.b, 0);
cvr.targetShadowColor = CColor(lo.shadowColorEnd.r, lo.shadowColorEnd.g, lo.shadowColorEnd.b, 0);
}
else
{
u8 a = (x - 1) * 0xFF / max(1, hcenter - 2);
cvr.targetColor = CColor::interpolate(lo.endColor, lo.begColor, a);
cvr.targetShadowColor = CColor::interpolate(lo.shadowColorEnd, lo.shadowColorBeg, a);
}
cvr.txtTargetAngle = lo.txtLeftAngle;
cvr.txtTargetPos = lo.txtLeftPos;
cvr.txtTargetColor = 0;
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
cvr.txtColor = 0;//instant fade out if was displayed
2012-01-21 21:57:41 +01:00
cvr.title.setFrame(lo.txtSideWidth, lo.txtSideStyle, false, instant);
}
// Right covers
else if (x > hcenter)
{
Vector3D deltaAngle(lo.rightDeltaAngle * (float)(x - hcenter - 1));
cvr.targetAngle = lo.rightAngle + deltaAngle;
cvr.targetPos = lo.rightPos + lo.rightSpacer.rotateY(deltaAngle.y * 0.5f) * (float)(x - hcenter - 1);
cvr.targetScale = lo.rightScale;
if (_invisibleCover(x, y))
{
cvr.targetColor = CColor(lo.endColor.r, lo.endColor.g, lo.endColor.b, 0);
cvr.targetShadowColor = CColor(lo.shadowColorEnd.r, lo.shadowColorEnd.g, lo.shadowColorEnd.b, 0);
}
else
{
u8 a = (m_columns - x - 2) * 0xFF / max(1, hcenter - 2);
cvr.targetColor = CColor::interpolate(lo.endColor, lo.begColor, a);
cvr.targetShadowColor = CColor::interpolate(lo.shadowColorEnd, lo.shadowColorBeg, a);
}
cvr.txtTargetAngle = lo.txtRightAngle;
cvr.txtTargetPos = lo.txtRightPos;
cvr.txtTargetColor = 0;
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
cvr.txtColor = 0;//instant fade out if was displayed
2012-01-21 21:57:41 +01:00
cvr.title.setFrame(lo.txtSideWidth, lo.txtSideStyle, false, instant);
}
// New center cover
else if (y == vcenter)
{
cvr.targetColor = 0xFFFFFFFF;
cvr.targetShadowColor = lo.shadowColorCenter;
cvr.targetAngle = lo.centerAngle;
cvr.targetPos = lo.centerPos;
cvr.targetScale = lo.centerScale;
cvr.txtTargetColor = 0xFF;
cvr.txtTargetAngle = lo.txtCenterAngle;
cvr.txtTargetPos = lo.txtCenterPos;
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
cvr.title.setFrame(lo.txtCenterWidth, lo.txtCenterStyle, false, true);
2012-01-21 21:57:41 +01:00
}
else // Center of a row
{
cvr.targetColor = lo.begColor;
cvr.targetShadowColor = lo.shadowColorBeg;
cvr.targetAngle = lo.rowCenterAngle;
cvr.targetPos = lo.rowCenterPos;
cvr.targetScale = lo.rowCenterScale;
cvr.txtTargetColor = 0;
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
cvr.txtColor = 0;//instant fade out if was displayed
2012-01-21 21:57:41 +01:00
if (y < vcenter)
{
cvr.txtTargetAngle = lo.txtLeftAngle;
cvr.txtTargetPos = lo.txtLeftPos;
}
else // (y > vcenter)
{
cvr.txtTargetAngle = lo.txtRightAngle;
cvr.txtTargetPos = lo.txtRightPos;
}
cvr.title.setFrame(lo.txtSideWidth, lo.txtSideStyle, false, instant);
}
// Top row
if (y < vcenter)
{
Vector3D deltaAngle(lo.topDeltaAngle * (float)(vcenter - y - 1));
cvr.targetAngle += lo.topAngle + deltaAngle;
cvr.targetPos += lo.topSpacer.rotateX(deltaAngle.x * 0.5f) * (float)(vcenter - y);
if (_invisibleCover(x, y))
{
cvr.targetColor = CColor(lo.endColor.r, lo.endColor.g, lo.endColor.b, 0);
cvr.targetShadowColor = CColor(lo.shadowColorEnd.r, lo.shadowColorEnd.g, lo.shadowColorEnd.b, 0);
}
else
{
u8 a = (y - 1) * 0xFF / max(1, vcenter - 2);
CColor c1(CColor::interpolate(lo.endColor, lo.begColor, a));
cvr.targetColor = CColor::interpolate(c1, cvr.targetColor, 0x7F);
CColor c2(CColor::interpolate(lo.shadowColorEnd, lo.shadowColorBeg, a));
cvr.targetShadowColor = CColor::interpolate(c2, cvr.targetShadowColor, 0x7F);
}
}
// Bottom row
else if (y > vcenter)
{
Vector3D deltaAngle(lo.bottomDeltaAngle * (float)(y - vcenter - 1));
cvr.targetAngle += lo.bottomAngle + deltaAngle;
cvr.targetPos += lo.bottomSpacer.rotateX(deltaAngle.x * 0.5f) * (float)(y - vcenter);
if (_invisibleCover(x, y))
{
cvr.targetColor = CColor(lo.endColor.r, lo.endColor.g, lo.endColor.b, 0);
cvr.targetShadowColor = CColor(lo.shadowColorEnd.r, lo.shadowColorEnd.g, lo.shadowColorEnd.b, 0);
}
else
{
u8 a = (m_rows - y - 2) * 0xFF / max(1, vcenter - 2);
CColor c1(CColor::interpolate(lo.endColor, lo.begColor, a));
cvr.targetColor = CColor::interpolate(c1, cvr.targetColor, 0x7F);
CColor c2(CColor::interpolate(lo.shadowColorEnd, lo.shadowColorBeg, a));
cvr.targetShadowColor = CColor::interpolate(c2, cvr.targetShadowColor, 0x7F);
}
}
else if (vcenter > 0 && !_invisibleCover(x, y) && x != hcenter)
{
cvr.targetColor = CColor::interpolate(lo.begColor, cvr.targetColor, 0x7F);
cvr.targetShadowColor = CColor::interpolate(lo.shadowColorBeg, cvr.targetShadowColor, 0x7F);
}
// Mouse selection
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
if (!m_selected && (u32)m_mouse[chan] < m_range)
{
if (i == m_mouse[chan])
{
cvr.targetColor = 0xFFFFFFFF;
cvr.targetShadowColor = lo.shadowColorCenter;
cvr.txtTargetAngle = lo.txtCenterAngle;
cvr.txtTargetPos = lo.txtCenterPos;
cvr.txtTargetColor = 0xFF;
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
cvr.title.setFrame(lo.txtCenterWidth, lo.txtCenterStyle, false, true);
2012-01-21 21:57:41 +01:00
}
else
{
cvr.targetColor = lo.mouseOffColor;
cvr.targetShadowColor = lo.shadowColorOff;
cvr.txtTargetAngle = m_mouse[chan] > i ? lo.txtLeftAngle : lo.txtRightAngle;
cvr.txtTargetPos = m_mouse[chan] > i ? lo.txtLeftPos : lo.txtRightPos;
cvr.txtTargetColor = 0;
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
cvr.txtColor = 0;//instant fade out if was displayed
2012-01-21 21:57:41 +01:00
cvr.title.setFrame(lo.txtSideWidth, lo.txtSideStyle, false, instant);
}
if (_invisibleCover(x, y))
{
cvr.targetColor.a = 0;
cvr.targetShadowColor.a = 0;
}
}
//
if (instant)
_instantTarget(i);
}
void CCoverFlow::_instantTarget(int i)
{
CCover &cvr = m_covers[i];
cvr.angle = cvr.targetAngle;
cvr.pos = cvr.targetPos;
cvr.scale = cvr.targetScale;
cvr.color = cvr.targetColor;
cvr.shadowColor = cvr.targetShadowColor;
cvr.txtAngle = cvr.txtTargetAngle;
cvr.txtPos = cvr.txtTargetPos;
cvr.txtColor = cvr.txtTargetColor;
}
bool CCoverFlow::_sortByPlayCount(CItem item1, CItem item2)
{
return (item1.playcount == item2.playcount) ? _sortByAlpha(item1, item2) : item1.playcount > item2.playcount;
}
bool CCoverFlow::_sortByLastPlayed(CItem item1, CItem item2)
{
return (item1.lastPlayed == item2.lastPlayed) ? _sortByPlayCount(item1, item2) : item1.lastPlayed > item2.lastPlayed;
}
bool CCoverFlow::_sortByGameID(CItem item1, CItem item2)
{
u32 s = min(strlen(item1.hdr->id), strlen(item2.hdr->id));
for(u32 k = 0; k < s; ++k)
2012-01-21 21:57:41 +01:00
{
if(toupper(item1.hdr->id[k]) > toupper(item2.hdr->id[k]))
2012-01-21 21:57:41 +01:00
return false;
else if(toupper(item1.hdr->id[k]) < toupper(item2.hdr->id[k]))
2012-01-21 21:57:41 +01:00
return true;
}
return strlen(item1.hdr->id) < strlen(item2.hdr->id);
2012-01-21 21:57:41 +01:00
}
bool CCoverFlow::_sortByAlpha(CItem item1, CItem item2)
{
const wchar_t *first = item1.hdr->title;
const wchar_t *second = item2.hdr->title;
return wchar_cmp(first, second, wcslen(first), wcslen(second));
2012-01-21 21:57:41 +01:00
}
bool CCoverFlow::_sortByPlayers(CItem item1, CItem item2)
{
if(item1.hdr->players == item2.hdr->players) return _sortByAlpha(item1, item2);
return item1.hdr->players < item2.hdr->players;
2012-01-21 21:57:41 +01:00
}
bool CCoverFlow::_sortByWifiPlayers(CItem item1, CItem item2)
{
if(item1.hdr->wifi == item2.hdr->wifi) return _sortByAlpha(item1, item2);
return item1.hdr->wifi < item2.hdr->wifi;
2012-01-21 21:57:41 +01:00
}
bool CCoverFlow::_sortByBtnNumbers(CItem item1, CItem item2)
{
if(item1.hdr->settings[0] == item2.hdr->settings[0]) return _sortByAlpha(item1, item2);
return item1.hdr->settings[0] < item2.hdr->settings[0];
}
bool CCoverFlow::start(const string &m_imgsDir)
2012-01-21 21:57:41 +01:00
{
if (m_items.empty()) return true;
// Sort items
if (m_sorting == SORT_ALPHA)
sort(m_items.begin(), m_items.end(), CCoverFlow::_sortByAlpha);
else if (m_sorting == SORT_PLAYCOUNT)
sort(m_items.begin(), m_items.end(), CCoverFlow::_sortByPlayCount);
else if (m_sorting == SORT_LASTPLAYED)
sort(m_items.begin(), m_items.end(), CCoverFlow::_sortByLastPlayed);
else if (m_sorting == SORT_GAMEID)
sort(m_items.begin(), m_items.end(), CCoverFlow::_sortByGameID);
else if (m_sorting == SORT_PLAYERS)
sort(m_items.begin(), m_items.end(), CCoverFlow::_sortByPlayers);
else if (m_sorting == SORT_WIFIPLAYERS)
sort(m_items.begin(), m_items.end(), CCoverFlow::_sortByWifiPlayers);
else if (m_sorting == SORT_BTN_NUMBERS)
sort(m_items.begin(), m_items.end(), CCoverFlow::_sortByBtnNumbers);
2012-01-21 21:57:41 +01:00
// Load resident textures
if(!m_dvdskin_loaded)
{
if(TexHandle.fromImageFile(m_dvdSkin, fmt("%s/dvdskin.jpg", m_imgsDir.c_str())) != TE_OK)
return false;
if(TexHandle.fromImageFile(m_dvdSkin_Red, fmt("%s/dvdskin_red.jpg", m_imgsDir.c_str())) != TE_OK)
return false;
if(TexHandle.fromImageFile(m_dvdSkin_Black, fmt("%s/dvdskin_black.jpg", m_imgsDir.c_str())) != TE_OK)
return false;
if(TexHandle.fromImageFile(m_dvdSkin_Yellow, fmt("%s/dvdskin_yellow.jpg", m_imgsDir.c_str())) != TE_OK)
return false;
if(TexHandle.fromImageFile(m_dvdSkin_GreenOne, fmt("%s/dvdskin_greenone.jpg", m_imgsDir.c_str())) != TE_OK)
return false;
if(TexHandle.fromImageFile(m_dvdSkin_GreenTwo, fmt("%s/dvdskin_greentwo.jpg", m_imgsDir.c_str())) != TE_OK)
return false;
m_dvdskin_loaded = true;
}
if(!m_defcovers_loaded)
{
if(m_pngLoadCover.empty() || TexHandle.fromImageFile(m_boxLoadingTexture, m_pngLoadCover.c_str(), GX_TF_CMPR, 32, 512) != TE_OK)
{
if(TexHandle.fromImageFile(m_boxLoadingTexture, fmt("%s/loading.jpg", m_imgsDir.c_str()), GX_TF_CMPR, 32, 512) != TE_OK)
return false;
}
if(m_pngNoCover.empty() || TexHandle.fromImageFile(m_boxNoCoverTexture, m_pngNoCover.c_str(), GX_TF_CMPR, 32, 512) != TE_OK)
{
if(TexHandle.fromImageFile(m_boxNoCoverTexture, fmt("%s/nopic.png", m_imgsDir.c_str()), GX_TF_CMPR, 32, 512) != TE_OK)
return false;
}
if(m_pngLoadCoverFlat.empty() || TexHandle.fromImageFile(m_flatLoadingTexture, m_pngLoadCoverFlat.c_str(), GX_TF_CMPR, 32, 512) != TE_OK)
{
if(TexHandle.fromImageFile(m_flatLoadingTexture, fmt("%s/flatloading.jpg", m_imgsDir.c_str()), GX_TF_CMPR, 32, 512) != TE_OK)
return false;
}
if(m_pngNoCoverFlat.empty() || TexHandle.fromImageFile(m_flatNoCoverTexture, m_pngNoCoverFlat.c_str(), GX_TF_CMPR, 32, 512) != TE_OK)
{
if(TexHandle.fromImageFile(m_flatNoCoverTexture, fmt("%s/flatnopic.png", m_imgsDir.c_str()), GX_TF_CMPR, 32, 512) != TE_OK)
return false;
}
m_defcovers_loaded = true;
}
m_loadingTexture = (m_box ? &m_boxLoadingTexture : &m_flatLoadingTexture);
m_noCoverTexture = (m_box ? &m_boxNoCoverTexture : &m_flatNoCoverTexture);
if(m_covers != NULL)
MEM2_free(m_covers);
m_covers = NULL;
if(m_range > 0)
{
m_covers = (CCover*)MEM2_alloc(sizeof(CCover) * m_range);
for(size_t i = 0; i < m_range; ++i)
m_covers[i] = *(new(m_covers+i) CCover);
}
2012-01-21 21:57:41 +01:00
m_jump = 0;
m_selected = false;
m_moved = true;
2012-01-21 21:57:41 +01:00
return true;
}
void CCoverFlow::up(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
if (m_jump != 0) return;
LockMutex lock(m_mutex);
_left(m_minDelay, 1);
}
void CCoverFlow::down(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
if (m_jump != 0) return;
LockMutex lock(m_mutex);
_right(m_minDelay, 1);
}
void CCoverFlow::left(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
if (m_jump != 0) return;
LockMutex lock(m_mutex);
_left(m_minDelay, m_rows >= 3 ? m_rows - 2 : 1);
}
void CCoverFlow::right(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
if (m_jump != 0) return;
LockMutex lock(m_mutex);
_right(m_minDelay, m_rows >= 3 ? m_rows - 2 : 1);
}
2012-01-21 21:57:41 +01:00
void CCoverFlow::_left(int repeatDelay, u32 step)
{
int prev, arrStep;
if (m_delay > 0) return;
m_moved = true;
m_delay = repeatDelay;
m_covers[m_range / 2].angle += _coverMovesA();
m_covers[m_range / 2].pos += _coverMovesP();
if (m_rows >= 3)
{
prev = m_covers[m_range / 2].index;
// Shift the array to the right
arrStep = step % (m_rows - 2) + (step / (m_rows - 2)) * m_rows;
for (int i = (int)m_range - 1; i >= arrStep; --i)
m_covers[i] = m_covers[i - arrStep];
_loadAllCovers(loopNum((int)prev - step, m_items.size()));
_updateAllTargets();
if (arrStep % m_rows != 0)
for (u32 i = 0; i < m_columns; ++i)
_instantTarget(i * m_rows);
if (arrStep / m_rows != 0)
for (u32 i = 0; i < m_rows; ++i)
_instantTarget(i);
}
else
{
prev = m_covers[0].index;
// Shift the array to the right
for (int i = (int)m_range - 1; i > 0; --i)
m_covers[i] = m_covers[i - 1];
_loadCover(0, loopNum(prev - step, m_items.size()));
_updateAllTargets();
_instantTarget(0);
}
_playSound(m_flipSound);
2012-01-21 21:57:41 +01:00
m_covers[m_range / 2].angle -= _coverMovesA();
m_covers[m_range / 2].pos -= _coverMovesP();
}
void CCoverFlow::_right(int repeatDelay, u32 step)
{
int prev, arrStep;
if (m_delay > 0) return;
m_moved = true;
m_delay = repeatDelay;
m_covers[m_range / 2].angle += _coverMovesA();
m_covers[m_range / 2].pos += _coverMovesP();
if (m_rows >= 3)
{
prev = m_covers[m_range / 2].index;
// Shift the array to the left
arrStep = step % (m_rows - 2) + (step / (m_rows - 2)) * m_rows;
for (u32 i = 0; i < m_range - arrStep; ++i)
m_covers[i] = m_covers[i + arrStep];
_loadAllCovers(loopNum(prev + step, m_items.size()));
_updateAllTargets();
if (arrStep % m_rows != 0)
for (u32 i = 0; i < m_columns; ++i)
_instantTarget(i * m_rows + m_rows - 1);
if (arrStep / m_rows != 0)
for (u32 i = 0; i < m_rows; ++i)
_instantTarget(i + (m_columns - 1) * m_rows);
}
else
{
prev = m_covers[m_range - 1].index;
// Shift the array to the left
for (u32 i = 0; i < m_range - 1; ++i)
m_covers[i] = m_covers[i + 1];
_loadCover(m_range - 1, loopNum(prev + step, m_items.size()));
_updateAllTargets();
_instantTarget(m_range - 1);
}
_playSound(m_flipSound);
2012-01-21 21:57:41 +01:00
m_covers[m_range / 2].angle -= _coverMovesA();
m_covers[m_range / 2].pos -= _coverMovesP();
}
u32 CCoverFlow::_currentPos(void) const
{
if (m_covers == NULL) return 0;
2012-01-21 21:57:41 +01:00
return m_covers[m_range / 2].index;
}
void CCoverFlow::mouse(int chan, int x, int y)
2012-01-21 21:57:41 +01:00
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
int m = m_mouse[chan];
if (x < 0 || y < 0)
m_mouse[chan] = -1;
else
{
m_vid.prepareStencil();
2012-01-21 21:57:41 +01:00
_draw(CCoverFlow::CFDR_STENCIL, false, false);
m_vid.renderStencil();
m_mouse[chan] = m_vid.stencilVal(x, y) - 1;
2012-01-21 21:57:41 +01:00
}
if (m != m_mouse[chan])
{
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
if ((u32)m_mouse[chan] < m_range && m_mouse[chan] >= 0)
2012-01-21 21:57:41 +01:00
_playSound(m_hoverSound);
_updateAllTargets();
}
}
bool CCoverFlow::mouseOver(int x, int y)
2012-01-21 21:57:41 +01:00
{
if (m_covers == NULL) return false;
2012-01-21 21:57:41 +01:00
m_vid.prepareStencil();
2012-01-21 21:57:41 +01:00
_draw(CCoverFlow::CFDR_STENCIL, false, false);
m_vid.renderStencil();
m_vid.prepareStencil();
2012-01-21 21:57:41 +01:00
_draw(CCoverFlow::CFDR_STENCIL, false, false);
m_vid.renderStencil();
return m_vid.stencilVal(x, y) == (int)m_range / 2 + 1;
2012-01-21 21:57:41 +01:00
}
void CCoverFlow::setSelected(int i)
{
LockMutex lock(m_mutex);
m_moved = true;
_loadAllCovers(i);
_updateAllTargets(true);
select();
}
bool CCoverFlow::findId(const char *id, bool instant, bool path)
2012-01-21 21:57:41 +01:00
{
LockMutex lock(m_mutex);
u32 i, curPos = _currentPos();
if(m_items.empty() || (instant && m_covers == NULL) || strlen(id) == 0)
2012-01-21 21:57:41 +01:00
return false;
//
for(i = 0; i < m_items.size(); ++i)
{
if(path)
{
neek2o changes: - re made it possible to use SD emunands with sNeek2o r96. - added vwii r96 beta 9.6 support. wiiflow lite will now look for vwiikernal.bin and emunands must be in a subfolder of vwiinands on USB only. - when exiting a emunand game using neek2o if on wii it will use the back2nand channel to return you to wii system menu or if on wiiu it will return you to wiiu system channel because returning to the vwii system menu isn't possible. - when using wiiflow lite and exit to neek2o it will just launch neek2o system menu. from there you can launch wiiflow or wiiflow lite (if installed on emunand) to use cheats on a emunand game. otherwise cheats do not work when using neek2o to launch a game. banner changes: - now when moving from banner to banner the background music will not play and you will not see coverflow (for a second) when using full screen banners. - now on game selected categories menu the banner will change when you change games using '+' or '-' buttons - added custom banners for plugin games. no longer using trialer thp videos as banners for plugin games. put your custom banners in the custom banner folder plus the plugin cover folder and name them the same as the rom with extension plus .bnr just like how you do for the covers. to make a plugin game banner i suggest downloading one of abdallahterro's custom gamecube dios mios booter channels and use customizemii to change the images (and sound if you want). make sure the images match exactly the size of the one's already there. when changes are done extract the banner and rename it and put it in the proper folder as previously mentioned. other changes: - trailer videos still work even for plugin games. again for plugins rename the thp and ogg file to match the rom plus extension and .thp or .ogg. on game selected screen press '-' to start or quit a trailer video if one is available. pressing 'B' or 'Home' will quit the video and return you to the main screen. - when flipping a cover none of the buttons are available and the mini banner is not shown until you press 'B' to de flip the cover to normal front view. - fixed game info menu - in case a custom channel is selected and is not included in gametdb it will display a message 'no game info' instead of random stuff from the last game viewed. tested on wiiflow lite forwarder channel. - now stopping sounds and music early when exiting wiiflow to prevent music from stuttering when exiting. - other minor coding changes.
2017-05-15 19:50:24 +02:00
//homebrew folder or rom title.ext
const char *name = strrchr(m_items[i].hdr->path, '/');
if(name != NULL && strcmp(name + 1, id) == 0)
break;
neek2o changes: - re made it possible to use SD emunands with sNeek2o r96. - added vwii r96 beta 9.6 support. wiiflow lite will now look for vwiikernal.bin and emunands must be in a subfolder of vwiinands on USB only. - when exiting a emunand game using neek2o if on wii it will use the back2nand channel to return you to wii system menu or if on wiiu it will return you to wiiu system channel because returning to the vwii system menu isn't possible. - when using wiiflow lite and exit to neek2o it will just launch neek2o system menu. from there you can launch wiiflow or wiiflow lite (if installed on emunand) to use cheats on a emunand game. otherwise cheats do not work when using neek2o to launch a game. banner changes: - now when moving from banner to banner the background music will not play and you will not see coverflow (for a second) when using full screen banners. - now on game selected categories menu the banner will change when you change games using '+' or '-' buttons - added custom banners for plugin games. no longer using trialer thp videos as banners for plugin games. put your custom banners in the custom banner folder plus the plugin cover folder and name them the same as the rom with extension plus .bnr just like how you do for the covers. to make a plugin game banner i suggest downloading one of abdallahterro's custom gamecube dios mios booter channels and use customizemii to change the images (and sound if you want). make sure the images match exactly the size of the one's already there. when changes are done extract the banner and rename it and put it in the proper folder as previously mentioned. other changes: - trailer videos still work even for plugin games. again for plugins rename the thp and ogg file to match the rom plus extension and .thp or .ogg. on game selected screen press '-' to start or quit a trailer video if one is available. pressing 'B' or 'Home' will quit the video and return you to the main screen. - when flipping a cover none of the buttons are available and the mini banner is not shown until you press 'B' to de flip the cover to normal front view. - fixed game info menu - in case a custom channel is selected and is not included in gametdb it will display a message 'no game info' instead of random stuff from the last game viewed. tested on wiiflow lite forwarder channel. - now stopping sounds and music early when exiting wiiflow to prevent music from stuttering when exiting. - other minor coding changes.
2017-05-15 19:50:24 +02:00
else if(strcmp(m_items[i].hdr->path, id) == 0)// scummvm
break;
}
else if(strcmp(m_items[i].hdr->id, id) == 0)
break;
}
if(i >= m_items.size())
2012-01-21 21:57:41 +01:00
return false;
m_jump = 0;
if (instant)
{
_loadAllCovers(i);
_updateAllTargets(true);
2012-01-21 21:57:41 +01:00
}
else
{
int j = (int)i - (int)curPos;
if (abs(j) <= (int)m_items.size() / 2)
_setJump(j);
else
_setJump(j < 0 ? j + (int)m_items.size() : j - (int)m_items.size());
}
return true;
}
void CCoverFlow::pageUp(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
int n, j;
if (m_rows >= 3)
{
j = m_jump - max(1, (int)m_columns - 2);
if (m_jump != 0)
{
n = ((int)m_items.size() - 1) / (m_rows - 2) + 1;
j = j < 0 ? -(-j % n) : j % n;
}
j *= (int)m_rows - 2;
}
else
{
j = m_jump - max(1, (int)m_range / 2);
if (m_jump != 0)
{
n = (int)m_items.size();
j = j < 0 ? -(-j % n) : j % n;
}
}
_setJump(j);
}
void CCoverFlow::pageDown(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
int n, j;
if (m_rows >= 3)
{
j = m_jump + max(1, (int)m_columns - 2);
if (m_jump != 0)
{
n = ((int)m_items.size() - 1) / (m_rows - 2) + 1;
j = j < 0 ? -(-j % n) : j % n;
}
j *= (int)m_rows - 2;
}
else
{
j = m_jump + max(1, (int)m_range / 2);
if (m_jump != 0)
{
n = (int)m_items.size();
j = j < 0 ? -(-j % n) : j % n;
}
}
_setJump(j);
}
void CCoverFlow::flip(bool force, bool f)
{
if (m_covers == NULL || !m_selected) return;
2012-01-21 21:57:41 +01:00
LockMutex lock(m_mutex);
CCoverFlow::CCover &cvr = m_covers[m_range / 2];
if (!force)
f = m_loSelected.centerAngle == cvr.targetAngle && m_loSelected.centerPos == cvr.targetPos && m_loSelected.centerScale == cvr.targetScale;
if (f)
{
cvr.targetPos = m_loSelected.centerPos + m_flipCoverPos;
cvr.targetAngle = m_loSelected.centerAngle + m_flipCoverAngle;
cvr.targetScale = m_loSelected.centerScale * m_flipCoverScale;
cvr.txtTargetColor = m_flipCoverPos == Vector3D(0.f, 0.f, 0.f) ? 0xFF : 0;
}
else
{
cvr.targetPos = m_loSelected.centerPos;
cvr.targetAngle = m_loSelected.centerAngle;
cvr.targetScale = m_loSelected.centerScale;
cvr.txtTargetColor = 0xFF;
}
}
bool CCoverFlow::_invisibleCover(u32 x, u32 y)
{
return (m_rows > 1 && (y == 0 || y == m_rows - 1)) || x == 0 || x == m_columns - 1;
}
void CCoverFlow::_loadAllCovers(int i)
{
int r = (int)m_rows;
int c = (int)m_columns;
int s = (int)m_items.size();
if (m_rows >= 3)
for (int j = 0; j < r; ++j)
for (int k = 0; k < c; ++k)
_loadCover(j + k * r, loopNum(i + (j - r / 2) + (k - c / 2) * (r - 2), s));
else
for (int k = 0; k < (int)m_range; ++k)
_loadCover(k, loopNum(i + k - (int)m_range / 2, s));
}
void CCoverFlow::_setJump(int j)
{
_loadAllCovers(_currentPos());
m_jump = j;
if (m_jump == 0)
_updateAllTargets();
}
void CCoverFlow::_completeJump(void)
{
if (m_rows >= 3)
_loadAllCovers((int)m_covers[m_range / 2].index + m_jump);
else
{
if (m_jump < 0)
_loadAllCovers((int)m_covers[0].index + m_jump + (int)m_range / 2);
else
_loadAllCovers((int)m_covers[m_range - 1].index + m_jump - ((int)m_range - 1) / 2);
}
}
void CCoverFlow::nextLetter(wchar_t *c)
{
if (m_covers == NULL || m_sorting == SORT_BTN_NUMBERS)
2012-01-21 21:57:41 +01:00
{
c[0] = L'\0';
return;
}
if (m_sorting == SORT_WIFIPLAYERS || m_sorting == SORT_PLAYERS)
return nextPlayers(m_sorting == SORT_WIFIPLAYERS, c);
if (m_sorting == SORT_GAMEID)
return nextID(c);
LockMutex lock(m_mutex);
u32 i, j = 0, k = 0, n = m_items.size();
_completeJump();
u32 curPos = _currentPos();
while (!iswalnum(m_items[curPos].hdr->title[j]) && m_items[curPos].hdr->title[j+1] != L'\0') j++;
c[0] = upperCaseWChar(m_items[curPos].hdr->title[j]);
for (i = 1; i < n; ++i)
{
k = 0;
while (!iswalnum(m_items[loopNum(curPos + i, n)].hdr->title[k]) && m_items[loopNum(curPos + i, n)].hdr->title[k+1] != L'\0') k++;
if (upperCaseWChar(m_items[loopNum(curPos + i, n)].hdr->title[k]) != c[0])
break;
}
if (i < n)
{
_setJump(i);
c[0] = upperCaseWChar(m_items[loopNum(curPos + i, n)].hdr->title[k]);
}
_updateAllTargets();
}
void CCoverFlow::prevLetter(wchar_t *c)
{
if (m_covers == NULL || m_sorting == SORT_BTN_NUMBERS)
2012-01-21 21:57:41 +01:00
{
c[0] = L'\0';
return;
}
if (m_sorting == SORT_WIFIPLAYERS || m_sorting == SORT_PLAYERS)
return prevPlayers(m_sorting == SORT_WIFIPLAYERS, c);
if (m_sorting == SORT_GAMEID)
return prevID(c);
LockMutex lock(m_mutex);
u32 i, j = 0, k = 0, n = m_items.size();
_completeJump();
u32 curPos = _currentPos();
while (!iswalnum(m_items[curPos].hdr->title[j]) && m_items[curPos].hdr->title[j+1] != L'\0') j++;
c[0] = upperCaseWChar(m_items[curPos].hdr->title[j]);
for (i = 1; i < n; ++i)
{
k = 0;
while (!iswalnum(m_items[loopNum(curPos - i, n)].hdr->title[k]) && m_items[loopNum(curPos - i, n)].hdr->title[k+1] != L'\0') k++;
if (upperCaseWChar(m_items[loopNum(curPos - i, n)].hdr->title[k]) != c[0])
{
c[0] = upperCaseWChar(m_items[loopNum(curPos - i, n)].hdr->title[k]);
while(i < n)
{
++i;
k = 0;
while (!iswalnum(m_items[loopNum(curPos - i, n)].hdr->title[k]) && m_items[loopNum(curPos - i, n)].hdr->title[k+1] != L'\0') k++;
if(upperCaseWChar(m_items[loopNum(curPos - i, n)].hdr->title[k]) != c[0])
break;
}
i--;
break;
}
}
if (i < n)
{
_setJump(-i);
k = 0;
while (!iswalnum(m_items[loopNum(curPos - i, n)].hdr->title[k]) && m_items[loopNum(curPos - i, n)].hdr->title[k+1] != L'\0') k++;
c[0] = upperCaseWChar(m_items[loopNum(curPos - i, n)].hdr->title[k]);
}
_updateAllTargets();
}
void CCoverFlow::nextPlayers(bool wifi, wchar_t *c)
{
LockMutex lock(m_mutex);
u32 i, n = m_items.size();
_completeJump();
u32 curPos = _currentPos();
int players = wifi ? m_items[curPos].hdr->wifi : m_items[curPos].hdr->players;
2012-01-21 21:57:41 +01:00
for (i = 1; i < n; ++i)
if ((wifi ? m_items[loopNum(curPos + i, n)].hdr->wifi : m_items[loopNum(curPos + i, n)].hdr->players) != players)
2012-01-21 21:57:41 +01:00
break;
if (i < n)
{
_setJump(i);
players = wifi ? m_items[loopNum(curPos + i, n)].hdr->wifi : m_items[loopNum(curPos + i, n)].hdr->players;
2012-01-21 21:57:41 +01:00
}
char p[4] = {0 ,0 ,0 ,0};
sprintf(p, "%d", players);
mbstowcs(c, p, strlen(p));
_updateAllTargets();
}
void CCoverFlow::prevPlayers(bool wifi, wchar_t *c)
{
LockMutex lock(m_mutex);
u32 i, n = m_items.size();
_completeJump();
u32 curPos = _currentPos();
int players = wifi ? m_items[curPos].hdr->wifi : m_items[curPos].hdr->players;
2012-01-21 21:57:41 +01:00
for (i = 1; i < n; ++i)
if ((wifi ? m_items[loopNum(curPos - i, n)].hdr->wifi : m_items[loopNum(curPos - i, n)].hdr->players) != players)
2012-01-21 21:57:41 +01:00
{
players = wifi ? m_items[loopNum(curPos - i, n)].hdr->wifi : m_items[loopNum(curPos - i, n)].hdr->players;
while(i < n && (wifi ? m_items[loopNum(curPos - i, n)].hdr->wifi : m_items[loopNum(curPos - i, n)].hdr->players) == players) ++i;
2012-01-21 21:57:41 +01:00
i--;
break;
}
if (i < n)
{
_setJump(-i);
players = wifi ? m_items[loopNum(curPos - i, n)].hdr->wifi : m_items[loopNum(curPos - i, n)].hdr->players;
2012-01-21 21:57:41 +01:00
}
char p[4] = {0 ,0 ,0 ,0};
sprintf(p, "%d", players);
mbstowcs(c, p, strlen(p));
_updateAllTargets();
}
void CCoverFlow::nextID(wchar_t *c)
{
LockMutex lock(m_mutex);
u32 i, n = m_items.size();
_completeJump();
u32 curPos = _currentPos();
char *system = m_items[curPos].hdr->id;
2012-01-21 21:57:41 +01:00
for (i = 1; i < n; ++i)
if (m_items[loopNum(curPos + i, n)].hdr->id[0] != system[0])
2012-01-21 21:57:41 +01:00
break;
if (i < n)
{
_setJump(i);
system = m_items[loopNum(curPos + i, n)].hdr->id;
2012-01-21 21:57:41 +01:00
}
system[1] = '\0';
mbstowcs(c, system, 1);
_updateAllTargets();
}
void CCoverFlow::prevID(wchar_t *c)
{
LockMutex lock(m_mutex);
u32 i, n = m_items.size();
_completeJump();
u32 curPos = _currentPos();
char *system = m_items[curPos].hdr->id;
2012-01-21 21:57:41 +01:00
for(i = 1; i < n; ++i)
if(m_items[loopNum(curPos - i, n)].hdr->id[0] != system[0])
2012-01-21 21:57:41 +01:00
{
system = m_items[loopNum(curPos - i, n)].hdr->id;
while(i < n && m_items[loopNum(curPos - i, n)].hdr->id[0] == system[0]) ++i;
2012-01-21 21:57:41 +01:00
i--;
break;
}
if (i < n)
{
_setJump(-i);
system = m_items[loopNum(curPos - i, n)].hdr->id;
2012-01-21 21:57:41 +01:00
}
system[1] = '\0';
mbstowcs(c, system, 1);
2012-01-21 21:57:41 +01:00
_updateAllTargets();
}
void CCoverFlow::_coverTick(int i)
{
float speed = m_selected ? m_selected_speed : m_normal_speed;
2012-01-21 21:57:41 +01:00
Vector3D posDist(m_covers[i].targetPos - m_covers[i].pos);
if (posDist.sqNorm() < 0.5f)
speed *= 0.5f;
m_covers[i].angle += (m_covers[i].targetAngle - m_covers[i].angle) * speed;
m_covers[i].pos += posDist * speed;
m_covers[i].scale += (m_covers[i].targetScale - m_covers[i].scale) * speed;
if (m_covers[i].color != m_covers[i].targetColor)
{
CColor c(m_covers[i].color);
m_covers[i].color = CColor::interpolate(c, m_covers[i].targetColor, 0x20);
if (m_covers[i].color == c) // If the interpolation doesn't do anything because of numerical approximation, force the target color
m_covers[i].color = m_covers[i].targetColor;
}
if (m_covers[i].shadowColor != m_covers[i].targetShadowColor)
{
CColor c(m_covers[i].shadowColor);
m_covers[i].shadowColor = CColor::interpolate(c, m_covers[i].targetShadowColor, 0x20);
if (m_covers[i].shadowColor == c) // If the interpolation doesn't do anything because of numerical approximation, force the target color
m_covers[i].shadowColor = m_covers[i].targetShadowColor;
}
m_covers[i].txtAngle += (m_covers[i].txtTargetAngle - m_covers[i].txtAngle) * speed;
m_covers[i].txtPos += (m_covers[i].txtTargetPos - m_covers[i].txtPos) * speed;
int colorDist = (int)m_covers[i].txtTargetColor - (int)m_covers[i].txtColor;
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
m_covers[i].txtColor += abs(colorDist) >= 8 ? (u8)(colorDist / 8) : (u8)colorDist;
2012-01-21 21:57:41 +01:00
m_covers[i].title.tick();
}
void CCoverFlow::_unselect(void)
{
if (m_selected)
{
m_cameraPos += _cameraMoves();
m_covers[m_range / 2].angle += _coverMovesA();
m_covers[m_range / 2].pos += _coverMovesP();
m_selected = false;
m_covers[m_range / 2].angle -= _coverMovesA();
m_covers[m_range / 2].pos -= _coverMovesP();
m_cameraPos -= _cameraMoves();
m_targetCameraPos = m_loNormal.camera;
m_targetCameraAim = m_loNormal.cameraAim;
}
}
void CCoverFlow::_jump(void)
{
int step, delay = 2;
if (m_rows >= 3)
step = (u32)abs(m_jump) <= (m_rows - 2) / 2 ? 1 : m_rows - 2;
else
// Cheat and skip covers we wouldn't see anyway
// This means the jump shouldn't be modified before it's done completely
step = (u32)abs(m_jump) > m_range + 1 ? abs(m_jump) - (m_range + 1) : 1;
if (m_jump < 0)
{
_left(delay, step);
m_jump += step;
}
else if (m_jump > 0)
{
_right(delay, step);
m_jump -= step;
}
}
void CCoverFlow::tick(void)
{
if (m_covers == NULL) return;
2012-01-21 21:57:41 +01:00
LockMutex lock(m_mutex);
++m_tickCount;
if (m_delay > 0)
--m_delay;
else
_jump();
for (u32 i = 0; i < m_range; ++i)
_coverTick(i);
m_cameraPos += (m_targetCameraPos - m_cameraPos) * 0.2f;
m_cameraAim += (m_targetCameraAim - m_cameraAim) * 0.2f;
}
struct SWFCHeader
{
u8 newFmt : 1; // Was 0 in beta
u8 full : 1;
u8 cmpr : 1;
u8 zipped : 1;
u8 backCover : 1;
u16 width;
u16 height;
u8 maxLOD;
u16 backWidth;
u16 backHeight;
u8 backMaxLOD;
public:
u32 getWidth(void) const { return width * 4; }
u32 getHeight(void) const { return height * 4; }
u32 getBackWidth(void) const { return backWidth * 4; }
u32 getBackHeight(void) const { return backHeight * 4; }
SWFCHeader(void)
{
memset(this, 0, sizeof *this);
}
SWFCHeader(const TexData &tex, bool f, bool z, const TexData &backTex = TexData())
2012-01-21 21:57:41 +01:00
{
newFmt = 1;
full = f ? 1 : 0;
cmpr = tex.format == GX_TF_CMPR ? 1 : 0;
zipped = z ? 1 : 0;
width = tex.width / 4;
height = tex.height / 4;
maxLOD = tex.maxLOD;
backCover = !!backTex.data ? 1 : 0;
backWidth = backTex.width / 4;
backHeight = backTex.height / 4;
backMaxLOD = backTex.maxLOD;
}
};
bool CCoverFlow::cacheCoverFile(const char *wfcPath, const char *coverPath, bool full)
{
TexData tex;
u8 textureFmt = m_compressTextures ? GX_TF_CMPR : GX_TF_RGB565;
if(TexHandle.fromImageFile(tex, coverPath, textureFmt, 32) != TE_OK)
return false;
u32 bufSize = fixGX_GetTexBufferSize(tex.width, tex.height, tex.format, tex.maxLOD > 0 ? GX_TRUE : GX_FALSE, tex.maxLOD);
if(tex.data != NULL)
{
FILE *file = fopen(wfcPath, "wb");
if(file != NULL)
{
SWFCHeader header(tex, full, false);
fwrite(&header, 1, sizeof(header), file);
fwrite(tex.data, 1, bufSize, file);
fclose(file);
}
}
TexHandle.Cleanup(tex);
return true;
}
bool CCoverFlow::cacheCoverBuffer(const char *wfcPath, const u8 *png, bool full)
2012-01-21 21:57:41 +01:00
{
TexData tex;
2012-01-21 21:57:41 +01:00
u8 textureFmt = m_compressTextures ? GX_TF_CMPR : GX_TF_RGB565;
if(TexHandle.fromPNG(tex, png, textureFmt, 32) != TE_OK)
return false;
2012-01-21 21:57:41 +01:00
u32 bufSize = fixGX_GetTexBufferSize(tex.width, tex.height, tex.format, tex.maxLOD > 0 ? GX_TRUE : GX_FALSE, tex.maxLOD);
if(tex.data != NULL)
2012-01-21 21:57:41 +01:00
{
FILE *file = fopen(wfcPath, "wb");
if(file != NULL)
2012-01-21 21:57:41 +01:00
{
SWFCHeader header(tex, full, false);
fwrite(&header, 1, sizeof(header), file);
fwrite(tex.data, 1, bufSize, file);
fclose(file);
2012-01-21 21:57:41 +01:00
}
}
TexHandle.Cleanup(tex);
2012-01-21 21:57:41 +01:00
return true;
}
bool CCoverFlow::fullCoverCached(const char *wfcPath)
2012-01-21 21:57:41 +01:00
{
bool found = false;
FILE *file = fopen(wfcPath, "rb");
if(file != NULL)
2012-01-21 21:57:41 +01:00
{
SWFCHeader header;
found = fread(&header, 1, sizeof header, file) == sizeof header
&& header.full != 0 && m_compressTextures == (header.cmpr != 0)
&& header.getWidth() >= 8 && header.getHeight() >= 8
&& header.getWidth() <= 1090 && header.getHeight() <= 1090;
fclose(file);
2012-01-21 21:57:41 +01:00
}
return found;
}
bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
2012-01-21 21:57:41 +01:00
{
2018-11-13 23:08:25 +01:00
if(!m_loadingCovers)
return false;
2018-11-13 23:08:25 +01:00
/* get path to cover png or jpg */
const char *path = box ? (blankBoxCover ? mainMenu.getBlankCoverPath(m_items[i].hdr) :
mainMenu.getBoxPath(m_items[i].hdr)) : mainMenu.getFrontPath(m_items[i].hdr);
if(path == NULL)
return false;
2018-11-13 23:08:25 +01:00
/* copy path to coverPath */
size_t path_len = strlen(path);
char *coverPath = (char*)MEM2_alloc(path_len+1);
if(coverPath == NULL)
return false;
memset(coverPath, 0, path_len+1);
memcpy(coverPath, path, path_len);
DCFlushRange(coverPath, path_len+1);
2018-11-13 23:08:25 +01:00
/* load cover png or jpg as a new texture */
TexData tex;
tex.thread = true;
m_renderingTex = &tex;
2018-11-13 23:08:25 +01:00
u8 textureFmt = m_compressTextures ? GX_TF_CMPR : GX_TF_RGB565;
if(TexHandle.fromImageFile(tex, coverPath, textureFmt, 32) != TE_OK)
{
MEM2_free(coverPath);
m_renderingTex = NULL;
return false;
}
MEM2_free(coverPath);
m_renderingTex = NULL;
if(!m_loadingCovers)
return false;
2012-01-21 21:57:41 +01:00
2018-11-13 23:08:25 +01:00
/* set the current coverflow cover to the new texture */
2012-01-21 21:57:41 +01:00
LWP_MutexLock(m_mutex);
TexHandle.Cleanup(m_items[i].texture);
2012-01-21 21:57:41 +01:00
m_items[i].texture = tex;
m_items[i].boxTexture = box;
m_items[i].state = STATE_Ready;
2012-01-21 21:57:41 +01:00
LWP_MutexUnlock(m_mutex);
2018-11-13 23:08:25 +01:00
/* save the texture as a wfc file to the cache folder for the next time */
if(!m_cachePath.empty())
2012-01-21 21:57:41 +01:00
{
u32 bufSize = fixGX_GetTexBufferSize(tex.width, tex.height, tex.format, tex.maxLOD > 0 ? GX_TRUE : GX_FALSE, tex.maxLOD);
if(tex.data != NULL)
2012-01-21 21:57:41 +01:00
{
2018-11-13 23:08:25 +01:00
const char *wfcTitle = NULL;
const char *wfcCoverDir = NULL;
char *full_path = (char*)MEM2_alloc(MAX_FAT_PATH+1);
if(full_path == NULL)
return false;
memset(full_path, 0, MAX_FAT_PATH+1);
2018-11-13 23:08:25 +01:00
/* get title for wfc file */
if(blankBoxCover)
{
const char *blankCoverPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
if(blankCoverPath != NULL && strrchr(blankCoverPath, '/') != NULL)
2018-11-13 23:08:25 +01:00
wfcTitle = strrchr(blankCoverPath, '/') + 1;
else
return false;
}
else
2018-11-13 23:08:25 +01:00
wfcTitle = getFilenameId(m_items[i].hdr);
2018-11-13 23:08:25 +01:00
/* get coverfolder for plugins and sourceflow */
if(m_items[i].hdr->type == TYPE_PLUGIN && m_pluginCacheFolders && !blankBoxCover)
2018-11-13 23:08:25 +01:00
wfcCoverDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]);
if(m_items[i].hdr->type == TYPE_SOURCE && !blankBoxCover)
2018-11-13 23:08:25 +01:00
wfcCoverDir = "sourceflow";
/* make coverfolder if needed and set full path of wfc file */
if(wfcCoverDir != NULL)
{
2018-11-13 23:08:25 +01:00
fsop_MakeFolder(fmt("%s/%s", m_cachePath.c_str(), wfcCoverDir));// will make subfolders if needed
strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), wfcCoverDir, wfcTitle), MAX_FAT_PATH);
}
else
2018-11-13 23:08:25 +01:00
strncpy(full_path, fmt("%s/%s.wfc", m_cachePath.c_str(), wfcTitle), MAX_FAT_PATH);
DCFlushRange(full_path, MAX_FAT_PATH+1);
2018-11-13 23:08:25 +01:00
/* finally write the wfc file to the cache */
FILE *file;
file = fopen(full_path, "wb");
MEM2_free(full_path);
if(file != NULL)
2012-01-21 21:57:41 +01:00
{
SWFCHeader header(tex, box, false);
fwrite(&header, 1, sizeof(header), file);
fwrite(tex.data, 1, bufSize, file);
fclose(file);
2012-01-21 21:57:41 +01:00
}
}
}
2018-11-13 23:08:25 +01:00
/* note the wfc texture file is full LOD */
if(!hq)
_dropHQLOD(i);// drop Level Of Detail of texture
2012-01-21 21:57:41 +01:00
return true;
}
bool CCoverFlow::_calcTexLQLOD(TexData &tex)
2012-01-21 21:57:41 +01:00
{
bool done = false;
while (tex.width > 512 && tex.height > 512 && tex.maxLOD > 0)
{
--tex.maxLOD;
tex.width >>= 1;// divide by 2
tex.height >>= 1;// divide by 2
2012-01-21 21:57:41 +01:00
done = true;
}
return done;
}
void CCoverFlow::_dropHQLOD(int i)
{
if ((u32)i >= m_items.size()) return;
LockMutex lock(m_mutex);
const TexData &prevTex = m_items[i].texture;
if(prevTex.data == NULL)
return;
TexData newTex;
2012-01-21 21:57:41 +01:00
newTex.maxLOD = prevTex.maxLOD;
newTex.width = prevTex.width;
newTex.height = prevTex.height;
newTex.format = prevTex.format;
if (!CCoverFlow::_calcTexLQLOD(newTex)) return;
u32 prevTexLen = fixGX_GetTexBufferSize(prevTex.width, prevTex.height, prevTex.format, prevTex.maxLOD > 0 ? GX_TRUE : GX_FALSE, prevTex.maxLOD);
u32 newTexLen = fixGX_GetTexBufferSize(newTex.width, newTex.height, newTex.format, newTex.maxLOD > 0 ? GX_TRUE : GX_FALSE, newTex.maxLOD);
newTex.data = (u8*)MEM2_alloc(newTexLen);
if(newTex.data == NULL)
return;
memcpy(newTex.data, prevTex.data + (prevTexLen - newTexLen), newTexLen);
DCFlushRange(newTex.data, newTexLen);
TexHandle.Cleanup(m_items[i].texture);
m_items[i].texture = newTex;
2012-01-21 21:57:41 +01:00
}
const char *CCoverFlow::getFilenameId(const dir_discHdr *curHdr)
{
if(NoGameID(curHdr->type))
{
if(strrchr(curHdr->path, '/') != NULL)
return strrchr(curHdr->path, '/') + 1;// app folder or rom name.ext
else
return curHdr->path;// title for scummvm
}
return curHdr->id;// ID for Wii, GC, & Channels
}
CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blankBoxCover)
2012-01-21 21:57:41 +01:00
{
if(!m_loadingCovers)
return CL_ERROR;
2012-01-21 21:57:41 +01:00
if(box && m_smallBox)//prevent smallbox from loading full box cover
return CL_ERROR;
2012-01-21 21:57:41 +01:00
bool allocFailed = false;
2018-11-13 23:08:25 +01:00
/* try to find the wfc texture file in the cache folder */
if(!m_cachePath.empty())
2012-01-21 21:57:41 +01:00
{
2018-11-13 23:08:25 +01:00
const char *wfcTitle = NULL;
const char *wfcCoverDir = NULL;
char *full_path = (char*)MEM2_alloc(MAX_FAT_PATH+1);
if(full_path == NULL)
return CL_NOMEM;
memset(full_path, 0, MAX_FAT_PATH+1);
2018-11-13 23:08:25 +01:00
/* get title for wfc file */
if(blankBoxCover)
{
const char *blankCoverPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
if(blankCoverPath != NULL && strrchr(blankCoverPath, '/') != NULL)
2018-11-13 23:08:25 +01:00
wfcTitle = strrchr(blankCoverPath, '/') + 1;
else
return CL_ERROR;
}
else
2018-11-13 23:08:25 +01:00
wfcTitle = getFilenameId(m_items[i].hdr);
2018-11-13 23:08:25 +01:00
/* get coverfolder for plugins and sourceflow */
if(m_items[i].hdr->type == TYPE_PLUGIN && m_pluginCacheFolders && !blankBoxCover)
2018-11-13 23:08:25 +01:00
wfcCoverDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]);
if(m_items[i].hdr->type == TYPE_SOURCE && !blankBoxCover)
2018-11-13 23:08:25 +01:00
wfcCoverDir = "sourceflow";
/* set full path of wfc file */
if(wfcCoverDir != NULL)
strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), wfcCoverDir, wfcTitle), MAX_FAT_PATH);
else
2018-11-13 23:08:25 +01:00
strncpy(full_path, fmt("%s/%s.wfc", m_cachePath.c_str(), wfcTitle), MAX_FAT_PATH);
DCFlushRange(full_path, MAX_FAT_PATH+1);
2018-11-13 23:08:25 +01:00
/* load wfc file */
FILE *fp;
fp = fopen(full_path, "rb");
free(full_path);
if(fp != NULL)//if wfc chache file is found
2012-01-21 21:57:41 +01:00
{
bool success = false;
struct stat stat_buf;
if(fstat(fileno(fp), &stat_buf) != 0)
{
fclose(fp);
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
}
u32 fileSize = stat_buf.st_size;
2012-01-21 21:57:41 +01:00
SWFCHeader header;
-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
if(fileSize > sizeof(header))
2012-01-21 21:57:41 +01:00
{
-updated NIN_CFG_VERSION to 7 for Nintendont argsboot and added triforce arcade option to game settings menu. tested and working. -fixed wii u widescreen option in game config menu. should properly work now. thanks pBullet! -added a fix for coverflow titles display when coverflow has 3 or more rows. for some reason 3 or more rows caused the title to display improperly. -removed **disabled** message from source menu. no need for it - was a stupid idea. if you don't want it to display then remove it from your source menu or don't add it. when a view is disabled in wiiflow_lite.ini then only that view icon is disabled from showing on the main menu screen. -removed titles.ini which wasn't really used except for displaying the return to channel in settings. I googled it and nothing really showed up. it seemed to be the same as custom_titles.ini - it seemed useless. -removed cacheing sourceflow list. the list is never big enuff to worry about cacheing. plus if you add or remove source btns you won't have to reload cache for the changes to take effect. -removed max_source_btns from wiiflow_lite.ini - added code to get highest source menu btn so now source menu can have as many buttons as you like. -removed Manage Languages Menu - restored option to just change wiiflow language. no need for downloading languages and the google link didn't work anyway. when i make a pack all the languages will be included. -added flat cover options for sourceflow and homebrew view. can be turned on/off via their config menu's accessed via 'HOME' btn. -added config menu for homebrew view - press 'HOME' btn while in homebrew view to access it. config menu options are - switch apps partition, adjust coverflow, smallbox on/off, and flat covers on/off. -updated config menu for source menu/flow. options include - sourceflow on/off, adjust coverflow, smallbox on/off, flat covers on/off, and for source menu only - multisource on/off. -added coverflow layouts/versions for individual plugins - which means each plugin can have its own coverflow layout without affecting the others. -set HQ cover to default to ON -made it so coverflow doesn't reload every time you access another menu or change favorites or whatever. -added error messages to game and app launching if any of the bin files needed for launching are missing. previously whenever these errors occurred wiiflow would just exit without the user knowing why. Now the error message should display before exit so the user has an idea what went wrong. had to move cleanup() back some for the errors to show. hopefully that doesn't cause out of mem issues for users with large game collections. -added error messages to game config menu. now all config options will show but if you can't use it then a error shows telling you. such as 'use neek2o' will be available but if you set it to on and neek2o isn't installed then an error message shows. added error msgs for extracting and flashing saves too. -added show_mem=yes/no option to wiiflow_lite.ini under [DEBUG]. manually edit wiiflow_lite.ini to turn it on/off. if set to 'yes' wiiflow will show how much free mem is available on screen. no need to compile wiiflow for this option anymore. -cleaned up some of the boot up code. -starting a random game - just hold 'B' and press '-'. no longer press'B' on config or question mark icon and no need to allow it in wiiflow_lite.ini
2016-11-07 16:06:00 +01:00
if(fread(&header, 1, sizeof(header), fp) != sizeof(header))
{
fclose(fp);
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
}
//make sure wfc cache file matches what we want
if(header.newFmt == 1 && (header.full != 0) == box && (header.cmpr != 0) == m_compressTextures)
2012-01-21 21:57:41 +01:00
{
TexData tex;
2012-01-21 21:57:41 +01:00
tex.format = header.cmpr != 0 ? GX_TF_CMPR : GX_TF_RGB565;
tex.width = header.getWidth();
tex.height = header.getHeight();
tex.maxLOD = header.maxLOD;
2018-11-13 23:08:25 +01:00
/* note bufSize and texLen will be the same if cover is HQ */
2012-01-21 21:57:41 +01:00
u32 bufSize = fixGX_GetTexBufferSize(tex.width, tex.height, tex.format, tex.maxLOD > 0 ? GX_TRUE : GX_FALSE, tex.maxLOD);
if(!hq)
CCoverFlow::_calcTexLQLOD(tex);
2012-01-21 21:57:41 +01:00
u32 texLen = fixGX_GetTexBufferSize(tex.width, tex.height, tex.format, tex.maxLOD > 0 ? GX_TRUE : GX_FALSE, tex.maxLOD);
tex.data = (u8*)MEM2_alloc(texLen);
if(tex.data == NULL)
allocFailed = true;
else
{
2018-11-13 23:08:25 +01:00
/* if not HQ cover then skip (bufSize - texLen) texture data after header */
fseek(fp, sizeof(header) + (bufSize - texLen), SEEK_SET);
if(fread(tex.data, 1, texLen, fp) != texLen)
{
fclose(fp);
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
}
2012-01-21 21:57:41 +01:00
}
if(!allocFailed)
{
LockMutex lock(m_mutex);
TexHandle.Cleanup(m_items[i].texture);
m_items[i].texture = tex;
DCFlushRange(tex.data, texLen);
m_items[i].state = STATE_Ready;
m_items[i].boxTexture = header.full != 0;
success = true;
}
if(!success && tex.data != NULL)
{
free(tex.data);
tex.data = NULL;
}
2012-01-21 21:57:41 +01:00
}
}
fclose(fp);
if(success)
return CL_OK;
2012-01-21 21:57:41 +01:00
}
}
if(allocFailed)
return CL_NOMEM;
2012-01-21 21:57:41 +01:00
// If wfc cache file not found, load the PNG and create a wfc cache file
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
2012-01-21 21:57:41 +01:00
}
void * CCoverFlow::_coverLoader(void *obj)
2012-01-21 21:57:41 +01:00
{
CCoverFlow *cf = static_cast<CCoverFlow *>(obj);
cf->m_coverThrdBusy = true;
CLRet ret;
u32 firstItem;
bool update;
u32 i, j;
bool hq_req = cf->m_useHQcover;
bool cur_pos_hq = false;
u32 bufferSize = min(cf->m_numBufCovers * max(2ul, cf->m_rows), 80ul);
2012-01-21 21:57:41 +01:00
while(cf->m_loadingCovers)
2012-01-21 21:57:41 +01:00
{
update = cf->m_moved;
2012-01-21 21:57:41 +01:00
cf->m_moved = false;
firstItem = cf->m_covers[cf->m_range / 2].index;
for(j = cf->m_items.size(); j >= bufferSize && !cf->m_moved && update; --j)
2012-01-21 21:57:41 +01:00
{
i = loopNum((j & 1) ? firstItem - (j + 1) / 2 : firstItem + j / 2, cf->m_items.size());
if(cf->m_items[i].state != STATE_Loading)
{
LWP_MutexLock(cf->m_mutex);
TexHandle.Cleanup(cf->m_items[i].texture);
cf->m_items[i].state = STATE_Loading;
LWP_MutexUnlock(cf->m_mutex);
}
2012-01-21 21:57:41 +01:00
}
ret = CL_OK;
for(j = 0; j <= bufferSize && !cf->m_moved && update && ret != CL_NOMEM; ++j)
2012-01-21 21:57:41 +01:00
{
i = loopNum((j & 1) ? firstItem - (j + 1) / 2 : firstItem + j / 2, cf->m_items.size());
cur_pos_hq = (hq_req && i == firstItem);
if((!hq_req || !cur_pos_hq) && cf->m_items[i].state != STATE_Loading)
continue;
if((ret = cf->_loadCoverTex(i, cf->m_box, cur_pos_hq, false)) == CL_ERROR)
2012-01-21 21:57:41 +01:00
{
if ((ret = cf->_loadCoverTex(i, !cf->m_box, cur_pos_hq, false)) == CL_ERROR)
{
if((ret = cf->_loadCoverTex(i, cf->m_box, cur_pos_hq, true)) == CL_ERROR)
cf->m_items[i].state = STATE_NoCover;
}
2012-01-21 21:57:41 +01:00
}
}
if(ret == CL_NOMEM && bufferSize > 3)
2012-01-21 21:57:41 +01:00
bufferSize -= 2;
}
cf->m_coverThrdBusy = false;
2012-01-21 21:57:41 +01:00
return 0;
}