switched from string to wstring

This commit is contained in:
Lendemor 2017-01-22 17:50:49 +01:00
parent d3e7128f87
commit 8b7d644958
2 changed files with 7 additions and 6 deletions

View File

@ -55,7 +55,9 @@ void Input::updateEvents(){
break; break;
case sf::Event::TextEntered: case sf::Event::TextEntered:
c = (char) event.text.unicode; c = (char) event.text.unicode;
m_buffer.push_back(c); sf::Utf32::encodeAnsi(event.text.unicode,std::back_inserter(m_buffer));
// std::cout << << std::endl;
// m_buffer.push_back('\u9190');
break; break;
case sf::Event::KeyPressed: case sf::Event::KeyPressed:
action = kb.getPressedAction(event.key.code); action = kb.getPressedAction(event.key.code);
@ -182,10 +184,9 @@ void Input::setMouseGrabbed(bool isGrabbed)
m_last_mouse_position = sf::Vector2i(m_window->getSize())/2; m_last_mouse_position = sf::Vector2i(m_window->getSize())/2;
} }
std::string Input::getText() std::wstring Input::getText()
{ {
std::string t = m_buffer; return m_buffer;
return t;
} }
/* ------ */ /* ------ */

View File

@ -38,7 +38,7 @@ private:
bool m_mouseGrabbed; bool m_mouseGrabbed;
/* text-related variable */ /* text-related variable */
std::string m_buffer; std::wstring m_buffer;
public: public:
/* Constructors */ /* Constructors */
Input(sf::Window *w); Input(sf::Window *w);
@ -72,7 +72,7 @@ public:
bool isMouseGrabbed() const { return m_mouseGrabbed; } bool isMouseGrabbed() const { return m_mouseGrabbed; }
/* text-related function */ /* text-related function */
std::string getText(); std::wstring getText();
void test(); void test();
}; };