project64/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp

119 lines
3.0 KiB
C++
Raw Normal View History

2017-08-18 05:08:22 +00:00
#include "stdafx.h"
#include "DebuggerUI.h"
#include "Symbols.h"
2019-12-25 00:41:20 +00:00
LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
2017-08-18 05:08:22 +00:00
{
2019-12-25 00:41:20 +00:00
CenterWindow();
m_AddressEdit.Attach(GetDlgItem(IDC_ADDR_EDIT));
m_AddressEdit.SetDisplayType(CEditNumber32::DisplayHex);
m_TypeComboBox.Attach(GetDlgItem(IDC_TYPE_COMBOBOX));
m_NameEdit.Attach(GetDlgItem(IDC_NAME_EDIT));
m_DescriptionEdit.Attach(GetDlgItem(IDC_DESC_EDIT));
for (int i = 0;; i++)
{
const char* typeName = CSymbolTable::m_SymbolTypes[i].name;
2021-04-12 11:35:39 +00:00
if (typeName == nullptr)
2019-12-25 00:41:20 +00:00
{
break;
}
2020-05-12 12:19:05 +00:00
m_TypeComboBox.AddString(stdstr(typeName).ToUTF16().c_str());
2019-12-25 00:41:20 +00:00
}
2020-05-12 12:19:05 +00:00
m_AddressEdit.SetWindowText(L"");
2019-12-25 00:41:20 +00:00
m_AddressEdit.SetFocus();
if (m_bHaveAddress)
{
m_AddressEdit.SetValue(m_InitAddress, DisplayMode::ZeroExtend);
2019-12-25 00:41:20 +00:00
m_TypeComboBox.SetFocus();
}
if(m_bHaveType)
{
m_TypeComboBox.SetCurSel(m_InitType);
m_NameEdit.SetFocus();
}
else
{
m_TypeComboBox.SetCurSel(SYM_DATA);
}
return FALSE;
2017-08-18 05:08:22 +00:00
}
2018-01-18 06:53:07 +00:00
LRESULT CAddSymbolDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
2017-08-18 05:08:22 +00:00
{
2019-12-25 00:41:20 +00:00
switch (wID)
{
case IDCANCEL:
EndDialog(0);
break;
case IDOK:
2020-05-12 12:19:05 +00:00
int addrLen = m_AddressEdit.GetWindowTextLength();
2019-12-25 00:41:20 +00:00
if (!addrLen)
{
2020-05-12 12:19:05 +00:00
MessageBox(L"Address required", L"Error", MB_OK);
2019-12-25 00:41:20 +00:00
return 0;
}
uint32_t address = m_AddressEdit.GetValue();
int type = m_TypeComboBox.GetCurSel();
2020-05-12 12:19:05 +00:00
int nameLen = m_NameEdit.GetWindowTextLength();
int descLen = m_DescriptionEdit.GetWindowTextLength();
2019-12-25 00:41:20 +00:00
if (!nameLen && !descLen)
{
2020-05-12 12:19:05 +00:00
MessageBox(L"Name and/or description required", L"Error", MB_OK);
2019-12-25 00:41:20 +00:00
return 0;
}
2020-05-12 12:19:05 +00:00
wchar_t name[128];
wchar_t description[256];
2019-12-25 00:41:20 +00:00
2020-05-12 12:19:05 +00:00
m_NameEdit.GetWindowText(name, nameLen + 1);
m_DescriptionEdit.GetWindowText(description, descLen + 1);
2019-12-25 00:41:20 +00:00
2020-05-12 12:19:05 +00:00
m_Debugger->SymbolTable()->AddSymbol(type, address, stdstr().FromUTF16(name).c_str(), stdstr().FromUTF16(description).c_str());
2019-12-25 00:41:20 +00:00
m_Debugger->SymbolTable()->Save();
m_Debugger->Debug_RefreshSymbolsWindow();
EndDialog(0);
break;
}
return 0;
2017-08-18 05:08:22 +00:00
}
INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger)
{
2019-12-25 00:41:20 +00:00
m_Debugger = debugger;
m_bHaveAddress = false;
m_bHaveType = false;
return CDialogImpl<CAddSymbolDlg>::DoModal();
2017-08-18 05:08:22 +00:00
}
INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger, uint32_t initAddress)
{
2019-12-25 00:41:20 +00:00
m_Debugger = debugger;
m_bHaveAddress = true;
m_bHaveType = false;
m_InitAddress = initAddress;
return CDialogImpl<CAddSymbolDlg>::DoModal();
2017-08-18 05:08:22 +00:00
}
INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger, uint32_t initAddress, int initType)
{
2019-12-25 00:41:20 +00:00
m_Debugger = debugger;
m_bHaveAddress = true;
m_bHaveType = true;
m_InitAddress = initAddress;
m_InitType = initType;
return CDialogImpl<CAddSymbolDlg>::DoModal();
}