!XT (Code) Update copyright headers in Code/Sandbox.
[CRYENGINE.git] / Code / Sandbox / Plugins / FBXPlugin / FBXSettingsDlg.cpp
blob4a4b8c5c461ac24e37a0a6566e5b1126cd87bc29
1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
3 #include "StdAfx.h"
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
15 enum EFbxFormat
17 eFbxFormat_Bin,
18 eFbxFormat_Ascii,
21 YASLI_ENUM_BEGIN(EFbxFormat, "FbxFormat")
22 YASLI_ENUM(EFbxFormat::eFbxFormat_Bin, "bin", "Binary");
23 YASLI_ENUM(EFbxFormat::eFbxFormat_Ascii, "ascii", "Text (ascii)");
24 YASLI_ENUM_END()
26 YASLI_ENUM_BEGIN(EAxis, "Axis")
27 YASLI_ENUM(EAxis::eAxis_Y, "Y", "Y");
28 YASLI_ENUM(EAxis::eAxis_Z, "Z", "Z");
29 YASLI_ENUM_END()
31 struct SSerializer
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");
45 return true;
48 SFBXSettings& value;
51 class CSettingsDialog : public CEditorDialog
53 public:
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);
81 setLayout(pLayout);
87 bool OpenFBXSettingsDlg(struct SFBXSettings& settings)
89 using namespace Private_FBXSettingsDlg;
91 SSerializer serializer(settings);
92 CSettingsDialog dialog(serializer);
94 return dialog.Execute();