Add multiple hotbars for inventory.

You can use alt to switch between first and second hotbar. You can also use alt+number to switch to the nth hotbar.
This commit is contained in:
UnknownShadow200 2017-03-01 17:21:27 +11:00
parent dd0b497136
commit 93b99aa3f0
3 changed files with 15 additions and 4 deletions

View File

@ -70,8 +70,7 @@ namespace ClassicalSharp.Gui.Screens {
ArrowKeyMove(-blocksPerRow);
} else if ((key == Key.Down || key == Key.Keypad2) && selIndex != -1) {
ArrowKeyMove(blocksPerRow);
} else if (key >= Key.Number1 && key <= Key.Number9) {
game.Inventory.SelectedIndex = (int)key - (int)Key.Number1;
} else if (game.Gui.hudScreen.hotbar.HandlesKeyDown(key)) {
}
return true;
}

View File

@ -101,7 +101,19 @@ namespace ClassicalSharp.Gui.Widgets {
public override bool HandlesKeyDown(Key key) {
if (key >= Key.Number1 && key <= Key.Number9) {
game.Inventory.SelectedIndex = (int)key - (int)Key.Number1;
int index = (int)key - (int)Key.Number1;
if (game.Input.AltDown) {
// Pick from first to ninth row
game.Inventory.Offset = index * Inventory.BlocksPerRow;
} else {
game.Inventory.SelectedIndex = index;
}
return true;
} else if (key == Key.AltLeft || key == Key.AltRight) {
// Alternate between first and second row
int index = game.Inventory.Offset == 0 ? 1 : 0;
game.Inventory.Offset = index * Inventory.BlocksPerRow;
return true;
}
return false;

View File

@ -27,7 +27,7 @@ namespace ClassicalSharp {
Game game;
public bool CanChangeHeldBlock = true;
public const int BlocksPerRow = 9, Rows = 2;
public const int BlocksPerRow = 9, Rows = 9;
public int Offset = 0;
public BlockID[] Hotbar = new BlockID[BlocksPerRow * Rows];