darken world behind menus/forms, and fix that old ungrabbed mouse bug when inventory is closed

This commit is contained in:
darkrose 2015-06-12 20:59:21 +10:00
parent 526672a259
commit 25ab63591a
6 changed files with 28 additions and 12 deletions

View File

@ -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),

View File

@ -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<std::wstring> m_chat_queue;

View File

@ -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"<<std::endl;
// It will delete itself by itself
@ -1959,6 +1962,7 @@ void the_game(
// Move mouse cursor on top of the disconnect button
input->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);

View File

@ -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;
}

View File

@ -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

View File

@ -105,6 +105,7 @@ public:
allowFocusRemoval(true);
// This removes Environment's grab on us
Environment->removeFocus(this);
m_menumgr->deletingMenu(this);
this->remove();
}