2004-06-08 00:47:53 +00:00
|
|
|
/* BitmapText - An actor that holds a Font and draws text to the screen. */
|
|
|
|
|
|
2002-11-16 08:07:38 +00:00
|
|
|
#ifndef BITMAPTEXT_H
|
|
|
|
|
#define BITMAPTEXT_H
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2005-01-26 11:21:43 +00:00
|
|
|
#include "Actor.h"
|
|
|
|
|
class RageTexture;
|
|
|
|
|
|
2005-02-15 07:07:23 +00:00
|
|
|
class Font;
|
|
|
|
|
|
|
|
|
|
|
2005-01-31 08:05:27 +00:00
|
|
|
template<class T>
|
|
|
|
|
class LunaBitmapText : public LunaActor<T>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
LunaBitmapText() { LUA->Register( Register ); }
|
|
|
|
|
|
2005-02-12 20:29:38 +00:00
|
|
|
static int wrapwidthpixels( T* p, lua_State *L ) { p->SetWrapWidthPixels( IArg(1) ); return 0; }
|
|
|
|
|
static int maxwidth( T* p, lua_State *L ) { p->SetMaxWidth( FArg(1) ); return 0; }
|
2005-04-15 12:25:59 +00:00
|
|
|
static int maxheight( T* p, lua_State *L ) { p->SetMaxHeight( FArg(1) ); return 0; }
|
2005-02-20 07:46:52 +00:00
|
|
|
static int settext( T* p, lua_State *L ) { p->SetText( SArg(1) ); return 0; }
|
2005-05-04 21:36:22 +00:00
|
|
|
static int GetText( T* p, lua_State *L ) { lua_pushstring( L, p->GetText() ); return 1; }
|
2005-01-26 11:21:43 +00:00
|
|
|
|
2005-01-31 08:05:27 +00:00
|
|
|
static void Register(lua_State *L)
|
|
|
|
|
{
|
2005-02-12 20:29:38 +00:00
|
|
|
ADD_METHOD( wrapwidthpixels )
|
|
|
|
|
ADD_METHOD( maxwidth )
|
2005-04-15 12:25:59 +00:00
|
|
|
ADD_METHOD( maxheight )
|
2005-02-20 07:46:52 +00:00
|
|
|
ADD_METHOD( settext )
|
2005-05-04 21:36:22 +00:00
|
|
|
ADD_METHOD( GetText )
|
2005-01-31 08:05:27 +00:00
|
|
|
LunaActor<T>::Register( L );
|
|
|
|
|
}
|
|
|
|
|
};
|
2005-01-26 11:21:43 +00:00
|
|
|
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
class BitmapText : public Actor
|
2001-11-03 10:52:42 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
BitmapText();
|
2002-08-23 08:30:10 +00:00
|
|
|
virtual ~BitmapText();
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2005-02-09 05:27:51 +00:00
|
|
|
void LoadFromNode( const CString& sDir, const XNode* pNode );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2005-01-16 07:08:58 +00:00
|
|
|
bool LoadFromFont( const CString& sFontName );
|
|
|
|
|
bool LoadFromTextureAndChars( const CString& sTexturePath, const CString& sChars );
|
|
|
|
|
void SetText( const CString& sText, const CString& sAlternateText = "", int iWrapWidthPixels = -1 );
|
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 );
|
2001-11-25 04:31:44 +00:00
|
|
|
|
2004-02-14 03:38:34 +00:00
|
|
|
virtual bool EarlyAbortDraw();
|
2002-05-19 01:59:48 +00:00
|
|
|
virtual void DrawPrimitives();
|
2001-12-19 01:50:57 +00:00
|
|
|
|
2002-04-16 17:31:00 +00:00
|
|
|
void TurnRainbowOn() { m_bRainbow = true; };
|
|
|
|
|
void TurnRainbowOff() { m_bRainbow = false; };
|
2001-11-27 22:47:30 +00:00
|
|
|
|
2003-01-04 07:55:42 +00:00
|
|
|
void SetHorizAlign( HorizAlign ha );
|
|
|
|
|
void SetVertAlign( VertAlign va );
|
|
|
|
|
|
2004-08-27 13:38:39 +00:00
|
|
|
void GetLines( vector<wstring> &wTextLines ) { wTextLines = m_wTextLines; }
|
|
|
|
|
|
2005-05-03 03:37:52 +00:00
|
|
|
void SetDynamicColor( bool coloration ) { m_bColored = coloration; }
|
|
|
|
|
|
2003-11-06 07:23:22 +00:00
|
|
|
CString 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. */
|
2005-01-16 07:08:58 +00:00
|
|
|
bool StringWillUseAlternate(const CString& sText, const CString& sAlternateText) const;
|
2003-02-12 19:34:53 +00:00
|
|
|
|
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
|
|
|
public:
|
2002-03-30 20:00:13 +00:00
|
|
|
Font* m_pFont;
|
2002-09-29 05:06:18 +00:00
|
|
|
|
|
|
|
|
protected:
|
2002-02-02 05:11:12 +00:00
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
// recalculate the items below on SetText()
|
2003-11-06 07:23:22 +00:00
|
|
|
CString m_sText;
|
|
|
|
|
vector<wstring> m_wTextLines;
|
2002-12-29 22:55:26 +00:00
|
|
|
vector<int> m_iLineWidths; // in source pixels
|
2003-11-06 07:23:22 +00:00
|
|
|
int m_iWrapWidthPixels; // -1 = no wrap
|
2003-12-17 09:47:03 +00:00
|
|
|
float m_fMaxWidth;
|
2005-04-15 12:25:59 +00:00
|
|
|
float m_fMaxHeight;
|
2003-01-10 02:54:07 +00:00
|
|
|
|
2002-04-16 17:31:00 +00:00
|
|
|
bool m_bRainbow;
|
2003-01-04 07:55:42 +00:00
|
|
|
|
2005-05-03 03:37:52 +00:00
|
|
|
bool m_bColored;
|
|
|
|
|
|
|
|
|
|
struct ColorChange
|
|
|
|
|
{
|
|
|
|
|
RageColor c; //Color to change to
|
|
|
|
|
int l; //Change Location
|
|
|
|
|
};
|
|
|
|
|
vector<ColorChange> m_vColors;
|
2003-07-07 01:29:18 +00:00
|
|
|
vector<RageSpriteVertex> verts;
|
2003-01-04 07:55:42 +00:00
|
|
|
vector<RageTexture *> tex;
|
|
|
|
|
|
2005-04-19 02:14:43 +00:00
|
|
|
void AddLine( CString & sAddition, int & iWidthPixels );
|
2003-01-04 07:55:42 +00:00
|
|
|
void BuildChars();
|
|
|
|
|
void DrawChars();
|
2003-12-17 09:47:03 +00:00
|
|
|
void UpdateBaseZoom();
|
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
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|