2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 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.
24 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.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
35 #include "DialogTextures.h"
36 #include "DialogInfo.h"
37 #include "EditViewDlg.h"
42 static char THIS_FILE[] = __FILE__;
45 HTREEITEM FindTreeItem(CTreeCtrl *tree, HTREEITEM root, const char *text, HTREEITEM forceParent);
46 extern void Select_SetKeyVal(const char *key, const char *val);
48 const char *CDialogTextures::TypeNames[] = {
62 // =======================================================================================================================
63 // CDialogTextures dialog
64 // =======================================================================================================================
66 CDialogTextures::CDialogTextures(CWnd *pParent /* =NULL */ ) :
67 CDialog(CDialogTextures::IDD, pParent) {
69 ignoreCollapse = false;
73 //{{AFX_DATA_INIT(CDialogTextures)
78 =======================================================================================================================
79 =======================================================================================================================
81 void CDialogTextures::DoDataExchange(CDataExchange *pDX) {
82 CDialog::DoDataExchange(pDX);
83 //{{AFX_DATA_MAP(CDialogTextures)
84 DDX_Control(pDX, IDC_CHECK_HIDEROOT, m_chkHideRoot);
85 DDX_Control(pDX, IDC_REFRESH, m_btnRefresh);
86 DDX_Control(pDX, IDC_LOAD, m_btnLoad);
87 DDX_Control(pDX, IDC_PREVIEW, m_wndPreview);
88 DDX_Control(pDX, IDC_TREE_TEXTURES, m_treeTextures);
92 BEGIN_MESSAGE_MAP(CDialogTextures, CDialog)
93 //{{AFX_MSG_MAP(CDialogTextures)
94 ON_BN_CLICKED(IDC_LOAD, OnLoad)
95 ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
96 ON_NOTIFY(NM_CLICK, IDC_TREE_TEXTURES, OnClickTreeTextures)
97 ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_TEXTURES, OnSelchangedTreeTextures)
98 ON_NOTIFY(NM_DBLCLK, IDC_TREE_TEXTURES, OnDblclkTreeTextures)
99 ON_BN_CLICKED(IDC_PREVIEW, OnPreview)
102 ON_BN_CLICKED(IDC_CHECK_HIDEROOT, OnCheckHideroot)
103 ON_COMMAND(ID_MATERIAL_EDIT, OnMaterialEdit)
104 ON_COMMAND(ID_MATERIAL_INFO, OnMaterialInfo)
107 ON_NOTIFY(NM_RCLICK, IDC_TREE_TEXTURES, OnNMRclickTreeTextures)
110 // =======================================================================================================================
111 // CDialogTextures message handlers
112 // =======================================================================================================================
114 void CDialogTextures::OnOK() {
119 =======================================================================================================================
120 =======================================================================================================================
122 BOOL CDialogTextures::OnInitDialog() {
123 CDialog::OnInitDialog();
125 m_image.Create(IDB_BITMAP_MATERIAL, 16, 1, RGB(255, 255, 255));
126 m_treeTextures.SetImageList(&m_image, TVSIL_NORMAL);
128 // m_wndPreview.SubclassDlgItem(IDC_PREVIEW, this);
129 m_wndPreview.setDrawable(&m_testDrawable);
132 return TRUE; // return TRUE unless you set the focus to a control
133 // EXCEPTION: OCX Property Pages should return FALSE
137 =======================================================================================================================
138 =======================================================================================================================
140 bool CDialogTextures::loadTree( HTREEITEM item, const idStr &name, CWaitDlg *dlg ) {
142 if ( item == NULL ) {
146 if ( m_treeTextures.ItemHasChildren( item ) ) {
150 HTREEITEM childItem = m_treeTextures.GetChildItem(item);
152 while ( childItem != NULL ) {
154 nextItem = m_treeTextures.GetNextItem( childItem, TVGN_NEXT );
155 childName = name + "/" + (const char *)m_treeTextures.GetItemText( childItem );
157 if ( m_treeTextures.ItemHasChildren( childItem ) ) {
158 if ( !loadTree( childItem, childName, dlg ) ) {
162 DWORD dw = m_treeTextures.GetItemData( childItem );
163 if ( dw == TEXTURES || dw == MATERIALS ) {
164 if ( dw == TEXTURES ) {
165 childName = "textures/" + childName;
167 dlg->SetText( childName.c_str() );
168 Texture_ForName( childName );
171 if ( dlg->CancelPressed() ) {
175 childItem = nextItem;
182 HTREEITEM CDialogTextures::findItem(const char *name, HTREEITEM item, HTREEITEM *foundItem) {
183 if (*foundItem || item == NULL) {
186 if (m_treeTextures.ItemHasChildren(item)) {
188 HTREEITEM childItem = m_treeTextures.GetChildItem(item);
189 while (childItem != NULL && *foundItem == NULL) {
190 nextItem = childItem;
191 if (m_treeTextures.ItemHasChildren(nextItem)) {
192 findItem(name, nextItem, foundItem);
194 DWORD dw = m_treeTextures.GetItemData(nextItem);
195 if (dw == TEXTURES) {
196 const char *matName = buildItemName(nextItem, TypeNames[TEXTURES]);
197 if ( !idStr::Icmpn( name, "textures/", 9 ) && stricmp(name + 9, matName) == 0) {
198 *foundItem = nextItem;
201 } else if (dw == MATERIALS) {
202 const char *matName = buildItemName(nextItem, TypeNames[MATERIALS]);
203 if (stricmp(name, matName) == 0) {
204 *foundItem = nextItem;
207 } else if (dw == SOUNDS) {
208 if (stricmp(name, m_treeTextures.GetItemText(nextItem)) == 0) {
209 *foundItem = nextItem;
214 childItem = m_treeTextures.GetNextItem(childItem, TVGN_NEXT);
215 //childItem = nextItem;
221 void CDialogTextures::CollapseChildren(HTREEITEM parent) {
223 HTREEITEM childItem = m_treeTextures.GetChildItem(parent);
225 nextItem = m_treeTextures.GetNextItem(childItem, TVGN_NEXT);
226 if (m_treeTextures.ItemHasChildren(childItem)) {
227 CollapseChildren(childItem);
228 m_treeTextures.Expand(childItem, TVE_COLLAPSE);
230 childItem = nextItem;
234 void CDialogTextures::SelectCurrentItem(bool collapse, const char *name, int id) {
235 HTREEITEM root = m_treeTextures.GetRootItem();
237 if ((id == TEXTURES) || (id == MATERIALS)) {
238 HTREEITEM matItem = NULL;
239 HTREEITEM *matPtr = &matItem;
241 // FIXME: This is a hack. How should this really work?
242 if (id == MATERIALS && !idStr::Icmpn( name, "textures/", 9 ) ) {
243 // Texture_SetTexture calls SelectCurrentItem with id == MATERIALS
248 if (collapse && !ignoreCollapse) {
249 CollapseChildren(root);
252 HTREEITEM *check = NULL;
255 if (id == TEXTURES && !idStr::Icmpn( name, "textures/", 9 ) ) {
256 // strip off "textures/"
261 if (quickTree.Get(qt, &check)) {
264 if (matItem == NULL) {
265 matItem = findItem(name, root, matPtr);
268 m_treeTextures.SelectItem(matItem);
272 } else if (id == SOUNDS) {
274 if (collapse && !ignoreCollapse) {
275 CollapseChildren(root);
277 HTREEITEM sel = FindTreeItem(&m_treeTextures, root, name, NULL);
279 m_treeTextures.SelectItem(sel);
285 void CDialogTextures::OnLoad() {
288 dlg.AllowCancel( true );
289 dlg.SetWindowText( "Loading textures..." );
291 HTREEITEM item = m_treeTextures.GetSelectedItem();
292 idStr name = buildItemName( item, TypeNames[TEXTURES] );
293 if ( !name.Cmpn( TypeNames[MATERIALS], strlen( TypeNames[MATERIALS] ) ) ) {
294 name = buildItemName( item, TypeNames[MATERIALS] );
296 loadTree( item, name, &dlg );
299 const char *CDialogTextures::buildItemName(HTREEITEM item, const char *rootName) {
300 itemName = m_treeTextures.GetItemText(item);
302 // have to build the name back up
303 HTREEITEM parent = m_treeTextures.GetParentItem(item);
305 idStr strParent = m_treeTextures.GetItemText(parent);
306 if ( idStr::Icmp(strParent, rootName) == 0 ) {
310 strParent += itemName;
311 itemName = strParent;
312 parent = m_treeTextures.GetParentItem(parent);
313 if (parent == NULL) {
320 =======================================================================================================================
321 =======================================================================================================================
323 void CDialogTextures::OnRefresh() {
328 if (mode == TEXTURES) {
329 idStrList textures(1024);
330 int count = declManager->GetNumDecls( DECL_MATERIAL );
332 const idMaterial *mat;
334 for (i = 0; i < count; i++) {
335 mat = declManager->MaterialByIndex(i, false);
336 if ( mat->IsValid() && mat->TestMaterialFlag(MF_EDITOR_VISIBLE) && !idStr::Icmpn( mat->GetName(), "textures/", 9 ) ) {
337 textures.Append(mat->GetName());
341 declManager->Reload( false );
344 count = textures.Num();
345 for (i = 0; i < count; i++) {
346 mat = declManager->FindMaterial(textures[i].c_str());
348 mat->SetMaterialFlag(MF_EDITOR_VISIBLE);
351 SelectCurrentItem(false, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::TEXTURES);
352 } else if (mode == MATERIALS) {
353 idStrList textures(1024);
354 int count = declManager->GetNumDecls( DECL_MATERIAL );
356 const idMaterial *mat;
358 for (i = 0; i < count; i++) {
359 mat = declManager->MaterialByIndex(i, false);
360 if ( mat->IsValid() && mat->TestMaterialFlag(MF_EDITOR_VISIBLE) && idStr::Icmpn( mat->GetName(), "textures/", 9 ) ) {
361 textures.Append(mat->GetName());
365 declManager->Reload( false );
368 count = textures.Num();
369 for (i = 0; i < count; i++) {
370 mat = declManager->FindMaterial(textures[i].c_str());
372 mat->SetMaterialFlag(MF_EDITOR_VISIBLE);
375 SelectCurrentItem(false, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::MATERIALS);
376 } else if (mode == SOUNDS || mode == SOUNDPARENT) {
377 HTREEITEM root = m_treeTextures.GetRootItem();
378 HTREEITEM sib = m_treeTextures.GetNextItem(root, TVGN_ROOT);
380 idStr str = m_treeTextures.GetItemText(sib);
381 if (str.Icmp(TypeNames[SOUNDS]) == 0) {
383 m_treeTextures.DeleteItem(sib);
385 declManager->Reload( false );
386 bool rootItems = m_chkHideRoot.GetCheck() == 0;
387 addSounds(rootItems);
390 sib = m_treeTextures.GetNextSiblingItem(sib);
396 =======================================================================================================================
397 =======================================================================================================================
399 HTREEITEM FindTreeItem(CTreeCtrl *tree, HTREEITEM root, const char *text, HTREEITEM forceParent) {
400 HTREEITEM theItem = NULL;
402 if ((theItem = tree->GetNextSiblingItem(root)) != NULL) {
403 theItem = FindTreeItem(tree, theItem, text, NULL);
406 if (tree->GetParentItem(theItem) == forceParent) {
416 if ((theItem = tree->GetChildItem(root)) != NULL) {
417 theItem = FindTreeItem(tree, theItem, text, NULL);
420 if (tree->GetParentItem(theItem) == forceParent) {
429 if (text && idStr::Icmp(tree->GetItemText(root), text) == 0 ) {
433 if (theItem && forceParent) {
434 if (tree->GetParentItem(theItem) != forceParent) {
442 =======================================================================================================================
443 =======================================================================================================================
445 void CDialogTextures::BuildTree() {
447 m_treeTextures.DeleteAllItems();
448 bool rootItems = m_chkHideRoot.GetCheck() == 0;
454 addMaterials( rootItems );
456 //addModels( rootItems );
457 addScripts( rootItems );
458 addSounds( rootItems );
459 addGuis( rootItems );
460 addParticles( rootItems );
464 common->Printf( "CDialogTextures::BuildTree() took %.0f milliseconds\n", timer.Milliseconds() );
468 =======================================================================================================================
469 =======================================================================================================================
471 void CDialogTextures::OnClickTreeTextures(NMHDR *pNMHDR, LRESULT *pResult) {
476 m_treeTextures.ScreenToClient(&pt);
477 HTREEITEM item = m_treeTextures.HitTest(pt);
480 DWORD dw = m_treeTextures.GetItemData(item);
482 if (mode == SOUNDS) {
484 if (!m_treeTextures.ItemHasChildren(item)) {
485 loadName = m_treeTextures.GetItemText(item);
486 idStr actionName = m_treeTextures.GetItemText(item);
487 soundSystem->SetMute( false );
488 g_qeglobals.sw->PlayShaderDirectly(actionName);
490 loadName = m_treeTextures.GetItemText(item);
494 g_qeglobals.sw->StopAllSounds();
500 =======================================================================================================================
501 =======================================================================================================================
503 void CDialogTextures::OnSelchangedTreeTextures(NMHDR *pNMHDR, LRESULT *pResult) {
504 NM_TREEVIEW *pNMTreeView = (NM_TREEVIEW *) pNMHDR;
511 m_wndPreview.setDrawable(&m_testDrawable);
512 HTREEITEM item = m_treeTextures.GetSelectedItem();
514 DWORD dw = m_treeTextures.GetItemData(item);
516 if ((dw == TEXTURES) || (dw == MATERIALS)) {
517 idStr matName = m_treeTextures.GetItemText(item);
519 // have to build the name back up
520 HTREEITEM parent = m_treeTextures.GetParentItem(item);
522 idStr strParent = m_treeTextures.GetItemText(parent);
523 if ( idStr::Icmp(strParent, TypeNames[dw]) == 0 ) {
527 strParent += matName;
529 parent = m_treeTextures.GetParentItem(parent);
530 if (parent == NULL) {
534 if ( dw == TEXTURES ) {
535 matName = "textures/" + matName;
538 const idMaterial *mat = Texture_ForName(matName);
540 m_drawMaterial.setMedia(matName);
541 m_wndPreview.setDrawable(&m_drawMaterial);
542 m_wndPreview.RedrawWindow();
544 ignoreCollapse = true;
545 Select_SetDefaultTexture(mat, false, setTexture);
546 ignoreCollapse = false;
547 } else if (dw == MODELS) {
549 idStr modelName = m_treeTextures.GetItemText(item);
550 // have to build the name back up
551 HTREEITEM parent = m_treeTextures.GetParentItem(item);
553 strParent = m_treeTextures.GetItemText(parent);
554 if ( idStr::Icmp(strParent, TypeNames[MODELS]) == 0 ) {
558 strParent += modelName;
559 modelName = strParent;
560 parent = m_treeTextures.GetParentItem(parent);
561 if (parent == NULL) {
565 strParent = "models/";
566 strParent += modelName;
567 m_drawModel.setMedia(strParent);
568 mediaName = strParent;
569 m_wndPreview.setDrawable(&m_drawModel);
570 m_drawModel.SetRealTime(0);
571 m_wndPreview.RedrawWindow();
572 } else if (dw == SCRIPTS) {
573 } else if (dw == SOUNDS) {
574 } else if (dw == PARTICLES) {
576 idStr modelName = m_treeTextures.GetItemText(item);
577 // have to build the name back up
578 HTREEITEM parent = m_treeTextures.GetParentItem(item);
580 strParent = m_treeTextures.GetItemText(parent);
581 if ( idStr::Icmp(strParent, TypeNames[PARTICLES]) == 0 ) {
585 strParent += modelName;
586 modelName = strParent;
587 parent = m_treeTextures.GetParentItem(parent);
588 if (parent == NULL) {
592 strParent = modelName;
593 mediaName = strParent;
595 m_drawModel.setMedia(mediaName);
596 m_drawModel.SetRealTime(50);
597 m_wndPreview.setDrawable(&m_drawModel);
598 m_wndPreview.RedrawWindow();
599 } else if (dw == GUIS) {
601 idStr modelName = m_treeTextures.GetItemText(item);
602 // have to build the name back up
603 HTREEITEM parent = m_treeTextures.GetParentItem(item);
605 strParent = m_treeTextures.GetItemText(parent);
606 if ( idStr::Icmp(strParent, TypeNames[GUIS]) == 0 ) {
610 strParent += modelName;
611 modelName = strParent;
612 parent = m_treeTextures.GetParentItem(parent);
613 if (parent == NULL) {
618 strParent += modelName;
619 const idMaterial *mat = declManager->FindMaterial("guisurfs/guipreview");
620 mat->SetGui(strParent);
622 m_drawMaterial.setMedia("guisurfs/guipreview");
623 m_drawMaterial.setScale(4.4f);
624 m_wndPreview.setDrawable(&m_drawMaterial);
625 m_wndPreview.RedrawWindow();
632 =======================================================================================================================
633 =======================================================================================================================
635 void CDialogTextures::addMaterials( bool rootItems ) {
636 idStrList textures(1024);
637 idStrList materials(1024);
639 textures.SetGranularity( 1024 );
640 materials.SetGranularity( 1024 );
642 int count = declManager->GetNumDecls( DECL_MATERIAL );
644 for ( int i = 0; i < count; i++ ) {
645 const idMaterial *mat = declManager->MaterialByIndex( i, false );
647 if ( strchr( mat->GetName(), '/' ) == NULL && strchr( mat->GetName(), '\\' ) == NULL ) {
651 // add everything except the textures/ materials
652 if ( idStr::Icmpn( mat->GetName(), "textures/", 9 ) == 0 ) {
653 textures.Append( mat->GetName() );
655 materials.Append( mat->GetName() );
658 idStrListSortPaths( textures );
659 addStrList( TypeNames[TEXTURES], textures, TEXTURES );
660 idStrListSortPaths( materials );
661 addStrList( TypeNames[MATERIALS], materials, MATERIALS );
666 =======================================================================================================================
667 =======================================================================================================================
669 void CDialogTextures::addParticles( bool rootItems ) {
670 idStrList list(1024);
671 int count = declManager->GetNumDecls( DECL_PARTICLE );
673 for (int i = 0; i < count; i++) {
674 const idDecl *ips = declManager->DeclByIndex( DECL_PARTICLE, i, false );
676 if (strchr(ips->GetName(), '/') == NULL && strchr(ips->GetName(), '\\') == NULL) {
680 list.Append(ips->GetName());
682 idStrListSortPaths( list );
683 addStrList( TypeNames[PARTICLES], list, PARTICLES );
688 =======================================================================================================================
689 =======================================================================================================================
691 void CDialogTextures::addSounds(bool rootItems) {
693 idStrList list(1024);
694 idStrList list2(1024);
695 HTREEITEM base = m_treeTextures.InsertItem(TypeNames[SOUNDS]);
697 for(i = 0; i < declManager->GetNumDecls( DECL_SOUND ); i++) {
698 const idSoundShader *poo = declManager->SoundByIndex(i, false);
699 list.AddUnique( poo->GetFileName() );
701 idStrListSortPaths( list );
703 for (i = 0; i < list.Num(); i++) {
704 HTREEITEM child = m_treeTextures.InsertItem(list[i], base);
705 m_treeTextures.SetItemData(child, SOUNDPARENT);
706 m_treeTextures.SetItemImage(child, 0, 1);
708 for (j = 0; j < declManager->GetNumDecls( DECL_SOUND ); j++) {
709 const idSoundShader *poo = declManager->SoundByIndex(j, false);
710 if ( idStr::Icmp( list[i], poo->GetFileName() ) == 0 ) {
711 list2.Append( poo->GetName() );
714 idStrListSortPaths( list2 );
715 for (j = 0; j < list2.Num(); j++) {
716 HTREEITEM child2 = m_treeTextures.InsertItem( list2[j], child );
717 m_treeTextures.SetItemData(child2, SOUNDS);
718 m_treeTextures.SetItemImage(child2, 2, 2);
724 void CDialogTextures::addStrList( const char *root, const idStrList &list, int id ) {
727 HTREEITEM base = m_treeTextures.GetRootItem();
729 out = m_treeTextures.GetItemText(base);
730 if (stricmp(root, out) == 0) {
733 base = m_treeTextures.GetNextSiblingItem(base);
737 base = m_treeTextures.InsertItem(root);
740 HTREEITEM item = base;
743 int count = list.Num();
746 for (int i = 0; i < count; i++) {
747 idStr name = list[i];
749 // now break the name down convert to slashes
750 name.BackSlashesToSlashes();
754 int len = last.Length();
756 index = name.Last('/');
758 name.Left(index, last);
761 else if (idStr::Icmpn(last, name, len) == 0 && name.Last('/') <= len) {
762 name.Right(name.Length() - len - 1, out);
763 add = m_treeTextures.InsertItem(out, item);
767 quickTree.Set(qt, add);
768 m_treeTextures.SetItemData(add, id);
769 m_treeTextures.SetItemImage(add, 2, 2);
780 index = name.Find('/');
782 HTREEITEM newItem = NULL;
783 HTREEITEM *check = NULL;
784 name.Left( index, out );
789 if (quickTree.Get(qt, &check)) {
792 //HTREEITEM newItem = FindTreeItem(&m_treeTextures, item, name.Left(index, out), item);
793 if (newItem == NULL) {
794 newItem = m_treeTextures.InsertItem(out, item);
798 quickTree.Set(qt, newItem);
799 m_treeTextures.SetItemImage(newItem, 0, 1);
804 name.Right( name.Length() - index - 1, out );
809 add = m_treeTextures.InsertItem(name, item);
814 quickTree.Set(qt, add);
815 m_treeTextures.SetItemData(add, id);
816 m_treeTextures.SetItemImage(add, 2, 2);
825 =======================================================================================================================
826 =======================================================================================================================
828 void CDialogTextures::addModels(bool rootItems) {
831 files = fileSystem->ListFilesTree( "models", ".ase|.lwo|.ma", true );
833 if ( files->GetNumFiles() ) {
834 addStrList( TypeNames[MODELS], files->GetList(), MODELS );
837 fileSystem->FreeFileList( files );
840 void CDialogTextures::addGuis( bool rootItems ) {
843 files = fileSystem->ListFilesTree( "guis", ".gui", true );
845 if ( files->GetNumFiles() ) {
846 addStrList( TypeNames[GUIS], files->GetList(), GUIS );
849 fileSystem->FreeFileList( files );
853 =======================================================================================================================
854 =======================================================================================================================
856 void CDialogTextures::addScripts(bool rootItems) {
860 files = fileSystem->ListFilesExt( "def", ".script" );
862 if ( files->GetNumFiles() ) {
863 addStrList("Scripts", files->GetList(), 3);
869 =======================================================================================================================
870 =======================================================================================================================
872 void CDialogTextures::OnDblclkTreeTextures(NMHDR *pNMHDR, LRESULT *pResult) {
875 m_treeTextures.ScreenToClient(&pt);
876 HTREEITEM item = m_treeTextures.HitTest(pt);
878 DWORD dw = m_treeTextures.GetItemData(item);
880 if (mode == SOUNDS) {
881 if (!m_treeTextures.ItemHasChildren(item)) {
882 idStr shaderName = m_treeTextures.GetItemText(item);
883 Select_SetKeyVal("s_shader", shaderName);
884 entity_t *ent = selected_brushes.next->owner;
886 g_Inspectors->UpdateEntitySel(ent->eclass);
890 } else if (mode == MODELS || mode == PARTICLES ) {
891 if (mediaName.Length()) {
892 g_Inspectors->entityDlg.UpdateKeyVal("model", mediaName);
894 } else if (mode <= MATERIALS) {
903 =======================================================================================================================
904 =======================================================================================================================
906 void CDialogTextures::OnPreview() {
907 // TODO: Add your control notification handler code here
911 //void CDialogTextures::OnSave()
915 m_wndEditShader.GetWindowText(str);
916 if (currentFile.length() && str.GetLength()) {
917 fileSystem->WriteFile(currentFile, str.GetBuffer(0), str.GetLength());
922 int CDialogTextures::OnCreate(LPCREATESTRUCT lpCreateStruct)
924 if (CDialog::OnCreate(lpCreateStruct) == -1)
927 // TODO: Add your specialized creation code here
932 void CDialogTextures::OnSize(UINT nType, int cx, int cy)
934 CDialog::OnSize(nType, cx, cy);
936 if (m_btnLoad.GetSafeHwnd() == NULL) {
940 CRect rect, rect2, rect3;
942 m_btnLoad.GetWindowRect(rect2);
944 m_btnLoad.SetWindowPos(NULL, rect.left + 4, rect.top + 4, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
945 m_btnRefresh.SetWindowPos(NULL, rect.left + rect2.Width() + 4, rect.top + 4, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
948 int right = rect.right - 4 - rect3.Width() - 4;
951 right = rect3.right - 4 - rect3.Width() - 4;
953 m_chkHideRoot.GetWindowRect(rect3);
954 m_chkHideRoot.SetWindowPos(NULL, right - rect3.Width() * 2, rect.top + 4, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
955 m_chkHideRoot.ShowWindow(SW_HIDE);
957 int verticalSpace = (rect.Height() - rect2.Height() - 12) / 2;
959 m_treeTextures.SetWindowPos(NULL, rect.left + 4, rect.top + 8 + rect2.Height(), (rect.Width() - 8), verticalSpace, SWP_SHOWWINDOW);
960 m_wndPreview.SetWindowPos(NULL, rect.left + 4, rect.top + 12 + rect2.Height() + verticalSpace, (rect.Width() - 8), verticalSpace, SWP_SHOWWINDOW);
965 BOOL CDialogTextures::PreCreateWindow(CREATESTRUCT& cs)
967 return CDialog::PreCreateWindow(cs);
970 void CDialogTextures::OnCheckHideroot()
975 void CDialogTextures::CollapseEditor() {
976 if (g_qeglobals.d_savedinfo.editorExpanded) {
981 void CDialogTextures::OnCancel() {
985 BOOL CDialogTextures::PreTranslateMessage(MSG* pMsg)
987 if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_RETURN)) {
988 if (pMsg->wParam == VK_ESCAPE) {
989 g_pParentWnd->GetCamera()->SetFocus();
995 return CDialog::PreTranslateMessage(pMsg);
998 void CDialogTextures::OnSetFocus(CWnd* pOldWnd)
1000 CDialog::OnSetFocus(pOldWnd);
1004 void CDialogTextures::OnNMRclickTreeTextures(NMHDR *pNMHDR, LRESULT *pResult)
1010 m_treeTextures.ScreenToClient(&pt);
1011 HTREEITEM item = m_treeTextures.HitTest(pt);
1014 DWORD dw = m_treeTextures.GetItemData(item);
1016 if (mode == TEXTURES || mode == MATERIALS || mode == GUIS) {
1017 m_treeTextures.SelectItem(item);
1018 HandlePopup(this, IDR_POPUP_MATERIAL);
1023 void CDialogTextures::OnMaterialEdit() {
1025 if ((mode == TEXTURES || mode == MATERIALS) && editMaterial) {
1026 dlg.SetMode(CEditViewDlg::MATERIALS);
1027 dlg.SetMaterialInfo(editMaterial->GetName(), editMaterial->GetFileName(), editMaterial->GetLineNum());
1029 } else if (mode == GUIS && editGui.Length()) {
1030 dlg.SetMode(CEditViewDlg::GUIS);
1031 dlg.SetGuiInfo(editGui);
1036 void CDialogTextures::OnMaterialInfo() {
1041 str += editMaterial->getFileName();
1042 str += "\r\nName: ";
1043 str = editMaterial->getName();
1044 ShowInfoDialog(str);
1045 } else if (editGui.Length()) {
1048 ShowInfoDialog(str);