refactor
This commit is contained in:
@@ -19,6 +19,16 @@ enum class contenttype {
|
|||||||
none, block, item
|
none, block, item
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline const char* contenttype_name(contenttype type) {
|
||||||
|
switch (type) {
|
||||||
|
case contenttype::none: return "none";
|
||||||
|
case contenttype::block: return "block";
|
||||||
|
case contenttype::item: return "item";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class namereuse_error: public std::runtime_error {
|
class namereuse_error: public std::runtime_error {
|
||||||
contenttype type;
|
contenttype type;
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -80,3 +80,20 @@ ContentLUT* ContentLUT::create(const fs::path& filename,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<contententry> ContentLUT::getMissingContent() const {
|
||||||
|
std::vector<contententry> entries;
|
||||||
|
for (size_t i = 0; i < blocks.size(); i++) {
|
||||||
|
if (blocks[i] == BLOCK_VOID) {
|
||||||
|
auto& name = blockNames[i];
|
||||||
|
entries.push_back(contententry {contenttype::block, name});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < items.size(); i++) {
|
||||||
|
if (items[i] == ITEM_VOID) {
|
||||||
|
auto& name = itemNames[i];
|
||||||
|
entries.push_back(contententry {contenttype::item, name});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,9 +8,14 @@
|
|||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
|
||||||
|
#include "Content.h"
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
class Content;
|
struct contententry {
|
||||||
|
contenttype type;
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: make it unified for all types of content
|
// TODO: make it unified for all types of content
|
||||||
|
|
||||||
@@ -84,6 +89,8 @@ public:
|
|||||||
inline size_t countItems() const {
|
inline size_t countItems() const {
|
||||||
return items.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<contententry> getMissingContent() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTENT_CONTENT_LUT_H_
|
#endif // CONTENT_CONTENT_LUT_H_
|
||||||
|
|||||||
+13
-35
@@ -83,42 +83,20 @@ void show_content_missing(Engine* engine, const Content* content,
|
|||||||
Panel* subpanel = new Panel(vec2(500, 100));
|
Panel* subpanel = new Panel(vec2(500, 100));
|
||||||
subpanel->color(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
subpanel->color(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
||||||
|
|
||||||
for (size_t i = 0; i < lut->countBlocks(); i++) {
|
for (auto& entry : lut->getMissingContent()) {
|
||||||
// missing block
|
Panel* hpanel = new Panel(vec2(500, 30));
|
||||||
if (lut->getBlockId(i) == BLOCK_VOID) {
|
hpanel->color(vec4(0.0f));
|
||||||
auto name = lut->getBlockName(i);
|
hpanel->orientation(Orientation::horizontal);
|
||||||
Panel* hpanel = new Panel(vec2(500, 30));
|
|
||||||
hpanel->color(vec4(0.0f));
|
Label* namelabel = new Label(util::str2wstr_utf8(entry.name));
|
||||||
hpanel->orientation(Orientation::horizontal);
|
namelabel->color(vec4(1.0f, 0.2f, 0.2f, 0.5f));
|
||||||
|
|
||||||
Label* namelabel = new Label(util::str2wstr_utf8(name));
|
|
||||||
namelabel->color(vec4(1.0f, 0.2f, 0.2f, 0.5f));
|
|
||||||
|
|
||||||
Label* typelabel = new Label(L"[block]");
|
auto contentname = util::str2wstr_utf8(contenttype_name(entry.type));
|
||||||
typelabel->color(vec4(0.5f));
|
Label* typelabel = new Label(L"["+contentname+L"]");
|
||||||
hpanel->add(typelabel);
|
typelabel->color(vec4(0.5f));
|
||||||
hpanel->add(namelabel);
|
hpanel->add(typelabel);
|
||||||
subpanel->add(hpanel);
|
hpanel->add(namelabel);
|
||||||
}
|
subpanel->add(hpanel);
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < lut->countItems(); i++) {
|
|
||||||
// missing block
|
|
||||||
if (lut->getItemId(i) == ITEM_VOID) {
|
|
||||||
auto name = lut->getItemName(i);
|
|
||||||
Panel* hpanel = new Panel(vec2(500, 30));
|
|
||||||
hpanel->color(vec4(0.0f));
|
|
||||||
hpanel->orientation(Orientation::horizontal);
|
|
||||||
|
|
||||||
Label* namelabel = new Label(util::str2wstr_utf8(name));
|
|
||||||
namelabel->color(vec4(1.0f, 0.2f, 0.2f, 0.5f));
|
|
||||||
|
|
||||||
Label* typelabel = new Label(L"[item]");
|
|
||||||
typelabel->color(vec4(0.5f));
|
|
||||||
hpanel->add(typelabel);
|
|
||||||
hpanel->add(namelabel);
|
|
||||||
subpanel->add(hpanel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
subpanel->maxLength(400);
|
subpanel->maxLength(400);
|
||||||
panel->add(subpanel);
|
panel->add(subpanel);
|
||||||
|
|||||||
Reference in New Issue
Block a user