diff --git a/source/FreeTypeGX.cpp b/source/FreeTypeGX.cpp index fcf087e7..cbacc81e 100644 --- a/source/FreeTypeGX.cpp +++ b/source/FreeTypeGX.cpp @@ -20,54 +20,64 @@ * along with FreeTypeGX. If not, see . */ +#include +#include #include "FreeTypeGX.h" +#include "settings/cfg.h" -FreeTypeGX *fontSystem[MAX_FONT_SIZE+1]; +#include "main.h" -static FT_Byte *customfontbuffer = NULL; -static u32 cstfontfilesize = 0; +/*! \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. */ -bool LoadCustomFont(const char *path) -{ - FILE *pfile = fopen(path, "rb"); + uint16_t textureWidth; /**< Texture width in pixels/bytes. */ + uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */ - if(pfile) - { - fseek(pfile, 0, SEEK_END); - cstfontfilesize = ftell(pfile); - rewind(pfile); + 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. */ - customfontbuffer = new FT_Byte[cstfontfilesize]; - if(!customfontbuffer) - { - cstfontfilesize = 0; - fclose(pfile); - return false; - } + uint32_t* glyphDataTexture; /**< Glyph texture bitmap data buffer. */ +} ftgxCharData; - fread(customfontbuffer, 1, cstfontfilesize, pfile); - fclose(pfile); +/*! \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; - return true; - } - return false; +/** + * 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); } -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; - } +/** + * Default destructor for the FreeTypeGX class. + */ +FreeTypeGX::~FreeTypeGX() { + this->unloadFont(); + FT_Done_FreeType(this->ftLibrary); } /** @@ -79,85 +89,31 @@ void ClearFontData() * @param strChar Character string to be converted. * @return Wide character representation of supplied character string. */ +wchar_t* FreeTypeGX::charToWideChar(char* strChar) { + wchar_t *strWChar; + try {strWChar = new wchar_t[strlen(strChar) + 1];} + catch (...) { return 0; } + // UTF-8 + int bt; + bt = mbstowcs(strWChar, strChar, strlen(strChar)); + if (bt > 0) { + strWChar[bt] = (wchar_t)'\0'; + return strWChar; + } -wchar_t* charToWideChar(const char* strChar) -{ - wchar_t *strWChar; - strWChar = new wchar_t[strlen(strChar) + 1]; + char *tempSrc = strChar; + wchar_t *tempDest = strWChar; + while ((*tempDest++ = *tempSrc++)); - // UTF-8 - int bt; - bt = mbstowcs(strWChar, strChar, strlen(strChar)); - if(bt > 0) { - strWChar[bt] = (wchar_t)'\0'; - return strWChar; - } - - char *tempSrc = (char *)strChar; - wchar_t *tempDest = strWChar; - while((*tempDest++ = *tempSrc++)); - - return strWChar; + return strWChar; } /** - * 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. + * \overload */ -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_UInt pixelSizeHorz) -{ - FT_Set_Pixel_Sizes(ftFace, pixelSizeHorz, pixelSize); -} - -uint8_t FreeTypeGX::GetMaxCharWidth() -{ - return ftFace->size->metrics.max_advance >> 6; +wchar_t* FreeTypeGX::charToWideChar(const char* strChar) { + return FreeTypeGX::charToWideChar((char*) strChar); } /** @@ -169,12 +125,12 @@ uint8_t FreeTypeGX::GetMaxCharWidth() * * @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) -{ - 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); +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); } /** @@ -187,9 +143,8 @@ void FreeTypeGX::setVertexFormat(uint8_t vertexIndex) * * @param compatibilityMode Compatibility descritor (FTGX_COMPATIBILITY_*) as defined in FreeTypeGX.h */ -void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode) -{ - this->compatibilityMode = compatibilityMode; +void FreeTypeGX::setCompatibilityMode(uint32_t compatibilityMode) { + this->compatibilityMode = compatibilityMode; } /** @@ -198,63 +153,138 @@ 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) - { - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE: - GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); - break; - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL: - GX_SetTevOp(GX_TEVSTAGE0, GX_DECAL); - break; - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_BLEND: - GX_SetTevOp(GX_TEVSTAGE0, GX_BLEND); - break; - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_REPLACE: - GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); - break; - case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR: - GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); - break; - default: - break; - } +void FreeTypeGX::setDefaultMode() { + if (this->compatibilityMode) { + switch (this->compatibilityMode & 0x00FF) { + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE: + GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); + break; + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL: + GX_SetTevOp(GX_TEVSTAGE0, GX_DECAL); + break; + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_BLEND: + GX_SetTevOp(GX_TEVSTAGE0, GX_BLEND); + break; + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_REPLACE: + GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); + break; + case FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR: + GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + break; + default: + break; + } - switch(this->compatibilityMode & 0xFF00) - { - case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE: - GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); - break; - case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT: - GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); - break; - case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX8: - GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8); - break; - case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX16: - GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX16); - break; - default: - break; - } - } + switch (this->compatibilityMode & 0xFF00) { + case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE: + GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); + break; + case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT: + GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); + break; + case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX8: + GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8); + break; + case FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX16: + GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX16); + break; + default: + break; + } + } } +/** + * 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::unloadFont() -{ - if(this->fontData.size() == 0) - return; - for(std::map::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) - free(i->second.glyphDataTexture); - this->fontData.clear(); +void FreeTypeGX::clearGlyphData() { + if (this->fontData.size() == 0) + return; + + GX_DrawDone(); + GX_Flush(); + + for ( std::map::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); } /** @@ -266,27 +296,26 @@ void FreeTypeGX::unloadFont() * @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 alignment; +uint16_t FreeTypeGX::adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat) { + uint16_t alignment; - 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 */ - alignment = 8; - break; + 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 */ + alignment = 8; + break; + + case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */ + case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */ + case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */ + case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */ + default: + alignment = 4; + break; + } + return textureWidth % alignment == 0 ? textureWidth : alignment + textureWidth - (textureWidth % alignment); - case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */ - case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */ - case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */ - case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */ - default: - alignment = 4; - break; - } - return textureWidth % alignment == 0 ? textureWidth : alignment + textureWidth - (textureWidth % alignment); } /** @@ -298,27 +327,26 @@ 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 alignment; +uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat) { + uint16_t alignment; - switch(textureFormat) - { - case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */ - alignment = 8; - break; + switch (textureFormat) { + case GX_TF_I4: /* 8x8 Tiles - 4-bit Intensity */ + alignment = 8; + break; + + case GX_TF_I8: /* 8x4 Tiles - 8-bit Intensity */ + case GX_TF_IA4: /* 8x4 Tiles - 4-bit Intensity, , 4-bit Alpha */ + case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */ + case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */ + case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */ + case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */ + default: + alignment = 4; + break; + } + return textureHeight % alignment == 0 ? textureHeight : alignment + textureHeight - (textureHeight % alignment); - case GX_TF_I8: /* 8x4 Tiles - 8-bit Intensity */ - case GX_TF_IA4: /* 8x4 Tiles - 4-bit Intensity, , 4-bit Alpha */ - case GX_TF_IA8: /* 4x4 Tiles - 8-bit Intensity, 8-bit Alpha */ - case GX_TF_RGB565: /* 4x4 Tiles - RGB565 Format */ - case GX_TF_RGB5A3: /* 4x4 Tiles - RGB5A3 Format */ - case GX_TF_RGBA8: /* 4x4 Tiles - RGBA8 Dual Cache Line Format */ - default: - alignment = 4; - break; - } - return textureHeight % alignment == 0 ? textureHeight : alignment + textureHeight - (textureHeight % alignment); } /** @@ -330,38 +358,38 @@ 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) -{ - FT_UInt gIndex; - uint16_t textureWidth = 0, textureHeight = 0; +ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) { + FT_UInt gIndex; + uint16_t textureWidth = 0, textureHeight = 0; - gIndex = FT_Get_Char_Index( ftFace, charCode ); - if (!FT_Load_Glyph(ftFace, gIndex, FT_LOAD_DEFAULT )) { - FT_Render_Glyph( ftSlot, FT_RENDER_MODE_NORMAL ); + 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 ); - if(ftSlot->format == FT_GLYPH_FORMAT_BITMAP) { - FT_Bitmap *glyphBitmap = &ftSlot->bitmap; + if (this->ftSlot->format == FT_GLYPH_FORMAT_BITMAP) { + FT_Bitmap *glyphBitmap = &this->ftSlot->bitmap; - textureWidth = adjustTextureWidth(glyphBitmap->width, this->textureFormat); - textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat); + textureWidth = adjustTextureWidth(glyphBitmap->width, this->textureFormat); + textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat); - this->fontData[charCode] = (ftgxCharData){ - ftSlot->bitmap_left, - ftSlot->advance.x >> 6, - gIndex, - textureWidth, - textureHeight, - ftSlot->bitmap_top, - ftSlot->bitmap_top, - glyphBitmap->rows - ftSlot->bitmap_top, - NULL - }; - this->loadGlyphData(glyphBitmap, &this->fontData[charCode]); + this->fontData[charCode] = (ftgxCharData) { + this->ftSlot->bitmap_left, + this->ftSlot->advance.x >> 6, + gIndex, + textureWidth, + textureHeight, + this->ftSlot->bitmap_top, + this->ftSlot->bitmap_top, + glyphBitmap->rows - this->ftSlot->bitmap_top, + NULL + }; + this->loadGlyphData(glyphBitmap, &this->fontData[charCode]); - return &this->fontData[charCode]; - } - } - return NULL; + return &this->fontData[charCode]; + } + } + + return NULL; } /** @@ -370,18 +398,20 @@ 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 i = 0; - FT_UInt gIndex; - 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 ); - } - return i; +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) { + i++; + } + + charCode = FT_Get_Next_Char( this->ftFace, charCode, &gIndex ); + } + + return i; } /** @@ -393,46 +423,44 @@ 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) -{ - uint32_t *glyphData = (uint32_t *)memalign(32, charData->textureWidth * charData->textureHeight * 4); - memset(glyphData, 0x00, charData->textureWidth * charData->textureHeight * 4); +void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) { - 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; - } - } + uint32_t *glyphData = (uint32_t *)memalign(32, charData->textureWidth * charData->textureHeight * 4); + memset(glyphData, 0x00, charData->textureWidth * charData->textureHeight * 4); - switch(this->textureFormat) - { - case GX_TF_I4: - charData->glyphDataTexture = Metaphrasis::convertBufferToI4(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_I8: - charData->glyphDataTexture = Metaphrasis::convertBufferToI8(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_IA4: - charData->glyphDataTexture = Metaphrasis::convertBufferToIA4(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_IA8: - charData->glyphDataTexture = Metaphrasis::convertBufferToIA8(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_RGB565: - charData->glyphDataTexture = Metaphrasis::convertBufferToRGB565(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_RGB5A3: - charData->glyphDataTexture = Metaphrasis::convertBufferToRGB5A3(glyphData, charData->textureWidth, charData->textureHeight); - break; - case GX_TF_RGBA8: - default: - charData->glyphDataTexture = Metaphrasis::convertBufferToRGBA8(glyphData, charData->textureWidth, charData->textureHeight); - break; - } - free(glyphData); + 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) { + case GX_TF_I4: + charData->glyphDataTexture = Metaphrasis::convertBufferToI4(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_I8: + charData->glyphDataTexture = Metaphrasis::convertBufferToI8(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_IA4: + charData->glyphDataTexture = Metaphrasis::convertBufferToIA4(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_IA8: + charData->glyphDataTexture = Metaphrasis::convertBufferToIA8(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_RGB565: + charData->glyphDataTexture = Metaphrasis::convertBufferToRGB565(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_RGB5A3: + charData->glyphDataTexture = Metaphrasis::convertBufferToRGB5A3(glyphData, charData->textureWidth, charData->textureHeight); + break; + case GX_TF_RGBA8: + default: + charData->glyphDataTexture = Metaphrasis::convertBufferToRGBA8(glyphData, charData->textureWidth, charData->textureHeight); + break; + } + + free(glyphData); } /** @@ -443,15 +471,21 @@ 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) -{ - if (format & FTGX_JUSTIFY_LEFT) - return 0; - else if (format & FTGX_JUSTIFY_CENTER) - return -(width >> 1); - else if (format & FTGX_JUSTIFY_RIGHT) - return -width; - return 0; +int16_t FreeTypeGX::getStyleOffsetWidth(uint16_t width, uint16_t format) { + + switch (format & FTGX_JUSTIFY_MASK) { + case FTGX_JUSTIFY_LEFT: + return 0; + + default: + case FTGX_JUSTIFY_CENTER: + return -(width >> 1); + + case FTGX_JUSTIFY_RIGHT: + return -width; + } + + return 0; } /** @@ -462,33 +496,32 @@ 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) - { - case FTGX_ALIGN_TOP: - return offset->ascender; +int16_t FreeTypeGX::getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format) { + switch (format & FTGX_ALIGN_MASK) { + case FTGX_ALIGN_TOP: + return offset->ascender; - default: - case FTGX_ALIGN_MIDDLE: - return (offset->ascender + offset->descender + 1) >> 1; + default: + case FTGX_ALIGN_MIDDLE: + return (offset->ascender + offset->descender + 1) >> 1; - case FTGX_ALIGN_BOTTOM: - return offset->descender; + case FTGX_ALIGN_BOTTOM: + return offset->descender; - case FTGX_ALIGN_BASELINE: - return 0; + case FTGX_ALIGN_BASELINE: + return 0; - case FTGX_ALIGN_GLYPH_TOP: - return offset->max; + case FTGX_ALIGN_GLYPH_TOP: + return offset->max; - case FTGX_ALIGN_GLYPH_MIDDLE: - return (offset->max + offset->min + 1) >> 1; + case FTGX_ALIGN_GLYPH_MIDDLE: + return (offset->max + offset->min + 1) >> 1; - case FTGX_ALIGN_GLYPH_BOTTOM: - return offset->min; - } - return 0; + case FTGX_ALIGN_GLYPH_BOTTOM: + return offset->min; + } + + return 0; } /** @@ -504,82 +537,100 @@ 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) -{ - if(!text) - return 0; +uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color, uint16_t textStyle) { + uint16_t strLength = wcslen(text); + uint16_t x_pos = x, printed = 0; + uint16_t x_offset = 0, y_offset = 0; + GXTexObj glyphTexture; + FT_Vector pairDelta; + ftgxDataOffset offset; - uint16_t strLength = wcslen(text); - uint16_t x_pos = x, printed = 0; - uint16_t x_offset = 0, y_offset = 0; - GXTexObj glyphTexture; - FT_Vector pairDelta; - ftgxDataOffset offset; + 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_JUSTIFY_MASK) - { - x_offset = this->getStyleOffsetWidth(this->getWidth(text), 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() ) - { - glyphData = &this->fontData[text[i]]; - } - else - { - glyphData = this->cacheGlyphData(text[i]); - } + ftgxCharData* glyphData = NULL; + if ( this->fontData.find(text[i]) != this->fontData.end() ) { + glyphData = &this->fontData[text[i]]; + } else { + glyphData = this->cacheGlyphData(text[i]); + } - 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; - } + if (glyphData != NULL) { - GX_InitTexObj(&glyphTexture, glyphData->glyphDataTexture, glyphData->textureWidth, glyphData->textureHeight, this->textureFormat, GX_CLAMP, GX_CLAMP, GX_FALSE); - this->copyTextureToFramebuffer(&glyphTexture, glyphData->textureWidth, glyphData->textureHeight, x_pos + glyphData->renderOffsetX + x_offset, y - glyphData->renderOffsetY + y_offset, color); + if (this->ftKerningEnabled && i) { + FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta ); + x_pos += pairDelta.x >> 6; + } - x_pos += glyphData->glyphAdvanceX; - printed++; - } - } + GX_InitTexObj(&glyphTexture, glyphData->glyphDataTexture, glyphData->textureWidth, glyphData->textureHeight, this->textureFormat, GX_CLAMP, GX_CLAMP, GX_FALSE); + this->copyTextureToFramebuffer(&glyphTexture, glyphData->textureWidth, glyphData->textureHeight, x_pos + glyphData->renderOffsetX + x_offset, y - glyphData->renderOffsetY + y_offset, color); - if(textStyle & FTGX_STYLE_MASK) - { - this->getOffset(text, &offset); - this->drawTextFeature(x + x_offset, y + y_offset, this->getWidth(text), &offset, textStyle, color); - } + x_pos += glyphData->glyphAdvanceX; + printed++; + } + } - return printed; + if (textStyle & FTGX_STYLE_MASK) { + this->drawTextFeature(x + x_offset, y + y_offset, this->getWidth(text), this->getOffset(text, &offset), textStyle, color); + } + + return printed; } /** * \overload */ -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); +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) -{ - uint16_t featureHeight = this->ftPointSize >> 4 > 0 ? this->ftPointSize >> 4 : 1; +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) - this->copyFeatureToFramebuffer(width, featureHeight, x, y + 1, color); + 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: + this->copyFeatureToFramebuffer(width, featureHeight, x, y + 1, color); + break; + } + } - if (format & FTGX_STYLE_STRIKE) - this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max) >> 1), color); + 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); + this->copyFeatureToFramebuffer(width, featureHeight, x, y - ((offsetData->max) >> 1), color); + break; + } + } } /** @@ -591,48 +642,39 @@ 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) -{ - if(!text) - return 0; +uint16_t FreeTypeGX::getWidth(wchar_t *text) { + uint16_t strLength = wcslen(text); + uint16_t strWidth = 0; + FT_Vector pairDelta; - 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() ) { + glyphData = &this->fontData[text[i]]; + } else { + glyphData = this->cacheGlyphData(text[i]); + } - ftgxCharData* glyphData = NULL; - if( this->fontData.find(text[i]) != this->fontData.end() ) - { - glyphData = &this->fontData[text[i]]; - } - 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 ); + strWidth += pairDelta.x >> 6; + } - 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; + strWidth += glyphData->glyphAdvanceX; + } + } + + return strWidth; } /** * * \overload */ -uint16_t FreeTypeGX::getWidth(wchar_t const *text) -{ - return this->getWidth((wchar_t *)text); +uint16_t FreeTypeGX::getWidth(wchar_t const *text) { + return this->getWidth((wchar_t *)text); } /** @@ -644,20 +686,19 @@ 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) -{ - ftgxDataOffset offset; - this->getOffset(text, &offset); - return offset.max - offset.min; +uint16_t FreeTypeGX::getHeight(wchar_t *text) { + ftgxDataOffset offset; + this->getOffset(text, &offset); + + return offset.max - offset.min; } /** * * \overload */ -uint16_t FreeTypeGX::getHeight(wchar_t const *text) -{ - return this->getHeight((wchar_t *)text); +uint16_t FreeTypeGX::getHeight(wchar_t const *text) { + return this->getHeight((wchar_t *)text); } /** @@ -670,43 +711,37 @@ uint16_t FreeTypeGX::getHeight(wchar_t const *text) * @param offset returns the max and min values above and below the font origin line * */ -void FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) -{ - uint16_t strLength = wcslen(text); - int16_t strMax = 0, strMin = 9999; +ftgxDataOffset* 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() ) - { - glyphData = &this->fontData[text[i]]; - } - else - { - glyphData = this->cacheGlyphData(text[i]); - } + ftgxCharData* glyphData = NULL; + if ( this->fontData.find(text[i]) != this->fontData.end() ) { + glyphData = &this->fontData[text[i]]; + } else { + glyphData = this->cacheGlyphData(text[i]); + } - if(glyphData != NULL) - { - strMax = glyphData->renderOffsetMax > strMax ? glyphData->renderOffsetMax : strMax; - strMin = glyphData->renderOffsetMin < strMin ? glyphData->renderOffsetMin : strMin; - } - } - offset->ascender = ftFace->size->metrics.ascender>>6; - offset->descender = ftFace->size->metrics.descender>>6; - offset->max = strMax; - offset->min = strMin; + 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->max = strMax; + offset->min = strMin; + return offset; } /** * * \overload */ -void FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset) -{ - this->getOffset(text, offset); +ftgxDataOffset* FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset) { + return this->getOffset(text, offset); } /** @@ -721,33 +756,33 @@ void FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset) * @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) -{ - GX_LoadTexObj(texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); +void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color) { - GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); - GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT); + GX_LoadTexObj(texObj, GX_TEXMAP0); + GX_InvalidateTexAll(); - GX_Begin(GX_QUADS, this->vertexIndex, 4); - GX_Position2s16(screenX, screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_TexCoord2f32(0.0f, 0.0f); + GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); + GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT); - GX_Position2s16(texWidth + screenX, screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_TexCoord2f32(1.0f, 0.0f); + GX_Begin(GX_QUADS, this->vertexIndex, 4); + GX_Position2s16(screenX, screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_TexCoord2f32(0.0f, 0.0f); - GX_Position2s16(texWidth + screenX, texHeight + screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_TexCoord2f32(1.0f, 1.0f); + GX_Position2s16(texWidth + screenX, screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_TexCoord2f32(1.0f, 0.0f); - GX_Position2s16(screenX, texHeight + screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_TexCoord2f32(0.0f, 1.0f); - GX_End(); + GX_Position2s16(texWidth + screenX, texHeight + screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_TexCoord2f32(1.0f, 1.0f); - this->setDefaultMode(); + GX_Position2s16(screenX, texHeight + screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_TexCoord2f32(0.0f, 1.0f); + GX_End(); + + this->setDefaultMode(); } /** @@ -761,24 +796,24 @@ 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) -{ - GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); - GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); +void FreeTypeGX::copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color) { - GX_Begin(GX_QUADS, this->vertexIndex, 4); - GX_Position2s16(screenX, screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); + GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); + GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); - GX_Position2s16(featureWidth + screenX, screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); + GX_Begin(GX_QUADS, this->vertexIndex, 4); + GX_Position2s16(screenX, screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); - GX_Position2s16(featureWidth + screenX, featureHeight + screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); + GX_Position2s16(featureWidth + screenX, screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); - GX_Position2s16(screenX, featureHeight + screenY); - GX_Color4u8(color.r, color.g, color.b, color.a); - GX_End(); + GX_Position2s16(featureWidth + screenX, featureHeight + screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); - this->setDefaultMode(); + GX_Position2s16(screenX, featureHeight + screenY); + GX_Color4u8(color.r, color.g, color.b, color.a); + GX_End(); + + this->setDefaultMode(); } diff --git a/source/FreeTypeGX.h b/source/FreeTypeGX.h index a093a5c0..5d235837 100644 --- a/source/FreeTypeGX.h +++ b/source/FreeTypeGX.h @@ -156,68 +156,37 @@ #include FT_FREETYPE_H #include FT_BITMAP_H #include "Metaphrasis.h" -#include "filelist.h" #include #include -#include #include -#define MAX_FONT_SIZE 100 - -/*! \struct ftgxCharData_ +/*! forward deklaration of private structures * - * 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; #define _TEXT(t) L ## t /**< Unicode helper macro. */ -#define FTGX_NULL 0x0000 -#define FTGX_JUSTIFY_LEFT 0x0001 -#define FTGX_JUSTIFY_CENTER 0x0002 -#define FTGX_JUSTIFY_RIGHT 0x0004 -#define FTGX_JUSTIFY_MASK 0x000f +#define FTGX_NULL 0x0000 +#define FTGX_JUSTIFY_LEFT 0x0001 +#define FTGX_JUSTIFY_CENTER 0x0002 +#define FTGX_JUSTIFY_RIGHT 0x0003 +#define FTGX_JUSTIFY_MASK 0x000f -#define FTGX_ALIGN_TOP 0x0010 -#define FTGX_ALIGN_MIDDLE 0x0020 -#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_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_STYLE_UNDERLINE 0x1000 -#define FTGX_STYLE_STRIKE 0x2000 -#define FTGX_STYLE_MASK 0xf000 +#define FTGX_STYLE_UNDERLINE 0x0100 +#define FTGX_STYLE_STRIKE 0x0200 +#define FTGX_STYLE_MASK 0x0f00 #define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE 0X0001 #define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL 0X0002 @@ -234,11 +203,10 @@ 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. */ - -wchar_t* charToWideChar(const char* p); -bool LoadCustomFont(const char *path); -void ClearFontData(); +const GXColor ftgxWhite = (GXColor) { + 0xff, 0xff, 0xff, 0xff +} +; /**< Constant color value used only to sanitize Doxygen documentation. */ /*! \class FreeTypeGX * \brief Wrapper class for the libFreeType library with GX rendering. @@ -251,56 +219,59 @@ void ClearFontData(); */ class FreeTypeGX { - private: - FT_Library ftLibrary; /**< FreeType FT_Library instance. */ - FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */ - 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. */ +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. */ - uint8_t textureFormat; /**< Defined texture format of the target EFB. */ - uint8_t vertexIndex; /**< Vertex format descriptor index. */ - uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */ - std::map fontData; /**< Map which holds the glyph data structures for the corresponding characters. */ + uint8_t textureFormat; /**< Defined texture format of the target EFB. */ + uint8_t vertexIndex; /**< Vertex format descriptor index. */ + uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */ + std::map fontData; /**< Map which holds the glyph data structures for the corresponding characters. */ - static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat); - static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat); + static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat); + static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat); - static int16_t getStyleOffsetWidth(uint16_t width, uint16_t format); - static int16_t getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format); + static int16_t getStyleOffsetWidth(uint16_t width, uint16_t format); + static int16_t getStyleOffsetHeight(ftgxDataOffset *offset, uint16_t format); - void unloadFont(); - ftgxCharData *cacheGlyphData(wchar_t charCode); - uint16_t cacheGlyphDataComplete(); - void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData); + void unloadFont(); + void clearGlyphData(); + ftgxCharData *cacheGlyphData(wchar_t charCode); + uint16_t cacheGlyphDataComplete(); + void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData); - void setDefaultMode(); + void setDefaultMode(); - void drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color); - 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); + void drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color); + 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(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(); +public: + FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1); + ~FreeTypeGX(); - void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize, bool loadcustomfont); - void ChangeFontSize(FT_UInt pixelSize, FT_UInt pixelSizeHorz = 0); - uint8_t GetMaxCharWidth(); + static wchar_t* charToWideChar(char* p); + static wchar_t* charToWideChar(const char* p); + void setVertexFormat(uint8_t vertexIndex); + void setCompatibilityMode(uint32_t compatibilityMode); - 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); + 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); - uint16_t getWidth(wchar_t *text); - uint16_t getWidth(wchar_t const *text); - uint16_t getHeight(wchar_t *text); - uint16_t getHeight(wchar_t const *text); - void getOffset(wchar_t *text, ftgxDataOffset* offset); - void getOffset(wchar_t const *text, ftgxDataOffset* offset); + uint16_t getWidth(wchar_t *text); + 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); }; #endif /* FREETYPEGX_H_ */ diff --git a/source/cheats/cheatmenu.cpp b/source/cheats/cheatmenu.cpp index c8ff9c02..a76e7cec 100644 --- a/source/cheats/cheatmenu.cpp +++ b/source/cheats/cheatmenu.cpp @@ -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, SCROLL_HORIZONTAL); + titleTxt.SetMaxWidth(350, GuiText::SCROLL); titleTxt.SetPosition(12,40); for (int i = 0; i <= cntcheats; i++) { diff --git a/source/homebrewboot/HomebrewBrowse.cpp b/source/homebrewboot/HomebrewBrowse.cpp index f3c440f0..c066689e 100644 --- a/source/homebrewboot/HomebrewBrowse.cpp +++ b/source/homebrewboot/HomebrewBrowse.cpp @@ -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, DOTTED); + MainButton1Txt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::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, DOTTED); + MainButton1DescTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::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, SCROLL_HORIZONTAL); + MainButton1DescOverTxt.SetMaxWidth(MainButton1Img.GetWidth()-150, GuiText::SCROLL); 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, DOTTED); + MainButton2Txt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::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, DOTTED); + MainButton2DescTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::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, SCROLL_HORIZONTAL); + MainButton2DescOverTxt.SetMaxWidth(MainButton2Img.GetWidth()-150, GuiText::SCROLL); 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, DOTTED); + MainButton3Txt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::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, DOTTED); + MainButton3DescTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::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, SCROLL_HORIZONTAL); + MainButton3DescOverTxt.SetMaxWidth(MainButton3Img.GetWidth()-150, GuiText::SCROLL); 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, DOTTED); + MainButton4Txt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::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, DOTTED); + MainButton4DescTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::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, SCROLL_HORIZONTAL ); + MainButton4DescOverTxt.SetMaxWidth(MainButton4Img.GetWidth()-150, GuiText::SCROLL); GuiButton MainButton4(MainButton4Img.GetWidth(), MainButton4Img.GetHeight()); MainButton4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); MainButton4.SetPosition(0, 300); @@ -838,29 +838,29 @@ int MenuHomebrewBrowse() { read += result; } - + char filename[101]; if (!error) { - + network_read((u8*) &filename, 100); - + // Do we need to unzip this thing? if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4) { // We need to unzip... if (temp[0] == 'P' && temp[1] == 'K' && temp[2] == 0x03 && temp[3] == 0x04) { // It's a zip file, unzip to the apps directory - + // Zip archive, ask for permission to install the zip char zippath[255]; sprintf((char *) &zippath, "%s%s", Settings.homebrewapps_path, filename); - + FILE *fp = fopen(zippath, "wb"); if (fp != NULL) { fwrite(temp, 1, infilesize, fp); fclose(fp); - + // Now unzip the zip file... unzFile uf = unzOpen(zippath); if (uf==NULL) { @@ -868,9 +868,9 @@ int MenuHomebrewBrowse() { } else { extractZip(uf,0,1,0, Settings.homebrewapps_path); unzCloseCurrentFile(uf); - + remove(zippath); - + // Reload this menu here... menu = MENU_HOMEBREWBROWSE; break; @@ -884,17 +884,17 @@ int MenuHomebrewBrowse() { uLongf f = uncfilesize; error = uncompress(unc, &f, temp, infilesize) != Z_OK; uncfilesize = f; - + free(temp); temp = unc; } } - + if (!error && strstr(filename,".zip") == NULL) { innetbuffer = temp; } } - + ProgressStop(); if (error || read != infilesize) { diff --git a/source/libwiigui/gui.h b/source/libwiigui/gui.h index 9b743523..9fac862c 100644 --- a/source/libwiigui/gui.h +++ b/source/libwiigui/gui.h @@ -47,14 +47,13 @@ #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); @@ -91,16 +90,6 @@ enum IMAGE_COPY }; -enum -{ - NONE, - WRAP, - LONGTEXT, - DOTTED, - SCROLL_HORIZONTAL, - SCROLL_NONE -}; - enum { TRIGGER_SIMPLE, @@ -710,8 +699,8 @@ class GuiText : public GuiElement //!Sets the text of the GuiText element //!\param t Text void SetText(const char * t); - void SetText(const wchar_t * t); void SetTextf(const char *format, ...) __attribute__((format(printf,2,3))); + void SetText(const wchar_t * t); //!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 @@ -721,30 +710,28 @@ class GuiText : public GuiElement //!\param s Font style //!\param h Text alignment (horizontal) //!\param v Text alignment (vertical) - void SetPresets(int sz, GXColor c, int w, u16 s, int h, int v); + static void SetPresets(int sz, GXColor c, int w, int wrap, 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 - void SetMaxWidth(int w = 0, int m = WRAP); + enum { + WRAP, + DOTTED, + SCROLL, + MARQUEE + }; + void SetMaxWidth(int w, short m=GuiText::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); + void SetStyle(u16 s, u16 m=0xffff); //!Sets the text alignment //!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE) //!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE) @@ -754,37 +741,33 @@ class GuiText : public GuiElement void SetFont(FreeTypeGX *f); //!Get the Horizontal Size of Text int GetTextWidth(); - //!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); - //!SetWidescreen + // 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(); //!Constantly called to draw the text void Draw(); protected: - 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 + wchar_t* text; //!< Unicode text value 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; - bool widescreen; //added - int firstLine; - int linestodraw; - int totalLines; - int textWidth; - int currentSize; - u32 *LineBreak; + 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 }; //!Display, manage, and manipulate tooltips in the GUI. @@ -997,7 +980,6 @@ class GuiKeyboard : public GuiWindow GuiTrigger * trigB; }; - typedef struct _optionlist { int length; char name[MAX_OPTIONS][60]; diff --git a/source/libwiigui/gui_customoptionbrowser.cpp b/source/libwiigui/gui_customoptionbrowser.cpp index 7f206c5e..f4a4e1f2 100644 --- a/source/libwiigui/gui_customoptionbrowser.cpp +++ b/source/libwiigui/gui_customoptionbrowser.cpp @@ -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), DOTTED); + optionTxt[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::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), DOTTED); + optionVal[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::DOTTED); optionValOver[i]->SetPosition(coL2,0); - optionValOver[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), SCROLL_HORIZONTAL); + optionValOver[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::SCROLL); } } } diff --git a/source/libwiigui/gui_filebrowser.cpp b/source/libwiigui/gui_filebrowser.cpp index 6cf5a600..2561efbc 100644 --- a/source/libwiigui/gui_filebrowser.cpp +++ b/source/libwiigui/gui_filebrowser.cpp @@ -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), DOTTED); + fileListText[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth()+20), GuiText::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), SCROLL_HORIZONTAL); + fileListTextOver[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth()+20), GuiText::SCROLL); fileListBg[i] = new GuiImage(bgFileSelectionEntry); //fileListArchives[i] = new GuiImage(fileArchives); diff --git a/source/libwiigui/gui_gamebrowser.cpp b/source/libwiigui/gui_gamebrowser.cpp index 2dbd02f6..2f083331 100644 --- a/source/libwiigui/gui_gamebrowser.cpp +++ b/source/libwiigui/gui_gamebrowser.cpp @@ -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, DOTTED); + gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::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, SCROLL_HORIZONTAL); + gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL); gameBg[i] = new GuiImage(bgGamesEntry); diff --git a/source/libwiigui/gui_gamecarousel.cpp b/source/libwiigui/gui_gamecarousel.cpp index 3355b367..bf90d99a 100644 --- a/source/libwiigui/gui_gamecarousel.cpp +++ b/source/libwiigui/gui_gamecarousel.cpp @@ -111,7 +111,7 @@ noCover(nocover_png) gamename->SetParent(this); gamename->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); gamename->SetPosition(0, 330); - gamename->SetMaxWidth(280, DOTTED); + gamename->SetMaxWidth(280, GuiText::DOTTED); gameIndex = new int[pagesize]; game = new GuiButton * [pagesize]; diff --git a/source/libwiigui/gui_searchbar.cpp b/source/libwiigui/gui_searchbar.cpp index 7b37a3ec..0ffa5f36 100644 --- a/source/libwiigui/gui_searchbar.cpp +++ b/source/libwiigui/gui_searchbar.cpp @@ -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), SCROLL_HORIZONTAL); + text.SetWidescreen(CFG.widescreen); + text.SetMaxWidth(width-(10+2*42+10), GuiText::SCROLL); this->Append(&text); snprintf(imgPath, sizeof(imgPath), "%skeyboard_backspace_over.png", CFG.theme_path); diff --git a/source/libwiigui/gui_text.cpp b/source/libwiigui/gui_text.cpp index cc9ce035..ef0a822f 100644 --- a/source/libwiigui/gui_text.cpp +++ b/source/libwiigui/gui_text.cpp @@ -10,62 +10,42 @@ #include "gui.h" -static int presetSize = 18; +static int currentSize = 0; +static int currentWidescreen = 0; +static int presetSize = 0; +static GXColor presetColor = (GXColor){255, 255, 255, 255}; 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 = 0; - firstLine = 0; - linestodraw = 8; - totalLines = 0; - widescreen = false; //added - LineBreak = NULL; - textDyn = NULL; + wrapMode = GuiText::WRAP; + scrollPos1 = 0; + scrollPos2 = 0; + scrollDelay = 0; font = NULL; - textScrollPos = 0; - textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; - textScrollDelay = TEXT_SCROLL_DELAY; + widescreen = 0; //added + firstLine = 1; + numLines = -1; + totalLines = 1; alignmentHor = ALIGN_CENTRE; alignmentVert = ALIGN_MIDDLE; - for(int i = 0; i < MAX_LINES_TO_DRAW; i++) - textDynRow[i] = NULL; - if(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); - } + text = FreeTypeGX::charToWideChar((char *)t); } /** @@ -73,46 +53,27 @@ 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; - firstLine = 0; - linestodraw = 8; - totalLines = 0; - widescreen = false; //added - LineBreak = NULL; - textDyn = NULL; + scrollPos1 = 0; + scrollPos2 = 0; + scrollDelay = 0; font = NULL; - textScrollPos = 0; - textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; - textScrollDelay = TEXT_SCROLL_DELAY; + widescreen = 0; //added + firstLine = 1; + numLines = -1; + totalLines = 1; alignmentHor = presetAlignmentHor; alignmentVert = presetAlignmentVert; - for(int i = 0; i < MAX_LINES_TO_DRAW; i++) - textDynRow[i] = NULL; - if(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); - } + text = FreeTypeGX::charToWideChar((char *)t); } /** @@ -120,109 +81,64 @@ GuiText::GuiText(const char * t) */ GuiText::~GuiText() { - if(origText) - free(origText); if(text) + { delete [] text; - 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; - } + text = 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) - { - 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); - textWidth = fontSystem[currentSize]->getWidth(text); - } - } + text = FreeTypeGX::charToWideChar((char *)t); + scrollPos2 = 0; + scrollDelay = 0; } - void GuiText::SetTextf(const char *format, ...) { - LOCK(this); - char *tmp=0; va_list va; va_start(va, format); @@ -233,143 +149,66 @@ void GuiText::SetTextf(const char *format, ...) } va_end(va); } - -void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v) +void GuiText::SetText(const wchar_t * t) +{ + 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) { - LOCK(this); presetSize = sz; presetColor = c; - presetStyle = s; presetMaxWidth = w; + presetWrapMode = wrap; + presetStyle = s; presetAlignmentHor = h; presetAlignmentVert = v; } void GuiText::SetFontSize(int s) { - LOCK(this); - + LOCK(this); size = s; } -void GuiText::SetMaxWidth(int width, int w) +void GuiText::SetMaxWidth(int w, short m/*=GuiText::WRAP*/) { - LOCK(this); - - 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; - } - } + LOCK(this); + maxWidth = w; + wrapMode = m; } void GuiText::SetColor(GXColor c) { - LOCK(this); + LOCK(this); color = c; alpha = c.a; } -void GuiText::SetStyle(u16 s) +void GuiText::SetStyle(u16 s, u16 m/*=0xffff*/) { - LOCK(this); - style = s; + LOCK(this); + style &= ~m; + style |= s & m; } void GuiText::SetAlignment(int hor, int vert) { - LOCK(this); - style = 0; + LOCK(this); + style = FTGX_NULL; switch(hor) { @@ -399,87 +238,44 @@ 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(); - return fontSystem[currentSize]->getWidth(text); -} - -/** - * Set the lines to draw - */ -void GuiText::SetFirstLine(int line) -{ - LOCK(this); - firstLine = line; - - for(int i = 0; i < MAX_LINES_TO_DRAW; i++) + if(newSize != currentSize || currentWidescreen != widescreen) { - if(textDynRow[i]) - { - delete [] textDynRow[i]; - textDynRow[i] = NULL; - } + //fontSystem->changeSize(newSize); + (font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0); + currentSize = newSize; + currentWidescreen = widescreen; } -} - -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; + return (font ? font : fontSystem)->getWidth(text); } void GuiText::SetWidescreen(bool w) { - LOCK(this); - widescreen = w; + LOCK(this); + widescreen = w; } - /** * Draw the text on screen */ void GuiText::Draw() { + LOCK(this); if(!text) return; @@ -491,240 +287,246 @@ void GuiText::Draw() int newSize = size*this->GetScale(); - if(newSize > MAX_FONT_SIZE) - newSize = MAX_FONT_SIZE; - - if(newSize != currentSize) + if(newSize != currentSize || currentWidescreen != widescreen) { - if(font) - { - font->ChangeFontSize(newSize); - } - else if(!fontSystem[newSize]) - fontSystem[newSize] = new FreeTypeGX(newSize); - - if(text) - textWidth = (font ? font : fontSystem[newSize])->getWidth(text); + //fontSystem->changeSize(newSize); + (font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0); currentSize = newSize; + currentWidescreen = widescreen; } - if(widescreen) - (font ? font : fontSystem[currentSize])->ChangeFontSize(currentSize, currentSize*0.8); + int voffset = 0; - if(maxWidth > 0 && maxWidth <= textWidth) +// if(alignmentVert == ALIGN_MIDDLE) +// voffset = -newSize/2 + 2; + + if(maxWidth > 0 && (font ? font : fontSystem)->getWidth(text) > maxWidth) { - if(wrapMode == LONGTEXT) // text wrapping - { - int lineheight = newSize + 6; - if(!textDynRow[0]) - { - int index = 0; - u32 strlen = (u32) wcslen(text); - int linenum = firstLine; - int lineIndex = 0; - u32 ch = LineBreak[linenum]; - - u32 lastch = LineBreak[linenum+linestodraw]+1; - - textDynRow[lineIndex] = new wchar_t[maxWidth]; - - textDynRow[lineIndex][index] = 0; - - while((ch < lastch) && (ch < strlen+1)) - { - if(ch == LineBreak[linenum+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) + if(wrapMode == GuiText::WRAP) // text wrapping { + int lineheight = newSize + 6; 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; - } - } - - if(maxWidth < textWidth && (frameCount % textScrollDelay == 0)) + int i = 0; + int ch = 0; + int linenum = 0; + int linemax = 200; + int lastSpace = -1; + int lastSpaceIndex = -1; + wchar_t * tmptext[linemax]; + + totalLines=0; + while(ch < strlen) { - if(textScrollInitialDelay) + if(i == 0) { - textScrollInitialDelay--; + if (linenum <= linemax) + { + tmptext[linenum] = new wchar_t[strlen + 1]; + } + else + { + break; + } } - else + + tmptext[linenum][i] = text[ch]; + tmptext[linenum][i+1] = 0; + + //if(text[ch] == ' ' || ch == strlen-1) + //{ + if((font ? font : fontSystem)->getWidth(tmptext[linenum]) >= maxWidth) + //if(fontSystem->getWidth(tmptext[linenum]) >= maxWidth) + { + if(lastSpace >= 0) + { + tmptext[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; + } + linenum++; + i = -1; + } + else if(ch == strlen-1) + { + linenum++; + } + //} + if(text[ch] == ' ' && i >= 0) { - textScrollPos++; - if(textScrollPos > strlen) - { - textScrollPos = 0; - textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; - } + lastSpace = ch; + lastSpaceIndex = i; + } + if(text[ch] == '\n' && ch != strlen-1 && i >= 0) + { + linenum++; + i = -1; + } + ch++; + i++; + } + totalLines = linenum; + + if(alignmentVert == ALIGN_MIDDLE) + voffset = voffset - (lineheight*linenum)/2 + lineheight/2; - 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 (numLines <0){ + for(i=0; i < linenum; i++) + { + (font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[i], c, style); + delete tmptext[i]; } } - 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) - { - 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; - } - linenum++; - i = -1; - } - else if(ch == txtlen-1) - { - linenum++; - } - } - if(text[ch] == ' ' && i >= 0) - { - lastSpace = ch; - lastSpaceIndex = i; - } - ch++; - i++; - } - linestodraw = linenum; - } - - int voffset = 0; - if(alignmentVert == ALIGN_MIDDLE) - voffset = -(lineheight*linestodraw)/2 + lineheight/2; - - for(int i=0; i < linestodraw; i++) - { - if(textDynRow[i]) - (font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, textDynRow[i], c, style); - } + + //put in for txt vertical txt scrolling + else { + int j; + i=0; + for(j=firstLine-1; j < numLines+firstLine-1; j++) + { + //if (jdrawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[j], c, style); + i++; + } + for(i=0; i < linenum; i++) + { + delete tmptext[i]; + } + } + + } - else + else if(wrapMode == GuiText::DOTTED) // text dotted { - (font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop(), text, c, style); + 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 } } else { - (font ? font : fontSystem[currentSize])->drawText(this->GetLeft(), this->GetTop(), text, c, style); + (font ? font : fontSystem)->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style); } this->UpdateEffects(); - - if(widescreen) - (font ? font : fontSystem[currentSize])->ChangeFontSize(currentSize, 0); } diff --git a/source/main.cpp b/source/main.cpp index 3e7d7f35..f5adfdbf 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -41,10 +41,18 @@ #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}); @@ -64,7 +72,7 @@ static void BootUpProblems() ret2 = IOS_ReloadIOS(249); if (ret2 < 0) { ret2 = IOS_ReloadIOS(222); - SDCard_Init(); + SDCard_Init(); load_ehc_module(); SDCard_deInit(); if(ret2 <0) { @@ -103,6 +111,12 @@ 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; + } } @@ -111,9 +125,6 @@ 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; @@ -128,14 +139,14 @@ main(int argc, char *argv[]) { /** PAD_Init has to be before InitVideo don't move that **/ PAD_Init(); // initialize PAD/WPAD - + USBDevice_Init();// seems enough to wake up some HDDs if they are in sleep mode when the loader starts (tested with WD MyPassport Essential 2.5") - + ret = IOS_ReloadIOS(249); if (ret < 0) { ret = IOS_ReloadIOS(222); - SDCard_Init(); + SDCard_Init(); load_ehc_module(); SDCard_deInit(); if(ret <0) { @@ -149,7 +160,7 @@ main(int argc, char *argv[]) { if (ret < 0) { ret = IOS_ReloadIOS(222); - SDCard_Init(); + SDCard_Init(); load_ehc_module(); SDCard_deInit(); if(ret < 0) { @@ -230,11 +241,18 @@ 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); - LoadCustomFont(fontPath); + fontSystem->loadFont(fontPath, font_ttf, font_ttf_size, 0); + fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); 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; diff --git a/source/main.h b/source/main.h index fb70f81a..f2588132 100644 --- a/source/main.h +++ b/source/main.h @@ -8,8 +8,11 @@ #ifndef _MAIN_H_ #define _MAIN_H_ +#include "FreeTypeGX.h" + extern struct SSettings Settings; void DefaultSettings(); +extern FreeTypeGX *fontSystem; #endif diff --git a/source/menu.cpp b/source/menu.cpp index f8eb4c6a..02789e42 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -213,7 +213,7 @@ void ExitGUIThreads() { } void rockout(int f = 0) { - + HaltGui(); int num=(f==2?-1:gameSelected); @@ -270,7 +270,7 @@ GuiImageData *LoadCoverImage(struct discHdr *header, bool Prefere3D, bool noCove { char *coverPath = flag ? Settings.covers_path : Settings.covers2d_path; flag = !flag; //Load full id image - snprintf(Path, sizeof(Path), "%s%s.png", coverPath, IDfull); + snprintf(Path, sizeof(Path), "%s%s.png", coverPath, IDfull); delete Cover; Cover = new(std::nothrow) GuiImageData(Path, NULL); //Load short id image if (!Cover || !Cover->GetImage()) @@ -329,7 +329,6 @@ int MenuDiscList() { int dataed = -1; int cosa=0,sina=0; int selectImg1 = 0; - bool firstRun = true; char ID[4]; char IDfull[7]; u32 covert = 0; @@ -337,7 +336,7 @@ int MenuDiscList() { if (!dvdheader) dvdheader = new struct discHdr; u8 mountMethodOLD =0; - + WDVD_GetCoverStatus(&covert); u32 covertOld=covert; @@ -469,19 +468,19 @@ int MenuDiscList() { GuiText usedSpaceTxt(spaceinfo, 18, THEME.info); usedSpaceTxt.SetAlignment(THEME.hddinfo_align, ALIGN_TOP); usedSpaceTxt.SetPosition(THEME.hddinfo_x, THEME.hddinfo_y); - + char GamesCnt[15]; sprintf(GamesCnt,"%s: %i",(mountMethod!=3?tr("Games"):tr("Channels")), gameCnt); GuiText gamecntTxt(GamesCnt, 18, THEME.info); - + GuiButton gamecntBtn(100,18); gamecntBtn.SetAlignment(THEME.gamecount_align, ALIGN_TOP); gamecntBtn.SetPosition(THEME.gamecount_x,THEME.gamecount_y); gamecntBtn.SetLabel(&gamecntTxt); gamecntBtn.SetEffectGrow(); gamecntBtn.SetTrigger(&trigA); - - + + GuiTooltip installBtnTT(tr("Install a game")); if (Settings.wsprompt == yes) @@ -745,18 +744,18 @@ int MenuDiscList() { idBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); idBtn.SetPosition(THEME.id_x,THEME.id_y); - + if (Settings.godmode == 1 && mountMethod!=3) {//only make the button have trigger & tooltip if in godmode DownloadBtn.SetSoundOver(&btnSoundOver); DownloadBtn.SetTrigger(&trigA); DownloadBtn.SetTrigger(&trig1); DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); - + idBtn.SetSoundOver(&btnSoundOver); idBtn.SetTrigger(&trigA); idBtn.SetToolTip(&IDBtnTT,205,-30); - + } else { DownloadBtn.SetRumble(false); @@ -784,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(clock_ttf, clock_ttf_size); + clockTimeBack.SetFont(fontClock); GuiText clockTime(theTime, 40, THEME.clock); clockTime.SetAlignment(THEME.clock_align, ALIGN_TOP); clockTime.SetPosition(THEME.clock_x, THEME.clock_y); - clockTime.SetFont(clock_ttf, clock_ttf_size); + clockTime.SetFont(fontClock); HaltGui(); GuiWindow w(screenwidth, screenheight); @@ -808,7 +807,7 @@ int MenuDiscList() { w.Append(&settingsBtn); w.Append(&DownloadBtn); w.Append(&idBtn); - + // Begin Toolbar w.Append(&favoriteBtn); Toolbar[0] = &favoriteBtn; @@ -828,9 +827,9 @@ int MenuDiscList() { Toolbar[7] = &dvdBtn; w.SetUpdateCallback(DiscListWinUpdateCallback); // End Toolbar - - - + + + if (Settings.godmode == 1) w.Append(&homebrewBtn); @@ -856,10 +855,10 @@ int MenuDiscList() { if(searchBar) mainWindow->Append(searchBar); } - + ResumeGui(); - - + + while (menu == MENU_NONE) { if (idiotFlag==1) { @@ -892,36 +891,31 @@ int MenuDiscList() { break; } - //CLOCK update every 10 secs - if(frameCount % 600 == 0 || firstRun) - { - firstRun = false; - - time_t rawtime = time(0); //this fixes code dump caused by the clock - if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) { - lastrawtime = rawtime; - timeinfo = localtime (&rawtime); - if (dataed < 1) { - if (Settings.hddinfo == hr12) { - if (rawtime & 1) - strftime(theTime, sizeof(theTime), "%I:%M", timeinfo); - else - strftime(theTime, sizeof(theTime), "%I %M", timeinfo); - } - if (Settings.hddinfo == hr24) { - if (rawtime & 1) - strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); - else - strftime(theTime, sizeof(theTime), "%H %M", timeinfo); - } - clockTime.SetText(theTime); - - } else if (dataed > 0) { - - clockTime.SetTextf("%i", (dataed-1)); + //CLOCK + time_t rawtime = time(0); //this fixes code dump caused by the clock + if (((Settings.hddinfo == hr12)||(Settings.hddinfo == hr24)) && rawtime != lastrawtime) { + lastrawtime = rawtime; + timeinfo = localtime (&rawtime); + if (dataed < 1) { + if (Settings.hddinfo == hr12) { + if (rawtime & 1) + strftime(theTime, sizeof(theTime), "%I:%M", timeinfo); + else + strftime(theTime, sizeof(theTime), "%I %M", timeinfo); } + if (Settings.hddinfo == hr24) { + if (rawtime & 1) + strftime(theTime, sizeof(theTime), "%H:%M", timeinfo); + else + strftime(theTime, sizeof(theTime), "%H %M", timeinfo); + } + clockTime.SetText(theTime); + } else if (dataed > 0) { + + 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 @@ -1064,7 +1058,7 @@ int MenuDiscList() { } if (isInserted(bootDevice)) { HaltGui(); // to fix endless rumble when clicking on the SD icon when rumble is disabled because rumble is set to on in Global_Default() - CFG_Load(); + CFG_Load(); ResumeGui(); } sdcardBtn.ResetState(); @@ -1179,8 +1173,8 @@ int MenuDiscList() { wcscpy(newFilter, gameFilter); newFilter[len] = searchChar; newFilter[len+1] = 0; - - + + __Menu_GetEntries(0, newFilter); menu = MENU_DISCLIST; break; @@ -1210,7 +1204,7 @@ int MenuDiscList() { searchBtn.SetImageOver(&searchBtnImg_g); searchBtn.SetAlpha(180); } - + ResumeGui(); } else if(searchChar == 8) // Backspace @@ -1221,7 +1215,7 @@ int MenuDiscList() { } } - + else if (abcBtn.GetState() == STATE_CLICKED) { if (Settings.sort != all) { Settings.sort=all; @@ -1239,6 +1233,7 @@ int MenuDiscList() { else if (countBtn.GetState() == STATE_CLICKED) { if (Settings.sort != pcount) { Settings.sort=pcount; + //if(isSdInserted()) { if (isInserted(bootDevice)) { cfg_save_global(); } @@ -1315,7 +1310,7 @@ int MenuDiscList() { } else if (dvdBtn.GetState() == STATE_CLICKED) { mountMethodOLD = (mountMethod==3?mountMethod:0); - + mountMethod=DiscMount(dvdheader); dvdBtn.ResetState(); @@ -1368,7 +1363,7 @@ int MenuDiscList() { delete GameRegionTxt; GameRegionTxt = NULL; } - + switch (header->id[3]) { case 'E': sprintf(gameregion,"NTSC U"); @@ -1432,7 +1427,7 @@ int MenuDiscList() { } } } - + if (idBtn.GetState() == STATE_CLICKED && mountMethod!=3) { struct discHdr * header = &gameList[gameBrowser->GetSelectedOption()]; //enter new game ID @@ -1445,13 +1440,13 @@ int MenuDiscList() { //__Menu_GetEntries(); menu = MENU_DISCLIST; } - + idBtn.ResetState(); } } if (((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) - || mountMethod==1 + || mountMethod==1 || mountMethod==2) { if(searchBar) { @@ -1480,7 +1475,7 @@ int MenuDiscList() { header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]); //reset header snprintf (IDfull,sizeof(IDfull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); - + if (game_cfg) { alternatedol = game_cfg->loadalternatedol; ocarinaChoice = game_cfg->ocarina; @@ -1524,7 +1519,7 @@ int MenuDiscList() { } } - + wiilight(0); if (isInserted(bootDevice)) { //////////save game play count//////////////// @@ -1623,7 +1618,7 @@ int MenuDiscList() { wiilight(0); //re-evaluate header now in case they changed games while on the game prompt header = &gameList[gameSelected]; - + //enter new game title char entered[60]; snprintf(entered, sizeof(entered), "%s", get_title(header)); @@ -1680,7 +1675,7 @@ int MenuDiscList() { if (game_cfg) { if (game_cfg->alternatedolstart != 0) altdoldefault = false; - } + } if (altdoldefault) { int autodol = autoSelectDol((char*)header->id, true); if (autodol>0) { @@ -1698,11 +1693,11 @@ int MenuDiscList() { } } } - + if (menu == MENU_EXIT) { SDCard_deInit(); } - + HaltGui(); mainWindow->RemoveAll(); mainWindow->Append(bgImg); @@ -1745,7 +1740,7 @@ static int MenuInstall() { GuiImageData batteryRed(imgPath, battery_red_png); snprintf(imgPath, sizeof(imgPath), "%sbattery_bar_red.png", CFG.theme_path); GuiImageData batteryBarRed(imgPath, battery_bar_red_png); - + HaltGui(); GuiWindow w(screenwidth, screenheight); @@ -2185,7 +2180,7 @@ int MainMenu(int menu) { break; } } - + //MemInfoPrompt(); //for testing /*if (mountMethod) @@ -2208,9 +2203,10 @@ int MainMenu(int menu) { delete GameIDTxt; delete cover; delete coverImg; + delete fontClock; + delete fontSystem; ShutdownAudio(); StopGX(); - ClearFontData(); gettextCleanUp(); if (mountMethod==3) { @@ -2250,7 +2246,7 @@ int MainMenu(int menu) { if (!altdoldefault) { alternatedol = game_cfg->loadalternatedol; alternatedoloffset = game_cfg->alternatedolstart; - } + } reloadblock = game_cfg->iosreloadblock; } else { videoChoice = Settings.video; @@ -2270,7 +2266,7 @@ int MainMenu(int menu) { } reloadblock = off; } - + int ios2; switch (iosChoice) { case i249: @@ -2297,8 +2293,8 @@ int MainMenu(int menu) { Sys_IosReload(249); } } - if (!mountMethod) - { + if (!mountMethod) + { ret = Disc_SetUSB(header->id); if (ret < 0) Sys_BackToLoader(); } @@ -2313,7 +2309,7 @@ int MainMenu(int menu) { } if(dvdheader) delete dvdheader; - + if (reloadblock == on && (IOS_GetVersion() == 222 || IOS_GetVersion() == 223)) { patch_cios_data(); mload_close(); diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp index 006e3ecb..d047584e 100644 --- a/source/prompts/DiscBrowser.cpp +++ b/source/prompts/DiscBrowser.cpp @@ -50,7 +50,7 @@ int DiscBrowse(struct discHdr * header) { return ret; } } - + ret = Disc_Open(); if (ret < 0) { ResumeGui(); @@ -71,7 +71,7 @@ int DiscBrowse(struct discHdr * header) { WindowPrompt(tr("ERROR:"), tr("Could not open WBFS partition"), tr("OK")); return ret; } - + int *buffer = (int*)allocate_memory(0x20); if (buffer == NULL) { @@ -86,7 +86,7 @@ int DiscBrowse(struct discHdr * header) { WindowPrompt(tr("ERROR:"), tr("Could not read the disc."), tr("OK")); return ret; } - + void *fstbuffer = allocate_memory(buffer[2]*4); FST_ENTRY *fst = (FST_ENTRY *)fstbuffer; @@ -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, SCROLL_HORIZONTAL); + titleTxt.SetMaxWidth(356, GuiText::SCROLL); GuiImage settingsbackground(&settingsbg); GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight()); @@ -241,29 +241,29 @@ int autoSelectDol(const char *id, bool force) { char id4[10]; sprintf(id4,"%c%c%c%c",id[0],id[1],id[2],id[3]); - + ////// games that can be forced (always need alt dol) - //Boogie + //Boogie if (strcmp(id,"RBOP69") == 0) return 675;//previous value was 657 if (strcmp(id,"RBOE69") == 0) return 675;//starstremr - + //Fifa 08 if (strcmp(id,"RF8E69") == 0) return 439;//from isostar if (strcmp(id,"RF8P69") == 0) return 463;//from isostar if (strcmp(id,"RF8X69") == 0) return 464;//from isostar - + //Madden NFL07 if (strcmp(id,"RMDP69") == 0) return 39;//from isostar - + //Madden NFL08 if (strcmp(id,"RNFP69") == 0) return 1079;//from isostar - + //Medal of Honor: Heroes 2 if (strcmp(id,"RM2X69") == 0)return 601;//dj_skual if (strcmp(id,"RM2P69") == 0)return 517;//MZottel - if (strcmp(id,"RM2E69") == 0) return 492;//Old8oy - + if (strcmp(id,"RM2E69") == 0) return 492;//Old8oy + //Mortal Kombat if (strcmp(id,"RKMP5D") == 0) return 290;//from isostar if (strcmp(id,"RKME5D") == 0) return 290;//starstremr @@ -273,7 +273,7 @@ int autoSelectDol(const char *id, bool force) { //Pangya! Golf with Style if (strcmp(id,"RPYP9B") == 0) return 12490;//from isostar - + //Redsteel if (strcmp(id,"REDP41") == 0) return 1957;//from isostar if (strcmp(id,"REDE41") == 0) return 1957;//starstremr @@ -281,37 +281,37 @@ int autoSelectDol(const char *id, bool force) { //SSX if (strcmp(id,"RSXP69") == 0) return 377;//previous value was 337 if (strcmp(id,"RSXE69") == 0) return 377;//previous value was 337 - + //Wii Sports Resort, needs alt dol one time only, to show the Motion Plus video //if (strcmp(id,"RZTP01") == 0 && CheckForSave(id4)==0) return 952;//from isostar //if (strcmp(id,"RZTE01") == 0 && CheckForSave(id4)==0) return 674;//from starstremr //as well as Grand Slam Tennis, Tiger Woods 10, Virtual Tennis 2009 - + ///// games that can't be forced (alt dol is not always needed) if (!force) { - + //Grand Slam Tennis if (strcmp(id,"R5TP69") == 0) return 1493;//from isostar if (strcmp(id,"R5TE69") == 0) return 1493;//starstremr - + //Medal of Honor Heroes if (strcmp(id,"RMZX69") == 0) return 492;//from isostar if (strcmp(id,"RMZP69") == 0) return 492;//from isostar - if (strcmp(id,"RMZE69") == 0) return 492;//starstremr - + if (strcmp(id,"RMZE69") == 0) return 492;//starstremr + //Tiger Woods 10 if (strcmp(id,"R9OP69") == 0) return 1991;//from isostar if (strcmp(id,"R9OE69") == 0) return 1973;//starstremr - + //Virtual Tennis 2009 if (strcmp(id,"RVUP8P") == 0) return 16426;//from isostar if (strcmp(id,"RVUE8P") == 0) return 16405;//from isostar - + //Wii Sports Resort if (strcmp(id,"RZTP01") == 0) return 952;//from isostar if (strcmp(id,"RZTE01") == 0) return 674;//from starstremr } - + return -1; } @@ -320,7 +320,7 @@ int autoSelectDolMenu(const char *id, bool force) { /* char id4[10]; sprintf(id4,"%c%c%c%c",id[0],id[1],id[2],id[3]); - + switch (CheckForSave(id4)) { case 0: WindowPrompt(tr("NO save"),0,tr("OK")); @@ -336,7 +336,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return -1; */ - + //Indiana Jones and the Staff of Kings (Fate of Atlantis) if (strcmp(id,"RJ8E64") == 0) { int choice = WindowPrompt(tr("Select a DOL"), 0, "Fate of Atlantis", tr("Default")); @@ -362,7 +362,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return choice; } - + //Metal Slug Anthology (Metal Slug 6) if (strcmp(id,"RMLEH4") == 0) { int choice = WindowPrompt(tr("Select a DOL"), 0, "Metal Slug 6", tr("Default")); @@ -388,7 +388,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return choice; } - + //Metroid Prime Trilogy if (strcmp(id,"R3ME01") == 0) { //do not use any alt dol if there is no save game in the nand @@ -439,7 +439,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return choice; } - + //Rampage: Total Destruction (M1.dol=Rampage, jarvos.dol=Rampage World Tour) if (strcmp(id,"RPGP5D") == 0) { int choice = WindowPrompt(tr("Select a DOL"), 0, "Rampage", "World Tour", tr("Default")); @@ -456,7 +456,7 @@ int autoSelectDolMenu(const char *id, bool force) { } return choice; } - + //The House Of The Dead 2 & 3 Return (only to play 2) if (strcmp(id,"RHDE8P") == 0) { int choice = WindowPrompt(tr("Select a DOL"), 0, "HotD 2", tr("Default")); @@ -501,7 +501,7 @@ void __dvd_readidcb(s32 result) u8 DiscMount(discHdr *header) { int ret; HaltGui(); - + u8 *tmpBuff = (u8 *) malloc(0x60); memcpy(tmpBuff, g_diskID, 0x60); // Make a backup of the first 96 bytes at 0x80000000 @@ -509,7 +509,7 @@ u8 DiscMount(discHdr *header) { dvddone = 0; ret = bwDVD_LowReset(__dvd_readidcb); while(ret>=0 && dvddone==0); - + dvddone = 0; ret = bwDVD_LowReadID(g_diskID, __dvd_readidcb); // Leave this one here, or you'll get an IOCTL error while(ret>=0 && dvddone==0); @@ -517,12 +517,12 @@ u8 DiscMount(discHdr *header) { dvddone = 0; ret = bwDVD_LowUnencryptedRead(g_diskID, 0x60, 0x00, __dvd_readidcb); // Overwrite the g_diskID thing while(ret>=0 && dvddone==0); - + memcpy(header, g_diskID, 0x60); memcpy(g_diskID, tmpBuff, 0x60); // Put the backup back, or games won't load free(tmpBuff); - + ResumeGui(); if (dvddone != 1) { return 0; diff --git a/source/prompts/ProgressWindow.cpp b/source/prompts/ProgressWindow.cpp index 344ea443..dcf63c7f 100644 --- a/source/prompts/ProgressWindow.cpp +++ b/source/prompts/ProgressWindow.cpp @@ -30,7 +30,6 @@ 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; @@ -53,13 +52,8 @@ static void GameInstallProgress() { if (gameinstalltotal <= 0) return; - int oldinstalldone = gameinstalldone; - GetProgressValue(&gameinstalldone, &gameinstalltotal); - if((oldinstalldone == gameinstalldone) && (gameinstalldone > 0)) - return; - if (gameinstalldone > gameinstalltotal) gameinstalldone = gameinstalltotal; @@ -95,7 +89,6 @@ static void GameInstallProgress() { snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%.2fGB/%.2fGB", gamesize * gameinstalldone/gameinstalltotal, gamesize); snprintf(progressSpeed, sizeof(progressSpeed), "%.1fMB/s", speed); - changed = true; } /**************************************************************************** @@ -172,12 +165,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, DOTTED); + msg1Txt.SetMaxWidth(430, GuiText::DOTTED); GuiText msg2Txt(msg2, 22, THEME.prompttext ); msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); msg2Txt.SetPosition(0,125); - msg2Txt.SetMaxWidth(430, DOTTED); + msg2Txt.SetMaxWidth(430, GuiText::DOTTED); GuiText prsTxt("%", 22, THEME.prompttext); prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); @@ -205,8 +198,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, DOTTED); - msg2Txt.SetMaxWidth(380, DOTTED); + msg1Txt.SetMaxWidth(380, GuiText::DOTTED); + msg2Txt.SetMaxWidth(380, GuiText::DOTTED); timeTxt.SetPosition(250,-50); timeTxt.SetFontSize(20); @@ -253,33 +246,28 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2 while (showProgress) { VIDEO_WaitVSync (); + usleep(20000); GameInstallProgress(); + tmp = static_cast(progressbarImg.GetWidth()*progressDone); - if(changed) - { - changed = false; + if (CFG.widescreen && Settings.wsprompt == yes) + progressbarImg.SetSkew(0,0,static_cast(progressbarImg.GetWidth()*progressDone*0.8)-progressbarImg.GetWidth(),0,static_cast(progressbarImg.GetWidth()*progressDone*0.8)-progressbarImg.GetWidth(),0,0,0); + else + progressbarImg.SetSkew(0,0,static_cast(progressbarImg.GetWidth()*progressDone)-progressbarImg.GetWidth(),0,static_cast(progressbarImg.GetWidth()*progressDone)-progressbarImg.GetWidth(),0,0,0); - tmp = static_cast(progressbarImg.GetWidth()*progressDone); + prTxt.SetTextf("%.2f", progressDone); - if (CFG.widescreen && Settings.wsprompt == yes) - progressbarImg.SetSkew(0,0,static_cast(progressbarImg.GetWidth()*progressDone*0.8)-progressbarImg.GetWidth(),0,static_cast(progressbarImg.GetWidth()*progressDone*0.8)-progressbarImg.GetWidth(),0,0,0); - else - progressbarImg.SetSkew(0,0,static_cast(progressbarImg.GetWidth()*progressDone)-progressbarImg.GetWidth(),0,static_cast(progressbarImg.GetWidth()*progressDone)-progressbarImg.GetWidth(),0,0,0); - - prTxt.SetTextf("%.2f", progressDone); - - if (showSize) { - sizeTxt.SetText(progressSizeLeft); - speedTxt.SetText(progressSpeed); - } - - if (showTime) - timeTxt.SetText(progressTime); - - if (msg2) - msg2Txt.SetText(dyn_message); + if (showSize) { + sizeTxt.SetText(progressSizeLeft); + speedTxt.SetText(progressSpeed); } + + if (showTime) + timeTxt.SetText(progressTime); + + if (msg2) + msg2Txt.SetText(dyn_message); } promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); @@ -386,7 +374,6 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done, showProgress = 1; progressDone = 100.0*done/total; - changed = true; LWP_ResumeThread(progressthread); } @@ -397,7 +384,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, 80); + LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 0); } /**************************************************************************** diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index 7fa8ffa5..84f495f5 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -216,7 +216,7 @@ void WindowCredits() { i++; y+=28; - txt[i]->SetPresets(22, (GXColor) {255, 255, 255, 255}, WRAP, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, ALIGN_LEFT, ALIGN_TOP); + GuiText::SetPresets(22, (GXColor) {255, 255, 255, 255}, 0, GuiText::WRAP,FTGX_JUSTIFY_LEFT | FTGX_ALIGN_TOP, ALIGN_LEFT, ALIGN_TOP); txt[i] = new GuiText(tr("Coding:")); txt[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP); @@ -916,7 +916,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, StopGX(); WII_Initialize(); WII_BootHBC(); - + } choice = 2; } @@ -1002,7 +1002,7 @@ void SetFavoriteImages(GuiImage *b1, GuiImage *b2, GuiImage *b3, GuiImage *b4, G b3->SetImage(favoritevar >= 3 ? on : off); b4->SetImage(favoritevar >= 4 ? on : off); b5->SetImage(favoritevar >= 5 ? on : off); -} +} /**************************************************************************** * GameWindowPrompt @@ -1063,7 +1063,7 @@ int GameWindowPrompt() { GuiText nameTxt("", 22, THEME.prompttext); if (Settings.wsprompt == yes) nameTxt.SetWidescreen(CFG.widescreen); - nameTxt.SetMaxWidth(350, SCROLL_HORIZONTAL); + nameTxt.SetMaxWidth(350, GuiText::SCROLL); GuiButton nameBtn(120,50); nameBtn.SetLabel(&nameTxt); // nameBtn.SetLabelOver(&nameTxt); @@ -1227,8 +1227,8 @@ int GameWindowPrompt() { if (diskCover) delete diskCover; - - + + snprintf(imgPath,sizeof(imgPath),"%s%s.png", Settings.disc_path, IDFull); //changed to current full id diskCover = new GuiImageData(imgPath,0); @@ -1299,13 +1299,13 @@ int GameWindowPrompt() { nameTxt.SetEffect(EFFECT_FADE, 17); } else diskImg.SetImage(diskCover); - + if (!mountMethod) { WBFS_GameSize(header->id, &size); sizeTxt.SetTextf("%.2fGB", size); //set size text; } - + nameTxt.SetText(get_title(header)); struct Game_NUM* game_num = CFG_get_game_num(header->id); @@ -1721,7 +1721,7 @@ FormatingPartition(const char *title, partitionEntry *entry) { * SearchMissingImages ***************************************************************************/ bool SearchMissingImages(int choice2) { - + GuiWindow promptWindow(472,320); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetPosition(0, -10); @@ -1762,14 +1762,14 @@ bool SearchMissingImages(int choice2) { mainWindow->Append(&promptWindow); mainWindow->ChangeFocus(&promptWindow); ResumeGui(); - + //make sure that all games are added to the gamelist __Menu_GetEntries(1); cntMissFiles = 0; u32 i = 0; char filename[11]; - + //add IDs of games that are missing covers to cntMissFiles bool found1 = false; bool found2 = false; @@ -1777,7 +1777,7 @@ bool SearchMissingImages(int choice2) { for (i = 0; i < gameCnt && cntMissFiles < 500; i++) { struct discHdr* header = &gameList[i]; if (choice2 != 3) { - + char *covers_path = choice2==1 ? Settings.covers2d_path : Settings.covers_path; snprintf (filename,sizeof(filename),"%c%c%c.png", header->id[0], header->id[1], header->id[2]); @@ -1809,7 +1809,7 @@ bool SearchMissingImages(int choice2) { msgTxt.SetText(tr("No file missing!")); sleep(1); } - + promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); while (promptWindow.GetEffect() > 0) usleep(50); @@ -1818,8 +1818,8 @@ bool SearchMissingImages(int choice2) { mainWindow->SetState(STATE_DEFAULT); __Menu_GetEntries(); ResumeGui(); - - if (cntMissFiles > 0) { + + if (cntMissFiles > 0) { //&& !IsNetworkInit()) { NetworkInitPrompt(); } @@ -2327,7 +2327,7 @@ ProgressDownloadWindow(int choice2) { } /**Temporary redownloading 1st image because of a fucking corruption bug **/ -#if 0 // is no longer necessary, since libfat is fixed +#if 0 // is no longer necessary, since libfat is fixed char URLFile[100]; struct block file = downloadfile(URLFile); if (choice2 == 2) { @@ -2894,7 +2894,7 @@ int ProgressUpdateWindow() { titleTxt.SetTextf("%s USB Loader GX", tr("Updating")); msgTxt.SetPosition(0,100); msgTxt.SetTextf("%s", tr("Updating WiiTDB.zip")); - + char wiitdbpath[200]; char wiitdbpathtmp[200]; struct block file = downloadfile(XMLurl); @@ -2915,7 +2915,7 @@ int ProgressUpdateWindow() { OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true); // open file, reload titles, keep in memory } } - + msgTxt.SetTextf("%s", tr("Updating Language Files:")); updateLanguageFiles(); promptWindow.Append(&progressbarEmptyImg); @@ -3296,7 +3296,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, SCROLL_HORIZONTAL); + nameTxt.SetMaxWidth(430, GuiText::SCROLL); if (strcmp(coder,"")) @@ -3321,16 +3321,11 @@ 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, LONGTEXT); - long_descriptionTxt.SetLinesToDraw(pagesize); - long_descriptionTxt.SetFirstLine(currentLine); - - int TotalLines = long_descriptionTxt.GetTotalLines(); + long_descriptionTxt.SetMaxWidth(360); + long_descriptionTxt.SetNumLines(pagesize); //convert filesize from u64 to char and put unit of measurement after it char temp2[7]; @@ -3422,24 +3417,18 @@ 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) ) { - currentLine--; - if(currentLine+pagesize > TotalLines) - currentLine = TotalLines-pagesize; - if(currentLine < 0) - currentLine = 0; - - long_descriptionTxt.SetFirstLine(currentLine); + if (long_descriptionTxt.GetFirstLine()>1) + long_descriptionTxt.SetFirstLine(long_descriptionTxt.GetFirstLine()-1); usleep(60000); if (!((ButtonsHold() & WPAD_BUTTON_UP)||(ButtonsHold() & PAD_BUTTON_UP))) arrowUpBtn.ResetState(); - } else if (arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD) { - currentLine++; - if(currentLine+pagesize > TotalLines) - currentLine = TotalLines-pagesize; - if(currentLine < 0) - currentLine = 0; + } else if ((arrowDownBtn.GetState()==STATE_CLICKED||arrowDownBtn.GetState()==STATE_HELD) + &&long_descriptionTxt.GetTotalLines()>pagesize + &&long_descriptionTxt.GetFirstLine()-1name, "stdnull")) + if(strcmp(devoptab_list[i]->name, "stdnull")) { snprintf(rootdir, sizeof(rootdir) , "%s:/", devoptab_list[i]->name); if(DIR_ITER *dir = diropen(rootdir)) @@ -195,7 +195,7 @@ int ParseDirectory(const char* Path, int Flags, FILTERCASCADE *Filter) { return -1; } if(getcwd(fulldir, sizeof(fulldir))) return -1; // gets the concatenated current working dir - chdir(filename); // restore the saved cwd + chdir(filename); // restore the saved cwd } } for(i=0; idir, &fulldir[strlen(browser->rootdir)]); } else if(Flags & FB_TRYSTDDEV) - { - curDevice = 0; + { + curDevice = 0; browser = &browsers[curDevice]; // when no browser was found and browser->dir[0] = 0; // we alowed try StdDevice and try RootDir strlcpy(fulldir, browser->rootdir, sizeof(fulldir)); // set the first browser with root-dir @@ -315,7 +315,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*= folderBtn.SetImage(&folderImg); folderBtn.SetTrigger(&trigA); folderBtn.SetEffectGrow(); - + char imgPath[100]; snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); GuiImageData btnOutline(imgPath, button_dialogue_box_png); @@ -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, SCROLL_HORIZONTAL); + AdressText.SetMaxWidth(Address.GetWidth()-40, GuiText::SCROLL); GuiImage AdressbarImg(&Address); GuiButton Adressbar(Address.GetWidth(), Address.GetHeight()); Adressbar.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); @@ -422,11 +422,11 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*= else if (strcmp(browser->browserList[clickedIndex].filename,".")) { /* test new directory namelength */ - if ((strlen(browser->dir) + strlen(browser->browserList[clickedIndex].filename) + if ((strlen(browser->dir) + strlen(browser->browserList[clickedIndex].filename) + 1/*'/'*/) < MAXPATHLEN) { /* update current directory name */ - sprintf(browser->dir, "%s%s/",browser->dir, + sprintf(browser->dir, "%s%s/",browser->dir, browser->browserList[clickedIndex].filename); pathCanged = true; } @@ -484,7 +484,7 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*= char oldfolder[100]; snprintf(newfolder, sizeof(newfolder), "%s%s", browser->rootdir, browser->dir); strcpy(oldfolder,newfolder); - + int result = OnScreenKeyboard(newfolder, sizeof(newfolder), strlen(browser->rootdir)); if ( result == 1 ) { unsigned int len = strlen(newfolder); diff --git a/source/prompts/gameinfo.cpp b/source/prompts/gameinfo.cpp index 3a1c416e..cc9e734b 100644 --- a/source/prompts/gameinfo.cpp +++ b/source/prompts/gameinfo.cpp @@ -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, SCROLL_HORIZONTAL); + titleTxt->SetMaxWidth(350, GuiText::SCROLL); //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, WRAP); + publisherTxt->SetMaxWidth(250,GuiText::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, WRAP); + developerTxt->SetMaxWidth(250,GuiText::WRAP); developerTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); developerTxt->SetPosition(-17,12+indexy); indexy+=(20 * newline); @@ -721,17 +721,14 @@ 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, LONGTEXT); + synopsisTxt->SetMaxWidth(350,GuiText::WRAP); synopsisTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); synopsisTxt->SetPosition(0,0); - synopsisTxt->SetLinesToDraw(pagesize); - synopsisTxt->SetFirstLine(0); - TotalLines = synopsisTxt->GetTotalLines(); + synopsisTxt->SetNumLines(pagesize); + //synopsisTxt->SetFirstLine(12); dialogBoxImg11 = new GuiImage(&dialogBox1); dialogBoxImg11->SetAlignment(0,3); @@ -852,24 +849,23 @@ int showGameInfo(char *ID) { } } else if ((upBtn.GetState()==STATE_CLICKED||upBtn.GetState()==STATE_HELD) && page==2) { - currentLine--; - if(currentLine+pagesize > TotalLines) - currentLine = TotalLines-pagesize; - if(currentLine < 0) - currentLine = 0; - - synopsisTxt->SetFirstLine(currentLine); - usleep(60000); + //int l=synopsisTxt->GetFirstLine()-1; + if (synopsisTxt->GetFirstLine()>1) + synopsisTxt->SetFirstLine(synopsisTxt->GetFirstLine()-1); + 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) { - currentLine++; - if(currentLine+pagesize > TotalLines) - currentLine = TotalLines-pagesize; - if(currentLine < 0) - currentLine = 0; + } else if ((dnBtn.GetState()==STATE_CLICKED||dnBtn.GetState()==STATE_HELD) && page==2 + &&synopsisTxt->GetTotalLines()>pagesize + &&synopsisTxt->GetFirstLine()-1GetTotalLines()-pagesize) { + int l=0; + //if(synopsisTxt->GetTotalLines()>pagesize) + l=synopsisTxt->GetFirstLine()+1; - synopsisTxt->SetFirstLine(currentLine); + //if (l>(synopsisTxt->GetTotalLines()+1)-pagesize) + //l=(synopsisTxt->GetTotalLines()+1)-pagesize; + + synopsisTxt->SetFirstLine(l); usleep(60000); if (!((ButtonsHold() & WPAD_BUTTON_DOWN)||(ButtonsHold() & PAD_BUTTON_DOWN))) dnBtn.ResetState(); diff --git a/source/settings/Settings.cpp b/source/settings/Settings.cpp index 6fcd66cd..d650fb04 100644 --- a/source/settings/Settings.cpp +++ b/source/settings/Settings.cpp @@ -23,7 +23,7 @@ /*** Extern functions ***/ extern void ResumeGui(); extern void HaltGui(); -extern bool +extern bool Database(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool keepopen); extern void titles_default(); @@ -251,7 +251,6 @@ int MenuSettings() { int pageToDisplay = 1; while ( pageToDisplay > 0) { //set pageToDisplay to 0 to quit - VIDEO_WaitVSync (); menu = MENU_NONE; @@ -493,7 +492,6 @@ int MenuSettings() { while (optionBrowser2.GetEffect() > 0) usleep(50); int returnhere = 1; - bool firstRun = true; char * languagefile; languagefile = strrchr(Settings.language_path, '/')+1; @@ -502,13 +500,93 @@ int MenuSettings() { returnhere = 1; + if (Settings.sinfo >= settings_sinfo_max) + Settings.sinfo = 0; + if (Settings.hddinfo >= settings_clock_max) + Settings.hddinfo = 0; //CLOCK + if (Settings.tooltips >= settings_tooltips_max) + Settings.tooltips = 0; + if ( Settings.xflip >= settings_xflip_max) + Settings.xflip = 0; + if ( Settings.wsprompt > 1 ) + Settings.wsprompt = 0; + if ( Settings.keyset >= settings_keyset_max) + Settings.keyset = 0; + if ( Settings.wiilight > 2 ) + Settings.wiilight = 0; + if (Settings.rumble >= settings_rumble_max) + Settings.rumble = 0; //RUMBLE + if (Settings.screensaver >= settings_screensaver_max) + Settings.screensaver = 0; //RUMBLE + if (Settings.titlesOverride >= 2) + Settings.titlesOverride = 0; + if (Settings.discart >= 4) + Settings.discart = 0; + if (!strcmp("notset", Settings.language_path)) + options2.SetValue(0, "%s", tr("Default")); + else + options2.SetValue(0, "%s", languagefile); + + if (Settings.sinfo == GameID) options2.SetValue(1,"%s",tr("Game ID")); + else if (Settings.sinfo == GameRegion) options2.SetValue(1,"%s",tr("Game Region")); + else if (Settings.sinfo == Both) options2.SetValue(1,"%s",tr("Both")); + else if (Settings.sinfo == Neither) options2.SetValue(1,"%s",tr("Neither")); + + if (Settings.hddinfo == hr12) options2.SetValue(2,"12 %s",tr("Hour")); + else if (Settings.hddinfo == hr24) options2.SetValue(2,"24 %s",tr("Hour")); + else if (Settings.hddinfo == Off) options2.SetValue(2,"%s",tr("OFF")); + + if (Settings.tooltips == TooltipsOn) options2.SetValue(3,"%s",tr("ON")); + else if (Settings.tooltips == TooltipsOff) options2.SetValue(3,"%s",tr("OFF")); + + if (Settings.xflip == no) options2.SetValue(4,"%s/%s",tr("Right"),tr("Next")); + else if (Settings.xflip == yes) options2.SetValue(4,"%s/%s",tr("Left"),tr("Prev")); + else if (Settings.xflip == sysmenu) options2.SetValue(4,"%s", tr("Like SysMenu")); + else if (Settings.xflip == wtf) options2.SetValue(4,"%s/%s",tr("Right"),tr("Prev")); + else if (Settings.xflip == disk3d) options2.SetValue(4,tr("DiskFlip")); + + if (Settings.wsprompt == no) options2.SetValue(5,"%s",tr("Normal")); + else if (Settings.wsprompt == yes) options2.SetValue(5,"%s",tr("Widescreen Fix")); + + if (Settings.keyset == us) options2.SetValue(6,"QWERTY"); + else if (Settings.keyset == qwerty) options2.SetValue(6,"QWERTY 2"); + else if (Settings.keyset == dvorak) options2.SetValue(6,"DVORAK"); + else if (Settings.keyset == euro) options2.SetValue(6,"QWERTZ"); + else if (Settings.keyset == azerty) options2.SetValue(6,"AZERTY"); + + if (Settings.discart == 0) options2.SetValue(7,"%s",tr("Only Original")); + else if (Settings.discart == 1) options2.SetValue(7,tr("Only Customs")); + else if (Settings.discart == 2) options2.SetValue(7,tr("Original/Customs")); + else if (Settings.discart == 3) options2.SetValue(7,tr("Customs/Original")); + + if (Settings.wiilight == 0) options2.SetValue(8,"%s",tr("OFF")); + else if (Settings.wiilight == 1) options2.SetValue(8,"%s",tr("ON")); + else if (Settings.wiilight == 2) options2.SetValue(8,"%s",tr("Only for Install")); + + if (Settings.rumble == RumbleOn) options2.SetValue(9,"%s",tr("ON")); + else if (Settings.rumble == RumbleOff) options2.SetValue(9,"%s",tr("OFF")); + + if (Settings.autonetwork == on) options2.SetValue(10,"%s",tr("ON")); + else if (Settings.autonetwork == off) options2.SetValue(10,"%s",tr("OFF")); + + if (Settings.titlesOverride == 0) options2.SetValue(11,"%s",tr("OFF")); + else if (Settings.titlesOverride == 1) options2.SetValue(11,"%s",tr("ON")); + + if (Settings.screensaver == 0) options2.SetValue(12,"%s",tr("OFF")); + else if (Settings.screensaver == 1) options2.SetValue(12,tr("3 min")); + else if (Settings.screensaver == 2) options2.SetValue(12,tr("5 min")); + else if (Settings.screensaver == 3) options2.SetValue(12,tr("10 min")); + else if (Settings.screensaver == 4) options2.SetValue(12,tr("20 min")); + else if (Settings.screensaver == 5) options2.SetValue(12,tr("30 min")); + else if (Settings.screensaver == 6) options2.SetValue(12,tr("1 hour")); + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; break; } - else if (shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); else if (reset == 1) Sys_Reboot(); @@ -544,159 +622,74 @@ int MenuSettings() { ret = optionBrowser2.GetClickedOption(); - if(firstRun || ret >= 0) - { - firstRun = false; - - switch (ret) - { - case 0: - if (isInserted(bootDevice)) { - if ( Settings.godmode == 1) { - w.SetEffect(EFFECT_FADE, -20); - while (w.GetEffect()>0) usleep(50); - mainWindow->Remove(&w); - while (returnhere == 1) - returnhere = MenuLanguageSelect(); - if (returnhere == 2) { - menu = MENU_SETTINGS; - pageToDisplay = 0; - exit = true; - mainWindow->Append(&w); - break; - } else { - HaltGui(); - mainWindow->Append(&w); - w.SetEffect(EFFECT_FADE, 20); - ResumeGui(); - while (w.GetEffect()>0) usleep(50); - } - } else { - WindowPrompt(tr("Language change:"),tr("Console should be unlocked to modify it."),tr("OK")); - } + switch (ret) { + case 0: + if (isInserted(bootDevice)) { + if ( Settings.godmode == 1) { + w.SetEffect(EFFECT_FADE, -20); + while (w.GetEffect()>0) usleep(50); + mainWindow->Remove(&w); + while (returnhere == 1) + returnhere = MenuLanguageSelect(); + if (returnhere == 2) { + menu = MENU_SETTINGS; + pageToDisplay = 0; + exit = true; + mainWindow->Append(&w); + break; } else { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to use this option."), tr("OK")); + HaltGui(); + mainWindow->Append(&w); + w.SetEffect(EFFECT_FADE, 20); + ResumeGui(); + while (w.GetEffect()>0) usleep(50); } - break; - case 1: - Settings.sinfo++; - if (Settings.sinfo >= settings_sinfo_max) - Settings.sinfo = 0; - break; - case 2: - Settings.hddinfo++; - if (Settings.hddinfo >= settings_clock_max) - Settings.hddinfo = 0; //CLOCK - break; - case 3: - Settings.tooltips++; - if (Settings.tooltips >= settings_tooltips_max) - Settings.tooltips = 0; - break; - case 4: - Settings.xflip++; - if ( Settings.xflip >= settings_xflip_max) - Settings.xflip = 0; - break; - case 5: - Settings.wsprompt++; - if ( Settings.wsprompt > 1 ) - Settings.wsprompt = 0; - break; - case 6: - Settings.keyset++; - if ( Settings.keyset >= settings_keyset_max) - Settings.keyset = 0; - break; - case 7: - Settings.discart++; - if (Settings.discart >= 4) - Settings.discart = 0; - break; - case 8: - Settings.wiilight++; - if ( Settings.wiilight > 2 ) - Settings.wiilight = 0; - break; - case 9: - Settings.rumble++; - if (Settings.rumble >= settings_rumble_max) - Settings.rumble = 0; //RUMBLE - break; - case 10: - Settings.autonetwork++; - if (Settings.autonetwork > 1) - Settings.autonetwork = 0; - break; - case 11: - Settings.titlesOverride++; - if (Settings.titlesOverride >= 2) - Settings.titlesOverride = 0; - break; - case 12: - Settings.screensaver++; - if (Settings.screensaver >= settings_screensaver_max) - Settings.screensaver = 0; //RUMBLE - break; + } else { + WindowPrompt(tr("Language change:"),tr("Console should be unlocked to modify it."),tr("OK")); + } + } else { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to use this option."), tr("OK")); } + break; + case 1: + Settings.sinfo++; + break; + case 2: + Settings.hddinfo++; + break; + case 3: + Settings.tooltips++; + break; + case 4: + Settings.xflip++; + break; + case 5: + Settings.wsprompt++; + break; + case 6: + Settings.keyset++; + break; + case 7: + Settings.discart++; + break; + case 8: + Settings.wiilight++; + break; + case 9: + Settings.rumble++; + break; + case 10: + Settings.autonetwork++; + if (Settings.autonetwork > 1) + Settings.autonetwork = 0; + break; + case 11: + Settings.titlesOverride++; + break; + case 12: + Settings.screensaver++; + break; - if (!strcmp("notset", Settings.language_path)) - options2.SetValue(0, "%s", tr("Default")); - else - options2.SetValue(0, "%s", languagefile); - - if (Settings.sinfo == GameID) options2.SetValue(1,"%s",tr("Game ID")); - else if (Settings.sinfo == GameRegion) options2.SetValue(1,"%s",tr("Game Region")); - else if (Settings.sinfo == Both) options2.SetValue(1,"%s",tr("Both")); - else if (Settings.sinfo == Neither) options2.SetValue(1,"%s",tr("Neither")); - - if (Settings.hddinfo == hr12) options2.SetValue(2,"12 %s",tr("Hour")); - else if (Settings.hddinfo == hr24) options2.SetValue(2,"24 %s",tr("Hour")); - else if (Settings.hddinfo == Off) options2.SetValue(2,"%s",tr("OFF")); - - if (Settings.tooltips == TooltipsOn) options2.SetValue(3,"%s",tr("ON")); - else if (Settings.tooltips == TooltipsOff) options2.SetValue(3,"%s",tr("OFF")); - - if (Settings.xflip == no) options2.SetValue(4,"%s/%s",tr("Right"),tr("Next")); - else if (Settings.xflip == yes) options2.SetValue(4,"%s/%s",tr("Left"),tr("Prev")); - else if (Settings.xflip == sysmenu) options2.SetValue(4,"%s", tr("Like SysMenu")); - else if (Settings.xflip == wtf) options2.SetValue(4,"%s/%s",tr("Right"),tr("Prev")); - else if (Settings.xflip == disk3d) options2.SetValue(4,tr("DiskFlip")); - - if (Settings.wsprompt == no) options2.SetValue(5,"%s",tr("Normal")); - else if (Settings.wsprompt == yes) options2.SetValue(5,"%s",tr("Widescreen Fix")); - - if (Settings.keyset == us) options2.SetValue(6,"QWERTY"); - else if (Settings.keyset == qwerty) options2.SetValue(6,"QWERTY 2"); - else if (Settings.keyset == dvorak) options2.SetValue(6,"DVORAK"); - else if (Settings.keyset == euro) options2.SetValue(6,"QWERTZ"); - else if (Settings.keyset == azerty) options2.SetValue(6,"AZERTY"); - - if (Settings.discart == 0) options2.SetValue(7,"%s",tr("Only Original")); - else if (Settings.discart == 1) options2.SetValue(7,tr("Only Customs")); - else if (Settings.discart == 2) options2.SetValue(7,tr("Original/Customs")); - else if (Settings.discart == 3) options2.SetValue(7,tr("Customs/Original")); - - if (Settings.wiilight == 0) options2.SetValue(8,"%s",tr("OFF")); - else if (Settings.wiilight == 1) options2.SetValue(8,"%s",tr("ON")); - else if (Settings.wiilight == 2) options2.SetValue(8,"%s",tr("Only for Install")); - - if (Settings.rumble == RumbleOn) options2.SetValue(9,"%s",tr("ON")); - else if (Settings.rumble == RumbleOff) options2.SetValue(9,"%s",tr("OFF")); - - if (Settings.autonetwork == on) options2.SetValue(10,"%s",tr("ON")); - else if (Settings.autonetwork == off) options2.SetValue(10,"%s",tr("OFF")); - - if (Settings.titlesOverride == 0) options2.SetValue(11,"%s",tr("OFF")); - else if (Settings.titlesOverride == 1) options2.SetValue(11,"%s",tr("ON")); - - if (Settings.screensaver == 0) options2.SetValue(12,"%s",tr("OFF")); - else if (Settings.screensaver == 1) options2.SetValue(12,tr("3 min")); - else if (Settings.screensaver == 2) options2.SetValue(12,tr("5 min")); - else if (Settings.screensaver == 3) options2.SetValue(12,tr("10 min")); - else if (Settings.screensaver == 4) options2.SetValue(12,tr("20 min")); - else if (Settings.screensaver == 5) options2.SetValue(12,tr("30 min")); - else if (Settings.screensaver == 6) options2.SetValue(12,tr("1 hour")); } } optionBrowser2.SetEffect(EFFECT_FADE, -20); @@ -741,15 +734,67 @@ int MenuSettings() { optionBrowser2.SetClickable(true); ResumeGui(); - bool firstRun = true; - VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); while (optionBrowser2.GetEffect() > 0) usleep(50); - while (!exit) - { + while (!exit) { VIDEO_WaitVSync (); + if (Settings.video >= settings_video_max) + Settings.video = 0; + if (Settings.vpatch >= settings_off_on_max) + Settings.vpatch = 0; + if ( Settings.patchcountrystrings > 1) + Settings.patchcountrystrings = 0; + if (Settings.ocarina >= settings_off_on_max) + Settings.ocarina = 0; + if ( Settings.qboot > 1 ) + Settings.qboot = 0; + if ( Settings.cios >= settings_cios_max) + Settings.cios = 0; + if ( Settings.language >= settings_language_max) + Settings.language = 0; + if (Settings.error002 >= settings_off_on_max+1) + Settings.error002 = 0; + + if (Settings.video == discdefault) options2.SetValue(0,"%s",tr("Disc Default")); + else if (Settings.video == systemdefault) options2.SetValue(0,"%s",tr("System Default")); + else if (Settings.video == patch) options2.SetValue(0,"%s",tr("AutoPatch")); + else if (Settings.video == pal50) options2.SetValue(0,"%s PAL50",tr("Force")); + else if (Settings.video == pal60) options2.SetValue(0,"%s PAL60",tr("Force")); + else if (Settings.video == ntsc) options2.SetValue(0,"%s NTSC",tr("Force")); + + if (Settings.vpatch == on) options2.SetValue(1,"%s",tr("ON")); + else if (Settings.vpatch == off) options2.SetValue(1,"%s",tr("OFF")); + + if (Settings.language == ConsoleLangDefault) options2.SetValue(2,"%s",tr("Console Default")); + else if (Settings.language == jap) options2.SetValue(2,"%s",tr("Japanese")); + else if (Settings.language == ger) options2.SetValue(2,"%s",tr("German")); + else if (Settings.language == eng) options2.SetValue(2,"%s",tr("English")); + else if (Settings.language == fren) options2.SetValue(2,"%s",tr("French")); + else if (Settings.language == esp) options2.SetValue(2,"%s",tr("Spanish")); + else if (Settings.language == it) options2.SetValue(2,"%s",tr("Italian")); + else if (Settings.language == dut) options2.SetValue(2,"%s",tr("Dutch")); + else if (Settings.language == schin) options2.SetValue(2,"%s",tr("SChinese")); + else if (Settings.language == tchin) options2.SetValue(2,"%s",tr("TChinese")); + else if (Settings.language == kor) options2.SetValue(2,"%s",tr("Korean")); + + if (Settings.patchcountrystrings == 0) options2.SetValue(3,"%s",tr("OFF")); + else if (Settings.patchcountrystrings == 1) options2.SetValue(3,"%s",tr("ON")); + + if (Settings.ocarina == on) options2.SetValue(4,"%s",tr("ON")); + else if (Settings.ocarina == off) options2.SetValue(4,"%s",tr("OFF")); + + if (Settings.godmode != 1) options2.SetValue(5, "********"); + else if (Settings.cios == ios249) options2.SetValue(5,"cIOS 249"); + else if (Settings.cios == ios222) options2.SetValue(5,"cIOS 222"); + + if (Settings.qboot == no) options2.SetValue(6,"%s",tr("No")); + else if (Settings.qboot == yes) options2.SetValue(6,"%s",tr("Yes")); + + if (Settings.error002 == no) options2.SetValue(7,"%s",tr("No")); + else if (Settings.error002 == yes) options2.SetValue(7,"%s",tr("Yes")); + else if (Settings.error002 == anti) options2.SetValue(7,"%s",tr("Anti")); if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); @@ -757,7 +802,7 @@ int MenuSettings() { break; } - else if (shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); else if (reset == 1) Sys_Reboot(); @@ -787,91 +832,33 @@ int MenuSettings() { ret = optionBrowser2.GetClickedOption(); - if(firstRun || ret >= 0) - { - firstRun = false; + switch (ret) { + case 0: + Settings.video++; + break; + case 1: + Settings.vpatch++; + break; + case 2: + Settings.language++; + break; + case 3: + Settings.patchcountrystrings++; + break; + case 4: + Settings.ocarina++; + break; + case 5: + if (Settings.godmode) + Settings.cios++; + break; + case 6: + Settings.qboot++; + break; + case 7: + Settings.error002++; + break; - switch (ret) { - case 0: - Settings.video++; - if (Settings.video >= settings_video_max) - Settings.video = 0; - break; - case 1: - Settings.vpatch++; - if (Settings.vpatch >= settings_off_on_max) - Settings.vpatch = 0; - break; - case 2: - Settings.language++; - if ( Settings.language >= settings_language_max) - Settings.language = 0; - break; - case 3: - Settings.patchcountrystrings++; - if ( Settings.patchcountrystrings > 1) - Settings.patchcountrystrings = 0; - break; - case 4: - Settings.ocarina++; - if (Settings.ocarina >= settings_off_on_max) - Settings.ocarina = 0; - break; - case 5: - if (Settings.godmode) - Settings.cios++; - break; - case 6: - Settings.qboot++; - if ( Settings.qboot > 1 ) - Settings.qboot = 0; - break; - case 7: - Settings.error002++; - if (Settings.error002 >= settings_off_on_max+1) - Settings.error002 = 0; - break; - - } - - if (Settings.video == discdefault) options2.SetValue(0,"%s",tr("Disc Default")); - else if (Settings.video == systemdefault) options2.SetValue(0,"%s",tr("System Default")); - else if (Settings.video == patch) options2.SetValue(0,"%s",tr("AutoPatch")); - else if (Settings.video == pal50) options2.SetValue(0,"%s PAL50",tr("Force")); - else if (Settings.video == pal60) options2.SetValue(0,"%s PAL60",tr("Force")); - else if (Settings.video == ntsc) options2.SetValue(0,"%s NTSC",tr("Force")); - - if (Settings.vpatch == on) options2.SetValue(1,"%s",tr("ON")); - else if (Settings.vpatch == off) options2.SetValue(1,"%s",tr("OFF")); - - if (Settings.language == ConsoleLangDefault) options2.SetValue(2,"%s",tr("Console Default")); - else if (Settings.language == jap) options2.SetValue(2,"%s",tr("Japanese")); - else if (Settings.language == ger) options2.SetValue(2,"%s",tr("German")); - else if (Settings.language == eng) options2.SetValue(2,"%s",tr("English")); - else if (Settings.language == fren) options2.SetValue(2,"%s",tr("French")); - else if (Settings.language == esp) options2.SetValue(2,"%s",tr("Spanish")); - else if (Settings.language == it) options2.SetValue(2,"%s",tr("Italian")); - else if (Settings.language == dut) options2.SetValue(2,"%s",tr("Dutch")); - else if (Settings.language == schin) options2.SetValue(2,"%s",tr("SChinese")); - else if (Settings.language == tchin) options2.SetValue(2,"%s",tr("TChinese")); - else if (Settings.language == kor) options2.SetValue(2,"%s",tr("Korean")); - - if (Settings.patchcountrystrings == 0) options2.SetValue(3,"%s",tr("OFF")); - else if (Settings.patchcountrystrings == 1) options2.SetValue(3,"%s",tr("ON")); - - if (Settings.ocarina == on) options2.SetValue(4,"%s",tr("ON")); - else if (Settings.ocarina == off) options2.SetValue(4,"%s",tr("OFF")); - - if (Settings.godmode != 1) options2.SetValue(5, "********"); - else if (Settings.cios == ios249) options2.SetValue(5,"cIOS 249"); - else if (Settings.cios == ios222) options2.SetValue(5,"cIOS 222"); - - if (Settings.qboot == no) options2.SetValue(6,"%s",tr("No")); - else if (Settings.qboot == yes) options2.SetValue(6,"%s",tr("Yes")); - - if (Settings.error002 == no) options2.SetValue(7,"%s",tr("No")); - else if (Settings.error002 == yes) options2.SetValue(7,"%s",tr("Yes")); - else if (Settings.error002 == anti) options2.SetValue(7,"%s",tr("Anti")); } } optionBrowser2.SetEffect(EFFECT_FADE, -20); @@ -910,23 +897,37 @@ int MenuSettings() { optionBrowser2.SetClickable(true); ResumeGui(); - bool firstRun = true; - VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); while (optionBrowser2.GetEffect() > 0) usleep(50); - while (!exit) - { + while (!exit) { VIDEO_WaitVSync (); + if (Settings.parentalcontrol > 4 ) + Settings.parentalcontrol = 0; + + if ( Settings.godmode == 1 ) options2.SetValue(0, tr("Unlocked")); + else if ( Settings.godmode == 0 ) options2.SetValue(0, tr("Locked")); + + if ( Settings.godmode != 1) options2.SetValue(1, "********"); + else if (!strcmp("", Settings.unlockCode)) options2.SetValue(1, "%s",tr("not set")); + else options2.SetValue(1, Settings.unlockCode); + + if (Settings.godmode != 1) options2.SetValue(2, "********"); + else if (Settings.parentalcontrol == 0) options2.SetValue(2, tr("OFF")); + else if (Settings.parentalcontrol == 1) options2.SetValue(2, tr("1 (Child 7+)")); + else if (Settings.parentalcontrol == 2) options2.SetValue(2, tr("2 (Teen 12+)")); + else if (Settings.parentalcontrol == 3) options2.SetValue(2, tr("3 (Mature 16+)")); + else if (Settings.parentalcontrol == 4) options2.SetValue(2, tr("4 (Adults Only 18+)")); + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; break; } - else if (shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); else if (reset == 1) Sys_Reboot(); @@ -956,84 +957,62 @@ int MenuSettings() { ret = optionBrowser2.GetClickedOption(); - if(firstRun || ret >= 0) - { - firstRun = false; - - switch (ret) { - case 0: - if (!strcmp("", Settings.unlockCode)) { - Settings.godmode = !Settings.godmode; - break; - } else if ( Settings.godmode == 0 ) { - //password check to unlock Install,Delete and Format - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[20] = ""; - int result = OnScreenKeyboard(entered, 20,0); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - if (!strcmp(entered, Settings.unlockCode)) { //if password correct - if (Settings.godmode == 0) { - WindowPrompt(tr("Correct Password"),tr("All the features of USB Loader GX are unlocked."),tr("OK")); - Settings.godmode = 1; - //__Menu_GetEntries(); - menu = MENU_DISCLIST; - } - } else { - WindowPrompt(tr("Wrong Password"),tr("USB Loader GX is protected"),tr("OK")); + switch (ret) { + case 0: + if (!strcmp("", Settings.unlockCode)) { + Settings.godmode = !Settings.godmode; + break; + } else if ( Settings.godmode == 0 ) { + //password check to unlock Install,Delete and Format + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[20] = ""; + int result = OnScreenKeyboard(entered, 20,0); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + if (!strcmp(entered, Settings.unlockCode)) { //if password correct + if (Settings.godmode == 0) { + WindowPrompt(tr("Correct Password"),tr("All the features of USB Loader GX are unlocked."),tr("OK")); + Settings.godmode = 1; + //__Menu_GetEntries(); + menu = MENU_DISCLIST; } - } - } else { - int choice = WindowPrompt (tr("Lock Console"),tr("Are you sure?"),tr("Yes"),tr("No")); - if (choice == 1) { - WindowPrompt(tr("Console Locked"),tr("USB Loader GX is protected"),tr("OK")); - Settings.godmode = 0; - //__Menu_GetEntries(); - menu = MENU_DISCLIST; + } else { + WindowPrompt(tr("Wrong Password"),tr("USB Loader GX is protected"),tr("OK")); } } - break; - case 1:// Modify Password - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[20] = ""; - strlcpy(entered, Settings.unlockCode, sizeof(entered)); - int result = OnScreenKeyboard(entered, 20,0); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - strlcpy(Settings.unlockCode, entered, sizeof(Settings.unlockCode)); - WindowPrompt(tr("Password Changed"),tr("Password has been changed"),tr("OK")); - } - } else { - WindowPrompt(tr("Password Changed"),tr("Console should be unlocked to modify it."),tr("OK")); + } else { + int choice = WindowPrompt (tr("Lock Console"),tr("Are you sure?"),tr("Yes"),tr("No")); + if (choice == 1) { + WindowPrompt(tr("Console Locked"),tr("USB Loader GX is protected"),tr("OK")); + Settings.godmode = 0; + //__Menu_GetEntries(); + menu = MENU_DISCLIST; } - break; - case 2: - if (Settings.godmode) - Settings.parentalcontrol++; - if (Settings.parentalcontrol > 4 ) - Settings.parentalcontrol = 0; - break; } - - - if ( Settings.godmode == 1 ) options2.SetValue(0, tr("Unlocked")); - else if ( Settings.godmode == 0 ) options2.SetValue(0, tr("Locked")); - - if ( Settings.godmode != 1) options2.SetValue(1, "********"); - else if (!strcmp("", Settings.unlockCode)) options2.SetValue(1, "%s",tr("not set")); - else options2.SetValue(1, Settings.unlockCode); - - if (Settings.godmode != 1) options2.SetValue(2, "********"); - else if (Settings.parentalcontrol == 0) options2.SetValue(2, tr("OFF")); - else if (Settings.parentalcontrol == 1) options2.SetValue(2, tr("1 (Child 7+)")); - else if (Settings.parentalcontrol == 2) options2.SetValue(2, tr("2 (Teen 12+)")); - else if (Settings.parentalcontrol == 3) options2.SetValue(2, tr("3 (Mature 16+)")); - else if (Settings.parentalcontrol == 4) options2.SetValue(2, tr("4 (Adults Only 18+)")); + break; + case 1:// Modify Password + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[20] = ""; + strlcpy(entered, Settings.unlockCode, sizeof(entered)); + int result = OnScreenKeyboard(entered, 20,0); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + strlcpy(Settings.unlockCode, entered, sizeof(Settings.unlockCode)); + WindowPrompt(tr("Password Changed"),tr("Password has been changed"),tr("OK")); + } + } else { + WindowPrompt(tr("Password Changed"),tr("Console should be unlocked to modify it."),tr("OK")); + } + break; + case 2: + if (Settings.godmode) + Settings.parentalcontrol++; + break; } } optionBrowser2.SetEffect(EFFECT_FADE, -20); @@ -1072,8 +1051,6 @@ int MenuSettings() { optionBrowser2.SetClickable(true); ResumeGui(); - bool firstRun = true; - VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); while (optionBrowser2.GetEffect() > 0) usleep(50); @@ -1086,13 +1063,29 @@ int MenuSettings() { bool returnhere = true; + if (!strcmp("notset", Settings.ogg_path)) + options2.SetValue(0, "%s", tr("Standard")); + else { + oggfile = strrchr(Settings.ogg_path, '/')+1; + options2.SetValue(0, "%s", oggfile); + } + + if (Settings.volume > 0) + options2.SetValue(1,"%i", Settings.volume); + else + options2.SetValue(1,"%s", tr("OFF")); + if (Settings.sfxvolume > 0) + options2.SetValue(2,"%i", Settings.sfxvolume); + else + options2.SetValue(2,"%s", tr("OFF")); + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; break; } - else if (shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); else if (reset == 1) Sys_Reboot(); @@ -1122,58 +1115,36 @@ int MenuSettings() { ret = optionBrowser2.GetClickedOption(); - if(firstRun || ret >= 0) - { - firstRun = false; - - switch (ret) - { - case 0: - if (isInserted(bootDevice)) { - w.SetEffect(EFFECT_FADE, -20); - while (w.GetEffect()>0) usleep(50); - mainWindow->Remove(&w); - while (returnhere) - returnhere = MenuOGG(); - HaltGui(); - mainWindow->Append(&w); - w.SetEffect(EFFECT_FADE, 20); - ResumeGui(); - while (w.GetEffect()>0) usleep(50); - } else - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to use this option."), tr("OK")); - break; - case 1: - Settings.volume += 10; - if (Settings.volume > 100) - Settings.volume = 0; - SetVolumeOgg(255*(Settings.volume/100.0)); - break; - case 2: - Settings.sfxvolume += 10; - if (Settings.sfxvolume > 100) - Settings.sfxvolume = 0; - btnSoundOver.SetVolume(Settings.sfxvolume); - btnClick.SetVolume(Settings.sfxvolume); - btnClick1.SetVolume(Settings.sfxvolume); - break; - } - - if (!strcmp("notset", Settings.ogg_path)) - options2.SetValue(0, "%s", tr("Standard")); - else { - oggfile = strrchr(Settings.ogg_path, '/')+1; - options2.SetValue(0, "%s", oggfile); - } - - if (Settings.volume > 0) - options2.SetValue(1,"%i", Settings.volume); - else - options2.SetValue(1,"%s", tr("OFF")); - if (Settings.sfxvolume > 0) - options2.SetValue(2,"%i", Settings.sfxvolume); - else - options2.SetValue(2,"%s", tr("OFF")); + switch (ret) { + case 0: + if (isInserted(bootDevice)) { + w.SetEffect(EFFECT_FADE, -20); + while (w.GetEffect()>0) usleep(50); + mainWindow->Remove(&w); + while (returnhere) + returnhere = MenuOGG(); + HaltGui(); + mainWindow->Append(&w); + w.SetEffect(EFFECT_FADE, 20); + ResumeGui(); + while (w.GetEffect()>0) usleep(50); + } else + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to use this option."), tr("OK")); + break; + case 1: + Settings.volume += 10; + if (Settings.volume > 100) + Settings.volume = 0; + SetVolumeOgg(255*(Settings.volume/100.0)); + break; + case 2: + Settings.sfxvolume += 10; + if (Settings.sfxvolume > 100) + Settings.sfxvolume = 0; + btnSoundOver.SetVolume(Settings.sfxvolume); + btnClick.SetVolume(Settings.sfxvolume); + btnClick1.SetVolume(Settings.sfxvolume); + break; } } optionBrowser2.SetEffect(EFFECT_FADE, -20); @@ -1222,8 +1193,6 @@ int MenuSettings() { optionBrowser2.SetClickable(true); ResumeGui(); - bool firstRun = true; - VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); while (optionBrowser2.GetEffect() > 0) usleep(50); @@ -1233,13 +1202,24 @@ int MenuSettings() { while (!exit) { VIDEO_WaitVSync (); + options2.SetValue(0, "%s", Settings.covers_path); + options2.SetValue(1, "%s", Settings.covers2d_path); + options2.SetValue(2, "%s", Settings.disc_path); + options2.SetValue(3, "%s", CFG.theme_path); + options2.SetValue(4, "%s", Settings.titlestxt_path); + options2.SetValue(5, "%s", Settings.update_path); + options2.SetValue(6, "%s", Settings.Cheatcodespath); + options2.SetValue(7, "%s", Settings.TxtCheatcodespath); + options2.SetValue(8, "%s", Settings.dolpath); + options2.SetValue(9, "%s", Settings.homebrewapps_path); + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; break; } - else if (shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); else if (reset == 1) Sys_Reboot(); @@ -1269,300 +1249,284 @@ int MenuSettings() { ret = optionBrowser2.GetClickedOption(); - if(firstRun || ret >= 0) - { - firstRun = false; - - switch (ret) { - case 0: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - strlcpy(entered, Settings.covers_path, sizeof(entered)); - titleTxt.SetText(tr("3D Cover Path")); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.covers_path, entered, sizeof(Settings.covers_path)); - WindowPrompt(tr("Cover Path Changed"),0,tr("OK")); - if (!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); - } + switch (ret) { + case 0: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strlcpy(entered, Settings.covers_path, sizeof(entered)); + titleTxt.SetText(tr("3D Cover Path")); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.covers_path, entered, sizeof(Settings.covers_path)); + WindowPrompt(tr("Cover Path Changed"),0,tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); } - } else { - WindowPrompt(tr("Cover Path Change"),tr("Console should be unlocked to modify it."),tr("OK")); } - break; - case 1: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - strlcpy(entered, Settings.covers2d_path, sizeof(entered)); - titleTxt.SetText(tr("2D Cover Path")); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.covers2d_path, entered, sizeof(Settings.covers2d_path)); - WindowPrompt(tr("Cover Path Changed"),0,tr("OK")); - if (!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); - } - } - } else { - WindowPrompt(tr("Cover Path Change"),tr("Console should be unlocked to modify it."),tr("OK")); - } - break; - case 2: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - strlcpy(entered, Settings.disc_path, sizeof(entered)); - titleTxt.SetText(tr("Disc Artwork Path")); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.disc_path, entered, sizeof(Settings.disc_path)); - WindowPrompt(tr("Disc Path Changed"),0,tr("OK")); - if (!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); - } - } - } else { - WindowPrompt(tr("Disc Path change"),tr("Console should be unlocked to modify it."),tr("OK")); - } - break; - case 3: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - titleTxt.SetText(tr("Theme Path")); - strlcpy(entered, CFG.theme_path, sizeof(entered)); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - HaltGui(); - w.RemoveAll(); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(CFG.theme_path, entered, sizeof(CFG.theme_path)); - WindowPrompt(tr("Theme Path Changed"),0,tr("OK")); - if (!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); - } else { - cfg_save_global(); - } - mainWindow->Remove(bgImg); - HaltGui(); - CFG_Load(); - CFG_LoadGlobal(); - ResumeGui(); - menu = MENU_SETTINGS; -#ifdef HW_RVL - snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); - pointer[0] = new GuiImageData(imgPath, player1_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); - pointer[1] = new GuiImageData(imgPath, player2_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); - pointer[2] = new GuiImageData(imgPath, player3_point_png); - snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); - pointer[3] = new GuiImageData(imgPath, player4_point_png); -#endif - if (CFG.widescreen) - snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); - else - snprintf(imgPath, sizeof(imgPath), "%sbackground.png", CFG.theme_path); - - background = new GuiImageData(imgPath, CFG.widescreen? wbackground_png : background_png); - - bgImg = new GuiImage(background); - mainWindow->Append(bgImg); - mainWindow->Append(&w); - } - w.Append(&settingsbackground); - w.Append(&titleTxt); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&backBtn); - w.Append(&optionBrowser2); - ResumeGui(); - } else { - WindowPrompt(tr("Theme Path change"),tr("Console should be unlocked to modify it."),tr("OK")); - } - break; - case 4: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - titleTxt.SetText(tr("WiiTDB Path")); - strlcpy(entered, Settings.titlestxt_path, sizeof(entered)); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - w.Append(&optionBrowser2); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.titlestxt_path, entered, sizeof(Settings.titlestxt_path)); - WindowPrompt(tr("WiiTDB Path changed."),0,tr("OK")); - if (isInserted(bootDevice)) { - cfg_save_global(); - HaltGui(); - CFG_Load(); - ResumeGui(); - } else { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); - } - } - } else { - WindowPrompt(tr("WiiTDB Path change"),tr("Console should be unlocked to modify it."),tr("OK")); - } - break; - case 5: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - strlcpy(entered, Settings.update_path, sizeof(entered)); - titleTxt.SetText(tr("Update Path")); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.update_path, entered, sizeof(Settings.update_path)); - WindowPrompt(tr("Update Path changed."),0,tr("OK")); - } - } else - WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); - break; - case 6: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - strlcpy(entered, Settings.Cheatcodespath, sizeof(entered)); - titleTxt.SetText(tr("GCT Cheatcodes Path")); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.Cheatcodespath, entered, sizeof(Settings.Cheatcodespath)); - WindowPrompt(tr("GCT Cheatcodes Path changed"),0,tr("OK")); - } - } else - WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); - break; - case 7: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - strlcpy(entered, Settings.TxtCheatcodespath, sizeof(entered)); - titleTxt.SetText(tr("TXT Cheatcodes Path")); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.TxtCheatcodespath, entered, sizeof(Settings.TxtCheatcodespath)); - WindowPrompt(tr("TXT Cheatcodes Path changed"),0,tr("OK")); - } - } else - WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); - break; - case 8: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - strlcpy(entered, Settings.dolpath, sizeof(entered)); - titleTxt.SetText(tr("DOL Path")); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.dolpath, entered, sizeof(Settings.dolpath)); - WindowPrompt(tr("DOL path changed"),0,tr("OK")); - if (!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); - } - } - } else { - WindowPrompt(tr("DOL path change"),tr("Console should be unlocked to modify it."),tr("OK")); - } - break; - case 9: - if ( Settings.godmode == 1) { - w.Remove(&optionBrowser2); - w.Remove(&backBtn); - char entered[43] = ""; - strlcpy(entered, Settings.homebrewapps_path, sizeof(entered)); - titleTxt.SetText(tr("Homebrew Apps Path")); - int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); - titleTxt.SetText(tr("Custom Paths")); - w.Append(&optionBrowser2); - w.Append(&backBtn); - if ( result == 1 ) { - int len = (strlen(entered)-1); - if (entered[len] !='/') - strncat (entered, "/", 1); - strlcpy(Settings.homebrewapps_path, entered, sizeof(Settings.homebrewapps_path)); - WindowPrompt(tr("Homebrew Appspath changed"),0,tr("OK")); - if (!isInserted(bootDevice)) { - WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); - } - } - } else { - WindowPrompt(tr("Homebrew Appspath change"),tr("Console should be unlocked to modify it."),tr("OK")); - } - break; - + } else { + WindowPrompt(tr("Cover Path Change"),tr("Console should be unlocked to modify it."),tr("OK")); } + break; + case 1: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strlcpy(entered, Settings.covers2d_path, sizeof(entered)); + titleTxt.SetText(tr("2D Cover Path")); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.covers2d_path, entered, sizeof(Settings.covers2d_path)); + WindowPrompt(tr("Cover Path Changed"),0,tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + } + } + } else { + WindowPrompt(tr("Cover Path Change"),tr("Console should be unlocked to modify it."),tr("OK")); + } + break; + case 2: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strlcpy(entered, Settings.disc_path, sizeof(entered)); + titleTxt.SetText(tr("Disc Artwork Path")); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.disc_path, entered, sizeof(Settings.disc_path)); + WindowPrompt(tr("Disc Path Changed"),0,tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + } + } + } else { + WindowPrompt(tr("Disc Path change"),tr("Console should be unlocked to modify it."),tr("OK")); + } + break; + case 3: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + titleTxt.SetText(tr("Theme Path")); + strlcpy(entered, CFG.theme_path, sizeof(entered)); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + HaltGui(); + w.RemoveAll(); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(CFG.theme_path, entered, sizeof(CFG.theme_path)); + WindowPrompt(tr("Theme Path Changed"),0,tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + } else { + cfg_save_global(); + } + mainWindow->Remove(bgImg); + HaltGui(); + CFG_Load(); + CFG_LoadGlobal(); + ResumeGui(); + menu = MENU_SETTINGS; +#ifdef HW_RVL + snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); + pointer[0] = new GuiImageData(imgPath, player1_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); + pointer[1] = new GuiImageData(imgPath, player2_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer3_point.png", CFG.theme_path); + pointer[2] = new GuiImageData(imgPath, player3_point_png); + snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); + pointer[3] = new GuiImageData(imgPath, player4_point_png); +#endif + if (CFG.widescreen) + snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); + else + snprintf(imgPath, sizeof(imgPath), "%sbackground.png", CFG.theme_path); + + background = new GuiImageData(imgPath, CFG.widescreen? wbackground_png : background_png); + + bgImg = new GuiImage(background); + mainWindow->Append(bgImg); + mainWindow->Append(&w); + } + w.Append(&settingsbackground); + w.Append(&titleTxt); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&backBtn); + w.Append(&optionBrowser2); + ResumeGui(); + } else { + WindowPrompt(tr("Theme Path change"),tr("Console should be unlocked to modify it."),tr("OK")); + } + break; + case 4: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + titleTxt.SetText(tr("WiiTDB Path")); + strlcpy(entered, Settings.titlestxt_path, sizeof(entered)); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + w.Append(&optionBrowser2); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.titlestxt_path, entered, sizeof(Settings.titlestxt_path)); + WindowPrompt(tr("WiiTDB Path changed."),0,tr("OK")); + if (isInserted(bootDevice)) { + cfg_save_global(); + HaltGui(); + CFG_Load(); + ResumeGui(); + } else { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + } + } + } else { + WindowPrompt(tr("WiiTDB Path change"),tr("Console should be unlocked to modify it."),tr("OK")); + } + break; + case 5: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strlcpy(entered, Settings.update_path, sizeof(entered)); + titleTxt.SetText(tr("Update Path")); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.update_path, entered, sizeof(Settings.update_path)); + WindowPrompt(tr("Update Path changed."),0,tr("OK")); + } + } else + WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); + break; + case 6: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strlcpy(entered, Settings.Cheatcodespath, sizeof(entered)); + titleTxt.SetText(tr("GCT Cheatcodes Path")); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.Cheatcodespath, entered, sizeof(Settings.Cheatcodespath)); + WindowPrompt(tr("GCT Cheatcodes Path changed"),0,tr("OK")); + } + } else + WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); + break; + case 7: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strlcpy(entered, Settings.TxtCheatcodespath, sizeof(entered)); + titleTxt.SetText(tr("TXT Cheatcodes Path")); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.TxtCheatcodespath, entered, sizeof(Settings.TxtCheatcodespath)); + WindowPrompt(tr("TXT Cheatcodes Path changed"),0,tr("OK")); + } + } else + WindowPrompt(0,tr("Console should be unlocked to modify it."),tr("OK")); + break; + case 8: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strlcpy(entered, Settings.dolpath, sizeof(entered)); + titleTxt.SetText(tr("DOL Path")); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.dolpath, entered, sizeof(Settings.dolpath)); + WindowPrompt(tr("DOL path changed"),0,tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + } + } + } else { + WindowPrompt(tr("DOL path change"),tr("Console should be unlocked to modify it."),tr("OK")); + } + break; + case 9: + if ( Settings.godmode == 1) { + w.Remove(&optionBrowser2); + w.Remove(&backBtn); + char entered[43] = ""; + strlcpy(entered, Settings.homebrewapps_path, sizeof(entered)); + titleTxt.SetText(tr("Homebrew Apps Path")); + int result = BrowseDevice(entered, sizeof(entered), FB_DEFAULT, noFILES); + titleTxt.SetText(tr("Custom Paths")); + w.Append(&optionBrowser2); + w.Append(&backBtn); + if ( result == 1 ) { + int len = (strlen(entered)-1); + if (entered[len] !='/') + strncat (entered, "/", 1); + strlcpy(Settings.homebrewapps_path, entered, sizeof(Settings.homebrewapps_path)); + WindowPrompt(tr("Homebrew Appspath changed"),0,tr("OK")); + if (!isInserted(bootDevice)) { + WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to save."), tr("OK")); + } + } + } else { + WindowPrompt(tr("Homebrew Appspath change"),tr("Console should be unlocked to modify it."),tr("OK")); + } + break; - options2.SetValue(0, "%s", Settings.covers_path); - options2.SetValue(1, "%s", Settings.covers2d_path); - options2.SetValue(2, "%s", Settings.disc_path); - options2.SetValue(3, "%s", CFG.theme_path); - options2.SetValue(4, "%s", Settings.titlestxt_path); - options2.SetValue(5, "%s", Settings.update_path); - options2.SetValue(6, "%s", Settings.Cheatcodespath); - options2.SetValue(7, "%s", Settings.TxtCheatcodespath); - options2.SetValue(8, "%s", Settings.dolpath); - options2.SetValue(9, "%s", Settings.homebrewapps_path); } } /** If not godmode don't let him inside **/ @@ -1676,10 +1640,10 @@ int MenuSettings() { if (shutdown == 1) Sys_Shutdown(); - else if (reset == 1) + if (reset == 1) Sys_Reboot(); - else if (backBtn.GetState() == STATE_CLICKED) { + if (backBtn.GetState() == STATE_CLICKED) { //Add the procedure call to save the global configuration if (isInserted(bootDevice)) { cfg_save_global(); @@ -1689,7 +1653,7 @@ int MenuSettings() { break; } - else if (GoLeftBtn.GetState() == STATE_CLICKED) { + if (GoLeftBtn.GetState() == STATE_CLICKED) { pageToDisplay--; /** Change direction of the flying buttons **/ if (pageToDisplay < 1) @@ -1699,7 +1663,7 @@ int MenuSettings() { break; } - else if (GoRightBtn.GetState() == STATE_CLICKED) { + if (GoRightBtn.GetState() == STATE_CLICKED) { pageToDisplay++; /** Change direction of the flying buttons **/ if (pageToDisplay > 2) @@ -1709,7 +1673,7 @@ int MenuSettings() { break; } - else if (PageIndicatorBtn1.GetState() == STATE_CLICKED) { + if (PageIndicatorBtn1.GetState() == STATE_CLICKED) { if (pageToDisplay == 2) { slidedirection = LEFT; pageToDisplay = 1; @@ -1727,7 +1691,7 @@ int MenuSettings() { PageIndicatorBtn2.ResetState(); } - else if (homo.GetState() == STATE_CLICKED) { + if (homo.GetState() == STATE_CLICKED) { cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); s32 thetimeofbg = bgMusic->GetPlayTime(); @@ -1768,7 +1732,7 @@ int MenuSettings() { if (opt_override != opt_overridenew && Settings.titlesOverride==0) { titles_default(); } - + HaltGui(); mainWindow->RemoveAll(); @@ -1833,7 +1797,7 @@ int GameSettings(struct discHdr * header) { GuiText titleTxt(!mountMethod?get_title(header):gameName, 28, (GXColor) {0, 0, 0, 255}); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetPosition(12,40); - titleTxt.SetMaxWidth(356, SCROLL_HORIZONTAL); + titleTxt.SetMaxWidth(356, GuiText::SCROLL); GuiImage settingsbackground(&settingsbg); @@ -2074,7 +2038,6 @@ int GameSettings(struct discHdr * header) { while (optionBrowser2.GetEffect() > 0) usleep(50); int returnhere = 1; - bool firstRun = true; char * languagefile; languagefile = strrchr(Settings.language_path, '/')+1; @@ -2083,13 +2046,91 @@ int GameSettings(struct discHdr * header) { returnhere = 1; + if (videoChoice >= 6) + videoChoice = 0; + if (viChoice >= 2) + viChoice = 0; + if (languageChoice >= 11) + languageChoice = 0; + if ( ocarinaChoice >= 2) + ocarinaChoice = 0; + if ( Settings.wsprompt > 1 ) + Settings.wsprompt = 0; + if ( iosChoice >= 3) + iosChoice = 0; + if ( Settings.wiilight > 2 ) + Settings.wiilight = 0; + if (parentalcontrolChoice >= 5) + parentalcontrolChoice = 0; + if (fix002 >= 3) + fix002 = 0; //RUMBLE + if (countrystrings >= 2) + countrystrings = 0; + if (alternatedol >= 3) + alternatedol = 0; + if (reloadblock >= 2) + reloadblock = 0; + + if (videoChoice == discdefault) options2.SetValue(0,"%s",tr("Disc Default")); + else if (videoChoice == systemdefault) options2.SetValue(0,"%s",tr("System Default")); + else if (videoChoice == patch) options2.SetValue(0,"%s",tr("AutoPatch")); + else if (videoChoice == pal50) options2.SetValue(0,"%s PAL50",tr("Force")); + else if (videoChoice == pal60) options2.SetValue(0,"%s PAL60",tr("Force")); + else if (videoChoice == ntsc) options2.SetValue(0,"%s NTSC",tr("Force")); + + if (viChoice == on) options2.SetValue(1,"%s",tr("ON")); + else if (viChoice == off) options2.SetValue(1,"%s",tr("OFF")); + + if (languageChoice == ConsoleLangDefault) options2.SetValue(2,"%s",tr("Console Default")); + else if (languageChoice == jap) options2.SetValue(2,"%s",tr("Japanese")); + else if (languageChoice == ger) options2.SetValue(2,"%s",tr("German")); + else if (languageChoice == eng) options2.SetValue(2,"%s",tr("English")); + else if (languageChoice == fren) options2.SetValue(2,"%s",tr("French")); + else if (languageChoice == esp) options2.SetValue(2,"%s",tr("Spanish")); + else if (languageChoice == it) options2.SetValue(2,"%s",tr("Italian")); + else if (languageChoice == dut) options2.SetValue(2,"%s",tr("Dutch")); + else if (languageChoice == schin) options2.SetValue(2,"%s",tr("SChinese")); + else if (languageChoice == tchin) options2.SetValue(2,"%s",tr("TChinese")); + else if (languageChoice == kor) options2.SetValue(2,"%s",tr("Korean")); + + if (ocarinaChoice == on) options2.SetValue(3,"%s",tr("ON")); + else if (ocarinaChoice == off) options2.SetValue(3,"%s",tr("OFF")); + + if (iosChoice == i249) options2.SetValue(4,"249"); + else if (iosChoice == i222) options2.SetValue(4,"222"); + else if (iosChoice == i223) options2.SetValue(4,"223"); + + if (parentalcontrolChoice == 0) options2.SetValue(5, tr("0 (Everyone)")); + else if (parentalcontrolChoice == 1) options2.SetValue(5, tr("1 (Child 7+)")); + else if (parentalcontrolChoice == 2) options2.SetValue(5, tr("2 (Teen 12+)")); + else if (parentalcontrolChoice == 3) options2.SetValue(5, tr("3 (Mature 16+)")); + else if (parentalcontrolChoice == 4) options2.SetValue(5, tr("4 (Adults Only 18+)")); + + if (fix002 == on) options2.SetValue(6,tr("ON")); + else if (fix002 == off) options2.SetValue(6,tr("OFF")); + else if (fix002 == anti) options2.SetValue(6,tr("Anti")); + + if (countrystrings == on) options2.SetValue(7,tr("ON")); + else if (countrystrings == off) options2.SetValue(7,tr("OFF")); + + if (alternatedol == on) options2.SetValue(8,tr("Load From SD/USB")); + if (alternatedol == 2) options2.SetValue(8,tr("Select a DOL")); + else if (alternatedol == off) options2.SetValue(8,tr("Default")); + + if (alternatedol == on) options2.SetValue(9,tr("SD/USB selected")); + else if (alternatedol == off) options2.SetValue(9,tr("Default")); + else options2.SetValue(9, alternatedname); + + if (reloadblock == on) options2.SetValue(10,tr("ON")); + else if (reloadblock == off) options2.SetValue(10,tr("OFF")); + if (backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); exit = true; break; } - else if (shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); else if (reset == 1) Sys_Reboot(); @@ -2123,7 +2164,87 @@ int GameSettings(struct discHdr * header) { optionBrowser2.SetState(STATE_DEFAULT); } - else if (saveBtn.GetState() == STATE_CLICKED) { + ret = optionBrowser2.GetClickedOption(); + + switch (ret) { + case 0: + videoChoice = (videoChoice + 1) % CFG_VIDEO_COUNT; + break; + case 1: + viChoice = (viChoice + 1) % 2; + break; + case 2: + languageChoice = (languageChoice + 1) % CFG_LANG_COUNT; + break; + case 3: + ocarinaChoice = (ocarinaChoice + 1) % 2; + break; + case 4: + iosChoice = (iosChoice + 1) % 3; + break; + case 5: + parentalcontrolChoice = (parentalcontrolChoice + 1) % 5; + break; + case 6: + fix002 = (fix002+1) % 3; + break; + case 7: + countrystrings = (countrystrings+1) % 2; + break; + case 8: + alternatedol = (alternatedol+2) % 3; + break; + case 9: + if (alternatedol == 2) { + char filename[10]; + snprintf(filename,sizeof(filename),"%c%c%c%c%c%c",header->id[0], header->id[1], header->id[2], + header->id[3],header->id[4], header->id[5]); + int dolchoice = 0; + //alt dol menu for games that require more than a single alt dol + int autodol = autoSelectDolMenu(filename,false); + + if (autodol>0) { + alternatedoloffset = autodol; + snprintf(alternatedname, sizeof(alternatedname), "%s <%i>", tr("AUTO"),autodol); + } else if (autodol == 0) { + // default was chosen + alternatedol = 0; + } else { + //check to see if we already know the offset of the correct dol + int autodol = autoSelectDol(filename, false); + //if we do know that offset ask if they want to use it + if (autodol>0) { + dolchoice = WindowPrompt(0,tr("Do you want to use the alternate DOL that is known to be correct?"),tr("Yes"),tr("Pick from a list"),tr("Cancel")); + if (dolchoice==0) { + alternatedol = 0; + } else if (dolchoice==1) { + alternatedoloffset = autodol; + snprintf(alternatedname, sizeof(alternatedname), "%s <%i>", tr("AUTO"),autodol); + } else if (dolchoice==2) {//they want to search for the correct dol themselves + int res = DiscBrowse(header); + if ((res >= 0)&&(res !=696969)) {//if res==696969 they pressed the back button + alternatedoloffset = res; + } + } + } else { + int res = DiscBrowse(header); + if ((res >= 0)&&(res !=696969)){ + alternatedoloffset = res; + char tmp[170]; + snprintf(tmp,sizeof(tmp),"%s %s - %i",tr("It seems that you have some information that will be helpful to us. Please pass this information along to the DEV team.") ,filename,alternatedoloffset); + WindowPrompt(0,tmp,tr("OK")); + } + } + } + } + break; + case 10: + reloadblock = (reloadblock+1) % 2; + break; + + } + + if (saveBtn.GetState() == STATE_CLICKED) { if (isInserted(bootDevice)) { if (CFG_save_game_opt(header->id)) { @@ -2148,163 +2269,6 @@ int GameSettings(struct discHdr * header) { saveBtn.ResetState(); optionBrowser2.SetFocus(1); } - - ret = optionBrowser2.GetClickedOption(); - - if(ret >= 0 || firstRun == true) - { - firstRun = false; - - if (videoChoice == discdefault) options2.SetValue(0,"%s",tr("Disc Default")); - else if (videoChoice == systemdefault) options2.SetValue(0,"%s",tr("System Default")); - else if (videoChoice == patch) options2.SetValue(0,"%s",tr("AutoPatch")); - else if (videoChoice == pal50) options2.SetValue(0,"%s PAL50",tr("Force")); - else if (videoChoice == pal60) options2.SetValue(0,"%s PAL60",tr("Force")); - else if (videoChoice == ntsc) options2.SetValue(0,"%s NTSC",tr("Force")); - - if (viChoice == on) options2.SetValue(1,"%s",tr("ON")); - else if (viChoice == off) options2.SetValue(1,"%s",tr("OFF")); - - if (languageChoice == ConsoleLangDefault) options2.SetValue(2,"%s",tr("Console Default")); - else if (languageChoice == jap) options2.SetValue(2,"%s",tr("Japanese")); - else if (languageChoice == ger) options2.SetValue(2,"%s",tr("German")); - else if (languageChoice == eng) options2.SetValue(2,"%s",tr("English")); - else if (languageChoice == fren) options2.SetValue(2,"%s",tr("French")); - else if (languageChoice == esp) options2.SetValue(2,"%s",tr("Spanish")); - else if (languageChoice == it) options2.SetValue(2,"%s",tr("Italian")); - else if (languageChoice == dut) options2.SetValue(2,"%s",tr("Dutch")); - else if (languageChoice == schin) options2.SetValue(2,"%s",tr("SChinese")); - else if (languageChoice == tchin) options2.SetValue(2,"%s",tr("TChinese")); - else if (languageChoice == kor) options2.SetValue(2,"%s",tr("Korean")); - - if (ocarinaChoice == on) options2.SetValue(3,"%s",tr("ON")); - else if (ocarinaChoice == off) options2.SetValue(3,"%s",tr("OFF")); - - if (iosChoice == i249) options2.SetValue(4,"249"); - else if (iosChoice == i222) options2.SetValue(4,"222"); - else if (iosChoice == i223) options2.SetValue(4,"223"); - - if (parentalcontrolChoice == 0) options2.SetValue(5, tr("0 (Everyone)")); - else if (parentalcontrolChoice == 1) options2.SetValue(5, tr("1 (Child 7+)")); - else if (parentalcontrolChoice == 2) options2.SetValue(5, tr("2 (Teen 12+)")); - else if (parentalcontrolChoice == 3) options2.SetValue(5, tr("3 (Mature 16+)")); - else if (parentalcontrolChoice == 4) options2.SetValue(5, tr("4 (Adults Only 18+)")); - - if (fix002 == on) options2.SetValue(6,tr("ON")); - else if (fix002 == off) options2.SetValue(6,tr("OFF")); - else if (fix002 == anti) options2.SetValue(6,tr("Anti")); - - if (countrystrings == on) options2.SetValue(7,tr("ON")); - else if (countrystrings == off) options2.SetValue(7,tr("OFF")); - - if (alternatedol == on) options2.SetValue(8,tr("Load From SD/USB")); - if (alternatedol == 2) options2.SetValue(8,tr("Select a DOL")); - else if (alternatedol == off) options2.SetValue(8,tr("Default")); - - if (alternatedol == on) options2.SetValue(9,tr("SD/USB selected")); - else if (alternatedol == off) options2.SetValue(9,tr("Default")); - else options2.SetValue(9, alternatedname); - - if (reloadblock == on) options2.SetValue(10,tr("ON")); - else if (reloadblock == off) options2.SetValue(10,tr("OFF")); - - switch (ret) { - case 0: - videoChoice = (videoChoice + 1) % CFG_VIDEO_COUNT; - if (videoChoice >= 6) - videoChoice = 0; - break; - case 1: - viChoice = (viChoice + 1) % 2; - if (viChoice >= 2) - viChoice = 0; - break; - case 2: - languageChoice = (languageChoice + 1) % CFG_LANG_COUNT; - if (languageChoice >= 11) - languageChoice = 0; - break; - case 3: - ocarinaChoice = (ocarinaChoice + 1) % 2; - if ( ocarinaChoice >= 2) - ocarinaChoice = 0; - break; - case 4: - iosChoice = (iosChoice + 1) % 3; - if ( iosChoice >= 3) - iosChoice = 0; - break; - case 5: - parentalcontrolChoice = (parentalcontrolChoice + 1) % 5; - if (parentalcontrolChoice >= 5) - parentalcontrolChoice = 0; - break; - case 6: - fix002 = (fix002+1) % 3; - if (fix002 >= 3) - fix002 = 0; //RUMBLE - break; - case 7: - countrystrings = (countrystrings+1) % 2; - if (countrystrings >= 2) - countrystrings = 0; - break; - case 8: - alternatedol = (alternatedol+2) % 3; - if (alternatedol >= 3) - alternatedol = 0; - break; - case 9: - if (alternatedol == 2) { - char filename[10]; - snprintf(filename,sizeof(filename),"%c%c%c%c%c%c",header->id[0], header->id[1], header->id[2], - header->id[3],header->id[4], header->id[5]); - int dolchoice = 0; - //alt dol menu for games that require more than a single alt dol - int autodol = autoSelectDolMenu(filename,false); - - if (autodol>0) { - alternatedoloffset = autodol; - snprintf(alternatedname, sizeof(alternatedname), "%s <%i>", tr("AUTO"),autodol); - } else if (autodol == 0) { - // default was chosen - alternatedol = 0; - } else { - //check to see if we already know the offset of the correct dol - int autodol = autoSelectDol(filename, false); - //if we do know that offset ask if they want to use it - if (autodol>0) { - dolchoice = WindowPrompt(0,tr("Do you want to use the alternate DOL that is known to be correct?"),tr("Yes"),tr("Pick from a list"),tr("Cancel")); - if (dolchoice==0) { - alternatedol = 0; - } else if (dolchoice==1) { - alternatedoloffset = autodol; - snprintf(alternatedname, sizeof(alternatedname), "%s <%i>", tr("AUTO"),autodol); - } else if (dolchoice==2) {//they want to search for the correct dol themselves - int res = DiscBrowse(header); - if ((res >= 0)&&(res !=696969)) {//if res==696969 they pressed the back button - alternatedoloffset = res; - } - } - } else { - int res = DiscBrowse(header); - if ((res >= 0)&&(res !=696969)){ - alternatedoloffset = res; - char tmp[170]; - snprintf(tmp,sizeof(tmp),"%s %s - %i",tr("It seems that you have some information that will be helpful to us. Please pass this information along to the DEV team.") ,filename,alternatedoloffset); - WindowPrompt(0,tmp,tr("OK")); - } - } - } - } - break; - case 10: - reloadblock = (reloadblock+1) % 2; - if (reloadblock >= 2) - reloadblock = 0; - break; - } - } } optionBrowser2.SetEffect(EFFECT_FADE, -20); @@ -2347,8 +2311,7 @@ int GameSettings(struct discHdr * header) { optionBrowser2.SetClickable(true); ResumeGui(); - bool firstRun = true; - + VIDEO_WaitVSync (); optionBrowser2.SetEffect(EFFECT_FADE, 20); while (optionBrowser2.GetEffect() > 0) usleep(50); @@ -2361,7 +2324,7 @@ int GameSettings(struct discHdr * header) { break; } - else if (shutdown == 1) + if (shutdown == 1) Sys_Shutdown(); else if (reset == 1) Sys_Reboot(); @@ -2391,91 +2354,86 @@ int GameSettings(struct discHdr * header) { ret = optionBrowser2.GetClickedOption(); - if(firstRun || ret >= 0) - { - firstRun = false; - - int choice1; - char tmp[200]; - switch (ret) { - case 0: - choice1 = WindowPrompt(tr("Do you really want to delete:"),gameName,tr("Yes"),tr("Cancel")); - if (choice1 == 1 && !mountMethod) { - CFG_forget_game_opt(header->id); - CFG_forget_game_num(header->id); - ret = WBFS_RemoveGame(header->id); - if (ret < 0) { - WindowPrompt( - tr("Can't delete:"), - gameName, - tr("OK")); - } else { - WindowPrompt(tr("Successfully deleted:"),gameName,tr("OK")); - retVal = 1; - } - } else if (choice1 == 0) { - optionBrowser2.SetFocus(1); + int choice1; + char tmp[200]; + switch (ret) { + case 0: + choice1 = WindowPrompt(tr("Do you really want to delete:"),gameName,tr("Yes"),tr("Cancel")); + if (choice1 == 1 && !mountMethod) { + CFG_forget_game_opt(header->id); + CFG_forget_game_num(header->id); + ret = WBFS_RemoveGame(header->id); + if (ret < 0) { + WindowPrompt( + tr("Can't delete:"), + gameName, + tr("OK")); + } else { + WindowPrompt(tr("Successfully deleted:"),gameName,tr("OK")); + retVal = 1; } - break; - case 1: - int result; - result = WindowPrompt(tr("Are you sure?"),0,tr("Yes"),tr("Cancel")); - if (result == 1) { - if (isInserted(bootDevice)) { - struct Game_NUM* game_num = CFG_get_game_num(header->id); - if (game_num) { - favoritevar = game_num->favorite; - playcount = game_num->count; - } else { - favoritevar = 0; - playcount = 0; - } - playcount = 0; - CFG_save_game_num(header->id); - } - } - break; - case 2: - - snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.png", Settings.covers_path, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - - choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); - if (choice1==1) { - if (checkfile(tmp)) - remove(tmp); - } - break; - case 3: - - snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.png", Settings.disc_path, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - - choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); - if (choice1==1) { - if (checkfile(tmp)) - remove(tmp); - } - break; - case 4: - - snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.txt", Settings.TxtCheatcodespath, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - - choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); - if (choice1==1) { - if (checkfile(tmp)) - remove(tmp); - } - break; - case 5: - - snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.gct", Settings.Cheatcodespath, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); - - choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); - if (choice1==1) { - if (checkfile(tmp)) - remove(tmp); - } - break; + } else if (choice1 == 0) { + optionBrowser2.SetFocus(1); } + break; + case 1: + int result; + result = WindowPrompt(tr("Are you sure?"),0,tr("Yes"),tr("Cancel")); + if (result == 1) { + if (isInserted(bootDevice)) { + struct Game_NUM* game_num = CFG_get_game_num(header->id); + if (game_num) { + favoritevar = game_num->favorite; + playcount = game_num->count; + } else { + favoritevar = 0; + playcount = 0; + } + playcount = 0; + CFG_save_game_num(header->id); + } + } + break; + case 2: + + snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.png", Settings.covers_path, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); + if (choice1==1) { + if (checkfile(tmp)) + remove(tmp); + } + break; + case 3: + + snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.png", Settings.disc_path, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); + if (choice1==1) { + if (checkfile(tmp)) + remove(tmp); + } + break; + case 4: + + snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.txt", Settings.TxtCheatcodespath, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); + if (choice1==1) { + if (checkfile(tmp)) + remove(tmp); + } + break; + case 5: + + snprintf(tmp,sizeof(tmp),"%s%c%c%c%c%c%c.gct", Settings.Cheatcodespath, header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]); + + choice1 = WindowPrompt(tr("Delete"),tmp,tr("Yes"),tr("No")); + if (choice1==1) { + if (checkfile(tmp)) + remove(tmp); + } + break; } } optionBrowser2.SetEffect(EFFECT_FADE, -20); diff --git a/source/usbloader/getentries.cpp b/source/usbloader/getentries.cpp index 589e052f..e0d5520f 100644 --- a/source/usbloader/getentries.cpp +++ b/source/usbloader/getentries.cpp @@ -5,7 +5,6 @@ #include "main.h" #include #include "getentries.h" -#include "FreeTypeGX.h" #include "../prompts/TitleBrowser.h" @@ -175,7 +174,7 @@ int __Menu_GetPrevFilter(int t, wchar_t* gameFilter, u32 gameFiltered, wchar_t * if(get_block(header) >= Settings.parentalcontrol) continue; - wchar_t *wname = charToWideChar(get_title(header)); + wchar_t *wname = FreeTypeGX::charToWideChar(get_title(header)); if(wname) nameList.push_back(wname); } @@ -221,7 +220,7 @@ int __Menu_GetGameFilter_NextList(discHdr *gameList, u32 gameCnt, wchar_t **Pgam for(i=0; i filter_len) @@ -392,7 +391,7 @@ int buildTitleList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameC if(gameFilter && *gameFilter) { u32 filter_len = wcslen(gameFilter); - wchar_t *gameName = charToWideChar(get_title(header)); + wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header)); if (!gameName || wcsnicmp(gameName, gameFilter, filter_len)) { delete [] gameName; continue; @@ -487,7 +486,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 = charToWideChar(get_title(header)); + wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header)); if (!gameName || wcsnicmp(gameName, gameFilter, filter_len)) { delete [] gameName; continue; diff --git a/source/video.cpp b/source/video.cpp index 45f99381..4f549012 100644 --- a/source/video.cpp +++ b/source/video.cpp @@ -218,12 +218,12 @@ void StopGX() { * Renders everything current sent to GX, and flushes video ***************************************************************************/ void Menu_Render() { + GX_DrawDone (); whichfb ^= 1; // flip framebuffer GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetColorUpdate(GX_TRUE); GX_CopyDisp(xfb[whichfb],GX_TRUE); - GX_DrawDone (); VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_Flush(); VIDEO_WaitVSync(); diff --git a/source/wad/wad.cpp b/source/wad/wad.cpp index 4b1d1fa3..ff4efdc3 100644 --- a/source/wad/wad.cpp +++ b/source/wad/wad.cpp @@ -141,11 +141,9 @@ s32 Wad_Install(FILE *fp) GuiText btn1Txt(tr("OK"), 22, THEME.prompttext); GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes) - { - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen); - } + if (Settings.wsprompt == yes){ + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen);} GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -35, &trigA, &btnSoundOver, &btnClick,1); btn1.SetLabel(&btn1Txt); btn1.SetState(STATE_SELECTED); @@ -371,7 +369,7 @@ s32 Wad_Install(FILE *fp) // Increase variables idx += size; offset += size; - + //snprintf(imgPath, sizeof(imgPath), "%s%d (%d)...",tr(">> Installing content #"),content->cid,idx); //msg4Txt.SetText(imgPath); @@ -472,11 +470,9 @@ s32 Wad_Uninstall(FILE *fp) GuiText btn1Txt(tr("OK"), 22, THEME.prompttext); GuiImage btn1Img(&btnOutline); - if (Settings.wsprompt == yes) - { - btn1Txt.SetWidescreen(CFG.widescreen); - btn1Img.SetWidescreen(CFG.widescreen); - } + if (Settings.wsprompt == yes){ + btn1Txt.SetWidescreen(CFG.widescreen); + btn1Img.SetWidescreen(CFG.widescreen);} GuiButton btn1(&btn1Img,&btn1Img, 2, 4, 0, -55, &trigA, &btnSoundOver, &btnClick,1); btn1.SetLabel(&btn1Txt); btn1.SetState(STATE_SELECTED);