Initial commit.

This commit is contained in:
Jim Gray
2013-04-04 14:32:05 -07:00
parent ba5c81da32
commit d71d53e8ec
2180 changed files with 1393544 additions and 1 deletions

View File

@@ -0,0 +1,521 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "commtest.h"
#include "../tools/modview/wintalk.h"
#include "commtestDoc.h"
#include "commtestview.h"
#include <assert.h>
#include "bits.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
ON_COMMAND(ID_EDIT_CUT, OnEditCut)
ON_COMMAND(ID_ERRORBOX_OFF, OnErrorboxOff)
ON_COMMAND(ID_ERRORBOX_ON, OnErrorboxOn)
ON_COMMAND(ID_EDIT_M4, OnEditM4)
ON_COMMAND(ID_STARTANIM, OnStartanim)
ON_COMMAND(ID_STARTANIMWRAP, OnStartanimwrap)
ON_COMMAND(ID_STOPANIM, OnStopanim)
ON_COMMAND(ID_LOCK_SEQUENCES, OnLockSequences)
ON_COMMAND(ID_UNLOCKALLSEQS, OnUnlockallseqs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
CMainFrame* gCMainFrame = NULL;
HWND g_hWnd;
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
g_hWnd = m_hWnd;
gCMainFrame = this; // eeeuuwww!!!!!
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
char *va(char *format, ...);
void R_OurTree_AddRemoteItemToThisParent(TreeItemData_t TreeItemData, HTREEITEM hTreeItem_Parent, HTREEITEM hTreeItem_Remote )
{
LPCSTR psAnswer;
// get remote item text...
//
if (!WinTalk_IssueCommand(va("modeltree_getitemtextpure %d",hTreeItem_Remote),NULL,0,&psAnswer))
{
// should never happen...
//
assert(0);
psAnswer = "Error!";
}
// generate new tree item...
//
HTREEITEM hTreeItem_This = gpCommTestView->GetTreeCtrl().InsertItem ( psAnswer, hTreeItem_Parent);
gpCommTestView->GetTreeCtrl().SetItemData( hTreeItem_This, TreeItemData.uiData);
// check remote version of this for children...
//
if (WinTalk_IssueCommand(va("modeltree_getchilditem %d",hTreeItem_Remote),NULL,0,&psAnswer))
{
HTREEITEM hTreeItemRemote_Child = (HTREEITEM) atoi(psAnswer);
if (hTreeItemRemote_Child)
{
R_OurTree_AddRemoteItemToThisParent( TreeItemData, hTreeItem_This, hTreeItemRemote_Child);
}
}
// check remote version of this for sibling...
//
if (WinTalk_IssueCommand(va("modeltree_getnextsiblingitem %d",hTreeItem_Remote),NULL,0,&psAnswer))
{
HTREEITEM hTreeItemRemote_Sibling = (HTREEITEM) atoi(psAnswer);
if (hTreeItemRemote_Sibling)
{
R_OurTree_AddRemoteItemToThisParent( TreeItemData, hTreeItem_Parent, hTreeItemRemote_Sibling);
}
}
}
//
void ExpandTreeItem( HTREEITEM hTreeItem )
{
gpCommTestView->GetTreeCtrl().Expand( hTreeItem, TVE_EXPAND );
}
void R_ApplyToTreeItem( void (*pFunction) ( HTREEITEM hTreeItem ), HTREEITEM hTreeItem )
{
if (hTreeItem)
{
// process item...
//
pFunction(hTreeItem);
// recurse child...
//
R_ApplyToTreeItem( pFunction, gpCommTestView->GetTreeCtrl().GetChildItem( hTreeItem ) );
// recurse sibling...
//
R_ApplyToTreeItem( pFunction, gpCommTestView->GetTreeCtrl().GetNextSiblingItem( hTreeItem ) );
}
}
bool R_IsDescendantOf(HTREEITEM hTreeItem_This, HTREEITEM hTreeItem_Ancestor)
{
if (hTreeItem_This == hTreeItem_Ancestor)
return true;
HTREEITEM hTreeItem_Parent = gpCommTestView->GetTreeCtrl().GetParentItem(hTreeItem_This);
if (hTreeItem_Parent)
{
return R_IsDescendantOf(hTreeItem_Parent, hTreeItem_Ancestor);
}
return false;
}
// made global so they can be accessed from another module...
//
HTREEITEM ghTreeItem_ModelName = NULL;
HTREEITEM ghTreeItem_Surfaces= NULL;
HTREEITEM ghTreeItem_Bones = NULL;
ModelHandle_t ghLastLoadedModel = NULL;
ModelHandle_t ghPrimaryModel = NULL;
int giPrimaryModel_NumSequences=0;
void OurTree_Generate(LPCSTR psModelName, ModelHandle_t hModel, HTREEITEM hTreeItemParent = TVI_ROOT);
void OurTree_Generate(LPCSTR psModelName, ModelHandle_t hModel, HTREEITEM hTreeItemParent)
{
ghLastLoadedModel = hModel;
if (hTreeItemParent == TVI_ROOT) // loading primary model?
gpCommTestView->GetTreeCtrl().DeleteAllItems();
TreeItemData_t TreeItemData={0};
TreeItemData.iModelHandle = hModel;
TreeItemData.iItemType = TREEITEMTYPE_MODELNAME;
ghTreeItem_ModelName = gpCommTestView->GetTreeCtrl().InsertItem(psModelName, hTreeItemParent);
gpCommTestView->GetTreeCtrl().SetItemData(ghTreeItem_ModelName,TreeItemData.uiData);
TreeItemData.iItemType = TREEITEMTYPE_SURFACEHEADER;
ghTreeItem_Surfaces = gpCommTestView->GetTreeCtrl().InsertItem("Surfaces", ghTreeItem_ModelName);
gpCommTestView->GetTreeCtrl().SetItemData(ghTreeItem_Surfaces, TreeItemData.uiData);
TreeItemData.iItemType = TREEITEMTYPE_BONEHEADER;
ghTreeItem_Bones = gpCommTestView->GetTreeCtrl().InsertItem("Bones", ghTreeItem_ModelName);
gpCommTestView->GetTreeCtrl().SetItemData(ghTreeItem_Bones, TreeItemData.uiData);
TreeItemData.iItemType = TREEITEMTYPE_BONEALIASHEADER;
HTREEITEM hTreeItem_Aliases=gpCommTestView->GetTreeCtrl().InsertItem("Bone Aliases",ghTreeItem_ModelName);
gpCommTestView->GetTreeCtrl().SetItemData(hTreeItem_Aliases, TreeItemData.uiData);
// ok, now we need to remote-ask ModView for the HTREEITEM values for its Bone and Surface items...
//
LPCSTR psAnswer = NULL;
// if (WinTalk_IssueCommand(va("modeltree_getrootsurface %s",va("%d",hModel)),NULL,0,&psAnswer))
if (WinTalk_IssueCommand(va("modeltree_getrootsurface %d",hModel),NULL,0,&psAnswer))
{
HTREEITEM hTreeItemRemote_RootSurface = (HTREEITEM) atoi(psAnswer);
// if (WinTalk_IssueCommand(va("modeltree_getrootbone %s",va("%d",hModel)),NULL,0,&psAnswer))
if (WinTalk_IssueCommand(va("modeltree_getrootbone %d",hModel),NULL,0,&psAnswer))
{
HTREEITEM hTreeItemRemote_RootBone = (HTREEITEM) atoi(psAnswer);
TreeItemData.iItemType = TREEITEMTYPE_GLM_SURFACE;
R_OurTree_AddRemoteItemToThisParent(TreeItemData, ghTreeItem_Surfaces, hTreeItemRemote_RootSurface );
TreeItemData.iItemType = TREEITEMTYPE_GLM_BONE;
R_OurTree_AddRemoteItemToThisParent(TreeItemData, ghTreeItem_Bones, hTreeItemRemote_RootBone );
// add bone aliases...
if (WinTalk_IssueCommand(va("model_getnumbonealiases %d",hModel),NULL,0,&psAnswer))
{
int iNumBoneAliases = atoi(psAnswer);
for (int iBoneAlias = 0; iBoneAlias < iNumBoneAliases; iBoneAlias++)
{
if (WinTalk_IssueCommand(va("model_getbonealias %d %d",hModel,iBoneAlias),NULL,0,&psAnswer))
{
CString strRealName(psAnswer);
int iLoc = strRealName.Find(" ",0);
if (iLoc!=-1)
{
CString strAliasName(strRealName.Mid(iLoc+1));
strRealName = strRealName.Left(iLoc); // I don't actually use this in this app, but FYI.
OutputDebugString(va("alias %d/%d: real = '%s', alias = '%s'\n",iBoneAlias,iNumBoneAliases,(LPCSTR)strRealName,(LPCSTR)strAliasName));
TreeItemData.iItemType = TREEITEMTYPE_GLM_BONEALIAS;
HTREEITEM hTreeItemTemp = gpCommTestView->GetTreeCtrl().InsertItem(strAliasName, hTreeItem_Aliases);
gpCommTestView->GetTreeCtrl().SetItemData( hTreeItemTemp, TreeItemData.uiData);
}
else
{
assert(0);
}
}
else
{
assert(0);
}
}
}
else
{
assert(0);
}
// query sequence info, and add to tree if present...
//
if (WinTalk_IssueCommand(va("model_getnumsequences %s",va("%d",hModel)),NULL,0,&psAnswer))
{
int iNumSequences = atoi(psAnswer);
if (hModel == ghPrimaryModel)
{
giPrimaryModel_NumSequences = iNumSequences;
}
if (iNumSequences)
{
TreeItemData.iItemType = TREEITEMTYPE_SEQUENCEHEADER;
HTREEITEM hTreeItem_Sequences = gpCommTestView->GetTreeCtrl().InsertItem("Sequences",ghTreeItem_ModelName);
gpCommTestView->GetTreeCtrl().SetItemData(hTreeItem_Sequences, TreeItemData.uiData);
for (int iSeq=0; iSeq<iNumSequences; iSeq++)
{
if (WinTalk_IssueCommand(va("model_getsequence %s %d",va("%d",hModel),iSeq),NULL,0,&psAnswer))
{
TreeItemData.iItemType = TREEITEMTYPE_SEQUENCE;
TreeItemData.iItemNumber= iSeq;
HTREEITEM hTreeItem_Sequence = gpCommTestView->GetTreeCtrl().InsertItem (psAnswer, hTreeItem_Sequences);
gpCommTestView->GetTreeCtrl().SetItemData(hTreeItem_Sequence, TreeItemData.uiData);
}
else
{
assert(0);
}
}
TreeItemData.iItemNumber = 0;
}
// add BoltOns tree item header...
//
TreeItemData.iItemType = TREEITEMTYPE_BOLTONSHEADER;
HTREEITEM hTreeItemBolts= gpCommTestView->GetTreeCtrl().InsertItem("BoltOns", ghTreeItem_ModelName);
gpCommTestView->GetTreeCtrl().SetItemData(hTreeItemBolts, TreeItemData.uiData);
}
else
{
assert(0);
}
}
else
{
assert(0);
}
}
else
{
assert(0);
}
R_ApplyToTreeItem( ExpandTreeItem, gpCommTestView->GetTreeCtrl().GetRootItem() );
gpCommTestView->GetTreeCtrl().SelectSetFirstVisible(gpCommTestView->GetTreeCtrl().GetRootItem());
}
// returns actual filename only, no path
//
char *Filename_WithoutPath(LPCSTR psFilename)
{
static char sString[MAX_PATH];
/*
LPCSTR p = strrchr(psFilename,'\\');
if (!p++)
{
p = strrchr(psFilename,'/');
if (!p++)
p=psFilename;
}
strcpy(sString,p);
*/
LPCSTR psCopyPos = psFilename;
while (*psFilename)
{
if (*psFilename == '/' || *psFilename == '\\')
psCopyPos = psFilename+1;
psFilename++;
}
strcpy(sString,psCopyPos);
return sString;
}
bool gbInhibit = false;
void CMainFrame::LoadModel(LPCSTR psFullPathedFileName)
{
gbInhibit = true;
LPCSTR psAnswer = NULL;
if (WinTalk_IssueCommand(va("model_loadprimary %s",psFullPathedFileName),NULL,0,&psAnswer))
{
ModelHandle_t hModel = (ModelHandle_t) atoi(psAnswer);
ghPrimaryModel = hModel; // do this BEFORE OurTree_Generate()
OurTree_Generate(Filename_WithoutPath(psFullPathedFileName),hModel);
}
else
{
ghPrimaryModel = NULL; // do this BEFORE OurTree_Generate()
gpCommTestView->GetTreeCtrl().DeleteAllItems();
}
gbInhibit = false;
}
extern HTREEITEM R_ModelTree_FindItemWithThisData(HTREEITEM hTreeItem, UINT32 uiData2Match);
void CMainFrame::BoltModel(ModelHandle_t hModel, LPCSTR psBoltName, LPCSTR psFullPathedName)
{
LPCSTR psAnswer = NULL;
if (WinTalk_IssueCommand(va("model_loadbolton %d %s %s",hModel,psBoltName,psFullPathedName),NULL,0,&psAnswer))
{
ModelHandle_t hModel_BoltOn = (ModelHandle_t) atoi(psAnswer);
TreeItemData_t TreeItemData = {0};
TreeItemData.iModelHandle = hModel;
TreeItemData.iItemType = TREEITEMTYPE_BOLTONSHEADER;
HTREEITEM hTreeItem_BoltOns = R_ModelTree_FindItemWithThisData(NULL, TreeItemData.uiData);
OurTree_Generate(Filename_WithoutPath(psFullPathedName),hModel_BoltOn,hTreeItem_BoltOns);
}
}
void CMainFrame::OnEditCopy()
{
LoadModel("S:/base/models/test/conetree4/conetree4.glm");
}
void CMainFrame::OnEditPaste()
{
LoadModel("S:/base/models/test/jake/jake.glm");
}
void CMainFrame::OnEditCut()
{
LoadModel("S:/base/models/test/baddir/badname.glm");
}
void CMainFrame::OnEditM4()
{
LoadModel("S:/base/models/test/m4/m4.glm");
}
void CMainFrame::OnErrorboxOff()
{
WinTalk_IssueCommand("errorbox_disable");
}
void CMainFrame::OnErrorboxOn()
{
WinTalk_IssueCommand("errorbox_enable");
}
void CMainFrame::OnStartanim()
{
WinTalk_IssueCommand("startanim");
}
void CMainFrame::OnStartanimwrap()
{
WinTalk_IssueCommand("startanimwrap");
}
void CMainFrame::OnStopanim()
{
WinTalk_IssueCommand("stopanim");
}
void CMainFrame::OnLockSequences()
{
if (ghPrimaryModel && giPrimaryModel_NumSequences)
{
static int iLockSeq = -1;
if (++iLockSeq >= giPrimaryModel_NumSequences)
{
iLockSeq = 0;
}
WinTalk_IssueCommand(va("model_locksequence %d, %d", ghPrimaryModel, iLockSeq));
}
}
void CMainFrame::OnUnlockallseqs()
{
if (ghPrimaryModel)
{
WinTalk_IssueCommand(va("model_unlocksequences %d",ghPrimaryModel));
}
}

View File

@@ -0,0 +1,72 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#include "bits.h"
#if !defined(AFX_MAINFRM_H__61504888_AF87_11D4_8A97_00500424438B__INCLUDED_)
#define AFX_MAINFRM_H__61504888_AF87_11D4_8A97_00500424438B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
void LoadModel(LPCSTR psFullPathedFileName);
void BoltModel(ModelHandle_t hModel, LPCSTR psBoltName, LPCSTR psFullPathedName);
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnEditCopy();
afx_msg void OnEditPaste();
afx_msg void OnEditCut();
afx_msg void OnErrorboxOff();
afx_msg void OnErrorboxOn();
afx_msg void OnEditM4();
afx_msg void OnStartanim();
afx_msg void OnStartanimwrap();
afx_msg void OnStopanim();
afx_msg void OnLockSequences();
afx_msg void OnUnlockallseqs();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__61504888_AF87_11D4_8A97_00500424438B__INCLUDED_)

