Merge pull request #1043 from ostermine/feat/hotbar-control

make hotbar size and layout configurable
This commit is contained in:
MihailRis 2026-10-18 11:38:10 +03:00 • committed by GitHub
commit bb73e3f354
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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;
}

View file

@ -49,6 +49,7 @@ class Player : public Serializable {
float speed;
int chosenSlot;
int hotbarSize;
glm::vec3 position;
glm::vec3 spawnpoint {std::nanf(""), std::nanf(""), std::nanf("")};
std::shared_ptr<Inventory> inventory;
@ -96,6 +97,10 @@ public:
int getChosenSlot() const;
void setHotbarSize(int size);
int getHotbarSize() const;
float getSpeed() const;
bool isSuspended() const;