From 25ab63591ae98133b192f825565a668bc0579f21 Mon Sep 17 00:00:00 2001 From: darkrose Date: Fri, 12 Jun 2015 20:59:21 +1000 Subject: [PATCH] darken world behind menus/forms, and fix that old ungrabbed mouse bug when inventory is closed --- src/client.cpp | 1 + src/client.h | 7 ++++--- src/game.cpp | 11 +++++++++-- src/guiFormSpecMenu.cpp | 1 + src/map.cpp | 19 ++++++++++++------- src/modalMenu.h | 1 + 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 232149e..6df9bc0 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -233,6 +233,7 @@ Client::Client( m_pointed_node(-32768,-32768,-32768), m_pointed_content(CONTENT_IGNORE), m_time_of_day(0), + m_form_open(false), m_map_seed(0), m_map_type(MGT_DEFAULT), m_password(password), diff --git a/src/client.h b/src/client.h index d649ed6..e6a3508 100644 --- a/src/client.h +++ b/src/client.h @@ -341,6 +341,9 @@ public: bool getServerSuffocation() {return m_server_suffocation;} bool getServerHunger() {return m_server_hunger;} + bool getFormState() {return m_form_open;} + void setFormState(bool state) {m_form_open = state;} + private: // Virtual methods from con::PeerHandler @@ -394,9 +397,7 @@ private: // Received from the server. 0-23999 u32 m_time_of_day; - // 0 <= m_daynight_i < DAYNIGHT_CACHE_COUNT - //s32 m_daynight_i; - //u32 m_daynight_ratio; + bool m_form_open; Queue m_chat_queue; diff --git a/src/game.cpp b/src/game.cpp index 35bf5dc..36d6e47 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1672,6 +1672,7 @@ void the_game( // Launch pause menu (new GUIPauseMenu(guienv, guiroot, -1, g_gamecallback, &g_menumgr))->drop(); + client.setFormState(true); /* Some statistics are collected in these @@ -1754,6 +1755,7 @@ void the_game( (new GUIPasswordChange(guienv, guiroot, -1, &g_menumgr, &client))->drop(); g_gamecallback->changepassword_requested = false; + client.setFormState(true); } /* @@ -1952,6 +1954,7 @@ void the_game( menu->setFormSpec(fio->getForm(), inventoryloc); menu->setFormIO(fio); menu->drop(); + client.setFormState(true); }else if (input->wasKeyDown(EscapeKey)) { infostream<<"the_game: Launching pause menu"<setMousePos(displaycenter.X, displaycenter.Y+25); + client.setFormState(true); }else if (input->wasKeyDown(getKeySetting(VLKC_CHAT))) { FormIO *fio = new ChatFormIO(&client); @@ -2593,6 +2597,7 @@ void the_game( sound = "open-menu"; client.playSound(sound,0); } + client.setFormState(true); } } if (input->getRightClicked()) { @@ -3006,8 +3011,10 @@ void the_game( int crosshair = 1; if (g_menumgr.menuCount() > 0) { crosshair = 0; - }else if (client.getPointedContent() != CONTENT_IGNORE) { - crosshair = 2; + }else{ + client.setFormState(false); + if (client.getPointedContent() != CONTENT_IGNORE) + crosshair = 2; } MapNode snode; v3s16 spos = v3s16(0,0,0); diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index 1029c2f..672f9a7 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -681,6 +681,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event) KeyPress kp(event.KeyInput); if (event.KeyInput.PressedDown && (kp == EscapeKey || kp == getKeySetting(VLKC_INVENTORY))) { m_tooltip_element->setVisible(false); + acceptInput(); quitMenu(); return true; } diff --git a/src/map.cpp b/src/map.cpp index 844ec27..3b95417 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3557,15 +3557,20 @@ void ClientMap::renderPostFx() m_camera_mutex.Lock(); v3f camera_position = m_camera_position; m_camera_mutex.Unlock(); + video::SColor post_effect_color(0,0,0,0); - MapNode n = getNodeNoEx(floatToInt(camera_position, BS)); + if (m_client->getFormState()) { + post_effect_color = video::SColor(128,0,0,0); + }else{ + MapNode n = getNodeNoEx(floatToInt(camera_position, BS)); - // - If the player is in a solid node, make everything black. - // - If the player is in liquid, draw a semi-transparent overlay. - ContentFeatures& features = content_features(n); - video::SColor post_effect_color = features.post_effect_color; - if (features.solidness == 2 && m_client->getLocalPlayer()->control.free == false) { - post_effect_color = video::SColor(255, 0, 0, 0); + // - If the player is in a solid node, make everything black. + // - If the player is in liquid, draw a semi-transparent overlay. + ContentFeatures& features = content_features(n); + post_effect_color = features.post_effect_color; + if (features.solidness == 2 && m_client->getLocalPlayer()->control.free == false) { + post_effect_color = video::SColor(255, 0, 0, 0); + } } if (post_effect_color.getAlpha() != 0) { // Draw a full-screen rectangle diff --git a/src/modalMenu.h b/src/modalMenu.h index 99af50c..18c2584 100644 --- a/src/modalMenu.h +++ b/src/modalMenu.h @@ -105,6 +105,7 @@ public: allowFocusRemoval(true); // This removes Environment's grab on us Environment->removeFocus(this); + m_menumgr->deletingMenu(this); this->remove(); }