Skip to content

Commit

Permalink
Home|UI: If needed, show a notice and button to pick the IWAD folder
Browse files Browse the repository at this point in the history
If no games are found, the home screen now simply shows a notice
that tells the user to locate the IWAD folder.

This enables one to run Doomsday completely without command line
options or Snowberry (i.e., directly starting the executable), albeit
add-ons cannot still be accessed via the Doomsday UI and resources can
only be loaded using console commands.

IssueID #1684
  • Loading branch information
skyjake committed Feb 12, 2015
1 parent 88d6d57 commit 44c2114
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 42 deletions.
128 changes: 86 additions & 42 deletions doomsday/client/src/ui/clientwindow.cpp
Expand Up @@ -37,6 +37,7 @@
#include <de/Drawable>
#include <de/CompositorWidget>
#include <de/NotificationAreaWidget>
#include <de/SignalAction>
#include <de/VRWindowTransform>
#include <de/concurrency.h>
#include <doomsday/console/exec.h>
Expand Down Expand Up @@ -72,63 +73,47 @@ DENG2_PIMPL(ClientWindow)
, DENG2_OBSERVES(Canvas, FocusChange)
, DENG2_OBSERVES(App, GameChange)
, DENG2_OBSERVES(App, StartupComplete)
, DENG2_OBSERVES(Games, Readiness)
, DENG2_OBSERVES(Variable, Change)
{
bool needMainInit;
bool needRecreateCanvas;
bool needRootSizeUpdate;
bool needMainInit = true;
bool needRecreateCanvas = false;
bool needRootSizeUpdate = false;

Mode mode;
Mode mode = Normal;

/// Root of the nomal UI widgets of this window.
ClientRootWidget root;
CompositorWidget *compositor;
GameWidget *game;
GameUIWidget *gameUI;
TaskBarWidget *taskBar;
LabelWidget *taskBarBlur; ///< Blur everything below the task bar.
NotificationAreaWidget *notifications;
AlertDialog *alerts;
ColorAdjustmentDialog *colorAdjust;
LabelWidget *background;
GameSelectionWidget *gameSelMenu;
BusyWidget *busy;
GuiWidget *sidebar;
LabelWidget *cursor;
CompositorWidget *compositor = nullptr;
GameWidget *game = nullptr;
GameUIWidget *gameUI = nullptr;
TaskBarWidget *taskBar = nullptr;
LabelWidget *taskBarBlur = nullptr; ///< Blur everything below the task bar.
NotificationAreaWidget *notifications = nullptr;
AlertDialog *alerts = nullptr;
ColorAdjustmentDialog *colorAdjust = nullptr;
LabelWidget *background = nullptr;
GuiWidget *iwadNotice = nullptr;
GameSelectionWidget *gameSelMenu = nullptr;
BusyWidget *busy = nullptr;
GuiWidget *sidebar = nullptr;
LabelWidget *cursor = nullptr;
ConstantRule *cursorX;
ConstantRule *cursorY;
bool cursorHasBeenHidden;
bool cursorHasBeenHidden = false;

// FPS notifications.
UniqueWidgetPtr<LabelWidget> fpsCounter;
float oldFps;
float oldFps = 0;

/// @todo Switch dynamically between VR and plain.
VRWindowTransform contentXf;

Instance(Public *i)
: Base(i)
, needMainInit(true)
, needRecreateCanvas(false)
, needRootSizeUpdate(false)
, mode(Normal)
, root(thisPublic)
, compositor(0)
, game(0)
, gameUI(0)
, taskBar(0)
, taskBarBlur(0)
, notifications(0)
, alerts(0)
, colorAdjust(0)
, background(0)
, gameSelMenu(0)
, sidebar(0)
, cursor(0)
, cursorX(new ConstantRule(0))
, cursorY(new ConstantRule(0))
, cursorHasBeenHidden(false)
, oldFps(0)
, contentXf(*i)
{
self.setTransform(contentXf);
Expand All @@ -138,6 +123,7 @@ DENG2_PIMPL(ClientWindow)

App::app().audienceForGameChange() += this;
App::app().audienceForStartupComplete() += this;
App_Games().audienceForReadiness() += this;

// Listen to input.
self.canvas().audienceForMouseStateChange() += this;
Expand All @@ -157,6 +143,7 @@ DENG2_PIMPL(ClientWindow)

App::app().audienceForGameChange() -= this;
App::app().audienceForStartupComplete() -= this;
App_Games().audienceForReadiness() -= this;

self.canvas().audienceForFocusChange() -= this;
self.canvas().audienceForMouseStateChange() -= this;
Expand Down Expand Up @@ -222,7 +209,7 @@ DENG2_PIMPL(ClientWindow)
gameSelMenu = new GameSelectionWidget;
gameSelMenu->enableActionOnSelection(true);
gameSelMenu->rule()
.setInput(Rule::AnchorX, root.viewLeft() + root.viewWidth() / 2)
.setInput(Rule::AnchorX, root.viewRule().midX())
.setInput(Rule::Width, root.viewWidth())
.setAnchorPoint(Vector2f(.5f, .5f));
AutoRef<Rule> pad(OperatorRule::maximum(style.rules().rule("gap"),
Expand All @@ -238,6 +225,32 @@ DENG2_PIMPL(ClientWindow)
container().add(gameSelMenu);
gameSelMenu->filter().enableBackground(gameSelMenu->scrollPositionY());

// As an alternative to game selection, a notice to pick the IWAD folder.
ButtonWidget *chooseIwad = nullptr;
iwadNotice = new GuiWidget;
{
LabelWidget *notice = LabelWidget::newWithText(_E(b) + tr("No playable games were found.\n") + _E(.) +
tr("Please select the folder where you have one or more game WAD files."),
iwadNotice);
notice->setTextColor("inverted.text");
notice->setSizePolicy(ui::Expand, ui::Expand);
notice->rule()
.setMidAnchorX(root.viewRule().midX())
.setInput(Rule::Bottom, root.viewRule().midY());

chooseIwad = new ButtonWidget;
chooseIwad->setText(tr("Select IWAD Folder..."));
chooseIwad->setSizePolicy(ui::Expand, ui::Expand);
chooseIwad->rule()
.setMidAnchorX(root.viewRule().midX())
.setInput(Rule::Top, notice->rule().bottom());
iwadNotice->add(chooseIwad);

iwadNotice->rule().setRect(root.viewRule());
iwadNotice->hide();
container().add(iwadNotice);
}

// Common notification area.
notifications = new NotificationAreaWidget;
notifications->useDefaultPlacement(game->rule());
Expand Down Expand Up @@ -282,6 +295,9 @@ DENG2_PIMPL(ClientWindow)

taskBar->hide();

// Task bar provides the IWAD selection feature.
chooseIwad->setAction(new SignalAction(taskBar, SLOT(chooseIWADFolder())));

// Mouse cursor is used with transformed content.
cursor = new LabelWidget;
cursor->setBehavior(Widget::Unhittable);
Expand Down Expand Up @@ -310,21 +326,47 @@ DENG2_PIMPL(ClientWindow)
}
}

void gameReadinessUpdated()
{
DENG2_ASSERT(!App_GameLoaded());
showGameSelectionMenu(true);
}

void showGameSelectionMenu(bool show)
{
bool gotPlayable = App_Games().numPlayable();
if(show && gotPlayable)
{
gameSelMenu->show();
iwadNotice->hide();
}
else if(show && !gotPlayable)
{
gameSelMenu->hide();
iwadNotice->show();
}
else if(!show)
{
gameSelMenu->hide();
iwadNotice->hide();
}
}

void currentGameChanged(game::Game const &newGame)
{
if(newGame.isNull())
{
//game->hide();
background->show();
gameSelMenu->show();
showGameSelectionMenu(true);

gameSelMenu->restoreState();
}
else
{
//game->show();
background->hide();
gameSelMenu->hide();
showGameSelectionMenu(false);

gameSelMenu->saveState();
}
Expand Down Expand Up @@ -366,7 +408,7 @@ DENG2_PIMPL(ClientWindow)
game->disable();
gameUI->hide();
gameUI->disable();
gameSelMenu->hide();
showGameSelectionMenu(false);
taskBar->disable();

busy->show();
Expand All @@ -382,7 +424,7 @@ DENG2_PIMPL(ClientWindow)
game->enable();
gameUI->show();
gameUI->enable();
if(!App_GameLoaded()) gameSelMenu->show();
if(!App_GameLoaded()) showGameSelectionMenu(true);
taskBar->enable();
break;
}
Expand Down Expand Up @@ -640,6 +682,7 @@ DENG2_PIMPL(ClientWindow)
// All the children of the compositor need to be relocated.
container().remove(*gameUI);
container().remove(*gameSelMenu);
container().remove(*iwadNotice);
if(sidebar) container().remove(*sidebar);
container().remove(*notifications);
container().remove(*taskBarBlur);
Expand Down Expand Up @@ -687,6 +730,7 @@ DENG2_PIMPL(ClientWindow)
}

container().add(gameSelMenu);
container().add(iwadNotice);
if(sidebar) container().add(sidebar);
container().add(notifications);
container().add(taskBarBlur);
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -741,6 +741,7 @@ void TaskBarWidget::chooseIWADFolder()
if(reload)
{
ClientApp::resourceSystem().updateOverrideIWADPathFromConfig();
ClientWindow::main().console().closeLogAndUnfocusCommandLine();

Con_InitProgress(200);
App_Games().forgetAllResources();
Expand Down

0 comments on commit 44c2114

Please sign in to comment.