Optimization Changes Part 1:

*Lots of changes in the TextDrawing stuff and FreeTypeGX to speed up the drawing
*Mostly optimization work which is not completely done yet, but mainly it is.
*You might not want to update to this revision right away there still might be bugs which are needed to be fixed. This is a version for everyone to test and report bugs caused by the changes.
*Vanishing WiiMotePointer should be fixed for the Settings/GameSettings probably (though it might still occur i am not sure if i didn't forget anything, there is just too much to change :P.
This commit is contained in:
dimok321 2009-10-17 20:48:52 +00:00
parent 1411b42132
commit 3c6bf6523b
25 changed files with 2304 additions and 2060 deletions

File diff suppressed because one or more lines are too long

View File

@ -20,64 +20,54 @@
* along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/stat.h>
#include <wchar.h>
#include "FreeTypeGX.h"
#include "settings/cfg.h"
#include "main.h"
FreeTypeGX *fontSystem[MAX_FONT_SIZE+1];
/*! \struct ftgxCharData_
*
* Font face character glyph relevant data structure.
*/
typedef struct ftgxCharData_ {
int16_t renderOffsetX; /**< Texture X axis bearing offset. */
uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */
uint16_t glyphIndex; /**< Charachter glyph index in the font face. */
static FT_Byte *customfontbuffer = NULL;
static u32 cstfontfilesize = 0;
uint16_t textureWidth; /**< Texture width in pixels/bytes. */
uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */
bool LoadCustomFont(const char *path)
{
FILE *pfile = fopen(path, "rb");
int16_t renderOffsetY; /**< Texture Y axis bearing offset. */
int16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */
int16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */
if(pfile)
{
fseek(pfile, 0, SEEK_END);
cstfontfilesize = ftell(pfile);
rewind(pfile);
uint32_t* glyphDataTexture; /**< Glyph texture bitmap data buffer. */
} ftgxCharData;
customfontbuffer = new FT_Byte[cstfontfilesize];
if(!customfontbuffer)
{
cstfontfilesize = 0;
fclose(pfile);
return false;
}
/*! \struct ftgxDataOffset_
*
* Offset structure which hold both a maximum and minimum value.
*/
typedef struct ftgxDataOffset_ {
int16_t ascender; /**< Maximum data offset. */
int16_t descender; /**< Minimum data offset. */
int16_t max; /**< Maximum data offset. */
int16_t min; /**< Minimum data offset. */
} ftgxDataOffset;
fread(customfontbuffer, 1, cstfontfilesize, pfile);
fclose(pfile);
return true;
}
/**
* Default constructor for the FreeTypeGX class.
*
* @param textureFormat Optional format (GX_TF_*) of the texture as defined by the libogc gx.h header file. If not specified default value is GX_TF_RGBA8.
* @param vertexIndex Optional vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. If not specified default value is GX_VTXFMT1.
*/
FreeTypeGX::FreeTypeGX(uint8_t textureFormat, uint8_t vertexIndex) : ftFace(NULL), ftFace_fromFile(NULL) {
FT_Init_FreeType(&this->ftLibrary);
this->textureFormat = textureFormat;
this->setVertexFormat(vertexIndex);
this->setCompatibilityMode(FTGX_COMPATIBILITY_NONE);
return false;
}
/**
* Default destructor for the FreeTypeGX class.
*/
FreeTypeGX::~FreeTypeGX() {
this->unloadFont();
FT_Done_FreeType(this->ftLibrary);
void ClearFontData()
{
for(int i=0; i<50; i++)
{
if(fontSystem[i])
delete fontSystem[i];
fontSystem[i] = NULL;
}
if(customfontbuffer)
{
delete customfontbuffer;
customfontbuffer = NULL;
cstfontfilesize = 0;
}
}
/**
@ -89,31 +79,85 @@ FreeTypeGX::~FreeTypeGX() {
* @param strChar Character string to be converted.
* @return Wide character representation of supplied character string.
*/
wchar_t* FreeTypeGX::charToWideChar(char* strChar) {
wchar_t* charToWideChar(const char* strChar)
{
wchar_t *strWChar;
try {strWChar = new wchar_t[strlen(strChar) + 1];}
catch (...) { return 0; }
strWChar = new wchar_t[strlen(strChar) + 1];
// UTF-8
int bt;
bt = mbstowcs(strWChar, strChar, strlen(strChar));
if (bt > 0) {
if(bt > 0) {
strWChar[bt] = (wchar_t)'\0';
return strWChar;
}
char *tempSrc = strChar;
char *tempSrc = (char *)strChar;
wchar_t *tempDest = strWChar;
while ((*tempDest++ = *tempSrc++));
while((*tempDest++ = *tempSrc++));
return strWChar;
}
/**
* Default constructor for the FreeTypeGX class.
*
* \overload
* @param textureFormat Optional format (GX_TF_*) of the texture as defined by the libogc gx.h header file. If not specified default value is GX_TF_RGBA8.
* @param vertexIndex Optional vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. If not specified default value is GX_VTXFMT1.
*/
wchar_t* FreeTypeGX::charToWideChar(const char* strChar) {
return FreeTypeGX::charToWideChar((char*) strChar);
FreeTypeGX::FreeTypeGX(FT_UInt pixelSize, uint8_t textureFormat, uint8_t vertexIndex)
{
this->textureFormat = textureFormat;
this->setVertexFormat(vertexIndex);
this->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
this->ftPointSize = pixelSize;
this->ftKerningEnabled = FT_HAS_KERNING(ftFace);
}
/**
* Overload for WiiXplorer
*/
FreeTypeGX::FreeTypeGX(FT_UInt pixelSize, bool loadcustomfont, uint8_t* fontBuffer, FT_Long bufferSize, uint8_t textureFormat, uint8_t vertexIndex)
{
this->InitFreeType(fontBuffer, bufferSize, loadcustomfont);
this->textureFormat = textureFormat;
this->setVertexFormat(vertexIndex);
this->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
this->ftPointSize = pixelSize;
this->ftKerningEnabled = FT_HAS_KERNING(ftFace);
this->ChangeFontSize(pixelSize);
}
/**
* Default destructor for the FreeTypeGX class.
*/
FreeTypeGX::~FreeTypeGX()
{
FT_Done_FreeType(ftLibrary);
FT_Done_Face(ftFace);
this->unloadFont();
}
void FreeTypeGX::InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize, bool loadcustomfont)
{
FT_Init_FreeType(&ftLibrary);
if(customfontbuffer && cstfontfilesize > 0 && loadcustomfont)
FT_New_Memory_Face(ftLibrary, customfontbuffer, cstfontfilesize, 0,&ftFace);
else
FT_New_Memory_Face(ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &ftFace);
ftSlot = ftFace->glyph;
}
void FreeTypeGX::ChangeFontSize(FT_UInt pixelSize)
{
FT_Set_Pixel_Sizes(ftFace, 0, pixelSize);
}
uint8_t FreeTypeGX::GetMaxCharWidth()
{
return ftFace->size->metrics.max_advance >> 6;
}
/**
@ -125,9 +169,9 @@ wchar_t* FreeTypeGX::charToWideChar(const char* strChar) {
*
* @param vertexIndex Vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file.
*/
void FreeTypeGX::setVertexFormat(uint8_t vertexIndex) {
void FreeTypeGX::setVertexFormat(uint8_t vertexIndex)
{
this->vertexIndex = vertexIndex;
GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_POS, GX_POS_XY, GX_S16, 0);
GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GX_SetVtxAttrFmt(this->vertexIndex, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
@ -143,7 +187,8 @@ void FreeTypeGX::setVertexFormat(uint8_t vertexIndex) {
*
* @param compatibilityMode Compatibility descritor (FTGX_COMPATIBILITY_*) as defined in FreeTypeGX.h
*/
void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode) {
void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode)
{
this->compatibilityMode = compatibilityMode;
}
@ -153,9 +198,12 @@ void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode) {
* This function calls the GX_SetTevOp and GX_SetVtxDesc functions with the compatibility parameters specified
* in setCompatibilityMode.
*/
void FreeTypeGX::setDefaultMode() {
if (this->compatibilityMode) {
switch (this->compatibilityMode & 0x00FF) {
void FreeTypeGX::setDefaultMode()
{
if(this->compatibilityMode)
{
switch(this->compatibilityMode & 0x00FF)
{
case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE:
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
break;
@ -175,7 +223,8 @@ void FreeTypeGX::setDefaultMode() {
break;
}
switch (this->compatibilityMode & 0xFF00) {
switch(this->compatibilityMode & 0xFF00)
{
case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE:
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
break;
@ -194,99 +243,20 @@ void FreeTypeGX::setDefaultMode() {
}
}
/**
* Loads and processes a specified true type font buffer to a specific point size.
*
* This routine takes a precompiled true type font buffer and loads the necessary processed data into memory. This routine should be called before drawText will succeed.
*
* @param fontPath filename with path to load font from file in memory.
* @param fontBuffer A pointer in memory to a precompiled true type font buffer.
* @param bufferSize Size of the true type font buffer in bytes.
* @param pointSize The desired point size this wrapper's configured font face.
* @param cacheAll Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false.
*/
uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
this->unloadFont();
this->ftPointSize = pointSize;
struct stat st;
if (fontPath && (stat(fontPath, &st)==0)) {
FILE *fontfile = fopen(fontPath, "rb");
if (fontfile) {
FT_Long ftFace_fromFile_Size;
fseek(fontfile, 0, SEEK_END);
ftFace_fromFile_Size = ftell(fontfile);
fseek(fontfile, 0, SEEK_SET);
ftFace_fromFile = (uint8_t*)malloc(ftFace_fromFile_Size);
if (ftFace_fromFile != NULL) {
fread(ftFace_fromFile, 1, ftFace_fromFile_Size, fontfile);
FT_New_Memory_Face(this->ftLibrary, ftFace_fromFile, ftFace_fromFile_Size, 0, &this->ftFace);
}
fclose(fontfile);
}
}
if (ftFace_fromFile == NULL)
FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace);
if (this->ftPointSize > 0)
FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize);
this->ftSlot = this->ftFace->glyph;
this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace);
if (cacheAll) {
return this->cacheGlyphDataComplete();
}
return 0;
}
/**
*
* \overload
*/
uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
return this->loadFont((char*)fontPath, (uint8_t *)fontBuffer, bufferSize, pointSize, cacheAll);
}
void FreeTypeGX::unloadFont() {
clearGlyphData();
if (this->ftFace) {
FT_Done_Face(this->ftFace);
this->ftFace = NULL;
}
if (this->ftFace_fromFile) {
free(this->ftFace_fromFile);
this->ftFace_fromFile = NULL;
}
}
/**
* Clears all loaded font glyph data.
*
* This routine clears all members of the font map structure and frees all allocated memory back to the system.
*/
void FreeTypeGX::clearGlyphData() {
if (this->fontData.size() == 0)
void FreeTypeGX::unloadFont()
{
if(this->fontData.size() == 0)
return;
GX_DrawDone();
GX_Flush();
for ( std::map<wchar_t, ftgxCharData>::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) {
for(std::map<wchar_t, ftgxCharData>::iterator i = this->fontData.begin(); i != this->fontData.end(); i++)
free(i->second.glyphDataTexture);
}
this->fontData.clear();
}
void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) {
this->clearGlyphData();
this->ftPointSize = vPointSize;
FT_Set_Pixel_Sizes(this->ftFace, hPointSize, this->ftPointSize);
}
/**
* Adjusts the texture data buffer to necessary width for a given texture format.
*
@ -296,10 +266,12 @@ void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) {
* @param textureFormat The texture format to which the data is to be converted.
* @return The correctly adjusted texture width.
*/
uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat) {
uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat)
{
uint16_t alignment;
switch (textureFormat) {
switch(textureFormat)
{
case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */
case GX_TF_I8: /* 8x4 Tiles - 8-bit Intensity */
case GX_TF_IA4: /* 8x4 Tiles - 4-bit Intensity, , 4-bit Alpha */
@ -315,7 +287,6 @@ uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFo
break;
}
return textureWidth % alignment == 0 ? textureWidth : alignment + textureWidth - (textureWidth % alignment);
}
/**
@ -327,10 +298,12 @@ uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFo
* @param textureFormat The texture format to which the data is to be converted.
* @return The correctly adjusted texture height.
*/
uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat) {
uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat)
{
uint16_t alignment;
switch (textureFormat) {
switch(textureFormat)
{
case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */
alignment = 8;
break;
@ -346,7 +319,6 @@ uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t texture
break;
}
return textureHeight % alignment == 0 ? textureHeight : alignment + textureHeight - (textureHeight % alignment);
}
/**
@ -358,29 +330,30 @@ uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t texture
* @param charCode The requested glyph's character code.
* @return A pointer to the allocated font structure.
*/
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) {
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode)
{
FT_UInt gIndex;
uint16_t textureWidth = 0, textureHeight = 0;
gIndex = FT_Get_Char_Index( this->ftFace, charCode );
if (!FT_Load_Glyph(this->ftFace, gIndex, FT_LOAD_DEFAULT )) {
FT_Render_Glyph( this->ftSlot, FT_RENDER_MODE_NORMAL );
gIndex = FT_Get_Char_Index( ftFace, charCode );
if (!FT_Load_Glyph(ftFace, gIndex, FT_LOAD_DEFAULT )) {
FT_Render_Glyph( ftSlot, FT_RENDER_MODE_NORMAL );
if (this->ftSlot->format == FT_GLYPH_FORMAT_BITMAP) {
FT_Bitmap *glyphBitmap = &this->ftSlot->bitmap;
if(ftSlot->format == FT_GLYPH_FORMAT_BITMAP) {
FT_Bitmap *glyphBitmap = &ftSlot->bitmap;
textureWidth = adjustTextureWidth(glyphBitmap->width, this->textureFormat);
textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat);
this->fontData[charCode] = (ftgxCharData) {
this->ftSlot->bitmap_left,
this->ftSlot->advance.x >> 6,
this->fontData[charCode] = (ftgxCharData){
ftSlot->bitmap_left,
ftSlot->advance.x >> 6,
gIndex,
textureWidth,
textureHeight,
this->ftSlot->bitmap_top,
this->ftSlot->bitmap_top,
glyphBitmap->rows - this->ftSlot->bitmap_top,
ftSlot->bitmap_top,
ftSlot->bitmap_top,
glyphBitmap->rows - ftSlot->bitmap_top,
NULL
};
this->loadGlyphData(glyphBitmap, &this->fontData[charCode]);
@ -388,7 +361,6 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) {
return &this->fontData[charCode];
}
}
return NULL;
}
@ -398,19 +370,17 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) {
* This routine locates each character in the configured font face and renders the glyph's bitmap.
* Each bitmap and relevant information is loaded into its own quickly addressible structure within an instance-specific map.
*/
uint16_t FreeTypeGX::cacheGlyphDataComplete() {
uint16_t FreeTypeGX::cacheGlyphDataComplete()
{
uint16_t i = 0;
FT_UInt gIndex;
FT_ULong charCode = FT_Get_First_Char( this->ftFace, &gIndex );
while ( gIndex != 0 ) {
if (this->cacheGlyphData(charCode) != NULL) {
FT_ULong charCode = FT_Get_First_Char( ftFace, &gIndex );
while ( gIndex != 0 )
{
if(this->cacheGlyphData(charCode) != NULL)
i++;
charCode = FT_Get_Next_Char( ftFace, charCode, &gIndex );
}
charCode = FT_Get_Next_Char( this->ftFace, charCode, &gIndex );
}
return i;
}
@ -423,19 +393,22 @@ uint16_t FreeTypeGX::cacheGlyphDataComplete() {
* @param bmp A pointer to the most recently rendered glyph's bitmap.
* @param charData A pointer to an allocated ftgxCharData structure whose data represent that of the last rendered glyph.
*/
void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData)
{
uint32_t *glyphData = (uint32_t *)memalign(32, charData->textureWidth * charData->textureHeight * 4);
memset(glyphData, 0x00, charData->textureWidth * charData->textureHeight * 4);
for (uint16_t imagePosY = 0; imagePosY < bmp->rows; imagePosY++) {
for (uint16_t imagePosX = 0; imagePosX < bmp->width; imagePosX++) {
for (uint16_t imagePosY = 0; imagePosY < bmp->rows; imagePosY++)
{
for (uint16_t imagePosX = 0; imagePosX < bmp->width; imagePosX++)
{
uint32_t pixel = (uint32_t) bmp->buffer[imagePosY * bmp->width + imagePosX];
glyphData[imagePosY * charData->textureWidth + imagePosX] = 0x00000000 | (pixel << 24) | (pixel << 16) | (pixel << 8) | pixel;
}
}
switch (this->textureFormat) {
switch(this->textureFormat)
{
case GX_TF_I4:
charData->glyphDataTexture = Metaphrasis::convertBufferToI4(glyphData, charData->textureWidth, charData->textureHeight);
break;
@ -459,7 +432,6 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
charData->glyphDataTexture = Metaphrasis::convertBufferToRGBA8(glyphData, charData->textureWidth, charData->textureHeight);
break;
}
free(glyphData);
}
@ -471,20 +443,14 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
* @param width Current pixel width of the string.
* @param format Positional format of the string.
*/
int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
switch (format & FTGX_JUSTIFY_MASK) {
case FTGX_JUSTIFY_LEFT:
int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format)
{
if (format & FTGX_JUSTIFY_LEFT)
return 0;
default:
case FTGX_JUSTIFY_CENTER:
else if (format & FTGX_JUSTIFY_CENTER)
return -(width >> 1);
case FTGX_JUSTIFY_RIGHT:
else if (format & FTGX_JUSTIFY_RIGHT)
return -width;
}
return 0;
}
@ -496,8 +462,10 @@ int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) {
* @param offset Current pixel offset data of the string.
* @param format Positional format of the string.
*/
int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format) {
switch (format & FTGX_ALIGN_MASK) {
int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format)
{
switch(format & FTGX_ALIGN_MASK)
{
case FTGX_ALIGN_TOP:
return offset->ascender;
@ -520,7 +488,6 @@ int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format
case FTGX_ALIGN_GLYPH_BOTTOM:
return offset->min;
}
return 0;
}
@ -537,7 +504,11 @@ int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format
* @param textStyle Flags which specify any styling which should be applied to the rendered string.
* @return The number of characters printed.
*/
uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color, uint16_t textStyle) {
uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color, uint16_t textStyle)
{
if(!text)
return 0;
uint16_t strLength = wcslen(text);
uint16_t x_pos = x, printed = 0;
uint16_t x_offset = 0, y_offset = 0;
@ -545,26 +516,33 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color
FT_Vector pairDelta;
ftgxDataOffset offset;
if (textStyle & FTGX_JUSTIFY_MASK) {
if(textStyle & FTGX_JUSTIFY_MASK)
{
x_offset = this->getStyleOffsetWidth(this->getWidth(text), textStyle);
}
if (textStyle & FTGX_ALIGN_MASK) {
y_offset = this->getStyleOffsetHeight(this->getOffset(text, &offset), textStyle);
if(textStyle & FTGX_ALIGN_MASK)
{
this->getOffset(text, &offset);
y_offset = this->getStyleOffsetHeight(&offset, textStyle);
}
for (uint16_t i = 0; i < strLength; i++) {
for (uint16_t i = 0; i < strLength; i++)
{
ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
if( this->fontData.find(text[i]) != this->fontData.end() )
{
glyphData = &this->fontData[text[i]];
} else {
}
else
{
glyphData = this->cacheGlyphData(text[i]);
}
if (glyphData != NULL) {
if (this->ftKerningEnabled && i) {
FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
if(glyphData != NULL)
{
if(this->ftKerningEnabled && i)
{
FT_Get_Kerning( ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
x_pos += pairDelta.x >> 6;
}
@ -576,8 +554,10 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color
}
}
if (textStyle & FTGX_STYLE_MASK) {
this->drawTextFeature(x + x_offset, y + y_offset, this->getWidth(text), this->getOffset(text, &offset), textStyle, color);
if(textStyle & FTGX_STYLE_MASK)
{
this->getOffset(text, &offset);
this->drawTextFeature(x + x_offset, y + y_offset, this->getWidth(text), &offset, textStyle, color);
}
return printed;
@ -586,51 +566,20 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color
/**
* \overload
*/
uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color, uint16_t textStyle) {
uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color, uint16_t textStyle)
{
return this->drawText(x, y, (wchar_t *)text, color, textStyle);
}
void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color) {
void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color)
{
uint16_t featureHeight = this->ftPointSize >> 4 > 0 ? this->ftPointSize >> 4 : 1;
if (format & FTGX_STYLE_UNDERLINE ) {
switch (format & FTGX_ALIGN_MASK) {
/*
case FTGX_ALIGN_TOP:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + offsetData->max + 1, color);
break;
case FTGX_ALIGN_MIDDLE:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color);
break;
case FTGX_ALIGN_BOTTOM:
this->copyFeatureToFramebuffer(width, featureHeight, x, y - offsetData->min, color);
break;
*/
default:
if (format & FTGX_STYLE_UNDERLINE)
this->copyFeatureToFramebuffer(width, featureHeight, x, y + 1, color);
break;
}
}
if (format & FTGX_STYLE_STRIKE ) {
switch (format & FTGX_ALIGN_MASK) {
/*
case FTGX_ALIGN_TOP:
this->copyFeatureToFramebuffer(width, featureHeight, x, y + ((offsetData->max - offsetData->min + 1) >> 1), color);
break;
case FTGX_ALIGN_MIDDLE:
this->copyFeatureToFramebuffer(width, featureHeight, x, y, color);
break;
case FTGX_ALIGN_BOTTOM:
this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max + offsetData->min) >> 1), color);
break;
*/
default:
// this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max - offsetData->min) >> 1), color);
if (format & FTGX_STYLE_STRIKE)
this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max) >> 1), color);
break;
}
}
}
/**
@ -642,30 +591,38 @@ void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataO
* @param text NULL terminated string to calculate.
* @return The width of the text string in pixels.
*/
uint16_t FreeTypeGX::getWidth(wchar_t *text) {
uint16_t FreeTypeGX::getWidth(wchar_t *text)
{
if(!text)
return 0;
uint16_t strLength = wcslen(text);
uint16_t strWidth = 0;
FT_Vector pairDelta;
for (uint16_t i = 0; i < strLength; i++) {
for (uint16_t i = 0; i < strLength; i++)
{
ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
if( this->fontData.find(text[i]) != this->fontData.end() )
{
glyphData = &this->fontData[text[i]];
} else {
}
else
{
glyphData = this->cacheGlyphData(text[i]);
}
if (glyphData != NULL) {
if (this->ftKerningEnabled && (i > 0)) {
FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
if(glyphData != NULL)
{
if(this->ftKerningEnabled && (i > 0))
{
FT_Get_Kerning( ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
strWidth += pairDelta.x >> 6;
}
strWidth += glyphData->glyphAdvanceX;
}
}
return strWidth;
}
@ -673,7 +630,8 @@ uint16_t FreeTypeGX::getWidth(wchar_t *text) {
*
* \overload
*/
uint16_t FreeTypeGX::getWidth(wchar_t const *text) {
uint16_t FreeTypeGX::getWidth(wchar_t const *text)
{
return this->getWidth((wchar_t *)text);
}
@ -686,10 +644,10 @@ uint16_t FreeTypeGX::getWidth(wchar_t const *text) {
* @param text NULL terminated string to calculate.
* @return The height of the text string in pixels.
*/
uint16_t FreeTypeGX::getHeight(wchar_t *text) {
uint16_t FreeTypeGX::getHeight(wchar_t *text)
{
ftgxDataOffset offset;
this->getOffset(text, &offset);
return offset.max - offset.min;
}
@ -697,7 +655,8 @@ uint16_t FreeTypeGX::getHeight(wchar_t *text) {
*
* \overload
*/
uint16_t FreeTypeGX::getHeight(wchar_t const *text) {
uint16_t FreeTypeGX::getHeight(wchar_t const *text)
{
return this->getHeight((wchar_t *)text);
}
@ -711,37 +670,43 @@ uint16_t FreeTypeGX::getHeight(wchar_t const *text) {
* @param offset returns the max and min values above and below the font origin line
*
*/
ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) {
void FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset)
{
uint16_t strLength = wcslen(text);
int16_t strMax = 0, strMin = 9999;
for (uint16_t i = 0; i < strLength; i++) {
for (uint16_t i = 0; i < strLength; i++)
{
ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) {
if( this->fontData.find(text[i]) != this->fontData.end() )
{
glyphData = &this->fontData[text[i]];
} else {
}
else
{
glyphData = this->cacheGlyphData(text[i]);
}
if (glyphData != NULL) {
if(glyphData != NULL)
{
strMax = glyphData->renderOffsetMax > strMax ? glyphData->renderOffsetMax : strMax;
strMin = glyphData->renderOffsetMin < strMin ? glyphData->renderOffsetMin : strMin;
}
}
offset->ascender = this->ftFace->size->metrics.ascender>>6;
offset->descender = this->ftFace->size->metrics.descender>>6;
offset->ascender = ftFace->size->metrics.ascender>>6;
offset->descender = ftFace->size->metrics.descender>>6;
offset->max = strMax;
offset->min = strMin;
return offset;
}
/**
*
* \overload
*/
ftgxDataOffset* FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset) {
return this->getOffset(text, offset);
void FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset)
{
this->getOffset(text, offset);
}
/**
@ -756,8 +721,8 @@ ftgxDataOffset* FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offse
* @param screenY The screen Y coordinate at which to output the rendered texture.
* @param color Color to apply to the texture.
*/
void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color) {
void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color)
{
GX_LoadTexObj(texObj, GX_TEXMAP0);
GX_InvalidateTexAll();
@ -781,6 +746,7 @@ void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 te
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_TexCoord2f32(0.0f, 1.0f);
GX_End();
GX_DrawDone();
this->setDefaultMode();
}
@ -796,8 +762,8 @@ void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 te
* @param screenY The screen Y coordinate at which to output the quad.
* @param color Color to apply to the texture.
*/
void FreeTypeGX::copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color) {
void FreeTypeGX::copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color)
{
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
@ -814,6 +780,7 @@ void FreeTypeGX::copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, i
GX_Position2s16(screenX, featureHeight + screenY);
GX_Color4u8(color.r, color.g, color.b, color.a);
GX_End();
GX_DrawDone();
this->setDefaultMode();
}

View File

@ -156,14 +156,45 @@
#include FT_FREETYPE_H
#include FT_BITMAP_H
#include "Metaphrasis.h"
#include "filelist.h"
#include <malloc.h>
#include <string.h>
#include <wchar.h>
#include <map>
/*! forward deklaration of private structures
#define MAX_FONT_SIZE 100
/*! \struct ftgxCharData_
*
* Font face character glyph relevant data structure.
*/
typedef struct ftgxCharData_ {
int16_t renderOffsetX; /**< Texture X axis bearing offset. */
uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */
uint16_t glyphIndex; /**< Charachter glyph index in the font face. */
uint16_t textureWidth; /**< Texture width in pixels/bytes. */
uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */
int16_t renderOffsetY; /**< Texture Y axis bearing offset. */
int16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */
int16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */
uint32_t* glyphDataTexture; /**< Glyph texture bitmap data buffer. */
} ftgxCharData;
/*! \struct ftgxDataOffset_
*
* Offset structure which hold both a maximum and minimum value.
*/
typedef struct ftgxDataOffset_ {
int16_t ascender; /**< Maximum data offset. */
int16_t descender; /**< Minimum data offset. */
int16_t max; /**< Maximum data offset. */
int16_t min; /**< Minimum data offset. */
} ftgxDataOffset;
typedef struct ftgxCharData_ ftgxCharData;
typedef struct ftgxDataOffset_ ftgxDataOffset;
@ -172,21 +203,21 @@ typedef struct ftgxDataOffset_ ftgxDataOffset;
#define FTGX_NULL 0x0000
#define FTGX_JUSTIFY_LEFT 0x0001
#define FTGX_JUSTIFY_CENTER 0x0002
#define FTGX_JUSTIFY_RIGHT 0x0003
#define FTGX_JUSTIFY_RIGHT 0x0004
#define FTGX_JUSTIFY_MASK 0x000f
#define FTGX_ALIGN_TOP 0x0010
#define FTGX_ALIGN_MIDDLE 0x0020
#define FTGX_ALIGN_BOTTOM 0x0030
#define FTGX_ALIGN_BASELINE 0x0040
#define FTGX_ALIGN_GLYPH_TOP 0x0050
#define FTGX_ALIGN_GLYPH_MIDDLE 0x0060
#define FTGX_ALIGN_GLYPH_BOTTOM 0x0070
#define FTGX_ALIGN_MASK 0x00f0
#define FTGX_ALIGN_BOTTOM 0x0040
#define FTGX_ALIGN_BASELINE 0x0080
#define FTGX_ALIGN_GLYPH_TOP 0x0100
#define FTGX_ALIGN_GLYPH_MIDDLE 0x0200
#define FTGX_ALIGN_GLYPH_BOTTOM 0x0400
#define FTGX_ALIGN_MASK 0x0ff0
#define FTGX_STYLE_UNDERLINE 0x0100
#define FTGX_STYLE_STRIKE 0x0200
#define FTGX_STYLE_MASK 0x0f00
#define FTGX_STYLE_UNDERLINE 0x1000
#define FTGX_STYLE_STRIKE 0x2000
#define FTGX_STYLE_MASK 0xf000
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE 0X0001
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL 0X0002
@ -203,10 +234,11 @@ typedef struct ftgxDataOffset_ ftgxDataOffset;
#define FTGX_COMPATIBILITY_GRRLIB FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE
#define FTGX_COMPATIBILITY_LIBWIISPRITE FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT
const GXColor ftgxWhite = (GXColor) {
0xff, 0xff, 0xff, 0xff
}
; /**< Constant color value used only to sanitize Doxygen documentation. */
const GXColor ftgxWhite = (GXColor){0xff, 0xff, 0xff, 0xff}; /**< Constant color value used only to sanitize Doxygen documentation. */
wchar_t* charToWideChar(const char* p);
bool LoadCustomFont(const char *path);
void ClearFontData();
/*! \class FreeTypeGX
* \brief Wrapper class for the libFreeType library with GX rendering.
@ -219,10 +251,9 @@ const GXColor ftgxWhite = (GXColor) {
*/
class FreeTypeGX {
private:
private:
FT_Library ftLibrary; /**< FreeType FT_Library instance. */
FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
FT_Byte *ftFace_fromFile;
FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */
FT_UInt ftPointSize; /**< Requested size of the rendered font. */
bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */
@ -239,7 +270,6 @@ private:
static int16_t getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format);
void unloadFont();
void clearGlyphData();
ftgxCharData *cacheGlyphData(wchar_t charCode);
uint16_t cacheGlyphDataComplete();
void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData);
@ -250,19 +280,18 @@ private:
void copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color);
void copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color);
public:
FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1);
public:
FreeTypeGX(FT_UInt pixelSize, uint8_t textureFormat, uint8_t vertexIndex);
FreeTypeGX(FT_UInt pixelSize, bool loadcustomfont = true, uint8_t* fontBuffer = (u8*)font_ttf, FT_Long bufferSize = font_ttf_size, uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1);
~FreeTypeGX();
static wchar_t* charToWideChar(char* p);
static wchar_t* charToWideChar(const char* p);
void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize, bool loadcustomfont);
void ChangeFontSize(FT_UInt pixelSize);
uint8_t GetMaxCharWidth();
void setVertexFormat(uint8_t vertexIndex);
void setCompatibilityMode(uint32_t compatibilityMode);
uint16_t loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
uint16_t loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
void changeSize(FT_UInt vPointSize, FT_UInt hPointSize=0);
uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
uint16_t drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
@ -270,8 +299,8 @@ public:
uint16_t getWidth(wchar_t const *text);
uint16_t getHeight(wchar_t *text);
uint16_t getHeight(wchar_t const *text);
ftgxDataOffset* getOffset(wchar_t *text, ftgxDataOffset* offset);
ftgxDataOffset* getOffset(wchar_t const *text, ftgxDataOffset* offset);
void getOffset(wchar_t *text, ftgxDataOffset* offset);
void getOffset(wchar_t const *text, ftgxDataOffset* offset);
};
#endif /* FREETYPEGX_H_ */

View File

@ -82,7 +82,7 @@ int CheatMenu(const char * gameID) {
GuiText titleTxt(c.getGameName().c_str(), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetMaxWidth(350, GuiText::SCROLL);
titleTxt.SetMaxWidth(350, SCROLL_HORIZONTAL);
titleTxt.SetPosition(12,40);
for (int i = 0; i <= cntcheats; i++) {

View File

@ -150,7 +150,7 @@ int MenuHomebrewBrowse() {
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
backBtnTxt.SetWidescreen(CFG.widescreen);
//backBtnTxt.SetWidescreen(CFG.widescreen);
backBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -180, 400, &trigA, &btnSoundOver, &btnClick,1);
@ -190,15 +190,15 @@ int MenuHomebrewBrowse() {
GuiImage MainButton1Img(&MainButtonImgData);
GuiImage MainButton1ImgOver(&MainButtonImgOverData);
GuiText MainButton1Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()-150, DOTTED);
MainButton1Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1Txt.SetPosition(148, -12);
GuiText MainButton1DescTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton1DescTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::DOTTED);
MainButton1DescTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, DOTTED);
MainButton1DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1DescTxt.SetPosition(148, 15);
GuiText MainButton1DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL);
MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, SCROLL_HORIZONTAL);
MainButton1DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton1DescOverTxt.SetPosition(148, 15);
GuiButton MainButton1(MainButton1Img.GetWidth(), MainButton1Img.GetHeight());
@ -219,15 +219,15 @@ int MenuHomebrewBrowse() {
GuiText MainButton2Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
MainButton2Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2Txt.SetPosition(148, -12);
MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()-150, DOTTED);
GuiText MainButton2DescTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton2DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2DescTxt.SetPosition(148, 15);
MainButton2DescTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::DOTTED);
MainButton2DescTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, DOTTED);
GuiText MainButton2DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton2DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton2DescOverTxt.SetPosition(148, 15);
MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL);
MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, SCROLL_HORIZONTAL);
GuiButton MainButton2(MainButton2Img.GetWidth(), MainButton2Img.GetHeight());
MainButton2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton2.SetPosition(0, 160);
@ -246,15 +246,15 @@ int MenuHomebrewBrowse() {
GuiText MainButton3Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton3Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3Txt.SetPosition(148, -12);
MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()-150, DOTTED);
GuiText MainButton3DescTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton3DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3DescTxt.SetPosition(148, 15);
MainButton3DescTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::DOTTED);
MainButton3DescTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, DOTTED);
GuiText MainButton3DescOverTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255 });
MainButton3DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton3DescOverTxt.SetPosition(148, 15);
MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL);
MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, SCROLL_HORIZONTAL);
GuiButton MainButton3(MainButton3Img.GetWidth(), MainButton3Img.GetHeight());
MainButton3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton3.SetPosition(0, 230);
@ -273,15 +273,15 @@ int MenuHomebrewBrowse() {
GuiText MainButton4Txt(MainButtonText, 18, (GXColor) {0, 0, 0, 255} );
MainButton4Txt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4Txt.SetPosition(148, -12);
MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()-150, DOTTED);
GuiText MainButton4DescTxt(MainButtonText, 18, (GXColor) {0, 0, 0, 255});
MainButton4DescTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4DescTxt.SetPosition(148, 15);
MainButton4DescTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::DOTTED);
MainButton4DescTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, DOTTED);
GuiText MainButton4DescOverTxt(MainButtonText, 18, (GXColor) { 0, 0, 0, 255});
MainButton4DescOverTxt.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
MainButton4DescOverTxt.SetPosition(148, 15);
MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL);
MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, SCROLL_HORIZONTAL );
GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight());
MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
MainButton4.SetPosition(0, 300);

View File

@ -47,13 +47,14 @@
#include "input.h"
#include "oggplayer.h"
extern FreeTypeGX *fontSystem;
extern FreeTypeGX *fontSystem[];
#define SCROLL_INITIAL_DELAY 20
#define SCROLL_LOOP_DELAY 3
#define PAGESIZE 9
#define FILEBROWSERSIZE 8
#define MAX_OPTIONS 170
#define MAX_LINES_TO_DRAW 30
typedef void (*UpdateCallback)(void * e);
@ -90,6 +91,15 @@ enum
IMAGE_COPY
};
enum
{
WRAP,
LONGTEXT,
DOTTED,
SCROLL_HORIZONTAL,
SCROLL_NONE
};
enum
{
TRIGGER_SIMPLE,
@ -699,8 +709,8 @@ class GuiText : public GuiElement
//!Sets the text of the GuiText element
//!\param t Text
void SetText(const char * t);
void SetTextf(const char *format, ...) __attribute__((format(printf,2,3)));
void SetText(const wchar_t * t);
void SetTextf(const char *format, ...) __attribute__((format(printf,2,3)));
//!Sets up preset values to be used by GuiText(t)
//!Useful when printing multiple text elements, all with the same attributes set
//!\param sz Font size
@ -710,28 +720,30 @@ class GuiText : public GuiElement
//!\param s Font style
//!\param h Text alignment (horizontal)
//!\param v Text alignment (vertical)
static void SetPresets(int sz, GXColor c, int w, int wrap, u16 s, int h, int v);
void SetPresets(int sz, GXColor c, int w, u16 s, int h, int v);
//!Sets the font size
//!\param s Font size
void SetFontSize(int s);
//!Sets the first line to draw (default = 0)
//!\param line
void SetFirstLine(int line);
//!Sets max lines to draw
//!\param lines
void SetLinesToDraw(int lines);
//!Gets the total line number
int GetTotalLines();
//!Sets the maximum width of the drawn texture image
//!If the text exceeds this, it is wrapped to the next line
//!\param w Maximum width
//!\param m WrapMode
enum {
WRAP,
DOTTED,
SCROLL,
MARQUEE
};
void SetMaxWidth(int w, short m=GuiText::WRAP);
void SetMaxWidth(int w = 0, int m = WRAP);
//!Sets the font color
//!\param c Font color
void SetColor(GXColor c);
//!Sets the FreeTypeGX style attributes
//!\param s Style attributes
//!\param m Style-Mask attributes
void SetStyle(u16 s, u16 m=0xffff);
void SetStyle(u16 s);
//!Sets the text alignment
//!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE)
//!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE)
@ -741,33 +753,35 @@ class GuiText : public GuiElement
void SetFont(FreeTypeGX *f);
//!Get the Horizontal Size of Text
int GetTextWidth();
// not NULL set horizontal scale to 0.75 //added
void SetWidescreen(bool w);
void SetNumLines(int n);//! these two are used to set the first line and numLine
void SetFirstLine(int n);
int GetNumLines();//! these return the line variables for this text
int GetFirstLine();
int GetLineHeight(int n);//! returns the height of the #n of lines including spacing if wrap mode is on
int GetTotalLines();
//!Get the offset of a linebreak
u32 GetLineBreakOffset(int line);
//!Change the font
//!\param font bufferblock
//!\param font filesize
bool SetFont(const u8 *font, const u32 filesize);
//!Constantly called to draw the text
void Draw();
protected:
wchar_t* text; //!< Unicode text value
wchar_t *text;
wchar_t *textDyn; //!< Wrapped text value
wchar_t *textDynRow[MAX_LINES_TO_DRAW]; //!< Wrapped lines text values
char *origText; //!< Original text data
int wrapMode; //!< Wrapping toggle
int textScrollPos; //!< Current starting index of text string for scrolling
int textScrollInitialDelay; //!< Delay to wait before starting to scroll
int textScrollDelay; //!< Scrolling speed
int size; //!< Font size
int maxWidth; //!< Maximum width of the generated text object (for text wrapping)
short wrapMode;
short scrollPos1;
short scrollPos2;
short scrollOffset;
u32 scrollDelay;
u16 style; //!< FreeTypeGX style attributes
GXColor color; //!< Font color
FreeTypeGX *font;
short widescreen; //added
//!these are default until the text is drawn
int firstLine; //!these are the first line and the number of lines drawn when the text is wrapped
int numLines;//! default is -1 and it means that all lines are drawn
int totalLines; //!this is the total # of lines when in wrap mode
bool widescreen; //added
int firstLine;
int linestodraw;
int totalLines;
int textWidth;
int currentSize;
u32 *LineBreak;
};
//!Display, manage, and manipulate tooltips in the GUI.
@ -980,6 +994,7 @@ class GuiKeyboard : public GuiWindow
GuiTrigger * trigB;
};
typedef struct _optionlist {
int length;
char name[MAX_OPTIONS][60];

View File

@ -187,7 +187,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
optionTxt[i] = new GuiText(options->GetName(i), 20, THEME.settingstext);
optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionTxt[i]->SetPosition(24,0);
optionTxt[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::DOTTED);
optionTxt[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), DOTTED);
optionBg[i] = new GuiImage(bgOptionsEntry);
@ -424,10 +424,10 @@ void GuiCustomOptionBrowser::UpdateListEntries()
if(optionBtn[i]->GetState() != STATE_DISABLED)
{
optionVal[i]->SetPosition(coL2,0);
optionVal[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::DOTTED);
optionVal[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), DOTTED);
optionValOver[i]->SetPosition(coL2,0);
optionValOver[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::SCROLL);
optionValOver[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), SCROLL_HORIZONTAL);
}
}
}

