mainfrm.cpp
来自「quake3工具源码。包括生成bsp文件」· C++ 代码 · 共 1,788 行 · 第 1/5 页
CPP
1,788 行
MENUITEMINFO MenuItemInfo;
//return;
for (i = 0; i < g_nCommandCount; i++)
{
memset(&MenuItemInfo, 0, sizeof(MENUITEMINFO));
MenuItemInfo.cbSize = sizeof(MENUITEMINFO);
MenuItemInfo.fMask = MIIM_TYPE;
MenuItemInfo.dwTypeData = key;
MenuItemInfo.cch = sizeof(key);
if (!pMenu->GetMenuItemInfo(g_Commands[i].m_nCommand, &MenuItemInfo))
continue;
if (MenuItemInfo.fType != MFT_STRING)
continue;
ptr = strchr(key, '\t');
if (ptr) *ptr = '\0';
strcat(key, "\t");
if (g_Commands[i].m_nModifiers) // are there modifiers present?
{
if (g_Commands[i].m_nModifiers & RAD_SHIFT)
strcat(key, "Shift-");
if (g_Commands[i].m_nModifiers & RAD_ALT)
strcat(key, "Alt-");
if (g_Commands[i].m_nModifiers & RAD_CONTROL)
strcat(key, "Ctrl-");
}
for (j = 0; j < g_nKeyCount; j++)
{
if (g_Commands[i].m_nKey == g_Keys[j].m_nVKKey)
{
strcat(key, g_Keys[j].m_strName);
break;
}
}
if (j >= g_nKeyCount)
{
sprintf(&key[strlen(key)], "%c", g_Commands[i].m_nKey);
}
memset(&MenuItemInfo, 0, sizeof(MENUITEMINFO));
MenuItemInfo.cbSize = sizeof(MENUITEMINFO);
MenuItemInfo.fMask = MIIM_TYPE;
MenuItemInfo.fType = MFT_STRING;
MenuItemInfo.dwTypeData = key;
MenuItemInfo.cch = strlen(key);
SetMenuItemInfo(pMenu->m_hMenu, g_Commands[i].m_nCommand, FALSE, &MenuItemInfo);
}
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//Init3Dfx();
char* pBuffer = g_strAppPath.GetBufferSetLength(_MAX_PATH + 1);
int nResult = ::GetModuleFileName(NULL, pBuffer, _MAX_PATH);
ASSERT(nResult != 0);
pBuffer[g_strAppPath.ReverseFind('\\') + 1] = '\0';
g_strAppPath.ReleaseBuffer();
InitCommonControls ();
g_qeglobals.d_hInstance = AfxGetInstanceHandle();
MFCCreate(AfxGetInstanceHandle());
//g_PrefsDlg.LoadPrefs();
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
UINT nStyle;
UINT nID = (g_PrefsDlg.m_bWideToolbar) ? IDR_TOOLBAR_ADVANCED : IDR_TOOLBAR1;
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(nID))
{
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
}
#if 0
if (!m_wndScaleBar.Create(this) ||
!m_wndScaleBar.LoadToolBar(IDR_TOOLBAR_SCALELOCK))
{
TRACE0("Failed to create scaling toolbar\n");
return -1; // fail to create
}
#endif
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
//m_wndScaleBar.SetBarStyle(m_wndScaleBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
//m_wndScaleBar.EnableDocking(CBRS_ALIGN_ANY);
//m_wndScaleBar.ShowWindow(SW_HIDE);
int nImage;
int nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CAMERATOGGLE);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
m_wndToolBar.GetToolBarCtrl().CheckButton(nID);
}
m_bCamPreview = true;
nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CUBICCLIPPING);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
}
nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_ENTITY);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
}
nIndex = m_wndToolBar.CommandToIndex(ID_VIEW_CLIPPER);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
}
nIndex = m_wndToolBar.CommandToIndex(ID_SELECT_MOUSEROTATE);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
}
nIndex = m_wndToolBar.CommandToIndex(ID_SELECT_MOUSESCALE);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
}
nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKX);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKX, FALSE);
}
nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKY);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKY, FALSE);
}
nIndex = m_wndToolBar.CommandToIndex(ID_SCALELOCKZ);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
m_wndToolBar.GetToolBarCtrl().CheckButton(ID_SCALELOCKZ, FALSE);
}
#ifdef QUAKE3
nIndex = m_wndToolBar.CommandToIndex(ID_DONTSELECTCURVE);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
}
nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_SHOWBOUNDINGBOX);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_SHOWBOUNDINGBOX, TRUE);
}
nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_WELD);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_WELD, TRUE);
}
nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_DRILLDOWN);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
m_wndToolBar.GetToolBarCtrl().CheckButton(ID_PATCH_DRILLDOWN, TRUE);
}
nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_BEND);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
}
nIndex = m_wndToolBar.CommandToIndex(ID_PATCH_INSDEL);
if (nIndex >= 0)
{
m_wndToolBar.GetButtonInfo(nIndex, nID, nStyle, nImage);
m_wndToolBar.SetButtonInfo(nIndex, nID, TBBS_CHECKBOX, nImage);
}
#else
m_wndToolBar.GetToolBarCtrl().HideButton(ID_DONTSELECTCURVE);
m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_SHOWBOUNDINGBOX);
m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_WELD);
m_wndToolBar.GetToolBarCtrl().HideButton(ID_PATCH_WIREFRAME);
#endif
g_nScaleHow = 0;
#ifdef QUAKE3
g_pParentWnd->GetMenu()->DestroyMenu();
CMenu* pMenu = new CMenu();
pMenu->LoadMenu(IDR_MENU_QUAKE3);
g_pParentWnd->SetMenu(pMenu);
#else
CMenu* pMenu = GetMenu();
#endif
m_wndTextureBar.Create(this, IDD_TEXTUREBAR, CBRS_BOTTOM, 7433);
m_wndTextureBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndTextureBar);
g_qeglobals.d_lpMruMenu = CreateMruMenuDefault();
m_bAutoMenuEnable = FALSE;
LoadCommandMap();
ShowMenuItemKeyBindings(pMenu);
CFont* pFont = new CFont();
pFont->CreatePointFont(g_PrefsDlg.m_nStatusSize * 10, "Arial");
m_wndStatusBar.SetFont(pFont);
OnPluginsRefresh();
if (g_PrefsDlg.m_bRunBefore == FALSE)
{
g_PrefsDlg.m_bRunBefore = TRUE;
g_PrefsDlg.SavePrefs();
/*
if (MessageBox("Would you like QERadiant to build and load a default project? If this is the first time you have run QERadiant or you are not familiar with editing QE4 project files directly, this is HIGHLY recommended", "Create a default project?", MB_YESNO) == IDYES)
{
OnFileNewproject();
}
*/
}
else
{
// hack that keeps SGI OpenGL from crashing on texture load with no map
#if 0
if (g_PrefsDlg.m_bSGIOpenGL)
{
vec3_t vMin, vMax;
vMin[0] = vMin[1] = vMin[2] = 0;
vMax[0] = vMax[1] = vMax[2] = 8;
brush_t* pBrush = Brush_Create(vMin, vMax, &g_qeglobals.d_texturewin.texdef);
Entity_LinkBrush (world_entity, pBrush);
Brush_Build(pBrush);
Brush_AddToList (pBrush, &active_brushes);
Select_Brush(pBrush);
Sys_UpdateWindows(W_ALL);
PostMessage(WM_COMMAND, ID_SELECTION_DELETE, 0);
}
#endif
// load plugins before the first Map_LoadFile
// required for model plugins
if (g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0)
Map_LoadFile(g_PrefsDlg.m_strLastMap.GetBuffer(0));
}
SetGridStatus();
SetTexValStatus();
SetButtonMenuStates();
LoadBarState("RadiantToolBars2");
if (!g_PrefsDlg.m_bTextureBar)
ShowControlBar(&m_wndTextureBar, FALSE, TRUE);
else
ShowControlBar(&m_wndTextureBar, TRUE, TRUE);
ShowControlBar(&m_wndToolBar, (m_wndToolBar.GetStyle() & WS_VISIBLE), TRUE);
SetActiveXY(m_pXYWnd);
m_pXYWnd->SetFocus();
PostMessage(WM_KEYDOWN, 'O', NULL);
return 0;
}
void CMainFrame::LoadCommandMap()
{
CString strINI;
char* pBuff = new char[1024];
if (g_PrefsDlg.m_strUserPath.GetLength() > 0)
strINI = g_PrefsDlg.m_strUserPath;
else
{
strINI = g_strAppPath;
strINI += "\\radiant.ini";
}
for (int i = 0; i < g_nCommandCount; i++)
{
int nLen = GetPrivateProfileString("Commands", g_Commands[i].m_strCommand, "", pBuff, 1024, strINI);
if (nLen > 0)
{
CString strBuff = pBuff;
strBuff.TrimLeft();
strBuff.TrimRight();
int nSpecial = strBuff.Find("+alt");
g_Commands[i].m_nModifiers = 0;
if (nSpecial >= 0)
{
g_Commands[i].m_nModifiers |= RAD_ALT;
FindReplace(strBuff, "+alt", "");
}
nSpecial = strBuff.Find("+ctrl");
if (nSpecial >= 0)
{
g_Commands[i].m_nModifiers |= RAD_CONTROL;
FindReplace(strBuff, "+ctrl", "");
}
nSpecial = strBuff.Find("+shift");
if (nSpecial >= 0)
{
g_Commands[i].m_nModifiers |= RAD_SHIFT;
FindReplace(strBuff, "+shift", "");
}
strBuff.TrimLeft();
strBuff.TrimRight();
strBuff.MakeUpper();
if (nLen == 1) // most often case.. deal with first
{
g_Commands[i].m_nKey = __toascii(strBuff.GetAt(0));
}
else // special key
{
for (int j = 0; j < g_nKeyCount; j++)
{
if (strBuff.CompareNoCase(g_Keys[j].m_strName) == 0)
{
g_Commands[i].m_nKey = g_Keys[j].m_nVKKey;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?