#include #include #include #include #include #include "abstractAppState.h" #include "defConfigs.h" using namespace game::core; using namespace vb01; using namespace std; namespace game{ namespace core{ void AbstractAppState::onAttachment() { const int stateId=(int)type,numBinds=core::numBinds[stateId]; int firstLine=0,lastLine; for(int i=0;i lines; readFile(PATH_STR + "../options.cfg", lines, firstLine,lastLine); for(int i=0;i>std::hex>>trigger; } Mapping::Bind bind=binds[stateId][i]; Mapping::BindType type = (stateId > 0 ? Mapping::KEYBOARD : Mapping::MOUSE_KEY); bool isAnalog = core::isAnalog[stateId][i]; Mapping *m = new Mapping; m->bind = bind; m->trigger = trigger; m->type = type; m->action = !isAnalog; attachedKeys.push_back(m); } attached = true; } void AbstractAppState::onDetachment() { attached = false; } void AbstractAppState::detachKey(Mapping *key) { for (int i = 0; i < attachedKeys.size(); i++) if (key == attachedKeys[i]) { delete key; attachedKeys.erase(attachedKeys.begin() + i); } } void AbstractAppState::detachAllKeys() { while (attachedKeys.size() > 0) { delete attachedKeys[attachedKeys.size() - 1]; attachedKeys.pop_back(); } } } }