aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-07-03 17:40:14 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-07-03 17:40:14 -0400
commit71849171e90dc5c25e41e53c55569494a952678e (patch)
tree12fc4b8734c34e79cc976f01bae2babf5102a5fd /src
parent4907843ac7a43d5d3519f9696ae90e0736d96c9d (diff)
control saving wip, but no segfault
Diffstat (limited to 'src')
-rw-r--r--src/ui.cpp24
-rw-r--r--src/ui_menu.cpp20
2 files changed, 24 insertions, 20 deletions
diff --git a/src/ui.cpp b/src/ui.cpp
index 9644381..c120730 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -30,8 +30,8 @@ extern std::vector<NPC *> aipreload;
extern bool gameRunning;
-static std::array<SDL_Keycode, 7> controlMap = {
- SDLK_w, SDLK_s, SDLK_a, SDLK_d, SDLK_LSHIFT, SDLK_LCTRL, SDLK_e
+static std::array<SDL_Keycode, 6> controlMap = {
+ SDLK_w, SDLK_a, SDLK_d, SDLK_LSHIFT, SDLK_LCTRL, SDLK_e
};
void setControl(unsigned int index, SDL_Keycode key)
@@ -1437,7 +1437,7 @@ EXIT:
worldSwitch(thing);
}).detach();
}
- } else if (SDL_KEY == controlMap[2]) {
+ } else if (SDL_KEY == controlMap[1]) {
if (!fadeEnable) {
player->vel.x = -PLAYER_SPEED_CONSTANT;
if (std::stoi(game::getValue("Slow")) == 1)
@@ -1452,7 +1452,7 @@ EXIT:
}).detach();
}
}
- } else if (SDL_KEY == controlMap[3]) {
+ } else if (SDL_KEY == controlMap[2]) {
if (!fadeEnable) {
player->vel.x = PLAYER_SPEED_CONSTANT;
if (std::stoi(game::getValue("Slow")) == 1)
@@ -1467,7 +1467,7 @@ EXIT:
}).detach();
}
}
- } else if (SDL_KEY == controlMap[4]) {
+ } else if (SDL_KEY == controlMap[3]) {
if (game::canSprint) {
if (debug) {
Mix_PlayChannel(1, sanic, -1);
@@ -1476,9 +1476,9 @@ EXIT:
player->speed = 2.0f;
}
}
- } else if (SDL_KEY == controlMap[5]) {
+ } else if (SDL_KEY == controlMap[4]) {
player->speed = .5;
- } else if (SDL_KEY == controlMap[6]) {
+ } else if (SDL_KEY == controlMap[5]) {
edown = true;
// start hover counter?
@@ -1515,18 +1515,18 @@ EXIT:
ui::menu::toggle();
player->save();
return;
- } else if (SDL_KEY == controlMap[2]) {
+ } else if (SDL_KEY == controlMap[1]) {
left = false;
- } else if (SDL_KEY == controlMap[3]) {
+ } else if (SDL_KEY == controlMap[2]) {
right = false;
- } else if (SDL_KEY == controlMap[4]) {
+ } else if (SDL_KEY == controlMap[3]) {
if (player->speed == 4)
Mix_FadeOutChannel(1, 2000);
player->speed = 1;
- } else if (SDL_KEY == controlMap[5]) {
+ } else if (SDL_KEY == controlMap[4]) {
player->speed = 1;
- } else if (SDL_KEY == controlMap[6]) {
+ } else if (SDL_KEY == controlMap[5]) {
edown = false;
if (player->inv->invHover) {
diff --git a/src/ui_menu.cpp b/src/ui_menu.cpp
index d842ece..2419ed2 100644
--- a/src/ui_menu.cpp
+++ b/src/ui_menu.cpp
@@ -48,7 +48,7 @@ std::string sym2str(const SDL_Keycode& c)
case SDLK_LCTRL : s = "LCONTROL"; break;
case SDLK_RCTRL : s = "RCONTROL"; break;
case SDLK_TAB : s = "TAB" ; break;
- default : s = "SHIT" ; break;
+ default : s += static_cast<char>(c); break;
}
return s;
@@ -61,10 +61,14 @@ void initControls(Menu *m)
SDL_Keycode z;
for (const auto &l : cfg) {
-
z = static_cast<SDL_Keycode>(std::stoi(l));
setControl(i, z);
- m->items[i++].button.text += sym2str(z);
+ std::cout<<"1\n";
+ auto fs = sym2str(z);
+ std::cout<<"2 " << i << "\n";
+ std::cout<<m->items[i].button.text<<'\n';
+ m->items[i++].button.text += fs;
+ std::cout<<"3\n";
}
}
@@ -172,17 +176,17 @@ namespace ui {
// Create the controls menu
controlsMenu.items.push_back(ui::menu::createButton({-450,300}, {400, 75}, {0.0f, 0.0f, 0.0f}, "Left: ", nullptr));
- controlsMenu.items.back().button.func = [](){ setControlF(2, controlsMenu.items[0]); };
+ controlsMenu.items.back().button.func = [](){ setControlF(1, controlsMenu.items[0]); };
controlsMenu.items.push_back(ui::menu::createButton({-450,200}, {400, 75}, {0.0f, 0.0f, 0.0f}, "Right: ", nullptr));
- controlsMenu.items.back().button.func = [](){ setControlF(3, controlsMenu.items[1]); };
+ controlsMenu.items.back().button.func = [](){ setControlF(2, controlsMenu.items[1]); };
controlsMenu.items.push_back(ui::menu::createButton({-450,100}, {400, 75}, {0.0f, 0.0f, 0.0f}, "Up: ", nullptr));
controlsMenu.items.back().button.func = [](){ setControlF(0, controlsMenu.items[2]); };
controlsMenu.items.push_back(ui::menu::createButton({-450,0}, {400, 75}, {0.0f, 0.0f, 0.0f}, "Sprint: ", nullptr));
- controlsMenu.items.back().button.func = [](){ setControlF(4, controlsMenu.items[3]); };
+ controlsMenu.items.back().button.func = [](){ setControlF(3, controlsMenu.items[3]); };
controlsMenu.items.push_back(ui::menu::createButton({-450,-100}, {400, 75}, {0.0f, 0.0f, 0.0f}, "Creep: ", nullptr));
- controlsMenu.items.back().button.func = [](){ setControlF(5, controlsMenu.items[4]); };
+ controlsMenu.items.back().button.func = [](){ setControlF(4, controlsMenu.items[4]); };
controlsMenu.items.push_back(ui::menu::createButton({-450,-200}, {400, 75}, {0.0f, 0.0f, 0.0f}, "Inventory: ", nullptr));
- controlsMenu.items.back().button.func = [](){ setControlF(6, controlsMenu.items[5]); };
+ controlsMenu.items.back().button.func = [](){ setControlF(5, controlsMenu.items[5]); };
controlsMenu.parent = &pauseMenu;
initControls(&controlsMenu);
}