2002-05-19 01:59:48 +00:00
|
|
|
#pragma once
|
2001-11-04 19:34:28 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-03-30 20:00:13 +00:00
|
|
|
File: BitmapText
|
2001-11-04 19:34:28 +00:00
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
Desc: An actor that holds a Font and draws text to the screen.
|
2001-11-04 19:34:28 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-03-30 20:00:13 +00:00
|
|
|
Chris Danford
|
2001-11-04 19:34:28 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Sprite.h"
|
2002-03-30 20:00:13 +00:00
|
|
|
#include "Font.h"
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
|
2002-06-29 11:59:09 +00:00
|
|
|
const int MAX_TEXT_LINES = 40;
|
2002-03-30 20:00:13 +00:00
|
|
|
const int MAX_TEXT_CHARS = MAX_NUM_QUADS;
|
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
|
|
|
{
|
2001-11-27 22:47:30 +00:00
|
|
|
protected:
|
|
|
|
|
|
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
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
bool LoadFromFont( CString sFontName );
|
|
|
|
|
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
|
2002-03-31 07:55:25 +00:00
|
|
|
void SetText( CString sText );
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
int GetWidestLineWidthInSourcePixels() { return m_iWidestLineWidth; };
|
2002-08-22 09:31:32 +00:00
|
|
|
void CropToWidth( int iWidthInSourcePixels );
|
2001-11-25 04:31:44 +00:00
|
|
|
|
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
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
protected:
|
2002-01-16 10:01:32 +00:00
|
|
|
CString m_sFontFilePath;
|
2002-03-30 20:00:13 +00:00
|
|
|
Font* m_pFont;
|
2002-02-02 05:11:12 +00:00
|
|
|
|
2002-03-30 20:00:13 +00:00
|
|
|
// recalculate the items below on SetText()
|
|
|
|
|
TCHAR m_szText[MAX_TEXT_CHARS];
|
|
|
|
|
TCHAR* m_szTextLines[MAX_TEXT_LINES]; // pointers into m_szText
|
|
|
|
|
int m_iLineLengths[MAX_TEXT_LINES]; // in characters
|
|
|
|
|
int m_iNumLines;
|
|
|
|
|
int m_iLineWidths[MAX_TEXT_LINES]; // in source pixels
|
|
|
|
|
int m_iWidestLineWidth; // in source pixels
|
|
|
|
|
|
2002-04-16 17:31:00 +00:00
|
|
|
bool m_bRainbow;
|
2001-11-03 10:52:42 +00:00
|
|
|
};
|
|
|
|
|
|