aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui.cpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-05-12 08:05:34 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-05-12 08:05:34 -0400
commitee4522669875b694911635b0c6cfbde7003ef040 (patch)
tree7841fd9bb0bd29798d31e9fe819ab4ededba67d3 /src/ui.cpp
parent5432b278f8ed8c9aaeccf1ee7a4da540787f965d (diff)
parentcab9a8f66e683d79b67a1a4d78b6e68009642534 (diff)
RENDERING
Diffstat (limited to 'src/ui.cpp')
-rw-r--r--src/ui.cpp74
1 files changed, 29 insertions, 45 deletions
diff --git a/src/ui.cpp b/src/ui.cpp
index dc6da8e..64e18fe 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -1101,6 +1101,16 @@ EXIT:
static vec2 fr;
static Entity *ig;
+ auto worldSwitch = [&](const WorldSwitchInfo& wsi){
+ player->canMove = false;
+ toggleBlackFast();
+ waitForCover();
+ wsi.first->bgmPlay(currentWorld);
+ std::tie(currentWorld, player->loc) = wsi;
+ toggleBlackFast();
+ player->canMove = true;
+ };
+
while(SDL_PollEvent(&e)) {
switch(e.type) {
@@ -1192,6 +1202,9 @@ EXIT:
// only let other keys be handled if dialog allows it
} else if (!dialogBoxExists || dialogPassive) {
switch(SDL_KEY) {
+ case SDLK_DELETE:
+ gameRunning = false;
+ break;
case SDLK_t:
game::time::tick(50);
break;
@@ -1204,15 +1217,8 @@ EXIT:
if (currentWorldToLeft) {
std::thread([&](void){
auto thing = currentWorld->goWorldLeft(player);
- if (thing.first != currentWorld) {
- player->canMove = false;
- toggleBlackFast();
- waitForCover();
- currentWorld = thing.first;
- player->loc = thing.second;
- toggleBlackFast();
- player->canMove = true;
- }
+ if (thing.first != currentWorld)
+ worldSwitch(thing);
}).detach();
}
break;
@@ -1225,15 +1231,8 @@ EXIT:
if (currentWorldToRight) {
std::thread([&](void){
auto thing = currentWorld->goWorldRight(player);
- if (thing.first != currentWorld) {
- player->canMove = false;
- toggleBlackFast();
- waitForCover();
- currentWorld = thing.first;
- player->loc = thing.second;
- toggleBlackFast();
- player->canMove = true;
- }
+ if (thing.first != currentWorld)
+ worldSwitch(thing);
}).detach();
}
break;
@@ -1241,30 +1240,14 @@ EXIT:
if (inBattle) {
std::thread([&](void){
auto thing = dynamic_cast<Arena *>(currentWorld)->exitArena(player);
- if (thing.first != currentWorld) {
- player->canMove = false;
- toggleBlackFast();
- waitForCover();
- //delete dynamic_cast<Arena *>(currentWorld);
- currentWorld = thing.first;
- player->loc = thing.second;
- toggleBlackFast();
- player->canMove = true;
- }
+ if (thing.first != currentWorld)
+ worldSwitch(thing);
}).detach();
} else {
std::thread([&](void){
auto thing = currentWorld->goInsideStructure(player);
- if (thing.first != currentWorld) {
- player->canMove = false;
- toggleBlackFast();
- waitForCover();
- currentWorld = thing.first;
- if (thing.second.x)
- player->loc.x = thing.second.x;
- toggleBlackFast();
- player->canMove = true;
- }
+ if (thing.first != currentWorld)
+ worldSwitch(thing);
}).detach();
}
break;
@@ -1342,11 +1325,10 @@ EXIT:
right = false;
break;
case SDLK_LSHIFT:
- if (player->speed == 4) {
+ if (player->speed == 4)
Mix_FadeOutChannel(1,2000);
- }
- player->speed = 1;
- break;
+
+ // fall through
case SDLK_LCTRL:
player->speed = 1;
break;
@@ -1354,9 +1336,11 @@ EXIT:
edown=false;
if (player->inv->invHover) {
player->inv->invHover = false;
- }else{
- if (!player->inv->selected)player->inv->invOpening ^= true;
- else player->inv->selected = false;
+ } else {
+ if (!player->inv->selected)
+ player->inv->invOpening ^= true;
+ else
+ player->inv->selected = false;
player->inv->mouseSel = false;
}