make hotbar size and layout configurable

Add hotbar-size, hotbar-layout and inventory-layout to config/defaults.toml,
player.get_hotbar_size / player.set_hotbar_size and
hud.is_hotbar_visible / hud.set_hotbar_visible.
This commit is contained in:
ostermine 2026-10-15 15:52:22 +03:00
parent 2e2233a489
commit aa670f3c9d
16 changed files with 188 additions and 20 deletions

View file

@ -41,6 +41,12 @@ Player::Player(
name(name),
speed(speed),
chosenSlot(0),
hotbarSize(glm::max(
1,
static_cast<int>(
level.content.getDefaults()["hotbar-size"].asInteger(10)
)
)),
position(position),
inventory(std::move(inv)),
eid(eid),
@ -153,13 +159,22 @@ void Player::attemptToChooseSpawnpoint() {
}
void Player::setChosenSlot(int index) {
chosenSlot = index;
chosenSlot = glm::clamp(index, 0, hotbarSize - 1);
}
int Player::getChosenSlot() const {
return chosenSlot;
}
void Player::setHotbarSize(int size) {
hotbarSize = glm::max(1, size);
setChosenSlot(chosenSlot);
}
int Player::getHotbarSize() const {
return hotbarSize;
}
float Player::getSpeed() const {
return speed;
}