Skip to content

Commit

Permalink
UI|Home: Adding packages to profiles using the package info dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 13, 2017
1 parent 6965982 commit 1da09ac
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 68 deletions.
Expand Up @@ -16,30 +16,30 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef DENG_CLIENT_UI_PACKAGEPOPUPWIDGET_H
#define DENG_CLIENT_UI_PACKAGEPOPUPWIDGET_H
#ifndef DENG_CLIENT_UI_PACKAGEINFODIALOG_H
#define DENG_CLIENT_UI_PACKAGEINFODIALOG_H

#include <de/DialogWidget>

/**
* Popup showing information about a package.
* Dialog showing information about a package.
*/
class PackagePopupWidget : public de::DialogWidget
class PackageInfoDialog : public de::DialogWidget
{
Q_OBJECT

public:
PackagePopupWidget(de::String const &packageId);
PackagePopupWidget(de::File const *packageFile);
PackageInfoDialog(de::String const &packageId);
PackageInfoDialog(de::File const *packageFile);

public slots:
void playInGame();
void addToProfile();
void configure();
void uninstall();
void showFile();

private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_UI_PACKAGEPOPUPWIDGET_H
#endif // DENG_CLIENT_UI_PACKAGEINFODIALOG_H
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/clientapp.cpp
Expand Up @@ -897,7 +897,7 @@ void ClientApp::unloadGame(GameProfile const &upcomingGame)
// Game has been set to null, update window.
ClientWindow::main().setTitle(DD_ComposeMainWindowTitle());

if (!upcomingGame.game().isEmpty())
if (!upcomingGame.gameId().isEmpty())
{
ClientWindow &mainWin = ClientWindow::main();
mainWin.taskBar().close();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -1093,7 +1093,7 @@ static void initialize()
else
{
StringList ids;
foreach (GameProfile const *prof, playable) ids << prof->game();
foreach (GameProfile const *prof, playable) ids << prof->gameId();
msg += "The following games are playable: " + String::join(ids, ", ");
}
App_Error(msg.toLatin1());
Expand Down
Expand Up @@ -141,7 +141,7 @@ GameProfile *CreateProfileDialog::makeProfile() const
void CreateProfileDialog::fetchFrom(GameProfile const &profile)
{
editor().setText(profile.name());
d->gameChoice->setSelected(d->gameChoice->items().findData(profile.game()));
d->gameChoice->setSelected(d->gameChoice->items().findData(profile.gameId()));
d->packages->setPackages(profile.packages());
}

Expand Down
Expand Up @@ -93,7 +93,7 @@ DENG2_PIMPL(PackageCompatibilityDialog)
// The only action on the packages is to view information.
actions << new ui::SubwidgetItem(tr("..."), ui::Up, [this] () -> PopupWidget *
{
return new PackagePopupWidget(list->actionPackage());
return new PackageInfoDialog(list->actionPackage());
});

self().area().add(list = new PackagesWidget(wanted));
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/ui/dialogs/packagesdialog.cpp
Expand Up @@ -150,7 +150,7 @@ DENG_GUI_PIMPL(PackagesDialog)

PopupWidget *makeInfoPopup() const
{
return new PackagePopupWidget(_item->packageFile());
return new PackageInfoDialog(_item->packageFile());
}

private:
Expand Down Expand Up @@ -227,7 +227,7 @@ DENG_GUI_PIMPL(PackagesDialog)
menu->items()
<< new ui::SubwidgetItem(tr("Info"), ui::Up,
[this] () -> PopupWidget * {
return new PackagePopupWidget(browser->actionPackage());
return new PackageInfoDialog(browser->actionPackage());
})
<< new ui::ActionItem(style().images().image("gear"), tr("Select Packages"),
new CallbackAction([this] () {
Expand All @@ -237,7 +237,7 @@ DENG_GUI_PIMPL(PackagesDialog)
}
else*/
{
return new PackagePopupWidget(id);
return new PackageInfoDialog(id);
}
});

Expand Down
8 changes: 4 additions & 4 deletions doomsday/apps/client/src/ui/home/gamecolumnwidget.cpp
Expand Up @@ -65,7 +65,7 @@ DENG_GUI_PIMPL(GameColumnWidget)
Game const &game() const
{
DENG2_ASSERT(profile != nullptr);
return DoomsdayApp::games()[profile->game()];
return profile->game();
}

//String gameId() const { return data().toString(); }
Expand Down Expand Up @@ -186,9 +186,9 @@ DENG_GUI_PIMPL(GameColumnWidget)
bool addItemForProfile(GameProfile &profile)
{
auto const &games = DoomsdayApp::games();
if (games.contains(profile.game()))
if (games.contains(profile.gameId()))
{
if (games[profile.game()].family() == gameFamily)
if (profile.game().family() == gameFamily)
{
menu->items() << new ProfileItem(this, profile);
addOrRemoveSubheading();
Expand Down Expand Up @@ -296,7 +296,7 @@ DENG_GUI_PIMPL(GameColumnWidget)
if (!prof1.isPlayable() && prof2.isPlayable()) return false;

// Finally, based on identifier.
return prof1.game().compareWithoutCase(prof2.game()) < 0;
return prof1.gameId().compareWithoutCase(prof2.gameId()) < 0;
}
return year < 0;
});
Expand Down
12 changes: 10 additions & 2 deletions doomsday/apps/client/src/ui/home/gamepanelbuttonwidget.cpp
Expand Up @@ -41,6 +41,7 @@
using namespace de;

DENG_GUI_PIMPL(GamePanelButtonWidget)
, DENG2_OBSERVES(Profiles::AbstractProfile, Change)
{
GameProfile &gameProfile;
ui::FilteredDataT<SaveListData::SaveItem> savedItems;
Expand All @@ -62,7 +63,7 @@ DENG_GUI_PIMPL(GamePanelButtonWidget)
{
// Only saved sessions for this game are to be included.
auto const &item = it.as<SaveListData::SaveItem>();
if (item.gameId() != gameProfile.game())
if (item.gameId() != gameProfile.gameId())
{
return false;
}
Expand Down Expand Up @@ -169,7 +170,7 @@ DENG_GUI_PIMPL(GamePanelButtonWidget)

Game const &game() const
{
return DoomsdayApp::games()[gameProfile.game()];
return gameProfile.game();
}

void updatePackagesIndicator()
Expand Down Expand Up @@ -239,6 +240,11 @@ DENG_GUI_PIMPL(GamePanelButtonWidget)
{
self().icon().setImage(self().makeGameLogo(game(), catalog));
}

void profileChanged(Profiles::AbstractProfile &)
{
self().updateContent();
}
};

GamePanelButtonWidget::GamePanelButtonWidget(GameProfile &game, SaveListData const &savedItems)
Expand All @@ -247,6 +253,8 @@ GamePanelButtonWidget::GamePanelButtonWidget(GameProfile &game, SaveListData con
connect(d->saves, SIGNAL(selectionChanged(de::ui::DataPos)), this, SLOT(saveSelected(de::ui::DataPos)));
connect(d->saves, SIGNAL(doubleClicked(de::ui::DataPos)), this, SLOT(saveDoubleClicked(de::ui::DataPos)));
connect(this, SIGNAL(doubleClicked()), this, SLOT(play()));

game.audienceForChange() += d;
}

void GamePanelButtonWidget::setSelected(bool selected)
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/client/src/ui/home/packagescolumnwidget.cpp
Expand Up @@ -66,13 +66,13 @@ DENG_GUI_PIMPL(PackagesColumnWidget)
{
actions << new ui::SubwidgetItem(tr("..."), ui::Left, [this] () -> PopupWidget *
{
return new PackagePopupWidget(packages->actionPackage());
return new PackageInfoDialog(packages->actionPackage());

/*auto *popMenu = new PopupMenuWidget;
popMenu->setColorTheme(Inverted);
popMenu->items() << new ui::SubwidgetItem(tr("Info"), ui::Down,
[this, packageId] () -> PopupWidget * {
return new PackagePopupWidget(packageId);
return new PackageInfoDialog(packageId);
});
if (Package::hasOptionalContent(packageId))
Expand Down

0 comments on commit 1da09ac

Please sign in to comment.