From: <ka...@us...> - 2011-05-30 20:27:44
|
Revision: 5591 http://paintown.svn.sourceforge.net/paintown/?rev=5591&view=rev Author: kazzmir Date: 2011-05-30 20:27:37 +0000 (Mon, 30 May 2011) Log Message: ----------- simplify mugen fonts by not deriving from the util font Modified Paths: -------------- trunk/src/mugen/font.cpp trunk/src/mugen/font.h Modified: trunk/src/mugen/font.cpp =================================================================== --- trunk/src/mugen/font.cpp 2011-05-30 20:00:55 UTC (rev 5590) +++ trunk/src/mugen/font.cpp 2011-05-30 20:27:37 UTC (rev 5591) @@ -60,8 +60,7 @@ offsetx(0), offsety(0), pcx(NULL), -pcxsize(0), -currentBank(0){ +pcxsize(0){ std::string temp = file.path(); temp = Mugen::Util::invertSlashes(temp); Global::debug(1) << "[mugen font] Opening file '" << temp << "'" << endl; @@ -155,7 +154,7 @@ int size =0; for (unsigned int i = 0; i < str.size(); ++i){ std::map<char, FontLocation>::const_iterator loc = positions.find(str[i]); - if (loc!=positions.end()){ + if (loc != positions.end()){ size += loc->second.width + spacingx; } else { // Couldn't find a position for this character assume regular width and skip to the next character @@ -174,11 +173,13 @@ return height; } +#if 0 void MugenFont::printf( int x, int y, int xSize, int ySize, Graphics::Color color, const Graphics::Bitmap & work, const string & str, int marker, ... ) const { /* call the other printf somehow.. */ } +#endif -void MugenFont::printf( int x, int y, Graphics::Color color, const Graphics::Bitmap & work, const string & str, int marker, ... ) const{ +void MugenFont::printf(int x, int y, int bank, const Graphics::Bitmap & work, const string & str, int marker, ... ){ // Va list char buf[512]; va_list ap; @@ -189,11 +190,10 @@ const std::string newstr(buf); - map<int, Util::ReferenceCount<Graphics::Bitmap> >::const_iterator find = banks.find(currentBank); - if (find == banks.end()){ + const Util::ReferenceCount<Graphics::Bitmap> & font = changeBank(bank); + if (font == NULL){ return; } - const Util::ReferenceCount<Graphics::Bitmap> & font = find->second; int workoffsetx = 0; for (unsigned int i = 0; i < newstr.size(); ++i){ @@ -215,22 +215,18 @@ } void MugenFont::render(int x, int y, int position, int bank, const Graphics::Bitmap & work, const string & str){ - changeBank(bank); - if (banks[currentBank] == NULL){ - return; - } const int height = getHeight(); const int length = textLength(str.c_str()); switch (position){ case -1: - printf(x - length, y - height, Graphics::makeColor(0, 0, 0), work, str, 0); + printf(x - length, y - height, bank, work, str, 0); break; case 1: - printf(x, y - height, Graphics::makeColor(0, 0, 0), work, str, 0); + printf(x, y - height, bank, work, str, 0); break; case 0: default: - printf(x - (length/2), y - height, Graphics::makeColor(0, 0, 0), work, str, 0); + printf(x - (length/2), y - height, bank, work, str, 0); break; } } @@ -273,15 +269,16 @@ return bmp; } -void MugenFont::changeBank(int bank){ - if (bank < 0 || bank > (colors -1) || currentBank == bank) return; - currentBank = bank; +Util::ReferenceCount<Graphics::Bitmap> MugenFont::changeBank(int bank){ + if (bank < 0 || bank > (colors -1)){ + return NULL; + } - if (banks[currentBank] == NULL){ - banks[currentBank] = makeBank(currentBank); + if (banks[bank] == NULL){ + banks[bank] = makeBank(bank); } - // return banks[currentBank]; + return banks[bank]; } void MugenFont::load(){ Modified: trunk/src/mugen/font.h =================================================================== --- trunk/src/mugen/font.h 2011-05-30 20:00:55 UTC (rev 5590) +++ trunk/src/mugen/font.h 2011-05-30 20:27:37 UTC (rev 5591) @@ -25,7 +25,7 @@ int width; }; -class MugenFont: public Font { +class MugenFont{ public: MugenFont( const Filesystem::AbsolutePath & file ); // MugenFont( const char * file ); @@ -46,14 +46,13 @@ virtual int getHeight( const std::string & str ) const; virtual int getHeight() const; - virtual void printf( int x, int y, Graphics::Color color, const Graphics::Bitmap & work, const std::string & str, int marker, ... ) const; - virtual void printf( int x, int y, int xSize, int ySize, Graphics::Color color, const Graphics::Bitmap & work, const std::string & str, int marker, ... ) const; + virtual void printf( int x, int y, int bank, const Graphics::Bitmap & work, const std::string & str, int marker, ... ); + // virtual void printf( int x, int y, int xSize, int ySize, Graphics::Color color, const Graphics::Bitmap & work, const std::string & str, int marker, ... ) const ; virtual void render( int x, int y, int position, int bank, const Graphics::Bitmap & work, const std::string & str ); - virtual void changeBank(int bank); + virtual Util::ReferenceCount<Graphics::Bitmap> changeBank(int bank); - inline int getCurrentBank() { return currentBank; }; inline int getTotalBanks() { return colors; }; protected: @@ -81,7 +80,7 @@ // mapping positions of font in bitmap std::map< char, FontLocation> positions; - int currentBank; + // int currentBank; void load(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |