X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=3c30a62495127a52ace02decb18233c845e463f5;hb=225a7e66ed3f3f03ab458ab39c914ed55cd69600;hp=f0a3f35c7b984825d2dcffbc4c529a8c0d9815cb;hpb=80a9a59d71a7b144c12f64cbef4644751bd54745;p=blank.git diff --git a/src/client/client.cpp b/src/client/client.cpp index f0a3f35..3c30a62 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -59,6 +59,7 @@ InteractiveState::InteractiveState(MasterState &master, uint32_t player_id) , chunk_receiver(world.Chunks(), save) , chunk_renderer(player.GetChunks()) , loop_timer(16) +, stat_timer(1000) , sky(master.GetEnv().loader.LoadCubeMap("skybox")) , update_status() , chat(master.GetEnv(), *this, *this) { @@ -75,6 +76,7 @@ InteractiveState::InteractiveState(MasterState &master, uint32_t player_id) chunk_renderer.LoadTextures(master.GetEnv().loader, res.tex_index); chunk_renderer.FogDensity(master.GetWorldConf().fog_density); loop_timer.Start(); + stat_timer.Start(); if (save.Exists(player)) { save.Read(player); } @@ -105,6 +107,11 @@ void InteractiveState::Handle(const SDL_Event &event) { case SDL_KEYDOWN: // TODO: move to interface if (event.key.keysym.sym == SDLK_RETURN) { + chat.Clear(); + master.GetEnv().state.Push(&chat); + hud.KeepMessages(true); + } else if (event.key.keysym.sym == SDLK_SLASH) { + chat.Preset("/"); master.GetEnv().state.Push(&chat); hud.KeepMessages(true); } else { @@ -135,20 +142,11 @@ void InteractiveState::Handle(const SDL_Event &event) { } void InteractiveState::Update(int dt) { - input.Update(dt); - if (input.BlockFocus()) { - hud.FocusBlock(input.BlockFocus().GetChunk(), input.BlockFocus().block); - } else if (input.EntityFocus()) { - hud.FocusEntity(*input.EntityFocus().entity); - } else { - hud.FocusNone(); - } - hud.Display(res.block_types[player.GetInventorySlot() + 1]); loop_timer.Update(dt); + stat_timer.Update(dt); master.Update(dt); chunk_receiver.Update(dt); - hud.Update(dt); int world_dt = 0; while (loop_timer.HitOnce()) { world.Update(loop_timer.Interval()); @@ -157,9 +155,21 @@ void InteractiveState::Update(int dt) { } chunk_renderer.Update(dt); + if (input.BlockFocus()) { + hud.FocusBlock(input.BlockFocus().GetChunk(), input.BlockFocus().block); + } else if (input.EntityFocus()) { + hud.FocusEntity(*input.EntityFocus().entity); + } else { + hud.FocusNone(); + } if (world_dt > 0) { input.PushPlayerUpdate(world_dt); } + hud.Display(res.block_types[player.GetInventorySlot() + 1]); + if (stat_timer.Hit()) { + hud.UpdateNetStats(master); + } + hud.Update(dt); glm::mat4 trans = player.GetEntity().Transform(player.GetEntity().ChunkCoords()); glm::vec3 dir(trans * glm::vec4(0.0f, 0.0f, -1.0f, 0.0f)); @@ -192,8 +202,6 @@ void InteractiveState::Handle(const Packet::SpawnEntity &pack) { if (model_id > 0 && model_id <= res.models.size()) { res.models.Get(model_id).Instantiate(entity.GetModel()); } - cout << "spawned entity #" << entity_id << " (" << entity.Name() - << ") at " << entity.AbsolutePosition() << endl; } void InteractiveState::Handle(const Packet::DespawnEntity &pack) { @@ -203,7 +211,6 @@ void InteractiveState::Handle(const Packet::DespawnEntity &pack) { for (Entity &entity : world.Entities()) { if (entity.ID() == entity_id) { entity.Kill(); - cout << "despawned entity #" << entity_id << " (" << entity.Name() << ") at " << entity.AbsolutePosition() << endl; return; } }