Fixed a bug with skipping over unicode characters.

This commit is contained in:
Aloshi 2012-09-16 14:18:11 -05:00
parent 9901a07fb6
commit 0468e64396
7 changed files with 27 additions and 18 deletions

View file

@ -1,5 +1,5 @@
CC=g++ CC=g++
CFLAGS=-c -Wall -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_DESKTOP_ CFLAGS=-c -Wall -I/usr/include/freetype2 -I/usr/include/SDL -I/usr/include -D_DESKTOP_ -g
LDFLAGS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage LDFLAGS=-lGL -lfreetype -lSDL -lboost_system -lboost_filesystem -lfreeimage
SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp SRCSOURCES=main.cpp Renderer.cpp Renderer_init.cpp Font.cpp Renderer_draw_gl.cpp GuiComponent.cpp InputManager.cpp SystemData.cpp GameData.cpp FolderData.cpp XMLReader.cpp MathExp.cpp components/GuiGameList.cpp components/GuiInputConfig.cpp components/GuiImage.cpp components/GuiMenu.cpp components/GuiTheme.cpp pugiXML/pugixml.cpp
SOURCES=$(addprefix src/,$(SRCSOURCES)) SOURCES=$(addprefix src/,$(SRCSOURCES))

View file

@ -36,7 +36,7 @@ EmulationStation will return once your system's command terminates (i.e. your em
gamelist.xml gamelist.xml
============ ============
If a file named gamelist.xml is found in the root of a system's search directory, it will be parsed and the detailed GuiGameList will be used. This means you can define images, descriptions, and different names for files. If a file named gamelist.xml is found in the root of a system's search directory, it will be parsed and the detailed GuiGameList will be used. This means you can define images, descriptions, and different names for files. Note that only standard ASCII characters are supported (if you see a weird [X] symbol, you're probably using unicode!).
Images will be automatically resized to fit within the left column of the screen. Smaller images will load faster, so try to keep your resolution low. Images will be automatically resized to fit within the left column of the screen. Smaller images will load faster, so try to keep your resolution low.
An example gamelist.xml: An example gamelist.xml:
``` ```

View file

@ -1,3 +1,6 @@
September 16
-Fixed a bug with skipping over unicode characters. [X] will be displayed if the character is not standard ASCII (characters 32 to 127).
September 15 September 15
-Added <listOffsetX>, <listTextOffsetX>, and <gameImageOffsetY> theme tags. See THEMES.md for details. -Added <listOffsetX>, <listTextOffsetX>, and <gameImageOffsetY> theme tags. See THEMES.md for details.
-Fixed a bug causing gamelists to be read incorrectly. -Fixed a bug causing gamelists to be read incorrectly.

View file

@ -199,7 +199,7 @@ void Font::drawText(std::string text, int startx, int starty, int color)
unsigned char letter = text[i]; unsigned char letter = text[i];
if(letter < 32 || letter >= 128) if(letter < 32 || letter >= 128)
continue; letter = 127; //print [X] if character is not standard ASCII
points[p].pos0x = x; points[p].pos0y = y + charData[letter].texH - charData[letter].bearingY; points[p].pos0x = x; points[p].pos0y = y + charData[letter].texH - charData[letter].bearingY;
points[p].pos1x = x + charData[letter].texW; points[p].pos1y = y - charData[letter].bearingY; points[p].pos1x = x + charData[letter].texW; points[p].pos1y = y - charData[letter].bearingY;

View file

@ -8,12 +8,6 @@
namespace Renderer { namespace Renderer {
bool loadedFonts = false; bool loadedFonts = false;
//defined and set in Renderer_init_rpi.cpp
extern unsigned int display_width;
extern unsigned int display_height;
unsigned int getScreenWidth() { return display_width; }
unsigned int getScreenHeight() { return display_height; }
void setColor4bArray(GLubyte* array, int color) void setColor4bArray(GLubyte* array, int color)
{ {
array[0] = (color & 0x00ff0000) / 0x10000; array[0] = (color & 0x00ff0000) / 0x10000;
@ -63,7 +57,7 @@ namespace Renderer {
Font* fonts[3] = {NULL, NULL, NULL}; Font* fonts[3] = {NULL, NULL, NULL};
void loadFonts() void loadFonts()
{ {
std::cout << "loading fonts\n"; std::cout << "loading fonts...";
std::string fontPath = "LinLibertine_R.ttf"; std::string fontPath = "LinLibertine_R.ttf";
@ -85,10 +79,14 @@ namespace Renderer {
} }
loadedFonts = true; loadedFonts = true;
std::cout << "done\n";
} }
void unloadFonts() void unloadFonts()
{ {
std::cout << "unloading fonts...";
for(unsigned int i = 0; i < 3; i++) for(unsigned int i = 0; i < 3; i++)
{ {
delete fonts[i]; delete fonts[i];
@ -96,6 +94,8 @@ namespace Renderer {
} }
loadedFonts = false; loadedFonts = false;
std::cout << "done.\n";
} }
Font* getFont(FontSize size) Font* getFont(FontSize size)

View file

@ -19,10 +19,12 @@ namespace Renderer
unsigned int display_width = 0; unsigned int display_width = 0;
unsigned int display_height = 0; unsigned int display_height = 0;
unsigned int getScreenWidth() { return display_width; }
unsigned int getScreenHeight() { return display_height; }
bool createSurface() //unsigned int display_width, unsigned int display_height) bool createSurface() //unsigned int display_width, unsigned int display_height)
{ {
std::cout << "Creating surface...\n"; std::cout << "Creating surface...";
DISPMANX_ELEMENT_HANDLE_T dispman_element; DISPMANX_ELEMENT_HANDLE_T dispman_element;
DISPMANX_DISPLAY_HANDLE_T dispman_display; DISPMANX_DISPLAY_HANDLE_T dispman_display;
@ -97,7 +99,7 @@ namespace Renderer
} }
} }
std::cout << "Display size is " << display_width << "x" << display_height << ".\n"; std::cout << display_width << "x" << display_height << "...";
dst_rect.x = 0; dst_rect.y = 0; dst_rect.x = 0; dst_rect.y = 0;
@ -133,7 +135,7 @@ namespace Renderer
} }
std::cout << "Success!\n"; std::cout << "success!\n";
return true; return true;
} }

View file

@ -8,13 +8,17 @@
namespace Renderer namespace Renderer
{ {
unsigned int display_width = 0, display_height = 0; unsigned int display_width = 0;
unsigned int display_height = 0;
unsigned int getScreenWidth() { return display_width; }
unsigned int getScreenHeight() { return display_height; }
SDL_Surface* sdlScreen = NULL; SDL_Surface* sdlScreen = NULL;
bool createSurface() //unsigned int display_width, unsigned int display_height) bool createSurface() //unsigned int display_width, unsigned int display_height)
{ {
std::cout << "Creating surface...\n"; std::cout << "Creating surface...";
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0) if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
{ {
@ -27,7 +31,7 @@ namespace Renderer
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
sdlScreen = SDL_SetVideoMode(display_width, display_height, 16, SDL_OPENGL | SDL_FULLSCREEN); sdlScreen = SDL_SetVideoMode(display_width, display_height, 16, SDL_OPENGL); //SDL_FULLSCREEN
if(sdlScreen == NULL) if(sdlScreen == NULL)
{ {
@ -44,7 +48,7 @@ namespace Renderer
display_width = sdlScreen->w; display_width = sdlScreen->w;
display_height = sdlScreen->h; display_height = sdlScreen->h;
std::cout << "Success!\n"; std::cout << "success!\n";
return true; return true;
} }