1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
4 #include <CryAISystem/IAISystem.h>
5 #include <CryAISystem/IAgent.h>
6 #include "AI/AIManager.h"
7 #include "HyperGraph/FlowGraphManager.h"
8 #include "HyperGraph/FlowGraph.h"
10 #include "SmartObjectActionDialog.h"
12 // CSmartObjectActionDialog dialog
14 IMPLEMENT_DYNAMIC(CSmartObjectActionDialog
, CDialog
)
15 CSmartObjectActionDialog::CSmartObjectActionDialog(CWnd
* pParent
/*=NULL*/)
16 : CDialog(CSmartObjectActionDialog::IDD
, pParent
)
20 CSmartObjectActionDialog::~CSmartObjectActionDialog()
24 void CSmartObjectActionDialog::DoDataExchange(CDataExchange
* pDX
)
26 CDialog::DoDataExchange(pDX
);
27 DDX_Control(pDX
, IDC_ANCHORS
, m_wndActionList
);
30 BEGIN_MESSAGE_MAP(CSmartObjectActionDialog
, CDialog
)
31 ON_LBN_DBLCLK(IDC_ANCHORS
, OnLbnDblClk
)
32 ON_LBN_SELCHANGE(IDC_ANCHORS
, OnLbnSelchangeAction
)
33 ON_BN_CLICKED(IDC_NEW
, OnNewBtn
)
34 ON_BN_CLICKED(IDEDIT
, OnEditBtn
)
35 ON_BN_CLICKED(IDREFRESH
, OnRefreshBtn
)
38 // CSmartObjectStateDialog message handlers
40 void CSmartObjectActionDialog::OnNewBtn()
43 if (GetIEditor()->GetAIManager()->NewAction(filename
))
45 m_sSOAction
= PathUtil::GetFileName((const char*)filename
);
46 IAIAction
* pAction
= gEnv
->pAISystem
->GetAIActionManager()->GetAIAction(m_sSOAction
);
49 CFlowGraphManager
* pManager
= GetIEditor()->GetFlowGraphManager();
50 CHyperFlowGraph
* pFlowGraph
= pManager
->FindGraphForAction(pAction
);
53 pManager
->OpenView(pFlowGraph
);
60 void CSmartObjectActionDialog::OnEditBtn()
62 // EndDialog( IDCANCEL );
64 IAIAction
* pAction
= gEnv
->pAISystem
->GetAIActionManager()->GetAIAction(m_sSOAction
);
67 CFlowGraphManager
* pManager
= GetIEditor()->GetFlowGraphManager();
68 CHyperFlowGraph
* pFlowGraph
= pManager
->FindGraphForAction(pAction
);
71 pManager
->OpenView(pFlowGraph
);
75 void CSmartObjectActionDialog::OnRefreshBtn()
77 // add empty string item
78 m_wndActionList
.ResetContent();
79 m_wndActionList
.AddString("");
81 IAIManager
* pAIMgr
= GetIEditor()->GetAIManager();
83 typedef std::vector
<string
> TSOActionsVec
;
84 TSOActionsVec vecSOActions
;
85 pAIMgr
->GetSmartObjectActions(vecSOActions
);
86 for (TSOActionsVec::iterator it
= vecSOActions
.begin(); it
!= vecSOActions
.end(); ++it
)
87 m_wndActionList
.AddString((*it
).GetString());
88 m_wndActionList
.SelectString(-1, m_sSOAction
);
91 void CSmartObjectActionDialog::OnLbnDblClk()
93 if (m_wndActionList
.GetCurSel() >= 0)
97 void CSmartObjectActionDialog::OnLbnSelchangeAction()
99 SetDlgItemText(IDCANCEL
, "Cancel");
100 GetDlgItem(IDOK
)->EnableWindow(TRUE
);
102 int nSel
= m_wndActionList
.GetCurSel();
105 m_wndActionList
.GetText(nSel
, m_sSOAction
);
108 BOOL
CSmartObjectActionDialog::OnInitDialog()
110 CDialog::OnInitDialog();
111 SetWindowText("AI Actions");
112 SetDlgItemText(IDC_LISTCAPTION
, "&Choose AI Action:");
114 GetDlgItem(IDC_NEW
)->EnableWindow(TRUE
);
115 GetDlgItem(IDEDIT
)->EnableWindow(TRUE
);
116 GetDlgItem(IDDELETE
)->EnableWindow(FALSE
);
117 GetDlgItem(IDREFRESH
)->EnableWindow(TRUE
);
121 return TRUE
; // return TRUE unless you set the focus to a control
122 // EXCEPTION: OCX Property Pages should return FALSE