aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2009-07-05 19:58:09 +0000
committerSven Hesse2009-07-05 19:58:09 +0000
commitc88b9be2a79abf97eed1997337b450a2920afe3b (patch)
treeb2d76478462d447bce971c540b61f660d52e599b /engines
parentd6c99ae861aa857b24023ecc66bd1507fa895ecd (diff)
downloadscummvm-rg350-c88b9be2a79abf97eed1997337b450a2920afe3b.tar.gz
scummvm-rg350-c88b9be2a79abf97eed1997337b450a2920afe3b.tar.bz2
scummvm-rg350-c88b9be2a79abf97eed1997337b450a2920afe3b.zip
Reordering some methods
svn-id: r42150
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/hotspots.cpp280
-rw-r--r--engines/gob/hotspots.h14
2 files changed, 149 insertions, 145 deletions
diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp
index 7cbefcc922..2982fc101e 100644
--- a/engines/gob/hotspots.cpp
+++ b/engines/gob/hotspots.cpp
@@ -687,53 +687,6 @@ uint16 Hotspots::check(uint8 handleMouse, int16 delay) {
return Hotspots::check(handleMouse, delay, id, index);
}
-void Hotspots::printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const {
- _vm->_draw->_destSpriteX = x;
- _vm->_draw->_destSpriteY = y;
- _vm->_draw->_frontColor = color;
- _vm->_draw->_fontIndex = fontIndex;
- _vm->_draw->_textToPrint = str;
- _vm->_draw->_transparency = 1;
-
- _vm->_draw->spriteOperation(DRAW_PRINTTEXT | 0x10);
-}
-
-void Hotspots::fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const {
- _vm->_draw->_destSurface = 21;
- _vm->_draw->_destSpriteX = x;
- _vm->_draw->_destSpriteY = y;
- _vm->_draw->_spriteRight = width;
- _vm->_draw->_spriteBottom = height;
- _vm->_draw->_backColor = color;
-
- _vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10 );
-}
-
-void Hotspots::getTextCursorPos(const Video::FontDesc &font, const char *str,
- uint32 pos, uint16 x, uint16 y, uint16 width, uint16 height,
- uint16 &cursorX, uint16 &cursorY, uint16 &cursorWidth, uint16 &cursorHeight) const {
-
- if (font.charWidths) {
- // Cursor to the right of the current character
-
- cursorX = x;
- cursorY = y;
- cursorWidth = 1;
- cursorHeight = height;
-
- for (uint32 i = 0; i < pos; i++)
- cursorX += font.charWidths[str[i] - font.startItem];
-
- } else {
- // Cursor underlining the current character
-
- cursorX = x + font.itemWidth * pos;
- cursorY = y + height - 1;
- cursorWidth = font.itemWidth;
- cursorHeight = 1;
- }
-}
-
uint16 Hotspots::readString(uint16 xPos, uint16 yPos, uint16 width, uint16 height,
uint16 backColor, uint16 frontColor, char *str, uint16 fontIndex,
Type type, int16 &duration, uint16 &id, uint16 index) {
@@ -952,99 +905,6 @@ uint16 Hotspots::readString(uint16 xPos, uint16 yPos, uint16 width, uint16 heigh
}
}
-void Hotspots::updateAllTexts(const InputDesc *inputs) const {
- uint16 input = 0;
-
- for (int i = 0; i < kHotspotCount; i++) {
- const Hotspot &spot = _hotspots[i];
-
- if (spot.isEnd())
- continue;
-
- if ((spot.getState() & 0xC) != 0x8)
- continue;
-
- if (!spot.isInput())
- continue;
-
- char tempStr[256];
- strncpy0(tempStr, GET_VARO_STR(spot.key), 255);
-
- uint16 x = spot.left;
- uint16 y = spot.top;
- uint16 width = spot.right - spot.left + 1;
- uint16 height = spot.bottom - spot.top + 1;
- fillRect(x, y, width, height, inputs[input].backColor);
-
- y += (width - _vm->_draw->_fonts[_vm->_draw->_fontIndex]->itemHeight) / 2;
-
- printText(x, y, tempStr, inputs[input].fontIndex, inputs[input].frontColor);
-
- input++;
- }
-}
-
-uint16 Hotspots::findInput(uint16 input) const {
- uint16 inputIndex = 0;
- for (int i = 0; i < kHotspotCount; i++) {
- Hotspot &spot = _hotspots[i];
-
- if (!spot.isActiveInput())
- continue;
-
- if (inputIndex == input)
- return i;
-
- inputIndex++;
- }
-
- return 0xFFFF;
-}
-
-uint16 Hotspots::findClickedInput(uint16 index) const {
- for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
- Hotspot &spot = _hotspots[i];
-
- if (spot.getWindow() != 0)
- continue;
-
- if (spot.getState() & 0x4)
- continue;
-
- if (!spot.isIn(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY))
- continue;
-
- if (spot.getCursor() != 0)
- continue;
-
- if (!spot.isInput())
- continue;
-
- index = i;
- break;
- }
-
- return index;
-}
-
-uint16 Hotspots::findNthInput(uint16 n) const {
- uint16 input = 0;
-
- for (int i = 0; i < kHotspotCount; i++) {
- Hotspot &spot = _hotspots[i];
-
- if (!spot.isActiveInput())
- continue;
-
- if (i == n)
- break;
-
- input++;
- }
-
- return input;
-}
-
uint16 Hotspots::handleInput(int16 time, uint16 inputCount, uint16 &curInput,
InputDesc *inputs, uint16 &id, uint16 &index) {
@@ -1672,4 +1532,144 @@ int16 Hotspots::findCursor(uint16 x, uint16 y) const {
return cursor;
}
+uint16 Hotspots::findInput(uint16 input) const {
+ uint16 inputIndex = 0;
+ for (int i = 0; i < kHotspotCount; i++) {
+ Hotspot &spot = _hotspots[i];
+
+ if (!spot.isActiveInput())
+ continue;
+
+ if (inputIndex == input)
+ return i;
+
+ inputIndex++;
+ }
+
+ return 0xFFFF;
+}
+
+uint16 Hotspots::findClickedInput(uint16 index) const {
+ for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
+ Hotspot &spot = _hotspots[i];
+
+ if (spot.getWindow() != 0)
+ continue;
+
+ if (spot.getState() & 0x4)
+ continue;
+
+ if (!spot.isIn(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY))
+ continue;
+
+ if (spot.getCursor() != 0)
+ continue;
+
+ if (!spot.isInput())
+ continue;
+
+ index = i;
+ break;
+ }
+
+ return index;
+}
+
+uint16 Hotspots::findNthInput(uint16 n) const {
+ uint16 input = 0;
+
+ for (int i = 0; i < kHotspotCount; i++) {
+ Hotspot &spot = _hotspots[i];
+
+ if (!spot.isActiveInput())
+ continue;
+
+ if (i == n)
+ break;
+
+ input++;
+ }
+
+ return input;
+}
+
+void Hotspots::getTextCursorPos(const Video::FontDesc &font, const char *str,
+ uint32 pos, uint16 x, uint16 y, uint16 width, uint16 height,
+ uint16 &cursorX, uint16 &cursorY, uint16 &cursorWidth, uint16 &cursorHeight) const {
+
+ if (font.charWidths) {
+ // Cursor to the right of the current character
+
+ cursorX = x;
+ cursorY = y;
+ cursorWidth = 1;
+ cursorHeight = height;
+
+ for (uint32 i = 0; i < pos; i++)
+ cursorX += font.charWidths[str[i] - font.startItem];
+
+ } else {
+ // Cursor underlining the current character
+
+ cursorX = x + font.itemWidth * pos;
+ cursorY = y + height - 1;
+ cursorWidth = font.itemWidth;
+ cursorHeight = 1;
+ }
+}
+
+void Hotspots::fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const {
+ _vm->_draw->_destSurface = 21;
+ _vm->_draw->_destSpriteX = x;
+ _vm->_draw->_destSpriteY = y;
+ _vm->_draw->_spriteRight = width;
+ _vm->_draw->_spriteBottom = height;
+ _vm->_draw->_backColor = color;
+
+ _vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10 );
+}
+
+void Hotspots::printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const {
+ _vm->_draw->_destSpriteX = x;
+ _vm->_draw->_destSpriteY = y;
+ _vm->_draw->_frontColor = color;
+ _vm->_draw->_fontIndex = fontIndex;
+ _vm->_draw->_textToPrint = str;
+ _vm->_draw->_transparency = 1;
+
+ _vm->_draw->spriteOperation(DRAW_PRINTTEXT | 0x10);
+}
+
+void Hotspots::updateAllTexts(const InputDesc *inputs) const {
+ uint16 input = 0;
+
+ for (int i = 0; i < kHotspotCount; i++) {
+ const Hotspot &spot = _hotspots[i];
+
+ if (spot.isEnd())
+ continue;
+
+ if ((spot.getState() & 0xC) != 0x8)
+ continue;
+
+ if (!spot.isInput())
+ continue;
+
+ char tempStr[256];
+ strncpy0(tempStr, GET_VARO_STR(spot.key), 255);
+
+ uint16 x = spot.left;
+ uint16 y = spot.top;
+ uint16 width = spot.right - spot.left + 1;
+ uint16 height = spot.bottom - spot.top + 1;
+ fillRect(x, y, width, height, inputs[input].backColor);
+
+ y += (width - _vm->_draw->_fonts[_vm->_draw->_fontIndex]->itemHeight) / 2;
+
+ printText(x, y, tempStr, inputs[input].fontIndex, inputs[input].frontColor);
+
+ input++;
+ }
+}
+
} // End of namespace Gob
diff --git a/engines/gob/hotspots.h b/engines/gob/hotspots.h
index b47cf39980..1801a10591 100644
--- a/engines/gob/hotspots.h
+++ b/engines/gob/hotspots.h
@@ -171,7 +171,7 @@ private:
/** Which hotspot is the mouse cursor currently at? */
uint16 checkMouse(Type type, uint16 &id, uint16 &index) const;
-void checkHotspotChanged();
+ void checkHotspotChanged();
uint16 readString(uint16 xPos, uint16 yPos, uint16 width, uint16 height,
uint16 backColor, uint16 frontColor, char *str, uint16 fontIndex,
@@ -183,17 +183,21 @@ void checkHotspotChanged();
void evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
uint16 &validId, bool &hasInput, uint16 &inputCount);
- void updateAllTexts(const InputDesc *inputs) const;
-
+ // Finding certain inputs
uint16 findInput(uint16 input) const;
uint16 findClickedInput(uint16 index) const;
uint16 findNthInput(uint16 n) const;
- void printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const;
- void fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const;
+ /** Calculate the graphical cursor position. */
void getTextCursorPos(const Video::FontDesc &font, const char *str,
uint32 pos, uint16 x, uint16 y, uint16 width, uint16 height,
uint16 &cursorX, uint16 &cursorY, uint16 &cursorWidth, uint16 &cursorHeight) const;
+
+ // Drawing functions
+ void fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const;
+ void printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const;
+
+ void updateAllTexts(const InputDesc *inputs) const;
};
} // End of namespace Gob