View File

@@ -0,0 +1,105 @@
========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : commtest
========================================================================
AppWizard has created this commtest application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your commtest application.
commtest.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
commtest.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CCommtestApp application class.
commtest.cpp
This is the main application source file that contains the application
class CCommtestApp.
commtest.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
commtest.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
res\commtest.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file commtest.rc.
res\commtest.rc2
This file contains resources that are not edited by Microsoft
Visual C++. You should place all resources not editable by
the resource editor in this file.
/////////////////////////////////////////////////////////////////////////////
For the main frame window:
MainFrm.h, MainFrm.cpp
These files contain the frame class CMainFrame, which is derived from
CFrameWnd and controls all SDI frame features.
res\Toolbar.bmp
This bitmap file is used to create tiled images for the toolbar.
The initial toolbar and status bar are constructed in the CMainFrame
class. Edit this toolbar bitmap using the resource editor, and
update the IDR_MAINFRAME TOOLBAR array in commtest.rc to add
toolbar buttons.
/////////////////////////////////////////////////////////////////////////////
AppWizard creates one document type and one view:
commtestDoc.h, commtestDoc.cpp - the document
These files contain your CCommtestDoc class. Edit these files to
add your special document data and to implement file saving and loading
(via CCommtestDoc::Serialize).
commtestView.h, commtestView.cpp - the view of the document
These files contain your CCommtestView class.
CCommtestView objects are used to view CCommtestDoc objects.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named commtest.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC42XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFC42DEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// commtest.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,27 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__61504886_AF87_11D4_8A97_00500424438B__INCLUDED_)
#define AFX_STDAFX_H__61504886_AF87_11D4_8A97_00500424438B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#include <afxcview.h>
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__61504886_AF87_11D4_8A97_00500424438B__INCLUDED_)

