mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-29 00:23:31 -04:00
fix last commit
This commit is contained in:
parent
93b99aa3f0
commit
3384b1aa55
@ -173,7 +173,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return hotbar.HandlesKeyUp(key);
|
||||
}
|
||||
|
||||
public void OpenTextInputBar(string text) {
|
||||
|
@ -75,6 +75,10 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandlesKeyUp(Key key) {
|
||||
return game.Gui.hudScreen.hotbar.HandlesKeyUp(key);
|
||||
}
|
||||
|
||||
void ArrowKeyMove(int delta) {
|
||||
int startIndex = selIndex;
|
||||
selIndex += delta;
|
||||
|
@ -98,7 +98,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||
selTex = new Texture(0, 0, y, hSize, vSize, rec);
|
||||
}
|
||||
|
||||
|
||||
bool altHandled;
|
||||
public override bool HandlesKeyDown(Key key) {
|
||||
if (key >= Key.Number1 && key <= Key.Number9) {
|
||||
int index = (int)key - (int)Key.Number1;
|
||||
@ -106,18 +106,30 @@ namespace ClassicalSharp.Gui.Widgets {
|
||||
if (game.Input.AltDown) {
|
||||
// Pick from first to ninth row
|
||||
game.Inventory.Offset = index * Inventory.BlocksPerRow;
|
||||
game.Events.RaiseHeldBlockChanged();
|
||||
altHandled = true;
|
||||
} else {
|
||||
game.Inventory.SelectedIndex = index;
|
||||
}
|
||||
return true;
|
||||
} else if (key == Key.AltLeft || key == Key.AltRight) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool HandlesKeyUp(Key key) {
|
||||
// We need to handle these cases:
|
||||
// a) user presses alt then number
|
||||
// b) user presses alt
|
||||
// thus we only do case b) if case a) did not happen
|
||||
if (!(key == Key.AltLeft || key == Key.AltRight)) return false;
|
||||
if (altHandled) { altHandled = false; return true; } // handled already
|
||||
|
||||
// Alternate between first and second row
|
||||
int index = game.Inventory.Offset == 0 ? 1 : 0;
|
||||
game.Inventory.Offset = index * Inventory.BlocksPerRow;
|
||||
game.Events.RaiseHeldBlockChanged();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool HandlesMouseClick(int mouseX, int mouseY, MouseButton button) {
|
||||
if (button != MouseButton.Left || !Bounds.Contains(mouseX, mouseY))
|
||||
|
Loading…
x
Reference in New Issue
Block a user