mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-27 13:44: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 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 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;
|
||||
|
||||
u8 textureFmt = m_compressTextures ? GX_TF_CMPR : GX_TF_RGB565;
|
||||
|
||||
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;
|
||||
size_t path_len = strlen(path);
|
||||
char *path_place = (char*)MEM2_alloc(path_len+1);
|
||||
if(path_place == NULL)
|
||||
char *coverPath = (char*)MEM2_alloc(path_len+1);
|
||||
if(coverPath == NULL)
|
||||
return false;
|
||||
memset(path_place, 0, path_len+1);
|
||||
memcpy(path_place, path, path_len);
|
||||
DCFlushRange(path_place, path_len+1);
|
||||
memset(coverPath, 0, path_len+1);
|
||||
memcpy(coverPath, path, path_len);
|
||||
DCFlushRange(coverPath, path_len+1);
|
||||
|
||||
TexData tex;
|
||||
tex.thread = true;
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
MEM2_free(path_place);
|
||||
MEM2_free(coverPath);
|
||||
m_renderingTex = NULL;
|
||||
if(!m_loadingCovers)
|
||||
return false;
|
||||
@ -2653,62 +2655,58 @@ bool CCoverFlow::_loadCoverTexPNG(u32 i, bool box, bool hq, bool blankBoxCover)
|
||||
if(zBuffer != NULL && (!m_compressCache || compress(zBuffer, &zBufferSize, tex.data, bufSize) == Z_OK))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if(zBuffer != NULL && m_compressCache)
|
||||
MEM2_free(zBuffer);
|
||||
return false;
|
||||
}
|
||||
memset(full_path, 0, MAX_FAT_PATH+1);
|
||||
|
||||
if(blankBoxCover)
|
||||
{
|
||||
const char *menuPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
|
||||
if(menuPath != NULL && strrchr(menuPath, '/') != NULL)
|
||||
gameNameOrID = strrchr(menuPath, '/') + 1;
|
||||
const char *blankCoverPath = mainMenu.getBlankCoverPath(m_items[i].hdr);
|
||||
if(blankCoverPath != NULL && strrchr(blankCoverPath, '/') != NULL)
|
||||
gameNameOrID = strrchr(blankCoverPath, '/') + 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)
|
||||
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)
|
||||
{
|
||||
char *full_path = (char*)MEM2_alloc(MAX_FAT_PATH+1);
|
||||
if(full_path == NULL)
|
||||
//check if coverWfcDir includes subfolders & make them
|
||||
if(strchr(coverWfcDir, '/') != NULL)
|
||||
{
|
||||
if(zBuffer != NULL && m_compressCache)
|
||||
MEM2_free(zBuffer);
|
||||
return false;
|
||||
}
|
||||
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
|
||||
{
|
||||
if(strchr(coverDir, '/') != NULL)
|
||||
char *tmp = (char*)MEM2_alloc(strlen(coverWfcDir)+1);
|
||||
strncpy(tmp, coverWfcDir, strlen(coverWfcDir));
|
||||
char *help = tmp;
|
||||
while(help != NULL && strchr(help, '/') != NULL)
|
||||
{
|
||||
char *tmp = (char*)MEM2_alloc(strlen(coverDir)+1);
|
||||
strncpy(tmp, coverDir, strlen(coverDir));
|
||||
char *help = tmp;
|
||||
while(help != NULL && strchr(help, '/') != NULL)
|
||||
{
|
||||
char *pos = strchr(help, '/');
|
||||
*pos = '\0';
|
||||
fsop_MakeFolder(fmt("%s/%s", m_cachePath.c_str(), tmp));
|
||||
*pos = '/';
|
||||
help = pos+1;
|
||||
}
|
||||
MEM2_free(tmp);
|
||||
char *pos = strchr(help, '/');
|
||||
*pos = '\0';
|
||||
fsop_MakeFolder(fmt("%s/%s", m_cachePath.c_str(), tmp));
|
||||
*pos = '/';
|
||||
help = pos+1;
|
||||
}
|
||||
fsop_MakeFolder(fmt("%s/%s", m_cachePath.c_str(), coverDir));
|
||||
strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), coverDir, gameNameOrID), MAX_FAT_PATH);
|
||||
MEM2_free(tmp);
|
||||
}
|
||||
DCFlushRange(full_path, MAX_FAT_PATH+1);
|
||||
file = fopen(full_path, "wb");
|
||||
MEM2_free(full_path);
|
||||
fsop_MakeFolder(fmt("%s/%s", m_cachePath.c_str(), coverWfcDir));
|
||||
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);
|
||||
//finally write the wfc file to the cache
|
||||
FILE *file;
|
||||
file = fopen(full_path, "wb");
|
||||
MEM2_free(full_path);
|
||||
if(file != NULL)
|
||||
{
|
||||
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 *TitleOrID = NULL;
|
||||
const char *NameOrID = NULL;
|
||||
if(NoGameID(curHdr->type))
|
||||
{
|
||||
if(strrchr(curHdr->path, '/') != NULL)
|
||||
{
|
||||
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
|
||||
TitleOrID = fmt("%ls", curHdr->title);// title without extension in lowercase
|
||||
NameOrID = fmt("%ls", curHdr->title);// title without extension in lowercase
|
||||
}
|
||||
else
|
||||
TitleOrID = curHdr->path;//title for scummvm
|
||||
NameOrID = curHdr->path;//title for scummvm
|
||||
}
|
||||
else
|
||||
TitleOrID = curHdr->id;// ID for Wii, GC, & Channels
|
||||
return TitleOrID;
|
||||
NameOrID = curHdr->id;// ID for Wii, GC, & Channels
|
||||
return NameOrID;
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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 *fp = NULL;
|
||||
if(gameNameOrID != 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(coverDir == NULL || strlen(coverDir) == 0)
|
||||
strncpy(full_path, fmt("%s/%s.wfc", m_cachePath.c_str(), gameNameOrID), MAX_FAT_PATH);
|
||||
else
|
||||
strncpy(full_path, fmt("%s/%s/%s.wfc", m_cachePath.c_str(), coverDir, gameNameOrID), MAX_FAT_PATH);
|
||||
DCFlushRange(full_path, MAX_FAT_PATH+1);
|
||||
fp = fopen(full_path, "rb");
|
||||
MEM2_free(full_path);
|
||||
}
|
||||
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)
|
||||
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);
|
||||
FILE *fp;
|
||||
fp = fopen(full_path, "rb");
|
||||
free(full_path);
|
||||
|
||||
if(fp != NULL)//if wfc chache file is found
|
||||
{
|
||||
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;
|
||||
}
|
||||
u32 fileSize = stat_buf.st_size;
|
||||
|
||||
SWFCHeader 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
|
||||
if(header.newFmt == 1 && (header.full != 0) == box && (header.cmpr != 0) == m_compressTextures)
|
||||
{
|
||||
@ -2868,21 +2867,22 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
|
||||
if(header.zipped != 0)//if it's compressed ie. zipped
|
||||
{
|
||||
u8 *ptrTex = (u8*)MEM2_alloc(bufSize);
|
||||
if(ptrTex == NULL)
|
||||
u8 *zBuffer = (u8*)MEM2_alloc(fileSize - sizeof header);
|
||||
if(ptrTex == NULL || zBuffer == NULL)
|
||||
allocFailed = true;
|
||||
else
|
||||
{
|
||||
u8 *zBuffer = (u8*)MEM2_alloc(fileSize - sizeof header);
|
||||
if(zBuffer != NULL)
|
||||
{
|
||||
fread(zBuffer, 1, fileSize - sizeof header, fp);
|
||||
uLongf size = bufSize;
|
||||
if(uncompress(ptrTex, &size, zBuffer, fileSize - sizeof header) == Z_OK && size == bufSize)
|
||||
memcpy(tex.data, ptrTex + bufSize - texLen, texLen);
|
||||
free(zBuffer);
|
||||
free(ptrTex);
|
||||
}
|
||||
size_t readLen;
|
||||
do {
|
||||
fseek(fp, sizeof header, SEEK_SET);
|
||||
readLen = fread(zBuffer, 1, fileSize - sizeof header, fp);
|
||||
} while (readLen != (fileSize - sizeof header));
|
||||
uLongf size = bufSize;
|
||||
if(uncompress(ptrTex, &size, zBuffer, fileSize - sizeof header) == Z_OK && size == bufSize)
|
||||
memcpy(tex.data, ptrTex + bufSize - texLen, texLen);
|
||||
}
|
||||
free(zBuffer);
|
||||
free(ptrTex);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2890,8 +2890,11 @@ CCoverFlow::CLRet CCoverFlow::_loadCoverTex(u32 i, bool box, bool hq, bool blank
|
||||
allocFailed = true;
|
||||
else
|
||||
{
|
||||
fseek(fp, fileSize - sizeof header - texLen, SEEK_CUR);
|
||||
fread(tex.data, 1, texLen, fp);
|
||||
size_t readLen;
|
||||
do {
|
||||
fseek(fp, sizeof header + bufSize - texLen, SEEK_SET);
|
||||
readLen = fread(tex.data, 1, texLen, fp);
|
||||
} while (readLen != texLen);
|
||||
}
|
||||
}
|
||||
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
|
||||
return _loadCoverTexPNG(i, box, hq, blankBoxCover) ? CL_OK : CL_ERROR;
|
||||
//return CL_ERROR;
|
||||
}
|
||||
|
||||
int CCoverFlow::_coverLoader(CCoverFlow *cf)
|
||||
@ -2939,9 +2941,9 @@ int CCoverFlow::_coverLoader(CCoverFlow *cf)
|
||||
{
|
||||
update = cf->m_moved;
|
||||
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;
|
||||
for(j = cf->m_items.size(); j >= bufferSize && !cf->m_moved && update; --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());
|
||||
if(cf->m_items[i].state != STATE_Loading)
|
||||
{
|
||||
@ -2952,9 +2954,8 @@ int CCoverFlow::_coverLoader(CCoverFlow *cf)
|
||||
}
|
||||
}
|
||||
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());
|
||||
cur_pos_hq = (hq_req && i == firstItem);
|
||||
if((!hq_req || !cur_pos_hq) && cf->m_items[i].state != STATE_Loading)
|
||||
|
@ -196,7 +196,7 @@ private:
|
||||
Vector3D bottomDeltaAngle;
|
||||
};
|
||||
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);
|
||||
dir_discHdr *hdr;
|
||||
@ -206,7 +206,7 @@ private:
|
||||
volatile bool boxTexture;
|
||||
volatile enum TexState state;
|
||||
} ATTRIBUTE_PACKED;
|
||||
struct CCover
|
||||
struct CCover// should be SCover because it's a struct
|
||||
{
|
||||
u32 index;
|
||||
Vector3D scale;
|
||||
|
@ -37,7 +37,6 @@ s16 CButtonsMgr::addButton(SFont font, const wstringEx &text, int x, int y, u32
|
||||
|
||||
b->font = font;
|
||||
b->visible = false;
|
||||
//b->text = text;
|
||||
b->text.setText(b->font, text);
|
||||
b->textColor = color;
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
wii_rumble[chan] = wii;
|
||||
@ -204,12 +410,74 @@ void CButtonsMgr::setRumble(int chan, bool wii, bool gc, bool 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)
|
||||
{
|
||||
if (m_elts.empty()) return;
|
||||
|
||||
float w, h;
|
||||
u16 start = 0;
|
||||
u16 start = -1;
|
||||
if(m_selected[chan] != -1 && m_selected[chan] < (s32)m_elts.size())
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_mouse = enable;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// **************************************************************************************************
|
||||
// * This is for moving backwards 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::up(void)
|
||||
{
|
||||
if(m_elts.empty() || m_mouse)
|
||||
@ -293,13 +546,17 @@ void CButtonsMgr::up(void)
|
||||
if (b.t == GUIELT_BUTTON && b.visible)
|
||||
{
|
||||
m_selected[0] = j;
|
||||
b.targetScaleX = 1.1f;
|
||||
b.targetScaleX = 1.1f;// mouse only enlarges 1.05
|
||||
b.targetScaleY = 1.1f;
|
||||
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)
|
||||
{
|
||||
if(m_elts.empty() || m_mouse)
|
||||
@ -322,51 +579,25 @@ void CButtonsMgr::down(void)
|
||||
if (b.t == GUIELT_BUTTON && b.visible)
|
||||
{
|
||||
m_selected[0] = j;
|
||||
b.targetScaleX = 1.1f;
|
||||
b.targetScaleX = 1.1f;// mouse only enlarges 1.05
|
||||
b.targetScaleY = 1.1f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CButtonsMgr::noHover(bool nohover)
|
||||
{
|
||||
m_nohover = nohover;
|
||||
}
|
||||
|
||||
void CButtonsMgr::noClick(bool noclick)
|
||||
{
|
||||
m_noclick = noclick;
|
||||
}
|
||||
|
||||
void CButtonsMgr::click(s16 id)
|
||||
void CButtonsMgr::tick(void)
|
||||
{
|
||||
for (u32 i = 0; i < m_elts.size(); ++i)
|
||||
m_elts[i]->tick();
|
||||
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)
|
||||
if (m_rumble[chan] > 0 && --m_rumble[chan] == 0)
|
||||
{
|
||||
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);
|
||||
WUPC_Rumble(chan, 0);
|
||||
WPAD_Rumble(chan, 0);
|
||||
PAD_ControlMotor(chan, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@ -389,226 +620,13 @@ void CButtonsMgr::SProgressBar::tick(void)
|
||||
val += (targetVal - val) * 0.1f;
|
||||
}
|
||||
|
||||
void CButtonsMgr::tick(void)
|
||||
void CButtonsMgr::SElement::tick(void)
|
||||
{
|
||||
for (u32 i = 0; i < m_elts.size(); ++i)
|
||||
m_elts[i]->tick();
|
||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||
if (m_rumble[chan] > 0 && --m_rumble[chan] == 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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::_drawBtn(CButtonsMgr::SButton &b, bool selected, bool click)
|
||||
|
@ -33,7 +33,8 @@ public:
|
||||
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,
|
||||
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,
|
||||
GuiSound *clickSound = NULL, GuiSound *hoverSound = NULL);
|
||||
s16 addPicButton(TexData &texNormal, TexData &texSelected, int x, int y, u32 width, u32 height,
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SFont
|
||||
class SFont// should be either struct SFont or class CFont
|
||||
{
|
||||
public:
|
||||
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)
|
||||
{
|
||||
if(tex.data != NULL)
|
||||
free(tex.data);
|
||||
free(tex.data);//mem2_free maybe
|
||||
tex.data = NULL;
|
||||
tex.dataSize = 0;
|
||||
tex.width = 0;
|
||||
|
@ -19,19 +19,26 @@ void CMenu::_gameinfo(void)
|
||||
|
||||
int amount_of_skips = 0;
|
||||
|
||||
int synopsis_x = 0, synopsis_y = 0;
|
||||
u32 synopsis_w = 0, synopsis_h = 0;
|
||||
//int synopsis_x = m_theme.getInt("GAMEINFO/SYNOPSIS", "x", 40);
|
||||
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
|
||||
{
|
||||
_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
|
||||
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);
|
||||
amount_of_skips++;
|
||||
@ -40,8 +47,9 @@ void CMenu::_gameinfo(void)
|
||||
|
||||
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);
|
||||
amount_of_skips++;
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ int CMenu::main(void)
|
||||
LoadView();
|
||||
}
|
||||
}
|
||||
|
||||
/* Hide Notice or Letter if times up */
|
||||
if(m_showtimer > 0)
|
||||
{
|
||||
if(--m_showtimer == 0)
|
||||
@ -733,7 +733,7 @@ int CMenu::main(void)
|
||||
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)
|
||||
m_btnMgr.show(m_mainBtnPrev);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user