[Key] Small fix for multiplayer mode.
If the 'config/keys.lua' file didn't exist custom keys were empty.
This commit is contained in:
parent
4ac67eedd4
commit
e3dc327b71
@ -36,7 +36,7 @@ Example:
|
||||
default_key = "E"
|
||||
```
|
||||
|
||||
Names are defined [here](https://github.com/Unarelith/GameKit/blob/master/source/core/input/KeyboardUtils.cpp).
|
||||
Names are defined [here](https://wiki.libsdl.org/SDL_Keycode).
|
||||
|
||||
### `name`
|
||||
|
||||
|
@ -44,7 +44,13 @@ class Key : public gk::ISerializable {
|
||||
: m_id(id), m_stringID(stringID), m_name(name) {}
|
||||
|
||||
void serialize(sf::Packet &packet) const override { packet << m_id << m_stringID << m_name << m_defaultKey; }
|
||||
void deserialize(sf::Packet &packet) override { packet >> m_id >> m_stringID >> m_name >> m_defaultKey; }
|
||||
void deserialize(sf::Packet &packet) override {
|
||||
packet >> m_id >> m_stringID >> m_name >> m_defaultKey;
|
||||
|
||||
// Needed for multiplayer mode
|
||||
if (m_keycode == SDLK_UNKNOWN)
|
||||
m_keycode = SDL_GetKeyFromName(m_defaultKey.c_str());
|
||||
}
|
||||
|
||||
u16 id() const { return m_id; }
|
||||
|
||||
@ -59,6 +65,7 @@ class Key : public gk::ISerializable {
|
||||
void setDefaultKey(const std::string &defaultKey) {
|
||||
m_defaultKey = defaultKey;
|
||||
|
||||
// Needed for singleplayer mode
|
||||
if (m_keycode == SDLK_UNKNOWN)
|
||||
m_keycode = SDL_GetKeyFromName(m_defaultKey.c_str());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user