/
EntityClassPreview.h
56 lines (47 loc) · 1.2 KB
/
EntityClassPreview.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include "ieclass.h"
#include "ui/ideclpreview.h"
#include "ModelPreview.h"
#include "../dialog/MessageBox.h"
namespace wxutil
{
class EntityClassPreview :
public EntityPreview,
public ui::IDeclarationPreview
{
public:
EntityClassPreview(wxWindow* parent) :
EntityPreview(parent)
{}
// Returns the widget that can be packed into the selector container
wxWindow* GetPreviewWidget() override
{
return _mainPanel;
}
void ClearPreview() override
{
setEntity({});
}
void SetPreviewDeclName(const std::string& declName) override
{
auto eclass = GlobalEntityClassManager().findClass(declName);
if (declName.empty() || !eclass)
{
ClearPreview();
return;
}
try
{
// Create an entity of the selected type
auto entity = GlobalEntityModule().createEntity(eclass);
setEntity(entity);
}
catch (const std::runtime_error&)
{
Messagebox::ShowError(fmt::format(
_("Unable to setup the preview,\ncould not find the entity class '{0}'"),
declName));
}
}
};
}