diff options
| author | Nipun Garg | 2019-07-11 02:24:12 +0530 | 
|---|---|---|
| committer | Eugene Sandulenko | 2019-09-03 17:17:17 +0200 | 
| commit | 69e4668422e0e7f3e6887de49d63b8d1a65846a5 (patch) | |
| tree | 9ff47713eedfe1b5f56d336812ca708a66ee7472 | |
| parent | 6f4e80b836823a5b4731dc3a29c0e8bc9e4ce92e (diff) | |
| download | scummvm-rg350-69e4668422e0e7f3e6887de49d63b8d1a65846a5.tar.gz scummvm-rg350-69e4668422e0e7f3e6887de49d63b8d1a65846a5.tar.bz2 scummvm-rg350-69e4668422e0e7f3e6887de49d63b8d1a65846a5.zip | |
HDB: Add centerPrint()
| -rw-r--r-- | engines/hdb/gfx.cpp | 14 | ||||
| -rw-r--r-- | engines/hdb/gfx.h | 1 | 
2 files changed, 15 insertions, 0 deletions
| diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp index ddee59fcb9..57a3d28f94 100644 --- a/engines/hdb/gfx.cpp +++ b/engines/hdb/gfx.cpp @@ -732,6 +732,20 @@ int Gfx::stringLength(const char *string) {  	return w;  } +void Gfx::centerPrint(const char *string) { +	int totalWidth = 0, i; + +	for (i = 0; i < (int)strlen(string); i++) { +		if (string[i] == ' ') +			totalWidth += kFontSpace; +		else if (string[i] != '\n') +			totalWidth += _charInfoBlocks[string[i]]->width; +	} + +	setCursor(kScreenWidth / 2 - totalWidth / 2, _cursorX); +	drawText(string); +} +  void Gfx::setTextEdges(int left, int right, int top, int bottom) {  	_eLeft = left;  	_eRight = right; diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h index d057caeca7..d113df4a58 100644 --- a/engines/hdb/gfx.h +++ b/engines/hdb/gfx.h @@ -144,6 +144,7 @@ public:  	void drawText(const char *string);  	void getDimensions(const char *string, int *pixelsWide, int *lines);  	int stringLength(const char *string); +	void centerPrint(const char *string);  	void setTextEdges(int left, int right, int top, int bottom);  	void getTextEdges(int *left, int *right, int *top, int *bottom);  	void setKernLead(int kern, int lead); | 
