29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/rc/DeclEditor_resource.h"
33 #include "../../sys/win32/rc/ScriptEditor_resource.h"
35 #include "../comafx/CPathTreeCtrl.h"
36 #include "../script/DialogScriptEditor.h"
41 #ifdef ID_DEBUG_MEMORY
52 #define GetIdFromTypeAndIndex( type, index ) ( ( (int)type << DECLTYPE_SHIFT ) | index )
53 #define GetTypeFromId( id ) ( (declType_t) ( (int)id >> DECLTYPE_SHIFT ) )
54 #define GetIndexFromId( id ) ( (int)id & DECLINDEX_MASK )
65 { IDCANCEL,
"cancel" },
103 CDialog::DoDataExchange(pDX);
123 template<
class type >
132 idStr rootStr, declName;
135 for ( i = 0; i < decls.
Num(); i++ ) {
145 for ( i = 0; i < decls.
Num(); i++) {
146 declName = rootStr + decls[
i]->GetName();
171 scriptName = files->
GetFile( i );
198 scriptName = files->
GetFile( i );
238 for( parent =
declTree.GetParentItem( item ); parent; parent =
declTree.GetParentItem( parent ) ) {
239 itemName =
declTree.GetItemText( item );
240 declName = itemName +
"/" + declName;
243 declName.
Strip(
'/' );
244 typeName =
declTree.GetItemText( item );
257 if (
declTree.GetChildItem( item ) ) {
297 if (
declTree.GetChildItem( item ) ) {
308 spawnArgs.
Set(
"articulatedFigure", decl->
GetName() );
326 idStr typeName, declName;
332 scriptEditor->ShowWindow( SW_SHOW );
333 scriptEditor->SetFocus();
341 declEditor->
LoadDecl( const_cast<idDecl *>( decl ) );
342 declEditor->ShowWindow( SW_SHOW );
343 declEditor->SetFocus();
385 text = (
char *) buffer;
393 char *declText = (
char *)_alloca( ( decl->
GetTextLength() + 1 ) *
sizeof(
char ) );
413 CDialog::OnInitDialog();
417 statusBar.CreateEx( SBARS_SIZEGRIP, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM,
initialRect,
this, AFX_IDW_STATUS_BAR );
433 EnableToolTips(
TRUE );
447 common->
Printf(
"Cannot run the declaration editor in fullscreen mode.\n"
448 "Set r_fullscreen to 0 and vid_restart.\n" );
452 if ( g_DeclDialog ==
NULL ) {
457 if ( g_DeclDialog->GetSafeHwnd() ==
NULL) {
468 g_DeclDialog->ShowWindow( SW_SHOW );
469 g_DeclDialog->SetFocus();
482 MSG *msg = AfxGetCurrentMessage();
484 MSG *msg = &m_msgCur;
487 while( ::PeekMessage(msg,
NULL,
NULL,
NULL, PM_NOREMOVE) ) {
489 if ( !AfxGetApp()->PumpMessage() ) {
510 if ( g_DeclDialog ) {
526 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
527 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
535 ON_NOTIFY(NM_DBLCLK, IDC_DECLBROWSER_TREE, OnTreeDblclk)
540 ON_BN_CLICKED(IDOK, OnBnClickedOk)
541 ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
552 CDialog::OnActivate( nState, pWndOther, bMinimized );
562 TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
563 TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
565 if ( pNMHDR->hwndFrom ==
declTree.GetSafeHwnd() ) {
576 if( pNMHDR->code == TTN_NEEDTEXTA ) {
578 m_pchTip =
new TCHAR[toolTip.GetLength() + 2];
579 lstrcpyn(
m_pchTip, toolTip, toolTip.GetLength() + 1 );
583 m_pwchTip =
new WCHAR[toolTip.GetLength() + 2];
584 _mbstowcsz(
m_pwchTip, toolTip, toolTip.GetLength() + 1 );
588 if( pNMHDR->code == TTN_NEEDTEXTA ) {
590 m_pchTip =
new TCHAR[toolTip.GetLength() + 2];
591 _wcstombsz(
m_pchTip, toolTip, toolTip.GetLength() + 1 );
595 m_pwchTip =
new WCHAR[toolTip.GetLength() + 2];
596 lstrcpyn(
m_pwchTip, toolTip, toolTip.GetLength() + 1 );
612 CDialog::OnSetFocus( pOldWnd );
624 return CDialog::OnDestroy();
633 if ( GetSafeHwnd() ) {
635 GetWindowRect( rct );
638 CDialog::OnMove( x, y );
646 #define BORDER_SIZE 4
647 #define BUTTON_SPACE 4
648 #define TOOLBAR_HEIGHT 24
651 CRect clientRect, rect;
655 CDialog::OnSize( nType, cx, cy );
657 GetClientRect( clientRect );
663 rect.bottom = clientRect.Height() - 100;
664 declTree.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
669 rect.top = clientRect.Height() - 100 +
BUTTON_SPACE + 2;
671 rect.bottom = clientRect.Height() - 76 + 2;
672 findNameStatic.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
679 rect.bottom = clientRect.Height() - 54 + 2;
680 findTextStatic.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
687 rect.bottom = clientRect.Height() - 76;
688 findNameEdit.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
695 rect.bottom = clientRect.Height() - 54;
696 findTextEdit.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
701 int width = rect.Width();
702 int height = rect.Height();
707 findButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
712 int width = rect.Width();
713 int height = rect.Height();
718 editButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
723 int width = rect.Width();
724 int height = rect.Height();
729 newButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
734 int width = rect.Width();
735 int height = rect.Height();
740 reloadButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
745 int width = rect.Width();
746 int height = rect.Height();
751 cancelButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
755 rect.left = clientRect.Width() - 2;
756 rect.top = clientRect.Height() - 2;
757 rect.right = clientRect.Width() - 2;
758 rect.bottom = clientRect.Height() - 2;
759 statusBar.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
762 UnlockWindowUpdate();
782 CDialog::OnSizing( nSide, lpRect );
784 if ( ( nSide - 1 ) % 3 == 0 ) {
785 if ( lpRect->right - lpRect->left <
initialRect.Width() ) {
786 lpRect->left = lpRect->right -
initialRect.Width();
788 }
else if ( ( nSide - 2 ) % 3 == 0 ) {
789 if ( lpRect->right - lpRect->left <
initialRect.Width() ) {
790 lpRect->right = lpRect->left +
initialRect.Width();
793 if ( nSide >= 3 && nSide <= 5 ) {
794 if ( lpRect->bottom - lpRect->top <
initialRect.Height() ) {
795 lpRect->top = lpRect->bottom -
initialRect.Height();
797 }
else if ( nSide >= 6 && nSide <= 9 ) {
798 if ( lpRect->bottom - lpRect->top <
initialRect.Height() ) {
799 lpRect->bottom = lpRect->top +
initialRect.Height();
810 LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
817 HTREEITEM item =
declTree.GetSelectedItem();
818 idStr typeName, declName;
834 PostMessage( WM_COMMAND, ( BN_CLICKED << 16 ) |
editButton.GetDlgCtrlID(), 0 );
876 idStr typeName, declName;
894 if ( newDeclDlg.DoModal() != IDOK ) {
int GetLineNum(void) const
#define IDC_DECLBROWSER_BUTTON_FIND
bool DeclBrowserCompareDecl(void *data, HTREEITEM item, const char *name)
void DeclBrowserShutdown(void)
BOOL DefaultOnToolTipNotify(const toolTip_t *toolTips, UINT id, NMHDR *pNMHDR, LRESULT *pResult)
void GetDeclName(HTREEITEM item, idStr &typeName, idStr &declName) const
void SetDefaultFile(const char *file)
afx_msg void OnBnClickedCancel()
void AddGUIsToTree(CPathTreeCtrl &tree)
const char * GetFileName(void) const
int idListDeclSortCompare(const type *a, const type *b)
CONST PIXELFORMATDESCRIPTOR UINT
void ParticleEditorInit(const idDict *spawnArgs)
void SetNum(int newnum, bool resize=true)
void AddDeclTypeToTree(declType_t type, const char *root, CPathTreeCtrl &tree)
bool Filter(const char *filter, bool casesensitive) const
virtual int ReadFile(const char *relativePath, void **buffer, ID_TIME_T *timestamp=NULL)=0
afx_msg void OnBnClickedOk()
int GetNumFiles(void) const
idRenderSystem * renderSystem
afx_msg void OnMove(int x, int y)
idFileSystem * fileSystem
static toolTip_t toolTips[]
afx_msg void OnBnClickedReload()
afx_msg void OnTreeDblclk(NMHDR *pNMHDR, LRESULT *pResult)
const char * GetName(void) const
void AFEditorInit(const idDict *spawnArgs)
#define GetIndexFromId(id)
#define IDD_DIALOG_SCRIPTEDITOR
void DeclBrowserReloadDeclarations(void)
afx_msg void OnTreeSelChanged(NMHDR *pNMHDR, LRESULT *pResult)
GLuint GLuint GLsizei GLenum type
void Set(const char *key, const char *value)
virtual void FreeFile(void *buffer)=0
const int DECLTYPE_SCRIPT
virtual BOOL OnInitDialog()
virtual ~DialogDeclBrowser()
afx_msg void OnSetFocus(CWnd *pOldWnd)
idDecl * GetNewDecl(void) const
void SetDeclTree(CPathTreeCtrl *tree)
virtual int GetNumDeclTypes(void) const =0
idStr & BackSlashesToSlashes(void)
#define IDC_DECLBROWSER_BUTTON_RELOAD
#define IDC_DECLBROWSER_BASE_TREE
afx_msg void OnSizing(UINT nSide, LPRECT lpRect)
const idDecl * GetDeclFromTreeItem(HTREEITEM item) const
bool CompareDecl(HTREEITEM item, const char *name) const
afx_msg void OnBnClickedEdit()
void Sort(cmp_t *compare=(cmp_t *)&idListSortCompare< type >)
const idDecl * GetSelectedDecl(void) const
virtual bool IsFullScreen(void) const =0
declType_t GetType(void) const
idStr & StripFileExtension(void)
#define GetTypeFromId(id)
#define IDD_DIALOG_DECLBROWSER
int SearchTree(treeItemCompare_t compare, void *data, CPathTreeCtrl &result)
#define IDC_DECLBROWSER_STATIC_SEARCH_NAMES
void EditSelected(void) const
void PDAEditorInit(const idDict *spawnArgs)
GLsizei GLsizei GLenum GLenum const GLvoid * data
void AddScriptsToTree(CPathTreeCtrl &tree)
#define IDC_DECLBROWSER_EDIT_SEARCH_NAMES
const char * GetFile(int index) const
static int FindText(const char *str, const char *text, bool casesensitive=true, int start=0, int end=-1)
virtual void Reload(bool force)=0
int Find(const char c, int start=0, int end=-1) const
virtual void FreeFileList(idFileList *fileList)=0
afx_msg BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
GLubyte GLubyte GLubyte a
virtual void Printf(const char *fmt,...) id_attribute((format(printf
void SetDefaultType(const char *type)
void ReloadDeclarations(void)
void LoadDecl(idDecl *decl)
GLenum GLsizei GLsizei height
virtual const char * GetDeclNameFromType(declType_t type) const =0
#define IDC_DECLBROWSER_BUTTON_EDIT
idDeclManager * declManager
CPathTreeCtrl baseDeclTree
void DeclBrowserInit(const idDict *spawnArgs)
HTREEITEM InsertPathIntoTree(const idStr &pathName, const int id)
void OpenFile(const char *fileName)
virtual int GetNumDecls(declType_t type)=0
HTREEITEM AddPathToTree(const idStr &pathName, const int id, idPathTreeStack &stack)
afx_msg void OnBnClickedFind()
void PushRoot(HTREEITEM root)
virtual const idDecl * DeclByIndex(declType_t type, int index, bool forceParse=true)=0
virtual idFileList * ListFilesTree(const char *relativePath, const char *extension, bool sort=false, const char *gamedir=NULL)=0
MFnDagNode * GetParent(MFnDagNode *joint)
virtual void DoDataExchange(CDataExchange *pDX)
const char * c_str(void) const
#define IDC_DECLBROWSER_STATIC_SEARCH_TEXT
void DeclBrowserRun(void)
#define IDC_DECLBROWSER_EDIT_SEARCH_TEXT
afx_msg void OnBnClickedNew()
#define IDC_DECLBROWSER_TREE
void GetText(char *text) const
char * va(const char *fmt,...)
#define GetIdFromTypeAndIndex(type, index)
#define IDC_DECLBROWSER_BUTTON_NEW
afx_msg void OnSize(UINT nType, int cx, int cy)
#define IDD_DIALOG_DECLEDITOR
int GetTextLength(void) const
int IcmpPath(const char *text) const
void InitBaseDeclTree(void)
void SetDefaultName(const char *name)