]> git.localhorst.tv Git - blank.git/commitdiff
fixed some initialization issues
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 29 Sep 2015 17:47:09 +0000 (19:47 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 29 Sep 2015 17:54:57 +0000 (19:54 +0200)
src/client/client.cpp
src/standalone/MasterState.cpp
src/ui/DirectInput.hpp
src/ui/ui.cpp
src/world/world.cpp

index fbf6bf28f9c2c1bb781b9d4c42edab76d45184da..cfc89cd2588dabca879a6dec218d40582dac5f48 100644 (file)
@@ -126,6 +126,7 @@ InteractiveState::InteractiveState(MasterState &master, uint32_t player_id)
        }
        TextureIndex tex_index;
        master.GetEnv().loader.LoadBlockTypes("default", block_types, tex_index);
+       interface.SetInventorySlots(block_types.Size() - 1);
        chunk_renderer.LoadTextures(master.GetEnv().loader, tex_index);
        chunk_renderer.FogDensity(master.GetWorldConf().fog_density);
        skeletons.Load();
@@ -170,6 +171,8 @@ void InteractiveState::Update(int dt) {
                hud.FocusBlock(input.BlockFocus().GetChunk(), input.BlockFocus().block);
        } else if (input.EntityFocus()) {
                hud.FocusEntity(*input.EntityFocus().entity);
+       } else {
+               hud.FocusNone();
        }
        hud.Display(block_types[player.GetInventorySlot() + 1]);
        loop_timer.Update(dt);
index 272e5a39ac2afbf1caff668d89e991b847cdaf24..635f2733fc4590317e36cd365e3ef9a2e52ce109 100644 (file)
@@ -37,6 +37,7 @@ MasterState::MasterState(
 , unload(env, world.Chunks(), save) {
        TextureIndex tex_index;
        env.loader.LoadBlockTypes("default", block_types, tex_index);
+       interface.SetInventorySlots(block_types.Size() - 1);
        chunk_renderer.LoadTextures(env.loader, tex_index);
        chunk_renderer.FogDensity(wc.fog_density);
        skeletons.Load();
@@ -84,6 +85,8 @@ void MasterState::Update(int dt) {
                hud.FocusBlock(input.BlockFocus().GetChunk(), input.BlockFocus().block);
        } else if (input.EntityFocus()) {
                hud.FocusEntity(*input.EntityFocus().entity);
+       } else {
+               hud.FocusNone();
        }
        hud.Display(block_types[player.GetInventorySlot() + 1]);
        hud.Update(dt);
index 525c85668c8f03460def706ad3c06faf1042f4b7..d4a2e96d110b4b0c740a69048f648f540589a7c6 100644 (file)
@@ -55,8 +55,6 @@ private:
        float yaw;
        bool dirty;
 
-       int active_slot;
-
        IntervalTimer place_timer;
        IntervalTimer remove_timer;
 
index 1e8a980112c0982fe69a6729849d37b75e50a959..75129c1b3837ebd5460328507cded17ff3f73473 100644 (file)
@@ -42,7 +42,6 @@ DirectInput::DirectInput(World &world, Player &player, WorldManipulator &manip)
 , pitch(0.0f)
 , yaw(0.0f)
 , dirty(true)
-, active_slot(0)
 , place_timer(256)
 , remove_timer(256) {
 
@@ -118,7 +117,8 @@ void DirectInput::StopTertiaryAction() {
        // nothing
 }
 
-void DirectInput::SelectInventory(int) {
+void DirectInput::SelectInventory(int i) {
+       player.SetInventorySlot(i);
 }
 
 void DirectInput::UpdatePlayer() {
@@ -636,6 +636,7 @@ void Interface::InvAbs(int s) {
        while (slot < 0) {
                slot += num_slots;
        }
+       player_ctrl.SelectInventory(slot);
 }
 
 void Interface::InvRel(int delta) {
index 242da2796af047fc0e41f472fdb5b20126009b05..e659322aa333c753fd953a718fc0c18b7eace276 100644 (file)
@@ -127,7 +127,8 @@ glm::mat4 EntityState::Transform(const glm::ivec3 &reference) const noexcept {
 
 Player::Player(Entity &e, ChunkIndex &c)
 : entity(e)
-, chunks(c) {
+, chunks(c)
+, inv_slot(0) {
 
 }