added save and load of keysmap in keymapper
This commit is contained in:
parent
13add53503
commit
7b91e32361
@ -5,9 +5,13 @@
|
|||||||
#include "SparrowInput/input.h"
|
#include "SparrowInput/input.h"
|
||||||
#include "defaultkeysmap.h"
|
#include "defaultkeysmap.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <cereal/cereal.hpp>
|
||||||
|
#include <cereal/archives/json.hpp>
|
||||||
|
|
||||||
KeyMapper::KeyMapper() :
|
KeyMapper::KeyMapper() :
|
||||||
m_enabled(false),
|
m_enabled(false),
|
||||||
|
m_keymap_file("keymap.json"),
|
||||||
m_waiting_for_input(-1)
|
m_waiting_for_input(-1)
|
||||||
{
|
{
|
||||||
// mapping between action numerical value and text value
|
// mapping between action numerical value and text value
|
||||||
@ -190,8 +194,17 @@ void KeyMapper::gui()
|
|||||||
getEngine().getInput()->updateKeyBindings();
|
getEngine().getInput()->updateKeyBindings();
|
||||||
}
|
}
|
||||||
//save
|
//save
|
||||||
|
if(ImGui::Button("Save Keymap")){
|
||||||
|
std::ofstream os(m_keymap_file);
|
||||||
|
cereal::JSONOutputArchive output(os);
|
||||||
|
output(m_keysmap);
|
||||||
|
}
|
||||||
//load
|
//load
|
||||||
|
if(ImGui::Button("Load Keymap")){
|
||||||
|
std::ifstream is(m_keymap_file);
|
||||||
|
cereal::JSONInputArchive input(is);
|
||||||
|
// input(m_keysmap);
|
||||||
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ class KeyMapper : public SceneNode
|
|||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
int m_selected_context;
|
int m_selected_context;
|
||||||
IKeysMap m_keysmap;
|
IKeysMap m_keysmap;
|
||||||
|
std::string m_keymap_file;
|
||||||
|
|
||||||
std::map<int,std::string> m_mouse_buttons;
|
std::map<int,std::string> m_mouse_buttons;
|
||||||
std::map<int,std::string> m_keyboard_keys;
|
std::map<int,std::string> m_keyboard_keys;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user