GE Debugger: Improve step count dialog.

This commit is contained in:
xebra 2018-12-18 00:27:02 +09:00
parent 21bdc2b4c9
commit f64156c8e7
2 changed files with 39 additions and 14 deletions

View File

@ -58,22 +58,34 @@ enum PrimaryDisplayType {
};
StepCountDlg::StepCountDlg(HINSTANCE _hInstance, HWND _hParent) : Dialog((LPCSTR)IDD_GEDBG_STEPCOUNT, _hInstance, _hParent) {
DialogManager::AddDlg(this);
for (int i = 0; i < 4; i++) // Add items 1, 10, 100, 1000
SendMessageA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), CB_ADDSTRING, 0, (LPARAM)std::to_string((int)pow(10, i)).c_str());
SetWindowTextA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), "1");
}
void StepCountDlg::Jump(bool minus, bool relative) {
char str[5];
int count;
GetWindowTextA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), str, 5);
if (TryParse(str, &count)) {
SetBreakNext(BreakNext::COUNT);
SetBreakCount(count * (minus ? -1 : 1), relative);
}
StepCountDlg::~StepCountDlg() {
DialogManager::RemoveDlg(this);
}
void StepCountDlg::Jump(int count, bool relative) {
if (relative && count == 0)
return;
SetBreakNext(BreakNext::COUNT);
SetBreakCount(count, relative);
};
BOOL StepCountDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
int count;
bool relative;
auto GetValue = [&]() {
char str[7]; // +/-99999\0
GetWindowTextA(GetDlgItem(m_hDlg, IDC_GEDBG_STEPCOUNT_COMBO), str, 7);
relative = str[0] == '+' || str[0] == '-';
return TryParse(str, &count);
};
switch (message) {
case WM_CLOSE:
Show(false);
@ -81,18 +93,30 @@ BOOL StepCountDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
case WM_COMMAND:
switch (wParam) {
case IDC_GEDBG_STEPCOUNT_DEC:
Jump(true, true);
if (GetValue())
Jump(-abs(count), true);
return TRUE;
case IDC_GEDBG_STEPCOUNT_INC:
Jump(false, true);
if (GetValue())
Jump(abs(count), true);
return TRUE;
case IDC_GEDBG_STEPCOUNT_JUMP:
Jump(false, false);
if (GetValue())
Jump(abs(count), false);
return TRUE;
case IDOK:
if (GetValue())
Jump(count, relative);
Show(false);
return TRUE;
case IDCANCEL:
SetFocus(m_hParent);
Show(false);
return TRUE;
}
default:
return FALSE;
break;
}
return FALSE;
}
void CGEDebugger::Init() {

View File

@ -47,10 +47,11 @@ struct GPUgstate;
class StepCountDlg : public Dialog {
public:
StepCountDlg(HINSTANCE _hInstance, HWND _hParent);
~StepCountDlg();
protected:
BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam);
private:
void Jump(bool minus, bool relative);
void Jump(int value, bool relative);
};
class CGEDebugger : public Dialog {