win32: updates to cheat dialog handling

This commit is contained in:
OV2 2018-05-01 22:59:09 +02:00
parent e3838a2dad
commit 3f4fc0e25a
1 changed files with 107 additions and 91 deletions

View File

@ -8603,6 +8603,8 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
TCHAR buf[CHEAT_SIZE];
LV_ITEM lvi;
internal_change = true; // do not enable update button
/* Code */
ITEM_QUERY (lvi, IDC_CHEAT_LIST, 0, buf, CHEAT_SIZE);
SetDlgItemText(hDlg, IDC_CHEAT_CODE, lvi.pszText);
@ -8611,7 +8613,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
ITEM_QUERY(lvi, IDC_CHEAT_LIST, 1, buf, CHEAT_SIZE);
SetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, lvi.pszText);
internal_change = true;
internal_change = false;
}
sel_idx=ListView_GetSelectionMark(GetDlgItem(hDlg, IDC_CHEAT_LIST));
has_sel=true;
@ -8633,11 +8635,11 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
if(internal_change)
{
internal_change=!internal_change;
return false;
}
if(!has_sel)
return true;
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), true);
return true;
}
@ -8702,7 +8704,10 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
for(j=0;j<(int)Cheat.g.size();j++)
{
if (ct.index[j] == sel_idx)
{
ct.state[j] = Modified;
break;
}
}
Utf8ToWide wstring(code);
@ -8725,6 +8730,9 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
lvi.pszText=temp;
lvi.cchTextMax = CHEAT_SIZE;
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
// update done, disable update button
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
}
}
@ -8735,7 +8743,10 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
for(j=0;j<Cheat.g.size();j++)
{
if (ct.index[j] == sel_idx)
{
ct.state[j] = Deleted;
break;
}
}
for(j=0;j<Cheat.g.size();j++)
{
@ -8765,7 +8776,10 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
switch(HIWORD(wParam))
{
case EN_CHANGE:
if (internal_change)
{
return true;
}
char temp[CHEAT_SIZE];
char *valid_cheat = NULL;
GetDlgItemTextA(hDlg, IDC_CHEAT_CODE, temp, CHEAT_SIZE);
@ -8774,7 +8788,8 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (has_sel)
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), true);
else EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
else
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), false);
EnableWindow(GetDlgItem(hDlg, IDC_ADD_CHEAT), true);
delete[] valid_cheat;
}
@ -8884,7 +8899,8 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
delete [] ct.state;
EndDialog(hDlg, 0);
return true;
default:return false;
default:
return false;
}
}
default: return false;