2001-11-04 19:34:28 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
File: BitmapText.h
|
|
|
|
|
|
|
|
|
|
Desc: A font class that draws characters from a bitmap.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001 Chris Danford. All rights reserved.
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
#ifndef _BITMAPTEXT_H_
|
|
|
|
|
#define _BITMAPTEXT_H_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Sprite.h"
|
|
|
|
|
#include "BitmapText.h"
|
|
|
|
|
|
2001-11-27 22:47:30 +00:00
|
|
|
|
|
|
|
|
const int NUM_CHARS = 256;
|
2001-11-03 10:52:42 +00:00
|
|
|
|
|
|
|
|
|
2001-11-27 22:47:30 +00:00
|
|
|
class BitmapText : public Sprite
|
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-01-16 10:01:32 +00:00
|
|
|
virtual void RenderPrimitives();
|
|
|
|
|
|
|
|
|
|
bool Load( CString sFontName );
|
2001-12-28 10:15:59 +00:00
|
|
|
void SetText( CString sText );
|
|
|
|
|
CString GetText();
|
2001-11-03 10:52:42 +00:00
|
|
|
|
2001-11-27 22:47:30 +00:00
|
|
|
bool LoadFontWidths( CString sFilePath );
|
|
|
|
|
|
2001-12-28 10:15:59 +00:00
|
|
|
float GetWidestLineWidthInSourcePixels(); // in logical, pre-zoomed units
|
|
|
|
|
float GetLineWidthInSourcePixels( int iLineNo );
|
2001-12-19 01:50:57 +00:00
|
|
|
|
2001-11-03 10:52:42 +00:00
|
|
|
protected:
|
2001-11-27 22:47:30 +00:00
|
|
|
bool LoadCharWidths( CString sWidthFilePath );
|
2002-02-02 05:11:12 +00:00
|
|
|
// a vertex buffer for all to share
|
2001-11-27 22:47:30 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
CString m_sFontFilePath;
|
|
|
|
|
int m_iCharToFrameNo[NUM_CHARS];
|
|
|
|
|
float m_fFrameNoToWidth[NUM_CHARS]; // in soure coordinate space
|
2001-12-28 10:15:59 +00:00
|
|
|
|
2002-02-02 05:11:12 +00:00
|
|
|
|
|
|
|
|
LPDIRECT3DVERTEXBUFFER8 m_pVB; // our vertex buffer only needs to be rebuilt when the text changes
|
|
|
|
|
int m_iNumVerticies;
|
|
|
|
|
RebuildVertexBuffer(); // this should be called when the
|
|
|
|
|
|
2001-12-28 10:15:59 +00:00
|
|
|
CStringArray m_sTextLines;
|
2001-11-03 10:52:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|