| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "modelskin.h" |
| 4 |
|
| 5 |
namespace ui |
| 6 |
{ |
| 7 |
|
| 8 |
// Temporary skin implementation used to assign the given material |
| 9 |
class TestModelSkin final |
| 10 |
{ |
| 11 |
private: |
| 12 |
MaterialPtr _material; |
| 13 |
|
| 14 |
const char* const NAME_PREFIX = "__internal_test_skin__"; |
| 15 |
std::string _nameSuffix; |
| 16 |
|
| 17 |
decl::ISkin::Ptr _skin; |
| 18 |
|
| 19 |
public: |
| 20 |
const char* const TEST_MODEL_MATERIAL = "material"; |
| 21 |
|
| 22 |
TestModelSkin(const std::string& name) : |
| 23 |
_nameSuffix(name), |
| 24 |
_skin(std::static_pointer_cast<decl::ISkin>( |
| 25 |
GlobalDeclarationManager().findOrCreateDeclaration(decl::Type::Skin, getSkinName()))) |
| 26 |
{} |
| 27 |
|
| 28 |
std::string getSkinName() const |
| 29 |
{ |
| 30 |
return NAME_PREFIX + _nameSuffix; |
| 31 |
} |
| 32 |
|
| 33 |
bool isEmpty() const |
| 34 |
{ |
| 35 |
return !_material; |
| 36 |
} |
| 37 |
|
| 38 |
void clear() |
| 39 |
{ |
| 40 |
_material.reset(); |
| 41 |
} |
| 42 |
|
| 43 |
void setRemapMaterial(const MaterialPtr& material) |
| 44 |
{ |
| 45 |
_material = material; |
| 46 |
|
| 47 |
decl::DeclarationBlockSyntax syntax; |
| 48 |
|
| 49 |
syntax.modName = "None"; |
| 50 |
syntax.typeName = "skin"; |
| 51 |
syntax.name = getSkinName(); |
| 52 |
|
| 53 |
syntax.contents = _material ? |
| 54 |
fmt::format("{0}\t{1}", TEST_MODEL_MATERIAL, _material->getName()) : ""; |
| 55 |
|
| 56 |
_skin->setBlockSyntax(syntax); |
| 57 |
} |
| 58 |
}; |
| 59 |
|
| 60 |
} |