diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/ListWidget.cpp | 9 | ||||
-rw-r--r-- | gui/ListWidget.h | 3 | ||||
-rw-r--r-- | gui/dialog.cpp | 3 | ||||
-rw-r--r-- | gui/dialog.h | 2 | ||||
-rw-r--r-- | gui/widget.h | 1 |
5 files changed, 13 insertions, 5 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 4216d67a60..d40cfc829d 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -48,7 +48,7 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h) _numberingMode = kListNumberingOne; _entriesPerPage = (_h - 4) / LINE_HEIGHT; _currentPos = 3; - + _selectedItem = -1; _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kScrollBarWidth, _h); _scrollBar->setTarget(this); @@ -86,6 +86,8 @@ ListWidget::~ListWidget() void ListWidget::handleClick(int x, int y, int button) { if (_flags & WIDGET_ENABLED) { + _selectedItem = (y / LINE_HEIGHT) + _currentPos; + draw(); } } @@ -121,6 +123,9 @@ void ListWidget::drawWidget(bool hilite) } else buffer = ""; buffer += _list[pos]; - gui->drawString(buffer, _x+5, _y+2 + LINE_HEIGHT * i, _w - 10, gui->_textcolor); + if (_selectedItem == pos) + gui->drawString(buffer, _x+5, _y+2 + LINE_HEIGHT * i, _w - 10, gui->_textcolorhi); + else + gui->drawString(buffer, _x+5, _y+2 + LINE_HEIGHT * i, _w - 10, gui->_textcolor); } } diff --git a/gui/ListWidget.h b/gui/ListWidget.h index d3973f6ebe..b3fa7437d2 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -40,6 +40,7 @@ protected: int _numberingMode; int _currentPos; int _entriesPerPage; + int _selectedItem; ScrollBarWidget *_scrollBar; public: ListWidget(Dialog *boss, int x, int y, int w, int h); @@ -47,7 +48,7 @@ public: void setList(const StringList& list) { _list = list; } const StringList& getList() const { return _list; } - + const int getSelected() {return _selectedItem;} void setNumberingMode(int numberingMode) { _numberingMode = numberingMode; } virtual void handleClick(int x, int y, int button); diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 9833058df7..9f399564f8 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -205,7 +205,7 @@ SaveLoadDialog::SaveLoadDialog(NewGui *gui) new SliderWidget(this, 110, 20, 80, 16, "Volume", 0); // FIXME - test - new ListWidget(this, 10, 40, 180, 74); + _savegameList = new ListWidget(this, 10, 40, 180, 74); } void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) @@ -214,6 +214,7 @@ void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat case kSaveCmd: break; case kLoadCmd: + //printf("Saving game in slot %d\n", _savegameList->getSelected()); break; case kPlayCmd: close(); diff --git a/gui/dialog.h b/gui/dialog.h index 336e50db05..29a4b76795 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -77,6 +77,8 @@ public: SaveLoadDialog(NewGui *gui); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); +protected: + Widget* _savegameList; }; diff --git a/gui/widget.h b/gui/widget.h index f7cc5eb316..b9fc92cc52 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -23,7 +23,6 @@ #include "scummsys.h" - class Dialog; enum { |