1. More informative Hex Editor bookmark edit dialog.
2. Fix some logic bugs of importing bookmarks. 3. Detail
This commit is contained in:
parent
8f785ba9d3
commit
6890f79768
|
@ -2232,7 +2232,7 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
bool success = false;
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
char buffer[128] = { 0 };
|
||||
char buffer[256] = { 0 };
|
||||
FILE* bld = fopen(nameo, "r");
|
||||
if (bld)
|
||||
{
|
||||
|
@ -2247,7 +2247,10 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
{
|
||||
if (importBookmarkProps & IMPORT_DISCARD_ORIGINAL)
|
||||
{
|
||||
discard_original:
|
||||
if (importBookmarkProps & IMPORT_OVERWRITE_NO_PROMPT || hexBookmarks.bookmarkCount == 0 || MessageBox(hwnd, "All your existing bookmarks will be discarded after importing the new bookmarks! Do you want to continue?", "Bookmark Import", MB_YESNO | MB_ICONWARNING) == IDYES)
|
||||
{
|
||||
removeAllBookmarks(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS));
|
||||
for (i = 0; i < import.bookmarkCount; ++i)
|
||||
{
|
||||
hexBookmarks[i].address = import[i].address;
|
||||
|
@ -2257,6 +2260,9 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
hexBookmarks.bookmarkCount = import.bookmarkCount;
|
||||
hexBookmarks.shortcutCount = import.shortcutCount;
|
||||
}
|
||||
updateBookmarkMenus(GetSubMenu(GetMenu(hwnd), BOOKMARKS_SUBMENU_POS));
|
||||
UpdateColorTable();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2382,6 +2388,14 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
strcat(buffer, " with yours.\r\nYou must choose which side would be reserved. Do you want to continue?");
|
||||
|
||||
continue_ = MessageBox(hwnd, buffer, "Bookmark conflict", MB_YESNO | MB_ICONEXCLAMATION) == IDYES && DialogBoxParam(fceu_hInstance, "IMPORTBOOKMARKOPTIONDIALOG", hwnd, importBookmarkCallB, (LPARAM)&tmpImportBookmarkProps);
|
||||
|
||||
if (tmpImportBookmarkProps & IMPORT_OVERWRITE_NO_PROMPT)
|
||||
importBookmarkProps = tmpImportBookmarkProps;
|
||||
|
||||
// in case user's mind changes on the fly
|
||||
if (tmpImportBookmarkProps & IMPORT_DISCARD_ORIGINAL)
|
||||
goto discard_original;
|
||||
|
||||
}
|
||||
|
||||
if (continue_)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef MEMVIEW_H
|
||||
#define MEMVIEW_H
|
||||
|
||||
void DoMemView();
|
||||
void KillMemView();
|
||||
void UpdateMemoryView(int draw_all);
|
||||
|
@ -15,4 +18,6 @@ int GetMaxSize(int editingMode);
|
|||
extern HWND hMemView, hMemFind;
|
||||
extern int EditingMode;
|
||||
|
||||
extern char* EditString[4];
|
||||
extern char* EditString[4];
|
||||
|
||||
#endif
|
|
@ -22,14 +22,19 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <uxtheme.h>
|
||||
#include "memviewsp.h"
|
||||
#include "memview.h"
|
||||
#include "debugger.h"
|
||||
#include "common.h"
|
||||
|
||||
int importBookmarkProps = IMPORT_OVERWRITE_NONE;
|
||||
#pragma comment(lib, "uxtheme.lib")
|
||||
|
||||
int importBookmarkProps = IMPORT_OVERWRITE_NONE;
|
||||
HexBookmarkList hexBookmarks;
|
||||
|
||||
static HFONT hFont, hNewFont;
|
||||
|
||||
/// Finds the bookmark for a given address
|
||||
/// @param address The address to find.
|
||||
/// @param editmode The editing mode of the hex editor (RAM/PPU/OAM/ROM)
|
||||
|
@ -38,13 +43,13 @@ int findBookmark(unsigned int address, int editmode)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (address > 0xFFFF)
|
||||
if (address > GetMaxSize(editmode))
|
||||
{
|
||||
MessageBox(0, "Error: Invalid address was specified as parameter to findBookmark", "Error", MB_OK | MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i=0;i<hexBookmarks.bookmarkCount;i++)
|
||||
|
||||
for (i=0; i < hexBookmarks.bookmarkCount; i++)
|
||||
{
|
||||
if (hexBookmarks[i].address == address && hexBookmarks[i].editmode == editmode)
|
||||
return i;
|
||||
|
@ -53,14 +58,12 @@ int findBookmark(unsigned int address, int editmode)
|
|||
return -1;
|
||||
}
|
||||
|
||||
BOOL CenterWindow(HWND hwndDlg);
|
||||
|
||||
/// Callback function for the name bookmark dialog
|
||||
INT_PTR CALLBACK nameHexBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// For Hex Editor
|
||||
static HexBookmarkMsg* hexBookmarkMsg;
|
||||
int dlgShortcutRadioCheck[10] = { IDC_RADIO_SHORTCUT0, IDC_RADIO_SHORTCUT1, IDC_RADIO_SHORTCUT2, IDC_RADIO_SHORTCUT3, IDC_RADIO_SHORTCUT4, IDC_RADIO_SHORTCUT5, IDC_RADIO_SHORTCUT6, IDC_RADIO_SHORTCUT7, IDC_RADIO_SHORTCUT8, IDC_RADIO_SHORTCUT9 };
|
||||
static int dlgShortcutRadio[10] = { IDC_RADIO_SHORTCUT0, IDC_RADIO_SHORTCUT1, IDC_RADIO_SHORTCUT2, IDC_RADIO_SHORTCUT3, IDC_RADIO_SHORTCUT4, IDC_RADIO_SHORTCUT5, IDC_RADIO_SHORTCUT6, IDC_RADIO_SHORTCUT7, IDC_RADIO_SHORTCUT8, IDC_RADIO_SHORTCUT9 };
|
||||
static int dlgShortcutCaption[10] = { IDC_EDIT_SHORTCUT0, IDC_EDIT_SHORTCUT1, IDC_EDIT_SHORTCUT2, IDC_EDIT_SHORTCUT3, IDC_EDIT_SHORTCUT4, IDC_EDIT_SHORTCUT5, IDC_EDIT_SHORTCUT6, IDC_EDIT_SHORTCUT7, IDC_EDIT_SHORTCUT8, IDC_EDIT_SHORTCUT9 };
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
|
@ -68,7 +71,7 @@ INT_PTR CALLBACK nameHexBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
|||
{
|
||||
// Limit bookmark descriptions to 50 characters
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_DESCRIPTION, EM_SETLIMITTEXT, 50, 0);
|
||||
|
||||
|
||||
// Limit the address text
|
||||
SendDlgItemMessage(hwndDlg, IDC_BOOKMARK_ADDRESS, EM_SETLIMITTEXT, 6, 0);
|
||||
DefaultEditCtrlProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_BOOKMARK_ADDRESS), GWLP_WNDPROC, (LONG_PTR)FilterEditCtrlProc);
|
||||
|
@ -80,21 +83,39 @@ INT_PTR CALLBACK nameHexBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
|||
hexBookmarkMsg = (HexBookmarkMsg*)lParam;
|
||||
HexBookmark* hexBookmark = hexBookmarkMsg->bookmark;
|
||||
|
||||
bool shortcut_assigned = hexBookmarkMsg->shortcut_index != -1;
|
||||
if (shortcut_assigned)
|
||||
if (hexBookmarkMsg->shortcut_index != -1)
|
||||
{
|
||||
CheckDlgButton(hwndDlg, IDC_CHECK_SHORTCUT, BST_CHECKED);
|
||||
CheckDlgButton(hwndDlg, dlgShortcutRadioCheck[hexBookmarkMsg->shortcut_index], BST_CHECKED);
|
||||
CheckDlgButton(hwndDlg, dlgShortcutRadio[hexBookmarkMsg->shortcut_index], BST_CHECKED);
|
||||
}
|
||||
else
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), FALSE);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (!shortcut_assigned || hexBookmarks.shortcuts[i] != -1 && hexBookmarks.shortcuts[i] != hexBookmarkMsg->bookmark_index)
|
||||
// this bookmark doesn't have a shortcut, or the shortcut number is occupied but it doesn't belongs to this bookmark
|
||||
EnableWindow(GetDlgItem(hwndDlg, dlgShortcutRadioCheck[i]), FALSE);
|
||||
hFont = (HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0);
|
||||
LOGFONT lf;
|
||||
GetObject(hFont, sizeof(LOGFONT), &lf);
|
||||
strcpy(lf.lfFaceName, "Courier New");
|
||||
hNewFont = CreateFontIndirect(&lf);
|
||||
|
||||
if (!shortcut_assigned && hexBookmarks.shortcutCount >= 10)
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
SetWindowTheme(GetDlgItem(hwndDlg, dlgShortcutRadio[i]), L"", L"");
|
||||
|
||||
// The slot is not occupied, or it is the same slot of the bookmark
|
||||
EnableWindow(GetDlgItem(hwndDlg, dlgShortcutRadio[i]), hexBookmarkMsg->shortcut_index != -1 && (hexBookmarks.shortcuts[i] == -1 || hexBookmarks.shortcuts[i] == hexBookmarkMsg->bookmark_index));
|
||||
|
||||
if (hexBookmarks.shortcuts[i] != -1) {
|
||||
// Fill the caption block with the address information
|
||||
char buf[16];
|
||||
sprintf(buf, "%s: $%04X", EditString[hexBookmarks[hexBookmarks.shortcuts[i]].editmode], hexBookmarks[hexBookmarks.shortcuts[i]].address);
|
||||
SetDlgItemText(hwndDlg, dlgShortcutCaption[i], buf);
|
||||
SendDlgItemMessage(hwndDlg, dlgShortcutCaption[i], WM_SETFONT, (WPARAM)hNewFont, FALSE);
|
||||
}
|
||||
else
|
||||
EnableWindow(GetDlgItem(hwndDlg, dlgShortcutCaption[i]), FALSE);
|
||||
}
|
||||
|
||||
if (hexBookmarkMsg->shortcut_index == -1 && hexBookmarks.shortcutCount >= 10)
|
||||
{
|
||||
// all the shortcuts are occupied and this one doesn't have a shortcut, it's impossible to assign a new shortcut
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_SHORTCUT), FALSE);
|
||||
|
@ -116,8 +137,18 @@ INT_PTR CALLBACK nameHexBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
|||
|
||||
break;
|
||||
}
|
||||
case WM_CTLCOLORSTATIC:
|
||||
if (hexBookmarkMsg->shortcut_index != -1 && hexBookmarks.shortcuts[hexBookmarkMsg->shortcut_index] == hexBookmarkMsg->bookmark_index && ((HWND)lParam == GetDlgItem(hwndDlg, dlgShortcutCaption[hexBookmarkMsg->shortcut_index]) || (HWND)lParam == GetDlgItem(hwndDlg, dlgShortcutRadio[hexBookmarkMsg->shortcut_index])))
|
||||
{
|
||||
SetBkMode((HDC)wParam, TRANSPARENT);
|
||||
SetTextColor((HDC)wParam, RGB(0, 128, 0));
|
||||
return (INT_PTR)GetSysColorBrush(COLOR_BTNFACE);
|
||||
}
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
case WM_QUIT:
|
||||
DeleteObject(hNewFont);
|
||||
DeleteObject(hFont);
|
||||
EndDialog(hwndDlg, 0);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
|
@ -129,10 +160,10 @@ INT_PTR CALLBACK nameHexBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
|||
case IDC_CHECK_SHORTCUT:
|
||||
{
|
||||
UINT shortcut_assigned = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHORTCUT);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), shortcut_assigned);
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDC_BOOKMARK_SHORTCUT_PREFIX_TEXT), shortcut_assigned == BST_CHECKED);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
EnableWindow(GetDlgItem(hwndDlg, dlgShortcutRadioCheck[i]), shortcut_assigned && (hexBookmarks.shortcuts[i] == -1 || hexBookmarks.shortcuts[i] == hexBookmarkMsg->bookmark_index));
|
||||
EnableWindow(GetDlgItem(hwndDlg, dlgShortcutRadio[i]), shortcut_assigned && (hexBookmarks.shortcuts[i] == -1 || hexBookmarks.shortcuts[i] == hexBookmarkMsg->bookmark_index));
|
||||
}
|
||||
break;
|
||||
case IDOK:
|
||||
|
@ -184,7 +215,7 @@ INT_PTR CALLBACK nameHexBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
|
|||
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHORTCUT))
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (IsDlgButtonChecked(hwndDlg, dlgShortcutRadioCheck[i]))
|
||||
if (IsDlgButtonChecked(hwndDlg, dlgShortcutRadio[i]))
|
||||
{
|
||||
// Update the shortcut index
|
||||
hexBookmarks.shortcuts[i] = hexBookmarkMsg->bookmark_index;
|
||||
|
|
|
@ -18,12 +18,15 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef MEMVIEWSP_H
|
||||
#define MEMVIEWSP_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define ID_FIRST_BOOKMARK 30
|
||||
#define ID_BOOKMARKLIST_SEP (ID_FIRST_BOOKMARK - 1)
|
||||
|
||||
typedef struct HEXBOOKMARK
|
||||
typedef struct
|
||||
{
|
||||
char description[51];
|
||||
unsigned int address;
|
||||
|
@ -37,14 +40,15 @@ typedef struct
|
|||
int shortcut_index = -1;
|
||||
} HexBookmarkMsg;
|
||||
|
||||
typedef struct {
|
||||
extern struct HexBookmarkList
|
||||
{
|
||||
HexBookmark bookmarks[64];
|
||||
int shortcuts[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
|
||||
int bookmarkCount = 0;
|
||||
int shortcutCount = 0;
|
||||
|
||||
HexBookmark& operator[](int index);
|
||||
} HexBookmarkList;
|
||||
} hexBookmarks;
|
||||
|
||||
#define IMPORT_OVERWRITE_NONE 0 // Overwrite nothing
|
||||
#define IMPORT_OVERWRITE_BOOKMARK 1 // Overwrite duplicated bookmarks but don't overwrite duplicated shortcuts
|
||||
|
@ -55,8 +59,6 @@ typedef struct {
|
|||
|
||||
extern int importBookmarkProps;
|
||||
|
||||
extern HexBookmarkList hexBookmarks;
|
||||
|
||||
int findBookmark(unsigned int address, int editmode);
|
||||
int addBookmark(HWND hwnd, unsigned int address, int editmode);
|
||||
int editBookmark(HWND hwnd, unsigned int index);
|
||||
|
@ -68,3 +70,5 @@ void removeAllBookmarks(HMENU menu);
|
|||
|
||||
extern LRESULT APIENTRY FilterEditCtrlProc(HWND hDlg, UINT msg, WPARAM wP, LPARAM lP);
|
||||
extern WNDPROC DefaultEditCtrlProc;
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by res.rc
|
||||
// Microsoft Visual C++ 生成的包含文件。
|
||||
// 供 res.rc 使用
|
||||
//
|
||||
#define CLOSE_BUTTON 1
|
||||
#define BUTTON_CLOSE 1
|
||||
|
@ -514,22 +514,33 @@
|
|||
#define MW_VAL04 1014
|
||||
#define MW_NAME05 1015
|
||||
#define MW_ADDR05 1016
|
||||
#define IDC_EDIT_SHORTCUT0 1016
|
||||
#define MW_VAL05 1017
|
||||
#define IDC_EDIT_SHORTCUT1 1017
|
||||
#define IDC_PRGROM_COMBO 1018
|
||||
#define MW_NAME06 1018
|
||||
#define IDC_EDIT_SHORTCUT2 1018
|
||||
#define MW_ADDR06 1019
|
||||
#define IDC_CHRROM_COMBO 1019
|
||||
#define IDC_EDIT_SHORTCUT7 1019
|
||||
#define IDC_RADIO_MIRR_HORIZONTAL 1020
|
||||
#define MW_VAL06 1020
|
||||
#define IDC_EDIT_SHORTCUT6 1020
|
||||
#define IDC_RADIO_MIRR_VERTICAL 1021
|
||||
#define MW_NAME07 1021
|
||||
#define IDC_EDIT6 1021
|
||||
#define IDC_EDIT_SHORTCUT9 1021
|
||||
#define MW_ADDR07 1022
|
||||
#define IDC_RADIO_MIRR_4SCREEN 1022
|
||||
#define IDC_EDIT_SHORTCUT5 1022
|
||||
#define MW_VAL07 1023
|
||||
#define IDC_EDIT_SHORTCUT4 1023
|
||||
#define IDC_CHECK_TRAINER 1024
|
||||
#define MW_NAME08 1024
|
||||
#define IDC_EDIT_SHORTCUT8 1024
|
||||
#define MW_ADDR08 1025
|
||||
#define IDC_PRGRAM_COMBO 1025
|
||||
#define IDC_EDIT_SHORTCUT3 1025
|
||||
#define IDC_MAPPER_COMBO 1026
|
||||
#define MW_VAL08 1026
|
||||
#define IDC_SUBMAPPER_EDIT 1027
|
||||
|
@ -676,6 +687,7 @@
|
|||
#define TASEDITOR_REWIND 1133
|
||||
#define TASEDITOR_FORWARD 1134
|
||||
#define TASEDITOR_REWIND_FULL 1135
|
||||
#define IDC_EDIT10 1135
|
||||
#define TASEDITOR_FORWARD_FULL 1136
|
||||
#define TASEDITOR_PLAYSTOP 1137
|
||||
#define IDC_RADIO_GREENZONE_SAVINGMODE_ALLFRAMES 1138
|
||||
|
@ -1181,7 +1193,7 @@
|
|||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 311
|
||||
#define _APS_NEXT_COMMAND_VALUE 40009
|
||||
#define _APS_NEXT_CONTROL_VALUE 1126
|
||||
#define _APS_NEXT_CONTROL_VALUE 1017
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue