mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-20 17:03:05 +00:00
GUI: Launcher can get the selected entry from the grid
This commit is contained in:
parent
638ad5be5d
commit
7e63200f78
@ -168,21 +168,6 @@ LauncherDialog::~LauncherDialog() {
|
||||
delete _loadDialog;
|
||||
}
|
||||
|
||||
ButtonWidget *LauncherDialog::createSwitchButton(const Common::String &name, const Common::U32String &desc, const Common::U32String &tooltip, const char *image, uint32 cmd) {
|
||||
ButtonWidget *button;
|
||||
|
||||
#ifndef DISABLE_FANCY_THEMES
|
||||
if (g_gui.xmlEval()->getVar("Globals.ShowChooserPics") == 1 && g_gui.theme()->supportsImages()) {
|
||||
button = new PicButtonWidget(this, name, tooltip, cmd);
|
||||
((PicButtonWidget *)button)->useThemeTransparency(true);
|
||||
((PicButtonWidget *)button)->setGfx(g_gui.theme()->getImageSurface(image), kPicButtonStateEnabled, false);
|
||||
} else
|
||||
#endif
|
||||
button = new ButtonWidget(this, name, desc, tooltip, cmd);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
void LauncherDialog::build() {
|
||||
_list = nullptr;
|
||||
#ifndef DISABLE_LIBRARYDISPLAY_GRID
|
||||
@ -314,16 +299,18 @@ void LauncherDialog::open() {
|
||||
|
||||
void LauncherDialog::close() {
|
||||
// Save last selection
|
||||
if (_list) {
|
||||
const int sel = _list->getSelected();
|
||||
if (sel >= 0)
|
||||
ConfMan.set("lastselectedgame", _domains[sel], ConfigManager::kApplicationDomain);
|
||||
else
|
||||
ConfMan.removeKey("lastselectedgame", ConfigManager::kApplicationDomain);
|
||||
} else {
|
||||
int sel;
|
||||
#ifndef DISABLE_LIBRARYDISPLAY_GRID
|
||||
if (_libraryDisplay == kLibraryDisplayGrid)
|
||||
sel = _grid->getSelected();
|
||||
else
|
||||
#endif
|
||||
sel = _list->getSelected();
|
||||
if (sel >= 0)
|
||||
ConfMan.set("lastselectedgame", _domains[sel], ConfigManager::kApplicationDomain);
|
||||
else
|
||||
ConfMan.removeKey("lastselectedgame", ConfigManager::kApplicationDomain);
|
||||
}
|
||||
|
||||
|
||||
ConfMan.flushToDisk();
|
||||
Dialog::close();
|
||||
}
|
||||
@ -389,6 +376,21 @@ void LauncherDialog::addChooserButtons() {
|
||||
_listButton = createSwitchButton("Launcher.ListSwitch", Common::U32String("L"), _("List view"), ThemeEngine::kImageList, kListSwitchCmd);
|
||||
_gridButton = createSwitchButton("Launcher.GridSwitch", Common::U32String("G"), _("Grid view"), ThemeEngine::kImageGrid, kGridSwitchCmd);
|
||||
}
|
||||
|
||||
ButtonWidget *LauncherDialog::createSwitchButton(const Common::String &name, const Common::U32String &desc, const Common::U32String &tooltip, const char *image, uint32 cmd) {
|
||||
ButtonWidget *button;
|
||||
|
||||
#ifndef DISABLE_FANCY_THEMES
|
||||
if (g_gui.xmlEval()->getVar("Globals.ShowChooserPics") == 1 && g_gui.theme()->supportsImages()) {
|
||||
button = new PicButtonWidget(this, name, tooltip, cmd);
|
||||
((PicButtonWidget *)button)->useThemeTransparency(true);
|
||||
((PicButtonWidget *)button)->setGfx(g_gui.theme()->getImageSurface(image), kPicButtonStateEnabled, false);
|
||||
} else
|
||||
#endif
|
||||
button = new ButtonWidget(this, name, desc, tooltip, cmd);
|
||||
|
||||
return button;
|
||||
}
|
||||
#endif
|
||||
|
||||
void LauncherDialog::updateListing() {
|
||||
@ -437,6 +439,7 @@ void LauncherDialog::updateListing() {
|
||||
// Now sort the list in dictionary order
|
||||
Common::sort(domainList.begin(), domainList.end(), LauncherEntryComparator());
|
||||
|
||||
#ifndef DISABLE_LIBRARYDISPLAY_GRID
|
||||
Common::Array<GridItemInfo> gridList;
|
||||
|
||||
int k = 0;
|
||||
@ -453,8 +456,9 @@ void LauncherDialog::updateListing() {
|
||||
gridList.push_back(GridItemInfo(k++, engineid, gameid, title, language, platform));
|
||||
}
|
||||
|
||||
if (_grid)
|
||||
if (_libraryDisplay == kLibraryDisplayGrid)
|
||||
_grid->setEntryList(&gridList);
|
||||
#endif
|
||||
|
||||
// And fill out our structures
|
||||
for (Common::Array<LauncherEntry>::const_iterator iter = domainList.begin(); iter != domainList.end(); ++iter) {
|
||||
@ -678,14 +682,14 @@ void LauncherDialog::handleKeyDown(Common::KeyState state) {
|
||||
if (state.keycode == Common::KEYCODE_TAB) {
|
||||
// Toggle between the game list and the quick search field.
|
||||
if (getFocusWidget() == _searchWidget) {
|
||||
if (_list)
|
||||
setFocusWidget(_list);
|
||||
else if (_grid)
|
||||
#ifndef DISABLE_LIBRARYDISPLAY_GRID
|
||||
if (_libraryDisplay == kLibraryDisplayGrid)
|
||||
setFocusWidget(_grid);
|
||||
else
|
||||
#endif
|
||||
setFocusWidget(_list);
|
||||
} else if (getFocusWidget() == _list) {
|
||||
setFocusWidget(_searchWidget);
|
||||
} else if (getFocusWidget() == _grid) {
|
||||
setFocusWidget(_searchWidget);
|
||||
}
|
||||
}
|
||||
Dialog::handleKeyDown(state);
|
||||
@ -806,11 +810,12 @@ bool LauncherDialog::doGameDetection(const Common::String &path) {
|
||||
|
||||
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
int item = 0;
|
||||
if (_list)
|
||||
#ifndef DISABLE_LIBRARYDISPLAY_GRID
|
||||
if (_libraryDisplay == kLibraryDisplayGrid)
|
||||
item = _grid->getSelected();
|
||||
else
|
||||
#endif
|
||||
item = _list->getSelected();
|
||||
if (_grid) {
|
||||
item = data;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case kAddGameCmd:
|
||||
@ -873,14 +878,18 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||
if (_list)
|
||||
_list->setFilter(Common::U32String());
|
||||
break;
|
||||
#ifndef DISABLE_LIBRARYDISPLAY_GRID
|
||||
case kGridSwitchCmd:
|
||||
_libraryDisplay = kLibraryDisplayGrid;
|
||||
openGrid();
|
||||
ConfMan.set("gui_launcher_grid", "grid", Common::ConfigManager::kApplicationDomain);
|
||||
break;
|
||||
case kListSwitchCmd:
|
||||
_libraryDisplay = kLibraryDisplayList;
|
||||
openList();
|
||||
ConfMan.set("gui_launcher_grid", "list", Common::ConfigManager::kApplicationDomain);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
Dialog::handleCommand(sender, cmd, data);
|
||||
}
|
||||
@ -888,15 +897,24 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
|
||||
|
||||
void LauncherDialog::updateButtons() {
|
||||
bool enable = false;
|
||||
if (_list)
|
||||
#ifndef DISABLE_LIBRARYDISPLAY_GRID
|
||||
if (_libraryDisplay == kLibraryDisplayGrid)
|
||||
enable = (_grid->getSelected() >= 0);
|
||||
else
|
||||
#endif
|
||||
enable = (_list->getSelected() >= 0);
|
||||
|
||||
if (enable != _removeButton->isEnabled()) {
|
||||
_removeButton->setEnabled(enable);
|
||||
_removeButton->markAsDirty();
|
||||
}
|
||||
|
||||
int item = 0;
|
||||
if (_list)
|
||||
#ifndef DISABLE_LIBRARYDISPLAY_GRID
|
||||
if (_libraryDisplay == kLibraryDisplayGrid)
|
||||
item = _grid->getSelected();
|
||||
else
|
||||
#endif
|
||||
item = _list->getSelected();
|
||||
bool en = enable;
|
||||
|
||||
|
@ -119,13 +119,13 @@ void GridItemWidget::drawWidget() {
|
||||
|
||||
void GridItemWidget::handleMouseWheel(int x, int y, int direction) {
|
||||
_grid->handleMouseWheel(x, y, direction);
|
||||
_grid->_selectedEntry = nullptr;
|
||||
_grid->_selectedEntry = -1;
|
||||
isHighlighted = false;
|
||||
}
|
||||
|
||||
void GridItemWidget::handleMouseEntered(int button) {
|
||||
if (!isHighlighted) {
|
||||
_grid->_selectedEntry = _activeEntry;
|
||||
_grid->_selectedEntry = _activeEntry->entryID;
|
||||
isHighlighted = true;
|
||||
markAsDirty();
|
||||
}
|
||||
@ -133,7 +133,7 @@ void GridItemWidget::handleMouseEntered(int button) {
|
||||
|
||||
void GridItemWidget::handleMouseLeft(int button) {
|
||||
if (isHighlighted) {
|
||||
_grid->_selectedEntry = nullptr;
|
||||
_grid->_selectedEntry = -1;
|
||||
isHighlighted = false;
|
||||
markAsDirty();
|
||||
}
|
||||
@ -287,6 +287,8 @@ GridWidget::GridWidget(GuiObject *boss, int x, int y, int w, int h)
|
||||
_scrollBar->setTarget(this);
|
||||
_scrollPos = 0;
|
||||
_firstVisibleItem = 0;
|
||||
|
||||
_selectedEntry = 0;
|
||||
}
|
||||
|
||||
GridWidget::GridWidget(GuiObject *boss, const String &name)
|
||||
@ -307,6 +309,8 @@ GridWidget::GridWidget(GuiObject *boss, const String &name)
|
||||
_scrollBar->setTarget(this);
|
||||
_scrollPos = 0;
|
||||
_firstVisibleItem = 0;
|
||||
|
||||
_selectedEntry = 0;
|
||||
}
|
||||
|
||||
GridWidget::~GridWidget() {
|
||||
|
@ -153,7 +153,7 @@ public:
|
||||
|
||||
bool _isTitlesVisible;
|
||||
|
||||
GridItemInfo *_selectedEntry;
|
||||
int _selectedEntry;
|
||||
GridItemTray *_tray;
|
||||
|
||||
GridWidget(GuiObject *boss, int x, int y, int w, int h);
|
||||
@ -179,6 +179,7 @@ public:
|
||||
void assignEntriesToItems();
|
||||
|
||||
int getScrollPos() const { return -_scrollPos; }
|
||||
int getSelected() const { return _selectedEntry; }
|
||||
int getThumbnailHeight() const { return _thumbnailHeight; }
|
||||
int getThumbnailWidth() const { return _thumbnailWidth; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user