Added new editor layout similar to idTech 5.

Cleaned up the entity inspector.
Fixed numerous radiant bugs.
This commit is contained in:
Justin Marshall
2026-05-06 12:47:20 -07:00
parent baeae00185
commit 1a08d4af90
11 changed files with 3883 additions and 723 deletions
+255 -87
View File
@@ -2,26 +2,7 @@
===========================================================================
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.
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
===========================================================================
*/
@@ -36,71 +17,156 @@ If you have questions concerning this license or the applicable additional terms
#include "InspectorDialog.h"
#include "TabsDlg.h"
CInspectorDialog *g_Inspectors = NULL;
// CInspectorDialog dialog
CInspectorDialog* g_Inspectors = NULL;
void InspectorsDockingCallback ( bool docked , int ID , CWnd* wnd )
{
g_Inspectors->SetDockedTabs( docked , ID );
static const COLORREF INSPECTOR_BG = RGB(245, 247, 250);
static const COLORREF INSPECTOR_PANEL_BG = RGB(255, 255, 255);
static const COLORREF INSPECTOR_TEXT = RGB(32, 36, 42);
static const COLORREF INSPECTOR_MUTED_TEXT = RGB(88, 96, 105);
static const COLORREF INSPECTOR_BORDER = RGB(218, 223, 230);
static const int INSPECTOR_MARGIN = 8;
static const int INSPECTOR_TAB_HEIGHT = 42;
static const int INSPECTOR_DIVIDER_HEIGHT = 1;
void InspectorsDockingCallback(bool docked, int ID, CWnd* wnd) {
if (g_Inspectors) {
g_Inspectors->SetDockedTabs(docked, ID);
}
}
// CInspectorDialog dialog
//IMPLEMENT_DYNAMIC(CInspectorDialog,CTabsDlg)
CInspectorDialog::CInspectorDialog(CWnd* pParent /*=NULL*/)
: CTabsDlg(CInspectorDialog::IDD, pParent)
{
: CTabsDlg(CInspectorDialog::IDD, pParent) {
initialized = false;
dockedTabs = W_CONSOLE | W_TEXTURE | W_MEDIA;
}
CInspectorDialog::~CInspectorDialog()
{
CInspectorDialog::~CInspectorDialog() {
if (modernFont.GetSafeHandle()) {
modernFont.DeleteObject();
}
if (bgBrush.GetSafeHandle()) {
bgBrush.DeleteObject();
}
if (editBrush.GetSafeHandle()) {
editBrush.DeleteObject();
}
if (staticBrush.GetSafeHandle()) {
staticBrush.DeleteObject();
}
}
BEGIN_MESSAGE_MAP(CInspectorDialog, CTabsDlg)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_INSPECTOR, OnTcnSelchange )
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_INSPECTOR, OnTcnSelchange)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_CLOSE()
ON_WM_CTLCOLOR()
ON_WM_ERASEBKGND()
ON_WM_PAINT()
END_MESSAGE_MAP()
// CInspectorDialog message handlers
BOOL CInspectorDialog::OnInitDialog()
{
BOOL CInspectorDialog::OnInitDialog() {
CTabsDlg::OnInitDialog();
ASSERT ( m_Tabs.GetSafeHwnd() );
ASSERT(m_Tabs.GetSafeHwnd());
LoadWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );
LoadWindowPlacement(GetSafeHwnd(), "radiant_InspectorsWindow");
consoleWnd.Create(IDD_DIALOG_CONSOLE, this);
texWnd.Create(TEXTURE_WINDOW_CLASS, "", QE3_SPLITTER_STYLE, CRect(5, 5, 10, 10), this, 1299);
mediaDlg.Create(IDD_DIALOG_TEXTURELIST, this);
entityDlg.Create(IDD_DIALOG_ENTITY, this);
dockedTabs = GetCvarInt ( "radiant_InspectorDockedDialogs" , W_CONSOLE | W_TEXTURE | W_MEDIA );
dockedTabs = GetCvarInt("radiant_InspectorDockedDialogs", W_CONSOLE | W_TEXTURE | W_MEDIA);
AddDockedWindow(&consoleWnd, W_CONSOLE, 1, "Console", (dockedTabs & W_CONSOLE) != 0, InspectorsDockingCallback);
AddDockedWindow(&texWnd, W_TEXTURE, 2, "Textures", (dockedTabs & W_TEXTURE) != 0, InspectorsDockingCallback);
AddDockedWindow(&mediaDlg, W_MEDIA, 3, "Media", (dockedTabs & W_MEDIA) != 0, InspectorsDockingCallback);
AddDockedWindow(&entityDlg, W_ENTITY, 4, "Entity", (dockedTabs & W_ENTITY) != 0, InspectorsDockingCallback);
ApplyModernTheme();
SetMode(W_CONSOLE);
AddDockedWindow ( &consoleWnd , W_CONSOLE , 1 , "Console" , (dockedTabs & W_CONSOLE ) != 0 , InspectorsDockingCallback );
AddDockedWindow ( &texWnd , W_TEXTURE , 2 , "Textures" , (dockedTabs & W_TEXTURE ) != 0 , InspectorsDockingCallback );
AddDockedWindow ( &mediaDlg , W_MEDIA , 3 , "Media" , (dockedTabs & W_MEDIA ) != 0 , InspectorsDockingCallback );
AddDockedWindow ( &entityDlg , W_ENTITY , 4 , "Entity" , (dockedTabs & W_ENTITY ) != 0 , InspectorsDockingCallback );
SetMode(W_CONSOLE);
initialized = true;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
CRect rc;
GetClientRect(&rc);
LayoutModern(rc.Width(), rc.Height());
return TRUE;
}
void CInspectorDialog::ApplyModernTheme() {
if (!modernFont.GetSafeHandle()) {
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
HDC hDC = ::GetDC(GetSafeHwnd());
const int dpiY = GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(GetSafeHwnd(), hDC);
lf.lfHeight = -MulDiv(9, dpiY, 72);
lf.lfWeight = FW_NORMAL;
lf.lfQuality = CLEARTYPE_QUALITY;
strncpy(lf.lfFaceName, "Segoe UI", sizeof(lf.lfFaceName) - 1);
lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
modernFont.CreateFontIndirect(&lf);
}
if (!bgBrush.GetSafeHandle()) {
bgBrush.CreateSolidBrush(INSPECTOR_BG);
}
if (!editBrush.GetSafeHandle()) {
editBrush.CreateSolidBrush(INSPECTOR_PANEL_BG);
}
if (!staticBrush.GetSafeHandle()) {
staticBrush.CreateSolidBrush(INSPECTOR_BG);
}
SetFont(&modernFont, FALSE);
if (m_Tabs.GetSafeHwnd()) {
m_Tabs.SetFont(&modernFont, FALSE);
m_Tabs.ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
}
ApplyModernFontRecursive(&consoleWnd);
ApplyModernFontRecursive(&mediaDlg);
ApplyModernFontRecursive(&entityDlg);
ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
Invalidate(TRUE);
}
void CInspectorDialog::ApplyModernFontRecursive(CWnd* wnd) {
if (!wnd || !wnd->GetSafeHwnd() || !modernFont.GetSafeHandle()) {
return;
}
wnd->SetFont(&modernFont, FALSE);
CWnd* child = wnd->GetWindow(GW_CHILD);
while (child) {
child->SetFont(&modernFont, FALSE);
child = child->GetNextWindow();
}
}
void CInspectorDialog::SetMode(int mode, bool updateTabs) {
FocusWindow ( mode );
FocusWindow(mode);
}
void CInspectorDialog::UpdateEntitySel(eclass_t *ent) {
void CInspectorDialog::UpdateEntitySel(eclass_t* ent) {
entityDlg.UpdateEntitySel(ent);
}
@@ -112,80 +178,183 @@ void CInspectorDialog::UpdateSelectedEntity() {
entityDlg.SetKeyValPairs();
}
bool CInspectorDialog::GetSelectAllCriteria(idStr &key, idStr &val) {
CString k, v;
bool CInspectorDialog::GetSelectAllCriteria(idStr& key, idStr& val) {
CString k;
CString v;
entityDlg.editKey.GetWindowText(k);
entityDlg.editVal.GetWindowText(v);
key = k;
val = v;
return true;
}
void CInspectorDialog::LayoutModern(int cx, int cy) {
if (!initialized || cx <= 0 || cy <= 0) {
return;
}
const int margin = INSPECTOR_MARGIN;
void CInspectorDialog::OnSize(UINT nType, int cx, int cy)
{
CTabsDlg::OnSize(nType, cx, cy);
CRect tabRect;
tabRect.left = margin;
tabRect.right = cx - margin;
tabRect.bottom = cy - margin;
tabRect.top = tabRect.bottom - INSPECTOR_TAB_HEIGHT;
if (tabRect.top < margin) {
tabRect.top = margin;
}
if (m_Tabs.GetSafeHwnd()) {
m_Tabs.SetWindowPos(
NULL,
tabRect.left,
tabRect.top,
tabRect.Width(),
tabRect.Height(),
SWP_NOZORDER | SWP_NOACTIVATE
);
}
CRect childRect;
childRect.left = margin;
childRect.top = margin;
childRect.right = cx - margin;
childRect.bottom = tabRect.top - margin;
if (childRect.right < childRect.left) {
childRect.right = childRect.left;
}
if (childRect.bottom < childRect.top) {
childRect.bottom = childRect.top;
}
DockedWindowInfo* info = NULL;
POSITION pos;
WORD wID;
for (pos = m_Windows.GetStartPosition(); pos != NULL; ) {
m_Windows.GetNextAssoc(pos, wID, (void*&)info);
if (info && info->m_Window && info->m_Window->GetSafeHwnd() && info->m_State == DockedWindowInfo::DOCKED) {
info->m_Window->SetWindowPos(
NULL,
childRect.left,
childRect.top,
childRect.Width(),
childRect.Height(),
SWP_NOZORDER | SWP_NOACTIVATE
);
info->m_Window->ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
}
}
}
void CInspectorDialog::OnSize(UINT nType, int cx, int cy) {
CTabsDlg::OnSize(nType, cx, cy);
if (!initialized) {
return;
}
CRect rect;
GetClientRect(rect);
LayoutModern(cx, cy);
Invalidate(FALSE);
}
CRect tabRect;
m_Tabs.GetWindowRect(tabRect);
// retain vert size but size 4 in from edges and 4 up from bottom
tabRect.left = 4;
tabRect.right = rect.Width() - 4;
tabRect.top = rect.Height() - tabRect.Height() - 4;
tabRect.bottom = rect.Height() - 4;
// adjust rect for children size
rect.bottom -= 5 + tabRect.Height();
BOOL CInspectorDialog::OnEraseBkgnd(CDC* pDC) {
CRect rc;
GetClientRect(&rc);
m_Tabs.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), 0);
pDC->FillSolidRect(&rc, INSPECTOR_BG);
for( pos = m_Windows.GetStartPosition(); pos != NULL ; )
{
m_Windows.GetNextAssoc( pos, wID, (void*&)info );
return TRUE;
}
if ( (info->m_State == DockedWindowInfo::DOCKED) ) {
info->m_Window->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), 0);
}
void CInspectorDialog::OnPaint() {
CPaintDC dc(this);
CRect rc;
GetClientRect(&rc);
dc.FillSolidRect(&rc, INSPECTOR_BG);
if (m_Tabs.GetSafeHwnd()) {
CRect tabRect;
m_Tabs.GetWindowRect(&tabRect);
ScreenToClient(&tabRect);
CRect lineRect;
lineRect.left = INSPECTOR_MARGIN;
lineRect.right = rc.Width() - INSPECTOR_MARGIN;
lineRect.top = tabRect.top - (INSPECTOR_MARGIN / 2);
lineRect.bottom = lineRect.top + INSPECTOR_DIVIDER_HEIGHT;
dc.FillSolidRect(&lineRect, INSPECTOR_BORDER);
}
}
void CInspectorDialog::OnDestroy()
{
::SaveWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );
SetCvarInt("radiant_InspectorDockedDialogs" , dockedTabs );
HBRUSH CInspectorDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
HBRUSH hbr = CTabsDlg::OnCtlColor(pDC, pWnd, nCtlColor);
if (!pDC) {
return hbr;
}
pDC->SetTextColor(INSPECTOR_TEXT);
switch (nCtlColor) {
case CTLCOLOR_DLG:
pDC->SetBkColor(INSPECTOR_BG);
return (HBRUSH)bgBrush.GetSafeHandle();
case CTLCOLOR_STATIC:
pDC->SetBkColor(INSPECTOR_BG);
pDC->SetTextColor(INSPECTOR_MUTED_TEXT);
return (HBRUSH)staticBrush.GetSafeHandle();
case CTLCOLOR_EDIT:
case CTLCOLOR_LISTBOX:
pDC->SetBkColor(INSPECTOR_PANEL_BG);
pDC->SetTextColor(INSPECTOR_TEXT);
return (HBRUSH)editBrush.GetSafeHandle();
case CTLCOLOR_BTN:
pDC->SetBkColor(INSPECTOR_BG);
pDC->SetTextColor(INSPECTOR_TEXT);
return (HBRUSH)bgBrush.GetSafeHandle();
default:
break;
}
return hbr;
}
void CInspectorDialog::OnDestroy() {
::SaveWindowPlacement(GetSafeHwnd(), "radiant_InspectorsWindow");
SetCvarInt("radiant_InspectorDockedDialogs", dockedTabs);
CTabsDlg::OnDestroy();
}
void CInspectorDialog::OnClose()
{
void CInspectorDialog::OnClose() {
CTabsDlg::OnClose();
}
BOOL CInspectorDialog::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) {
BOOL CInspectorDialog::PreTranslateMessage(MSG* pMsg) {
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) {
g_pParentWnd->PostMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
}
return CTabsDlg::PreTranslateMessage(pMsg);
}
void CInspectorDialog::SetDockedTabs ( bool docked , int ID )
{
if ( docked ) {
void CInspectorDialog::SetDockedTabs(bool docked, int ID) {
if (docked) {
dockedTabs |= ID;
}
else {
@@ -193,7 +362,6 @@ void CInspectorDialog::SetDockedTabs ( bool docked , int ID )
}
}
void CInspectorDialog::AssignModel ()
{
void CInspectorDialog::AssignModel() {
entityDlg.AssignModel();
}
}