| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program 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.
- **
- ** This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
- // MemLogDialog.cpp : implementation file
- //
- #include "stdafx.h"
- #include "leveledit.h"
- #include "memlogdialog.h"
- #include "wwmemlog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Constants
- /////////////////////////////////////////////////////////////////////////////
- enum
- {
- COL_NAME = 0,
- COL_CURRENT,
- COL_PEAK,
- };
- /////////////////////////////////////////////////////////////////////////////
- //
- // MemLogDialogClass
- //
- /////////////////////////////////////////////////////////////////////////////
- MemLogDialogClass::MemLogDialogClass(CWnd* pParent /*=NULL*/)
- : CDialog(MemLogDialogClass::IDD, pParent)
- {
- //{{AFX_DATA_INIT(MemLogDialogClass)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- return ;
- }
- /////////////////////////////////////////////////////////////////////////////
- //
- // DoDataExchange
- //
- /////////////////////////////////////////////////////////////////////////////
- void
- MemLogDialogClass::DoDataExchange (CDataExchange *pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(MemLogDialogClass)
- DDX_Control(pDX, IDC_MEM_USAGE_LIST, m_ListCtrl);
- //}}AFX_DATA_MAP
- return ;
- }
- BEGIN_MESSAGE_MAP(MemLogDialogClass, CDialog)
- //{{AFX_MSG_MAP(MemLogDialogClass)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- //
- // OnInitDialog
- //
- /////////////////////////////////////////////////////////////////////////////
- BOOL
- MemLogDialogClass::OnInitDialog (void)
- {
- CDialog::OnInitDialog ();
- //
- // Configure the columns
- //
- m_ListCtrl.InsertColumn (COL_NAME, "Name");
- m_ListCtrl.InsertColumn (COL_CURRENT, "Current Usage");
- m_ListCtrl.InsertColumn (COL_PEAK, "Peak Usage");
- m_ListCtrl.SetExtendedStyle (m_ListCtrl.GetExtendedStyle () | LVS_EX_FULLROWSELECT);
-
- //
- // Choose an appropriate size for the columns
- //
- CRect rect;
- m_ListCtrl.GetClientRect (&rect);
- rect.right -= ::GetSystemMetrics (SM_CXVSCROLL) + 2;
- m_ListCtrl.SetColumnWidth (COL_NAME, (rect.Width () * 3) / 5);
- m_ListCtrl.SetColumnWidth (COL_CURRENT, rect.Width () / 5);
- m_ListCtrl.SetColumnWidth (COL_PEAK, rect.Width () / 5);
-
- //
- // Loop over all the categories in the logger
- //
- int count = WWMemoryLogClass::Get_Category_Count ();
- for (int index = 0; index < count; index ++) {
- const char *name = WWMemoryLogClass::Get_Category_Name (index);
- int current_mem = WWMemoryLogClass::Get_Current_Allocated_Memory (index);
- int peak_mem = WWMemoryLogClass::Get_Peak_Allocated_Memory (index);
- //
- // Insert this category in the list
- //
- int item_index = m_ListCtrl.InsertItem (index, name);
- if (item_index >= 0) {
- CString current_mem_string;
- CString peak_mem_string;
- current_mem_string.Format ("%.2f KB", (float)current_mem / 1024.0F);
- peak_mem_string.Format ("%.2f KB", (float)peak_mem / 1024.0F);
- m_ListCtrl.SetItemText (item_index, COL_CURRENT, current_mem_string);
- m_ListCtrl.SetItemText (item_index, COL_PEAK, peak_mem_string);
- }
- }
-
- return TRUE;
- }
|