2009-04-16 11:14:13 +00:00
#ifndef __CMESSAGE_H__
#define __CMESSAGE_H__
2010-02-04 15:50:59 +00:00
#include "FontBase.h"
2009-05-20 10:08:56 +00:00
#include "../global.h"
2011-02-06 17:26:27 +00:00
//#include <SDL.h>
2010-07-06 02:10:26 +00:00
#include <boost/function.hpp>
2009-04-16 11:14:13 +00:00
2009-04-15 14:03:31 +00:00
/*
* CMessage.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
2009-04-16 11:14:13 +00:00
*/
2011-02-06 17:26:27 +00:00
struct SDL_Surface ;
2009-04-16 11:14:13 +00:00
enum EWindowType { infoOnly , infoOK , yesOrNO };
class CPreGame ;
class MapSel ;
class CSimpleWindow ;
class CInfoWindow ;
class CDefHandler ;
class SComponent ;
class CSelWindow ;
class CSelectableComponent ;
namespace NMessage
{
extern CDefHandler * ok , * cancel ;
extern std :: vector < std :: vector < SDL_Surface *> > piecesOfBox ; //in colors of all players
extern SDL_Surface * background ;
}
struct ComponentResolved
{
SComponent * comp ;
SDL_Surface * img ;
std :: vector < std :: vector < SDL_Surface *> > * txt ;
2009-06-01 05:40:54 +00:00
int txtFontHeight ;
2009-04-16 11:14:13 +00:00
2009-05-07 17:20:41 +00:00
ComponentResolved (); //c-tor
ComponentResolved ( SComponent * Comp ); //c-tor
~ ComponentResolved (); //d-tor
2009-04-16 11:14:13 +00:00
};
struct ComponentsToBlit
{
std :: vector < std :: vector < ComponentResolved *> > comps ;
int w , h ;
void blitCompsOnSur ( SDL_Surface * _or , int inter , int & curh , SDL_Surface * ret );
2009-05-07 17:20:41 +00:00
ComponentsToBlit ( std :: vector < SComponent *> & SComps , int maxw , SDL_Surface * _or ); //c-tor
~ ComponentsToBlit (); //d-tor
2009-04-16 11:14:13 +00:00
};
2011-02-22 11:52:36 +00:00
/// Class which draws formatted text messages and generates chat windows
2009-04-16 11:14:13 +00:00
class CMessage
{
public :
2009-06-01 05:40:54 +00:00
static std :: pair < int , int > getMaxSizes ( std :: vector < std :: vector < SDL_Surface *> > * txtg , int fontHeight );
2010-02-04 15:50:59 +00:00
static std :: vector < std :: vector < SDL_Surface *> > * drawText ( std :: vector < std :: string > * brtext , int & fontHeigh , EFonts font = FONT_MEDIUM );
2009-06-01 05:40:54 +00:00
static SDL_Surface * blitTextOnSur ( std :: vector < std :: vector < SDL_Surface *> > * txtg , int fontHeight , int & curh , SDL_Surface * ret , int xCenterPos =- 1 ); //xPos==-1 works as if ret->w/2
2010-07-26 15:37:58 +00:00
static void drawIWindow ( CInfoWindow * ret , std :: string text , int player );
2009-10-22 00:25:39 +00:00
static CSimpleWindow * genWindow ( std :: string text , int player , bool centerOnMouse = false , int Lmar = 35 , int Rmar = 35 , int Tmar = 35 , int Bmar = 35 ); //supports h3 text formatting; player sets color of window, Lmar/Rmar/Tmar/Bmar are Left/Right/Top/Bottom margins
2009-04-16 11:14:13 +00:00
static SDL_Surface * drawBox1 ( int w , int h , int playerColor = 1 );
static void drawBorder ( int playerColor , SDL_Surface * ret , int w , int h , int x = 0 , int y = 0 );
static SDL_Surface * drawBoxTextBitmapSub ( int player , std :: string text , SDL_Surface * bitmap , std :: string sub , int charperline = 30 , int imgToBmp = 55 );
2010-07-06 02:10:26 +00:00
static std :: vector < std :: string > breakText ( std :: string text , size_t maxLineSize = 30 , const boost :: function < int ( char ) > & charMetric = boost :: function < int ( char ) > (), bool allowLeadingWhitespace = false );
static std :: vector < std :: string > breakText ( std :: string text , size_t maxLineWidth , EFonts font );
2009-04-16 11:14:13 +00:00
static void init ();
static void dispose ();
};
//
#endif // __CMESSAGE_H__