mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
DolphinWX: Use std::string over char arrays in MemoryView
This commit is contained in:
parent
6ea82790ba
commit
9db370ea40
@ -3,8 +3,6 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdio>
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <wx/brush.h>
|
#include <wx/brush.h>
|
||||||
#include <wx/chartype.h>
|
#include <wx/chartype.h>
|
||||||
@ -25,6 +23,7 @@
|
|||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "Common/DebugInterface.h"
|
#include "Common/DebugInterface.h"
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
#include "DolphinWX/Globals.h"
|
#include "DolphinWX/Globals.h"
|
||||||
#include "DolphinWX/WxUtils.h"
|
#include "DolphinWX/WxUtils.h"
|
||||||
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
||||||
@ -174,8 +173,7 @@ void CMemoryView::OnPopupMenu(wxCommandEvent& event)
|
|||||||
|
|
||||||
case IDM_COPYHEX:
|
case IDM_COPYHEX:
|
||||||
{
|
{
|
||||||
char temp[24];
|
std::string temp = StringFromFormat("%08x", debugger->ReadExtraMemory(memory, selection));
|
||||||
sprintf(temp, "%08x", debugger->ReadExtraMemory(memory, selection));
|
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(temp)));
|
wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(temp)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -314,29 +312,33 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
|
|||||||
|
|
||||||
if (debugger->IsAlive())
|
if (debugger->IsAlive())
|
||||||
{
|
{
|
||||||
char dis[256] = {0};
|
std::string dis;
|
||||||
u32 mem_data = debugger->ReadExtraMemory(memory, address);
|
u32 mem_data = debugger->ReadExtraMemory(memory, address);
|
||||||
|
|
||||||
if (viewAsType == VIEWAS_FP)
|
if (viewAsType == VIEWAS_FP)
|
||||||
{
|
{
|
||||||
float flt = *(float *)(&mem_data);
|
float flt = *(float *)(&mem_data);
|
||||||
sprintf(dis, "f: %f", flt);
|
dis = StringFromFormat("f: %f", flt);
|
||||||
}
|
}
|
||||||
else if (viewAsType == VIEWAS_ASCII)
|
else if (viewAsType == VIEWAS_ASCII)
|
||||||
{
|
{
|
||||||
u32 a[4] = {(mem_data&0xff000000)>>24,
|
u32 a[4] = {
|
||||||
(mem_data&0xff0000)>>16,
|
(mem_data & 0xff000000) >> 24,
|
||||||
(mem_data&0xff00)>>8,
|
(mem_data & 0xff0000) >> 16,
|
||||||
mem_data&0xff};
|
(mem_data & 0xff00) >> 8,
|
||||||
|
(mem_data & 0xff)
|
||||||
|
};
|
||||||
|
|
||||||
for (auto& word : a)
|
for (auto& word : a)
|
||||||
|
{
|
||||||
if (word == '\0')
|
if (word == '\0')
|
||||||
word = ' ';
|
word = ' ';
|
||||||
sprintf(dis, "%c%c%c%c", a[0], a[1], a[2], a[3]);
|
}
|
||||||
|
|
||||||
|
dis = StringFromFormat("%c%c%c%c", a[0], a[1], a[2], a[3]);
|
||||||
}
|
}
|
||||||
else if (viewAsType == VIEWAS_HEX)
|
else if (viewAsType == VIEWAS_HEX)
|
||||||
{
|
{
|
||||||
dis[0] = 0;
|
|
||||||
dis[1] = 0;
|
|
||||||
u32 mema[8] = {
|
u32 mema[8] = {
|
||||||
debugger->ReadExtraMemory(memory, address),
|
debugger->ReadExtraMemory(memory, address),
|
||||||
debugger->ReadExtraMemory(memory, address+4),
|
debugger->ReadExtraMemory(memory, address+4),
|
||||||
@ -350,51 +352,46 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
|
|||||||
|
|
||||||
for (auto& word : mema)
|
for (auto& word : mema)
|
||||||
{
|
{
|
||||||
char buf[32] = "";
|
|
||||||
switch (dataType)
|
switch (dataType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
sprintf(buf, " %02X %02X %02X %02X",
|
dis += StringFromFormat(" %02X %02X %02X %02X",
|
||||||
((word&0xff000000)>>24)&0xFF,
|
((word & 0xff000000) >> 24) & 0xFF,
|
||||||
((word&0xff0000)>>16)&0xFF,
|
((word & 0xff0000) >> 16) & 0xFF,
|
||||||
((word&0xff00)>>8)&0xFF,
|
((word & 0xff00) >> 8) & 0xFF,
|
||||||
word&0xff);
|
word & 0xff);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sprintf(buf, " %02X%02X %02X%02X",
|
dis += StringFromFormat(" %02X%02X %02X%02X",
|
||||||
((word&0xff000000)>>24)&0xFF,
|
((word & 0xff000000) >> 24) & 0xFF,
|
||||||
((word&0xff0000)>>16)&0xFF,
|
((word & 0xff0000) >> 16) & 0xFF,
|
||||||
((word&0xff00)>>8)&0xFF,
|
((word & 0xff00) >> 8) & 0xFF,
|
||||||
word&0xff);
|
word & 0xff);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sprintf(buf, " %02X%02X%02X%02X",
|
dis += StringFromFormat(" %02X%02X%02X%02X",
|
||||||
((word&0xff000000)>>24)&0xFF,
|
((word & 0xff000000) >> 24) & 0xFF,
|
||||||
((word&0xff0000)>>16)&0xFF,
|
((word & 0xff0000) >> 16) & 0xFF,
|
||||||
((word&0xff00)>>8)&0xFF,
|
((word & 0xff00) >> 8) & 0xFF,
|
||||||
word&0xff);
|
word & 0xff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strcat(dis, buf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(dis, "INVALID VIEWAS TYPE");
|
dis = "INVALID VIEWAS TYPE";
|
||||||
}
|
}
|
||||||
|
|
||||||
char desc[256] = "";
|
|
||||||
if (viewAsType != VIEWAS_HEX)
|
if (viewAsType != VIEWAS_HEX)
|
||||||
dc.DrawText(StrToWxStr(dis), textPlacement + fontSize*(8 + 8), rowY1);
|
dc.DrawText(StrToWxStr(dis), textPlacement + fontSize*(8 + 8), rowY1);
|
||||||
else
|
else
|
||||||
dc.DrawText(StrToWxStr(dis), textPlacement, rowY1);
|
dc.DrawText(StrToWxStr(dis), textPlacement, rowY1);
|
||||||
|
|
||||||
if (desc[0] == 0)
|
|
||||||
strcpy(desc, debugger->GetDescription(address).c_str());
|
|
||||||
|
|
||||||
dc.SetTextForeground(*wxBLUE);
|
dc.SetTextForeground(*wxBLUE);
|
||||||
|
|
||||||
if (strlen(desc))
|
std::string desc = debugger->GetDescription(address);
|
||||||
|
if (!desc.empty())
|
||||||
dc.DrawText(StrToWxStr(desc), 17+fontSize*((8+8+8+30)*2), rowY1);
|
dc.DrawText(StrToWxStr(desc), 17+fontSize*((8+8+8+30)*2), rowY1);
|
||||||
|
|
||||||
// Show blue memory check dot
|
// Show blue memory check dot
|
||||||
|
Loading…
Reference in New Issue
Block a user