[Scummvm-cvs-logs] scummvm master -> db2baa6f06fbc8382d75f2c6855dc6fecee62d5e

urukgit urukgit at users.noreply.github.com
Tue Feb 11 22:35:08 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
db2baa6f06 AVALANCHE: Partially implement Help::getMe().


Commit: db2baa6f06fbc8382d75f2c6855dc6fecee62d5e
    https://github.com/scummvm/scummvm/commit/db2baa6f06fbc8382d75f2c6855dc6fecee62d5e
Author: uruk (koppirnyo at gmail.com)
Date: 2014-02-11T13:34:27-08:00

Commit Message:
AVALANCHE: Partially implement Help::getMe().

The drawing of the buttons are still missing.

Changed paths:
    engines/avalanche/graphics.cpp
    engines/avalanche/graphics.h
    engines/avalanche/help.cpp
    engines/avalanche/help.h



diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index 8699ad1..9a6e48c 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -352,6 +352,25 @@ void GraphicManager::drawNormalText(const Common::String text, FontType font, by
 	drawText(_surface, text, font, fontHeight, x, y, color);
 }
 
+/**
+ * Used in Help. Draws text double the size of the normal.
+ */
+void GraphicManager::drawBigText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color) {
+	for (uint i = 0; i < text.size(); i++) {
+		for (int j = 0; j < fontHeight; j++) {
+			byte pixel = font[(byte)text[i]][j];
+			byte pixelBit = 0;
+			for (int bit = 0; bit < 16; bit++) {
+				if ((bit % 2) == 0)
+					pixelBit = (pixel >> (bit / 2)) & 1;
+				for (int k = 0; k < 2; k++) 
+					if (pixelBit) 
+						*(byte *)_surface.getBasePtr(x + i * 16 + 16 - bit, y + j * 2 + k) = color;
+			}
+		}
+	}
+}
+
 void GraphicManager::drawScrollText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color) {
 	drawText(_scrolls, text, font, fontHeight, x, y, color);
 }
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index 822b4c7..71f1a09 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -67,6 +67,7 @@ public:
 	void drawFilledRectangle(Common::Rect rect, Color color);
 	void drawRectangle(Common::Rect rect, Color color);
 	void drawNormalText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
+	void drawBigText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color); // Very similar to drawText. TODO: Try to unify the two.
 	void drawScrollText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
 	void drawDigit(int index, int x, int y);
 	void drawDirection(int index, int x, int y);
diff --git a/engines/avalanche/help.cpp b/engines/avalanche/help.cpp
index 0588b28..a34ac4c 100644
--- a/engines/avalanche/help.cpp
+++ b/engines/avalanche/help.cpp
@@ -43,12 +43,64 @@ void Help::plotButton(int8 y, byte which) {
 }
 
 void Help::getMe(byte which) {
+	
+	_highlightWas = 177; // Forget where the highlight was.
+
+	Common::File file;
+
+	if (!file.open("help.avd"))
+		error("AVALANCHE: Help: File not found: help.avd");
+
+	file.seek(which * 2);
+	uint16 offset = file.readUint16LE();
+	file.seek(offset);
+
+	Common::String title = getLine(file);
+
+	_vm->_graphics->drawFilledRectangle(Common::Rect(0, 0, 640, 200), kColorBlue);
+	_vm->_graphics->drawFilledRectangle(Common::Rect(8, 40, 450, 200), kColorWhite);
+
+	byte index = file.readByte();
+	plotButton(-177, index);
+
+	// Plot the title:
+	_vm->_graphics->drawNormalText(title, _vm->_font, 8, 629 - 8 * title.size(), 26, kColorBlack);
+	_vm->_graphics->drawNormalText(title, _vm->_font, 8, 630 - 8 * title.size(), 25, kColorCyan);
+
+	_vm->_graphics->drawBigText("help!", _vm->_font, 8, 549, 1, kColorBlack);
+	_vm->_graphics->drawBigText("help!", _vm->_font, 8, 550, 0, kColorCyan);
+	
+	byte y = 0;
+	do {
+		Common::String line = getLine(file);
+		if (!line.empty()) {
+			if (line.compareTo(Common::String('!')) == 0)  // End of the help text is signalled with a '!'.
+				break;
+			if (line[0] == '\\') {
+				line.deleteChar(0);
+				_vm->_graphics->drawNormalText(line, _vm->_font, 8, 16, 41 + y * 10, kColorRed);
+			}
+			else
+				_vm->_graphics->drawNormalText(line, _vm->_font, 8, 16, 41 + y * 10, kColorBlack);
+		}
+		y++;
+	} while (true);
+
 	warning("STUB: Help::getMe()");
+
+	_vm->_graphics->refreshScreen();
+
+	file.close();
 }
 
-Common::String Help::getLine() {
-	warning("STUB: Help::getLine()");
-	return "STUB: Help::getLine()";
+Common::String Help::getLine(Common::File &file) {
+	Common::String line;
+	byte length = file.readByte();
+	for (int i = 0; i < length; i++) {
+		char c = file.readByte();
+		line += (c ^ 177);
+	}
+	return line;
 }
 
 byte Help::checkMouse() {
diff --git a/engines/avalanche/help.h b/engines/avalanche/help.h
index f2a2656..912927a 100644
--- a/engines/avalanche/help.h
+++ b/engines/avalanche/help.h
@@ -51,7 +51,7 @@ private:
 
 	void plotButton(int8 y, byte which);
 	void getMe(byte which);
-	Common::String getLine(); // It was a nested function in getMe().
+	Common::String getLine(Common::File &file); // It was a nested function in getMe().
 	byte checkMouse(); // Returns clicked-on button, or 0 if none.
 	void continueHelp();
 };






More information about the Scummvm-git-logs mailing list