View File

@@ -0,0 +1,61 @@
// Filename:- bits.h
//
// some leftover stuff to get this compiling,
// mainly from model.h in modview but I couldn't include that directly here
// NOTE:!!!! It's ok for this to be ot of sync with the version in modview, there's no communication of the
// actual values. This is important to realise, even if this is only a test app.
#ifndef BITS_H
#define BITS_H
typedef int ModelHandle_t;
typedef struct
{
union
{
struct
{
unsigned int iItemType : 8; // allows 256 item types (see #defines below)
unsigned int iModelHandle : 8; // allows 256 models
unsigned int iItemNumber : 16; // allows 65536 surfaces, bones, sequences etc
};
//
UINT32 uiData;
};
} TreeItemData_t;
// max 256 of these...
//
typedef enum
{
TREEITEMTYPE_NULL=0, // nothing, ie usually a reasonable default for clicking on emptry tree space
TREEITEMTYPE_MODELNAME, // "modelname"
TREEITEMTYPE_SURFACEHEADER, // "surfaces"
TREEITEMTYPE_BONEHEADER, // "bones"
TREEITEMTYPE_BONEALIASHEADER, // "bone aliases"
TREEITEMTYPE_SEQUENCEHEADER, // "sequences"
TREEITEMTYPE_BOLTONSHEADER, // "BoltOns"
//
// Ones beyond here should have updated code in ModelTree_GetItemText() to handle pure enquiries if nec.
//
TREEITEMTYPE_GLM_SURFACE, // a surface (index in bottom bits, currently allows 65535 surfaces)
TREEITEMTYPE_GLM_BONE, // a bone (index in bottom bits, currently allows 65535 bones)
TREEITEMTYPE_GLM_BONEALIAS, // a bone alias (index in bottom bits, currently allows 65535 aliases)
TREEITEMTYPE_SEQUENCE, // a sequence (index in bottom bits, currently allows 65535 bones)
} TreeTypes_e;
#define GetYesNo(psQuery) (!!(AfxMessageBox(psQuery, MB_YESNO|MB_ICONWARNING|MB_TASKMODAL)==IDYES))
#endif // #ifndef BITS_H
///////////////////////// eof /////////////////////

