!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / Sandbox / Plugins / EditorSchematyc2 / Editor / AddAbstractInterfaceImplementationDlg.cpp
blobc9600515f59b93401476bcddee61e508a1741be7
1 // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
3 #include "StdAfx.h"
4 #include "AddAbstractInterfaceImplementationDlg.h"
6 #include "Resource.h"
8 namespace Schematyc2
10 //////////////////////////////////////////////////////////////////////////
11 BEGIN_MESSAGE_MAP(CAddAbstractInterfaceImplementationDlg, CDialog)
12 ON_LBN_SELCHANGE(IDD_SCHEMATYC_ABSTRACT_INTERFACES, OnAbstractInterfacesCtrlSelChange)
13 END_MESSAGE_MAP()
15 //////////////////////////////////////////////////////////////////////////
16 CAddAbstractInterfaceImplementationDlg::CAddAbstractInterfaceImplementationDlg(CWnd* pParent, CPoint pos, TScriptFile& scriptFile, const SGUID& objectGUID)
17 : CDialog(IDD_SCHEMATYC_ADD_ABSTRACT_INTERFACE_IMPLEMENTATION, pParent)
18 , m_pos(pos)
19 , m_scriptFile(scriptFile)
20 , m_objectGUID(objectGUID)
23 //////////////////////////////////////////////////////////////////////////
24 SGUID CAddAbstractInterfaceImplementationDlg::GetAbstractInterfaceImplementationGUID() const
26 return m_abstractInterfaceImplementationGUID;
29 //////////////////////////////////////////////////////////////////////////
30 BOOL CAddAbstractInterfaceImplementationDlg::OnInitDialog()
32 SetWindowPos(NULL, m_pos.x, m_pos.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
33 CDialog::OnInitDialog();
35 m_scriptFile.VisitAbstractInterfaceImplementations(ScriptAbstractInterfaceImplementationConstVisitor::FromMemberFunction<CAddAbstractInterfaceImplementationDlg, &CAddAbstractInterfaceImplementationDlg::VisitScriptAbstractInterfaceImplementation>(*this), m_objectGUID, false);
37 GetSchematyc()->GetEnvRegistry().VisitAbstractInterfaces(EnvAbstractInterfaceVisitor::FromMemberFunction<CAddAbstractInterfaceImplementationDlg, &CAddAbstractInterfaceImplementationDlg::VisitEnvAbstractInterface>(*this));
38 ScriptIncludeRecursionUtils::VisitAbstractInterfaces(m_scriptFile, ScriptIncludeRecursionUtils::AbstractInterfaceVisitor::FromMemberFunction<CAddAbstractInterfaceImplementationDlg, &CAddAbstractInterfaceImplementationDlg::VisitScriptAbstractInterface>(*this), SGUID(), true);
40 for(AbstractInterfaceVector::const_iterator iAbstractInterface = m_abstractInterfaces.begin(), iEndAbstractInterface = m_abstractInterfaces.end(); iAbstractInterface != iEndAbstractInterface; ++ iAbstractInterface)
42 m_abstractInterfacesCtrl.AddString(iAbstractInterface->name.c_str());
44 m_abstractInterfacesCtrl.SetCurSel(0);
45 OnAbstractInterfacesCtrlSelChange();
47 return true;
50 //////////////////////////////////////////////////////////////////////////
51 void CAddAbstractInterfaceImplementationDlg::DoDataExchange(CDataExchange* pDX)
53 DDX_Control(pDX, IDD_SCHEMATYC_ABSTRACT_INTERFACES, m_abstractInterfacesCtrl);
54 DDX_Control(pDX, IDD_SCHEMATYC_ABSTRACT_INTERFACE_DESCRIPTION, m_descriptionCtrl);
55 CDialog::DoDataExchange(pDX);
58 //////////////////////////////////////////////////////////////////////////
59 void CAddAbstractInterfaceImplementationDlg::OnAbstractInterfacesCtrlSelChange()
61 const char* textDesc = "";
62 const AbstractInterface abstractInterface = GetAbstractInterface();
63 switch(abstractInterface.domain)
65 case EDomain::Env:
67 IAbstractInterfaceConstPtr pAbstractInterface = GetSchematyc()->GetEnvRegistry().GetAbstractInterface(abstractInterface.guid);
68 if(pAbstractInterface)
70 textDesc = pAbstractInterface->GetDescription();
72 break;
74 case EDomain::Script:
76 const IScriptAbstractInterface* pAbstractInterface = ScriptIncludeRecursionUtils::GetAbstractInterface(m_scriptFile, abstractInterface.guid).second;
77 if(pAbstractInterface)
79 textDesc = pAbstractInterface->GetDescription();
81 break;
84 m_descriptionCtrl.SetWindowText(textDesc);
87 //////////////////////////////////////////////////////////////////////////
88 void CAddAbstractInterfaceImplementationDlg::OnOK()
90 const AbstractInterface abstractInterface = GetAbstractInterface();
91 IScriptAbstractInterfaceImplementation* pAbstractInterfaceImplementation = m_scriptFile.AddAbstractInterfaceImplementation(m_objectGUID, abstractInterface.domain, abstractInterface.guid);
92 if(pAbstractInterfaceImplementation)
94 m_abstractInterfaceImplementationGUID = pAbstractInterfaceImplementation->GetGUID();
96 CDialog::OnOK();
99 //////////////////////////////////////////////////////////////////////////
100 CAddAbstractInterfaceImplementationDlg::AbstractInterface::AbstractInterface() {}
102 //////////////////////////////////////////////////////////////////////////
103 CAddAbstractInterfaceImplementationDlg::AbstractInterface::AbstractInterface(const char* _name, EDomain _domain, const SGUID& _guid)
104 : name(_name)
105 , domain(_domain)
106 , guid(_guid)
109 //////////////////////////////////////////////////////////////////////////
110 EVisitStatus CAddAbstractInterfaceImplementationDlg::VisitScriptAbstractInterfaceImplementation(const IScriptAbstractInterfaceImplementation& abstractInterfaceImplementation)
112 m_exclusions.push_back(abstractInterfaceImplementation.GetRefGUID());
113 return EVisitStatus::Continue;
116 //////////////////////////////////////////////////////////////////////////
117 EVisitStatus CAddAbstractInterfaceImplementationDlg::VisitEnvAbstractInterface(const IAbstractInterfaceConstPtr& pAbstractInterface)
119 const SGUID abstractInterfaceGUID = pAbstractInterface->GetGUID();
120 if(std::find(m_exclusions.begin(), m_exclusions.end(), abstractInterfaceGUID) == m_exclusions.end())
122 stack_string fullName;
123 EnvRegistryUtils::GetFullName(pAbstractInterface->GetName(), pAbstractInterface->GetNamespace(), fullName);
124 m_abstractInterfaces.push_back(AbstractInterface(fullName.c_str(), EDomain::Env, abstractInterfaceGUID));
126 return EVisitStatus::Continue;
129 //////////////////////////////////////////////////////////////////////////
130 void CAddAbstractInterfaceImplementationDlg::VisitScriptAbstractInterface(const TScriptFile& abstractInterfaceFile, const IScriptAbstractInterface& abstractInterface)
132 const SGUID abstractInterfaceGUID = abstractInterface.GetGUID();
133 if(std::find(m_exclusions.begin(), m_exclusions.end(), abstractInterfaceGUID) == m_exclusions.end())
135 stack_string fullName;
136 DocUtils::GetFullElementName(m_scriptFile, abstractInterface, fullName);
137 m_abstractInterfaces.push_back(AbstractInterface(fullName.c_str(), EDomain::Script, abstractInterfaceGUID));
141 //////////////////////////////////////////////////////////////////////////
142 CAddAbstractInterfaceImplementationDlg::AbstractInterface CAddAbstractInterfaceImplementationDlg::GetAbstractInterface() const
144 const int curSel = m_abstractInterfacesCtrl.GetCurSel();
145 if((curSel != LB_ERR) && (curSel >= 0))
147 return m_abstractInterfaces[curSel];
149 return AbstractInterface();