added getCurrentContext()

This commit is contained in:
Lendemor 2016-12-14 21:57:14 +01:00
parent f2856dcf63
commit 273e8cc7e6
2 changed files with 57 additions and 54 deletions

View File

@ -95,14 +95,18 @@ std::vector<int> Input::getActions()
}
/* context-related functions */
void Input::addContext(Context context)
{
m_contexts.push_back(context);
}
void Input::setCurrentContext(std::string context_name){
m_current_context = context_name;
}
//void Input::addContext(Context context)
//{
// m_contexts.push_back(context);
//}
//std::string Input::getCurrentContext()
//{
// return m_current_context;
//}
//void Input::setCurrentContext(std::string context_name){
// m_current_context = context_name;
//}
void Input::updateKeyBindings(){
m_keybindings.clear();

View File

@ -11,7 +11,34 @@
#include "textbuffer.h"
class Input{
public:
private:
/* window-related variables */
sf::Window* m_window;
bool m_closeRequested;
bool m_hasBeenResized;
/* general action-mapping variables */
IKeysMap m_keysmap;
std::vector<int> m_actions;
int nb_actions;
/* context-related variables */
std::string m_current_context;
std::vector<Context> m_contexts;
std::unordered_map<std::string,KeyBindings> m_keybindings;
/* keyboard-related variables */
std::vector<sf::Keyboard::Key> m_heldkeys;
void releaseHeldKeys(sf::Keyboard::Key keycode);
/* mouse-related variables */
sf::Vector2i m_mouse_position;
sf::Vector2i m_last_mouse_position;
float m_delta_vertical_scroll;
/* text-related variable */
std::string m_buffer;
public:
/* Constructors */
Input(sf::Window *w);
@ -21,8 +48,9 @@ class Input{
std::vector<int> getActions(); //get the first action in the file of event
/* context-related functions */
void addContext(Context context);
void setCurrentContext(std::string context_name);
void addContext(Context context){m_contexts.push_back(context);}
std::string getCurrentContext(){return m_current_context;}
void setCurrentContext(std::string context_name){m_current_context = context_name;}
void updateKeyBindings();
/* window-related function */
@ -41,35 +69,6 @@ class Input{
std::string getText();
void test();
private:
/* window-related variables */
sf::Window* m_window;
bool m_closeRequested;
bool m_hasBeenResized;
/* general action-mapping variables */
IKeysMap m_keysmap;
std::vector<int> m_actions;
int nb_actions;
/* context-related variables */
std::string m_current_context;
//std::unordered_map<std::string, std::vector<int>> contexts;
std::vector<Context> m_contexts;
std::unordered_map<std::string,KeyBindings> m_keybindings;
/* keyboard-related variables */
std::vector<sf::Keyboard::Key> m_heldkeys;
void releaseHeldKeys(sf::Keyboard::Key keycode);
/* mouse-related variables */
sf::Vector2i m_mouse_position;
sf::Vector2i m_last_mouse_position;
float m_delta_vertical_scroll;
/* text-related variable */
std::string m_buffer;
};
#endif //INPUT_H