View File

@@ -0,0 +1,172 @@
// commtest.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "commtest.h"
#include "../tools/modview/commarea.h"
#include "../tools/modview/wintalk.h"
#include "MainFrm.h"
#include "commtestDoc.h"
#include "commtestView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCommtestApp
BEGIN_MESSAGE_MAP(CCommtestApp, CWinApp)
//{{AFX_MSG_MAP(CCommtestApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCommtestApp construction
CCommtestApp::CCommtestApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCommtestApp object
CCommtestApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CCommtestApp initialization
bool gbCommInitialised = false;
BOOL CCommtestApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CCommtestDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CCommtestView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
CommArea_ClientInitOnceOnly();
gbCommInitialised = true;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CCommtestApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CCommtestApp message handlers
int CCommtestApp::ExitInstance()
{
CommArea_ShutDown();
return CWinApp::ExitInstance();
}
BOOL CCommtestApp::OnIdle(LONG lCount)
{
WinTalk_HandleMessages();
return CWinApp::OnIdle(lCount);
}

View File

@@ -0,0 +1,190 @@
# Microsoft Developer Studio Project File - Name="commtest" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=commtest - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "commtest.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "commtest.mak" CFG="commtest - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "commtest - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "commtest - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/Tools/ModView/commtest", LGECAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "commtest - Win32 Release"
# PROP BASE Use_MFC 5
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 5
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "commtest - Win32 Debug"
# PROP BASE Use_MFC 5
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 5
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "commtest - Win32 Release"
# Name "commtest - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\Tools\ModView\CommArea.cpp
# End Source File
# Begin Source File
SOURCE=..\Tools\ModView\CommArea.h
# End Source File
# Begin Source File
SOURCE=.\commtest.cpp
# End Source File
# Begin Source File
SOURCE=.\commtest.rc
# End Source File
# Begin Source File
SOURCE=.\commtestDoc.cpp
# End Source File
# Begin Source File
SOURCE=.\commtestView.cpp
# End Source File
# Begin Source File
SOURCE=.\MainFrm.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# Begin Source File
SOURCE=.\wintalk.cpp
# End Source File
# Begin Source File
SOURCE=..\Tools\ModView\wintalk.h
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\bits.h
# End Source File
# Begin Source File
SOURCE=.\commtest.h
# End Source File
# Begin Source File
SOURCE=.\commtestDoc.h
# End Source File
# Begin Source File
SOURCE=.\commtestView.h
# End Source File
# Begin Source File
SOURCE=.\MainFrm.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\commtest.ico
# End Source File
# Begin Source File
SOURCE=.\res\commtest.rc2
# End Source File
# Begin Source File
SOURCE=.\res\commtestDoc.ico
# End Source File
# Begin Source File
SOURCE=.\res\Toolbar.bmp
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,51 @@
// commtest.h : main header file for the COMMTEST application
//
#if !defined(AFX_COMMTEST_H__61504884_AF87_11D4_8A97_00500424438B__INCLUDED_)
#define AFX_COMMTEST_H__61504884_AF87_11D4_8A97_00500424438B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CCommtestApp:
// See commtest.cpp for the implementation of this class
//
class CCommtestApp : public CWinApp
{
public:
CCommtestApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCommtestApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
virtual BOOL OnIdle(LONG lCount);
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CCommtestApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COMMTEST_H__61504884_AF87_11D4_8A97_00500424438B__INCLUDED_)

View File

