doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MaterialEditor.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
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.
13 
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.
18 
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/>.
21 
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.
23 
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.
25 
26 ===========================================================================
27 */
28 #include "../../idlib/precompiled.h"
29 #pragma hdrstop
30 
31 #include "../../sys/win32/win_local.h"
32 
33 #include "MaterialEditor.h"
34 #include "MEMainFrame.h"
35 
36 #ifdef _DEBUG
37 #define new DEBUG_NEW
38 #endif
39 
41 
43 
47 void MaterialEditorInit( void ) {
48 
50 
52 
53  Sys_GrabMouseCursor( false );
54 
55  InitAfx();
56 
57  InitCommonControls();
58 
59  // Initialize OLE libraries
60  if (!AfxOleInit())
61  {
62  return;
63  }
64  AfxEnableControlContainer();
65 
66  NONCLIENTMETRICS info;
67  info.cbSize = sizeof(info);
68 
69  ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0);
70 
71  LOGFONT lf;
72  memset(&lf, 0, sizeof (LOGFONT));
73 
74  CWindowDC dc(NULL);
75  lf.lfCharSet = (BYTE)GetTextCharsetInfo(dc.GetSafeHdc(), NULL, 0);
76 
77  lf.lfHeight = info.lfMenuFont.lfHeight;
78  lf.lfWeight = info.lfMenuFont.lfWeight;
79  lf.lfItalic = info.lfMenuFont.lfItalic;
80 
81  // check if we should use system font
82  _tcscpy(lf.lfFaceName, info.lfMenuFont.lfFaceName);
83 
84  materialEditorFont = new CFont;
85  materialEditorFont->CreateFontIndirect(&lf);
86 
87 
88  // To create the main window, this code creates a new frame window
89  // object and then sets it as the application's main window object
90  meMainFrame = new MEMainFrame;
91 
92  // create and load the frame with its resources
93  meMainFrame->LoadFrame(IDR_ME_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL);
94 
95 
96  // hide the doom window by default
97  ::ShowWindow ( win32.hWnd, SW_HIDE );
98 
99  // The one and only window has been initialized, so show and update it
100  meMainFrame->ShowWindow(SW_SHOW);
101  meMainFrame->UpdateWindow();
102 }
103 
107 void MaterialEditorRun( void ) {
108 
109  MSG *msg = AfxGetCurrentMessage();
110 
111  while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
112  // pump message
113  if ( !AfxGetApp()->PumpMessage() ) {
114  }
115  }
116 }
117 
122 
123  delete meMainFrame;
124 
125  delete materialEditorFont;
126 
127  meMainFrame = NULL;
128 }
129 
133 void MaterialEditorPrintConsole( const char *msg ) {
135  meMainFrame->PrintConsoleMessage(msg);
136 }
137 
142  return meMainFrame->GetSafeHwnd();
143 }
144 
148 class CAboutDlg : public CDialog
149 {
150 public:
151  CAboutDlg();
152 
153  enum { IDD = IDD_ME_ABOUTBOX };
154 
155 protected:
156  virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
157 
158  DECLARE_MESSAGE_MAP()
159 };
160 
164 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) {
165 }
166 
170 void CAboutDlg::DoDataExchange(CDataExchange* pDX) {
171  CDialog::DoDataExchange(pDX);
172 }
173 
174 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
175 END_MESSAGE_MAP()
176 
Simple about box for the material editor.
CAboutDlg()
Constructor for the about box.
MEMainFrame * meMainFrame
#define IDD_ME_ABOUTBOX
void PrintConsoleMessage(const char *msg)
Called to add console text to the console view.
#define IDR_ME_MAINFRAME
virtual void DoDataExchange(CDataExchange *pDX)
Called by the MFC framework to exchange data with the window controls.
void InitAfx(void)
Definition: StdAfx.cpp:53
int com_editors
Definition: Common.cpp:97
void InitPropTree(HINSTANCE hInstance)
Definition: PropTree.cpp:62
#define NULL
Definition: Lib.h:88
void MaterialEditorRun(void)
Called every frame by the doom engine to allow the material editor to process messages.
void MaterialEditorPrintConsole(const char *msg)
Allows the doom engine to reflect console output to the material editors console. ...
void MaterialEditorShutdown(void)
Called by the doom engine when the material editor needs to be destroyed.
HWND GetMaterialEditorWindow()
Returns the handle to the main Material Editor Window.
CFont * materialEditorFont
void MaterialEditorInit(void)
Initializes the material editor tool.
HINSTANCE hInstance
Definition: win_local.h:102
Win32Vars_t win32
Definition: win_main.cpp:65
void Sys_GrabMouseCursor(bool)
Definition: dedicated.cpp:43
The main window for the material editor.
Definition: MEMainFrame.h:47