mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-24 04:09:15 +01:00
- finally seem to have fixed the random messed up cover!
- fixed the hover over sound for the main settings button. you may not have noticed but sometimes it didn't make that sound. now it does all the time. - adjusted the game info synopsis scrolling and line height so the text isn't all smashed together vertically.
This commit is contained in:
parent
5cefb92df7
commit
f72def02ba
BIN
out/boot.dol
BIN
out/boot.dol
Binary file not shown.
Before Width: | Height: | Size: 3.1 MiB After Width: | Height: | Size: 3.1 MiB |
@ -18,4 +18,4 @@ const u8 WFB_HASH[] = { 0x4f, 0xad, 0x97, 0xfd, 0x4a, 0x28, 0x8c, 0x47, 0xe0,
|
|||||||
#define TITLEFONT TITLEFONT_PT_SZ, TITLEFONT_PT_SZ - 4, FONT_BOLD, 1, "title_font"
|
#define TITLEFONT TITLEFONT_PT_SZ, TITLEFONT_PT_SZ - 4, FONT_BOLD, 1, "title_font"
|
||||||
#define BUTTONFONT BTNFONT_PT_SZ, BTNFONT_PT_SZ - 4, FONT_BOLD, 1, "button_font"
|
#define BUTTONFONT BTNFONT_PT_SZ, BTNFONT_PT_SZ - 4, FONT_BOLD, 1, "button_font"
|
||||||
#define LABELFONT LBLFONT_PT_SZ, LBLFONT_PT_SZ, FONT_BOLD, 1, "label_font"
|
#define LABELFONT LBLFONT_PT_SZ, LBLFONT_PT_SZ, FONT_BOLD, 1, "label_font"
|
||||||
#define TEXTFONT TEXTFONT_PT_SZ, TEXTFONT_PT_SZ, FONT_BOLD, 1, "text_font"
|
#define TEXTFONT TEXTFONT_PT_SZ, TEXTFONT_PT_SZ + 6, FONT_BOLD, 1, "text_font"
|
@ -2612,27 +2612,29 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
|
|||||||
if(!m_loadingCovers) return false;
|
if(!m_loadingCovers) return false;
|
||||||
|
|
||||||
u8 textureFmt = m_compressTextures ? GX_TF_CMPR : GX_TF_RGB565;
|
u8 textureFmt = m_compressTextures ? GX_TF_CMPR : GX_TF_RGB565;
|
||||||
|
|
||||||
const char *path = box ? (blankBoxCover ? mainMenu.getBlankCoverPath(m_items[i].hdr) :
|
const char *path = box ? (blankBoxCover ? mainMenu.getBlankCoverPath(m_items[i].hdr) :
|
||||||
mainMenu.getBoxPath(m_items[i].hdr)) : mainMenu.getFrontPath(m_items[i].hdr);
|
mainMenu.getBoxPath(m_items[i].hdr)) : mainMenu.getFrontPath(m_items[i].hdr);
|
||||||
if(path == NULL)
|
if(path == NULL)
|
||||||
return false;
|
return false;
|
||||||
size_t path_len = strlen(path);
|
size_t path_len = strlen(path);
|
||||||
char *path_place = (char*)MEM2_alloc(path_len+1);
|
char *coverPath = (char*)MEM2_alloc(path_len+1);
|
||||||
if(path_place == NULL)
|
if(coverPath == NULL)
|
||||||
return false;
|
return false;
|
||||||
memset(path_place, 0, path_len+1);
|
memset(coverPath, 0, path_len+1);
|
||||||
memcpy(path_place, path, path_len);
|
memcpy(coverPath, path, path_len);
|
||||||
DCFlushRange(path_place, path_len+1);
|
DCFlushRange(coverPath, path_len+1);
|
||||||
|
|
||||||
TexData tex;
|
TexData tex;
|
||||||
tex.thread = true;
|
tex.thread = true;
|
||||||
m_renderingTex = &tex;
|
m_renderingTex = &tex;
|
||||||
if(TexHandle.fromImageFile(tex, path_place, textureFmt, 32) != TE_OK)
|
if(TexHandle.fromImageFile(tex, coverPath, textureFmt, 32) != TE_OK)
|
||||||
{
|
{
|
||||||
MEM2_free(path_place);
|
MEM2_free(coverPath);
|
||||||
m_renderingTex = NULL;
|
m_renderingTex = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MEM2_free(path_place);
|
MEM2_free(coverPath);
|
||||||
m_renderingTex = NULL;
|
m_renderingTex = NULL;
|
||||||
if(!m_loadingCovers)
|
if(!m_loadingCovers)
|
||||||
return false;
|
return false;
|
||||||
@ -2653,28 +2655,7 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
|
|||||||
if(zBuffer != NULL && (!m_compressCache || compress(zBuffer, &zBufferSize, tex.data, bufSize) == Z_OK))
|
if(zBuffer != NULL && (!m_compressCache || compress(zBuffer, &zBufferSize, tex.data, bufSize) == Z_OK))
|
||||||
{
|
{
|
||||||
const char *gameNameOrID = NULL;
|
const char *gameNameOrID = NULL;
|
||||||
const char *coverDir = NULL;
|
const char *coverWfcDir = NULL;
|
||||||
if(blankBoxCover)
|
|
||||||
{
|
|
||||||
const char *menuPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
|
|
||||||
if(menuPath != NULL && strrchr(menuPath, '/') != NULL)
|
|
||||||
gameNameOrID = strrchr(menuPath, '/') + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gameNameOrID = getPathId(m_items[i].hdr);
|
|
||||||
if(NoGameID(m_items[i].hdr->type))
|
|
||||||
{
|
|
||||||
if(m_pluginCacheFolders && m_items[i].hdr->type == TYPE_PLUGIN)
|
|
||||||
coverDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]);
|
|
||||||
if(m_items[i].hdr->type == TYPE_SOURCE)
|
|
||||||
coverDir = "sourceflow";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE *file = NULL;
|
|
||||||
if(gameNameOrID != NULL)
|
|
||||||
{
|
|
||||||
char *full_path = (char*)MEM2_alloc(MAX_FAT_PATH+1);
|
char *full_path = (char*)MEM2_alloc(MAX_FAT_PATH+1);
|
||||||
if(full_path == NULL)
|
if(full_path == NULL)
|
||||||
{
|
{
|
||||||
@ -2683,14 +2664,27 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
memset(full_path, 0, MAX_FAT_PATH+1);
|
memset(full_path, 0, MAX_FAT_PATH+1);
|
||||||
if(coverDir == NULL || strlen(coverDir) == 0)
|
|
||||||
strncpy(full_path, fmt("%s/%s.wfc", m_cachePath.c_str(), gameNameOrID), MAX_FAT_PATH);
|
if(blankBoxCover)
|
||||||
|
{
|
||||||
|
const char *blankCoverPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
|
||||||
|
if(blankCoverPath != NULL && strrchr(blankCoverPath, '/') != NULL)
|
||||||
|
gameNameOrID = strrchr(blankCoverPath, '/') + 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
gameNameOrID = getPathId(m_items[i].hdr);
|
||||||
|
|
||||||
|
if(m_items[i].hdr->type == TYPE_PLUGIN && m_pluginCacheFolders && !blankBoxCover)
|
||||||
|
coverWfcDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]);
|
||||||
|
if(m_items[i].hdr->type == TYPE_SOURCE && !blankBoxCover)
|
||||||
|
coverWfcDir = "sourceflow";
|
||||||
|
if(coverWfcDir != NULL)
|
||||||
{
|
{
|
||||||
if(strchr(coverDir, '/') != NULL)
|
//check if coverWfcDir includes subfolders & make them
|
||||||
|
if(strchr(coverWfcDir, '/') != NULL)
|
||||||
{
|
{
|
||||||
char *tmp = (char*)MEM2_alloc(strlen(coverDir)+1);
|
char *tmp = (char*)MEM2_alloc(strlen(coverWfcDir)+1);
|
||||||
strncpy(tmp, coverDir, strlen(coverDir));
|
strncpy(tmp, coverWfcDir, strlen(coverWfcDir));
|
||||||
char *help = tmp;
|
char *help = tmp;
|
||||||
while(help != NULL && strchr(help, '/') != NULL)
|
while(help != NULL && strchr(help, '/') != NULL)
|
||||||
{
|
{
|
||||||
@ -2702,13 +2696,17 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
|
|||||||
}
|
}
|
||||||
MEM2_free(tmp);
|
MEM2_free(tmp);
|
||||||
}
|
}
|
||||||
fsop_MakeFolder(fmt("%s/%s", m_cachePath.c_str(), coverDir));
|
fsop_MakeFolder(fmt("%s/%s", m_cachePath.c_str(), coverWfcDir));
|
||||||
strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), coverDir, gameNameOrID), MAX_FAT_PATH);
|
strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), coverWfcDir, gameNameOrID), MAX_FAT_PATH);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
strncpy(full_path, fmt("%s/%s.wfc", m_cachePath.c_str(), gameNameOrID), MAX_FAT_PATH);
|
||||||
|
|
||||||
DCFlushRange(full_path, MAX_FAT_PATH+1);
|
DCFlushRange(full_path, MAX_FAT_PATH+1);
|
||||||
|
//finally write the wfc file to the cache
|
||||||
|
FILE *file;
|
||||||
file = fopen(full_path, "wb");
|
file = fopen(full_path, "wb");
|
||||||
MEM2_free(full_path);
|
MEM2_free(full_path);
|
||||||
}
|
|
||||||
if(file != NULL)
|
if(file != NULL)
|
||||||
{
|
{
|
||||||
SWFCHeader header(tex, box, m_compressCache);
|
SWFCHeader header(tex, box, m_compressCache);
|
||||||
@ -2772,22 +2770,22 @@ void CCoverFlow::_dropHQLOD(int i)
|
|||||||
|
|
||||||
const char *CCoverFlow::getPathId(const dir_discHdr *curHdr, bool extension)
|
const char *CCoverFlow::getPathId(const dir_discHdr *curHdr, bool extension)
|
||||||
{
|
{
|
||||||
const char *TitleOrID = NULL;
|
const char *NameOrID = NULL;
|
||||||
if(NoGameID(curHdr->type))
|
if(NoGameID(curHdr->type))
|
||||||
{
|
{
|
||||||
if(strrchr(curHdr->path, '/') != NULL)
|
if(strrchr(curHdr->path, '/') != NULL)
|
||||||
{
|
{
|
||||||
if(curHdr->type == TYPE_HOMEBREW || extension)
|
if(curHdr->type == TYPE_HOMEBREW || extension)
|
||||||
TitleOrID = strrchr(curHdr->path, '/') + 1;//returns title.ext or folder name for boot.dol
|
NameOrID = strrchr(curHdr->path, '/') + 1;//returns title.ext or folder name for boot.dol
|
||||||
else
|
else
|
||||||
TitleOrID = fmt("%ls", curHdr->title);// title without extension in lowercase
|
NameOrID = fmt("%ls", curHdr->title);// title without extension in lowercase
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TitleOrID = curHdr->path;//title for scummvm
|
NameOrID = curHdr->path;//title for scummvm
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TitleOrID = curHdr->id;// ID for Wii, GC, & Channels
|
NameOrID = curHdr->id;// ID for Wii, GC, & Channels
|
||||||
return TitleOrID;
|
return NameOrID;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blankBoxCover)
|
CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blankBoxCover)
|
||||||
@ -2801,7 +2799,12 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
|
|||||||
if(!m_cachePath.empty())
|
if(!m_cachePath.empty())
|
||||||
{
|
{
|
||||||
const char *gameNameOrID = NULL;
|
const char *gameNameOrID = NULL;
|
||||||
const char *coverDir = NULL;
|
const char *coverWfcDir = 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);
|
||||||
|
|
||||||
if(blankBoxCover)
|
if(blankBoxCover)
|
||||||
{
|
{
|
||||||
const char *blankCoverPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
|
const char *blankCoverPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
|
||||||
@ -2809,32 +2812,22 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
|
|||||||
gameNameOrID = strrchr(blankCoverPath, '/') + 1;
|
gameNameOrID = strrchr(blankCoverPath, '/') + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
gameNameOrID = getPathId(m_items[i].hdr);
|
gameNameOrID = getPathId(m_items[i].hdr);
|
||||||
if(NoGameID(m_items[i].hdr->type))
|
|
||||||
{
|
|
||||||
if(m_pluginCacheFolders && m_items[i].hdr->type == TYPE_PLUGIN)
|
|
||||||
coverDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]);
|
|
||||||
if(m_items[i].hdr->type == TYPE_SOURCE)
|
|
||||||
coverDir = "sourceflow";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE *fp = NULL;
|
if(m_items[i].hdr->type == TYPE_PLUGIN && m_pluginCacheFolders && !blankBoxCover)
|
||||||
if(gameNameOrID != NULL)
|
coverWfcDir = m_plugin.GetCoverFolderName(m_items[i].hdr->settings[0]);
|
||||||
{
|
if(m_items[i].hdr->type == TYPE_SOURCE && !blankBoxCover)
|
||||||
char *full_path = (char*)MEM2_alloc(MAX_FAT_PATH+1);
|
coverWfcDir = "sourceflow";
|
||||||
if(full_path == NULL)
|
if(coverWfcDir != NULL)
|
||||||
return CL_NOMEM;
|
strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), coverWfcDir, gameNameOrID), MAX_FAT_PATH);
|
||||||
memset(full_path, 0, MAX_FAT_PATH+1);
|
|
||||||
if(coverDir == NULL || strlen(coverDir) == 0)
|
|
||||||
strncpy(full_path, fmt("%s/%s.wfc", m_cachePath.c_str(), gameNameOrID), MAX_FAT_PATH);
|
|
||||||
else
|
else
|
||||||
strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), coverDir, gameNameOrID), MAX_FAT_PATH);
|
strncpy(full_path, fmt("%s/%s.wfc", m_cachePath.c_str(), gameNameOrID), MAX_FAT_PATH);
|
||||||
|
|
||||||
DCFlushRange(full_path, MAX_FAT_PATH+1);
|
DCFlushRange(full_path, MAX_FAT_PATH+1);
|
||||||
|
FILE *fp;
|
||||||
fp = fopen(full_path, "rb");
|
fp = fopen(full_path, "rb");
|
||||||
MEM2_free(full_path);
|
free(full_path);
|
||||||
}
|
|
||||||
if(fp != NULL)//if wfc chache file is found
|
if(fp != NULL)//if wfc chache file is found
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
@ -2845,10 +2838,16 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
|
|||||||
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
|
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
|
||||||
}
|
}
|
||||||
u32 fileSize = stat_buf.st_size;
|
u32 fileSize = stat_buf.st_size;
|
||||||
|
|
||||||
SWFCHeader header;
|
SWFCHeader header;
|
||||||
if(fileSize > sizeof header)
|
if(fileSize > sizeof header)
|
||||||
{
|
{
|
||||||
fread(&header, 1, sizeof header, fp);
|
size_t readLen;
|
||||||
|
do {
|
||||||
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
readLen = fread(&header, 1, sizeof header, fp);
|
||||||
|
} while (readLen != sizeof header);
|
||||||
|
//fread(&header, 1, sizeof header, fp);
|
||||||
//make sure wfc cache file matches what we want
|
//make sure wfc cache file matches what we want
|
||||||
if(header.newFmt == 1 && (header.full != 0) == box && (header.cmpr != 0) == m_compressTextures)
|
if(header.newFmt == 1 && (header.full != 0) == box && (header.cmpr != 0) == m_compressTextures)
|
||||||
{
|
{
|
||||||
@ -2868,30 +2867,34 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
|
|||||||
if(header.zipped != 0)//if it's compressed ie. zipped
|
if(header.zipped != 0)//if it's compressed ie. zipped
|
||||||
{
|
{
|
||||||
u8 *ptrTex = (u8*)MEM2_alloc(bufSize);
|
u8 *ptrTex = (u8*)MEM2_alloc(bufSize);
|
||||||
if(ptrTex == NULL)
|
u8 *zBuffer = (u8*)MEM2_alloc(fileSize - sizeof header);
|
||||||
|
if(ptrTex == NULL || zBuffer == NULL)
|
||||||
allocFailed = true;
|
allocFailed = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 *zBuffer = (u8*)MEM2_alloc(fileSize - sizeof header);
|
size_t readLen;
|
||||||
if(zBuffer != NULL)
|
do {
|
||||||
{
|
fseek(fp, sizeof header, SEEK_SET);
|
||||||
fread(zBuffer, 1, fileSize - sizeof header, fp);
|
readLen = fread(zBuffer, 1, fileSize - sizeof header, fp);
|
||||||
|
} while (readLen != (fileSize - sizeof header));
|
||||||
uLongf size = bufSize;
|
uLongf size = bufSize;
|
||||||
if(uncompress(ptrTex, &size, zBuffer, fileSize - sizeof header) == Z_OK && size == bufSize)
|
if(uncompress(ptrTex, &size, zBuffer, fileSize - sizeof header) == Z_OK && size == bufSize)
|
||||||
memcpy(tex.data, ptrTex + bufSize - texLen, texLen);
|
memcpy(tex.data, ptrTex + bufSize - texLen, texLen);
|
||||||
|
}
|
||||||
free(zBuffer);
|
free(zBuffer);
|
||||||
free(ptrTex);
|
free(ptrTex);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(tex.data == NULL)
|
if(tex.data == NULL)
|
||||||
allocFailed = true;
|
allocFailed = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fseek(fp, fileSize - sizeof header - texLen, SEEK_CUR);
|
size_t readLen;
|
||||||
fread(tex.data, 1, texLen, fp);
|
do {
|
||||||
|
fseek(fp, sizeof header + bufSize - texLen, SEEK_SET);
|
||||||
|
readLen = fread(tex.data, 1, texLen, fp);
|
||||||
|
} while (readLen != texLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!allocFailed)
|
if(!allocFailed)
|
||||||
@ -2921,7 +2924,6 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
|
|||||||
|
|
||||||
// If wfc cache file not found, load the PNG and create a wfc cache file
|
// 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;
|
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
|
||||||
//return CL_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCoverFlow::_coverLoader(CCoverFlow *cf)
|
int CCoverFlow::_coverLoader(CCoverFlow *cf)
|
||||||
@ -2939,9 +2941,9 @@ int CCoverFlow::_coverLoader(CCoverFlow *cf)
|
|||||||
{
|
{
|
||||||
update = cf->m_moved;
|
update = cf->m_moved;
|
||||||
cf->m_moved = false;
|
cf->m_moved = false;
|
||||||
for(j = cf->m_items.size(); j >= bufferSize && cf->m_loadingCovers && !cf->m_moved && update; --j)
|
|
||||||
{
|
|
||||||
firstItem = cf->m_covers[cf->m_range / 2].index;
|
firstItem = cf->m_covers[cf->m_range / 2].index;
|
||||||
|
for(j = cf->m_items.size(); j >= bufferSize && !cf->m_moved && update; --j)
|
||||||
|
{
|
||||||
i = loopNum((j & 1) ? firstItem - (j + 1) / 2 : firstItem + j / 2, cf->m_items.size());
|
i = loopNum((j & 1) ? firstItem - (j + 1) / 2 : firstItem + j / 2, cf->m_items.size());
|
||||||
if(cf->m_items[i].state != STATE_Loading)
|
if(cf->m_items[i].state != STATE_Loading)
|
||||||
{
|
{
|
||||||
@ -2952,9 +2954,8 @@ int CCoverFlow::_coverLoader(CCoverFlow *cf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = CL_OK;
|
ret = CL_OK;
|
||||||
for(j = 0; j <= bufferSize && cf->m_loadingCovers && !cf->m_moved && update && ret != CL_NOMEM; ++j)
|
for(j = 0; j <= bufferSize && !cf->m_moved && update && ret != CL_NOMEM; ++j)
|
||||||
{
|
{
|
||||||
firstItem = cf->m_covers[cf->m_range / 2].index;
|
|
||||||
i = loopNum((j & 1) ? firstItem - (j + 1) / 2 : firstItem + j / 2, cf->m_items.size());
|
i = loopNum((j & 1) ? firstItem - (j + 1) / 2 : firstItem + j / 2, cf->m_items.size());
|
||||||
cur_pos_hq = (hq_req && i == firstItem);
|
cur_pos_hq = (hq_req && i == firstItem);
|
||||||
if((!hq_req || !cur_pos_hq) && cf->m_items[i].state != STATE_Loading)
|
if((!hq_req || !cur_pos_hq) && cf->m_items[i].state != STATE_Loading)
|
||||||
|
@ -196,7 +196,7 @@ private:
|
|||||||
Vector3D bottomDeltaAngle;
|
Vector3D bottomDeltaAngle;
|
||||||
};
|
};
|
||||||
enum TexState { STATE_Loading, STATE_Ready, STATE_NoCover };
|
enum TexState { STATE_Loading, STATE_Ready, STATE_NoCover };
|
||||||
struct CItem
|
struct CItem//should be SItem because it's a struct
|
||||||
{
|
{
|
||||||
CItem(dir_discHdr *itemHdr, int playcount, unsigned int lastPlayed);
|
CItem(dir_discHdr *itemHdr, int playcount, unsigned int lastPlayed);
|
||||||
dir_discHdr *hdr;
|
dir_discHdr *hdr;
|
||||||
@ -206,7 +206,7 @@ private:
|
|||||||
volatile bool boxTexture;
|
volatile bool boxTexture;
|
||||||
volatile enum TexState state;
|
volatile enum TexState state;
|
||||||
} ATTRIBUTE_PACKED;
|
} ATTRIBUTE_PACKED;
|
||||||
struct CCover
|
struct CCover// should be SCover because it's a struct
|
||||||
{
|
{
|
||||||
u32 index;
|
u32 index;
|
||||||
Vector3D scale;
|
Vector3D scale;
|
||||||
|
@ -37,7 +37,6 @@ s16 CButtonsMgr::addButton(SFont font, const wstringEx &text, int x, int y, u32
|
|||||||
|
|
||||||
b->font = font;
|
b->font = font;
|
||||||
b->visible = false;
|
b->visible = false;
|
||||||
//b->text = text;
|
|
||||||
b->text.setText(b->font, text);
|
b->text.setText(b->font, text);
|
||||||
b->textColor = color;
|
b->textColor = color;
|
||||||
b->x = x + width / 2;
|
b->x = x + width / 2;
|
||||||
@ -63,6 +62,213 @@ s16 CButtonsMgr::addButton(SFont font, const wstringEx &text, int x, int y, u32
|
|||||||
return m_elts.size() > sz ? m_elts.size() - 1 : -2;
|
return m_elts.size() > sz ? m_elts.size() - 1 : -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s16 CButtonsMgr::addLabel(SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color, s16 style, const TexData &bg)
|
||||||
|
{
|
||||||
|
SLabel *b = new SLabel;
|
||||||
|
|
||||||
|
b->font = font;
|
||||||
|
b->visible = false;
|
||||||
|
b->textStyle = style;
|
||||||
|
b->text.setText(b->font, text);
|
||||||
|
b->text.setFrame(width, b->textStyle, false, true);
|
||||||
|
b->textColor = color;
|
||||||
|
b->x = x + width / 2;
|
||||||
|
b->y = y + height / 2;
|
||||||
|
b->w = width;
|
||||||
|
b->h = height;
|
||||||
|
b->alpha = 0;
|
||||||
|
b->targetAlpha = 0;
|
||||||
|
b->scaleX = 0.f;
|
||||||
|
b->scaleY = 0.f;
|
||||||
|
b->targetScaleX = 0.f;
|
||||||
|
b->targetScaleY = 0.f;
|
||||||
|
b->texBg = bg;
|
||||||
|
b->moveByX = 0;
|
||||||
|
b->moveByY = 0;
|
||||||
|
|
||||||
|
u32 sz = m_elts.size();
|
||||||
|
m_elts.push_back(b);
|
||||||
|
|
||||||
|
return m_elts.size() > sz ? m_elts.size() - 1 : -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
s16 CButtonsMgr::addProgressBar(int x, int y, u32 width, u32 height, SButtonTextureSet &texSet)
|
||||||
|
{
|
||||||
|
SProgressBar *b = new SProgressBar;
|
||||||
|
|
||||||
|
b->visible = false;
|
||||||
|
b->x = x + width / 2;
|
||||||
|
b->y = y + height / 2;
|
||||||
|
b->w = width;
|
||||||
|
b->h = height;
|
||||||
|
b->alpha = 0;
|
||||||
|
b->targetAlpha = 0;
|
||||||
|
b->scaleX = 0.f;
|
||||||
|
b->scaleY = 0.f;
|
||||||
|
b->targetScaleX = 0.f;
|
||||||
|
b->targetScaleY = 0.f;
|
||||||
|
b->tex = texSet;
|
||||||
|
b->val = 0.f;
|
||||||
|
b->targetVal = 0.f;
|
||||||
|
b->moveByX = 0;
|
||||||
|
b->moveByY = 0;
|
||||||
|
|
||||||
|
u32 sz = m_elts.size();
|
||||||
|
m_elts.push_back(b);
|
||||||
|
|
||||||
|
return m_elts.size() > sz ? m_elts.size() - 1 : -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
s16 CButtonsMgr::addPicButton(TexData &texNormal, TexData &texSelected, int x, int y, u32 width, u32 height, GuiSound *clickSound, GuiSound *hoverSound)
|
||||||
|
{
|
||||||
|
SButtonTextureSet texSet;
|
||||||
|
|
||||||
|
texSet.center = texNormal;
|
||||||
|
texSet.centerSel = texSelected;
|
||||||
|
return addButton(SFont(), wstringEx(), x, y, width, height, CColor(), texSet, clickSound, hoverSound);
|
||||||
|
}
|
||||||
|
|
||||||
|
s16 CButtonsMgr::addPicButton(const u8 *pngNormal, const u8 *pngSelected, int x, int y, u32 width, u32 height, GuiSound *clickSound, GuiSound *hoverSound)
|
||||||
|
{
|
||||||
|
SButtonTextureSet texSet;
|
||||||
|
|
||||||
|
TexHandle.fromPNG(texSet.center, pngNormal);
|
||||||
|
TexHandle.fromPNG(texSet.centerSel, pngSelected);
|
||||||
|
return addButton(SFont(), wstringEx(), x, y, width, height, CColor(), texSet, clickSound, hoverSound);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::setText(s16 id, const wstringEx &text, bool unwrap)// unwrap means no wrap
|
||||||
|
{
|
||||||
|
if (id == -1) return;
|
||||||
|
if (id < (s32)m_elts.size())
|
||||||
|
{
|
||||||
|
SLabel *lbl = NULL;
|
||||||
|
SButton *btn = NULL;
|
||||||
|
switch (m_elts[id]->t)
|
||||||
|
{
|
||||||
|
case GUIELT_BUTTON:
|
||||||
|
btn = (SButton*)m_elts[id];
|
||||||
|
btn->text.setText(btn->font, text);
|
||||||
|
break;
|
||||||
|
case GUIELT_LABEL:
|
||||||
|
lbl = (SLabel*)m_elts[id];
|
||||||
|
lbl->text.setText(lbl->font, text);
|
||||||
|
if (unwrap)
|
||||||
|
lbl->text.setFrame(100000, lbl->textStyle, true, true);
|
||||||
|
else
|
||||||
|
lbl->text.setFrame(lbl->w, lbl->textStyle, false, !unwrap);
|
||||||
|
break;
|
||||||
|
case GUIELT_PROGRESS:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::setText(s16 id, const wstringEx &text, u32 startline, bool unwrap)
|
||||||
|
{
|
||||||
|
if (id == -1) return;
|
||||||
|
if (id < (s32)m_elts.size())
|
||||||
|
{
|
||||||
|
SButton *btn = NULL;
|
||||||
|
SLabel *lbl = NULL;
|
||||||
|
switch(m_elts[id]->t)
|
||||||
|
{
|
||||||
|
case GUIELT_BUTTON:
|
||||||
|
btn = (SButton*)m_elts[id];
|
||||||
|
btn->text.setText(btn->font, text);
|
||||||
|
break;
|
||||||
|
case GUIELT_LABEL:
|
||||||
|
lbl = (SLabel*)m_elts[id];
|
||||||
|
lbl->text.setText(lbl->font, text, startline);
|
||||||
|
if (unwrap)
|
||||||
|
lbl->text.setFrame(100000, lbl->textStyle, true, true);
|
||||||
|
else
|
||||||
|
lbl->text.setFrame(lbl->w, lbl->textStyle, false, !unwrap);
|
||||||
|
break;
|
||||||
|
case GUIELT_PROGRESS:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::setBtnTexture(s16 id, TexData &texNormal, TexData &texSelected)
|
||||||
|
{
|
||||||
|
if (id == -1) return;
|
||||||
|
if (id < (s32)m_elts.size())
|
||||||
|
{
|
||||||
|
SButton *b = (SButton*)m_elts[id];
|
||||||
|
/* free old textures */
|
||||||
|
TexHandle.Cleanup(b->tex.center);
|
||||||
|
TexHandle.Cleanup(b->tex.centerSel);
|
||||||
|
/*change textures */
|
||||||
|
b->tex.center = texNormal;
|
||||||
|
b->tex.centerSel = texSelected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::freeBtnTexture(s16 id)
|
||||||
|
{
|
||||||
|
if(id == -1) return;
|
||||||
|
if(id < (s32)m_elts.size())
|
||||||
|
{
|
||||||
|
SButton *b = (SButton*)m_elts[id];
|
||||||
|
TexHandle.Cleanup(b->tex.center);
|
||||||
|
TexHandle.Cleanup(b->tex.centerSel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::setTexture(s16 id, TexData &bg)
|
||||||
|
{
|
||||||
|
if (id == -1) return;
|
||||||
|
if (id < (s32)m_elts.size())
|
||||||
|
{
|
||||||
|
SLabel *lbl = NULL;
|
||||||
|
switch(m_elts[id]->t)
|
||||||
|
{
|
||||||
|
case GUIELT_BUTTON:
|
||||||
|
break;
|
||||||
|
case GUIELT_LABEL:
|
||||||
|
lbl = (SLabel*)m_elts[id];
|
||||||
|
lbl->texBg = bg;//change texture
|
||||||
|
break;
|
||||||
|
case GUIELT_PROGRESS:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::setTexture(s16 id, TexData &bg, int width, int height)
|
||||||
|
{
|
||||||
|
if (id == -1) return;
|
||||||
|
if (id < (s32)m_elts.size())
|
||||||
|
{
|
||||||
|
SLabel *lbl = NULL;
|
||||||
|
switch(m_elts[id]->t)
|
||||||
|
{
|
||||||
|
case GUIELT_BUTTON:
|
||||||
|
break;
|
||||||
|
case GUIELT_LABEL:
|
||||||
|
lbl = (SLabel*)m_elts[id];
|
||||||
|
lbl->texBg = bg;//change texture
|
||||||
|
lbl->w = width;
|
||||||
|
lbl->h = height;
|
||||||
|
break;
|
||||||
|
case GUIELT_PROGRESS:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::setProgress(s16 id, float f, bool instant)
|
||||||
|
{
|
||||||
|
if(m_elts[id]->t == GUIELT_PROGRESS)
|
||||||
|
{
|
||||||
|
SProgressBar *b = (SProgressBar*)m_elts[id];
|
||||||
|
b->targetVal = std::min(std::max(0.f, f), 1.f);
|
||||||
|
if (instant) b->val = b->targetVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CButtonsMgr::reset(s16 id, bool instant)
|
void CButtonsMgr::reset(s16 id, bool instant)
|
||||||
{
|
{
|
||||||
if (id == -1) return;
|
if (id == -1) return;
|
||||||
@ -160,22 +366,6 @@ void CButtonsMgr::hide(s16 id, bool instant)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CButtonsMgr::stopSounds(void)
|
|
||||||
{
|
|
||||||
for (u32 i = 0; i < m_elts.size(); ++i)
|
|
||||||
if (m_elts[i]->t == GUIELT_BUTTON)
|
|
||||||
{
|
|
||||||
SButton *b = (SButton*)m_elts[i];
|
|
||||||
b->hoverSound->Stop();
|
|
||||||
b->clickSound->Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::setSoundVolume(int vol)
|
|
||||||
{
|
|
||||||
m_soundVolume = min(max(0, vol), 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::show(s16 id, bool instant)
|
void CButtonsMgr::show(s16 id, bool instant)
|
||||||
{
|
{
|
||||||
if (id == -1) return;
|
if (id == -1) return;
|
||||||
@ -197,6 +387,22 @@ void CButtonsMgr::show(s16 id, bool instant)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::stopSounds(void)
|
||||||
|
{
|
||||||
|
for (u32 i = 0; i < m_elts.size(); ++i)
|
||||||
|
if (m_elts[i]->t == GUIELT_BUTTON)
|
||||||
|
{
|
||||||
|
SButton *b = (SButton*)m_elts[i];
|
||||||
|
b->hoverSound->Stop();
|
||||||
|
b->clickSound->Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::setSoundVolume(int vol)
|
||||||
|
{
|
||||||
|
m_soundVolume = min(max(0, vol), 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
void CButtonsMgr::setRumble(int chan, bool wii, bool gc, bool wupc)
|
void CButtonsMgr::setRumble(int chan, bool wii, bool gc, bool wupc)
|
||||||
{
|
{
|
||||||
wii_rumble[chan] = wii;
|
wii_rumble[chan] = wii;
|
||||||
@ -204,12 +410,74 @@ void CButtonsMgr::setRumble(int chan, bool wii, bool gc, bool wupc)
|
|||||||
wupc_rumble[chan] = wupc;
|
wupc_rumble[chan] = wupc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::setMouse(bool enable)
|
||||||
|
{
|
||||||
|
m_mouse = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::noHover(bool nohover)
|
||||||
|
{
|
||||||
|
m_nohover = nohover;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CButtonsMgr::noClick(bool noclick)
|
||||||
|
{
|
||||||
|
m_noclick = noclick;
|
||||||
|
}
|
||||||
|
|
||||||
|
// **********************************************************************************************
|
||||||
|
// * This makes the click sound when a button is selected unless m_noclick is true. *
|
||||||
|
// * You check to see if a controller button pressed and then call m_btnMgr.selected(btn name) *
|
||||||
|
// **********************************************************************************************
|
||||||
|
bool CButtonsMgr::selected(s16 button)
|
||||||
|
{
|
||||||
|
for(int chan = WPAD_MAX_WIIMOTES - 1; chan >= 0; chan--)
|
||||||
|
{
|
||||||
|
if(m_selected[chan] == button)
|
||||||
|
{
|
||||||
|
if(m_selected[chan] != -1 && !m_noclick)
|
||||||
|
click(m_selected[chan]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// **********************************************************************************************
|
||||||
|
// * Plays the click sound for the function above. Also sets rumble off and enlarges button *
|
||||||
|
// **********************************************************************************************
|
||||||
|
void CButtonsMgr::click(s16 id)
|
||||||
|
{
|
||||||
|
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||||
|
{
|
||||||
|
WUPC_Rumble(chan, 0);
|
||||||
|
WPAD_Rumble(chan, 0);
|
||||||
|
PAD_ControlMotor(chan, 0);
|
||||||
|
|
||||||
|
if (id == -1) id = m_selected[chan];
|
||||||
|
if (id == -1) continue;
|
||||||
|
if (id < (s32)m_elts.size() && m_elts[id]->t == GUIELT_BUTTON)
|
||||||
|
{
|
||||||
|
SButton *b = (SButton*)m_elts[id];
|
||||||
|
b->click = 1.f;
|
||||||
|
b->scaleX = 1.1f;
|
||||||
|
b->scaleY = 1.1f;
|
||||||
|
if (m_soundVolume > 0) b->clickSound->Play(m_soundVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ********************************************************************************************
|
||||||
|
// * This is for using the mouse/pointer to select a button. It slightly enlarges the button, *
|
||||||
|
// * makes the hover sound if it's newly selected and if m_noHover is not set, and uses *
|
||||||
|
// * rumble if set on. *
|
||||||
|
// ********************************************************************************************
|
||||||
void CButtonsMgr::mouse(int chan, int x, int y)
|
void CButtonsMgr::mouse(int chan, int x, int y)
|
||||||
{
|
{
|
||||||
if (m_elts.empty()) return;
|
if (m_elts.empty()) return;
|
||||||
|
|
||||||
float w, h;
|
float w, h;
|
||||||
u16 start = 0;
|
u16 start = -1;
|
||||||
if(m_selected[chan] != -1 && m_selected[chan] < (s32)m_elts.size())
|
if(m_selected[chan] != -1 && m_selected[chan] < (s32)m_elts.size())
|
||||||
{
|
{
|
||||||
m_elts[m_selected[chan]]->targetScaleX = 1.f;
|
m_elts[m_selected[chan]]->targetScaleX = 1.f;
|
||||||
@ -252,25 +520,10 @@ void CButtonsMgr::mouse(int chan, int x, int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CButtonsMgr::setMouse(bool enable)
|
// **************************************************************************************************
|
||||||
{
|
// * This is for moving backwards to the next available button when using the d-pad instead of the *
|
||||||
m_mouse = enable;
|
// * pointer/mouse. The Button is slightly enlarged to show it's been selected. *
|
||||||
}
|
// **************************************************************************************************
|
||||||
|
|
||||||
bool CButtonsMgr::selected(s16 button)
|
|
||||||
{
|
|
||||||
for(int chan = WPAD_MAX_WIIMOTES - 1; chan >= 0; chan--)
|
|
||||||
{
|
|
||||||
if(m_selected[chan] == button)
|
|
||||||
{
|
|
||||||
if(m_selected[chan] != -1 && !m_noclick)
|
|
||||||
click(m_selected[chan]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::up(void)
|
void CButtonsMgr::up(void)
|
||||||
{
|
{
|
||||||
if(m_elts.empty() || m_mouse)
|
if(m_elts.empty() || m_mouse)
|
||||||
@ -293,13 +546,17 @@ void CButtonsMgr::up(void)
|
|||||||
if (b.t == GUIELT_BUTTON && b.visible)
|
if (b.t == GUIELT_BUTTON && b.visible)
|
||||||
{
|
{
|
||||||
m_selected[0] = j;
|
m_selected[0] = j;
|
||||||
b.targetScaleX = 1.1f;
|
b.targetScaleX = 1.1f;// mouse only enlarges 1.05
|
||||||
b.targetScaleY = 1.1f;
|
b.targetScaleY = 1.1f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// **************************************************************************************************
|
||||||
|
// * This is for moving forwards to the next available button when using the d-pad instead of the *
|
||||||
|
// * pointer/mouse. The Button is slightly enlarged to show it's been selected. *
|
||||||
|
// **************************************************************************************************
|
||||||
void CButtonsMgr::down(void)
|
void CButtonsMgr::down(void)
|
||||||
{
|
{
|
||||||
if(m_elts.empty() || m_mouse)
|
if(m_elts.empty() || m_mouse)
|
||||||
@ -322,51 +579,25 @@ void CButtonsMgr::down(void)
|
|||||||
if (b.t == GUIELT_BUTTON && b.visible)
|
if (b.t == GUIELT_BUTTON && b.visible)
|
||||||
{
|
{
|
||||||
m_selected[0] = j;
|
m_selected[0] = j;
|
||||||
b.targetScaleX = 1.1f;
|
b.targetScaleX = 1.1f;// mouse only enlarges 1.05
|
||||||
b.targetScaleY = 1.1f;
|
b.targetScaleY = 1.1f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CButtonsMgr::noHover(bool nohover)
|
void CButtonsMgr::tick(void)
|
||||||
{
|
|
||||||
m_nohover = nohover;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::noClick(bool noclick)
|
|
||||||
{
|
|
||||||
m_noclick = noclick;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::click(s16 id)
|
|
||||||
{
|
{
|
||||||
|
for (u32 i = 0; i < m_elts.size(); ++i)
|
||||||
|
m_elts[i]->tick();
|
||||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||||
|
if (m_rumble[chan] > 0 && --m_rumble[chan] == 0)
|
||||||
{
|
{
|
||||||
WUPC_Rumble(chan, 0);
|
WUPC_Rumble(chan, 0);
|
||||||
WPAD_Rumble(chan, 0);
|
WPAD_Rumble(chan, 0);
|
||||||
PAD_ControlMotor(chan, 0);
|
PAD_ControlMotor(chan, 0);
|
||||||
|
|
||||||
if (id == -1) id = m_selected[chan];
|
|
||||||
if (id == -1) continue;
|
|
||||||
if (id < (s32)m_elts.size() && m_elts[id]->t == GUIELT_BUTTON)
|
|
||||||
{
|
|
||||||
SButton *b = (SButton*)m_elts[id];
|
|
||||||
b->click = 1.f;
|
|
||||||
b->scaleX = 1.1f;
|
|
||||||
b->scaleY = 1.1f;
|
|
||||||
if (m_soundVolume > 0) b->clickSound->Play(m_soundVolume);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::SElement::tick(void)
|
|
||||||
{
|
|
||||||
scaleX += (targetScaleX - scaleX) * (targetScaleX > scaleX ? 0.3f : 0.1f);
|
|
||||||
scaleY += (targetScaleY - scaleY) * (targetScaleY > scaleY ? 0.3f : 0.1f);
|
|
||||||
int alphaDist = (int)targetAlpha - (int)alpha;
|
|
||||||
alpha += abs(alphaDist) >= 8 ? (u8)(alphaDist / 8) : (u8)alphaDist;
|
|
||||||
pos += (targetPos - pos) * 0.1f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CButtonsMgr::SLabel::tick(void)
|
void CButtonsMgr::SLabel::tick(void)
|
||||||
@ -389,226 +620,13 @@ void CButtonsMgr::SProgressBar::tick(void)
|
|||||||
val += (targetVal - val) * 0.1f;
|
val += (targetVal - val) * 0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CButtonsMgr::tick(void)
|
void CButtonsMgr::SElement::tick(void)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < m_elts.size(); ++i)
|
scaleX += (targetScaleX - scaleX) * (targetScaleX > scaleX ? 0.3f : 0.1f);
|
||||||
m_elts[i]->tick();
|
scaleY += (targetScaleY - scaleY) * (targetScaleY > scaleY ? 0.3f : 0.1f);
|
||||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
int alphaDist = (int)targetAlpha - (int)alpha;
|
||||||
if (m_rumble[chan] > 0 && --m_rumble[chan] == 0)
|
alpha += abs(alphaDist) >= 8 ? (u8)(alphaDist / 8) : (u8)alphaDist;
|
||||||
{
|
pos += (targetPos - pos) * 0.1f;
|
||||||
WUPC_Rumble(chan, 0);
|
|
||||||
WPAD_Rumble(chan, 0);
|
|
||||||
PAD_ControlMotor(chan, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
s16 CButtonsMgr::addLabel(SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color, s16 style, const TexData &bg)
|
|
||||||
{
|
|
||||||
SLabel *b = new SLabel;
|
|
||||||
|
|
||||||
b->font = font;
|
|
||||||
b->visible = false;
|
|
||||||
b->textStyle = style;
|
|
||||||
b->text.setText(b->font, text);
|
|
||||||
b->text.setFrame(width, b->textStyle, false, true);
|
|
||||||
b->textColor = color;
|
|
||||||
b->x = x + width / 2;
|
|
||||||
b->y = y + height / 2;
|
|
||||||
b->w = width;
|
|
||||||
b->h = height;
|
|
||||||
b->alpha = 0;
|
|
||||||
b->targetAlpha = 0;
|
|
||||||
b->scaleX = 0.f;
|
|
||||||
b->scaleY = 0.f;
|
|
||||||
b->targetScaleX = 0.f;
|
|
||||||
b->targetScaleY = 0.f;
|
|
||||||
b->texBg = bg;
|
|
||||||
b->moveByX = 0;
|
|
||||||
b->moveByY = 0;
|
|
||||||
|
|
||||||
u32 sz = m_elts.size();
|
|
||||||
m_elts.push_back(b);
|
|
||||||
|
|
||||||
return m_elts.size() > sz ? m_elts.size() - 1 : -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
s16 CButtonsMgr::addProgressBar(int x, int y, u32 width, u32 height, SButtonTextureSet &texSet)
|
|
||||||
{
|
|
||||||
SProgressBar *b = new SProgressBar;
|
|
||||||
|
|
||||||
b->visible = false;
|
|
||||||
b->x = x + width / 2;
|
|
||||||
b->y = y + height / 2;
|
|
||||||
b->w = width;
|
|
||||||
b->h = height;
|
|
||||||
b->alpha = 0;
|
|
||||||
b->targetAlpha = 0;
|
|
||||||
b->scaleX = 0.f;
|
|
||||||
b->scaleY = 0.f;
|
|
||||||
b->targetScaleX = 0.f;
|
|
||||||
b->targetScaleY = 0.f;
|
|
||||||
b->tex = texSet;
|
|
||||||
b->val = 0.f;
|
|
||||||
b->targetVal = 0.f;
|
|
||||||
b->moveByX = 0;
|
|
||||||
b->moveByY = 0;
|
|
||||||
|
|
||||||
u32 sz = m_elts.size();
|
|
||||||
m_elts.push_back(b);
|
|
||||||
|
|
||||||
return m_elts.size() > sz ? m_elts.size() - 1 : -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
s16 CButtonsMgr::addPicButton(TexData &texNormal, TexData &texSelected, int x, int y, u32 width, u32 height, GuiSound *clickSound, GuiSound *hoverSound)
|
|
||||||
{
|
|
||||||
SButtonTextureSet texSet;
|
|
||||||
|
|
||||||
texSet.center = texNormal;
|
|
||||||
texSet.centerSel = texSelected;
|
|
||||||
return addButton(SFont(), wstringEx(), x, y, width, height, CColor(), texSet, clickSound, hoverSound);
|
|
||||||
}
|
|
||||||
|
|
||||||
s16 CButtonsMgr::addPicButton(const u8 *pngNormal, const u8 *pngSelected, int x, int y, u32 width, u32 height, GuiSound *clickSound, GuiSound *hoverSound)
|
|
||||||
{
|
|
||||||
SButtonTextureSet texSet;
|
|
||||||
|
|
||||||
TexHandle.fromPNG(texSet.center, pngNormal);
|
|
||||||
TexHandle.fromPNG(texSet.centerSel, pngSelected);
|
|
||||||
return addButton(SFont(), wstringEx(), x, y, width, height, CColor(), texSet, clickSound, hoverSound);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::setText(s16 id, const wstringEx &text, bool unwrap)
|
|
||||||
{
|
|
||||||
if (id == -1) return;
|
|
||||||
if (id < (s32)m_elts.size())
|
|
||||||
{
|
|
||||||
SLabel *lbl = NULL;
|
|
||||||
SButton *btn = NULL;
|
|
||||||
switch (m_elts[id]->t)
|
|
||||||
{
|
|
||||||
case GUIELT_BUTTON:
|
|
||||||
btn = (SButton*)m_elts[id];
|
|
||||||
btn->text.setText(btn->font, text);
|
|
||||||
break;
|
|
||||||
case GUIELT_LABEL:
|
|
||||||
lbl = (SLabel*)m_elts[id];
|
|
||||||
lbl->text.setText(lbl->font, text);
|
|
||||||
if (unwrap)
|
|
||||||
lbl->text.setFrame(100000, lbl->textStyle, true, true);
|
|
||||||
else
|
|
||||||
lbl->text.setFrame(lbl->w, lbl->textStyle, false, !unwrap);
|
|
||||||
break;
|
|
||||||
case GUIELT_PROGRESS:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::setText(s16 id, const wstringEx &text, u32 startline,bool unwrap)
|
|
||||||
{
|
|
||||||
if (id == -1) return;
|
|
||||||
if (id < (s32)m_elts.size())
|
|
||||||
{
|
|
||||||
SButton *btn = NULL;
|
|
||||||
SLabel *lbl = NULL;
|
|
||||||
switch(m_elts[id]->t)
|
|
||||||
{
|
|
||||||
case GUIELT_BUTTON:
|
|
||||||
//((CButtonsMgr::SButton *)m_elts[id].get())->text = text;
|
|
||||||
btn = (SButton*)m_elts[id];
|
|
||||||
btn->text.setText(btn->font, text);
|
|
||||||
break;
|
|
||||||
case GUIELT_LABEL:
|
|
||||||
lbl = (SLabel*)m_elts[id];
|
|
||||||
lbl->text.setText(lbl->font, text, startline);
|
|
||||||
if (unwrap)
|
|
||||||
lbl->text.setFrame(100000, lbl->textStyle, true, true);
|
|
||||||
else
|
|
||||||
lbl->text.setFrame(lbl->w, lbl->textStyle, false, !unwrap);
|
|
||||||
break;
|
|
||||||
case GUIELT_PROGRESS:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::setBtnTexture(s16 id, TexData &texNormal, TexData &texSelected)
|
|
||||||
{
|
|
||||||
if (id == -1) return;
|
|
||||||
if (id < (s32)m_elts.size())
|
|
||||||
{
|
|
||||||
SButton *b = (SButton*)m_elts[id];
|
|
||||||
/* free old textures */
|
|
||||||
TexHandle.Cleanup(b->tex.center);
|
|
||||||
TexHandle.Cleanup(b->tex.centerSel);
|
|
||||||
/*change textures */
|
|
||||||
b->tex.center = texNormal;
|
|
||||||
b->tex.centerSel = texSelected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::freeBtnTexture(s16 id)
|
|
||||||
{
|
|
||||||
if(id == -1) return;
|
|
||||||
if(id < (s32)m_elts.size())
|
|
||||||
{
|
|
||||||
SButton *b = (SButton*)m_elts[id];
|
|
||||||
TexHandle.Cleanup(b->tex.center);
|
|
||||||
TexHandle.Cleanup(b->tex.centerSel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::setTexture(s16 id, TexData &bg)
|
|
||||||
{
|
|
||||||
if (id == -1) return;
|
|
||||||
if (id < (s32)m_elts.size())
|
|
||||||
{
|
|
||||||
SLabel *lbl = NULL;
|
|
||||||
switch(m_elts[id]->t)
|
|
||||||
{
|
|
||||||
case GUIELT_BUTTON:
|
|
||||||
break;
|
|
||||||
case GUIELT_LABEL:
|
|
||||||
lbl = (SLabel*)m_elts[id];
|
|
||||||
lbl->texBg = bg;//change texture
|
|
||||||
break;
|
|
||||||
case GUIELT_PROGRESS:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::setTexture(s16 id, TexData &bg, int width, int height)
|
|
||||||
{
|
|
||||||
if (id == -1) return;
|
|
||||||
if (id < (s32)m_elts.size())
|
|
||||||
{
|
|
||||||
SLabel *lbl = NULL;
|
|
||||||
switch(m_elts[id]->t)
|
|
||||||
{
|
|
||||||
case GUIELT_BUTTON:
|
|
||||||
break;
|
|
||||||
case GUIELT_LABEL:
|
|
||||||
lbl = (SLabel*)m_elts[id];
|
|
||||||
lbl->texBg = bg;//change texture
|
|
||||||
lbl->w = width;
|
|
||||||
lbl->h = height;
|
|
||||||
break;
|
|
||||||
case GUIELT_PROGRESS:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButtonsMgr::setProgress(s16 id, float f, bool instant)
|
|
||||||
{
|
|
||||||
if(m_elts[id]->t == GUIELT_PROGRESS)
|
|
||||||
{
|
|
||||||
SProgressBar *b = (SProgressBar*)m_elts[id];
|
|
||||||
b->targetVal = std::min(std::max(0.f, f), 1.f);
|
|
||||||
if (instant) b->val = b->targetVal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CButtonsMgr::_drawBtn(CButtonsMgr::SButton &b, bool selected, bool click)
|
void CButtonsMgr::_drawBtn(CButtonsMgr::SButton &b, bool selected, bool click)
|
||||||
|
@ -33,7 +33,8 @@ public:
|
|||||||
void reserve(u32 capacity) { m_elts.reserve(capacity); }
|
void reserve(u32 capacity) { m_elts.reserve(capacity); }
|
||||||
s16 addButton(SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color,
|
s16 addButton(SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color,
|
||||||
const SButtonTextureSet &texSet, GuiSound *clickSound = NULL, GuiSound *hoverSound = NULL);
|
const SButtonTextureSet &texSet, GuiSound *clickSound = NULL, GuiSound *hoverSound = NULL);
|
||||||
s16 addLabel(SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color, s16 style, const TexData &bg = _noTexture);
|
s16 addLabel(SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color,
|
||||||
|
s16 style, const TexData &bg = _noTexture);
|
||||||
s16 addPicButton(const u8 *pngNormal, const u8 *pngSelected, int x, int y, u32 width, u32 height,
|
s16 addPicButton(const u8 *pngNormal, const u8 *pngSelected, int x, int y, u32 width, u32 height,
|
||||||
GuiSound *clickSound = NULL, GuiSound *hoverSound = NULL);
|
GuiSound *clickSound = NULL, GuiSound *hoverSound = NULL);
|
||||||
s16 addPicButton(TexData &texNormal, TexData &texSelected, int x, int y, u32 width, u32 height,
|
s16 addPicButton(TexData &texNormal, TexData &texSelected, int x, int y, u32 width, u32 height,
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class SFont
|
class SFont// should be either struct SFont or class CFont
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SFont(void) : font(NULL), fSize(0), lineSpacing(0), weight(0), index(0), data(NULL), dataSize(0) { memset(name, 0, 128); };
|
SFont(void) : font(NULL), fSize(0), lineSpacing(0), weight(0), index(0), data(NULL), dataSize(0) { memset(name, 0, 128); };
|
||||||
|
@ -185,7 +185,7 @@ static inline void _convertToCMPR(u8 *dst, const u8 *src, u32 width, u32 height)
|
|||||||
void STexture::Cleanup(TexData &tex)
|
void STexture::Cleanup(TexData &tex)
|
||||||
{
|
{
|
||||||
if(tex.data != NULL)
|
if(tex.data != NULL)
|
||||||
free(tex.data);
|
free(tex.data);//mem2_free maybe
|
||||||
tex.data = NULL;
|
tex.data = NULL;
|
||||||
tex.dataSize = 0;
|
tex.dataSize = 0;
|
||||||
tex.width = 0;
|
tex.width = 0;
|
||||||
|
@ -19,19 +19,26 @@ void CMenu::_gameinfo(void)
|
|||||||
|
|
||||||
int amount_of_skips = 0;
|
int amount_of_skips = 0;
|
||||||
|
|
||||||
int synopsis_x = 0, synopsis_y = 0;
|
//int synopsis_x = m_theme.getInt("GAMEINFO/SYNOPSIS", "x", 40);
|
||||||
u32 synopsis_w = 0, synopsis_h = 0;
|
int synopsis_y = m_theme.getInt("GAMEINFO/SYNOPSIS", "y", 120);
|
||||||
|
//u16 synopsis_w = m_theme.getInt("GAMEINFO/SYNOPSIS", "width", 560);
|
||||||
|
int synopsis_h = m_theme.getInt("GAMEINFO/SYNOPSIS", "height", 280);
|
||||||
|
//CText text;
|
||||||
|
u32 synopsis_th = 0;
|
||||||
|
int dummy1 = 0;
|
||||||
|
u32 dummy2 = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
_mainLoopCommon();
|
_mainLoopCommon();
|
||||||
|
|
||||||
if (amount_of_skips == 0)
|
if (amount_of_skips == 0 && page == 1)
|
||||||
{
|
{
|
||||||
// Check dimensions in the loop, because the animation can have an effect
|
// Check dimensions in the loop, because the animation can have an effect
|
||||||
m_btnMgr.getDimensions(m_gameinfoLblSynopsis, synopsis_x, synopsis_y, synopsis_w, synopsis_h); // Get original dimensions
|
m_btnMgr.getDimensions(m_gameinfoLblSynopsis, dummy1, dummy1, dummy2, synopsis_th); // Get original dimensions
|
||||||
|
//gprintf("synopsis\nx = %i\ny = %i\nw = %i\nh = %i\n", synopsis_x, synopsis_y, synopsis_w, synopsis_h);
|
||||||
}
|
}
|
||||||
if(first && page == 1)
|
if (first && page == 1)
|
||||||
{
|
{
|
||||||
m_btnMgr.moveBy(m_gameinfoLblSynopsis, 0, -1);
|
m_btnMgr.moveBy(m_gameinfoLblSynopsis, 0, -1);
|
||||||
amount_of_skips++;
|
amount_of_skips++;
|
||||||
@ -40,7 +47,8 @@ void CMenu::_gameinfo(void)
|
|||||||
|
|
||||||
if ((BTN_DOWN_PRESSED || BTN_DOWN_HELD) && !(m_thrdWorking && m_thrdStop) && page == 1)
|
if ((BTN_DOWN_PRESSED || BTN_DOWN_HELD) && !(m_thrdWorking && m_thrdStop) && page == 1)
|
||||||
{
|
{
|
||||||
if (synopsis_h - (amount_of_skips * pixels_to_skip) > (m_vid.height2D() - (35 + synopsis_y)))
|
//if (synopsis_h - (amount_of_skips * pixels_to_skip) > (m_vid.height2D() - (synopsis_y)))//+35
|
||||||
|
if(((int)synopsis_th - 48) - (amount_of_skips * pixels_to_skip) > (synopsis_h - synopsis_y))
|
||||||
{
|
{
|
||||||
m_btnMgr.moveBy(m_gameinfoLblSynopsis, 0, -pixels_to_skip);
|
m_btnMgr.moveBy(m_gameinfoLblSynopsis, 0, -pixels_to_skip);
|
||||||
amount_of_skips++;
|
amount_of_skips++;
|
||||||
|
@ -724,7 +724,7 @@ int CMenu::main(void)
|
|||||||
LoadView();
|
LoadView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Hide Notice or Letter if times up */
|
||||||
if(m_showtimer > 0)
|
if(m_showtimer > 0)
|
||||||
{
|
{
|
||||||
if(--m_showtimer == 0)
|
if(--m_showtimer == 0)
|
||||||
@ -733,7 +733,7 @@ int CMenu::main(void)
|
|||||||
m_btnMgr.hide(m_mainLblNotice);
|
m_btnMgr.hide(m_mainLblNotice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//zones, showing and hiding buttons
|
/*zones, showing and hiding buttons */
|
||||||
if(!m_gameList.empty() && m_show_zone_prev && !m_sourceflow && m_current_view != COVERFLOW_HOMEBREW)
|
if(!m_gameList.empty() && m_show_zone_prev && !m_sourceflow && m_current_view != COVERFLOW_HOMEBREW)
|
||||||
m_btnMgr.show(m_mainBtnPrev);
|
m_btnMgr.show(m_mainBtnPrev);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user