!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / Sandbox / Plugins / SchematycEditor / MainWindow.cpp
blob180926bd9e00c00232e9ff7af9609be25fea2a70
1 // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
3 #include "StdAfx.h"
4 #include "MainWindow.h"
6 #include <functional>
8 #include <qlayout.h>
9 #include <qpushbutton.h>
11 #include <CrySchematyc2/IFramework.h>
12 #include <CrySchematyc2/Script/IScriptRegistry.h>
14 #include "GenericWidget.h"
15 #include "LegacyOpenDlg.h"
16 #include "LegacyOpenDlgModel.h"
18 //////////////////////////////////////////////////////////////////////////
19 namespace Cry {
20 namespace SchematycEd {
22 REGISTER_VIEWPANE_FACTORY(CMainWindow, "Schematyc Editor (Reworked)", "Tools", false)
24 CMainWindow::CMainWindow()
25 : CAssetEditor(QStringList{ "SchematycEntity", "SchematycLibrary" })
26 , m_pLegacyOpenDlg(nullptr)
27 , m_pAddComponentButton(nullptr)
29 EnableDockingSystem();
31 InitLegacyOpenDlg();
32 InitGenericWidgets();
35 CMainWindow::~CMainWindow()
37 FinishLegacyOpenDlg();
38 FinishGenericWidgets();
41 void CMainWindow::CreateDefaultLayout(CDockableContainer* pSender)
43 CRY_ASSERT(pSender);
45 //auto pComponentsWidget = pSender->SpawnWidget("Generic0");
46 //auto pVariablesWidget = pSender->SpawnWidget("Generic1", QToolWindowAreaReference::VSplitRight);
48 //auto pGraphsWidget = pSender->SpawnWidget("Generic2", pComponentsWidget, QToolWindowAreaReference::HSplitBottom);
49 //auto pSignalsAndTypesWidget = pSender->SpawnWidget("Generic3", pGraphsWidget, QToolWindowAreaReference::HSplitBottom);
52 void CMainWindow::OnOpenLegacy()
54 m_pLegacyOpenDlg->exec();
57 void CMainWindow::OnOpenLegacyClass(CAbstractDictionaryEntry& classEntry)
59 CLegacyOpenDlgEntry& legacyEntry = static_cast<CLegacyOpenDlgEntry&>(classEntry);
61 Schematyc2::IScriptFile* pScriptFile = gEnv->pSchematyc2->GetScriptRegistry().GetFile(legacyEntry.GetFullName().toLatin1().data());
62 if (pScriptFile)
64 Schematyc2::IScriptClass* pScriptClass = pScriptFile->GetClass(legacyEntry.GetTypeGUID());
65 for (auto pWidget : m_genericWidgets)
67 pWidget->setWindowTitle(pScriptClass->GetName());
68 pWidget->LoadClass(pScriptFile->GetGUID(), pScriptClass->GetGUID());
72 m_pLegacyOpenDlg->done(0);
75 void CMainWindow::InitLegacyOpenDlg()
77 QAction* const pAction = GetMenu(MenuItems::FileMenu)->CreateAction(tr("Open Legacy"), 0, 0);
78 connect(pAction, &QAction::triggered, this, &CMainWindow::OnOpenLegacy);
80 m_pLegacyOpenDlg = new CLegacyOpenDlg();
81 connect(m_pLegacyOpenDlg->GetDialogDictWidget(), &CDictionaryWidget::OnEntryDoubleClicked, this, &CMainWindow::OnOpenLegacyClass);
84 void CMainWindow::FinishLegacyOpenDlg()
86 m_pLegacyOpenDlg->deleteLater();
89 void CMainWindow::InitGenericWidgets()
91 //RegisterDockableWidget("Generic0", std::bind(&CMainWindow::CreateWidgetTemplateFunc, this, "<Empty>"), true, false);
92 //RegisterDockableWidget("Generic1", std::bind(&CMainWindow::CreateWidgetTemplateFunc, this, "<Empty>"), true, false);
93 //RegisterDockableWidget("Generic2", std::bind(&CMainWindow::CreateWidgetTemplateFunc, this, "<Empty>"), true, false);
94 //RegisterDockableWidget("Generic3", std::bind(&CMainWindow::CreateWidgetTemplateFunc, this, "<Empty>"), true, false);
97 void CMainWindow::FinishGenericWidgets()
99 for (auto pWidget : m_genericWidgets)
101 pWidget->deleteLater();
103 m_genericWidgets.clear();
107 QWidget* CMainWindow::CreateWidgetTemplateFunc(const char* name)
109 m_genericWidgets.push_back(CGenericWidget::Create());
110 m_genericWidgets.back()->setWindowTitle(name);
112 return m_genericWidgets.back();
115 } //namespace SchematycEd
116 } //namespace Cry