finalize 2.1.6

This commit is contained in:
dborth 2010-05-19 21:52:59 +00:00
parent 47280c60b8
commit 0893c0857b
8 changed files with 149 additions and 30 deletions

View File

@ -2,8 +2,8 @@
<app version="1"> <app version="1">
<name>Visual Boy Advance GX</name> <name>Visual Boy Advance GX</name>
<coder>Tantric</coder> <coder>Tantric</coder>
<version>2.1.5</version> <version>2.1.6</version>
<release_date>20100409</release_date> <release_date>20100519</release_date>
<short_description>GBA/GBC/GB Emulator</short_description> <short_description>GBA/GBC/GB Emulator</short_description>
<long_description>A port of Visual Boy Advance - M to the Wii.</long_description> <long_description>A port of Visual Boy Advance - M to the Wii.</long_description>
</app> </app>

View File

@ -1,7 +1,7 @@
¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ ¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤
- Visual Boy Advance GX - - Visual Boy Advance GX -
Version 2.1.5 Version 2.1.6
http://code.google.com/p/vba-wii http://code.google.com/p/vba-wii
(Under GPL License) (Under GPL License)
@ -28,6 +28,14 @@ With it you can play GBA/Game Boy Color/Game Boy games on your Wii/GameCube.
|0O×øo· UPDATE HISTORY ·oø×O0| |0O×øo· UPDATE HISTORY ·oø×O0|
`¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨' `¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨'
[2.1.6 - May 19, 2010]
* DVD support fixed
* Fixed some potential hangs when returning to menu
* Video/audio code changes
* Fixed scrolling text bug
* Other minor changes
[2.1.5 - April 9, 2010] [2.1.5 - April 9, 2010]
* Fix auto-save bug * Fix auto-save bug

View File

@ -641,6 +641,11 @@ class GuiText : public GuiElement
//!Sets the text of the GuiText element //!Sets the text of the GuiText element
//!\param t Text //!\param t Text
void SetText(const char * t); void SetText(const char * t);
//!Sets the text of the GuiText element
//!\param t UTF-8 Text
void SetWText(wchar_t * t);
//!Gets the translated text length of the GuiText element
int GetLength();
//!Sets up preset values to be used by GuiText(t) //!Sets up preset values to be used by GuiText(t)
//!Useful when printing multiple text elements, all with the same attributes set //!Useful when printing multiple text elements, all with the same attributes set
//!\param sz Font size //!\param sz Font size
@ -656,6 +661,8 @@ class GuiText : public GuiElement
//!Sets the maximum width of the drawn texture image //!Sets the maximum width of the drawn texture image
//!\param w Maximum width //!\param w Maximum width
void SetMaxWidth(int w); void SetMaxWidth(int w);
//!Gets the width of the text when rendered
int GetTextWidth();
//!Enables/disables text scrolling //!Enables/disables text scrolling
//!\param s Scrolling on/off //!\param s Scrolling on/off
void SetScroll(int s); void SetScroll(int s);

View File

