aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/ui
diff options
context:
space:
mode:
authorPeter Kohaut2019-03-12 22:13:25 +0100
committerPeter Kohaut2019-03-12 22:37:12 +0100
commitd605a250814a0603fe6ede7e5654ab8b222d7acc (patch)
tree8fae1cd464e1502ce18cf525e1f32a7c29eecf7b /engines/bladerunner/ui
parentefa9717c691ef488f7b0ab3f04bd71b734b881e5 (diff)
downloadscummvm-rg350-d605a250814a0603fe6ede7e5654ab8b222d7acc.tar.gz
scummvm-rg350-d605a250814a0603fe6ede7e5654ab8b222d7acc.tar.bz2
scummvm-rg350-d605a250814a0603fe6ede7e5654ab8b222d7acc.zip
BLADERUNNER: Added support for scrolling with mouse wheel
Not in the original game
Diffstat (limited to 'engines/bladerunner/ui')
-rw-r--r--engines/bladerunner/ui/kia.cpp9
-rw-r--r--engines/bladerunner/ui/kia.h1
-rw-r--r--engines/bladerunner/ui/kia_section_base.h1
-rw-r--r--engines/bladerunner/ui/kia_section_clues.cpp4
-rw-r--r--engines/bladerunner/ui/kia_section_clues.h13
-rw-r--r--engines/bladerunner/ui/kia_section_crimes.cpp4
-rw-r--r--engines/bladerunner/ui/kia_section_crimes.h13
-rw-r--r--engines/bladerunner/ui/kia_section_diagnostic.h6
-rw-r--r--engines/bladerunner/ui/kia_section_help.cpp4
-rw-r--r--engines/bladerunner/ui/kia_section_help.h15
-rw-r--r--engines/bladerunner/ui/kia_section_load.cpp4
-rw-r--r--engines/bladerunner/ui/kia_section_load.h1
-rw-r--r--engines/bladerunner/ui/kia_section_pogo.h4
-rw-r--r--engines/bladerunner/ui/kia_section_save.cpp7
-rw-r--r--engines/bladerunner/ui/kia_section_save.h1
-rw-r--r--engines/bladerunner/ui/kia_section_settings.h14
-rw-r--r--engines/bladerunner/ui/kia_section_suspects.cpp4
-rw-r--r--engines/bladerunner/ui/kia_section_suspects.h13
-rw-r--r--engines/bladerunner/ui/ui_component.h1
-rw-r--r--engines/bladerunner/ui/ui_container.cpp7
-rw-r--r--engines/bladerunner/ui/ui_container.h1
-rw-r--r--engines/bladerunner/ui/ui_scroll_box.cpp17
-rw-r--r--engines/bladerunner/ui/ui_scroll_box.h11
23 files changed, 114 insertions, 41 deletions
diff --git a/engines/bladerunner/ui/kia.cpp b/engines/bladerunner/ui/kia.cpp
index be64131d34..af26851b27 100644
--- a/engines/bladerunner/ui/kia.cpp
+++ b/engines/bladerunner/ui/kia.cpp
@@ -434,6 +434,15 @@ void KIA::handleMouseUp(int mouseX, int mouseY, bool mainButton) {
}
}
+void KIA::handleMouseScroll(int mouseX, int mouseY, int direction) {
+ if (!isOpen()) {
+ return;
+ }
+ if (_currentSection) {
+ _currentSection->handleMouseScroll(direction);
+ }
+}
+
void KIA::handleKeyUp(const Common::KeyState &kbd) {
if (!isOpen()) {
return;
diff --git a/engines/bladerunner/ui/kia.h b/engines/bladerunner/ui/kia.h
index c6d612f0df..47ea63946d 100644
--- a/engines/bladerunner/ui/kia.h
+++ b/engines/bladerunner/ui/kia.h
@@ -141,6 +141,7 @@ public:
void handleMouseDown(int mouseX, int mouseY, bool mainButton);
void handleMouseUp(int mouseX, int mouseY, bool mainButton);
+ void handleMouseScroll(int mouseX, int mouseY, int direction); // Added by ScummVM team
void handleKeyUp(const Common::KeyState &kbd);
void handleKeyDown(const Common::KeyState &kbd);
diff --git a/engines/bladerunner/ui/kia_section_base.h b/engines/bladerunner/ui/kia_section_base.h
index 988d223105..b1a72916ac 100644
--- a/engines/bladerunner/ui/kia_section_base.h
+++ b/engines/bladerunner/ui/kia_section_base.h
@@ -55,6 +55,7 @@ public:
virtual void handleMouseMove(int mouseX, int mouseY) {}
virtual void handleMouseDown(bool mainButton) {}
virtual void handleMouseUp(bool mainButton) {}
+ virtual void handleMouseScroll(int direction) {} // Added by ScummVM team
protected:
virtual void onButtonPressed(int buttonId) {}
diff --git a/engines/bladerunner/ui/kia_section_clues.cpp b/engines/bladerunner/ui/kia_section_clues.cpp
index 7485d8ebcb..0157d72c48 100644
--- a/engines/bladerunner/ui/kia_section_clues.cpp
+++ b/engines/bladerunner/ui/kia_section_clues.cpp
@@ -186,6 +186,10 @@ void KIASectionClues::handleMouseUp(bool mainButton) {
}
}
+void KIASectionClues::handleMouseScroll(int direction) {
+ _uiContainer->handleMouseScroll(direction);
+}
+
void KIASectionClues::saveToLog() {
_vm->_kia->_log->add(0, sizeof(bool) * _filterCount, _filters.data());
}
diff --git a/engines/bladerunner/ui/kia_section_clues.h b/engines/bladerunner/ui/kia_section_clues.h
index eb43f60102..991010267f 100644
--- a/engines/bladerunner/ui/kia_section_clues.h
+++ b/engines/bladerunner/ui/kia_section_clues.h
@@ -68,14 +68,15 @@ public:
void reset();
- void open();
- void close();
+ void open() override;
+ void close() override;
- void draw(Graphics::Surface &surface);
+ void draw(Graphics::Surface &surface) override;
- void handleMouseMove(int mouseX, int mouseY);
- void handleMouseDown(bool mainButton);
- void handleMouseUp(bool mainButton);
+ void handleMouseMove(int mouseX, int mouseY) override;
+ void handleMouseDown(bool mainButton) override;
+ void handleMouseUp(bool mainButton) override;
+ void handleMouseScroll(int direction) override;
void saveToLog();
void loadFromLog();
diff --git a/engines/bladerunner/ui/kia_section_crimes.cpp b/engines/bladerunner/ui/kia_section_crimes.cpp
index ff6352b3e0..3d82056a3b 100644
--- a/engines/bladerunner/ui/kia_section_crimes.cpp
+++ b/engines/bladerunner/ui/kia_section_crimes.cpp
@@ -210,6 +210,10 @@ void KIASectionCrimes::handleMouseUp(bool mainButton) {
_uiContainer->handleMouseUp(!mainButton);
}
+void KIASectionCrimes::handleMouseScroll(int direction) {
+ _uiContainer->handleMouseScroll(direction);
+}
+
void KIASectionCrimes::saveToLog() {
int data[] = { _crimeSelected, _suspectSelected };
_vm->_kia->_log->add(2, sizeof(data), &data);
diff --git a/engines/bladerunner/ui/kia_section_crimes.h b/engines/bladerunner/ui/kia_section_crimes.h
index bd2a2f2d80..1bc3f88e4a 100644
--- a/engines/bladerunner/ui/kia_section_crimes.h
+++ b/engines/bladerunner/ui/kia_section_crimes.h
@@ -81,14 +81,15 @@ public:
void reset();
- void open();
- void close();
+ void open() override;
+ void close() override;
- void draw(Graphics::Surface &surface);
+ void draw(Graphics::Surface &surface) override;
- void handleMouseMove(int mouseX, int mouseY);
- void handleMouseDown(bool mainButton);
- void handleMouseUp(bool mainButton);
+ void handleMouseMove(int mouseX, int mouseY) override;
+ void handleMouseDown(bool mainButton) override;
+ void handleMouseUp(bool mainButton) override;
+ void handleMouseScroll(int direction) override;
void saveToLog();
void loadFromLog();
diff --git a/engines/bladerunner/ui/kia_section_diagnostic.h b/engines/bladerunner/ui/kia_section_diagnostic.h
index 192de8150f..1642586a54 100644
--- a/engines/bladerunner/ui/kia_section_diagnostic.h
+++ b/engines/bladerunner/ui/kia_section_diagnostic.h
@@ -40,10 +40,10 @@ class KIASectionDiagnostic : public KIASectionBase {
public:
KIASectionDiagnostic(BladeRunnerEngine *vm);
- void open();
- void close();
+ void open() override;
+ void close() override;
- void draw(Graphics::Surface &surface);
+ void draw(Graphics::Surface &surface) override;
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/ui/kia_section_help.cpp b/engines/bladerunner/ui/kia_section_help.cpp
index 61cfc99157..20002da94c 100644
--- a/engines/bladerunner/ui/kia_section_help.cpp
+++ b/engines/bladerunner/ui/kia_section_help.cpp
@@ -89,4 +89,8 @@ void KIASectionHelp::handleMouseUp(bool mainButton) {
_uiContainer->handleMouseUp(!mainButton);
}
+void KIASectionHelp::handleMouseScroll(int direction) {
+ _uiContainer->handleMouseScroll(direction);
+}
+
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/ui/kia_section_help.h b/engines/bladerunner/ui/kia_section_help.h
index 0bda5d8851..779ad9e427 100644
--- a/engines/bladerunner/ui/kia_section_help.h
+++ b/engines/bladerunner/ui/kia_section_help.h
@@ -39,15 +39,16 @@ public:
KIASectionHelp(BladeRunnerEngine *vm);
~KIASectionHelp();
- void open();
- void close();
+ void open() override;
+ void close() override;
- void draw(Graphics::Surface &surface);
+ void draw(Graphics::Surface &surface) override;
- void handleKeyUp(const Common::KeyState &kbd);
- void handleMouseMove(int mouseX, int mouseY);
- void handleMouseDown(bool mainButton);
- void handleMouseUp(bool mainButton);
+ void handleKeyUp(const Common::KeyState &kbd) override;
+ void handleMouseMove(int mouseX, int mouseY) override;
+ void handleMouseDown(bool mainButton) override;
+ void handleMouseUp(bool mainButton) override;
+ void handleMouseScroll(int direction) override;
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/ui/kia_section_load.cpp b/engines/bladerunner/ui/kia_section_load.cpp
index 5f8b635320..62facbde39 100644
--- a/engines/bladerunner/ui/kia_section_load.cpp
+++ b/engines/bladerunner/ui/kia_section_load.cpp
@@ -152,6 +152,10 @@ void KIASectionLoad::handleMouseUp(bool mainButton) {
_uiContainer->handleMouseUp(!mainButton);
}
+void KIASectionLoad::handleMouseScroll(int direction) {
+ _uiContainer->handleMouseScroll(direction);
+}
+
void KIASectionLoad::scrollBoxCallback(void *callbackData, void *source, int lineData, int mouseButton) {
KIASectionLoad *self = (KIASectionLoad *)callbackData;
diff --git a/engines/bladerunner/ui/kia_section_load.h b/engines/bladerunner/ui/kia_section_load.h
index cd34d9946e..70efd4789a 100644
--- a/engines/bladerunner/ui/kia_section_load.h
+++ b/engines/bladerunner/ui/kia_section_load.h
@@ -66,6 +66,7 @@ public:
void handleMouseMove(int mouseX, int mouseY) override;
void handleMouseDown(bool mainButton) override;
void handleMouseUp(bool mainButton) override;
+ void handleMouseScroll(int direction) override;
private:
static void scrollBoxCallback(void *callbackData, void *source, int lineData, int mouseButton);
diff --git a/engines/bladerunner/ui/kia_section_pogo.h b/engines/bladerunner/ui/kia_section_pogo.h
index 122a729752..bcfd641c58 100644
--- a/engines/bladerunner/ui/kia_section_pogo.h
+++ b/engines/bladerunner/ui/kia_section_pogo.h
@@ -45,9 +45,9 @@ class KIASectionPogo : public KIASectionBase {
public:
KIASectionPogo(BladeRunnerEngine *vm);
- void open();
+ void open() override;
- void draw(Graphics::Surface &surface);
+ void draw(Graphics::Surface &surface) override;
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/ui/kia_section_save.cpp b/engines/bladerunner/ui/kia_section_save.cpp
index f24d0e01ab..26e666ac5e 100644
--- a/engines/bladerunner/ui/kia_section_save.cpp
+++ b/engines/bladerunner/ui/kia_section_save.cpp
@@ -278,6 +278,13 @@ void KIASectionSave::handleMouseUp(bool mainButton) {
}
}
+void KIASectionSave::handleMouseScroll(int direction) {
+ if (_state == kStateNormal) {
+ _uiContainer->handleMouseScroll(direction);
+ }
+}
+
+
void KIASectionSave::scrollBoxCallback(void *callbackData, void *source, int lineData, int mouseButton) {
KIASectionSave *self = (KIASectionSave *)callbackData;
diff --git a/engines/bladerunner/ui/kia_section_save.h b/engines/bladerunner/ui/kia_section_save.h
index 528771684d..0d5bc43076 100644
--- a/engines/bladerunner/ui/kia_section_save.h
+++ b/engines/bladerunner/ui/kia_section_save.h
@@ -82,6 +82,7 @@ public:
void handleMouseMove(int mouseX, int mouseY) override;
void handleMouseDown(bool mainButton) override;
void handleMouseUp(bool mainButton) override;
+ void handleMouseScroll(int direction) override;
private:
static void scrollBoxCallback(void *callbackData, void *source, int lineData, int mouseButton);
diff --git a/engines/bladerunner/ui/kia_section_settings.h b/engines/bladerunner/ui/kia_section_settings.h
index 985b778f5d..5252ad7163 100644
--- a/engines/bladerunner/ui/kia_section_settings.h
+++ b/engines/bladerunner/ui/kia_section_settings.h
@@ -59,15 +59,15 @@ public:
KIASectionSettings(BladeRunnerEngine *vm);
~KIASectionSettings();
- void open();
- void close();
+ void open() override;
+ void close() override;
- void draw(Graphics::Surface &surface);
+ void draw(Graphics::Surface &surface) override;
- void handleKeyUp(const Common::KeyState &kbd);
- void handleMouseMove(int mouseX, int mouseY);
- void handleMouseDown(bool mainButton);
- void handleMouseUp(bool mainButton);
+ void handleKeyUp(const Common::KeyState &kbd) override;
+ void handleMouseMove(int mouseX, int mouseY) override;
+ void handleMouseDown(bool mainButton) override;
+ void handleMouseUp(bool mainButton) override;
private:
static void sliderCallback(void *callbackData, void *source);
diff --git a/engines/bladerunner/ui/kia_section_suspects.cpp b/engines/bladerunner/ui/kia_section_suspects.cpp
index 460f744a2a..26bd87547b 100644
--- a/engines/bladerunner/ui/kia_section_suspects.cpp
+++ b/engines/bladerunner/ui/kia_section_suspects.cpp
@@ -246,6 +246,10 @@ void KIASectionSuspects::handleMouseUp(bool mainButton) {
_uiContainer->handleMouseUp(!mainButton);
}
+void KIASectionSuspects::handleMouseScroll(int direction) {
+ _uiContainer->handleMouseScroll(direction);
+}
+
void KIASectionSuspects::saveToLog() {
int data[] = {
_crimeSelected,
diff --git a/engines/bladerunner/ui/kia_section_suspects.h b/engines/bladerunner/ui/kia_section_suspects.h
index 22a3accbee..33563288a1 100644
--- a/engines/bladerunner/ui/kia_section_suspects.h
+++ b/engines/bladerunner/ui/kia_section_suspects.h
@@ -90,14 +90,15 @@ public:
void reset();
- void open();
- void close();
+ void open() override;
+ void close() override;
- void draw(Graphics::Surface &surface);
+ void draw(Graphics::Surface &surface) override;
- void handleMouseMove(int mouseX, int mouseY);
- void handleMouseDown(bool mainButton);
- void handleMouseUp(bool mainButton);
+ void handleMouseMove(int mouseX, int mouseY) override;
+ void handleMouseDown(bool mainButton) override;
+ void handleMouseUp(bool mainButton) override;
+ void handleMouseScroll(int direction) override;
void saveToLog();
void loadFromLog();
diff --git a/engines/bladerunner/ui/ui_component.h b/engines/bladerunner/ui/ui_component.h
index aae944d3ad..c90c80c847 100644
--- a/engines/bladerunner/ui/ui_component.h
+++ b/engines/bladerunner/ui/ui_component.h
@@ -53,6 +53,7 @@ public:
virtual void handleMouseMove(int mouseX, int mouseY) {}
virtual void handleMouseDown(bool alternateButton) {}
virtual void handleMouseUp(bool alternateButton) {}
+ virtual void handleMouseScroll(int direction) {} // Added by ScummVM team
virtual void handleKeyUp(const Common::KeyState &kbd) {}
virtual void handleKeyDown(const Common::KeyState &kbd) {}
};
diff --git a/engines/bladerunner/ui/ui_container.cpp b/engines/bladerunner/ui/ui_container.cpp
index eed1bcd9a2..a9b89ae933 100644
--- a/engines/bladerunner/ui/ui_container.cpp
+++ b/engines/bladerunner/ui/ui_container.cpp
@@ -50,6 +50,13 @@ void UIContainer::handleMouseUp(bool alternateButton) {
}
}
+void UIContainer::handleMouseScroll(int direction) {
+ for (Common::Array<UIComponent*>::iterator component = _components.begin(); component != _components.end(); ++component) {
+ (*component)->handleMouseScroll(direction);
+ }
+}
+
+
void UIContainer::handleKeyUp(const Common::KeyState &kbd) {
for (Common::Array<UIComponent*>::iterator component = _components.begin(); component != _components.end(); ++component) {
(*component)->handleKeyUp(kbd);
diff --git a/engines/bladerunner/ui/ui_container.h b/engines/bladerunner/ui/ui_container.h
index 6d5a20765e..07ae20fd44 100644
--- a/engines/bladerunner/ui/ui_container.h
+++ b/engines/bladerunner/ui/ui_container.h
@@ -42,6 +42,7 @@ public:
void handleMouseMove(int mouseX, int mouseY);
void handleMouseDown(bool alternateButton);
void handleMouseUp(bool alternateButton);
+ void handleMouseScroll(int direction); // Added by ScummVM team
void handleKeyUp(const Common::KeyState &kbd);
void handleKeyDown(const Common::KeyState &kbd);
diff --git a/engines/bladerunner/ui/ui_scroll_box.cpp b/engines/bladerunner/ui/ui_scroll_box.cpp
index 39e4174fa3..15b0a59712 100644
--- a/engines/bladerunner/ui/ui_scroll_box.cpp
+++ b/engines/bladerunner/ui/ui_scroll_box.cpp
@@ -71,6 +71,7 @@ UIScrollBox::UIScrollBox(BladeRunnerEngine *vm, UIScrollBoxCallback *lineSelecte
_rect = rect;
_scrollBarRect = scrollBarRect;
+ _scrollBarRect.right += 15; // right side was not used, but it's useful for determining if the control is selected
_lineCount = 0;
_maxLineCount = maxLineCount;
@@ -89,6 +90,8 @@ UIScrollBox::UIScrollBox(BladeRunnerEngine *vm, UIScrollBoxCallback *lineSelecte
_lines[i]->flags = 0x00;
_lines[i]->checkboxFrame = 5;
}
+
+ _mouseOver = false;
}
UIScrollBox::~UIScrollBox() {
@@ -120,6 +123,8 @@ void UIScrollBox::show() {
_highlightFrame = 0;
_isVisible = true;
+
+ _mouseOver = false;
}
void UIScrollBox::hide() {
@@ -157,6 +162,8 @@ void UIScrollBox::handleMouseMove(int mouseX, int mouseY) {
return;
}
+ _mouseOver = _rect.contains(mouseX, mouseY) || _scrollBarRect.contains(mouseX, mouseY);
+
if (_rect.contains(mouseX, mouseY)) {
int newHoveredLine = (mouseY - _rect.top) / 10 + _firstLineVisible;
if (newHoveredLine >= _lineCount) {
@@ -314,6 +321,16 @@ void UIScrollBox::handleMouseUp(bool alternateButton) {
}
}
+void UIScrollBox::handleMouseScroll(int direction) {
+ if (_mouseOver) {
+ if (direction > 0) {
+ scrollDown();
+ } else if (direction < 0) {
+ scrollUp();
+ }
+ }
+}
+
int UIScrollBox::getSelectedLineData() {
if (_hoveredLine >= 0 && _selectedLineState != 1 && _hoveredLine < _lineCount) {
return _lines[_hoveredLine]->lineData;
diff --git a/engines/bladerunner/ui/ui_scroll_box.h b/engines/bladerunner/ui/ui_scroll_box.h
index da4c574c87..f2b40a9936 100644
--- a/engines/bladerunner/ui/ui_scroll_box.h
+++ b/engines/bladerunner/ui/ui_scroll_box.h
@@ -89,15 +89,18 @@ class UIScrollBox : public UIComponent {
int _maxLinesVisible;
int _firstLineVisible;
+ bool _mouseOver;
+
public:
UIScrollBox(BladeRunnerEngine *vm, UIScrollBoxCallback *lineSelectedCallback, void *callbackData, int maxLineCount, int style, bool center, Common::Rect rect,Common::Rect scrollBarRect);
~UIScrollBox();
- void draw(Graphics::Surface &surface);
+ void draw(Graphics::Surface &surface) override;
- void handleMouseMove(int mouseX, int mouseY);
- void handleMouseDown(bool alternateButton);
- void handleMouseUp(bool alternateButton);
+ void handleMouseMove(int mouseX, int mouseY) override;
+ void handleMouseDown(bool alternateButton) override;
+ void handleMouseUp(bool alternateButton) override;
+ void handleMouseScroll(int direction) override;
void show();
void hide();