Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master' into savegame-re…
Browse files Browse the repository at this point in the history
…factor
  • Loading branch information
danij-deng committed Mar 10, 2014
2 parents c7f6397 + 620b91a commit 25b533e
Show file tree
Hide file tree
Showing 14 changed files with 299 additions and 50 deletions.
8 changes: 8 additions & 0 deletions doomsday/client/src/ui/clientwindow.cpp
Expand Up @@ -257,6 +257,14 @@ DENG2_PIMPL(ClientWindow)
// Allow the background image to show.
background->setImageColor(Vector4f(1, 1, 1, 1));
taskBar->show();

// Show the tutorial if it hasn't been automatically shown yet.
if(!App::config().getb("tutorial.shown", false))
{
App::config().set("tutorial.shown", true);

taskBar->showTutorial();
}
}

void currentGameChanged(game::Game const &newGame)
Expand Down
12 changes: 6 additions & 6 deletions doomsday/client/src/ui/widgets/inputbindingwidget.cpp
Expand Up @@ -63,22 +63,22 @@ DENG_GUI_PIMPL(InputBindingWidget)
return eventDesc;
}

String name = eventDesc.mid(4, eventDesc.indexOf("-", 4) - 4);
name = name.mid(0, 1).toUpper() + name.mid(1).toLower();
String name = eventDesc.substr(Rangei(4, eventDesc.indexOf("-", 4)));
name = name.left(1).toUpper() + name.mid(1).toLower();

