From: Daniel Karbach Date: Tue, 29 Sep 2015 17:47:09 +0000 (+0200) Subject: fixed some initialization issues X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=ccd6e7001572808400b9cb9bc91f9bedcf28a1ad;p=blank.git fixed some initialization issues --- diff --git a/src/client/client.cpp b/src/client/client.cpp index fbf6bf2..cfc89cd 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -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); diff --git a/src/standalone/MasterState.cpp b/src/standalone/MasterState.cpp index 272e5a3..635f273 100644 --- a/src/standalone/MasterState.cpp +++ b/src/standalone/MasterState.cpp @@ -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); diff --git a/src/ui/DirectInput.hpp b/src/ui/DirectInput.hpp index 525c856..d4a2e96 100644 --- a/src/ui/DirectInput.hpp +++ b/src/ui/DirectInput.hpp @@ -55,8 +55,6 @@ private: float yaw; bool dirty; - int active_slot; - IntervalTimer place_timer; IntervalTimer remove_timer; diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 1e8a980..75129c1 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -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) { diff --git a/src/world/world.cpp b/src/world/world.cpp index 242da27..e659322 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -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) { }