@@ -0,0 +1,404 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#include ""res\\commtest.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#include ""afxprint.rc"" // printing/print preview resources\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\commtest.ico"
IDR_COMMTETYPE ICON DISCARDABLE "res\\commtestDoc.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Toolbar
//
IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15
BEGIN
BUTTON ID_FILE_NEW
BUTTON ID_FILE_OPEN
BUTTON ID_FILE_SAVE
SEPARATOR
BUTTON ID_EDIT_CUT
BUTTON ID_EDIT_COPY
BUTTON ID_EDIT_PASTE
SEPARATOR
BUTTON ID_FILE_PRINT
SEPARATOR
BUTTON ID_APP_ABOUT
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
MENUITEM "Save &As...", ID_MODEL_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT
MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW
MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP
MENUITEM SEPARATOR
MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_APP_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO
MENUITEM SEPARATOR
MENUITEM "Load model garbagename", ID_EDIT_CUT
MENUITEM "Load model conetree4", ID_EDIT_COPY
MENUITEM "Load model jake", ID_EDIT_PASTE
MENUITEM "Load Model M4", ID_EDIT_M4
MENUITEM "ErrorBoxes OFF", ID_ERRORBOX_OFF
MENUITEM "ErrorBoxes ON", ID_ERRORBOX_ON
MENUITEM SEPARATOR
MENUITEM "Start Animation", ID_STARTANIM
MENUITEM "Start Animation (with wrap)", ID_STARTANIMWRAP
MENUITEM "Stop Animation", ID_STOPANIM
MENUITEM SEPARATOR
MENUITEM "Lock Sequence (primary model), + auto-inc seq #",
ID_LOCK_SEQUENCES
MENUITEM "Unlock All Sequences (primary model)", ID_UNLOCKALLSEQS
END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
END
POPUP "&Help"
BEGIN
MENUITEM "&About commtest...", ID_APP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"N", ID_FILE_NEW, VIRTKEY, CONTROL
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
"S", ID_FILE_SAVE, VIRTKEY, CONTROL
"P", ID_FILE_PRINT, VIRTKEY, CONTROL
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT
VK_F6, ID_NEXT_PANE, VIRTKEY
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About commtest"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "commtest Version 1.0",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) 2000",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "commtest MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "commtest\0"
VALUE "LegalCopyright", "Copyright (C) 2000\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "commtest.EXE\0"
VALUE "ProductName", "commtest Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 228
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "commtest\n\nCommte\n\n\nCommtest.Document\nCommte Document"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "commtest"
AFX_IDS_IDLEMESSAGE "Ready"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_INDICATOR_EXT "EXT"
ID_INDICATOR_CAPS "CAP"
ID_INDICATOR_NUM "NUM"
ID_INDICATOR_SCRL "SCRL"
ID_INDICATOR_OVR "OVR"
ID_INDICATOR_REC "REC"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_NEW "Create a new document\nNew"
ID_FILE_OPEN "Open an existing document\nOpen"
ID_FILE_CLOSE "Close the active document\nClose"
ID_FILE_SAVE "Save the active document\nSave"
ID_MODEL_SAVE_AS "Save the active document with a new name\nSave As"
ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup"
ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup"
ID_FILE_PRINT "Print the active document\nPrint"
ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_MRU_FILE1 "Open this document"
ID_FILE_MRU_FILE2 "Open this document"
ID_FILE_MRU_FILE3 "Open this document"
ID_FILE_MRU_FILE4 "Open this document"
ID_FILE_MRU_FILE5 "Open this document"
ID_FILE_MRU_FILE6 "Open this document"
ID_FILE_MRU_FILE7 "Open this document"
ID_FILE_MRU_FILE8 "Open this document"
ID_FILE_MRU_FILE9 "Open this document"
ID_FILE_MRU_FILE10 "Open this document"
ID_FILE_MRU_FILE11 "Open this document"
ID_FILE_MRU_FILE12 "Open this document"
ID_FILE_MRU_FILE13 "Open this document"
ID_FILE_MRU_FILE14 "Open this document"
ID_FILE_MRU_FILE15 "Open this document"
ID_FILE_MRU_FILE16 "Open this document"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_CLEAR "Erase the selection\nErase"
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
ID_EDIT_FIND "Find the specified text\nFind"
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
ID_EDIT_UNDO "Undo the last action\nUndo"
ID_EDIT_REDO "Redo the previously undone action\nRedo"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change the window size"
AFX_IDS_SCMOVE "Change the window position"
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCRESTORE "Restore the window to normal size"
AFX_IDS_SCTASKLIST "Activate Task List"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\commtest.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#include "afxprint.rc" // printing/print preview resources
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,84 @@
// commtestDoc.cpp : implementation of the CCommtestDoc class
//
#include "stdafx.h"
#include "commtest.h"
#include "commtestDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCommtestDoc
IMPLEMENT_DYNCREATE(CCommtestDoc, CDocument)
BEGIN_MESSAGE_MAP(CCommtestDoc, CDocument)
//{{AFX_MSG_MAP(CCommtestDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCommtestDoc construction/destruction
CCommtestDoc::CCommtestDoc()
{
// TODO: add one-time construction code here
}
CCommtestDoc::~CCommtestDoc()
{
}
BOOL CCommtestDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CCommtestDoc serialization
void CCommtestDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CCommtestDoc diagnostics
#ifdef _DEBUG
void CCommtestDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CCommtestDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCommtestDoc commands

View File

@@ -0,0 +1,57 @@
// commtestDoc.h : interface of the CCommtestDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_COMMTESTDOC_H__6150488A_AF87_11D4_8A97_00500424438B__INCLUDED_)
#define AFX_COMMTESTDOC_H__6150488A_AF87_11D4_8A97_00500424438B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CCommtestDoc : public CDocument
{
protected: // create from serialization only
CCommtestDoc();
DECLARE_DYNCREATE(CCommtestDoc)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCommtestDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CCommtestDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CCommtestDoc)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COMMTESTDOC_H__6150488A_AF87_11D4_8A97_00500424438B__INCLUDED_)

View File

