From 1401eca7129e8533a9e307c6527583b5676aaec3 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 29 Apr 2024 02:58:35 +0300 Subject: [PATCH] removed some redundant code --- src/frontend/ContentGfxCache.cpp | 8 ---- src/frontend/ContentGfxCache.h | 64 +++++++++++++++----------------- src/frontend/InventoryView.cpp | 4 -- src/frontend/InventoryView.h | 2 - src/frontend/hud.cpp | 9 +---- 5 files changed, 31 insertions(+), 56 deletions(-) diff --git a/src/frontend/ContentGfxCache.cpp b/src/frontend/ContentGfxCache.cpp index c9ceca09..8dbf3e98 100644 --- a/src/frontend/ContentGfxCache.cpp +++ b/src/frontend/ContentGfxCache.cpp @@ -40,14 +40,6 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) : conte ContentGfxCache::~ContentGfxCache() { } -std::shared_ptr ContentGfxCache::getLayout(const std::string& id) { - auto found = layouts.find(id); - if (found == layouts.end()) { - return nullptr; - } - return found->second; -} - const Content* ContentGfxCache::getContent() const { return content; } diff --git a/src/frontend/ContentGfxCache.h b/src/frontend/ContentGfxCache.h index 354675e1..7c644709 100644 --- a/src/frontend/ContentGfxCache.h +++ b/src/frontend/ContentGfxCache.h @@ -1,35 +1,29 @@ -#ifndef FRONTEND_BLOCKS_GFX_CACHE_H_ -#define FRONTEND_BLOCKS_GFX_CACHE_H_ - -#include -#include -#include -#include "../typedefs.h" - -class Content; -class Assets; -class UiDocument; -struct UVRegion; - -using uidocuments_map = std::unordered_map>; - -class ContentGfxCache { - const Content* content; - // array of block sides uv regions (6 per block) - std::unique_ptr sideregions; - // all loaded layouts - uidocuments_map layouts; -public: - ContentGfxCache(const Content* content, Assets* assets); - ~ContentGfxCache(); - - inline const UVRegion& getRegion(blockid_t id, int side) const { - return sideregions[id * 6 + side]; - } - - std::shared_ptr getLayout(const std::string& id); - - const Content* getContent() const; -}; - -#endif // FRONTEND_BLOCKS_GFX_CACHE_H_ +#ifndef FRONTEND_BLOCKS_GFX_CACHE_H_ +#define FRONTEND_BLOCKS_GFX_CACHE_H_ + +#include "../typedefs.h" + +#include +#include +#include + +class Content; +class Assets; +struct UVRegion; + +class ContentGfxCache { + const Content* content; + // array of block sides uv regions (6 per block) + std::unique_ptr sideregions; +public: + ContentGfxCache(const Content* content, Assets* assets); + ~ContentGfxCache(); + + inline const UVRegion& getRegion(blockid_t id, int side) const { + return sideregions[id * 6 + side]; + } + + const Content* getContent() const; +}; + +#endif // FRONTEND_BLOCKS_GFX_CACHE_H_ diff --git a/src/frontend/InventoryView.cpp b/src/frontend/InventoryView.cpp index 27ee9db2..a4a8264d 100644 --- a/src/frontend/InventoryView.cpp +++ b/src/frontend/InventoryView.cpp @@ -362,10 +362,6 @@ glm::vec2 InventoryView::getOrigin() const { return origin; } -void InventoryView::setInventory(std::shared_ptr inventory) { - this->inventory = inventory; -} - #include "../coders/xml.h" #include "../graphics/ui/gui_xml.hpp" diff --git a/src/frontend/InventoryView.h b/src/frontend/InventoryView.h index cd89fc19..93632367 100644 --- a/src/frontend/InventoryView.h +++ b/src/frontend/InventoryView.h @@ -86,8 +86,6 @@ public: InventoryView(); virtual ~InventoryView(); - void setInventory(std::shared_ptr inventory); - virtual void setPos(glm::vec2 pos) override; void setOrigin(glm::vec2 origin); diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index f1a638a4..86994dbb 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -13,14 +13,13 @@ #include "../graphics/core/Mesh.hpp" #include "../graphics/core/Shader.hpp" #include "../graphics/core/Texture.hpp" -#include "../graphics/render/BlocksPreview.hpp" #include "../graphics/render/WorldRenderer.hpp" -#include "../graphics/ui/elements/UINode.hpp" #include "../graphics/ui/elements/Menu.hpp" #include "../graphics/ui/elements/Panel.hpp" #include "../graphics/ui/elements/Plotter.hpp" -#include "../graphics/ui/GUI.hpp" +#include "../graphics/ui/elements/UINode.hpp" #include "../graphics/ui/gui_util.hpp" +#include "../graphics/ui/GUI.hpp" #include "../items/Inventories.h" #include "../items/Inventory.h" #include "../items/ItemDef.h" @@ -30,7 +29,6 @@ #include "../physics/Hitbox.h" #include "../typedefs.h" #include "../util/stringutil.h" -#include "../util/timeutil.h" #include "../voxels/Block.h" #include "../voxels/Chunk.h" #include "../voxels/Chunks.h" @@ -43,13 +41,10 @@ #include "ContentGfxCache.h" #include "InventoryView.h" #include "LevelFrontend.h" -#include "menu.hpp" #include "UiDocument.h" #include -#include #include -#include #include #include