reman3/Rayman_X/cpa/tempgrp/TID/Src/IADVwRst.cpp

1367 lines
45 KiB
C++

// CPAMVwMS.cpp : implementation file
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#define HieFriend
#include "IADVwRst.hpp"
#include "IADFmMn.hpp"
#include "IADDoc.hpp"
#include "IADCnst.hpp"
#include "_IADItrf.hpp"
#include "IADEdtTr.hpp"
#include "IADLnkMt.hpp"
#include "IADDgFnd.hpp"
#include "IADTrCtl.hpp"
#include "IADVwMn.hpp"
#include "help_def.h" //for Context Help
//External modules
#include "OAc.h"
#include "ErO.h"
#include "GAM.h"
//End of External modules
//BEGIN ROMTEAM Cristi Petrescu 98-05-
#include "IADVrVw.hpp"
#include "x:/cpa/tempgrp/tia/inc/showflag.hpp"
#include "x:/cpa/tempgrp/tia/inc/ai_intf.hpp"
#include "x:/cpa/main/inc/_EditId.h"
//END ROMTEAM Cristi Petrescu 98-05-
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// IAD_ResultView
IMPLEMENT_DYNCREATE(IAD_ResultView, CFormView)
BEGIN_MESSAGE_MAP(IAD_ResultView, CFormView)
//{{AFX_MSG_MAP(IAD_ResultView)
ON_WM_HELPINFO()
ON_WM_SIZE()
ON_BN_CLICKED(IDC_CHECK_SYNCHRONIZE, OnCheckSynchronize)
ON_EN_CHANGE(IDC_EDIT_LEVELS, OnChangeEditLevels)
ON_BN_CLICKED(IDC_BUTTON_FIND_NEXT_IN_TREE, OnButtonFindNextInTree)
ON_BN_CLICKED(IDC_BUTTON_FIND_IN_TREE, OnButtonFindInTree)
ON_BN_CLICKED(IDC_BUTTON_FIND_PREVIOUS_IN_TREE, OnButtonFindPreviousInTree)
ON_BN_CLICKED(IDC_CHECK_VIEW_REFLEX, OnCheckViewReflex)
ON_BN_CLICKED(IDC_CHECK_VIEW_AI, OnCheckViewAI)
ON_BN_CLICKED(IDC_CHECK_SHOW_TESTS, OnCheckShowTests)
ON_BN_CLICKED(IDC_CHECK_SHOW_MARKS, OnCheckShowMarks)
ON_BN_CLICKED(IDC_BUTTON_NEXT_LINE, OnButtonNextLine)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//***************************************************************************
IAD_ResultView::IAD_ResultView()
: CFormView(IAD_ResultView::IDD)
{
//{{AFX_DATA_INIT(IAD_ResultView)
m_lLevelToExpand = 0;
m_bMustSynchronize = TRUE;
m_bViewAI = TRUE;
m_bViewReflex = TRUE;
m_bShowMarks = TRUE;
m_bShowTests = TRUE;
//}}AFX_DATA_INIT
m_pri_pclTreeControl = NULL;
//BEGIN ROMTEAM Cristi Petrescu 98-05-
m_p_stInternalActor = NULL;
//END ROMTEAM Cristi Petrescu 98-05-
}
//***************************************************************************
IAD_ResultView::~IAD_ResultView()
{
if ( m_pri_pclTreeControl != NULL )
delete m_pri_pclTreeControl;
}
//***************************************************************************
void IAD_ResultView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(IAD_ResultView)
DDX_Text(pDX, IDC_EDIT_LEVELS, m_lLevelToExpand);
DDX_Check(pDX, IDC_CHECK_SYNCHRONIZE, m_bMustSynchronize);
//}}AFX_DATA_MAP
}
//Member Functions
////////////////////////////
//***************************************************************************
void IAD_ResultView::OnInitialUpdate()
{
//Creates the TreeControl
m_pri_pclTreeControl = new IAD_TreeControl;
m_pri_pclTreeControl->m_pub_fn_bCreate(this);
CFormView::OnInitialUpdate();
m_fn_pclGetDocument()->m_pclResultView = this;
//Sets icon on buttons
HICON hIcon = AfxGetApp()->LoadIcon(IDI_ICON_FIND_NEXT);
((CButton *)GetDlgItem(IDC_BUTTON_FIND_NEXT_IN_TREE))->SetIcon(hIcon);
hIcon = AfxGetApp()->LoadIcon(IDI_ICON_FIND_PREVIOUS);
((CButton *)GetDlgItem(IDC_BUTTON_FIND_PREVIOUS_IN_TREE))->SetIcon(hIcon);
hIcon = AfxGetApp()->LoadIcon(IDI_ICON_FIND);
((CButton *)GetDlgItem(IDC_BUTTON_FIND_IN_TREE))->SetIcon(hIcon);
// BEGIN ROMTEAM Cristi Petrescu 98-08-
hIcon = AfxGetApp()->LoadIcon(IDI_ICON_NEXT_LINE);
((CButton *)GetDlgItem(IDC_BUTTON_NEXT_LINE))->SetIcon(hIcon);
// END ROMTEAM Cristi Petrescu 98-08-
CRect crClientRect;
GetClientRect(crClientRect);
m_pub_fn_vSetEditedActorName("<< Nothing edited >>");
CSpinButtonCtrl *pclSpin = (CSpinButtonCtrl *)GetDlgItem(IDC_SPIN_LEVELS);
if ( pclSpin != NULL )
pclSpin->SetRange(0, 50);
if ( m_pri_pclTreeControl != NULL )
m_pri_pclTreeControl->SetIndent(3);
CProgressCtrl *pclProgress = (CProgressCtrl *)GetDlgItem(IDC_PROGRESS_STATUS);
if ( pclProgress != NULL )
pclProgress->SetRange(0, 100);
m_pub_fn_vSetStatusText("Ready !");
m_pub_fn_vSetFindStatusText("Nothing has been searched");
//BEGIN ROMTEAM Cristi Petrescu 98-05-
// BEGIN ROMTEAM Cristi Petrescu 98-08-
m_bMustSynchronize = TRUE;
((CButton *) GetDlgItem (IDC_CHECK_SYNCHRONIZE)) -> SetCheck (m_bMustSynchronize);
// END ROMTEAM Cristi Petrescu 98-08-
((CButton *) GetDlgItem (IDC_CHECK_VIEW_AI)) -> SetCheck (m_bViewAI);
((CButton *) GetDlgItem (IDC_CHECK_VIEW_REFLEX)) -> SetCheck (m_bViewReflex);
// BEGIN ROMTEAM Cristi Petrescu 98-08-
((CButton *) GetDlgItem (IDC_CHECK_SHOW_MARKS)) -> SetCheck (! m_bShowMarks);
// END ROMTEAM Cristi Petrescu 98-08-
((CButton *) GetDlgItem (IDC_CHECK_SHOW_TESTS)) -> SetCheck (m_bShowTests);
((CButton *) GetDlgItem (IDC_CHECK_SHOW_TESTS)) -> EnableWindow (! m_bShowMarks);
CPA_DLLBase *p_clDll = g_pclInterface->GetMainWorld()->GetToolDLLWithName(C_szDLLAIEditorName);
if ( p_clDll != NULL )
p_clDll -> OnQueryAction (g_pclInterface, C_uiAI_ShowFlags, m_fn_lShowFlags ());
//END ROMTEAM Cristi Petrescu 98-05-
}
//*******************************************************************************
void IAD_ResultView::m_pub_fn_vRefreshTree()
{
m_pri_pclTreeControl->InvalidateRect(NULL);
}
//*******************************************************************************
void IAD_ResultView::m_pub_fn_vDeleteAllInTreeControl()
{
m_fn_pclGetDocument()->m_pub_bIsDeletingTree = TRUE;
m_pri_pclTreeControl->DeleteAllItems();
m_fn_pclGetDocument()->m_pub_bIsDeletingTree = FALSE;
}
//*******************************************************************************
IAD_MyDocument* IAD_ResultView::m_fn_pclGetDocument()
{
return g_pclInterface->m_fn_pclGetDocument();
}
//***************************************************************************
void IAD_ResultView::m_pub_fn_vSetStatusText(CString _csNewStatus,
char _cPercentage /*= -1*/)
{
GetDlgItem(IDC_STATIC_STATUS)->SetWindowText(_csNewStatus);
if ( _cPercentage != -1 )
{
//Re-centers
_cPercentage = max (0, _cPercentage);
_cPercentage = min (100, _cPercentage);
//Displays in progress control
CProgressCtrl *pclProgress = (CProgressCtrl *)GetDlgItem(IDC_PROGRESS_STATUS);
if ( pclProgress != NULL )
pclProgress->SetPos(_cPercentage);
}
}
//***************************************************************************
void IAD_ResultView::m_pub_fn_vSetFindStatusText(CString _csNewStatus)
{
GetDlgItem(IDC_STATIC_FIND_STATUS)->SetWindowText(_csNewStatus);
}
//***************************************************************************
void IAD_ResultView::m_pub_fn_vSetEditedActorName(CString _csName)
{
GetDlgItem(IDC_STATIC_ACTOR_NAME)->SetWindowText(_csName);
}
//***************************************************************************
BOOL IAD_ResultView::OnHelpInfo(HELPINFO* pHelpInfo)
{
::WinHelp(m_hWnd,
LPCTSTR(g_pclInterface->m_clDocument.m_csHelpFileNameAndPath),
HELP_CONTEXT,
IDH_GENERAL);
return FALSE;
}
#define IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING 3
//***************************************************************************
void IAD_ResultView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
CRect crNameStaticDestRect;
CRect crTreeStaticDestRect;
CRect crStatusStaticDestRect;
CRect crButtonDestRect;
CRect crProgressDestRect;
CRect crButtonFindNextDestRect;
CRect crButtonFindPrevDestRect;
CRect crButtonFindDestRect;
//BEGIN ROMTEAM Cristi Petrescu 98-05-
CRect crVariableRect;
LONG lLeft;
//END ROMTEAM Cristi Petrescu 98-05-
//Re-sizes Static for Actor's name
CStatic *pclStatic = (CStatic *)GetDlgItem(IDC_STATIC_ACTOR_NAME);
if ( pclStatic != NULL )
{
CRect crStaticRect;
pclStatic->GetWindowRect(crStaticRect);
ScreenToClient(crStaticRect);
crNameStaticDestRect.top = IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crNameStaticDestRect.bottom = crNameStaticDestRect.top + crStaticRect.Height();
crNameStaticDestRect.left = crStaticRect.left;
crNameStaticDestRect.right = cx - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
pclStatic->MoveWindow(crNameStaticDestRect);
}
//Moves "Synchro" button
CButton *pclButton = (CButton *)GetDlgItem(IDC_CHECK_SYNCHRONIZE);
if ( pclButton != NULL )
{
CRect crButtonRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonDestRect.top = crNameStaticDestRect.bottom + IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonDestRect.bottom = crButtonDestRect.top + crButtonRect.Height();
crButtonDestRect.right = cx - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
//BEGIN ROMTEAM Cristi Petrescu 98-05-
lLeft = crButtonDestRect.left = crButtonDestRect.right - crButtonRect.Width();
//END ROMTEAM Cristi Petrescu 98-05-
pclButton->MoveWindow(crButtonDestRect);
}
//BEGIN ROMTEAM Cristi Petrescu 98-05-
// moves check ai button
pclButton = (CButton *) GetDlgItem (IDC_CHECK_VIEW_AI);
if ( pclButton != NULL )
{
CRect crButtonRect;
CRect crButtonFinalRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonFinalRect.top = crNameStaticDestRect.bottom + IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonFinalRect.bottom = crButtonFinalRect.top + crButtonRect.Height();
crButtonFinalRect.right = lLeft - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
lLeft = crButtonFinalRect.left = crButtonFinalRect.right - crButtonRect.Width();
pclButton->MoveWindow(crButtonFinalRect);
}
// moves check reflex button
pclButton = (CButton *) GetDlgItem (IDC_CHECK_VIEW_REFLEX);
if ( pclButton != NULL )
{
CRect crButtonRect;
CRect crButtonFinalRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonFinalRect.top = crNameStaticDestRect.bottom + IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonFinalRect.bottom = crButtonFinalRect.top + crButtonRect.Height();
crButtonFinalRect.right = lLeft - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
lLeft = crButtonFinalRect.left = crButtonFinalRect.right - crButtonRect.Width();
pclButton->MoveWindow(crButtonFinalRect);
}
// moves Tests button
pclButton = (CButton *) GetDlgItem (IDC_CHECK_SHOW_TESTS);
if ( pclButton != NULL )
{
CRect crButtonRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonFindNextDestRect.top = crButtonDestRect.bottom + IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonFindNextDestRect.bottom = crButtonFindNextDestRect.top + crButtonRect.Height();
crButtonFindNextDestRect.right = cx - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonFindNextDestRect.left = crButtonFindNextDestRect.right - crButtonRect.Width();
pclButton->MoveWindow(crButtonFindNextDestRect);
}
// moves Marks button
pclButton = (CButton *) GetDlgItem (IDC_CHECK_SHOW_MARKS);
if ( pclButton != NULL )
{
CRect crButtonRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonDestRect.top = crButtonFindNextDestRect.top;
crButtonDestRect.bottom = crButtonDestRect.top + crButtonRect.Height();
crButtonDestRect.right = crButtonFindNextDestRect.left - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonDestRect.left = crButtonDestRect.right - crButtonRect.Width();
pclButton->MoveWindow(crButtonDestRect);
}
//END ROMTEAM Cristi Petrescu 98-05-
// BEGIN ROMTEAM Cristi Petrescu 98-08-
//Moves "Find" button
pclButton = (CButton *)GetDlgItem(IDC_BUTTON_NEXT_LINE);
if ( pclButton != NULL )
{
CRect crButtonRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonDestRect.top = crButtonDestRect.top;
crButtonDestRect.bottom = crButtonDestRect.top + crButtonRect.Height();
crButtonDestRect.right = crButtonDestRect.left - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonDestRect.left = crButtonDestRect.right - crButtonRect.Width();
pclButton->MoveWindow(crButtonDestRect);
}
// END ROMTEAM Cristi Petrescu 98-08-
//Moves "Find Next" button
pclButton = (CButton *)GetDlgItem(IDC_BUTTON_FIND_NEXT_IN_TREE);
if ( pclButton != NULL )
{
CRect crButtonRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonFindNextDestRect.top = crButtonDestRect.bottom + IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonFindNextDestRect.bottom = crButtonFindNextDestRect.top + crButtonRect.Height();
crButtonFindNextDestRect.right = cx - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonFindNextDestRect.left = crButtonFindNextDestRect.right - crButtonRect.Width();
pclButton->MoveWindow(crButtonFindNextDestRect);
}
//Moves "Find Prev" button
pclButton = (CButton *)GetDlgItem(IDC_BUTTON_FIND_PREVIOUS_IN_TREE);
if ( pclButton != NULL )
{
CRect crButtonRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonFindPrevDestRect.top = crButtonFindNextDestRect.top;
crButtonFindPrevDestRect.bottom = crButtonFindPrevDestRect.top + crButtonRect.Height();
crButtonFindPrevDestRect.right = crButtonFindNextDestRect.left - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonFindPrevDestRect.left = crButtonFindPrevDestRect.right - crButtonRect.Width();
pclButton->MoveWindow(crButtonFindPrevDestRect);
}
//Moves "Find" button
pclButton = (CButton *)GetDlgItem(IDC_BUTTON_FIND_IN_TREE);
if ( pclButton != NULL )
{
CRect crButtonRect;
pclButton->GetWindowRect(crButtonRect);
ScreenToClient(crButtonRect);
crButtonFindDestRect.top = crButtonFindNextDestRect.top;
crButtonFindDestRect.bottom = crButtonFindDestRect.top + crButtonRect.Height();
crButtonFindDestRect.right = crButtonFindPrevDestRect.left - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crButtonFindDestRect.left = crButtonFindDestRect.right - crButtonRect.Width();
pclButton->MoveWindow(crButtonFindDestRect);
}
//Moves Find Status static
pclStatic = (CStatic *)GetDlgItem(IDC_STATIC_FIND_STATUS);
if ( pclStatic != NULL )
{
CRect crStaticRect;
pclStatic->GetWindowRect(crStaticRect);
ScreenToClient(crStaticRect);
CRect crDestRect;
crDestRect.top = crButtonFindDestRect.top;
crDestRect.bottom = crDestRect.top + crStaticRect.Height();
crDestRect.left = IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crDestRect.right = crButtonFindDestRect.left - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
pclStatic->MoveWindow(crDestRect);
}
//Re-sizes Static for Actor's name
pclStatic = (CStatic *)GetDlgItem(IDC_STATIC_IA_TREE);
if ( pclStatic != NULL )
{
CRect crStaticRect;
pclStatic->GetWindowRect(crStaticRect);
ScreenToClient(crStaticRect);
crTreeStaticDestRect.top = crButtonFindNextDestRect.bottom + IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crTreeStaticDestRect.bottom = crTreeStaticDestRect.top + crStaticRect.Height();
crTreeStaticDestRect.left = crStaticRect.left;
crTreeStaticDestRect.right = cx - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
pclStatic->MoveWindow(crTreeStaticDestRect);
}
//Re-sizes Static for status progress
CWnd *pclProgress = GetDlgItem(IDC_PROGRESS_STATUS);
if ( pclProgress != NULL )
{
CRect crStaticRect;
pclProgress->GetWindowRect(crStaticRect);
crProgressDestRect.bottom = cy - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crProgressDestRect.top = crProgressDestRect.bottom - crStaticRect.Height();
crProgressDestRect.left = IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crProgressDestRect.right = cx - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
pclProgress->MoveWindow(crProgressDestRect);
}
//Re-sizes Static for status
pclStatic = (CStatic *)GetDlgItem(IDC_STATIC_STATUS);
if ( pclStatic != NULL )
{
CRect crStaticRect;
pclStatic->GetWindowRect(crStaticRect);
crStatusStaticDestRect.bottom = crProgressDestRect.top - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crStatusStaticDestRect.top = crStatusStaticDestRect.bottom - crStaticRect.Height();
crStatusStaticDestRect.left = IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crStatusStaticDestRect.right = cx - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
pclStatic->MoveWindow(crStatusStaticDestRect);
}
//Re-sizes Tree Ctrl
if ( m_pri_pclTreeControl != NULL )
{
CRect crTreeRect;
crTreeRect.top = crTreeStaticDestRect.bottom + IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crTreeRect.bottom = crStatusStaticDestRect.top - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crTreeRect.left = IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
crTreeRect.right = cx - IA_DEBUGGER_TREE_VIEW_CONTROL_SPACING;
m_pri_pclTreeControl->MoveWindow(crTreeRect);
}
}
//***************************************************************************
void IAD_ResultView::m_pub_fn_vDisplayTraceForActor(struct IAD_stInternalActorDescription *_p_stInternalActor)
{
//BEGIN ROMTEAM Cristi Petrescu 98-05-
m_p_stInternalActor = _p_stInternalActor;
//END ROMTEAM Cristi Petrescu 98-05-
if ( _p_stInternalActor != NULL )
{
if ( _p_stInternalActor != g_pclInterface->m_clDocument.m_pub_fn_p_stGetSelectedActor() )
{
AfxGetApp()->DoWaitCursor(1);
//Frees all needed for last selected Actor
g_pclInterface->m_clDocument.m_pub_fn_vFreeEditorTraceForEditedActor();
g_pclInterface->m_clDocument.m_pub_fn_vSetSelectedActor(_p_stInternalActor);
//Sets Actor's Name
m_pub_fn_vSetEditedActorName(_p_stInternalActor->pclActor->GetName());
m_fn_vEnableFindNextButton(FALSE);
CString csText("Computing Editor Tree for Actor '");
csText += _p_stInternalActor->pclActor->GetName() + "' ... Please wait !";
m_pub_fn_vSetStatusText(csText);
m_pri_fn_vComputeEditorTreeFromMotorTrace(_p_stInternalActor);
m_pub_fn_vSetStatusText("Filling Tree", 0);
m_pri_fn_vFillTreeControl(_p_stInternalActor);
CString csReadyText;
csReadyText.Format("Ready ! [ %s -> %ld entry(ies) ]", _p_stInternalActor->pclActor->GetName(), m_pri_ulTotalNumberOfNodes);
m_pub_fn_vSetStatusText(csReadyText, 0);
g_pclInterface->m_clDocument.m_pub_fn_vSetSelectedActor(_p_stInternalActor);
AfxGetApp()->DoWaitCursor(-1);
}
}
}
//***************************************************************************
void IAD_ResultView::OnCheckSynchronize()
{
UpdateData(TRUE);
}
//***************************************************************************
void IAD_ResultView::OnChangeEditLevels()
{
if ( GetDlgItem(IDC_EDIT_LEVELS)->m_hWnd != NULL ) //To avoid construction
{
UpdateData(TRUE);
if ( m_pri_pclTreeControl != NULL )
{
HTREEITEM hCurrentRootTreeItem = m_pri_pclTreeControl->GetNextItem(NULL, TVGN_ROOT);
while ( hCurrentRootTreeItem != NULL )
{
//Tries to expand childs of this root Item, at the right level
m_pri_pclTreeControl->Expand(hCurrentRootTreeItem, (m_lLevelToExpand > 0) ? TVE_EXPAND : TVE_COLLAPSE);
m_pri_fn_lLookInChildsToExpand(hCurrentRootTreeItem, 0);
hCurrentRootTreeItem = m_pri_pclTreeControl->GetNextItem(hCurrentRootTreeItem, TVGN_NEXT);
}
}
}
}
//***************************************************************************
void IAD_ResultView::OnButtonFindInTree()
{
if ( m_fn_pclGetDocument()->m_pub_fn_p_stGetSelectedActor() != NULL )
{
IAD_Dialog_FindInTree dial(AfxGetMainWnd());
if ( dial.DoModal() == IDOK )
{
AfxGetApp()->DoWaitCursor(1);
HTREEITEM hFoundTreeItem = m_fn_pclGetDocument()->m_pub_fn_hFindInTree( m_fn_pclGetDocument()->m_pub_fn_p_stGetSelectedActor()->pclRoot,
m_fn_pclGetDocument()->m_pub_p_tdstGetFindInfo());
if ( hFoundTreeItem != NULL )
m_pri_pclTreeControl->m_pub_fn_vSelectAndShowItem(hFoundTreeItem);
AfxGetApp()->DoWaitCursor(-1);
}
}
}
//***************************************************************************
void IAD_ResultView::OnButtonFindNextInTree()
{
HTREEITEM hFoundTreeItem = m_fn_pclGetDocument()->m_pub_fn_hFindNextInTree();
if ( hFoundTreeItem != NULL )
m_pri_pclTreeControl->m_pub_fn_vSelectAndShowItem(hFoundTreeItem);
}
//***************************************************************************
void IAD_ResultView::OnButtonFindPreviousInTree()
{
HTREEITEM hFoundTreeItem = m_fn_pclGetDocument()->m_pub_fn_hFindPreviousInTree();
if ( hFoundTreeItem != NULL )
m_pri_pclTreeControl->m_pub_fn_vSelectAndShowItem(hFoundTreeItem);
}
//***************************************************************************
void IAD_ResultView::m_fn_vEnableFindNextButton(BOOL _bEnable /*= TRUE*/)
{
GetDlgItem(IDC_BUTTON_FIND_NEXT_IN_TREE)->EnableWindow(_bEnable);
}
//***************************************************************************
void IAD_ResultView::m_fn_vEnableFindPrevButton(BOOL _bEnable /*= TRUE*/)
{
GetDlgItem(IDC_BUTTON_FIND_PREVIOUS_IN_TREE)->EnableWindow(_bEnable);
}
//BEGIN ROMTEAM Cristi Petrescu 98-05-
//***************************************************************************
void IAD_ResultView::OnCheckViewAI()
{
//UpdateData (TRUE);
m_bViewAI = !m_bViewAI;
if (!m_bViewAI && !m_bViewReflex)
{
m_bViewAI = TRUE;
}
else
{
((CButton *) GetDlgItem (IDC_CHECK_VIEW_AI)) -> SetCheck (m_bViewAI);
if (m_p_stInternalActor != NULL)
{
m_pri_pclTreeControl -> m_fn_vSetViewAI (m_bViewAI);
m_pri_fn_vFillTreeControl (m_p_stInternalActor);
}
}
}
//***************************************************************************
void IAD_ResultView::OnCheckViewReflex()
{
m_bViewReflex = !m_bViewReflex;
if (!m_bViewAI && !m_bViewReflex)
{
m_bViewReflex = TRUE;
}
else
{
((CButton *) GetDlgItem (IDC_CHECK_VIEW_REFLEX)) -> SetCheck (m_bViewReflex);
if (m_p_stInternalActor != NULL)
{
m_pri_pclTreeControl -> m_fn_vSetViewReflex (m_bViewReflex);
m_pri_fn_vFillTreeControl (m_p_stInternalActor);
}
}
}
//***************************************************************************
void IAD_ResultView::OnCheckShowTests()
{
m_bShowTests = ! m_bShowTests;
((CButton *) GetDlgItem (IDC_CHECK_SHOW_TESTS)) -> SetCheck (m_bShowTests);
CPA_DLLBase *p_clDll = g_pclInterface->GetMainWorld()->GetToolDLLWithName(C_szDLLAIEditorName);
if ( p_clDll != NULL )
p_clDll -> OnQueryAction (g_pclInterface, C_uiAI_ShowFlags, m_fn_lShowFlags ());
}
//***************************************************************************
void IAD_ResultView::OnCheckShowMarks()
{
m_bShowMarks = ! m_bShowMarks;
// BEGIN ROMTEAM Cristi Petrescu 98-08-
((CButton *) GetDlgItem (IDC_CHECK_SHOW_MARKS)) -> SetCheck (! m_bShowMarks);
// END ROMTEAM Cristi Petrescu 98-08-
((CButton *) GetDlgItem (IDC_CHECK_SHOW_TESTS)) -> EnableWindow (! m_bShowMarks);
CPA_DLLBase *p_clDll = g_pclInterface->GetMainWorld()->GetToolDLLWithName(C_szDLLAIEditorName);
if ( p_clDll != NULL )
p_clDll -> OnQueryAction (g_pclInterface, C_uiAI_ShowFlags, m_fn_lShowFlags ());
}
//***************************************************************************
long IAD_ResultView::m_fn_lShowFlags (void)
{
if (m_bShowMarks)
return E_MarkExecutedLines;
if (m_bShowTests)
return E_ShowTestsAndActions;
return E_ShowActions;
}
//END ROMTEAM Cristi Petrescu 98-05-
// BEGIN ROMTEAM Cristi Petrescu 98-08-
void IAD_ResultView::OnButtonNextLine()
{
IAD_EditorTreeNode *pclNextLine = NULL;
// find the current node
IAD_EditorTreeNode *pclCurrentNode = m_fn_pclGetSelectedEditorNode ();
if (! pclCurrentNode)
return;
// get the current behaviour and the current line
IAD_EditorTreeNode *pclBehaviourNode = pclCurrentNode;
IAD_EditorTreeNode *pclCurrentLineNode = NULL;
while (pclBehaviourNode && pclBehaviourNode -> m_pub_fn_tdeGetNodeType () != AIDebug_E_SecTyp_ReflexOrAI)
{
pclCurrentLineNode = pclBehaviourNode;
pclBehaviourNode = pclBehaviourNode -> m_pub_fn_pclGetParentNode ();
}
if (! pclBehaviourNode)
return;
if (! pclCurrentLineNode)
{
// first line of the behaviour
pclNextLine = pclBehaviourNode -> m_pub_fn_ptdGetListOfChildNodes () -> GetHead ();
}
else
{
POSITION pos = pclBehaviourNode -> m_pub_fn_ptdGetListOfChildNodes () -> Find (pclCurrentLineNode);
pclBehaviourNode -> m_pub_fn_ptdGetListOfChildNodes () -> GetNext (pos);
if (! pos)
{
CString csBehaviourName = pclBehaviourNode -> m_pub_fn_csGetNodeName ();
//should find the next loop
IAD_EditorTreeNode *pclCurrentLoop = pclBehaviourNode -> m_fn_pclGetEngineLoopParentNode ();
IAD_EditorTreeNode *pclRoot = pclCurrentLoop -> m_pub_fn_pclGetParentNode ();
IAD_EditorTreeNode *pclNextLoop;
pos = pclRoot -> m_pub_fn_ptdGetListOfChildNodes () -> Find (pclCurrentLoop);
pclRoot -> m_pub_fn_ptdGetListOfChildNodes () -> GetNext (pos);
if (! pos)
{
// last loop; acquire data from engine
M_GetMainApp () -> fn_vAppliAskToStopEditors ();
M_GetMainApp () -> fn_vAppliAskOneStep ();
M_GetMainApp () -> fn_vAppliAskToStartEditors ();
//rebuild all
m_pub_fn_vDisplayTraceForActor (m_p_stInternalActor);
// select last loop (the only ?!)
pclNextLoop = m_p_stInternalActor -> pclRoot -> m_pub_fn_ptdGetListOfChildNodes () -> GetTail ();
if (! pclNextLoop)
return;
}
else
{
pclNextLoop = pclRoot -> m_pub_fn_ptdGetListOfChildNodes () -> GetNext (pos);
}
// build the subtree for this node (select that node!)
m_pri_pclTreeControl -> m_pub_fn_vSelectAndShowItem (pclNextLoop -> m_pub_fn_hGetTreeItem ());
// now get the new behaviour node
pos = pclNextLoop -> m_pub_fn_ptdGetListOfChildNodes () -> GetHeadPosition ();
while (pos)
{
pclBehaviourNode = pclNextLoop -> m_pub_fn_ptdGetListOfChildNodes () -> GetNext (pos);
if (csBehaviourName == pclBehaviourNode -> m_pub_fn_csGetNodeName ())
{
pclNextLine = pclBehaviourNode -> m_pub_fn_ptdGetListOfChildNodes () -> GetHead ();
break;
}
}
}
else
{
pclNextLine = pclBehaviourNode -> m_pub_fn_ptdGetListOfChildNodes () -> GetNext (pos);
}
}
if (pclNextLine)
{
// select the line
m_pri_pclTreeControl -> m_pub_fn_vSelectAndShowItem (pclNextLine -> m_pub_fn_hGetTreeItem ());
}
}
// END ROMTEAM Cristi Petrescu 98-08-
//***************************************************************************
//***************************************************************************
//***************************************************************************
//***************************************************************************
///////////////////////
// Private functions //
///////////////////////
//***************************************************************************
void IAD_ResultView::m_pri_fn_vComputeEditorTreeFromMotorTrace(struct IAD_stInternalActorDescription *_p_stInternalActor)
{
//Gets motor trace
if ( ((tdstEngineObject *)_p_stInternalActor->pclActor->GetStruct())->h_Brain != NULL )
{
AI_tdstMind *p_stMind = M_pstGetMindOfBrain( ((tdstEngineObject *)_p_stInternalActor->pclActor->GetStruct())->h_Brain );
//Building Tree Root
if ( _p_stInternalActor->pclRoot == NULL )
_p_stInternalActor->pclRoot = new IAD_EditorTreeNode;
m_pri_ulTotalNumberOfNodes = 0;
//Inits motor trace reading
unsigned char ucDepth;
// CG PB DEBUGGER 23/06/98 {
#ifdef ACTIVE_AIDEBUG
BOOL bMustGoOn = ( AIDebug_fn_bInitExploitation(p_stMind,
&m_pri_tdeSectionType,
&m_pri_lID,
&m_pri_stGetSetParam,
&ucDepth,
&m_pri_p_stNode) == 1 );
#else
BOOL bMustGoOn = FALSE;
#endif
// CG PB DEBUGGER
if ( bMustGoOn )
{
m_pri_bMustStopTreeConstruction = FALSE;
//Will be called recursively
m_pri_fn_lAddChildNodesToOneNode(_p_stInternalActor->pclRoot, p_stMind, ucDepth, _p_stInternalActor);
//BEGIN ROMTEAM Cristi Petrescu 98-05-
//cleanup unneeded nodes (Reflex/AI), mark changements)
m_fn_vPostProcessEditorTree (_p_stInternalActor->pclRoot);
//END ROMTEAM Cristi Petrescu 98-05-
}
else
{
CString csMessage = "Nothing in Trace for the Actor '" + _p_stInternalActor->pclActor->GetName() + "' !";
m_pub_fn_vSetStatusText(csMessage, 0);
}
}
else
{
CString csMessage = "No Brain for the Actor '" + _p_stInternalActor->pclActor->GetName() + "' ! This should not occur...";
m_pub_fn_vSetStatusText(csMessage, 0);
}
}
//***************************************************************************
long IAD_ResultView::m_pri_fn_lAddChildNodesToOneNode(IAD_EditorTreeNode *_pclParentNode,
struct AI_tdstMind_ *_p_tdstMind,
long _lPreviousDepth,
struct IAD_stInternalActorDescription *_p_stInternalActor)
{
long lOffsetIndex = 0;
unsigned char ucCurrentDepth = (unsigned char)_lPreviousDepth;
CString csNewElementType;
CString csNewElementName;
CString csNewElementValue;
CString csNewElemenReturnValue;
BOOL bMustGoOn = TRUE;
BOOL bReadNextElement = TRUE;
IAD_EditorTreeNode *pclLastAddedNode = NULL;
//BEGIN ROMTEAM Cristi Petrescu 98-05-
CString csBehaviourName;
//END ROMTEAM Cristi Petrescu 98-05-
// CG PB DEBUGGER 23/06/98 {
#ifdef ACTIVE_AIDEBUG
while ( bMustGoOn )
{
// BEGIN ROMTEAM Cristi Petrescu 98-06-
// I'll keep this node since it seems it replaces a normal node. Is very strange...
// this was already added in the first pass
// Further tests shows tis is not true. So, KILL this node without remorse
//while (m_pri_tdeSectionType == AIDebug_E_SecTyp_CurrentComport)
//{
//skip it
// m_pri_bMustStopTreeConstruction = (AIDebug_fn_bGetNextEntry (_p_tdstMind, & m_pri_tdeSectionType, & m_pri_lID, & m_pri_stGetSetParam, & ucCurrentDepth, & m_pri_p_stNode) == 0);
// if (! m_pri_bMustStopTreeConstruction)
// return ucCurrentDepth;
//}
// END ROMTEAM Cristi Petrescu 98-06-
//Adds node to current Father
if ( ucCurrentDepth == _lPreviousDepth )
{
//Computes strings
if ( g_a_p_fnArrayOfGetTypeCallBacks[m_pri_tdeSectionType] != NULL )
csNewElementType = g_a_p_fnArrayOfGetTypeCallBacks[m_pri_tdeSectionType](m_pri_lID, &m_pri_stGetSetParam);
else
csNewElementType = "Unknown";
if ( g_a_p_fnArrayOfGetNameCallBacks[m_pri_tdeSectionType] != NULL )
csNewElementName = g_a_p_fnArrayOfGetNameCallBacks[m_pri_tdeSectionType](m_pri_lID, &m_pri_stGetSetParam);
else
csNewElementName = "";
if ( g_a_p_fnArrayOfGetValueCallBacks[m_pri_tdeSectionType] != NULL )
csNewElementValue = g_a_p_fnArrayOfGetValueCallBacks[m_pri_tdeSectionType](m_pri_lID, &m_pri_stGetSetParam);
else
csNewElementValue = "";
if ( g_a_p_fnArrayOfGetReturnValueCallBacks[m_pri_tdeSectionType] != NULL )
csNewElemenReturnValue = g_a_p_fnArrayOfGetReturnValueCallBacks[m_pri_tdeSectionType](m_pri_lID, &m_pri_stGetSetParam);
else
csNewElemenReturnValue = "";
//BEGIN ROMTEAM Cristi Petrescu 98-05-
if (_pclParentNode -> m_pub_fn_tdeGetNodeType () == AIDebug_E_SecTyp_ReflexOrAI)
{
if (m_pri_tdeSectionType == AIDebug_E_SecTyp_CurrentComport)
{
char szName[SCR_CV_ui_Cfg_MaxLenName];
SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csNewElementValue, NULL, NULL, szName);
csBehaviourName = CString (szName);
// BEGIN ROMTEAM Cristi Petrescu 98-08-
csNewElementValue = csBehaviourName;
// END ROMTEAM Cristi Petrescu 98-08-
}
else
{
csBehaviourName = _p_stInternalActor -> pclActor -> m_fn_csGetBehaviourName (m_pri_p_stNode);
}
BOOL bBehaviourNodeExists = FALSE;
POSITION pos = _pclParentNode -> m_pub_fn_ptdGetListOfChildNodes () -> GetHeadPosition ();
IAD_EditorTreeNode *pclBehaviourNode;
while (pos)
{
pclBehaviourNode = _pclParentNode -> m_pub_fn_ptdGetListOfChildNodes () -> GetNext (pos);
if (csBehaviourName == pclBehaviourNode -> m_pub_fn_csGetNodeName ())
{
bBehaviourNodeExists = TRUE;
break;
}
}
if (! bBehaviourNodeExists)
{
CString csBehaviourType;
// BEGIN ROMTEAM Cristi Petrescu 98-08-
if (m_pri_tdeSectionType == AIDebug_E_SecTyp_CurrentComport)
csBehaviourType = "C ";
if (_pclParentNode -> m_pub_fn_csGetNodeType () == "Reflex")
csBehaviourType += "R:";
else
csBehaviourType += "I:";
// END ROMTEAM Cristi Petrescu 98-08-
//create a the behaviour name in the parent
pclBehaviourNode = _pclParentNode -> m_pub_fn_pclAddChildNode ( AIDebug_E_SecTyp_ReflexOrAI, NULL, _p_stInternalActor->pclActor, csBehaviourType, csBehaviourName, "", "", "");
}
// add the node to the behaviour node child list
//if (m_pri_tdeSectionType != AIDebug_E_SecTyp_CurrentComport)
pclLastAddedNode = pclBehaviourNode->m_pub_fn_pclAddChildNode(m_pri_tdeSectionType, m_pri_p_stNode, _p_stInternalActor->pclActor, csNewElementType, csNewElementName, csNewElementValue, csNewElemenReturnValue, "");
}
else
{
// as usual
pclLastAddedNode = _pclParentNode->m_pub_fn_pclAddChildNode(m_pri_tdeSectionType, m_pri_p_stNode, _p_stInternalActor->pclActor, csNewElementType, csNewElementName, csNewElementValue, csNewElemenReturnValue, "");
}
//END ROMTEAM Cristi Petrescu 98-05-
m_pri_ulTotalNumberOfNodes ++;
bReadNextElement = TRUE;
}
//returns
else if ( ucCurrentDepth < _lPreviousDepth )
{
bMustGoOn = FALSE;
}
//Adds childs nodes
else if ( ucCurrentDepth > _lPreviousDepth )
{
ucCurrentDepth = (unsigned char)m_pri_fn_lAddChildNodesToOneNode( pclLastAddedNode,
_p_tdstMind,
ucCurrentDepth,
_p_stInternalActor);
bReadNextElement = FALSE;
bMustGoOn = !m_pri_bMustStopTreeConstruction;
}
if ( bMustGoOn && bReadNextElement )
{
// BEGIN ROMTEAM Cristi Petrescu 98-06-
if (m_pri_tdeSectionType == AIDebug_E_SecTyp_EngineLoop)
{
// force abort tree computation
AIDebug_tdstTrace *p_stTrace = AI_M_p_stGetTrace(_p_tdstMind);
pclLastAddedNode -> m_uwSubtreeTraceIndex = AIDebug_M_uwGetExplIndex( p_stTrace );
pclLastAddedNode -> m_bSubtreeBuilded = FALSE;
// get all engine loops
// + get the variables snapshot
while (1)
{
m_pri_bMustStopTreeConstruction = ( AIDebug_fn_bGetNextEntry (_p_tdstMind,
& m_pri_tdeSectionType,
& m_pri_lID,
& m_pri_stGetSetParam,
& ucCurrentDepth,
& m_pri_p_stNode) == 0);
if (m_pri_bMustStopTreeConstruction)
break;
// look for variables snapshot
if (m_pri_tdeSectionType == AIDebug_E_SecTyp_DsgVar && m_pri_p_stNode == NULL)
{
// TODO get the variable
pclLastAddedNode -> m_fn_vAddVariableValue (& m_pri_stGetSetParam);
// for the subtree computation, just skip those nodes
pclLastAddedNode -> m_uwSubtreeTraceIndex = AIDebug_M_uwGetExplIndex( p_stTrace );
continue;
}
// look for change behaviour nodes
if (m_pri_tdeSectionType == AIDebug_E_SecTyp_CurrentComport)
{
// get the values for the node.
csNewElementType = "Changed Behaviour";
//if ( g_a_p_fnArrayOfGetTypeCallBacks[m_pri_tdeSectionType] != NULL )
// csNewElementType = g_a_p_fnArrayOfGetTypeCallBacks[m_pri_tdeSectionType](m_pri_lID, &m_pri_stGetSetParam);
//else
// csNewElementType = "Unknown";
if ( g_a_p_fnArrayOfGetNameCallBacks[m_pri_tdeSectionType] != NULL )
csNewElementName = g_a_p_fnArrayOfGetNameCallBacks[m_pri_tdeSectionType](m_pri_lID, &m_pri_stGetSetParam);
else
csNewElementName = "";
if ( g_a_p_fnArrayOfGetValueCallBacks[m_pri_tdeSectionType] != NULL )
csNewElementValue = g_a_p_fnArrayOfGetValueCallBacks[m_pri_tdeSectionType](m_pri_lID, &m_pri_stGetSetParam);
else
csNewElementValue = "";
if ( g_a_p_fnArrayOfGetReturnValueCallBacks[m_pri_tdeSectionType] != NULL )
csNewElemenReturnValue = g_a_p_fnArrayOfGetReturnValueCallBacks[m_pri_tdeSectionType](m_pri_lID, &m_pri_stGetSetParam);
else
csNewElemenReturnValue = "";
// build change comport node
pclLastAddedNode -> m_pub_fn_pclAddChildNode(m_pri_tdeSectionType, m_pri_p_stNode, _p_stInternalActor->pclActor, csNewElementType, csNewElementName, csNewElementValue, csNewElemenReturnValue, "");
continue;
}
if (m_pri_tdeSectionType == AIDebug_E_SecTyp_EngineLoop)
{
// the next engine loop, add it to the same node
m_pri_fn_lAddChildNodesToOneNode (_pclParentNode, _p_tdstMind, _lPreviousDepth, _p_stInternalActor);
}
}
}
else
{
//Gets the next trace element
m_pri_bMustStopTreeConstruction = ( AIDebug_fn_bGetNextEntry( _p_tdstMind,
&m_pri_tdeSectionType,
&m_pri_lID,
&m_pri_stGetSetParam,
&ucCurrentDepth,
&m_pri_p_stNode) == 0 );
}
// END ROMTEAM Cristi Petrescu 98-06-
bMustGoOn = !m_pri_bMustStopTreeConstruction;
}
}
#endif
// CG PB DEBUGGER
return ucCurrentDepth;
}
//BEGIN ROMTEAM Cristi Petrescu 98-05-
//***************************************************************************
void IAD_ResultView::m_fn_vPostProcessEditorTree (IAD_EditorTreeNode *_pclParentNode)
{
IAD_tdListOfNodes clListOfNodes;
IAD_EditorTreeNode *_pclCurrentNode;
POSITION pos = _pclParentNode -> m_pub_fn_ptdGetListOfChildNodes () -> GetHeadPosition ();
while ( pos != NULL )
{
_pclCurrentNode = _pclParentNode -> m_pub_fn_ptdGetListOfChildNodes () -> GetNext (pos);
// CG PB DEBUGGER 23/06/98 {
#ifdef ACTIVE_AIDEBUG
//cleanup, eliminates the "Reflex" and "AI" nodes
// but keep all others
if (_pclParentNode -> m_pub_fn_tdeGetNodeType () == AIDebug_E_SecTyp_EngineLoop)
{
if (_pclCurrentNode -> m_pub_fn_tdeGetNodeType () == AIDebug_E_SecTyp_ReflexOrAI)
{
IAD_EditorTreeNode *_pclNode;
POSITION cleanpos = _pclCurrentNode->m_pub_fn_ptdGetListOfChildNodes()->GetHeadPosition();
IAD_tdListOfNodes clListOfAllNodes;
while (cleanpos != NULL)
{
_pclNode = _pclCurrentNode->m_pub_fn_ptdGetListOfChildNodes()->GetNext(cleanpos);
clListOfNodes . AddTail (_pclNode);
// and set the parent pointer properly
_pclNode -> m_fn_vSetParentNode (_pclParentNode);
}
}
else
{
clListOfNodes . AddTail (_pclCurrentNode);
}
}
#endif
// CG PB DEBUGGER
//Calls recursively to build childs level
m_fn_vPostProcessEditorTree(_pclCurrentNode);
}
// CG PB DEBUGGER 23/06/98 {
#ifdef ACTIVE_AIDEBUG
if (_pclParentNode -> m_pub_fn_tdeGetNodeType () == AIDebug_E_SecTyp_EngineLoop)
{
_pclParentNode -> m_fn_vSetListOfChildNodes (& clListOfNodes);
}
#endif
// CG PB DEBUGGER
}
//END ROMTEAM Cristi Petrescu 98-05-
// BEGIN ROMTEAM Cristi Petrescu 98-06-
//***************************************************************************
void IAD_ResultView::m_fn_vBuildSubtree (IAD_EditorTreeNode *pclParentNode)//, HTREEITEM hTreeParentItem)
{
// BEGIN ROMTEAM Cristi Petrescu 98-08-
HTREEITEM hTreeParentItem = pclParentNode -> m_pub_fn_hGetTreeItem ();
// END ROMTEAM Cristi Petrescu 98-08-
m_pri_bMustStopTreeConstruction = FALSE;
AI_tdstMind *p_stMind = M_pstGetMindOfBrain(((tdstEngineObject *) m_p_stInternalActor -> pclActor -> GetStruct ()) -> h_Brain);
unsigned char ucCurrentDepth;
// CG PB DEBUGGER 23/06/98 {
#ifdef ACTIVE_AIDEBUG
m_pri_bMustStopTreeConstruction = (AIDebug_fn_bGetNextEntry (p_stMind,
& m_pri_tdeSectionType,
& m_pri_lID,
& m_pri_stGetSetParam,
& ucCurrentDepth,
& m_pri_p_stNode) == 0);
#else
m_pri_bMustStopTreeConstruction = TRUE;
#endif
// CG PB DEBUGGER
while (! m_pri_bMustStopTreeConstruction)
{
m_pri_fn_lAddChildNodesToOneNode (pclParentNode,
p_stMind,
ucCurrentDepth, // the depth of the Loop is 1
m_p_stInternalActor);
// CG PB DEBUGGER 23/06/98 {
#ifdef ACTIVE_AIDEBUG
if (m_pri_tdeSectionType == AIDebug_E_SecTyp_EngineLoop)
m_pri_bMustStopTreeConstruction = TRUE;
#endif
// CG PB DEBUGGER
}
m_fn_vPostProcessEditorTree (pclParentNode);
// synchro new data with tree control
m_pri_fn_vFillOneLevelOfTree (pclParentNode, hTreeParentItem, TRUE);
}
IAD_EditorTreeNode *IAD_ResultView::m_fn_pclGetSelectedEditorNode (void)
{
// first, which is the selected tree control node?
HTREEITEM hItem = m_pri_pclTreeControl -> GetSelectedItem ();
if (! hItem)
return NULL;
// now, get the coresponding editor node
return (IAD_EditorTreeNode *) m_pri_pclTreeControl -> GetItemData (hItem);
}
// END ROMTEAM Cristi Petrescu 98-06-
//***************************************************************************
void IAD_ResultView::m_pri_fn_vFillTreeControl(struct IAD_stInternalActorDescription *_p_stInternalActor)
{
ERROR_ASSERT( m_pri_pclTreeControl != NULL );
if ( ( _p_stInternalActor != NULL )
&& ( _p_stInternalActor->pclRoot != NULL )
)
{
// BEGIN ROMTEAM Cristi Petrescu 98-06-
m_fn_pclGetDocument()->m_pub_bIsDeletingTree = TRUE;
m_pri_pclTreeControl->DeleteAllItems();
m_fn_pclGetDocument()->m_pub_bIsDeletingTree = FALSE;
// END ROMTEAM Cristi Petrescu 98-06-
m_pri_ulCurrentNode = 0;
m_pri_pclTreeControl -> m_pclSelectedBehaviourNode = NULL;
m_pri_fn_vFillOneLevelOfTree(_p_stInternalActor->pclRoot, TVI_ROOT);
// BEGIN ROMTEAM Cristi Petrescu 98-08-
if (_p_stInternalActor->pclRoot->m_pub_fn_ptdGetListOfChildNodes()->GetCount())
{
// Find last loop
IAD_EditorTreeNode * pclLastEngineLoopNode = _p_stInternalActor -> pclRoot -> m_pub_fn_ptdGetListOfChildNodes () -> GetTail ();
if (pclLastEngineLoopNode)
{
HTREEITEM hTree = pclLastEngineLoopNode -> m_pub_fn_hGetTreeItem ();
if (hTree)
{
// Selects it -> this will build the subtree
m_pri_pclTreeControl -> SelectItem (hTree);
// Open it one level
m_pri_pclTreeControl -> Expand (hTree, TVE_EXPAND);
}
}
}
// END ROMTEAM Cristi Petrescu 98-08-
}
}
//***************************************************************************
// BEGIN ROMTEAM Cristi Petrescu 98-06-
void IAD_ResultView::m_pri_fn_vFillOneLevelOfTree(IAD_EditorTreeNode *_pclParentNode, HTREEITEM _hTreeParentItem, BOOL bSkipChangeComport /* == FALSE*/)
// END ROMTEAM Cristi Petrescu 98-06-
{
IAD_EditorTreeNode *_pclCurrentNode;
HTREEITEM hTreeCurrentItem;
unsigned char ucPercentage;
CString csProgressionString;
POSITION pos = _pclParentNode->m_pub_fn_ptdGetListOfChildNodes()->GetHeadPosition();
while ( pos != NULL )
{
_pclCurrentNode = _pclParentNode->m_pub_fn_ptdGetListOfChildNodes()->GetNext(pos);
//BEGIN ROMTEAM Cristi Petrescu 98-05-
//Adds in Tree, if needed
if (!((_pclCurrentNode -> m_pub_fn_csGetNodeType () == "R:" && m_bViewReflex == FALSE) ||
(_pclCurrentNode -> m_pub_fn_csGetNodeType () == "I:" && m_bViewAI == FALSE)) &&
!(bSkipChangeComport && _pclCurrentNode -> m_pub_fn_csGetNodeType () == "Changed Behaviour"))
{
//END ROMTEAM Cristi Petrescu 98-05-
hTreeCurrentItem = m_pri_pclTreeControl->InsertItem(_pclCurrentNode->m_pub_fn_csGetCompleteString(), _hTreeParentItem);
m_pri_pclTreeControl->SetItemData(hTreeCurrentItem, DWORD(_pclCurrentNode));
_pclCurrentNode->m_pub_fn_vSetTreeItem(hTreeCurrentItem);
//Displays infos
m_pri_ulCurrentNode ++;
ucPercentage = (unsigned char)((m_pri_ulCurrentNode * 100) / m_pri_ulTotalNumberOfNodes );
csProgressionString.Format("Filling Tree : node %ld on %ld", m_pri_ulCurrentNode, m_pri_ulTotalNumberOfNodes);
m_pub_fn_vSetStatusText(csProgressionString, ucPercentage);
//Calls recursively to build childs level
m_pri_fn_vFillOneLevelOfTree(_pclCurrentNode, hTreeCurrentItem);
//BEGIN ROMTEAM Cristi Petrescu 98-05-
}
//END ROMTEAM Cristi Petrescu 98-05-
}
}
//***************************************************************************
long IAD_ResultView::m_pri_fn_lLookInChildsToExpand(HTREEITEM _hParentItem,
long _lCurrentLevel)
{
long lCurrentLevel = _lCurrentLevel + 1;
HTREEITEM hCurrentChildItem = m_pri_pclTreeControl->GetNextItem(_hParentItem, TVGN_CHILD);
while ( hCurrentChildItem != NULL )
{
//Tries to expand childs of this root Item, at the right level
m_pri_pclTreeControl->Expand(hCurrentChildItem, (lCurrentLevel < m_lLevelToExpand) ? TVE_EXPAND : TVE_COLLAPSE);
m_pri_fn_lLookInChildsToExpand(hCurrentChildItem, lCurrentLevel);
hCurrentChildItem = m_pri_pclTreeControl->GetNextItem(hCurrentChildItem, TVGN_NEXT);
}
return -1;
}
/////////////////////////////////////////////////////////////////////////////
// IAD_ResultView diagnostics
//***************************************************************************
//***************************************************************************
//***************************************************************************
#ifdef _DEBUG
void IAD_ResultView::AssertValid() const
{
CFormView::AssertValid();
}
void IAD_ResultView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
// BEGIN ROMTEAM Cristi Petrescu 98-08-
/*
void IAD_ResultView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch (nChar)
{
case VK_F10:
OnButtonNextLine ();
break;
default:
break;
}
CFormView::OnKeyDown(nChar, nRepCnt, nFlags);
}
*/
/*
BOOL IAD_ResultView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NMHDR * pNMHDR = (NMHDR *) lParam;
TV_KEYDOWN * pTV_KEYDOWN;
switch (pNMHDR -> code)
{
case TVN_KEYDOWN: // for tree
case TCN_KEYDOWN: // for tabs
//case HDN_KEYDOWN: // for header (?)
//case TTN_KEYDOWN: // for tool tip
case LVN_KEYDOWN: // for list
pTV_KEYDOWN = (TV_KEYDOWN *) lParam;
switch (pTV_KEYDOWN -> wVKey)
{
case VK_F10:
OnButtonNextLine ();
return TRUE;
default:
break;
}
break;
default:
break;
}
return CFormView::OnNotify(wParam, lParam, pResult);
}
void IAD_ResultView::OnAccNextLine()
{
OnButtonNextLine ();
}
*/
// END ROMTEAM Cristi Petrescu 98-08-
#endif //_DEBUG