aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-02-03 11:24:50 +0100
committerEugene Sandulenko2016-02-14 17:12:58 +0100
commit53e68cf92cd3dda8a428bce42015235766b0b70f (patch)
tree973576fd7bf2db5eabc0b3ca36d2de4efd177789
parentd812706328ddd31bd23b425d7d4eb7777d29ae55 (diff)
downloadscummvm-rg350-53e68cf92cd3dda8a428bce42015235766b0b70f.tar.gz
scummvm-rg350-53e68cf92cd3dda8a428bce42015235766b0b70f.tar.bz2
scummvm-rg350-53e68cf92cd3dda8a428bce42015235766b0b70f.zip
WAGE: Calculate click position in text
-rw-r--r--engines/wage/gui.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 3bd47bbbb5..733241f7a1 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -661,11 +661,23 @@ void Gui::mouseDown(int x, int y) {
void Gui::startMarking(int x, int y) {
const int firstLine = _scrollPos / _consoleLineHeight;
int textLine = (y - kConHOverlap - kConHPadding - _scrollPos % _consoleLineHeight - _consoleTextArea.top) / _consoleLineHeight + firstLine;
- int charPos = x - kConWOverlap - kConWPadding - _consoleTextArea.left;
+ int textChar = 0;
+ int charX = x - kConWOverlap - kConWPadding - _consoleTextArea.left;
+ const Graphics::Font *font = getConsoleFont();
+ Common::String str = _lines[textLine];
+
+ for (int i = str.size(); i >= 0; i--) {
+ if (font->getStringWidth(str) < charX) {
+ textChar = i;
+ break;
+ }
+
+ str.deleteLastChar();
+ }
_inTextSelection = true;
- warning("x: %d y: %d", textLine, charPos);
+ warning("x: %d y: %d", textLine, textChar);
}
} // End of namespace Wage