@ -49,6 +49,9 @@ GuiText::GuiText(const char * t, int s, GXColor c)
origText = strdup(t); origText = strdup(t);
text = charToWideChar(gettext(t)); text = charToWideChar(gettext(t));
} }
for(int i=0; i < 20; i++)
textDyn[i] = NULL;
} }
/** /**
@ -78,6 +81,9 @@ GuiText::GuiText(const char * t)
origText = strdup(t); origText = strdup(t);
text = charToWideChar(gettext(t)); text = charToWideChar(gettext(t));
} }
for(int i=0; i < 20; i++)
textDyn[i] = NULL;
} }
/** /**
@ -93,7 +99,8 @@ GuiText::~GuiText()
if(textDynNum > 0) if(textDynNum > 0)
{ {
for(int i=0; i < textDynNum; i++) for(int i=0; i < textDynNum; i++)
delete[] textDyn[i]; if(textDyn[i])
delete[] textDyn[i];
} }
} }
@ -107,7 +114,8 @@ void GuiText::SetText(const char * t)
if(textDynNum > 0) if(textDynNum > 0)
{ {
for(int i=0; i < textDynNum; i++) for(int i=0; i < textDynNum; i++)
delete[] textDyn[i]; if(textDyn[i])
delete[] textDyn[i];
} }
origText = NULL; origText = NULL;
@ -123,6 +131,38 @@ void GuiText::SetText(const char * t)
} }
} }
void GuiText::SetWText(wchar_t * t)
{
if(origText)
free(origText);
if(text)
delete[] text;
if(textDynNum > 0)
{
for(int i=0; i < textDynNum; i++)
if(textDyn[i])
delete[] textDyn[i];
}
origText = NULL;
text = NULL;
textDynNum = 0;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
if(t)
text = wcsdup(t);
}
int GuiText::GetLength()
{
if(!text)
return 0;
return wcslen(text);
}
void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v) void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v)
{ {
presetSize = sz; presetSize = sz;
@ -142,24 +182,49 @@ void GuiText::SetMaxWidth(int width)
{ {
maxWidth = width; maxWidth = width;
if(textDynNum > 0) for(int i=0; i < textDynNum; i++)
{ {
for(int i=0; i < textDynNum; i++) if(textDyn[i])
{
delete[] textDyn[i]; delete[] textDyn[i];
textDyn[i] = NULL;
}
} }
textDynNum = 0; textDynNum = 0;
} }
int GuiText::GetTextWidth()
{
if(!text)
return 0;
if(currentSize != size)
{
ChangeFontSize(size);
if(!fontSystem[size])
fontSystem[size] = new FreeTypeGX(size);
currentSize = size;
}
return fontSystem[size]->getWidth(text);
}
void GuiText::SetWrap(bool w, int width) void GuiText::SetWrap(bool w, int width)
{ {
wrap = w; wrap = w;
maxWidth = width; maxWidth = width;
if(textDynNum > 0) for(int i=0; i < textDynNum; i++)
{ {
for(int i=0; i < textDynNum; i++) if(textDyn[i])
{
delete[] textDyn[i]; delete[] textDyn[i];
textDyn[i] = NULL;
}
} }
textDynNum = 0; textDynNum = 0;
} }
@ -168,11 +233,15 @@ void GuiText::SetScroll(int s)
if(textScroll == s) if(textScroll == s)
return; return;
if(textDynNum > 0) for(int i=0; i < textDynNum; i++)
{ {
for(int i=0; i < textDynNum; i++) if(textDyn[i])
{
delete[] textDyn[i]; delete[] textDyn[i];
textDyn[i] = NULL;
}
} }
textDynNum = 0; textDynNum = 0;
textScroll = s; textScroll = s;
@ -234,12 +303,17 @@ void GuiText::ResetText()
text = charToWideChar(gettext(origText)); text = charToWideChar(gettext(origText));
if(textDynNum > 0) for(int i=0; i < textDynNum; i++)
{ {
for(int i=0; i < textDynNum; i++) if(textDyn[i])
{
delete[] textDyn[i]; delete[] textDyn[i];
textDyn[i] = NULL;
}
} }
textDynNum = 0; textDynNum = 0;
currentSize = 0;
} }
/** /**
@ -276,7 +350,6 @@ void GuiText::Draw()
return; return;
} }
u32 maxChar = maxWidth*2.5 / (float)newSize; // approximate
u32 textlen = wcslen(text); u32 textlen = wcslen(text);
if(wrap) if(wrap)
@ -298,7 +371,7 @@ void GuiText::Draw()
if(text[ch] == ' ' || ch == textlen-1) if(text[ch] == ' ' || ch == textlen-1)
{ {
if(wcslen(textDyn[linenum]) >= maxChar) if(fontSystem[currentSize]->getWidth(textDyn[linenum]) > maxWidth)
{ {
if(lastSpace >= 0) if(lastSpace >= 0)
{ {
@ -344,14 +417,15 @@ void GuiText::Draw()
{ {
textDynNum = 1; textDynNum = 1;
textDyn[0] = wcsdup(text); textDyn[0] = wcsdup(text);
int len = wcslen(textDyn[0]);
if(textlen > maxChar) while(fontSystem[currentSize]->getWidth(textDyn[0]) > maxWidth)
textDyn[0][maxChar] = 0; textDyn[0][--len] = 0;
} }
if(textScroll == SCROLL_HORIZONTAL) if(textScroll == SCROLL_HORIZONTAL)
{ {
if(textlen > maxChar && (FrameTimer % textScrollDelay == 0)) if(fontSystem[currentSize]->getWidth(text) > maxWidth && (FrameTimer % textScrollDelay == 0))
{ {
if(textScrollInitialDelay) if(textScrollInitialDelay)
{ {
@ -366,15 +440,36 @@ void GuiText::Draw()
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
} }
wcsncpy(textDyn[0], &text[textScrollPos], maxChar-1); wcscpy(textDyn[0], &text[textScrollPos]);
u32 dynlen = wcslen(textDyn[0]); u32 dynlen = wcslen(textDyn[0]);
if(dynlen+2 < maxChar) if(dynlen+2 < textlen)
{ {
textDyn[0][dynlen] = ' '; textDyn[0][dynlen] = ' ';
textDyn[0][dynlen+1] = ' '; textDyn[0][dynlen+1] = ' ';
wcsncat(&textDyn[0][dynlen+2], text, maxChar - dynlen - 2); textDyn[0][dynlen+2] = 0;
dynlen += 2;
}
if(fontSystem[currentSize]->getWidth(textDyn[0]) > maxWidth)
{
while(fontSystem[currentSize]->getWidth(textDyn[0]) > maxWidth)
textDyn[0][--dynlen] = 0;
}
else
{
int i = 0;
while(fontSystem[currentSize]->getWidth(textDyn[0]) < maxWidth && dynlen+1 < textlen)
{
textDyn[0][dynlen] = text[i++];
textDyn[0][++dynlen] = 0;
}
if(fontSystem[currentSize]->getWidth(textDyn[0]) > maxWidth)
textDyn[0][dynlen-2] = 0;
else
textDyn[0][dynlen-1] = 0;
} }
} }
} }

View File

@ -38,6 +38,13 @@ void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize)
fontSystem[i] = NULL; fontSystem[i] = NULL;
} }
void DeinitFreeType()
{
ClearFontData();
FT_Done_FreeType(ftLibrary);
ftLibrary = NULL;
}
void ChangeFontSize(FT_UInt pixelSize) void ChangeFontSize(FT_UInt pixelSize)
{ {
FT_Set_Pixel_Sizes(ftFace, 0, pixelSize); FT_Set_Pixel_Sizes(ftFace, 0, pixelSize);
@ -544,10 +551,10 @@ uint16_t FreeTypeGX::getWidth(wchar_t *text)
std::map<wchar_t, ftgxCharData>::iterator thisEnd =this->fontData.end(); std::map<wchar_t, ftgxCharData>::iterator thisEnd =this->fontData.end();
for (uint32_t i = 0; i < strLength; ++i){ for (uint32_t i = 0; i < strLength; ++i)
{
ftgxCharData* glyphData = NULL; ftgxCharData* glyphData = NULL;
if( this->fontData.find(text[i]) != thisEnd) if(this->fontData.find(text[i]) != thisEnd)
{ {
glyphData = &this->fontData[text[i]]; glyphData = &this->fontData[text[i]];
} }
@ -560,7 +567,7 @@ uint16_t FreeTypeGX::getWidth(wchar_t *text)
{ {
if(this->ftKerningEnabled && (i > 0)) if(this->ftKerningEnabled && (i > 0))
{ {
FT_Get_Kerning( ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta ); FT_Get_Kerning(ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta);
strWidth += pairDelta.x >> 6; strWidth += pairDelta.x >> 6;
} }
strWidth += glyphData->glyphAdvanceX; strWidth += glyphData->glyphAdvanceX;

View File

@ -155,13 +155,14 @@
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_BITMAP_H #include FT_BITMAP_H
#include "Metaphrasis.h"
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
#include <map> #include <map>
#include "Metaphrasis.h"
#define MAX_FONT_SIZE 100 #define MAX_FONT_SIZE 100
/*! \struct ftgxCharData_ /*! \struct ftgxCharData_
@ -236,6 +237,7 @@ typedef struct ftgxDataOffset_ ftgxDataOffset;
const GXColor ftgxWhite = (GXColor){0xff, 0xff, 0xff, 0xff}; /**< Constant color value used only to sanitize Doxygen documentation. */ const GXColor ftgxWhite = (GXColor){0xff, 0xff, 0xff, 0xff}; /**< Constant color value used only to sanitize Doxygen documentation. */
void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize); void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize);
void DeinitFreeType();
void ChangeFontSize(FT_UInt pixelSize); void ChangeFontSize(FT_UInt pixelSize);
wchar_t* charToWideChar(const char* p); wchar_t* charToWideChar(const char* p);
void ClearFontData(); void ClearFontData();

View File

@ -16,7 +16,7 @@
#include "utils/FreeTypeGX.h" #include "utils/FreeTypeGX.h"
#define APPNAME "Visual Boy Advance GX" #define APPNAME "Visual Boy Advance GX"
#define APPVERSION "2.1.5" #define APPVERSION "2.1.6"
#define APPFOLDER "vbagx" #define APPFOLDER "vbagx"
#define PREF_FILE_NAME "settings.xml" #define PREF_FILE_NAME "settings.xml"
#define PAL_FILE_NAME "palettes.xml" #define PAL_FILE_NAME "palettes.xml"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app version="2.1.5"> <app version="2.1.6">
<file url="http://vba-wii.googlecode.com/files/Visual%20Boy%20Advance%20GX%202.1.5.zip"></file> <file url="http://vba-wii.googlecode.com/files/Visual%20Boy%20Advance%20GX%202.1.6.zip"></file>
</app> </app>