removed some redundant code

This commit is contained in:
MihailRis 2024-04-29 02:58:35 +03:00
parent 63768ccd6d
commit 1401eca712
5 changed files with 31 additions and 56 deletions

View File

@ -40,14 +40,6 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) : conte
ContentGfxCache::~ContentGfxCache() { ContentGfxCache::~ContentGfxCache() {
} }
std::shared_ptr<UiDocument> 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 { const Content* ContentGfxCache::getContent() const {
return content; return content;
} }

View File

@ -1,35 +1,29 @@
#ifndef FRONTEND_BLOCKS_GFX_CACHE_H_ #ifndef FRONTEND_BLOCKS_GFX_CACHE_H_
#define FRONTEND_BLOCKS_GFX_CACHE_H_ #define FRONTEND_BLOCKS_GFX_CACHE_H_
#include <memory> #include "../typedefs.h"
#include <string>
#include <unordered_map> #include <memory>
#include "../typedefs.h" #include <string>
#include <unordered_map>
class Content;
class Assets; class Content;
class UiDocument; class Assets;
struct UVRegion; struct UVRegion;
using uidocuments_map = std::unordered_map<std::string, std::shared_ptr<UiDocument>>; class ContentGfxCache {
const Content* content;
class ContentGfxCache { // array of block sides uv regions (6 per block)
const Content* content; std::unique_ptr<UVRegion[]> sideregions;
// array of block sides uv regions (6 per block) public:
std::unique_ptr<UVRegion[]> sideregions; ContentGfxCache(const Content* content, Assets* assets);
// all loaded layouts ~ContentGfxCache();
uidocuments_map layouts;
public: inline const UVRegion& getRegion(blockid_t id, int side) const {
ContentGfxCache(const Content* content, Assets* assets); return sideregions[id * 6 + side];
~ContentGfxCache(); }
inline const UVRegion& getRegion(blockid_t id, int side) const { const Content* getContent() const;
return sideregions[id * 6 + side]; };
}
#endif // FRONTEND_BLOCKS_GFX_CACHE_H_
std::shared_ptr<UiDocument> getLayout(const std::string& id);
const Content* getContent() const;
};
#endif // FRONTEND_BLOCKS_GFX_CACHE_H_

View File

@ -362,10 +362,6 @@ glm::vec2 InventoryView::getOrigin() const {
return origin; return origin;
} }
void InventoryView::setInventory(std::shared_ptr<Inventory> inventory) {
this->inventory = inventory;
}
#include "../coders/xml.h" #include "../coders/xml.h"
#include "../graphics/ui/gui_xml.hpp" #include "../graphics/ui/gui_xml.hpp"

View File

@ -86,8 +86,6 @@ public:
InventoryView(); InventoryView();
virtual ~InventoryView(); virtual ~InventoryView();
void setInventory(std::shared_ptr<Inventory> inventory);
virtual void setPos(glm::vec2 pos) override; virtual void setPos(glm::vec2 pos) override;
void setOrigin(glm::vec2 origin); void setOrigin(glm::vec2 origin);

View File

@ -13,14 +13,13 @@
#include "../graphics/core/Mesh.hpp" #include "../graphics/core/Mesh.hpp"
#include "../graphics/core/Shader.hpp" #include "../graphics/core/Shader.hpp"
#include "../graphics/core/Texture.hpp" #include "../graphics/core/Texture.hpp"
#include "../graphics/render/BlocksPreview.hpp"
#include "../graphics/render/WorldRenderer.hpp" #include "../graphics/render/WorldRenderer.hpp"
#include "../graphics/ui/elements/UINode.hpp"
#include "../graphics/ui/elements/Menu.hpp" #include "../graphics/ui/elements/Menu.hpp"
#include "../graphics/ui/elements/Panel.hpp" #include "../graphics/ui/elements/Panel.hpp"
#include "../graphics/ui/elements/Plotter.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_util.hpp"
#include "../graphics/ui/GUI.hpp"
#include "../items/Inventories.h" #include "../items/Inventories.h"
#include "../items/Inventory.h" #include "../items/Inventory.h"
#include "../items/ItemDef.h" #include "../items/ItemDef.h"
@ -30,7 +29,6 @@
#include "../physics/Hitbox.h" #include "../physics/Hitbox.h"
#include "../typedefs.h" #include "../typedefs.h"
#include "../util/stringutil.h" #include "../util/stringutil.h"
#include "../util/timeutil.h"
#include "../voxels/Block.h" #include "../voxels/Block.h"
#include "../voxels/Chunk.h" #include "../voxels/Chunk.h"
#include "../voxels/Chunks.h" #include "../voxels/Chunks.h"
@ -43,13 +41,10 @@
#include "ContentGfxCache.h" #include "ContentGfxCache.h"
#include "InventoryView.h" #include "InventoryView.h"
#include "LevelFrontend.h" #include "LevelFrontend.h"
#include "menu.hpp"
#include "UiDocument.h" #include "UiDocument.h"
#include <assert.h> #include <assert.h>
#include <iostream>
#include <memory> #include <memory>
#include <sstream>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>