aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/duckman
diff options
context:
space:
mode:
authorEric Fry2018-06-15 21:07:27 +1000
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commitced1ff2356391f24c70f9bb4c514733aeadfc38b (patch)
treec486e9400f2be1c32b3c66d259c4d776d2a3bd89 /engines/illusions/duckman
parent0793272dfa574d48c28e94181993c3c7ab5afb60 (diff)
downloadscummvm-rg350-ced1ff2356391f24c70f9bb4c514733aeadfc38b.tar.gz
scummvm-rg350-ced1ff2356391f24c70f9bb4c514733aeadfc38b.tar.bz2
scummvm-rg350-ced1ff2356391f24c70f9bb4c514733aeadfc38b.zip
ILLUSIONS: Move sliders in option menu
Diffstat (limited to 'engines/illusions/duckman')
-rw-r--r--engines/illusions/duckman/menusystem_duckman.cpp77
-rw-r--r--engines/illusions/duckman/menusystem_duckman.h14
2 files changed, 85 insertions, 6 deletions
diff --git a/engines/illusions/duckman/menusystem_duckman.cpp b/engines/illusions/duckman/menusystem_duckman.cpp
index 8a9e1cce47..554be9aac5 100644
--- a/engines/illusions/duckman/menusystem_duckman.cpp
+++ b/engines/illusions/duckman/menusystem_duckman.cpp
@@ -110,12 +110,26 @@ BaseMenu *DuckmanMenuSystem::createOptionsMenu() {
BaseMenu *menu = new BaseMenu(this, 0x00120003, 12, 17, 11, 27, 1);
menu->addText(" GAME OPTIONS @@@@");
menu->addText("--------------------------------------");
- menu->addMenuItem(new MenuItem("SFX Volume @@{~~~~~~~~~~~~|~~~} @@@", new MenuActionReturnChoice(this, 21)));
- menu->addMenuItem(new MenuItem("Music Volume @@@{~~~~~~~~~~~~|~~~} @@@", new MenuActionReturnChoice(this, 21)));
- menu->addMenuItem(new MenuItem("Speech Volume {~~~~~~~~~~~~|~~~} @@@", new MenuActionReturnChoice(this, 21)));
- menu->addMenuItem(new MenuItem("Text Duration @@@{~~~~~~~~~~~~|~~~} @@@", new MenuActionReturnChoice(this, 21)));
- menu->addMenuItem(new MenuItem("Restore Defaults @@", new MenuActionReturnChoice(this, 21)));
- menu->addMenuItem(new MenuItem("Back @@@", new MenuActionLeaveMenu(this)));
+ MenuActionUpdateSlider *action = new MenuActionUpdateSlider(this, menu);
+ MenuItem *menuItem = new MenuItem("SFX Volume @@{~~~~~~~~~~~~|~~~} @@@", action);
+ action->setMenuItem(menuItem);
+ menu->addMenuItem(menuItem);
+
+ action = new MenuActionUpdateSlider(this, menu);
+ menuItem = new MenuItem("Music Volume @@@{~~~~~~~~~~~~|~~~} @@@", action);
+ action->setMenuItem(menuItem);
+ menu->addMenuItem(menuItem);
+
+ action = new MenuActionUpdateSlider(this, menu);
+ menuItem = new MenuItem("Speech Volume {~~~~~~~~~~~~|~~~} @@@", action);
+ action->setMenuItem(menuItem);
+ menu->addMenuItem(menuItem);
+
+ action = new MenuActionUpdateSlider(this, menu);
+ menuItem = new MenuItem("Text Duration @@@{~~~~~~~~~~~~|~~~} @@@", action);
+ action->setMenuItem(menuItem);
+ menu->addMenuItem(menuItem);
+
return menu;
}
@@ -290,4 +304,55 @@ void MenuActionInventoryAddRemove::execute() {
_menuSystem->leaveMenu();
}
+MenuActionUpdateSlider::MenuActionUpdateSlider(BaseMenuSystem *menuSystem, BaseMenu *menu)
+ : BaseMenuAction(menuSystem), menu(menu) {
+ menuItem = NULL;
+}
+
+void MenuActionUpdateSlider::execute() {
+ assert(menuItem);
+ Common::String text = menuItem->getText();
+ Common::Point point = menuItem->getMouseClickPoint();
+ int offset = 0;
+ _menuSystem->calcMenuItemTextPositionAtPoint(point, offset);
+ int newSliderValue = calcNewSliderValue(text, offset);
+
+ debug(0, "item text: %s, (%d, %d), New slider value: %d", text.c_str(), point.x, point.y, newSliderValue);
+
+ menuItem->setText(text);
+ _menuSystem->redrawMenuText(menu);
+ // TODO update slider here set value callback.
+}
+
+int MenuActionUpdateSlider::calcNewSliderValue(Common::String &text, int newOffset) {
+ int newSliderValue = 0;
+ int start = 0;
+ int end = 0;
+ int currentPosition = 0;
+ for(int i = 0; i < text.size(); i++) {
+ switch (text[i]) {
+ case '{' : start = i; break;
+ case '}' : end = i; break;
+ case '|' : currentPosition = i; break;
+ default: break;
+ }
+ }
+
+ if (newOffset >= start && newOffset <= end) {
+ if (newOffset == start) {
+ newSliderValue = 0;
+ } else if (newOffset == end) {
+ newSliderValue = 15;
+ } else {
+ newSliderValue = newOffset - (start + 1);
+ }
+
+ text.setChar('~', currentPosition);
+ text.setChar('|', start + 1 + newSliderValue);
+
+ return newSliderValue;
+ }
+ return currentPosition - start - 1;
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/duckman/menusystem_duckman.h b/engines/illusions/duckman/menusystem_duckman.h
index 2921277630..22bfefa794 100644
--- a/engines/illusions/duckman/menusystem_duckman.h
+++ b/engines/illusions/duckman/menusystem_duckman.h
@@ -83,6 +83,20 @@ protected:
int _choiceIndex;
};
+class MenuActionUpdateSlider : public BaseMenuAction {
+public:
+ MenuActionUpdateSlider(BaseMenuSystem *menuSystem, BaseMenu *baseMenu);
+ void setMenuItem(MenuItem *newMmenuItem) {
+ menuItem = newMmenuItem;
+ }
+
+ virtual void execute();
+protected:
+ MenuItem *menuItem;
+ BaseMenu *menu;
+ int calcNewSliderValue(Common::String &text, int newOffset);
+};
+
} // End of namespace Illusions
#endif // ILLUSIONS_DUCKMAN_MENUSYSTEM_DUCKMAN_H