@@ -0,0 +1,471 @@
// commtestView.cpp : implementation of the CCommtestView class
//
#include "stdafx.h"
#include "commtest.h"
#include <assert.h>
#include "commtestDoc.h"
#include "commtestView.h"
#include "../tools/modview/wintalk.h"
#include "bits.h"
#include "mainfrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCommtestView
IMPLEMENT_DYNCREATE(CCommtestView, CTreeView)
BEGIN_MESSAGE_MAP(CCommtestView, CTreeView)
//{{AFX_MSG_MAP(CCommtestView)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_TIMER()
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CTreeView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CTreeView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CTreeView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCommtestView construction/destruction
CCommtestView* gpCommTestView = NULL;
CCommtestView::CCommtestView()
{
}
CCommtestView::~CCommtestView()
{
}
BOOL CCommtestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
if (!CTreeView::PreCreateWindow(cs))
{
return FALSE;
}
cs.style |= TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS/* | TVS_EDITLABELS*/;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CCommtestView drawing
/////////////////////////////////////////////////////////////////////////////
// CCommtestView printing
BOOL CCommtestView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCommtestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCommtestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCommtestView diagnostics
#ifdef _DEBUG
void CCommtestView::AssertValid() const
{
CTreeView::AssertValid();
}
void CCommtestView::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
CCommtestDoc* CCommtestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCommtestDoc)));
return (CCommtestDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCommtestView message handlers
enum eTimerHandles
{
th_DO_NOT_USE = 0, // system reserved for NULL timer
th_100FPS = 1,
};
int CCommtestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTreeView::OnCreate(lpCreateStruct) == -1)
return -1;
m_TimerHandle_Update100FPS = SetTimer( th_100FPS, // UINT nIDEvent,
200, // UINT nElapse, (in milliseconds)
NULL // void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD)
);
return 0;
}
BOOL CCommtestView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
m_TimerHandle_Update100FPS = 0;
BOOL b = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
gpCommTestView = this;
HTREEITEM h = GetTreeCtrl().InsertItem("test_root_item", NULL);
GetTreeCtrl().InsertItem("child", h);
return b;
}
void CCommtestView::OnDestroy()
{
if (m_TimerHandle_Update100FPS)
{
bool bOk = !!KillTimer(m_TimerHandle_Update100FPS); // NZ return if good
if (bOk)
{
m_TimerHandle_Update100FPS = NULL;
}
else
{
// ErrorBox("Error killing timer!"); // should never happen
}
}
CTreeView::OnDestroy();
}
void CCommtestView::OnTimer(UINT nIDEvent)
{
if (nIDEvent != th_100FPS)
{
CTreeView::OnTimer(nIDEvent);
return;
}
// WinTalk_HandleMessages();
}
//DEL void CCommtestView::OnDraw(CDC* pDC)
//DEL {
//DEL CCommtestDoc* pDoc = GetDocument();
//DEL ASSERT_VALID(pDoc);
//DEL // TODO: add draw code for native data here
//DEL }
extern char *va(char *format, ...);
extern bool gbCommInitialised;
extern bool R_IsDescendantOf(HTREEITEM hTreeItem_This, HTREEITEM hTreeItem_Ancestor);
extern bool gbInhibit;
// search tree for an item whose userdata matches what's been passed...
//
// hTreeItem = tree item to start from, pass NULL to start from root
//
HTREEITEM R_ModelTree_FindItemWithThisData(HTREEITEM hTreeItem, UINT32 uiData2Match)
{
if (!hTreeItem)
hTreeItem = gpCommTestView->GetTreeCtrl().GetRootItem();
if (hTreeItem)
{
CString str(gpCommTestView->GetTreeCtrl().GetItemText(hTreeItem));
OutputDebugString(va("Scanning item %X (%s)\n",hTreeItem,(LPCSTR)str));
if (str=="BoltOns")
{
int x=1;
}
// check this tree item...
//
TreeItemData_t TreeItemData;
TreeItemData.uiData = gpCommTestView->GetTreeCtrl().GetItemData(hTreeItem);
// match?...
//
if (TreeItemData.uiData == uiData2Match)
return hTreeItem;
// check child...
//
HTREEITEM hTreeItem_Child = gpCommTestView->GetTreeCtrl().GetChildItem(hTreeItem);
if (hTreeItem_Child)
{
HTREEITEM hTreeItemFound = R_ModelTree_FindItemWithThisData(hTreeItem_Child, uiData2Match);
if (hTreeItemFound)
return hTreeItemFound;
}
// process siblings...
//
HTREEITEM hTreeItem_Sibling = gpCommTestView->GetTreeCtrl().GetNextSiblingItem(hTreeItem);
if (hTreeItem_Sibling)
{
HTREEITEM hTreeItemFound = R_ModelTree_FindItemWithThisData(hTreeItem_Sibling, uiData2Match);
if (hTreeItemFound)
return hTreeItemFound;
}
// this treeitem isnt a match, and neither are its siblings or children, so...
//
return NULL;
}
// we must have called this when the treeview was uninitialised... (duh!)
//
ASSERT(0);
return NULL;
}
void CCommtestView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
if (gbCommInitialised && GetTreeCtrl().GetCount() > 3 /*?*/ && !gbInhibit)
{
HTREEITEM hTreeItem = GetTreeCtrl().GetSelectedItem();
CString Text = GetTreeCtrl().GetItemText(hTreeItem);
TreeItemData_t TreeItemData;
TreeItemData.uiData = GetTreeCtrl().GetItemData(hTreeItem);
LPCSTR psArg = Text;
if (Text == "Bones")
psArg = "#all";
if (Text == "Surfaces")
psArg = "#all";
// LPCSTR psAnswer;
bool bOk = false;
/* if (R_IsDescendantOf(hTreeItem, ghTreeItem_Surfaces))
{
WinTalk_IssueCommand( "model_highlightbone #none");
bOk = WinTalk_IssueCommand(va("model_highlightsurface %s",psArg),NULL,0,&psAnswer);
}
else
if (R_IsDescendantOf(hTreeItem, ghTreeItem_Bones))
{
WinTalk_IssueCommand( "model_highlightsurface #none");
bOk = WinTalk_IssueCommand(va("model_highlightbone %s",psArg),NULL,0,&psAnswer);
}
else
{
WinTalk_IssueCommand( "model_highlightbone #none");
WinTalk_IssueCommand( "model_highlightsurface #none");
}
*/
WinTalk_IssueCommand(va("model_highlightbone %d #none",TreeItemData.iModelHandle));
WinTalk_IssueCommand(va("model_highlightsurface %d #none",TreeItemData.iModelHandle));
switch (TreeItemData.iItemType)
{
case TREEITEMTYPE_SURFACEHEADER: // "surfaces"
{
bOk = WinTalk_IssueCommand(va("model_highlightsurface %d #all",TreeItemData.iModelHandle));
}
break;
case TREEITEMTYPE_BONEHEADER: // "bones"
{
bOk = WinTalk_IssueCommand(va("model_highlightbone %d #all",TreeItemData.iModelHandle));
}
break;
case TREEITEMTYPE_GLM_SURFACE: // a surface
{
bOk = WinTalk_IssueCommand(va("model_highlightsurface %d %s",TreeItemData.iModelHandle, psArg));
}
break;
case TREEITEMTYPE_BONEALIASHEADER: // alias header
{
bOk = WinTalk_IssueCommand(va("model_highlightbone %d #aliased",TreeItemData.iModelHandle));
}
break;
case TREEITEMTYPE_GLM_BONEALIAS: // a bone alias
case TREEITEMTYPE_GLM_BONE: // a bone
{
// WinTalk_IssueCommand(va("model_highlightsurface %d #none",TreeItemData.iModelHandle));
bOk = WinTalk_IssueCommand(va("model_highlightbone %d %s",TreeItemData.iModelHandle, psArg));
}
break;
}
if (bOk)
{
//
}
else
{
// assert(0);
}
}
*pResult = 0;
}
// "psInitialLoadName" param can be "" if not bothered, "psInitialDir" can be NULL to open to last browse-dir
//
// psFilter example: TEXT("Model files (*.glm)|*.glm|All Files(*.*)|*.*||") // LPCSTR psFilter
//
char *InputLoadFileName(LPCSTR psInitialLoadName, LPCSTR psCaption, LPCSTR psInitialDir, LPCSTR psFilter)
{
CFileStatus Filestatus;
CFile File;
static char name[MAX_PATH];
CFileDialog FileDlg(TRUE, NULL, NULL,
OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST,
//TEXT("Map Project Files (*.mpj)|*.lit|Other Map Files (*.smd/*.sc2)|*.sc2;*.smd|FastMap Files (*.fmf)|*.fmf|All Files(*.*)|*.*||"), //Map Object Files|*.sms||"),
psFilter, //Map Object Files|*.sms||"),
AfxGetMainWnd());
static CString strInitialDir;
if (psInitialDir)
strInitialDir = psInitialDir;
FileDlg.m_ofn.lpstrInitialDir = (LPCSTR) strInitialDir;
FileDlg.m_ofn.lpstrTitle=psCaption; // Load Editor Model";
strcpy(name,psInitialLoadName);
FileDlg.m_ofn.lpstrFile=name;
if (FileDlg.DoModal() == IDOK)
{
return name;
}
return NULL;
}
LPCSTR Model_GetSupportedTypesFilter(void)
{
return "Model files (*.glm)|*.glm|All Files(*.*)|*.*||";
}
void CCommtestView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
if (gbCommInitialised && GetTreeCtrl().GetCount() > 3 /*?*/ && !gbInhibit)
{
HTREEITEM hTreeItem = GetTreeCtrl().GetSelectedItem();
CString Text = GetTreeCtrl().GetItemText(hTreeItem);
TreeItemData_t TreeItemData;
TreeItemData.uiData = GetTreeCtrl().GetItemData(hTreeItem);
bool bOk = false;
/* if (R_IsDescendantOf(hTreeItem, ghTreeItem_Surfaces))
{
WinTalk_IssueCommand( "model_highlightbone #none");
bOk = WinTalk_IssueCommand(va("model_highlightsurface %s",psArg),NULL,0,&psAnswer);
}
else
if (R_IsDescendantOf(hTreeItem, ghTreeItem_Bones))
{
WinTalk_IssueCommand( "model_highlightsurface #none");
bOk = WinTalk_IssueCommand(va("model_highlightbone %s",psArg),NULL,0,&psAnswer);
}
else
{
WinTalk_IssueCommand( "model_highlightbone #none");
WinTalk_IssueCommand( "model_highlightsurface #none");
}
*/
switch (TreeItemData.iItemType)
{
case TREEITEMTYPE_MODELNAME:
{
// is this a bolted model or the root (find out by seeing if its parent is a "BoltOns" treeitem)...
//
HTREEITEM hTreeItemParent = GetTreeCtrl().GetParentItem(hTreeItem);
if (hTreeItemParent)
{
TreeItemData_t TreeItemData_Parent;
TreeItemData_Parent.uiData = GetTreeCtrl().GetItemData(hTreeItemParent);
if (TreeItemData_Parent.iItemType == TREEITEMTYPE_BOLTONSHEADER)
{
//if (GetYesNo("Unbolt/discard this model?"))
{
//<modelhandle of bolted thing to delete>
WinTalk_IssueCommand(va("model_deletebolton %d",TreeItemData.iModelHandle));
GetTreeCtrl().DeleteItem(hTreeItem);
}
}
}
}
break;
case TREEITEMTYPE_GLM_BONE: // a bone
{
extern CMainFrame* gCMainFrame;
if (gCMainFrame)
{
char *psFullPathedFilename = InputLoadFileName( "", // LPCSTR psInitialLoadName,
"Load Model", // LPCSTR psCaption,
"S:\\base\\models\\test\\conetree4", // LPCSTR psInitialDir,
Model_GetSupportedTypesFilter() // LPCSTR psFilter
);
if (psFullPathedFilename)
{
gCMainFrame->BoltModel(TreeItemData.iModelHandle, Text, psFullPathedFilename);
}
}
}
break;
}
if (bOk)
{
//
}
else
{
// assert(0);
}
}
*pResult = 0;
}

