1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
4 #include "FBXSettingsDlg.h"
5 #include "FBXExporter.h"
7 #include "Controls/EditorDialog.h"
8 #include <Serialization/QPropertyTree/QPropertyTree.h>
9 #include <CrySerialization/yasli/Archive.h>
10 #include <CrySerialization/yasli/Enum.h>
12 namespace Private_FBXSettingsDlg
21 YASLI_ENUM_BEGIN(EFbxFormat
, "FbxFormat")
22 YASLI_ENUM(EFbxFormat::eFbxFormat_Bin
, "bin", "Binary");
23 YASLI_ENUM(EFbxFormat::eFbxFormat_Ascii
, "ascii", "Text (ascii)");
26 YASLI_ENUM_BEGIN(EAxis
, "Axis")
27 YASLI_ENUM(EAxis::eAxis_Y
, "Y", "Y");
28 YASLI_ENUM(EAxis::eAxis_Z
, "Z", "Z");
33 SSerializer(SFBXSettings
& value
) : value(value
) {}
35 bool Serialize(yasli::Archive
& ar
)
37 ar(value
.bCopyTextures
, "textures", "Copy textures into folder with FBX file");
38 ar(value
.bEmbedded
, "embedded", "Embedded data (Put textures inside FBX file)");
40 EFbxFormat format
= value
.bAsciiFormat
? eFbxFormat_Ascii
: eFbxFormat_Bin
;
41 ar(format
, "ascii", "Format of FBX file");
42 value
.bAsciiFormat
= format
;
44 ar(value
.axis
, "up", "Up Axis");
51 class CSettingsDialog
: public CEditorDialog
54 CSettingsDialog(SSerializer
& settings
):
55 CEditorDialog("FBXExportSettings")
57 setWindowTitle(tr("FBX Export Settings"));
59 QPropertyTree
* pPropertyTree
= new QPropertyTree(this);
61 PropertyTreeStyle
treeStyle(QPropertyTree::defaultTreeStyle());
62 treeStyle
.propertySplitter
= true;
63 treeStyle
.groupRectangle
= false;
64 pPropertyTree
->setTreeStyle(treeStyle
);
65 pPropertyTree
->setCompact(false);
66 pPropertyTree
->setExpandLevels(1);
67 pPropertyTree
->setSliderUpdateDelay(5);
68 pPropertyTree
->setValueColumnWidth(0.6f
);
69 pPropertyTree
->attach(Serialization::SStruct(settings
));
71 QVBoxLayout
* pLayout
= new QVBoxLayout();
72 pLayout
->setContentsMargins(0, 0, 0, 0);
73 pLayout
->addWidget(pPropertyTree
);
75 auto pButtons
= new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
, Qt::Horizontal
);
76 pLayout
->addWidget(pButtons
, 0);
78 connect(pButtons
, &QDialogButtonBox::accepted
, this, &QDialog::accept
);
79 connect(pButtons
, &QDialogButtonBox::rejected
, this, &QDialog::reject
);
87 bool OpenFBXSettingsDlg(struct SFBXSettings
& settings
)
89 using namespace Private_FBXSettingsDlg
;
91 SSerializer
serializer(settings
);
92 CSettingsDialog
dialog(serializer
);
94 return dialog
.Execute();