GE Debugger: Add breakpoint icon in state.

This commit is contained in:
Unknown W. Brackets 2022-02-05 19:00:31 -08:00
parent 4de217d3e4
commit 1bb1f34af0
8 changed files with 76 additions and 20 deletions

BIN
Windows/BreakpointSmall.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

View File

@ -15,6 +15,7 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Windows/resource.h"
#include "Windows/InputBox.h"
@ -28,17 +29,22 @@
using namespace GPUBreakpoints;
// TODO: Show an icon or something for breakpoints, toggle.
// First column is the breakpoint icon.
static const GenericListViewColumn stateValuesCols[] = {
{ L"Name", 0.50f },
{ L"Value", 0.50f },
{ L"", 0.03f },
{ L"Name", 0.40f },
{ L"Value", 0.57f },
};
GenericListViewDef stateValuesListDef = {
stateValuesCols, ARRAY_SIZE(stateValuesCols), NULL, false
stateValuesCols,
ARRAY_SIZE(stateValuesCols),
nullptr,
false,
};
enum StateValuesCols {
STATEVALUES_COL_BREAKPOINT,
STATEVALUES_COL_NAME,
STATEVALUES_COL_VALUE,
};
@ -279,9 +285,28 @@ static void ToggleWatchList(const TabStateRow &info) {
watchList.push_back(info);
}
static bool ToggleBreakpoint(const TabStateRow &info) {
if (IsCmdBreakpoint(info.cmd)) {
RemoveCmdBreakpoint(info.cmd);
RemoveCmdBreakpoint(info.otherCmd);
RemoveCmdBreakpoint(info.otherCmd2);
return false;
}
AddCmdBreakpoint(info.cmd);
if (info.otherCmd) {
AddCmdBreakpoint(info.otherCmd);
}
if (info.otherCmd2) {
AddCmdBreakpoint(info.otherCmd2);
}
return true;
}
CtrlStateValues::CtrlStateValues(const TabStateRow *rows, int rowCount, HWND hwnd)
: GenericListControl(hwnd, stateValuesListDef),
rows_(rows), rowCount_(rowCount) {
SetIconList(12, 12, { (HICON)LoadIcon(GetModuleHandle(0), (LPCWSTR)IDI_BREAKPOINT_SMALL) });
Update();
}
@ -810,6 +835,10 @@ void CtrlStateValues::GetColumnText(wchar_t *dest, int row, int col) {
}
switch (col) {
case STATEVALUES_COL_BREAKPOINT:
wcscpy(dest, L" ");
break;
case STATEVALUES_COL_NAME:
wcscpy(dest, rows_[row].title);
break;
@ -835,11 +864,17 @@ void CtrlStateValues::GetColumnText(wchar_t *dest, int row, int col) {
}
void CtrlStateValues::OnDoubleClick(int row, int column) {
if (gpuDebug == NULL) {
if (gpuDebug == nullptr || row > rowCount_) {
return;
}
const auto info = rows_[row];
if (column == STATEVALUES_COL_BREAKPOINT) {
SetItemState(row, ToggleBreakpoint(info) ? 1 : 0);
return;
}
switch (info.fmt) {
case CMD_FMT_FLAG:
{
@ -887,19 +922,7 @@ void CtrlStateValues::OnRightClick(int row, int column, const POINT &point) {
switch (TriggerContextMenu(ContextMenuID::GEDBG_STATE, GetHandle(), ContextPoint::FromClient(point)))
{
case ID_DISASM_TOGGLEBREAKPOINT:
if (IsCmdBreakpoint(info.cmd)) {
RemoveCmdBreakpoint(info.cmd);
RemoveCmdBreakpoint(info.otherCmd);
RemoveCmdBreakpoint(info.otherCmd2);
} else {
AddCmdBreakpoint(info.cmd);
if (info.otherCmd) {
AddCmdBreakpoint(info.otherCmd);
}
if (info.otherCmd2) {
AddCmdBreakpoint(info.otherCmd2);
}
}
SetItemState(row, ToggleBreakpoint(info) ? 1 : 0);
break;
case ID_DISASM_COPYINSTRUCTIONHEX: {

View File

@ -1703,6 +1703,7 @@
<None Include="PPSSPP.manifest" />
</ItemGroup>
<ItemGroup>
<Image Include="BreakpointSmall.ico" />
<Image Include="ppsspp_gold.ico" />
</ItemGroup>
<ItemGroup>

View File

@ -721,6 +721,9 @@
<Image Include="ppsspp_gold.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="BreakpointSmall.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<Text Include="..\ppge_atlasscript.txt">

View File

@ -203,6 +203,19 @@ GenericListControl::GenericListControl(HWND hwnd, const GenericListViewDef& def)
valid = true;
}
GenericListControl::~GenericListControl() {
if (images_ != nullptr)
ImageList_Destroy((HIMAGELIST)images_);
}
void GenericListControl::SetIconList(int w, int h, const std::vector<HICON> &icons) {
images_ = ImageList_Create(w, h, ILC_COLOR32 | ILC_MASK, 0, (int)icons.size());
for (const HICON &icon : icons)
ImageList_AddIcon((HIMAGELIST)images_, icon);
ListView_SetImageList(handle, (HIMAGELIST)images_, LVSIL_STATE);
}
void GenericListControl::HandleNotify(LPARAM lParam)
{
LPNMHDR mhdr = (LPNMHDR) lParam;
@ -234,6 +247,7 @@ void GenericListControl::HandleNotify(LPARAM lParam)
wcscat(stringBuffer,L"Invalid");
dispInfo->item.pszText = stringBuffer;
dispInfo->item.mask |= LVIF_TEXT;
return;
}
@ -313,6 +327,13 @@ void GenericListControl::SetCheckState(int item, bool state)
updating = false;
}
void GenericListControl::SetItemState(int item, uint8_t state) {
updating = true;
ListView_SetItemState(handle, item, (state & 0xF) << 12, LVIS_STATEIMAGEMASK);
ListView_RedrawItems(handle, item, item);
updating = false;
}
void GenericListControl::ResizeColumns()
{
if (inResizeColumns)

View File

@ -1,6 +1,8 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include "Common/CommonWindows.h"
namespace W32Util
@ -41,14 +43,17 @@ class GenericListControl
{
public:
GenericListControl(HWND hwnd, const GenericListViewDef& def);
virtual ~GenericListControl() { };
virtual ~GenericListControl();
void HandleNotify(LPARAM lParam);
void Update();
int GetSelectedIndex();
HWND GetHandle() { return handle; };
void SetSendInvalidRows(bool enabled) { sendInvalidRows = enabled; };
protected:
void SetIconList(int w, int h, const std::vector<HICON> &icons);
void SetCheckState(int item, bool state);
void SetItemState(int item, uint8_t state);
virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) = 0;
virtual void GetColumnText(wchar_t* dest, int row, int col) = 0;
virtual int GetRowCount() = 0;
@ -66,6 +71,7 @@ private:
HWND handle;
WNDPROC oldProc;
void *images_ = nullptr;
const GenericListViewColumn* columns;
int columnCount;
wchar_t stringBuffer[256];

View File

@ -454,6 +454,7 @@ IDI_PPSSPP ICON "ppsspp.ico"
#endif
IDI_STOP ICON "icon1.ico"
IDI_STOPDISABLE ICON "stop1.ico"
IDI_BREAKPOINT_SMALL ICON "BreakpointSmall.ico"
/////////////////////////////////////////////////////////////////////////////

View File

@ -324,6 +324,7 @@
#define ID_GEDBG_BREAK_MENU 40211
#define IDC_GEDBG_FLUSH 40212
#define IDC_GEDBG_FLUSHAUTO 40213
#define IDI_BREAKPOINT_SMALL 40214
// Dummy option to let the buffered rendering hotkey cycle through all the options.
#define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500
@ -336,7 +337,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 256
#define _APS_NEXT_COMMAND_VALUE 40214
#define _APS_NEXT_COMMAND_VALUE 40215
#define _APS_NEXT_CONTROL_VALUE 1202
#define _APS_NEXT_SYMED_VALUE 101
#endif