View File

@ -111,12 +111,12 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
fileListText[i] = new GuiText(NULL,20, (GXColor){0, 0, 0, 0xff});
fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
fileListText[i]->SetPosition(5,0);
fileListText[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth()+20), GuiText::DOTTED);
fileListText[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth()+20), DOTTED);
fileListTextOver[i] = new GuiText(NULL,20, (GXColor){0, 0, 0, 0xff});
fileListTextOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
fileListTextOver[i]->SetPosition(5,0);
fileListTextOver[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth()+20), GuiText::SCROLL);
fileListTextOver[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth()+20), SCROLL_HORIZONTAL);
fileListBg[i] = new GuiImage(bgFileSelectionEntry);
//fileListArchives[i] = new GuiImage(fileArchives);

View File

@ -127,13 +127,13 @@ GuiGameBrowser::GuiGameBrowser(int w, int h, struct discHdr * l, int gameCnt, co
gameTxt[i] = new GuiText(get_title(&gameList[i]), 20, THEME.gametext);
gameTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
gameTxt[i]->SetPosition(24,0);
gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::DOTTED);
gameTxt[i]->SetMaxWidth(maxTextWidth, DOTTED);
gameTxtOver[i] = new GuiText(get_title(&gameList[i]), 20, THEME.gametext);
gameTxtOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
gameTxtOver[i]->SetPosition(24,0);
gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL);
gameTxtOver[i]->SetMaxWidth(maxTextWidth, SCROLL_HORIZONTAL);
gameBg[i] = new GuiImage(bgGamesEntry);

