mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-10-01 01:35:23 -04:00
Fix holding down B causing inventory menu to close
This commit is contained in:
parent
d68d17eaa5
commit
f320b8dea0
@ -55,9 +55,14 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We want the user to be able to press B to exit the inventory menu
|
||||||
|
// however since we use KeyRepeat = true, we must wait until the first time they released B
|
||||||
|
// before marking the next press as closing the menu
|
||||||
|
bool releasedInv;
|
||||||
public override bool HandlesKeyDown(Key key) {
|
public override bool HandlesKeyDown(Key key) {
|
||||||
if (key == game.Mapping(KeyBind.PauseOrExit) ||
|
if (key == game.Mapping(KeyBind.PauseOrExit)) {
|
||||||
key == game.Mapping(KeyBind.Inventory)) {
|
game.Gui.SetNewScreen(null);
|
||||||
|
} else if (key == game.Mapping(KeyBind.Inventory) && releasedInv) {
|
||||||
game.Gui.SetNewScreen(null);
|
game.Gui.SetNewScreen(null);
|
||||||
} else if (key == Key.Enter && selIndex != -1) {
|
} else if (key == Key.Enter && selIndex != -1) {
|
||||||
game.Inventory.Selected = blocksTable[selIndex];
|
game.Inventory.Selected = blocksTable[selIndex];
|
||||||
@ -76,6 +81,9 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyUp(Key key) {
|
public override bool HandlesKeyUp(Key key) {
|
||||||
|
if (key == game.Mapping(KeyBind.Inventory)) {
|
||||||
|
releasedInv = true; return true;
|
||||||
|
}
|
||||||
return game.Gui.hudScreen.hotbar.HandlesKeyUp(key);
|
return game.Gui.hudScreen.hotbar.HandlesKeyUp(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user