From 6d1178c26d7cdd2a24e0eed224913fafc68057c8 Mon Sep 17 00:00:00 2001 From: "ardi@ist-einmalig.de" Date: Mon, 19 Oct 2009 23:09:27 +0000 Subject: [PATCH] optimized the font stuff --- source/FreeTypeGX.cpp | 183 ++++++++++++++---------------- source/FreeTypeGX.h | 21 ++-- source/libwiigui/gui_text.cpp | 19 +--- source/prompts/DiscBrowser.cpp | 10 +- source/prompts/ProgressWindow.cpp | 47 +++++--- source/prompts/TitleBrowser.cpp | 5 +- source/prompts/filebrowser.cpp | 14 +-- 7 files changed, 142 insertions(+), 157 deletions(-) diff --git a/source/FreeTypeGX.cpp b/source/FreeTypeGX.cpp index cbacc81e..b9099d2d 100644 --- a/source/FreeTypeGX.cpp +++ b/source/FreeTypeGX.cpp @@ -64,12 +64,16 @@ typedef struct ftgxDataOffset_ { * @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) { +FreeTypeGX::FreeTypeGX(uint8_t textureFormat, uint8_t vertexIndex, uint32_t compatibilityMode) +: +ftFace(NULL), +ftFace_fromFile(NULL) +{ FT_Init_FreeType(&this->ftLibrary); this->textureFormat = textureFormat; this->setVertexFormat(vertexIndex); - this->setCompatibilityMode(FTGX_COMPATIBILITY_NONE); + this->setCompatibilityMode(compatibilityMode); } /** @@ -89,10 +93,10 @@ FreeTypeGX::~FreeTypeGX() { * @param strChar Character string to be converted. * @return Wide character representation of supplied character string. */ -wchar_t* FreeTypeGX::charToWideChar(char* strChar) { +wchar_t* FreeTypeGX::charToWideChar(const char* strChar) { wchar_t *strWChar; - try {strWChar = new wchar_t[strlen(strChar) + 1];} - catch (...) { return 0; } + strWChar = new(std::nothrow) wchar_t[strlen(strChar) + 1]; + if(!strWChar) return NULL; // UTF-8 int bt; bt = mbstowcs(strWChar, strChar, strlen(strChar)); @@ -101,21 +105,12 @@ wchar_t* FreeTypeGX::charToWideChar(char* strChar) { return strWChar; } - char *tempSrc = strChar; wchar_t *tempDest = strWChar; - while ((*tempDest++ = *tempSrc++)); + while ((*tempDest++ = *strChar++)); return strWChar; } -/** - * - * \overload - */ -wchar_t* FreeTypeGX::charToWideChar(const char* strChar) { - return FreeTypeGX::charToWideChar((char*) strChar); -} - /** * Setup the vertex attribute formats for the glyph textures. * @@ -205,9 +200,9 @@ void FreeTypeGX::setDefaultMode() { * @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) { +uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) { this->unloadFont(); - this->ftPointSize = pointSize; + this->ftPointSize_v = this->ftPointSize_h = 0; struct stat st; if (fontPath && (stat(fontPath, &st)==0)) { @@ -229,8 +224,8 @@ uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long buffe 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); + if (pointSize > 0) + changeSize(pointSize); this->ftSlot = this->ftFace->glyph; this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace); @@ -242,14 +237,6 @@ uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long buffe 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(); @@ -268,23 +255,38 @@ void FreeTypeGX::unloadFont() { * This routine clears all members of the font map structure and frees all allocated memory back to the system. */ void FreeTypeGX::clearGlyphData() { - if (this->fontData.size() == 0) + if (this->fontDatas.size() == 0) return; GX_DrawDone(); GX_Flush(); - for ( std::map::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) { + for ( std::map::iterator i = this->fontDatas.begin(); i != this->fontDatas.end(); i++) + { + for ( FTGX_Cache::iterator j = i->second.begin(); j != i->second.end(); j++) + { + free(j->second.glyphDataTexture); + } + i->second.clear(); + } +/* for ( std::map::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) { free(i->second.glyphDataTexture); } - - this->fontData.clear(); +*/ + this->fontDatas.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); + if(hPointSize == 0) hPointSize = vPointSize; + if(vPointSize > 255) vPointSize = 255;// limit to 255 + if(hPointSize > 255) hPointSize = 255; + if(this->ftPointSize_v != vPointSize || this->ftPointSize_h != hPointSize) + { +// this->clearGlyphData(); + this->ftPointSize_v = vPointSize; + this->ftPointSize_h = hPointSize; + FT_Set_Pixel_Sizes(this->ftFace, this->ftPointSize_h, this->ftPointSize_v); + } } /** @@ -358,38 +360,44 @@ 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) +{ + FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8]; + return cacheGlyphData(charCode, fontData); +} +ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, FTGX_Cache &fontData) +{ + FT_UInt gIndex; + uint16_t textureWidth = 0, textureHeight = 0; - gIndex = FT_Get_Char_Index( this->ftFace, charCode ); - if (!FT_Load_Glyph(this->ftFace, gIndex, FT_LOAD_DEFAULT )) { - FT_Render_Glyph( this->ftSlot, FT_RENDER_MODE_NORMAL ); + gIndex = FT_Get_Char_Index( this->ftFace, charCode ); + if (!FT_Load_Glyph(this->ftFace, gIndex, FT_LOAD_DEFAULT )) { + FT_Render_Glyph( this->ftSlot, FT_RENDER_MODE_NORMAL ); - if (this->ftSlot->format == FT_GLYPH_FORMAT_BITMAP) { - FT_Bitmap *glyphBitmap = &this->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) { - 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]); + 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, &fontData[charCode]); - return &this->fontData[charCode]; - } - } + return &fontData[charCode]; + } + } - return NULL; + return NULL; } /** @@ -544,7 +552,8 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color GXTexObj glyphTexture; FT_Vector pairDelta; ftgxDataOffset offset; - + FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8]; + if (textStyle & FTGX_JUSTIFY_MASK) { x_offset = this->getStyleOffsetWidth(this->getWidth(text), textStyle); } @@ -555,16 +564,16 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color 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]]; + if ( fontData.find(text[i]) != fontData.end() ) { + glyphData = &fontData[text[i]]; } else { - glyphData = this->cacheGlyphData(text[i]); + glyphData = this->cacheGlyphData(text[i], fontData); } if (glyphData != NULL) { if (this->ftKerningEnabled && i) { - FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta ); + FT_Get_Kerning( this->ftFace, fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta ); x_pos += pairDelta.x >> 6; } @@ -591,7 +600,7 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t const *text, GXColor } 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; + uint16_t featureHeight = this->ftPointSize_v >> 4 > 0 ? this->ftPointSize_v >> 4 : 1; if (format & FTGX_STYLE_UNDERLINE ) { switch (format & FTGX_ALIGN_MASK) { @@ -642,23 +651,24 @@ void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataO * @param text NULL terminated string to calculate. * @return The width of the text string in pixels. */ -uint16_t FreeTypeGX::getWidth(wchar_t *text) { +uint16_t FreeTypeGX::getWidth(const wchar_t *text) { uint16_t strLength = wcslen(text); uint16_t strWidth = 0; FT_Vector pairDelta; + FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8]; 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]]; + if ( fontData.find(text[i]) != fontData.end() ) { + glyphData = &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 ); + FT_Get_Kerning( this->ftFace, fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta ); strWidth += pairDelta.x >> 6; } @@ -669,13 +679,6 @@ uint16_t FreeTypeGX::getWidth(wchar_t *text) { return strWidth; } -/** - * - * \overload - */ -uint16_t FreeTypeGX::getWidth(wchar_t const *text) { - return this->getWidth((wchar_t *)text); -} /** * Processes the supplied string and return the height of the string in pixels. @@ -686,21 +689,13 @@ uint16_t FreeTypeGX::getWidth(wchar_t const *text) { * @param text NULL terminated string to calculate. * @return The height of the text string in pixels. */ -uint16_t FreeTypeGX::getHeight(wchar_t *text) { +uint16_t FreeTypeGX::getHeight(const 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); -} - /** * Get the maximum offset above and minimum offset below the font origin line. * @@ -711,15 +706,16 @@ uint16_t FreeTypeGX::getHeight(wchar_t const *text) { * @param offset returns the max and min values above and below the font origin line * */ -ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) { +ftgxDataOffset* FreeTypeGX::getOffset(const wchar_t *text, ftgxDataOffset* offset) { uint16_t strLength = wcslen(text); int16_t strMax = 0, strMin = 9999; - + FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8]; + 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]]; + if ( fontData.find(text[i]) != fontData.end() ) { + glyphData = &fontData[text[i]]; } else { glyphData = this->cacheGlyphData(text[i]); } @@ -736,13 +732,6 @@ ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) { return offset; } -/** - * - * \overload - */ -ftgxDataOffset* FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset) { - return this->getOffset(text, offset); -} /** * Copies the supplied texture quad to the EFB. diff --git a/source/FreeTypeGX.h b/source/FreeTypeGX.h index 5d235837..3276abe5 100644 --- a/source/FreeTypeGX.h +++ b/source/FreeTypeGX.h @@ -217,6 +217,7 @@ const GXColor ftgxWhite = (GXColor) { * a specified texture format. Rendering of the data to the EFB is accomplished through the application of high performance * GX texture functions resulting in high throughput of string rendering. */ +typedef std::map FTGX_Cache; class FreeTypeGX { private: @@ -224,13 +225,15 @@ private: 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. */ + FT_UInt ftPointSize_v; /**< Requested size of the rendered font. */ + FT_UInt ftPointSize_h; /**< 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. */ +// FTGX_Cache fontData; /**< Map which holds the glyph data structures for the corresponding characters. */ + std::map fontDatas; static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat); static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat); @@ -241,6 +244,7 @@ private: void unloadFont(); void clearGlyphData(); ftgxCharData *cacheGlyphData(wchar_t charCode); + ftgxCharData *cacheGlyphData(wchar_t charCode, FTGX_Cache &fontData); uint16_t cacheGlyphDataComplete(); void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData); @@ -251,27 +255,22 @@ private: void copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color); public: - FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1); + FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1, uint32_t compatibilityMode = FTGX_COMPATIBILITY_NONE); ~FreeTypeGX(); - static wchar_t* charToWideChar(char* p); static wchar_t* charToWideChar(const char* p); 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 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); + uint16_t getWidth(const wchar_t *text); + uint16_t getHeight(const wchar_t *text); + ftgxDataOffset* getOffset(const wchar_t *text, ftgxDataOffset* offset); }; #endif /* FREETYPEGX_H_ */ diff --git a/source/libwiigui/gui_text.cpp b/source/libwiigui/gui_text.cpp index ef0a822f..7c9c5f56 100644 --- a/source/libwiigui/gui_text.cpp +++ b/source/libwiigui/gui_text.cpp @@ -10,8 +10,6 @@ #include "gui.h" -static int currentSize = 0; -static int currentWidescreen = 0; static int presetSize = 0; static GXColor presetColor = (GXColor){255, 255, 255, 255}; static int presetMaxWidth = 0; @@ -255,13 +253,7 @@ int GuiText::GetTextWidth() int newSize = size*this->GetScale(); - if(newSize != currentSize || currentWidescreen != widescreen) - { - //fontSystem->changeSize(newSize); - (font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0); - currentSize = newSize; - currentWidescreen = widescreen; - } + (font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0); return (font ? font : fontSystem)->getWidth(text); } @@ -287,14 +279,7 @@ void GuiText::Draw() int newSize = size*this->GetScale(); - if(newSize != currentSize || currentWidescreen != widescreen) - { - //fontSystem->changeSize(newSize); - (font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0); - currentSize = newSize; - currentWidescreen = widescreen; - } - + (font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0); int voffset = 0; // if(alignmentVert == ALIGN_MIDDLE) diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp index d047584e..249a287d 100644 --- a/source/prompts/DiscBrowser.cpp +++ b/source/prompts/DiscBrowser.cpp @@ -293,12 +293,12 @@ int autoSelectDol(const char *id, bool 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 - + //Tiger Woods 10 if (strcmp(id,"R9OP69") == 0) return 1991;//from isostar if (strcmp(id,"R9OE69") == 0) return 1973;//starstremr @@ -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 @@ -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")); diff --git a/source/prompts/ProgressWindow.cpp b/source/prompts/ProgressWindow.cpp index dcf63c7f..951581e0 100644 --- a/source/prompts/ProgressWindow.cpp +++ b/source/prompts/ProgressWindow.cpp @@ -30,6 +30,7 @@ static int showProgress = 0; static f32 progressDone = 0.0; static bool showTime = false; static bool showSize = false; +static bool changed = true; static s32 gameinstalldone = 0; static s32 gameinstalltotal = -1; static time_t start; @@ -52,8 +53,13 @@ static void GameInstallProgress() { if (gameinstalltotal <= 0) return; + int oldinstalldone = gameinstalldone; + GetProgressValue(&gameinstalldone, &gameinstalltotal); + if((oldinstalldone == gameinstalldone) && (gameinstalldone > 0)) + return; + if (gameinstalldone > gameinstalltotal) gameinstalldone = gameinstalltotal; @@ -89,6 +95,7 @@ static void GameInstallProgress() { snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%.2fGB/%.2fGB", gamesize * gameinstalldone/gameinstalltotal, gamesize); snprintf(progressSpeed, sizeof(progressSpeed), "%.1fMB/s", speed); + changed = true; } /**************************************************************************** @@ -246,28 +253,33 @@ 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 (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); + if(changed) + { + changed = false; - prTxt.SetTextf("%.2f", progressDone); + tmp = static_cast(progressbarImg.GetWidth()*progressDone); - if (showSize) { - sizeTxt.SetText(progressSizeLeft); - speedTxt.SetText(progressSpeed); + 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 (showTime) - timeTxt.SetText(progressTime); - - if (msg2) - msg2Txt.SetText(dyn_message); } promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); @@ -374,6 +386,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done, showProgress = 1; progressDone = 100.0*done/total; + changed = true; LWP_ResumeThread(progressthread); } @@ -384,7 +397,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done, * Startup Progressthread in idle prio ***************************************************************************/ void InitProgressThread() { - LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 0); + LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 80); } /**************************************************************************** diff --git a/source/prompts/TitleBrowser.cpp b/source/prompts/TitleBrowser.cpp index 513a242f..29e23828 100644 --- a/source/prompts/TitleBrowser.cpp +++ b/source/prompts/TitleBrowser.cpp @@ -493,14 +493,13 @@ int TitleBrowser(u32 type) { int pick = WindowPrompt(tr(" Wad Saved as:"), tmptxt, tr("Install"),tr("Uninstall"),tr("Cancel")); //install or uninstall it if (pick==1) - { - + { HaltGui(); w.Remove(&titleTxt); w.Remove(&cancelBtn); w.Remove(&wifiBtn); w.Remove(&optionBrowser3); - ResumeGui(); + ResumeGui(); Wad_Install(file); diff --git a/source/prompts/filebrowser.cpp b/source/prompts/filebrowser.cpp index 8ea70d9b..f1e382f9 100644 --- a/source/prompts/filebrowser.cpp +++ b/source/prompts/filebrowser.cpp @@ -77,7 +77,7 @@ int InitBrowsers() { char rootdir[ROOTDIRLEN]; for(int i=3; iname, "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 @@ -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; }