Skip to content

Commit

Permalink
Gloom: Changed mouse look to toggle grab on mouse click
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent e3d9d73 commit cc64a0a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion doomsday/apps/gloom/src/gloomapp.cpp
Expand Up @@ -148,7 +148,7 @@ void GloomApp::initialize()

// Load resource banks.
{
const Package &base = App::packageLoader().package("net.dengine.gloom.test");
const Package &base = packageLoader().package("net.dengine.gloom.test");
d->images .addFromInfo(base.root().locate<File>("images.dei"));
waveforms().addFromInfo(base.root().locate<File>("audio.dei"));
}
Expand Down
36 changes: 15 additions & 21 deletions doomsday/apps/gloom/src/gloomwidget.cpp
Expand Up @@ -40,7 +40,6 @@ DE_GUI_PIMPL(GloomWidget)
User user;
User::InputState inputs;
bool mouseLook = false;
Vec2i lastMousePos;

Impl(Public *i) : Base(i)
{}
Expand Down Expand Up @@ -211,32 +210,27 @@ bool GloomWidget::handleEvent(Event const &event)

if (mouse.type() == Event::MouseWheel)
{
d->user.turn(Vec2f(mouse.wheel()) / 10.f);
d->user.turn(Vec2f(mouse.wheel()) / 1.f);
return true;
}

if (d->mouseLook)
if (mouse.type() == Event::MouseMotion && d->mouseLook)
{
const Vec2i delta = mouse.pos() - d->lastMousePos;
d->lastMousePos = mouse.pos();

d->user.turn(Vec2f(delta) / 7.f);
d->user.turn(Vec2f(mouse.pos()) / 7.f);
return true;
}

switch (handleMouseClick(event, MouseEvent::Left))
if (mouse.type() == Event::MouseButton)
{
case MouseClickStarted:
d->lastMousePos = mouse.pos();
d->mouseLook = true;
break;

default:
d->mouseLook = false;
break;

case MouseClickUnrelated:
break;
switch (handleMouseClick(event, MouseEvent::Left))
{
case MouseClickFinished:
d->mouseLook = !d->mouseLook;
root().window().eventHandler().trapMouse(d->mouseLook);
break;

default:
break;
}
return true;
}
}

Expand Down
1 change: 0 additions & 1 deletion doomsday/apps/gloom/src/mainwindow.cpp
Expand Up @@ -135,7 +135,6 @@ DE_PIMPL(MainWindow)
{
auto &loop = Loop::get();
loop.setRate(hasFocus ? 60 : 1);
self().eventHandler().trapMouse(hasFocus);
}
};

Expand Down
2 changes: 0 additions & 2 deletions doomsday/libs/appfw/src/guirootwidget.cpp
Expand Up @@ -347,8 +347,6 @@ bool GuiRootWidget::processEvent(Event const &event)
{
window().glActivate();

debug("GuiRootWidget ev:%i", event.type());

if ((event.type() == Event::MouseButton &&
event.as<MouseEvent>().state() != MouseEvent::Released) ||
event.type() == Event::MouseWheel)
Expand Down

0 comments on commit cc64a0a

Please sign in to comment.