void MasterState::OnResume() {
if (spawn_index.MissingChunks() > 0) {
env.state.Push(&preload);
- }
- if (config.input.mouse) {
- env.window.GrabMouse();
+ return;
}
if (spawn_player) {
// TODO: spawn
spawn_player = false;
}
hud.KeepMessages(false);
+ OnFocus();
}
void MasterState::OnPause() {
+ OnBlur();
+}
+
+void MasterState::OnFocus() {
+ if (config.input.mouse) {
+ env.window.GrabMouse();
+ }
+ interface.Unlock();
+}
+
+void MasterState::OnBlur() {
env.window.ReleaseMouse();
+ interface.Lock();
}
void MasterState::Handle(const SDL_Event &event) {
switch (event.type) {
case SDL_KEYDOWN:
- // TODO: move to interface?
+ // TODO: move to interface
if (event.key.keysym.sym == SDLK_RETURN) {
env.state.Push(&chat);
hud.KeepMessages(true);
}
void MasterState::OnLineSubmit(const std::string &line) {
- hud.PostMessage(line);
+ if (!line.empty()) {
+ hud.PostMessage(line);
+ }
}
}