summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/Debugger/BreakpointDlg.cpp
blob: 9665bb271ecbb1f5e48e9b3b10c6210c31fe793c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <string>
#include <wx/dialog.h>
#include <wx/msgdlg.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>

#include "Common/BreakPoints.h"
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
#include "Core/PowerPC/PowerPC.h"
#include "DolphinWX/Debugger/BreakpointDlg.h"
#include "DolphinWX/Debugger/BreakpointWindow.h"
#include "DolphinWX/WxUtils.h"

BreakPointDlg::BreakPointDlg(CBreakPointWindow* _Parent)
    : wxDialog(_Parent, wxID_ANY, _("Add Breakpoint")), Parent(_Parent)
{
  Bind(wxEVT_BUTTON, &BreakPointDlg::OnOK, this, wxID_OK);

  m_pEditAddress = new wxTextCtrl(this, wxID_ANY, "80000000");

  wxBoxSizer* sMainSizer = new wxBoxSizer(wxVERTICAL);
  sMainSizer->Add(m_pEditAddress, 0, wxEXPAND | wxALL, 5);
  sMainSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALL, 5);

  SetSizerAndFit(sMainSizer);
  SetFocus();
}

void BreakPointDlg::OnOK(wxCommandEvent& event)
{
  wxString AddressString = m_pEditAddress->GetLineText(0);
  u32 Address = 0;
  if (AsciiToHex(WxStrToStr(AddressString), Address))
  {
    PowerPC::breakpoints.Add(Address);
    Parent->NotifyUpdate();
    Close();
  }
  else
  {
    WxUtils::ShowErrorDialog(
        wxString::Format(_("The address %s is invalid."), WxStrToStr(AddressString).c_str()));
  }

  event.Skip();
}