// Any modifiers?
int idx = eventDesc.indexOf("+");
if(idx > 0)
{
String const conds = eventDesc.mid(idx + 1);
if(conds.contains("key-ctrl-down") || conds.contains("key-control-down"))
{
name = String(CONTROL_CHAR) + name;
}
if(conds.contains("key-alt-down"))
{
name = String(DENG2_CHAR_ALT_KEY) + name;
}
if(conds.contains("key-ctrl-down") || conds.contains("key-control-down"))
{
name = String(CONTROL_CHAR) + name;
}
if(conds.contains("key-shift-down"))
{
name = String(DENG2_CHAR_SHIFT_KEY) + name;
Expand Down
32 changes: 26 additions & 6 deletions doomsday/client/src/ui/widgets/tutorialwidget.cpp
Expand Up @@ -25,9 +25,12 @@

#include <de/MessageDialog>
#include <de/SignalAction>
#include <de/Untrapper>

using namespace de;

static TimeDelta const FLASH_SPAN = 0.6;

DENG_GUI_PIMPL(TutorialWidget)
{
enum Step {
Expand All @@ -44,37 +47,49 @@ DENG_GUI_PIMPL(TutorialWidget)
MessageDialog *dlg;
LabelWidget *highlight;
QTimer flashing;
bool taskBarInitiallyOpen;
Untrapper untrapper;

Instance(Public *i)
: Base(i)
, current(Welcome)
, dlg(0)
, taskBarInitiallyOpen(ClientWindow::main().taskBar().isOpen())
, untrapper(ClientWindow::main())
{
self.add(darken = new LabelWidget);
darken->set(Background(style().colors().colorf("altaccent") *
Vector4f(.3f, .3f, .3f, .55f)));
darken->setOpacity(0);

self.add(highlight = new LabelWidget);
highlight->set(Background(Background::BorderGlow,
/*highlight->set(Background(Background::BorderGlow,
style().colors().colorf("accent"),
style().rules().rule("glow").value()));
style().rules().rule("glow").value()));*/
highlight->set(Background(Background::GradientFrame,
style().colors().colorf("accent"), 6));
highlight->setOpacity(0);

flashing.setSingleShot(false);
flashing.setInterval(1000);
flashing.setInterval(FLASH_SPAN.asMilliSeconds());
}

void flash()
{
highlight->setOpacity(.6f);
highlight->setOpacity(.3f, 1, .4f);
if(highlight->opacity().target() > .5f)
{
highlight->setOpacity(.2f, FLASH_SPAN);
}
else
{
highlight->setOpacity(.8f, FLASH_SPAN);
}
}

void startHighlight(GuiWidget const &w)
{
highlight->rule().setRect(w.rule());

highlight->setOpacity(.2f);
highlight->show();
flashing.start();
flash();
Expand Down Expand Up @@ -234,6 +249,11 @@ void TutorialWidget::start()

void TutorialWidget::stop()
{
if(!d->taskBarInitiallyOpen)
{
ClientWindow::main().taskBar().close();
}

d->deinitStep();

// Animate away and unfade darkening.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/libappfw/include/de/Untrapper
@@ -0,0 +1,2 @@
#include "framework/untrapper.h"

47 changes: 47 additions & 0 deletions doomsday/libappfw/include/de/framework/untrapper.h
@@ -0,0 +1,47 @@
/** @file untrapper.h Mouse untrapping utility.
*
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* LGPL: http://www.gnu.org/licenses/lgpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBAPPFW_UNTRAPPER_H
#define LIBAPPFW_UNTRAPPER_H

#include "../libappfw.h"
#include <de/CanvasWindow>

namespace de {

/**
* Utility for untrapping the mouse. The mouse is untrapped from the specified window for
* the lifetime of the Untrapper instance. When Untrapper is destroyed, mouse is
* automatically trapped if it originally was trapped.
*/
class LIBAPPFW_PUBLIC Untrapper
{
public:
/**
* Mouse is untrapped if it has been trapped in @a window.
* @param window Window where (un)trapping is done.
*/
Untrapper(CanvasWindow &window);

private:
DENG2_PRIVATE(d)
};

} // namespace de

#endif // LIBAPPFW_UNTRAPPER_H
3 changes: 3 additions & 0 deletions doomsday/libappfw/libappfw.pro
Expand Up @@ -75,6 +75,7 @@ publicHeaders(root, \
include/de/TabWidget \
include/de/TextDrawable \
include/de/ToggleWidget \
include/de/Untrapper \
include/de/VRWindowTransform \
include/de/WindowSystem \
include/de/WindowTransform \
Expand Down Expand Up @@ -128,6 +129,7 @@ publicHeaders(framework, \
include/de/framework/submenuitem.h \
include/de/framework/subwidgetitem.h \
include/de/framework/textdrawable.h \
include/de/framework/untrapper.h \
include/de/framework/variabletoggleitem.h \
include/de/framework/vrwindowtransform.h \
include/de/framework/windowsystem.h \
Expand Down Expand Up @@ -197,6 +199,7 @@ SOURCES += \
src/signalaction.cpp \
src/style.cpp \
src/textdrawable.cpp \
src/untrapper.cpp \
src/vrwindowtransform.cpp \
src/vr/oculusrift.cpp \
src/vr/vrconfig.cpp \
Expand Down
49 changes: 49 additions & 0 deletions doomsday/libappfw/src/untrapper.cpp
@@ -0,0 +1,49 @@
/** @file untrapper.cpp Mouse untrapping utility.
*
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* LGPL: http://www.gnu.org/licenses/lgpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#include "de/Untrapper"

namespace de {

DENG2_PIMPL(Untrapper)
{
CanvasWindow &window;
bool wasTrapped;

Instance(Public *i, CanvasWindow &w) : Base(i), window(w)
{
wasTrapped = window.canvas().isMouseTrapped();
if(wasTrapped)
{
window.canvas().trapMouse(false);
}
}

~Instance()
{
if(wasTrapped)
{
window.canvas().trapMouse();
}
}
};

Untrapper::Untrapper(CanvasWindow &window) : d(new Instance(this, window))
{}

} // namespace de
18 changes: 5 additions & 13 deletions doomsday/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -25,6 +25,7 @@

#include <de/KeyEvent>
#include <de/MouseEvent>
#include <de/Untrapper>
#include <QEventLoop>

namespace de {
Expand Down Expand Up @@ -95,7 +96,7 @@ public ChildWidgetOrganizer::IFilter
bool needButtonUpdate;
float normalGlow;
bool animatingGlow;
bool needTrapAfterClose;
QScopedPointer<Untrapper> untrapper;
DialogContentStylist stylist;

Instance(Public *i, Flags const &dialogFlags)
Expand All @@ -106,7 +107,6 @@ public ChildWidgetOrganizer::IFilter
, acceptAction(0)
, needButtonUpdate(false)
, animatingGlow(false)
, needTrapAfterClose(false)
{
// Initialize the border glow.
normalGlow = style().colors().colorf("glow").w;
Expand Down Expand Up @@ -615,12 +615,8 @@ void DialogWidget::reject(int result)

void DialogWidget::prepare()
{
if(root().window().canvas().isMouseTrapped())
{
// Mouse needs to be untrapped for the user to be access the dialog.
root().window().canvas().trapMouse(false);
d->needTrapAfterClose = true;
}
// Mouse needs to be untrapped for the user to be access the dialog.
d->untrapper.reset(new Untrapper(root().window()));

root().setFocus(0);

Expand Down Expand Up @@ -651,11 +647,7 @@ void DialogWidget::finish(int result)
root().setFocus(0);
close();

if(d->needTrapAfterClose)
{
root().window().canvas().trapMouse();
d->needTrapAfterClose = false;
}
d->untrapper.reset();

if(result > 0)
{
Expand Down
28 changes: 14 additions & 14 deletions doomsday/libdeng2/include/de/core/config.h
Expand Up @@ -49,10 +49,6 @@ class ArrayValue;
*/
class DENG2_PUBLIC Config
{
public:
/// Attempted to get the value of a variable while expecting the wrong type. @ingroup errors
DENG2_ERROR(ValueTypeError);

public:
/**
* Constructs a new configuration.
Expand All @@ -68,36 +64,40 @@ class DENG2_PUBLIC Config
void write() const;

/// Returns the value of @a name as a Value.
Value &get(String const &name) const;
Value const &get(String const &name) const;

/// Returns the value of @a name as an integer.
dint geti(String const &name) const;

dint geti(String const &name, dint defaultValue) const;

/// Returns the value of @a name as a boolean.
bool getb(String const &name) const;

bool getb(String const &name, bool defaultValue) const;

/// Returns the value of @a name as an unsigned integer.
duint getui(String const &name) const;

duint getui(String const &name, duint defaultValue) const;

/// Returns the value of @a name as a double-precision floating point number.
ddouble getd(String const &name) const;

ddouble getd(String const &name, ddouble defaultValue) const;

/// Returns the value of @a name as a string.
String gets(String const &name) const;

String gets(String const &name, String const &defaultValue) const;

/// Returns the value of @a name as an array value. An exception is thrown
/// if the variable does not have an array value.
ArrayValue &geta(String const &name) const;
ArrayValue const &geta(String const &name) const;

template <typename ValueType>
ValueType &getAs(String const &name) const {
ValueType *v = dynamic_cast<ValueType *>(&get(name));
if(!v)
{
throw ValueTypeError("Config::getAs", String("Cannot cast to expected type (") +
DENG2_TYPE_NAME(ValueType) + ")");
}
return *v;
ValueType const &getAs(String const &name) const {
return names().getAs<ValueType>(name);
}

/**
Expand Down

0 comments on commit 25b533e

Please sign in to comment.