2009-04-15 17:03:31 +03: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 14:14:13 +03:00
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../render/Graphics.h"
|
|
|
|
#include "../../lib/GameConstants.h"
|
2016-11-10 13:03:56 +02:00
|
|
|
|
2011-02-06 19:26:27 +02:00
|
|
|
struct SDL_Surface;
|
2009-04-16 14:14:13 +03:00
|
|
|
class CInfoWindow;
|
2011-12-22 16:05:19 +03:00
|
|
|
class CComponent;
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2023-02-01 20:42:06 +02:00
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Class which draws formatted text messages and generates chat windows
|
2009-04-16 14:14:13 +03:00
|
|
|
class CMessage
|
|
|
|
{
|
2018-07-25 00:36:48 +02:00
|
|
|
/// Draw simple dialog box (borders and background only)
|
|
|
|
static SDL_Surface * drawDialogBox(int w, int h, PlayerColor playerColor = PlayerColor(1));
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2018-07-25 00:36:48 +02:00
|
|
|
public:
|
2012-05-13 18:04:21 +03:00
|
|
|
/// Draw border on exiting surface
|
2013-03-03 20:06:03 +03:00
|
|
|
static void drawBorder(PlayerColor playerColor, SDL_Surface * ret, int w, int h, int x=0, int y=0);
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
static void drawIWindow(CInfoWindow * ret, std::string text, PlayerColor player);
|
2012-05-13 18:04:21 +03:00
|
|
|
|
|
|
|
/// split text in lines
|
2010-07-06 05:10:26 +03:00
|
|
|
static std::vector<std::string> breakText(std::string text, size_t maxLineWidth, EFonts font);
|
2012-05-13 18:04:21 +03:00
|
|
|
|
2023-03-07 02:29:04 +02:00
|
|
|
/// Try to guess a header of a message
|
|
|
|
static std::string guessHeader(const std::string & msg);
|
|
|
|
|
|
|
|
/// For convenience
|
|
|
|
static int guessHeight(const std::string & string, int width, EFonts fnt);
|
|
|
|
|
2023-03-12 21:31:23 +02:00
|
|
|
static int getEstimatedComponentHeight(int numComps);
|
2012-05-13 18:04:21 +03:00
|
|
|
/// constructor
|
2009-04-16 14:14:13 +03:00
|
|
|
static void init();
|
2012-05-13 18:04:21 +03:00
|
|
|
/// destructor
|
2009-04-16 14:14:13 +03:00
|
|
|
static void dispose();
|
|
|
|
};
|