123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938 |
- /*
- ===========================================================================
- 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 "../../idlib/precompiled.h"
- #pragma hdrstop
- #include "MaterialEditor.h"
- #include "MEMainFrame.h"
- #include "MaterialDef.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- #define TAB_CONTROL 0x1006
- IMPLEMENT_DYNAMIC(MEMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(MEMainFrame, CFrameWnd)
- ON_WM_CREATE()
- ON_WM_SETFOCUS()
- ON_WM_DESTROY()
- ON_WM_SIZE()
- ON_NOTIFY(TCN_SELCHANGE, TAB_CONTROL, OnTcnSelChange)
-
- ON_COMMAND(ID_ME_FILE_EXIT, OnFileExit)
- ON_COMMAND(ID_ME_FILE_SAVEMATERIAL, OnFileSaveMaterial)
- ON_COMMAND(ID_ME_FILE_SAVEFILE, OnFileSaveFile)
- ON_COMMAND(ID_ME_FILE_SAVE, OnFileSaveAll)
- ON_UPDATE_COMMAND_UI(ID_ME_FILE_SAVEMATERIAL, OnFileSaveMaterialUpdate )
- ON_UPDATE_COMMAND_UI(ID_ME_FILE_SAVEFILE, OnFileSaveFileUpdate )
- ON_UPDATE_COMMAND_UI(ID_ME_FILE_SAVE, OnFileSaveAllUpdate )
-
- ON_COMMAND(ID_ME_PREVIEW_APPLYCHANGES, OnApplyMaterial)
- ON_COMMAND(ID_ME_PREVIEW_APPLYFILE, OnApplyFile)
- ON_COMMAND(ID_ME_PREVIEW_APPLYALL, OnApplyAll)
- ON_UPDATE_COMMAND_UI(ID_ME_PREVIEW_APPLYCHANGES, OnApplyMaterialUpdate )
- ON_UPDATE_COMMAND_UI(ID_ME_PREVIEW_APPLYFILE, OnApplyFileUpdate )
- ON_UPDATE_COMMAND_UI(ID_ME_PREVIEW_APPLYALL, OnApplyAllUpdate )
- ON_COMMAND(ID_ME_EDIT_CUT, OnEditCut)
- ON_COMMAND(ID_ME_EDIT_COPY, OnEditCopy)
- ON_COMMAND(ID_ME_EDIT_PASTE, OnEditPaste)
- ON_COMMAND(ID_ME_EDIT_DELETE, OnEditDelete)
- ON_COMMAND(ID_ME_EDIT_RENAME, OnEditRename)
- ON_UPDATE_COMMAND_UI(ID_ME_EDIT_CUT, OnEditCutUpdate)
- ON_UPDATE_COMMAND_UI(ID_ME_EDIT_COPY, OnEditCopyUpdate)
- ON_UPDATE_COMMAND_UI(ID_ME_EDIT_PASTE, OnEditPasteUpdate)
- ON_UPDATE_COMMAND_UI(ID_ME_EDIT_DELETE, OnEditDeleteUpdate)
- ON_UPDATE_COMMAND_UI(ID_ME_EDIT_RENAME, OnEditRenameUpdate)
- ON_COMMAND(ID_ME_EDIT_FIND, OnEditFind)
- ON_COMMAND(ID_ME_EDIT_FIND_NEXT, OnEditFindNext)
- ON_COMMAND(ID_ME_EDIT_UNDO, OnEditUndo)
- ON_COMMAND(ID_ME_EDIT_REDO, OnEditRedo)
- ON_UPDATE_COMMAND_UI(ID_ME_EDIT_UNDO, OnEditUndoUpdate )
- ON_UPDATE_COMMAND_UI(ID_ME_EDIT_REDO, OnEditRedoUpdate )
-
- ON_COMMAND(ID_VIEW_INCLUDEFILENAME, OnViewIncludeFile)
- ON_COMMAND(ID_PREVIEW_RELOADARBPROGRAMS, OnReloadArbPrograms)
- ON_COMMAND(ID_PREVIEW_RELOADIMAGES, OnReloadImages )
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /**
- * Constructor for MEMainFrame. Initialize some member data and load the options.
- */
- MEMainFrame::MEMainFrame() {
-
- currentDoc = NULL;
- m_find = NULL;
- searchData.searched = false;
- options.Load();
- }
- /**
- * Destructor for MEMainFrame.
- */
- MEMainFrame::~MEMainFrame() {
- }
- /**
- * Called to add console text to the console view.
- * @param msg The text that is to be added to the console.
- */
- void MEMainFrame::PrintConsoleMessage(const char *msg) {
- m_consoleView->AddText(msg);
- }
- /**
- * Sets a few window styles for the main window during the creation process.
- */
- BOOL MEMainFrame::PreCreateWindow(CREATESTRUCT& cs) {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
-
- cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
- cs.lpszClass = AfxRegisterWndClass(0);
-
- return TRUE;
- }
- /**
- * Called by the MFC framework to allow the window to create any client windows. This method
- * creates all of the spliter windows and registers all of the views with the document manager.
- */
- BOOL MEMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) {
- CCreateContext consoleContext;
- consoleContext.m_pNewViewClass = RUNTIME_CLASS(ConsoleView);
- m_consoleView = (ConsoleView*)CreateView(&consoleContext);
- m_consoleView->ShowWindow(SW_HIDE);
- m_tabs.Create(TCS_BOTTOM | TCS_FLATBUTTONS | WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), this, TAB_CONTROL);
- m_tabs.InsertItem(0, "Editor");
- m_tabs.InsertItem(1, "Console");
- m_tabs.SetFont(materialEditorFont);
- m_splitterWnd.CreateStatic(this, 2, 1);
-
- m_editSplitter.CreateStatic(&m_splitterWnd, 1, 2, WS_CHILD | WS_VISIBLE | WS_BORDER, m_splitterWnd.IdFromRowCol(0, 0));
- if(!m_editSplitter.CreateView(0, 0, RUNTIME_CLASS(MaterialTreeView), CSize(300, 200), pContext)) {
- TRACE0("Failed to create material list pane\n");
- return FALSE;
- }
- if(!m_editSplitter.CreateView(0, 1, RUNTIME_CLASS(MaterialEditView), CSize(200, 200), pContext)) {
- TRACE0("Failed to create stage property pane\n");
- return FALSE;
- }
- m_previewSplitter.CreateStatic(&m_splitterWnd, 1, 2, WS_CHILD | WS_VISIBLE | WS_BORDER, m_splitterWnd.IdFromRowCol(1, 0));
- if(!m_previewSplitter.CreateView(0, 0, RUNTIME_CLASS(MaterialPreviewPropView), CSize(300, 200), pContext)) {
- TRACE0("Failed to create preview property pane\n");
- return FALSE;
- }
- if(!m_previewSplitter.CreateView(0, 1, RUNTIME_CLASS(MaterialPreviewView), CSize(100, 200), pContext)) {
- TRACE0("Failed to create preview pane\n");
- return FALSE;
- }
- //Get references to all of the views
- m_materialTreeView = (MaterialTreeView*)m_editSplitter.GetPane(0, 0);
- m_previewPropertyView = (MaterialPreviewPropView*)m_previewSplitter.GetPane(0, 0);
- m_materialPreviewView = (MaterialPreviewView*)m_previewSplitter.GetPane(0, 1);
- m_materialEditView = (MaterialEditView*)m_editSplitter.GetPane(0, 1);
- m_stageView = m_materialEditView->m_stageView;
- m_materialPropertyView = m_materialEditView->m_materialPropertyView;
- m_materialEditSplitter = &m_materialEditView->m_editSplitter;
- //Load the splitter positions from the registry
- int val = options.GetMaterialEditHeight();
- if(val <= 0)
- val = 300;
- m_splitterWnd.SetRowInfo(0, val, 0);
- val = options.GetMaterialTreeWidth();
- if(val <= 0)
- val = 300;
- m_editSplitter.SetColumnInfo(0, val, 0);
- val = options.GetStageWidth();
- if(val <= 0)
- val = 200;
- m_materialEditSplitter->SetColumnInfo(0, val, 0);
- val = options.GetPreviewPropertiesWidth();
- if(val <= 0)
- val = 300;
- m_previewSplitter.SetColumnInfo(0, val, 0);
-
- //Register the views with the document manager
- materialDocManager.RegisterMaterialView(this);
- materialDocManager.RegisterMaterialView(m_materialTreeView);
- materialDocManager.RegisterMaterialView(m_stageView);
- materialDocManager.RegisterMaterialView(m_materialPropertyView);
- materialDocManager.RegisterMaterialView(m_materialPreviewView);
- materialDocManager.RegisterMaterialView(m_materialEditView);
- //Let the stage window know about the prop window
- m_stageView->SetMaterialPropertyView(m_materialPropertyView);
- //Let the preview props now about the preview window
- m_previewPropertyView->RegisterPreviewView(m_materialPreviewView);
- m_previewPropertyView->InitializePropTree();
- m_previewPropertyView->GetPropertyTreeCtrl().SetColumn(120);
- MaterialDefManager::InitializeMaterialDefLists();
- //Some prop tree initialization
- //m_materialPropertyView->InitializePropTreeDefs();
- val = options.GetMaterialPropHeadingWidth();
- if(val <= 0)
- val = 200;
- m_materialPropertyView->GetPropertyTreeCtrl().SetColumn(val);
- m_materialPropertyView->LoadSettings();
- val = options.GetPreviewPropHeadingWidth();
- if(val <= 0)
- val = 120;
- m_previewPropertyView->GetPropertyTreeCtrl().SetColumn(val);
- //Build the material list
- m_materialTreeView->InitializeMaterialList(true);
- SetActiveView(m_materialTreeView);
- return CFrameWnd::OnCreateClient(lpcs, pContext);
- }
- /**
- * Called by the framework while the window is being created. This methods
- * creates the tool bars and status bars
- * /todo Bmatt Nerve: Need to get the toolbars to work correctly.
- */
- int MEMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_ME_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
- }
- //Load the window placement from the options
- options.GetWindowPlacement ( "mainframe", m_hWnd );
- return 0;
- }
- /**
- * Called by the MFC framework while the window is being destroyed. This method
- * saves the splitter and window positions.
- */
- void MEMainFrame::OnDestroy() {
- CFrameWnd::OnDestroy();
- int cur;
- int min;
- m_splitterWnd.GetRowInfo(0, cur, min);
- options.SetMaterialEditHeight(cur);
- m_editSplitter.GetColumnInfo(0, cur, min);
- options.SetMaterialTreeWidth(cur);
- m_materialEditSplitter->GetColumnInfo(0, cur, min);
- options.SetStageWidth(cur);
- m_previewSplitter.GetColumnInfo(0, cur, min);
- options.SetPreviewPropertiesWidth(cur);
- cur = m_materialPropertyView->GetPropertyTreeCtrl().GetColumn();
- options.SetMaterialPropHeadingWidth(cur);
- cur = m_previewPropertyView->GetPropertyTreeCtrl().GetColumn();
- options.SetPreviewPropHeadingWidth(cur);
- options.SetWindowPlacement ( "mainframe", m_hWnd );
- options.Save();
- m_materialPropertyView->SaveSettings();
- MaterialDefManager::DestroyMaterialDefLists();
- AfxGetApp()->ExitInstance();
- }
- /**
- * Called by the MFC framework when the window size is changed. This method adjusts the console view
- * so that it is always at the bottom of the window and resizes the splitter window to fit
- * the remaining space.
- */
- void MEMainFrame::OnSize(UINT nType, int cx, int cy)
- {
- CFrameWnd::OnSize(nType, cx, cy);
- CRect statusRect;
- m_wndStatusBar.GetWindowRect(statusRect);
- CRect toolbarRect;
- m_wndToolBar.GetWindowRect(toolbarRect);
- CRect tabRect;
- m_tabs.GetItemRect(0, tabRect);
- int tabHeight = tabRect.Height()+5;
- m_splitterWnd.MoveWindow(0, toolbarRect.Height(), cx, cy-statusRect.Height()-toolbarRect.Height()-tabHeight);
- m_tabs.MoveWindow(0, cy-statusRect.Height()-tabHeight, cx, tabHeight);
- m_consoleView->MoveWindow(0, toolbarRect.Height(), cx, cy-statusRect.Height()-toolbarRect.Height()-tabHeight);
- }
- /**
- * Called when the user changes the editor/console tab selection. This methods shows and hides
- * the appropriate windows.
- */
- void MEMainFrame::OnTcnSelChange(NMHDR *pNMHDR, LRESULT *pResult) {
- int sel = m_tabs.GetCurSel();
- switch(sel) {
- case 0:
- m_splitterWnd.ShowWindow(SW_SHOW);
- m_consoleView->ShowWindow(SW_HIDE);
- break;
- case 1:
- m_splitterWnd.ShowWindow(SW_HIDE);
- m_consoleView->ShowWindow(SW_SHOW);
- CRect rect;
- GetWindowRect(rect);
- MoveWindow(rect);
- break;
- }
- }
- /**
- * Shuts down the material editor.
- * /todo BMatt Nerve: Need to warn the user if a file is modified.
- */
- void MEMainFrame::OnFileExit() {
- PostMessage(WM_DESTROY, 0, 0);
- }
- /**
- * Saves the selected material.
- */
- void MEMainFrame::OnFileSaveMaterial() {
- MaterialDoc* material = materialDocManager.GetCurrentMaterialDoc();
- if(material) {
- materialDocManager.SaveMaterial(material);
- }
- }
- /**
- * Saves the selected file.
- */
- void MEMainFrame::OnFileSaveFile() {
-
- idStr filename = m_materialTreeView->GetSaveFilename();
- if(filename.Length() > 0) {
- materialDocManager.SaveFile(filename);
- }
- }
- /**
- * Saves all modified materials.
- */
- void MEMainFrame::OnFileSaveAll() {
- materialDocManager.SaveAllMaterials();
- }
- /**
- * Enables the save material menu item if a material is selected and has been modified.
- */
- void MEMainFrame::OnFileSaveMaterialUpdate(CCmdUI *pCmdUI) {
- MaterialDoc* pDoc = materialDocManager.GetCurrentMaterialDoc();
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- if(pDoc && pDoc->modified) {
- pCmdUI->Enable(TRUE);
- } else {
- pCmdUI->Enable(FALSE);
- }
- }
- /**
- * Enables the Save File menu item if the current file contains a modified material.
- */
- void MEMainFrame::OnFileSaveFileUpdate(CCmdUI *pCmdUI) {
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- if(m_materialTreeView->CanSaveFile()) {
- pCmdUI->Enable(TRUE);
- } else {
- pCmdUI->Enable(FALSE);
- }
- }
- /**
- * Enables the Save All menu item if there are any materials that have been modified.
- */
- void MEMainFrame::OnFileSaveAllUpdate(CCmdUI *pCmdUI) {
-
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- if(materialDocManager.IsAnyModified()) {
- pCmdUI->Enable(TRUE);
- } else {
- pCmdUI->Enable(FALSE);
- }
- }
- /**
- * Apply the selected material.
- */
- void MEMainFrame::OnApplyMaterial() {
- MaterialDoc* material = materialDocManager.GetCurrentMaterialDoc();
- if(material) {
- materialDocManager.ApplyMaterial(material);
- }
- }
- /**
- * Applies all modified materials in the selected file.
- */
- void MEMainFrame::OnApplyFile() {
-
- idStr filename = m_materialTreeView->GetSaveFilename();
- if(filename.Length() > 0) {
- materialDocManager.ApplyFile(filename);
- }
- }
- /**
- * Applies all modified materials.
- */
- void MEMainFrame::OnApplyAll() {
- materialDocManager.ApplyAll();
- }
- /**
- * Enables the Apply Material menu item if the current material has an apply waiting.
- */
- void MEMainFrame::OnApplyMaterialUpdate(CCmdUI *pCmdUI) {
- MaterialDoc* pDoc = materialDocManager.GetCurrentMaterialDoc();
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- if(pDoc && pDoc->applyWaiting) {
- pCmdUI->Enable(TRUE);
- } else {
- pCmdUI->Enable(FALSE);
- }
- }
- /**
- * Enables the apply file menu item if the current file contains any materials
- * that need to be applied.
- */
- void MEMainFrame::OnApplyFileUpdate(CCmdUI *pCmdUI) {
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- MaterialDoc* pDoc = materialDocManager.GetCurrentMaterialDoc();
- if(pDoc && materialDocManager.DoesFileNeedApply(pDoc->renderMaterial->GetFileName())) {
- pCmdUI->Enable(TRUE);
- } else {
- pCmdUI->Enable(FALSE);
- }
- }
- /**
- * Enables the apply all menu item if there are any materials that need
- * to be applied.
- */
- void MEMainFrame::OnApplyAllUpdate(CCmdUI *pCmdUI) {
-
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
-
- if(materialDocManager.DoesAnyNeedApply()) {
- pCmdUI->Enable(TRUE);
- } else {
- pCmdUI->Enable(FALSE);
- }
- }
- /**
- * Performs a cut operation on the selected material.
- */
- void MEMainFrame::OnEditCut() {
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- m_materialTreeView->OnCut();
- }
- }
- }
- /**
- * Performs a copy operation on the selected material or stage.
- */
- void MEMainFrame::OnEditCopy() {
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- m_stageView->OnCopy();
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- m_materialTreeView->OnCopy();
- }
- }
- }
- /**
- * Performs a paste operation on the selected material or stage.
- */
- void MEMainFrame::OnEditPaste() {
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- m_stageView->OnPaste();
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- m_materialTreeView->OnPaste();
- }
- }
- }
- /**
- * Performs a delete operation on the selected material or stage.
- */
- void MEMainFrame::OnEditDelete() {
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- m_stageView->OnDeleteStage();
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- m_materialTreeView->OnDeleteMaterial();
- }
- }
- }
- /**
- * Performs a rename operation on the selected material or stage.
- */
- void MEMainFrame::OnEditRename() {
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- m_stageView->OnRenameStage();
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- m_materialTreeView->OnRenameMaterial();
- }
- }
- }
- /**
- * Enable the cut menu item if a material is selected.
- */
- void MEMainFrame::OnEditCutUpdate(CCmdUI *pCmdUI) {
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- BOOL enable = FALSE;
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- if(m_stageView->CanCut()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- if(m_materialTreeView->CanCut()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(CRichEditCtrl))) {
- enable = TRUE;
- }
- }
- pCmdUI->Enable(enable);
- }
- /**
- * Enables the copy menu item if a material or stage is selected.
- */
- void MEMainFrame::OnEditCopyUpdate(CCmdUI *pCmdUI) {
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- BOOL enable = FALSE;
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- if(m_stageView->CanCopy()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- if(m_materialTreeView->CanCopy()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(CRichEditCtrl))) {
- enable = TRUE;
- }
- }
- pCmdUI->Enable(enable);
- }
- /**
- * Enables a paste operation when a material or stage has been copied.
- */
- void MEMainFrame::OnEditPasteUpdate(CCmdUI *pCmdUI) {
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- BOOL enable = FALSE;
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- if(m_stageView->CanPaste()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- if(m_materialTreeView->CanPaste()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(CRichEditCtrl))) {
- enable = TRUE;
- }
- }
- pCmdUI->Enable(enable);
- }
- /**
- * Enables a delete operation when a material or stage is selected.
- */
- void MEMainFrame::OnEditDeleteUpdate(CCmdUI *pCmdUI) {
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- BOOL enable = FALSE;
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- if(m_stageView->CanDelete()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- if(m_materialTreeView->CanDelete()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(CRichEditCtrl))) {
- enable = TRUE;
- }
- }
- pCmdUI->Enable(enable);
- }
- /**
- * Enables a rename operation when a material, folder or stage is selected.
- */
- void MEMainFrame::OnEditRenameUpdate(CCmdUI *pCmdUI) {
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- BOOL enable = FALSE;
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(StageView))) {
- if(m_stageView->CanRename()) {
- enable = TRUE;
- }
- } else if (focus->IsKindOf(RUNTIME_CLASS(MaterialTreeView))) {
- if(m_materialTreeView->CanRename()) {
- enable = TRUE;
- }
- }
- }
- pCmdUI->Enable(enable);
- }
- /**
- * Opens the find dialog.
- */
- void MEMainFrame::OnEditFind() {
- if (m_find== NULL)
- {
- m_find = new FindDialog(this);
- m_find->Create();
- m_find->ShowWindow(SW_SHOW);
- }
- else
- m_find->SetActiveWindow();
- }
- /**
- * Performs a search with the previously selected search parameters.
- */
- void MEMainFrame::OnEditFindNext() {
- FindNext(NULL);
- }
- /**
- * Performs an undo operation.
- */
- void MEMainFrame::OnEditUndo() {
-
- //Check for undo operation on special windows
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(CRichEditCtrl))) {
- m_materialEditView->m_textView.Undo();
- return;
- }
- }
- materialDocManager.Undo();
- }
- /**
- * Performs a redo operation.
- */
- void MEMainFrame::OnEditRedo() {
-
- //Check for redo operation on special windows
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(CRichEditCtrl))) {
- m_materialEditView->m_textView.Redo();
- return;
- }
- }
- materialDocManager.Redo();
- }
- /**
- * Enables the undo menu item if an undo is available.
- */
- void MEMainFrame::OnEditUndoUpdate(CCmdUI *pCmdUI) {
-
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(CRichEditCtrl))) {
- pCmdUI->Enable(m_materialEditView->m_textView.CanUndo());
- return;
- }
- }
- pCmdUI->Enable(materialDocManager.IsUndoAvailable());
- }
- /**
- * Enables the redo menu item if a redo is available.
- */
- void MEMainFrame::OnEditRedoUpdate(CCmdUI *pCmdUI) {
-
- if(pCmdUI->m_pMenu == NULL) {
- pCmdUI->Enable(TRUE);
- return;
- }
- CWnd* focus = GetFocus();
- if(focus) {
- if (focus->IsKindOf(RUNTIME_CLASS(CRichEditCtrl))) {
- pCmdUI->Enable(m_materialEditView->m_textView.CanRedo());
- return;
- }
- }
- pCmdUI->Enable(materialDocManager.IsRedoAvailable());
- }
- /**
- * Toggles between including the file into the material list and not.
- */
- void MEMainFrame::OnViewIncludeFile() {
-
- CMenu* mmenu = GetMenu();
-
- UINT state = mmenu->GetMenuState(ID_VIEW_INCLUDEFILENAME, MF_BYCOMMAND);
- ASSERT(state != 0xFFFFFFFF);
- if (state & MF_CHECKED) {
- mmenu->CheckMenuItem(ID_VIEW_INCLUDEFILENAME, MF_UNCHECKED | MF_BYCOMMAND);
- m_materialTreeView->InitializeMaterialList(false);
- } else {
- mmenu->CheckMenuItem(ID_VIEW_INCLUDEFILENAME, MF_CHECKED | MF_BYCOMMAND);
- m_materialTreeView->InitializeMaterialList(true);
- }
- }
- /**
- * Executes the reloadARBPrograms console command for convinience.
- */
- void MEMainFrame::OnReloadArbPrograms() {
- cmdSystem->BufferCommandText(CMD_EXEC_NOW, "reloadARBprograms");
- }
- /**
- * Executes the reloadImages command to reload images that have been changed outside
- * of the editor.
- */
- void MEMainFrame::OnReloadImages() {
- cmdSystem->BufferCommandText(CMD_EXEC_NOW, "reloadImages");
- }
- /**
- * Called by the find dialog when it is closing.
- */
- void MEMainFrame::CloseFind() {
- m_find = NULL;
- }
- /**
- * Begins a search based on the provided parameters or the previously used
- * parameters.
- */
- void MEMainFrame::FindNext(MaterialSearchData_t* search) {
- if(search) {
- searchData = *search;
- } else {
- if(!searchData.searched) {
- return;
- }
- }
- //The material tree controls the searching
- if(!m_materialTreeView->FindNextMaterial(&searchData)) {
- MessageBox(va("Unable to find '%s'.", searchData.searchText.c_str()), "Find");
- }
- searchData.searched = true;
- }
- /**
- * Called when the selected material has changed.
- * @param pMaterial The newly selected material.
- */
- void MEMainFrame::MV_OnMaterialSelectionChange(MaterialDoc* pMaterial) {
-
- }
|