2004-06-08 00:47:53 +00:00
|
|
|
/* BitmapText - An actor that holds a Font and draws text to the screen. */
|
|
|
|
|
|
2007-08-18 22:16:05 +00:00
|
|
|
#ifndef BITMAP_TEXT_H
|
|
|
|
|
#define BITMAP_TEXT_H
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2005-01-26 11:21:43 +00:00
|
|
|
#include "Actor.h"
|
2007-08-18 22:16:05 +00:00
|
|
|
#include <map>
|
2005-01-26 11:21:43 +00:00
|
|
|
|
2007-08-18 22:16:05 +00:00
|
|
|
class RageTexture;
|
2005-02-15 07:07:23 +00:00
|
|
|
class Font;
|
2008-02-15 09:31:54 +00:00
|
|
|
struct FontPageTextures;
|
2005-02-15 07:07:23 +00:00
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
class BitmapText : public Actor
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
BitmapText();
|
2005-07-15 03:50:56 +00:00
|
|
|
BitmapText( const BitmapText &cpy );
|
2008-05-27 17:40:30 +00:00
|
|
|
BitmapText &operator=(const BitmapText &cpy);
|
2002-08-23 08:30:10 +00:00
|
|
|
virtual ~BitmapText();
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2006-10-09 08:24:10 +00:00
|
|
|
virtual void LoadFromNode( const XNode* pNode );
|
2006-10-20 00:17:51 +00:00
|
|
|
virtual BitmapText *Copy() const;
|
2002-03-30 20:00:13 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
bool LoadFromFont( const RString& sFontName );
|
|
|
|
|
bool LoadFromTextureAndChars( const RString& sTexturePath, const RString& sChars );
|
2007-06-09 07:56:34 +00:00
|
|
|
virtual void SetText( const RString& sText, const RString& sAlternateText = "", int iWrapWidthPixels = -1 );
|
2006-01-24 01:12:54 +00:00
|
|
|
void SetVertSpacing( int iSpacing );
|
2005-04-15 12:25:59 +00:00
|
|
|
void SetMaxWidth( float fMaxWidth );
|
|
|
|
|
void SetMaxHeight( float fMaxHeight );
|
2003-11-06 07:23:22 +00:00
|
|
|
void SetWrapWidthPixels( int iWrapWidthPixels );
|
2002-08-22 09:31:32 +00:00
|
|
|
void CropToWidth( int iWidthInSourcePixels );
|
2002-03-30 20:00:13 +00:00
|
|
|
|
2005-08-25 00:57:53 +00:00
|
|
|
virtual bool EarlyAbortDraw() const;
|
2002-05-19 01:59:48 +00:00
|
|
|
virtual void DrawPrimitives();
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2008-07-05 02:08:17 +00:00
|
|
|
void SetUppercase( bool b );
|
2007-02-19 09:32:07 +00:00
|
|
|
void SetRainbowScroll( bool b ) { m_bRainbowScroll = b; }
|
2006-12-07 07:49:22 +00:00
|
|
|
void SetJitter( bool b ) { m_bJitter = b; }
|
2001-12-19 01:50:57 +00:00
|
|
|
|
2007-03-01 08:14:33 +00:00
|
|
|
void SetHorizAlign( float f );
|
2003-01-04 07:55:42 +00:00
|
|
|
|
2008-02-15 09:31:54 +00:00
|
|
|
void SetStrokeColor( RageColor c ) { m_StrokeColor = c; }
|
2008-08-17 14:34:53 +00:00
|
|
|
RageColor GetStrokeColor() { return m_StrokeColor; }
|
2008-02-15 09:31:54 +00:00
|
|
|
|
2007-08-18 22:16:05 +00:00
|
|
|
void GetLines( vector<wstring> &wTextLines ) const { wTextLines = m_wTextLines; }
|
|
|
|
|
const vector<wstring> &GetLines() const { return m_wTextLines; }
|
2004-08-27 13:38:39 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString GetText() const { return m_sText; }
|
2003-02-12 20:19:20 +00:00
|
|
|
/* Return true if the string 's' will use an alternate string, if available. */
|
2006-01-22 01:00:06 +00:00
|
|
|
bool StringWillUseAlternate( const RString& sText, const RString& sAlternateText ) const;
|
2003-02-12 19:34:53 +00:00
|
|
|
|
2007-08-18 22:16:05 +00:00
|
|
|
struct Attribute
|
|
|
|
|
{
|
|
|
|
|
Attribute() : length(-1) { }
|
|
|
|
|
int length;
|
|
|
|
|
RageColor diffuse[4];
|
|
|
|
|
RageColor glow;
|
|
|
|
|
|
|
|
|
|
void FromStack( lua_State *L, int iPos );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Attribute GetDefaultAttribute() const;
|
|
|
|
|
void AddAttribute( size_t iPos, const Attribute &attr );
|
|
|
|
|
void ClearAttributes();
|
|
|
|
|
|
2005-01-26 11:21:43 +00:00
|
|
|
//
|
|
|
|
|
// Commands
|
|
|
|
|
//
|
|
|
|
|
virtual void PushSelf( lua_State *L );
|
2003-11-06 07:23:22 +00:00
|
|
|
|
2002-09-29 05:06:18 +00:00
|
|
|
protected:
|
2007-08-18 02:15:35 +00:00
|
|
|
Font *m_pFont;
|
2008-03-28 12:24:04 +00:00
|
|
|
bool m_bUppercase;
|
2006-12-07 07:49:22 +00:00
|
|
|
RString m_sText;
|
|
|
|
|
vector<wstring> m_wTextLines;
|
|
|
|
|
vector<int> m_iLineWidths; // in source pixels
|
|
|
|
|
int m_iWrapWidthPixels; // -1 = no wrap
|
2008-03-27 22:18:10 +00:00
|
|
|
float m_fMaxWidth; // 0 = no max
|
|
|
|
|
float m_fMaxHeight; // 0 = no max
|
2007-02-19 09:32:07 +00:00
|
|
|
bool m_bRainbowScroll;
|
2006-12-07 07:49:22 +00:00
|
|
|
bool m_bJitter;
|
|
|
|
|
int m_iVertSpacing;
|
2006-01-24 01:02:21 +00:00
|
|
|
|
|
|
|
|
vector<RageSpriteVertex> m_aVertices;
|
2008-02-15 09:31:54 +00:00
|
|
|
|
|
|
|
|
vector<FontPageTextures*> m_vpFontPageTextures;
|
2007-08-18 22:16:05 +00:00
|
|
|
map<size_t, Attribute> m_mAttributes;
|
2007-08-21 00:25:06 +00:00
|
|
|
bool m_bHasGlowAttribute;
|
2008-02-15 09:31:54 +00:00
|
|
|
|
|
|
|
|
RageColor m_StrokeColor;
|
2001-12-28 10:15:59 +00:00
|
|
|
|
2005-05-19 06:55:31 +00:00
|
|
|
// recalculate the items in SetText()
|
2003-01-04 07:55:42 +00:00
|
|
|
void BuildChars();
|
2008-02-15 09:31:54 +00:00
|
|
|
void DrawChars( bool bUseStrokeTexture );
|
2003-12-17 09:47:03 +00:00
|
|
|
void UpdateBaseZoom();
|
2007-08-18 22:16:05 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void SetTextInternal();
|
2001-11-03 10:52:42 +00:00
|
|
|
};
|
|
|
|
|
|
2002-11-16 08:07:38 +00:00
|
|
|
#endif
|
2004-06-08 00:47:53 +00:00
|
|
|
|
|
|
|
|
/*
|
2007-08-18 22:16:05 +00:00
|
|
|
* (c) 2001-2007 Chris Danford, Charles Lohr, Steve Checkoway
|
2004-06-08 00:47:53 +00:00
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|