View File

@@ -0,0 +1,74 @@
// commtestView.h : interface of the CCommtestView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_COMMTESTVIEW_H__6150488C_AF87_11D4_8A97_00500424438B__INCLUDED_)
#define AFX_COMMTESTVIEW_H__6150488C_AF87_11D4_8A97_00500424438B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CCommtestView : public CTreeView
{
protected: // create from serialization only
CCommtestView();
DECLARE_DYNCREATE(CCommtestView)
// Attributes
public:
CCommtestDoc* GetDocument();
UINT m_TimerHandle_Update100FPS;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCommtestView)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CCommtestView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CCommtestView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDblclk(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in commtestView.cpp
inline CCommtestDoc* CCommtestView::GetDocument()
{ return (CCommtestDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
extern CCommtestView* gpCommTestView;
#endif // !defined(AFX_COMMTESTVIEW_H__6150488C_AF87_11D4_8A97_00500424438B__INCLUDED_)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,13 @@
//
// COMMTEST.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,27 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by commtest.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_COMMTETYPE 129
#define ID_ERRORBOX_OFF 32771
#define ID_ERRORBOX_ON 32772
#define ID_EDIT_M4 32773
#define ID_STARTANIM 32775
#define ID_STOPANIM 32776
#define ID_STARTANIMWRAP 32777
#define ID_LOCK_SEQUENCES 32778
#define ID_UNLOCKALLSEQS 32779
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32780
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,308 @@
// Filename:- wintalk.cpp
//
// a module containing code for talking to other windows apps via a shared memory space...
//
#include "stdafx.h"
#include <assert.h>
#include "commtestDoc.h"
#include "commtestview.h"
//#include <winbase.h>
#include "../tools/modview/CommArea.h"
//
#include "../tools/modview/wintalk.h"
#ifndef ZEROMEM
#define ZEROMEM(blah) memset(&blah,0,sizeof(blah))
#endif
void ErrorBox(const char *sString)
{
MessageBox( NULL, sString, "Error", MB_OK|MB_ICONERROR|MB_TASKMODAL );
}
void InfoBox(const char *sString)
{
MessageBox( NULL, sString, "Info", MB_OK|MB_ICONINFORMATION|MB_TASKMODAL );
}
void WarningBox(const char *sString)
{
MessageBox( NULL, sString, "Warning", MB_OK|MB_ICONWARNING|MB_TASKMODAL );
}
char *va(char *format, ...)
{
va_list argptr;
static char string[16][1024];
static index = 0;
index = (++index)&15;
va_start (argptr, format);
vsprintf (string[index], format,argptr);
va_end (argptr);
return string[index];
}
// this'll return a string of up to the first 4095 chars of a system error message...
//
LPCSTR SystemErrorString(DWORD dwError)
{
static char sString[4096];
LPVOID lpMsgBuf=0;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
ZEROMEM(sString);
strncpy(sString,(LPCSTR) lpMsgBuf,sizeof(sString)-1);
LocalFree( lpMsgBuf );
return sString;
}
//void SystemErrorBox(DWORD dwError)
extern HWND g_hWnd;
#define GetYesNo(psQuery) (!!(MessageBox(g_hWnd,psQuery,"Query",MB_YESNO|MB_ICONWARNING|MB_TASKMODAL)==IDYES))
//////////////////////////////////////////////////////////////////////////////
static LPCSTR FindWhitespace(LPCSTR psString)
{
while (*psString && !isspace(*psString)) psString++;
return psString;
}
static LPCSTR SkipWhitespace(LPCSTR psString)
{
while (isspace(*psString)) psString++;
return psString;
}
// every case here must either do CommArea_CommandAck(...) or CommArea_CommandError(...),
// failure to do this is amazingly bad!!!
//
static void HandleCommands(LPCSTR psString, byte *pbCommandData, int iCommandDataSize)
{
/*
#define IF_ARG(string) if (!strncmp(psArg,string,strlen(string)))
#define NEXT_ARG SkipWhitespace(FindWhitespace(psArg))
LPCSTR psArg = psString;
IF_ARG("model_loadprimary")
{
psArg = NEXT_ARG;
if (Document_ModelLoadPrimary( psArg ))
{
CommArea_CommandAck();
}
else
{
CommArea_CommandError(va("ModView: Failed command: \"model_loadprimary %s\"\"", psArg));
}
}
else
IF_ARG("modeltree_getrootsurface")
{
// for this command, just send back whatever the answer is without validating...
//
HTREEITEM hTreeItem = ModelTree_GetRootSurface(Model_GetPrimaryHandle());
CommArea_CommandAck(va("%d",hTreeItem));
}
else
IF_ARG("modeltree_getrootbone")
{
// for this command, just send back whatever the answer is without validating...
//
HTREEITEM hTreeItem = ModelTree_GetRootBone(Model_GetPrimaryHandle());
CommArea_CommandAck(va("%d",hTreeItem));
}
else
// this version MUST be the first of the two, or the shorter one will early-match even a long command
IF_ARG("modeltree_getitemtextpure") // "...pure" will skip stuff like "////" for disabled surfaces
{
psArg = NEXT_ARG;
HTREEITEM hTreeItem = (HTREEITEM) atoi(psArg);
LPCSTR psText = ModelTree_GetItemText(hTreeItem,true);
CommArea_CommandAck(psText);
}
else
IF_ARG("modeltree_getitemtext")
{
psArg = NEXT_ARG;
HTREEITEM hTreeItem = (HTREEITEM) atoi(psArg);
LPCSTR psText = ModelTree_GetItemText(hTreeItem);
CommArea_CommandAck(psText);
}
else
IF_ARG("modeltree_getchilditem")
{
psArg = NEXT_ARG;
HTREEITEM hTreeItem = (HTREEITEM) atoi(psArg);
hTreeItem = ModelTree_GetChildItem(hTreeItem);
CommArea_CommandAck(va("%d",hTreeItem));
}
else
IF_ARG("modeltree_getnextsiblingitem")
{
psArg = NEXT_ARG;
HTREEITEM hTreeItem = (HTREEITEM) atoi(psArg);
hTreeItem = ModelTree_GetNextSiblingItem(hTreeItem);
CommArea_CommandAck(va("%d",hTreeItem));
}
else
{
// unknown command...
//
CommArea_CommandError(va("ModView: Unknown command \"%s\"", psString));
}
*/
InfoBox(va("CommsTest: Command recieved: \"%s\"",psString));
if (GetYesNo("CommsTest: Report as error? ('NO' will report success)"))
{
CommArea_CommandError(va("CommsTest: Failed to complete task '%s'", psString));
}
else
{
CommArea_CommandAck();
}
}
static bool bDoNotEnterHandler = false; // Modal dialogue boxes can cause problems with re-entrance
void WinTalk_HandleMessages(void)
{
if (!bDoNotEnterHandler)
{
bDoNotEnterHandler = true;
if (!CommArea_IsIdle())
{
CWaitCursor wait;
byte *pbCommandData = NULL;
int iCommandDataSize;
LPCSTR psString;
if ((psString = CommArea_IsCommandWaiting( &pbCommandData, &iCommandDataSize )) != NULL)
{
HandleCommands(psString, pbCommandData, iCommandDataSize);
}
else
if ((psString = CommArea_IsErrorWaiting()) != NULL)
{
assert(0); // I don't think we should ever get here, but just in case...
ErrorBox(va("CommTest: Other program reported an error:\n\n\"%s\"",psString));
CommArea_CommandClear();
}
}
bDoNotEnterHandler = false;
}
}
// return is success / fail
//
bool WinTalk_IssueCommand( LPCSTR psCommand,
byte *pbData, // optional extra command data (current max = 64k)
int iDataSize, // sizeof above
LPCSTR *ppsResultPassback, // optional result passback if expecting an answer string
byte **ppbDataPassback, // optional data passback if expecting a data result
int *piDataSizePassback // optional size of above if you need it supplying
)
{
bool bError = false;
while (!CommArea_IsIdle())
{
WinTalk_HandleMessages();
}
bDoNotEnterHandler = true;
{
CommArea_IssueCommand(psCommand, pbData, iDataSize);
// wait until command is acknowledged or has failed... (you may want a sanity check timeout?)
//
CWaitCursor wait;
while (1)
{
LPCSTR psReply;
if ((psReply = CommArea_IsAckWaiting(ppbDataPassback,piDataSizePassback)) != NULL)
{
if ( ppsResultPassback)
*ppsResultPassback = psReply;
bError = false;
break;
}
if ((psReply = CommArea_IsErrorWaiting()) != NULL)
{
ErrorBox(va("Other program reported an error:\n\n\"%s\"",psReply));
bError = true;
break;
}
Sleep(0); // needed to avoid hogging all CPU time :-)
}
// you MUST do this...
//
CommArea_CommandClear();
/* {
gpCommTestView->GetTreeCtrl().DeleteAllItems();
gpCommTestView->GetTreeCtrl().InsertItem("hello");
}
*/
}
bDoNotEnterHandler = false;
return !bError;
}
////////////////////// eof ////////////////