1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "tools/edit_gui_common.h"
#include "../../sys/win32/rc/DeclEditor_resource.h"
#include "../comafx/CPathTreeCtrl.h"
#include "DialogDeclBrowser.h"
#include "DialogDeclNew.h"
#ifdef ID_DEBUG_MEMORY
#undef new
#undef DEBUG_NEW
#define DEBUG_NEW new
#endif
toolTip_t DialogDeclNew::toolTips[] = {
{ IDC_DECLNEW_COMBO_NEW_TYPE, "select the declaration type to create" },
{ IDC_DECLNEW_EDIT_NEW_NAME, "enter a name for the new declaration" },
{ IDC_DECLNEW_EDIT_NEW_FILE, "enter the name of the file to add the declaration to" },
{ IDC_DECLNEW_BUTTON_NEW_FILE, "select existing file to add the declaration to" },
{ IDOK, "create new declaration" },
{ IDCANCEL, "cancel" },
{ 0, NULL }
};
IMPLEMENT_DYNAMIC(DialogDeclNew, CDialog)
/*
================
DialogDeclNew::DialogDeclNew
================
*/
DialogDeclNew::DialogDeclNew( CWnd* pParent /*=NULL*/ )
: CDialog(DialogDeclNew::IDD, pParent)
, declTree(NULL)
, newDecl(NULL)
{
}
/*
================
DialogDeclNew::~DialogDeclNew
================
*/
DialogDeclNew::~DialogDeclNew() {
}
/*
================
DialogDeclNew::DoDataExchange
================
*/
void DialogDeclNew::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DialogDeclNew)
DDX_Control(pDX, IDC_DECLNEW_COMBO_NEW_TYPE, typeList);
DDX_Control(pDX, IDC_DECLNEW_EDIT_NEW_NAME, nameEdit);
DDX_Control(pDX, IDC_DECLNEW_EDIT_NEW_FILE, fileEdit);
DDX_Control(pDX, IDC_DECLNEW_BUTTON_NEW_FILE, fileButton);
DDX_Control(pDX, IDOK, okButton);
DDX_Control(pDX, IDCANCEL, cancelButton);
//}}AFX_DATA_MAP
}
/*
================
DialogDeclNew::InitTypeList
================
*/
void DialogDeclNew::InitTypeList( void ) {
int i;
typeList.ResetContent();
for ( i = 0; i < declManager->GetNumDeclTypes(); i++ ) {
typeList.AddString( declManager->GetDeclNameFromType( (declType_t)i ) );
}
}
/*
================
DialogDeclNew::OnInitDialog
================
*/
BOOL DialogDeclNew::OnInitDialog() {
CDialog::OnInitDialog();
InitTypeList();
SetSafeComboBoxSelection( &typeList, defaultType.c_str(), -1 );
nameEdit.SetWindowText( defaultName.c_str() );
fileEdit.SetWindowText( defaultFile.c_str() );
EnableToolTips( TRUE );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(DialogDeclNew, CDialog)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
ON_WM_DESTROY()
ON_WM_ACTIVATE()
ON_WM_SETFOCUS()
ON_BN_CLICKED(IDC_DECLNEW_BUTTON_NEW_FILE, OnBnClickedFile)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
END_MESSAGE_MAP()
// DialogDeclNew message handlers
/*
================
DialogDeclNew::OnActivate
================
*/
void DialogDeclNew::OnActivate( UINT nState, CWnd *pWndOther, BOOL bMinimized ) {
CDialog::OnActivate( nState, pWndOther, bMinimized );
}
/*
================
DialogDeclNew::OnToolTipNotify
================
*/
BOOL DialogDeclNew::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
}
/*
================
DialogDeclNew::OnSetFocus
================
*/
void DialogDeclNew::OnSetFocus( CWnd *pOldWnd ) {
CDialog::OnSetFocus( pOldWnd );
}
/*
================
DialogDeclNew::OnDestroy
================
*/
void DialogDeclNew::OnDestroy() {
return CDialog::OnDestroy();
}
/*
================
DialogDeclNew::OnBnClickedFile
================
*/
void DialogDeclNew::OnBnClickedFile() {
CString typeName, folder, ext;
idStr path;
const char *errorTitle = "Error selecting file.";
if ( GetSafeComboBoxSelection( &typeList, typeName, -1 ) == -1 ) {
MessageBox( "Select a declaration type first.", errorTitle, MB_OK );
return;
}
declType_t type = declManager->GetDeclTypeFromName( typeName );
if ( type >= declManager->GetNumDeclTypes() ) {
MessageBox( "Unknown declaration type.", errorTitle, MB_OK | MB_ICONERROR );
return;
}
switch( type ) {
// FIXME: SteelStorm2 has a _v1 suffix for materials, def and fx - why?
case DECL_TABLE: folder = "materials"; ext = "(*.mtr)|*.mtr|(*.*)|*.*||"; break;
case DECL_MATERIAL: folder = "materials"; ext = "(*.mtr)|*.mtr|(*.*)|*.*||"; break;
case DECL_SKIN: folder = "skins"; ext = "(*.skin)|*.skin|(*.*)|*.*||"; break;
case DECL_SOUND: folder = "sound"; ext = "(*.sndshd|*.sndshd|(*.*)|*.*||"; break;
case DECL_ENTITYDEF: folder = "def"; ext = "(*.def)|*.def|(*.decl)|*.decl|(*.*)|*.*||"; break;
case DECL_MODELDEF: folder = "def"; ext = "(*.def)|*.def|(*.*)|*.*||"; break;
case DECL_FX: folder = "fx"; ext = "(*.fx)|*.fx|(*.*)|*.*||"; break;
case DECL_PARTICLE: folder = "particles"; ext = "(*.prt)|*.prt|(*.*)|*.*||"; break;
case DECL_AF: folder = "af"; ext = "(*.af)|*.af|(*.*)|*.*||"; break;
default: folder = "def"; ext = "(*.decl)|*.decl|(*.*)|*.*||"; break;
}
path = fileSystem->RelativePathToOSPath( folder );
path += "\\*";
CFileDialog dlgFile( TRUE, "decl", path, 0, ext, this );
if ( dlgFile.DoModal() == IDOK ) {
path = fileSystem->OSPathToRelativePath( dlgFile.m_ofn.lpstrFile );
fileEdit.SetWindowText( path );
}
}
/*
================
DialogDeclNew::OnBnClickedOk
================
*/
void DialogDeclNew::OnBnClickedOk() {
CString typeName, declName, fileName;
const char *errorTitle = "Error creating declaration.";
if ( !declTree ) {
MessageBox( "No declaration tree available.", errorTitle, MB_OK | MB_ICONERROR );
return;
}
if ( GetSafeComboBoxSelection( &typeList, typeName, -1 ) == -1 ) {
MessageBox( "No declaration type selected.", errorTitle, MB_OK | MB_ICONERROR );
return;
}
nameEdit.GetWindowText( declName );
if ( declName.GetLength() == 0 ) {
MessageBox( "No declaration name specified.", errorTitle, MB_OK | MB_ICONERROR );
return;
}
fileEdit.GetWindowText( fileName );
if ( fileName.GetLength() == 0 ) {
MessageBox( "No file name specified.", errorTitle, MB_OK | MB_ICONERROR );
return;
}
if ( declTree->FindItem( idStr( typeName + "/" + declName ) ) ) {
MessageBox( "Declaration already exists.", errorTitle, MB_OK | MB_ICONERROR );
return;
}
declType_t type = declManager->GetDeclTypeFromName( typeName );
if ( type >= declManager->GetNumDeclTypes() ) {
MessageBox( "Unknown declaration type.", errorTitle, MB_OK | MB_ICONERROR );
return;
}
newDecl = declManager->CreateNewDecl( type, declName, fileName );
OnOK();
}
/*
================
DialogDeclNew::OnBnClickedCancel
================
*/
void DialogDeclNew::OnBnClickedCancel() {
OnCancel();
}
|