diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-07-03 17:40:14 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-07-03 17:40:14 -0400 |
commit | 71849171e90dc5c25e41e53c55569494a952678e (patch) | |
tree | 12fc4b8734c34e79cc976f01bae2babf5102a5fd | |
parent | 4907843ac7a43d5d3519f9696ae90e0736d96c9d (diff) |
control saving wip, but no segfault
-rw-r--r-- | src/ui.cpp | 24 | ||||
-rw-r--r-- | src/ui_menu.cpp | 20 | ||||
-rw-r--r-- | xml/!town.xml | 4 |
3 files changed, 26 insertions, 22 deletions
@@ -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); } diff --git a/xml/!town.xml b/xml/!town.xml index a7a1270..e3a6a20 100644 --- a/xml/!town.xml +++ b/xml/!town.xml @@ -4,8 +4,8 @@ <generation type="Random" width="1600"/> <time>6000</time> <spawnx>-300</spawnx> - <npc name="Sanc" hasDialog="true" health="1" x="223.98889" y="74.797943" dindex="0"/> - <npc name="Bob" hasDialog="true" spawnx="30" health="1" x="143.87997" y="72.197983" dindex="0"/> + <npc name="Sanc" hasDialog="true" health="1" x="34.877903" y="70.59893" dindex="0"/> + <npc name="Bob" hasDialog="true" spawnx="30" health="1" x="-134.12997" y="69.999039" dindex="0"/> <structure type="1" spawnx="300" alive="1"/> <structure inside="bobshouse.xml" type="1" spawnx="10" alive="1"/> <chest alive="1"/> |