View File

@ -111,7 +111,7 @@ noCover(nocover_png)
gamename->SetParent(this);
gamename->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
gamename->SetPosition(0, 330);
gamename->SetMaxWidth(280, GuiText::DOTTED);
gamename->SetMaxWidth(280, DOTTED);
gameIndex = new int[pagesize];
game = new GuiButton * [pagesize];

View File

@ -69,8 +69,8 @@ sndClick(button_click_pcm, button_click_pcm_size, SOUND_PCM, Settings.sfxvolume)
text.SetText(gameFilter);
text.SetPosition(10, 15);
text.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
text.SetWidescreen(CFG.widescreen);
text.SetMaxWidth(width-(10+2*42+10), GuiText::SCROLL);
//text.SetWidescreen(CFG.widescreen);
text.SetMaxWidth(width-(10+2*42+10), SCROLL_HORIZONTAL);
this->Append(&text);
snprintf(imgPath, sizeof(imgPath), "%skeyboard_backspace_over.png", CFG.theme_path);

View File

@ -10,42 +10,62 @@
#include "gui.h"
static int currentSize = 0;
static int currentWidescreen = 0;
static int presetSize = 0;
static GXColor presetColor = (GXColor){255, 255, 255, 255};
static int presetSize = 18;
static int presetMaxWidth = 0;
static int presetWrapMode = GuiText::WRAP;
static u16 presetStyle = FTGX_NULL;
static int presetAlignmentHor = 0;
static int presetAlignmentVert = 0;
static int presetWrapMode = 0;
static u16 presetStyle = FTGX_NULL;
static GXColor presetColor = (GXColor){255, 255, 255, 255};
#define TEXT_SCROLL_DELAY 5
#define TEXT_SCROLL_INITIAL_DELAY 8
/**
* Constructor for the GuiText class.
*/
GuiText::GuiText(const char * t, int s, GXColor c)
{
origText = NULL;
text = NULL;
size = s;
currentSize = size;
color = c;
alpha = c.a;
style = FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE;
maxWidth = 0;
wrapMode = GuiText::WRAP;
scrollPos1 = 0;
scrollPos2 = 0;
scrollDelay = 0;
font = NULL;
wrapMode = 0;
firstLine = 0;
linestodraw = 8;
totalLines = 0;
widescreen = 0; //added
firstLine = 1;
numLines = -1;
totalLines = 1;
LineBreak = NULL;
textDyn = NULL;
font = NULL;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE;
for(int i = 0; i < MAX_LINES_TO_DRAW; i++)
textDynRow[i] = NULL;
if(t)
text = FreeTypeGX::charToWideChar((char *)t);
{
origText = strdup(t);
text = charToWideChar(t);
if(currentSize > MAX_FONT_SIZE)
currentSize = MAX_FONT_SIZE;
if(!fontSystem[currentSize])
{
fontSystem[currentSize] = new FreeTypeGX(currentSize);
}
textWidth = fontSystem[currentSize]->getWidth(text);
}
}
/**
@ -53,27 +73,46 @@ GuiText::GuiText(const char * t, int s, GXColor c)
*/
GuiText::GuiText(const char * t)
{
origText = NULL;
text = NULL;
size = presetSize;
currentSize = size;
color = presetColor;
alpha = presetColor.a;
style = presetStyle;
maxWidth = presetMaxWidth;
wrapMode = presetWrapMode;
scrollPos1 = 0;
scrollPos2 = 0;
scrollDelay = 0;
font = NULL;
firstLine = 0;
linestodraw = 8;
totalLines = 0;
widescreen = 0; //added
firstLine = 1;
numLines = -1;
totalLines = 1;
LineBreak = NULL;
textDyn = NULL;
font = NULL;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
alignmentHor = presetAlignmentHor;
alignmentVert = presetAlignmentVert;
for(int i = 0; i < MAX_LINES_TO_DRAW; i++)
textDynRow[i] = NULL;
if(t)
text = FreeTypeGX::charToWideChar((char *)t);
{
origText = strdup(t);
text = charToWideChar(t);
if(currentSize > MAX_FONT_SIZE)
currentSize = MAX_FONT_SIZE;
if(!fontSystem[currentSize])
{
fontSystem[currentSize] = new FreeTypeGX(currentSize);
}
textWidth = fontSystem[currentSize]->getWidth(text);
}
}
/**
@ -81,64 +120,105 @@ GuiText::GuiText(const char * t)
*/
GuiText::~GuiText()
{
if(origText)
free(origText);
if(text)
{
delete [] text;
text = NULL;
if(textDyn)
delete [] textDyn;
if(LineBreak) {
free(LineBreak);
LineBreak = NULL;
}
if(font)
{
delete font;
font = NULL;
}
for(int i = 0; i < MAX_LINES_TO_DRAW; i++)
{
if(textDynRow[i])
{
delete [] textDynRow[i];
textDynRow[i] = NULL;
}
}
}
void GuiText::SetNumLines(int n)
{
numLines = n;
}
void GuiText::SetFirstLine(int n)
{
firstLine = n;
}
int GuiText::GetNumLines()
{
return numLines;
}
int GuiText::GetFirstLine()
{
return firstLine;
}
int GuiText::GetTotalLines()
{
return totalLines;
}
int GuiText::GetLineHeight(int n)
{
int newSize = size*this->GetScale();
int lineheight = newSize + 6;
if (numLines <0)
return totalLines*lineheight+newSize;
else return numLines*lineheight+newSize;
}
void GuiText::SetText(const char * t)
{
if(t && origText)
if(strcmp(t, origText) == 0)
return;
LOCK(this);
if(origText)
free(origText);
if(text)
delete [] text;
if(textDyn)
delete [] textDyn;
for(int i = 0; i < MAX_LINES_TO_DRAW; i++)
{
if(textDynRow[i])
{
delete [] textDynRow[i];
textDynRow[i] = NULL;
}
}
origText = NULL;
text = NULL;
textDyn = NULL;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
if(t)
text = FreeTypeGX::charToWideChar((char *)t);
scrollPos2 = 0;
scrollDelay = 0;
{
origText = strdup(t);
text = charToWideChar(t);
textWidth = fontSystem[currentSize]->getWidth(text);
}
}
void GuiText::SetText(const wchar_t * t)
{
LOCK(this);
if(origText)
free(origText);
if(text)
delete [] text;
if(textDyn)
delete [] textDyn;
for(int i = 0; i < MAX_LINES_TO_DRAW; i++)
{
if(textDynRow[i])
{
delete [] textDynRow[i];
textDynRow[i] = NULL;
}
}
origText = NULL;
text = NULL;
textDyn = NULL;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
if(t)
{
int len = wcslen(t);
text = new wchar_t[len+1];
if(text) wcscpy(text, t);
}
}
void GuiText::SetTextf(const char *format, ...)
{
LOCK(this);
char *tmp=0;
va_list va;
va_start(va, format);
@ -149,31 +229,14 @@ void GuiText::SetTextf(const char *format, ...)
}
va_end(va);
}
void GuiText::SetText(const wchar_t * t)
void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v)
{
LOCK(this);
if(text)
delete [] text;
text = NULL;
if(t)
{
int len = wcslen(t);
text = new wchar_t[len+1];
if(text) wcscpy(text, t);
}
scrollPos2 = 0;
scrollDelay = 0;
}
void GuiText::SetPresets(int sz, GXColor c, int w, int wrap, u16 s, int h, int v)
{
presetSize = sz;
presetColor = c;
presetMaxWidth = w;
presetWrapMode = wrap;
presetStyle = s;
presetMaxWidth = w;
presetAlignmentHor = h;
presetAlignmentVert = v;
}
@ -181,14 +244,109 @@ void GuiText::SetPresets(int sz, GXColor c, int w, int wrap, u16 s, int h, int v
void GuiText::SetFontSize(int s)
{
LOCK(this);
size = s;
}
void GuiText::SetMaxWidth(int w, short m/*=GuiText::WRAP*/)
void GuiText::SetMaxWidth(int width, int w)
{
LOCK(this);
maxWidth = w;
wrapMode = m;
maxWidth = width;
wrapMode = w;
if(w == LONGTEXT && text) {
int strlen = wcslen(text);
int i = 0;
int ch = 0;
int linenum = 0;
int lastSpace = -1;
int lastSpaceIndex = -1;
wchar_t *tmptext = new wchar_t[maxWidth];
LineBreak = (u32 *) malloc(sizeof(u32));
memset(&(LineBreak[linenum]), 0, sizeof(u32));
LineBreak[linenum] = 0;
linenum++;
while(ch < strlen)
{
tmptext[i] = text[ch];
tmptext[i+1] = 0;
if(text[ch] == ' ' || ch == strlen-1 || fontSystem[currentSize]->getWidth(tmptext) >= maxWidth)
{
if(fontSystem[currentSize]->getWidth(tmptext) >= maxWidth)
{
if(lastSpace >= 0)
{
tmptext[lastSpaceIndex] = 0; // discard space, and everything after
ch = lastSpace; // go backwards to the last space
lastSpace = -1; // we have used this space
lastSpaceIndex = -1;
}
LineBreak = (u32 *) realloc(LineBreak, (linenum+1)* sizeof(u32));
memset(&(LineBreak[linenum]), 0, sizeof(u32));
LineBreak[linenum] = ch;
linenum++;
i = -1;
}
}
if(text[ch] == ' ' && i >= 0)
{
lastSpace = ch+1;
lastSpaceIndex = i;
}
if(text[ch] == '\n')
{
LineBreak = (u32 *) realloc(LineBreak, (linenum+1)* sizeof(u32));
memset(&(LineBreak[linenum]), 0, sizeof(u32));
LineBreak[linenum] = ch+1;
linenum++;
i = -1;
lastSpace = -1;
lastSpaceIndex = -1;
}
ch++;
i++;
if(ch == strlen)
{
LineBreak = (u32 *) realloc(LineBreak, (linenum+1)* sizeof(u32));
memset(&(LineBreak[linenum]), 0, sizeof(u32));
LineBreak[linenum] = ch;
linenum++;
break;
}
}
delete [] tmptext;
totalLines = linenum;
}
else if(w == SCROLL_HORIZONTAL) {
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
}
if(textDyn)
{
delete [] textDyn;
textDyn = NULL;
}
for(int i = 0; i < MAX_LINES_TO_DRAW; i++)
{
if(textDynRow[i])
{
delete [] textDynRow[i];
textDynRow[i] = NULL;
}
}
}
void GuiText::SetColor(GXColor c)
@ -198,17 +356,16 @@ void GuiText::SetColor(GXColor c)
alpha = c.a;
}
void GuiText::SetStyle(u16 s, u16 m/*=0xffff*/)
void GuiText::SetStyle(u16 s)
{
LOCK(this);
style &= ~m;
style |= s & m;
style = s;
}
void GuiText::SetAlignment(int hor, int vert)
{
LOCK(this);
style = FTGX_NULL;
style = 0;
switch(hor)
{
@ -238,44 +395,81 @@ void GuiText::SetAlignment(int hor, int vert)
alignmentHor = hor;
alignmentVert = vert;
}
/**
* Set the Font
*/
void GuiText::SetFont(FreeTypeGX *f)
{
LOCK(this);
font = f;
}
int GuiText::GetTextWidth()
{
LOCK(this);
if(!text)
return 0;
int newSize = size*this->GetScale();
if(newSize != currentSize || currentWidescreen != widescreen)
{
//fontSystem->changeSize(newSize);
(font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0);
currentSize = newSize;
currentWidescreen = widescreen;
}
return (font ? font : fontSystem)->getWidth(text);
return fontSystem[currentSize]->getWidth(text);
}
void GuiText::SetWidescreen(bool w)
/**
* Set the lines to draw
*/
void GuiText::SetFirstLine(int line)
{
LOCK(this);
widescreen = w;
firstLine = line;
for(int i = 0; i < MAX_LINES_TO_DRAW; i++)
{
if(textDynRow[i])
{
delete [] textDynRow[i];
textDynRow[i] = NULL;
}
}
}
void GuiText::SetLinesToDraw(int line)
{
LOCK(this);
linestodraw = line;
if(linestodraw >= MAX_LINES_TO_DRAW)
linestodraw = MAX_LINES_TO_DRAW-1;
for(int i = 0; i < MAX_LINES_TO_DRAW; i++)
{
if(textDynRow[i])
{
delete [] textDynRow[i];
textDynRow[i] = NULL;
}
}
}
int GuiText::GetTotalLines()
{
return totalLines-1;
}
/**
* Change font
*/
bool GuiText::SetFont(const u8 *fontbuffer, const u32 filesize)
{
if(!fontbuffer || !filesize)
return false;
LOCK(this);
if(font)
{
delete font;
font = NULL;
}
font = new FreeTypeGX(currentSize, false, (u8 *) fontbuffer, filesize);
textWidth = font->getWidth(text);
return true;
}
/**
* Draw the text on screen
*/
void GuiText::Draw()
{
LOCK(this);
if(!text)
return;
@ -287,59 +481,193 @@ void GuiText::Draw()
int newSize = size*this->GetScale();
if(newSize != currentSize || currentWidescreen != widescreen)
if(newSize > MAX_FONT_SIZE)
newSize = MAX_FONT_SIZE;
if(newSize != currentSize)
{
//fontSystem->changeSize(newSize);
(font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0);
if(font)
{
font->ChangeFontSize(newSize);
}
else if(!fontSystem[newSize])
fontSystem[newSize] = new FreeTypeGX(newSize);
if(text)
textWidth = (font ? font : fontSystem[newSize])->getWidth(text);
currentSize = newSize;
currentWidescreen = widescreen;
}
int voffset = 0;
// if(alignmentVert == ALIGN_MIDDLE)
// voffset = -newSize/2 + 2;
if(maxWidth > 0 && (font ? font : fontSystem)->getWidth(text) > maxWidth)
if(maxWidth > 0 && maxWidth <= textWidth)
{
if(wrapMode == GuiText::WRAP) // text wrapping
if(wrapMode == LONGTEXT) // text wrapping
{
int lineheight = newSize + 6;
int strlen = wcslen(text);
int i = 0;
int ch = 0;
int linenum = 0;
int linemax = 200;
int lastSpace = -1;
int lastSpaceIndex = -1;
wchar_t * tmptext[linemax];
if(!textDynRow[0])
{
int index = 0;
u32 strlen = (u32) wcslen(text);
int linenum = firstLine;
int lineIndex = 0;
u32 ch = LineBreak[linenum];
totalLines=0;
while(ch < strlen)
u32 lastch = LineBreak[linenum+linestodraw]+1;
textDynRow[lineIndex] = new wchar_t[maxWidth];
textDynRow[lineIndex][index] = 0;
while((ch < lastch) && (ch < strlen+1))
{
if(i == 0)
if(ch == LineBreak[linenum+1])
{
if (linenum <= linemax)
{
tmptext[linenum] = new wchar_t[strlen + 1];
(font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop()+lineIndex*lineheight, textDynRow[lineIndex], c, style);
linenum++;
lineIndex++;
index = 0;
if(!textDynRow[lineIndex])
textDynRow[lineIndex] = new wchar_t[maxWidth];
textDynRow[lineIndex][index] = 0;
}
textDynRow[lineIndex][index] = text[ch];
textDynRow[lineIndex][index+1] = 0;
index++;
ch++;
}
}
else
{
for(int i = 0; i < linestodraw; i++)
if(textDynRow[i])
(font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop()+i*lineheight, textDynRow[i], c, style);
}
}
else if(wrapMode == DOTTED) // text dotted
{
if(!textDyn)
{
int strlen = wcslen(text);
int i = 0;
textDyn = new wchar_t[maxWidth];
while(i < strlen)
{
textDyn[i] = text[i];
textDyn[i+1] = 0;
if((font ? font : fontSystem[currentSize])->getWidth(textDyn) >= maxWidth)
{
textDyn[i-3] = '.';
textDyn[i-2] = '.';
textDyn[i-1] = '.';
textDyn[i] = 0;
break;
}
i++;
}
}
if(textDyn)
(font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop(), textDyn, c, style);
}
else if(wrapMode == SCROLL_HORIZONTAL)
{
int strlen = wcslen(text);
int ch = 0;
if(!textDyn) {
textDyn = new wchar_t[maxWidth];
while(ch < strlen)
{
textDyn[ch] = text[ch];
textDyn[ch+1] = 0;
ch++;
if((font ? font : fontSystem[currentSize])->getWidth(textDyn) >= maxWidth)
break;
}
}
tmptext[linenum][i] = text[ch];
tmptext[linenum][i+1] = 0;
if(maxWidth < textWidth && (frameCount % textScrollDelay == 0))
{
if(textScrollInitialDelay)
{
textScrollInitialDelay--;
}
else
{
textScrollPos++;
if(textScrollPos > strlen)
{
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
}
//if(text[ch] == ' ' || ch == strlen-1)
//{
if((font ? font : fontSystem)->getWidth(tmptext[linenum]) >= maxWidth)
//if(fontSystem->getWidth(tmptext[linenum]) >= maxWidth)
int ch = textScrollPos;
if(textDyn) {
delete [] textDyn;
textDyn = NULL;
}
textDyn = new wchar_t[maxWidth];
int i = 0;
while(1)
{
if(ch > strlen-1) {
textDyn[i++] = ' ';
textDyn[i++] = ' ';
textDyn[i++] = ' ';
textDyn[i+1] = 0;
ch = 0;
}
textDyn[i] = text[ch];
textDyn[i+1] = 0;
ch++;
i++;
if((font ? font : fontSystem[currentSize])->getWidth(textDyn) >= maxWidth)
break;
}
}
}
if(textDyn)
(font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop(), textDyn, c, style);
}
else if(wrapMode == WRAP)
{
int lineheight = newSize + 6;
if(!textDynRow[0])
{
int txtlen = wcslen(text);
int i = 0;
int ch = 0;
int linenum = 0;
int lastSpace = -1;
int lastSpaceIndex = -1;
while(ch < txtlen && linenum < MAX_LINES_TO_DRAW)
{
if(!textDynRow[linenum])
textDynRow[linenum] = new wchar_t[maxWidth];
textDynRow[linenum][i] = text[ch];
textDynRow[linenum][i+1] = 0;
if(text[ch] == ' ' || ch == txtlen-1)
{
if((font ? font : fontSystem[currentSize])->getWidth(textDynRow[linenum]) >= maxWidth)
{
if(lastSpace >= 0)
{
tmptext[linenum][lastSpaceIndex] = 0; // discard space, and everything after
textDynRow[linenum][lastSpaceIndex] = 0; // discard space, and everything after
ch = lastSpace; // go backwards to the last space
lastSpace = -1; // we have used this space
lastSpaceIndex = -1;
@ -347,186 +675,40 @@ void GuiText::Draw()
linenum++;
i = -1;
}
else if(ch == strlen-1)
else if(ch == txtlen-1)
{
linenum++;
}
//}
}
if(text[ch] == ' ' && i >= 0)
{
lastSpace = ch;
lastSpaceIndex = i;
}
if(text[ch] == '\n' && ch != strlen-1 && i >= 0)
{
linenum++;
i = -1;
}
ch++;
i++;
}
totalLines = linenum;
linestodraw = linenum;
}
int voffset = 0;
if(alignmentVert == ALIGN_MIDDLE)
voffset = voffset - (lineheight*linenum)/2 + lineheight/2;
voffset = -(lineheight*linestodraw)/2 + lineheight/2;
if (numLines <0){
for(i=0; i < linenum; i++)
for(int i=0; i < linestodraw; i++)
{
(font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[i], c, style);
delete tmptext[i];
}
}
//put in for txt vertical txt scrolling
else {
int j;
i=0;
for(j=firstLine-1; j < numLines+firstLine-1; j++)
{
//if (j<linenum-(firstLine-1))
if (j < linenum)
(font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[j], c, style);
i++;
}
for(i=0; i < linenum; i++)
{
delete tmptext[i];
}
}
}
else if(wrapMode == GuiText::DOTTED) // text dotted
{
wchar_t save[4];
int strlen = wcslen(text);
int dotPos=strlen-3;
int i;
bool drawed = false;
while(dotPos > 0 && drawed == false)
{
for(i=0; i<4; i++) // save Text for "..."
{
save[i] = text[dotPos+i];
text[dotPos+i] = (i != 3 ? _TEXT('.') : 0);
}
if(((font ? font : fontSystem)->getWidth(text)) <= maxWidth)
{
(font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style);
drawed = true;
}
for(i=0; i<4; i++) // write saved Text back
text[dotPos+i] = save[i];
dotPos--;
}
if(!drawed)
(font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style);
}
else if(wrapMode == GuiText::SCROLL) // text scroller
{
wchar_t save;
if(scrollPos2 == 0 || frameCount > scrollDelay+5)
{
scrollPos1 = 0;
scrollOffset = 0;
for(scrollPos2 = wcslen(text); scrollPos2 > 1; scrollPos2--)
{
save = text[scrollPos2]; // save Pos2
text[scrollPos2] = 0;
int textWidth = (font ? font : fontSystem)->getWidth(text);
text[scrollPos2] = save; // restore Pos2
if(textWidth <= maxWidth)
break;
}
scrollDelay = frameCount+50; // wait 50 Frames before beginning with scrolling
}
else if(scrollPos2 > 0 && frameCount >= scrollDelay)
{
if(--scrollOffset < 0)
{
wchar_t tmp[] = { text[scrollPos1], text[scrollPos1+1], 0 };
scrollOffset += (font ? font : fontSystem)->getWidth(tmp) - (font ? font : fontSystem)->getWidth(tmp+1);
scrollPos1++;
}
int strlen = wcslen(text);
for(; scrollPos2 < strlen; scrollPos2++)
{
save = text[scrollPos2+1]; // save Pos2
text[scrollPos2+1] = 0;
int textWidth = (font ? font : fontSystem)->getWidth(&text[scrollPos1]);
text[scrollPos2+1] = save; // restore Pos2
if(textWidth+scrollOffset > maxWidth)
break;
}
if(scrollPos2 == strlen)
{
scrollPos2 = -scrollPos2;
scrollDelay = frameCount+25; // when dir-change wait 25 Frames
}
else
scrollDelay = frameCount+1; // wait 1 Frames
}
else if(frameCount >= scrollDelay)
{
scrollPos2 = -scrollPos2;
scrollOffset++;
wchar_t tmp[] = { text[scrollPos1-1], text[scrollPos1], 0 };
int tmpOffset = (font ? font : fontSystem)->getWidth(tmp) - (font ? font : fontSystem)->getWidth(tmp+1);
if(scrollOffset >= tmpOffset)
{
scrollOffset -= tmpOffset;
scrollPos1--;
}
for(; scrollPos2 > scrollPos1; scrollPos2--)
{
save = text[scrollPos2]; // save Pos2
text[scrollPos2] = 0;
int textWidth = (font ? font : fontSystem)->getWidth(&text[scrollPos1]);
text[scrollPos2] = save; // restore Pos2
if(textWidth+scrollOffset <= maxWidth)
break;
}
if(scrollPos1 == 0)
{
scrollPos2 = -scrollPos2;
scrollDelay = frameCount+25; // when dir-change wait 25 Frames
}
else
scrollDelay = frameCount+1; // wait 10 Frames
scrollPos2 = -scrollPos2;
}
uint16_t drawStyle = style;
uint16_t drawX = this->GetLeft() + scrollOffset;
if((drawStyle & FTGX_JUSTIFY_MASK) == FTGX_JUSTIFY_CENTER)
{
drawStyle = (drawStyle & ~FTGX_JUSTIFY_MASK) | FTGX_JUSTIFY_LEFT;
drawX -= maxWidth >> 1;
}
else if((drawStyle & FTGX_JUSTIFY_MASK) == FTGX_JUSTIFY_RIGHT)
{
drawStyle = (drawStyle & ~FTGX_JUSTIFY_MASK) | FTGX_JUSTIFY_LEFT;
drawX -= maxWidth;
}
save = text[abs(scrollPos2)]; // save Pos2
text[abs(scrollPos2)] = 0;
(font ? font : fontSystem)->drawText(drawX, this->GetTop()+voffset, &text[scrollPos1], c, drawStyle);
text[abs(scrollPos2)] = save; // restore Pos2
if(textDynRow[i])
(font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, textDynRow[i], c, style);
}
}
else
{
(font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style);
(font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop(), text, c, style);
}
}
else
{
(font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop(), text, c, style);
}
this->UpdateEffects();
}

View File

@ -41,18 +41,10 @@
#define CONSOLE_WIDTH 340
#define CONSOLE_HEIGHT 218
FreeTypeGX *fontSystem=0;
FreeTypeGX *fontClock=0;
static void BootUpProblems()
{
s32 ret2;
// load main font from file, or default to built-in font
fontSystem = new FreeTypeGX();
fontSystem->loadFont(NULL, font_ttf, font_ttf_size, 0);
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
GuiImageData bootimageData(gxlogo_png);
GuiImage bootimage(&bootimageData);
GuiText boottext(NULL, 20, (GXColor) {255, 255, 255, 255});
@ -111,12 +103,6 @@ static void BootUpProblems()
Menu_Render();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
///delete font to load up custom if set
if(fontSystem) {
delete fontSystem;
fontSystem = NULL;
}
}
@ -125,6 +111,9 @@ main(int argc, char *argv[]) {
setlocale(LC_ALL, "en.UTF-8");
for(int i = 0; i < MAX_FONT_SIZE+1; i++)
fontSystem[i] = NULL;
s32 ret;
bool startupproblem = false;
@ -241,18 +230,11 @@ main(int argc, char *argv[]) {
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
// load main font from file, or default to built-in font
fontSystem = new FreeTypeGX();
char *fontPath = NULL;
asprintf(&fontPath, "%sfont.ttf", CFG.theme_path);
fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0);
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
LoadCustomFont(fontPath);
free(fontPath);
fontClock = new FreeTypeGX();
fontClock->loadFont(NULL, clock_ttf, clock_ttf_size, 0);
fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
InitGUIThreads();
MainMenu(MENU_CHECK);
return 0;

View File

@ -8,11 +8,8 @@
#ifndef _MAIN_H_
#define _MAIN_H_
#include "FreeTypeGX.h"
extern struct SSettings Settings;
void DefaultSettings();
extern FreeTypeGX *fontSystem;
#endif

View File

@ -783,11 +783,11 @@ int MenuDiscList() {
GuiText clockTimeBack("88:88", 40, (GXColor) {THEME.clock.r, THEME.clock.g, THEME.clock.b, THEME.clock.a/6});
clockTimeBack.SetAlignment(THEME.clock_align, ALIGN_TOP);
clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y);
clockTimeBack.SetFont(fontClock);
clockTimeBack.SetFont(clock_ttf, clock_ttf_size);
GuiText clockTime(theTime, 40, THEME.clock);
clockTime.SetAlignment(THEME.clock_align, ALIGN_TOP);
clockTime.SetPosition(THEME.clock_x, THEME.clock_y);
clockTime.SetFont(fontClock);
clockTime.SetFont(clock_ttf, clock_ttf_size);
HaltGui();
GuiWindow w(screenwidth, screenheight);
@ -891,7 +891,9 @@ int MenuDiscList() {
break;
}
//CLOCK
//CLOCK update every 10 secs
if(frameCount % (60*10))
{
time_t rawtime = time(0); //this fixes code dump caused by the clock
if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) {
lastrawtime = rawtime;
@ -916,6 +918,7 @@ int MenuDiscList() {
clockTime.SetTextf("%i", (dataed-1));
}
}
}
if ((datagB<1)&&(Settings.cios==1)&&(Settings.video == ntsc)&&(Settings.hddinfo == hr12)&&(Settings.qboot==1)&&(Settings.wsprompt==0)&&(Settings.language==ger)&&(Settings.tooltips==0)){dataed=1;dataef=1;}if (dataef==1){if (cosa>7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}}
// respond to button presses
@ -2207,10 +2210,9 @@ int MainMenu(int menu) {
delete GameIDTxt;
delete cover;
delete coverImg;
delete fontClock;
delete fontSystem;
ShutdownAudio();
StopGX();
ClearFontData();
gettextCleanUp();
if (mountMethod==3)
{

View File

@ -161,7 +161,7 @@ int DiscBrowse(struct discHdr * header) {
GuiText titleTxt(get_title(header), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(12,40);
titleTxt.SetMaxWidth(356, GuiText::SCROLL);
titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL);
GuiImage settingsbackground(&settingsbg);
GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
@ -173,7 +173,7 @@ int DiscBrowse(struct discHdr * header) {
cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage cancelBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
cancelBtnTxt.SetWidescreen(CFG.widescreen);
//cancelBtnTxt.SetWidescreen(CFG.widescreen);
cancelBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1);

View File

@ -30,6 +30,7 @@ static int showProgress = 0;
static f32 progressDone = 0.0;
static bool showTime = false;
static bool showSize = false;
static bool changed = true;
static s32 gameinstalldone = 0;
static s32 gameinstalltotal = -1;
static time_t start;
@ -52,8 +53,13 @@ static void GameInstallProgress() {
if (gameinstalltotal <= 0)
return;
int oldinstalldone = gameinstalldone;
GetProgressValue(&gameinstalldone, &gameinstalltotal);
if((oldinstalldone == gameinstalldone) && (gameinstalldone > 0))
return;
if (gameinstalldone > gameinstalltotal)
gameinstalldone = gameinstalltotal;
@ -89,6 +95,7 @@ static void GameInstallProgress() {
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%.2fGB/%.2fGB", gamesize * gameinstalldone/gameinstalltotal, gamesize);
snprintf(progressSpeed, sizeof(progressSpeed), "%.1fMB/s", speed);
changed = true;
}
/****************************************************************************
@ -165,12 +172,12 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
msg1Txt.SetPosition(0,120);
else
msg1Txt.SetPosition(0,100);
msg1Txt.SetMaxWidth(430, GuiText::DOTTED);
msg1Txt.SetMaxWidth(430, DOTTED);
GuiText msg2Txt(msg2, 22, THEME.prompttext );
msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
msg2Txt.SetPosition(0,125);
msg2Txt.SetMaxWidth(430, GuiText::DOTTED);
msg2Txt.SetMaxWidth(430, DOTTED);
GuiText prsTxt("%", 22, THEME.prompttext);
prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
@ -198,8 +205,8 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
progressbarEmptyImg.SetPosition(80,40);
progressbarEmptyImg.SetTile(78);
progressbarImg.SetPosition(80, 40);
msg1Txt.SetMaxWidth(380, GuiText::DOTTED);
msg2Txt.SetMaxWidth(380, GuiText::DOTTED);
msg1Txt.SetMaxWidth(380, DOTTED);
msg2Txt.SetMaxWidth(380, DOTTED);
timeTxt.SetPosition(250,-50);
timeTxt.SetFontSize(20);
@ -246,9 +253,13 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
while (showProgress) {
VIDEO_WaitVSync ();
usleep(20000);
GameInstallProgress();
if(changed)
{
changed = false;
tmp = static_cast<int>(progressbarImg.GetWidth()*progressDone);
if (CFG.widescreen && Settings.wsprompt == yes)
@ -269,6 +280,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
if (msg2)
msg2Txt.SetText(dyn_message);
}
}
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0) usleep(100);
@ -384,7 +396,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
* Startup Progressthread in idle prio
***************************************************************************/
void InitProgressThread() {
LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 0);
LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 80);
}
/****************************************************************************

View File

@ -90,7 +90,7 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min) {
GuiText okBtnTxt(tr("OK"), 22, THEME.prompttext);
GuiImage okBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
okBtnTxt.SetWidescreen(CFG.widescreen);
//okBtnTxt.SetWidescreen(CFG.widescreen);
okBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 5, 15, &trigA, &btnSoundOver, &btnClick,1);
@ -98,7 +98,7 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min) {
GuiText cancelBtnTxt(tr("Cancel"), 22, THEME.prompttext);
GuiImage cancelBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
cancelBtnTxt.SetWidescreen(CFG.widescreen);
//cancelBtnTxt.SetWidescreen(CFG.widescreen);
cancelBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 1, 4, -5, 15, &trigA, &btnSoundOver, &btnClick,1);
@ -215,7 +215,7 @@ void WindowCredits() {
i++;
y+=28;
GuiText::SetPresets(22, (GXColor) {255, 255, 255, 255}, 0, GuiText::WRAP,FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, ALIGN_LEFT, ALIGN_TOP);
txt[i]->SetPresets(22, (GXColor) {255, 255, 255, 255}, WRAP, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, ALIGN_LEFT, ALIGN_TOP);
txt[i] = new GuiText(tr("Coding:"));
txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
@ -459,7 +459,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
GuiText btn1Txt(btn1Label, 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);
}
@ -470,7 +470,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
GuiText btn2Txt(btn2Label, 22, THEME.prompttext);
GuiImage btn2Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn2Txt.SetWidescreen(CFG.widescreen);
//btn2Txt.SetWidescreen(CFG.widescreen);
btn2Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn2(&btn2Img, &btn2Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1);
@ -481,7 +481,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
GuiText btn3Txt(btn3Label, 22, THEME.prompttext);
GuiImage btn3Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn3Txt.SetWidescreen(CFG.widescreen);
//btn3Txt.SetWidescreen(CFG.widescreen);
btn3Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn3(&btn3Img, &btn3Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1);
@ -492,7 +492,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
GuiText btn4Txt(btn4Label, 22, THEME.prompttext);
GuiImage btn4Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn4Txt.SetWidescreen(CFG.widescreen);
//btn4Txt.SetWidescreen(CFG.widescreen);
btn4Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn4(&btn4Img, &btn4Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1);
@ -778,7 +778,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
closeTxt.SetPosition(10,3);
GuiImage closeImg(&close);
if (Settings.wsprompt == yes) {
closeTxt.SetWidescreen(CFG.widescreen);
//closeTxt.SetWidescreen(CFG.widescreen);
closeImg.SetWidescreen(CFG.widescreen);
}
GuiButton closeBtn(close.GetWidth(), close.GetHeight());
@ -797,7 +797,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
GuiText btn2Txt((HBC!=1?tr("Homebrew Channel"):btn1Label), 28, (GXColor) {0, 0, 0, 255});
GuiImage btn2Img(&button);
if (Settings.wsprompt == yes) {
btn2Txt.SetWidescreen(CFG.widescreen);
//btn2Txt.SetWidescreen(CFG.widescreen);
btn2Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn2(&btn2Img,&btn2Img, 2, 5, -150, 0, &trigA, &btnSoundOver, &btnClick,1);
@ -811,7 +811,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
GuiText btn3Txt(btn2Label, 28, (GXColor) {0, 0, 0, 255});
GuiImage btn3Img(&button);
if (Settings.wsprompt == yes) {
btn3Txt.SetWidescreen(CFG.widescreen);
//btn3Txt.SetWidescreen(CFG.widescreen);
btn3Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn3(&btn3Img,&btn3Img, 2, 5, 150, 0, &trigA, &btnSoundOver, &btnClick,1);
@ -1060,9 +1060,9 @@ int GameWindowPrompt() {
if (Settings.wsprompt == yes)
nameBtnTT.SetWidescreen(CFG.widescreen);
GuiText nameTxt("", 22, THEME.prompttext);
if (Settings.wsprompt == yes)
nameTxt.SetWidescreen(CFG.widescreen);
nameTxt.SetMaxWidth(350, GuiText::SCROLL);
//if (Settings.wsprompt == yes)
//nameTxt.SetWidescreen(CFG.widescreen);
nameTxt.SetMaxWidth(350, SCROLL_HORIZONTAL);
GuiButton nameBtn(120,50);
nameBtn.SetLabel(&nameTxt);
// nameBtn.SetLabelOver(&nameTxt);
@ -1110,7 +1110,7 @@ int GameWindowPrompt() {
GuiText btn2Txt(tr("Back"), 22, THEME.prompttext);
GuiImage btn2Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn2Txt.SetWidescreen(CFG.widescreen);
//btn2Txt.SetWidescreen(CFG.widescreen);
btn2Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn2(&btn2Img,&btn2Img, 1, 5, 0, 0, &trigA, &btnSoundOver, &btnClick,1);
@ -1128,7 +1128,7 @@ int GameWindowPrompt() {
GuiText btn3Txt(tr("Settings"), 22, THEME.prompttext);
GuiImage btn3Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn3Txt.SetWidescreen(CFG.widescreen);
//btn3Txt.SetWidescreen(CFG.widescreen);
btn3Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn3(&btn3Img,&btn3Img, 0, 4, 50, -40, &trigA, &btnSoundOver, &btnClick,1);
@ -1566,7 +1566,7 @@ DiscWait(const char *title, const char *msg, const char *btn1Label, const char *
GuiText btn1Txt(btn1Label, 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn1(&btn1Img,&btn1Img, 1, 5, 0, 0, &trigA, &btnSoundOver, &btnClick,1);
@ -1586,7 +1586,7 @@ DiscWait(const char *title, const char *msg, const char *btn1Label, const char *
GuiText btn2Txt(btn2Label, 22, THEME.prompttext);
GuiImage btn2Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn2Txt.SetWidescreen(CFG.widescreen);
//btn2Txt.SetWidescreen(CFG.widescreen);
btn2Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn2(&btn2Img,&btn2Img, 1, 4, -20, -25, &trigA, &btnSoundOver, &btnClick,1);
@ -1872,7 +1872,7 @@ bool NetworkInitPrompt() {
GuiText btn1Txt(tr("Cancel"), 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, &btnClick,1);
@ -2000,7 +2000,7 @@ ProgressDownloadWindow(int choice2) {
GuiText btn1Txt(tr("Cancel"), 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -45, &trigA, &btnSoundOver, &btnClick,1);
@ -2484,7 +2484,7 @@ int ProgressUpdateWindow() {
GuiText btn1Txt(tr("Cancel"), 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1);
@ -3112,7 +3112,7 @@ int CodeDownload(const char *id) {
GuiText btn1Txt(tr("Cancel"), 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -40, &trigA, &btnSoundOver, &btnClick,1);
@ -3324,7 +3324,7 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
GuiText nameTxt(name,30 , THEME.prompttext);
nameTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
nameTxt.SetPosition(0,-15);
nameTxt.SetMaxWidth(430, GuiText::SCROLL);
nameTxt.SetMaxWidth(430, SCROLL_HORIZONTAL);
if (strcmp(coder,""))
@ -3349,11 +3349,16 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
release_dateTxt.SetMaxWidth(430);
int pagesize = 6;
int currentLine = 0;
GuiText long_descriptionTxt(long_description, 20, THEME.prompttext);
long_descriptionTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
long_descriptionTxt.SetPosition(46,117);
long_descriptionTxt.SetMaxWidth(360);
long_descriptionTxt.SetNumLines(pagesize);
long_descriptionTxt.SetMaxWidth(360, LONGTEXT);
long_descriptionTxt.SetLinesToDraw(pagesize);
long_descriptionTxt.SetFirstLine(currentLine);
int TotalLines = long_descriptionTxt.GetTotalLines();
//convert filesize from u64 to char and put unit of measurement after it
char temp2[7];
@ -3384,7 +3389,7 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
GuiText btn1Txt(tr("Load"), 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);
}
@ -3395,7 +3400,7 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
GuiText btn2Txt(tr("Back"), 22, THEME.prompttext);
GuiImage btn2Img(&btnOutline);
if (Settings.wsprompt == yes) {
btn2Txt.SetWidescreen(CFG.widescreen);
//btn2Txt.SetWidescreen(CFG.widescreen);
btn2Img.SetWidescreen(CFG.widescreen);
}
GuiButton btn2(&btn2Img, &btn2Img, 0,3,0,0,&trigA,&btnSoundOver,&btnClick,1);
@ -3445,18 +3450,24 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
} else if (btn2.GetState() == STATE_CLICKED) {
choice = 0;
} else if ((arrowUpBtn.GetState()==STATE_CLICKED||arrowUpBtn.GetState()==STATE_HELD) ) {
if (long_descriptionTxt.GetFirstLine()>1)
long_descriptionTxt.SetFirstLine(long_descriptionTxt.GetFirstLine()-1);
currentLine--;
if(currentLine+pagesize > TotalLines)
currentLine = TotalLines-pagesize;
if(currentLine < 0)
currentLine = 0;
long_descriptionTxt.SetFirstLine(currentLine);
usleep(60000);
if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP)))
arrowUpBtn.ResetState();
} else if ((arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD)
&&long_descriptionTxt.GetTotalLines()>pagesize
&&long_descriptionTxt.GetFirstLine()-1<long_descriptionTxt.GetTotalLines()-pagesize) {
int l=0;
l=long_descriptionTxt.GetFirstLine()+1;
} else if (arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD) {
currentLine++;
if(currentLine+pagesize > TotalLines)
currentLine = TotalLines-pagesize;
if(currentLine < 0)
currentLine = 0;
long_descriptionTxt.SetFirstLine(l);
long_descriptionTxt.SetFirstLine(currentLine);
usleep(60000);
if (!((ButtonsHold() & WPAD_BUTTON_DOWN)||(ButtonsHold() & PAD_BUTTON_DOWN)))
arrowDownBtn.ResetState();

View File

@ -250,7 +250,7 @@ int TitleBrowser(u32 type) {
GuiText titleTxt(tr("Title Launcher"), 28, (GXColor) {0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(12,40);
titleTxt.SetMaxWidth(356, GuiText::SCROLL);
titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL);
GuiImage settingsbackground(&settingsbg);
GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight());
@ -262,7 +262,7 @@ int TitleBrowser(u32 type) {
cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage cancelBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
cancelBtnTxt.SetWidescreen(CFG.widescreen);
//cancelBtnTxt.SetWidescreen(CFG.widescreen);
cancelBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, &btnClick,1);

View File

@ -322,7 +322,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
GuiText ExitBtnTxt(tr("Cancel"), 24, (GXColor) {0, 0, 0, 255});
GuiImage ExitBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
ExitBtnTxt.SetWidescreen(CFG.widescreen);
//ExitBtnTxt.SetWidescreen(CFG.widescreen);
ExitBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton ExitBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
@ -337,7 +337,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
GuiText usbBtnTxt(browsers[(curDevice+1)%browsers.size()].rootdir, 24, (GXColor) {0, 0, 0, 255});
GuiImage usbBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
usbBtnTxt.SetWidescreen(CFG.widescreen);
//usbBtnTxt.SetWidescreen(CFG.widescreen);
usbBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton usbBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
@ -351,7 +351,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
GuiText okBtnTxt(tr("OK"), 22, THEME.prompttext);
GuiImage okBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
okBtnTxt.SetWidescreen(CFG.widescreen);
//okBtnTxt.SetWidescreen(CFG.widescreen);
okBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 40, -35, &trigA, &btnSoundOver, &btnClick,1);
@ -366,7 +366,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
AdressText.SetTextf("%s%s", browser->rootdir, browser->dir);
AdressText.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
AdressText.SetPosition(20, 0);
AdressText.SetMaxWidth(Address.GetWidth()-40, GuiText::SCROLL);
AdressText.SetMaxWidth(Address.GetWidth()-40, SCROLL_HORIZONTAL);
GuiImage AdressbarImg(&Address);
GuiButton Adressbar(Address.GetWidth(), Address.GetHeight());
Adressbar.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);

View File

@ -596,7 +596,7 @@ int showGameInfo(char *ID) {
if (strcmp(gameinfo.title,"") != 0) {
snprintf(linebuf, sizeof(linebuf), "%s",gameinfo.title);
titleTxt = new GuiText(linebuf, titlefontsize, (GXColor) {0,0,0, 255});
titleTxt->SetMaxWidth(350, GuiText::SCROLL);
titleTxt->SetMaxWidth(350, SCROLL_HORIZONTAL);
//while (titleTxt->GetWidth()>250) { titleTxt->SetFontSize(titlefontsize-=2); }
titleTxt->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt->SetPosition(txtXOffset,12+titley);
@ -664,7 +664,7 @@ int showGameInfo(char *ID) {
snprintf(linebuf, sizeof(linebuf), "%s %s", tr("Published by"), gameinfo.publisher);
publisherTxt = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
if (publisherTxt->GetWidth()>250) newline=2;
publisherTxt->SetMaxWidth(250,GuiText::WRAP);
publisherTxt->SetMaxWidth(250, WRAP);
publisherTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
publisherTxt->SetPosition(-17,12+indexy);
indexy+=(20 * newline);
@ -677,7 +677,7 @@ int showGameInfo(char *ID) {
snprintf(linebuf, sizeof(linebuf), "%s %s", tr("Developed by"), gameinfo.developer);
developerTxt = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
if (developerTxt->GetWidth()>250) newline=2;
developerTxt->SetMaxWidth(250,GuiText::WRAP);
developerTxt->SetMaxWidth(250, WRAP);
developerTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
developerTxt->SetPosition(-17,12+indexy);
indexy+=(20 * newline);
@ -721,14 +721,17 @@ int showGameInfo(char *ID) {
//synopsis
int pagesize=12;
int currentLine = 0;
int TotalLines = 0;
if (strcmp(gameinfo.synopsis,"") != 0) {
snprintf(linebuf, sizeof(linebuf), "%s", gameinfo.synopsis);
synopsisTxt = new GuiText(linebuf, 16, (GXColor) {0,0,0, 255});
synopsisTxt->SetMaxWidth(350,GuiText::WRAP);
synopsisTxt->SetMaxWidth(350, LONGTEXT);
synopsisTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
synopsisTxt->SetPosition(0,0);
synopsisTxt->SetNumLines(pagesize);
//synopsisTxt->SetFirstLine(12);
synopsisTxt->SetLinesToDraw(pagesize);
synopsisTxt->SetFirstLine(0);
TotalLines = synopsisTxt->GetTotalLines();
dialogBoxImg11 = new GuiImage(&dialogBox1);
dialogBoxImg11->SetAlignment(0,3);
@ -849,23 +852,24 @@ int showGameInfo(char *ID) {
}
} else if ((upBtn.GetState()==STATE_CLICKED||upBtn.GetState()==STATE_HELD) && page==2) {
//int l=synopsisTxt->GetFirstLine()-1;
if (synopsisTxt->GetFirstLine()>1)
synopsisTxt->SetFirstLine(synopsisTxt->GetFirstLine()-1);
currentLine--;
if(currentLine+pagesize > TotalLines)
currentLine = TotalLines-pagesize;
if(currentLine < 0)
currentLine = 0;
synopsisTxt->SetFirstLine(currentLine);
usleep(60000);
if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP)))
upBtn.ResetState();
} else if ((dnBtn.GetState()==STATE_CLICKED||dnBtn.GetState()==STATE_HELD) && page==2
&&synopsisTxt->GetTotalLines()>pagesize
&&synopsisTxt->GetFirstLine()-1<synopsisTxt->GetTotalLines()-pagesize) {
int l=0;
//if(synopsisTxt->GetTotalLines()>pagesize)
l=synopsisTxt->GetFirstLine()+1;
} else if ((dnBtn.GetState()==STATE_CLICKED||dnBtn.GetState()==STATE_HELD) && page==2) {
currentLine++;
if(currentLine+pagesize > TotalLines)
currentLine = TotalLines-pagesize;
if(currentLine < 0)
currentLine = 0;
//if (l>(synopsisTxt->GetTotalLines()+1)-pagesize)
//l=(synopsisTxt->GetTotalLines()+1)-pagesize;
synopsisTxt->SetFirstLine(l);
synopsisTxt->SetFirstLine(currentLine);
usleep(60000);
if (!((ButtonsHold() & WPAD_BUTTON_DOWN)||(ButtonsHold() & PAD_BUTTON_DOWN)))
dnBtn.ResetState();

File diff suppressed because it is too large Load Diff

View File

@ -85,7 +85,7 @@ bool MenuOGG() {
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
backBtnTxt.SetWidescreen(CFG.widescreen);
//backBtnTxt.SetWidescreen(CFG.widescreen);
backBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
@ -103,7 +103,7 @@ bool MenuOGG() {
defaultBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage defaultBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
defaultBtnTxt.SetWidescreen(CFG.widescreen);
//defaultBtnTxt.SetWidescreen(CFG.widescreen);
defaultBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
@ -367,7 +367,7 @@ int MenuLanguageSelect() {
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
backBtnTxt.SetWidescreen(CFG.widescreen);
//backBtnTxt.SetWidescreen(CFG.widescreen);
backBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
@ -385,7 +385,7 @@ int MenuLanguageSelect() {
defaultBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage defaultBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
defaultBtnTxt.SetWidescreen(CFG.widescreen);
//defaultBtnTxt.SetWidescreen(CFG.widescreen);
defaultBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton defaultBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
@ -402,7 +402,7 @@ int MenuLanguageSelect() {
updateBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage updateBtnImg(&btnOutline);
if (Settings.wsprompt == yes) {
updateBtnTxt.SetWidescreen(CFG.widescreen);
//updateBtnTxt.SetWidescreen(CFG.widescreen);
updateBtnImg.SetWidescreen(CFG.widescreen);
}
GuiButton updateBtn(btnOutline.GetWidth(), btnOutline.GetHeight());

View File

@ -5,6 +5,7 @@
#include "main.h"
#include <wctype.h>
#include "getentries.h"
#include "FreeTypeGX.h"
#include "../prompts/TitleBrowser.h"
@ -174,7 +175,7 @@ int __Menu_GetPrevFilter(int t, wchar_t* gameFilter, u32 gameFiltered, wchar_t *
if(get_block(header) >= Settings.parentalcontrol)
continue;
wchar_t *wname = FreeTypeGX::charToWideChar(get_title(header));
wchar_t *wname = charToWideChar(get_title(header));
if(wname) nameList.push_back(wname);
}
@ -220,7 +221,7 @@ int __Menu_GetGameFilter_NextList(discHdr *gameList, u32 gameCnt, wchar_t **Pgam
for(i=0; i<gameCnt; i++)
{
u32 nextFilterChar = 0x10000;
wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(&gameList[i]));
wchar_t *gameName = charToWideChar(get_title(&gameList[i]));
if(gameName == NULL) goto error;
if(wcslen(gameName) > filter_len)
@ -391,7 +392,7 @@ int buildTitleList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameC
if(gameFilter && *gameFilter) {
u32 filter_len = wcslen(gameFilter);
wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header));
wchar_t *gameName = charToWideChar(get_title(header));
if (!gameName || wcsnicmp(gameName, gameFilter, filter_len)) {
delete [] gameName;
continue;
@ -486,7 +487,7 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg
if(gameFilter && *gameFilter && t==0) {
u32 filter_len = wcslen(gameFilter);
wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header));
wchar_t *gameName = charToWideChar(get_title(header));
if (!gameName || wcsnicmp(gameName, gameFilter, filter_len)) {
delete [] gameName;
continue;

View File

@ -142,7 +142,7 @@ s32 Wad_Install(FILE *fp)
GuiText btn1Txt(tr("OK"), 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes){
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);}
GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -35, &trigA, &btnSoundOver, &btnClick,1);
btn1.SetLabel(&btn1Txt);
@ -471,7 +471,7 @@ s32 Wad_Uninstall(FILE *fp)
GuiText btn1Txt(tr("OK"), 22, THEME.prompttext);
GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes){
btn1Txt.SetWidescreen(CFG.widescreen);
//btn1Txt.SetWidescreen(CFG.widescreen);
btn1Img.SetWidescreen(CFG.widescreen);}
GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -55, &trigA, &btnSoundOver, &btnClick,1);
btn1.SetLabel(&btn1Txt);