Win32 - Hex Editor - Drag & Drop for .tbl files

This commit is contained in:
adelikat 2009-06-25 00:05:43 +00:00
parent 7574788b23
commit a4bcc8d28a
2 changed files with 54 additions and 18 deletions

View File

@ -1,3 +1,4 @@
24-jun-2009 - adelikat - win32 - Hex Editor - Drag & Drop for .tbl files
24-jun-2009 - adelikat - win32 - Drag & Drop for .fcm, it converts and then loads the converted movie automatically 24-jun-2009 - adelikat - win32 - Drag & Drop for .fcm, it converts and then loads the converted movie automatically
24-jun-2009 - adelikat - win32 - Drag & Drop support for palette files 24-jun-2009 - adelikat - win32 - Drag & Drop support for palette files
23-jun-2009 - adelikat - win32 - Drag & Drop support for savestates 23-jun-2009 - adelikat - win32 - Drag & Drop support for savestates

View File

@ -283,27 +283,12 @@ void SaveRomAs()
} }
} }
//should return -1, otherwise returns the line number it had the error on int LoadTable(const char* nameo)
int LoadTableFile(){ {
char str[50]; char str[50];
FILE *FP; FILE *FP;
int i, line, charcode1, charcode2; int i, line, charcode1, charcode2;
const char filter[]="Table Files (*.TBL)\0*.tbl\0";
char nameo[2048]; //todo: possibly no need for this? can lpstrfilter point to loadedcdfile instead?
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Load Table File...";
ofn.lpstrFilter=filter;
nameo[0]=0;
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hCDLogger;
if(!GetOpenFileName(&ofn))return -1;
for(i = 0;i < 256;i++){ for(i = 0;i < 256;i++){
chartable[i] = 0; chartable[i] = 0;
} }
@ -352,7 +337,27 @@ int LoadTableFile(){
TableFileLoaded = 1; TableFileLoaded = 1;
fclose(FP); fclose(FP);
return -1; return -1;
}
//should return -1, otherwise returns the line number it had the error on
int LoadTableFile(){
const char filter[]="Table Files (*.TBL)\0*.tbl\0";
char nameo[2048]; //todo: possibly no need for this? can lpstrfilter point to loadedcdfile instead?
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
ofn.lStructSize=sizeof(ofn);
ofn.hInstance=fceu_hInstance;
ofn.lpstrTitle="Load Table File...";
ofn.lpstrFilter=filter;
nameo[0]=0;
ofn.lpstrFile=nameo;
ofn.nMaxFile=256;
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
ofn.hwndOwner = hCDLogger;
if(!GetOpenFileName(&ofn))return -1;
int result = LoadTable(nameo);
return result;
} }
void UnloadTableFile(){ void UnloadTableFile(){
@ -946,6 +951,33 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
EndPaint(hwnd, &ps); EndPaint(hwnd, &ps);
UpdateMemoryView(1); UpdateMemoryView(1);
return 0; return 0;
case WM_DROPFILES:
{
UINT len;
char *ftmp;
len=DragQueryFile((HDROP)wParam,0,0,0)+1;
if((ftmp=(char*)malloc(len)))
{
DragQueryFile((HDROP)wParam,0,ftmp,len);
string fileDropped = ftmp;
//adelikat: Drag and Drop only checks file extension, the internal functions are responsible for file error checking
//-------------------------------------------------------
//Check if .tbl
//-------------------------------------------------------
if (!(fileDropped.find(".tbl") == string::npos) && (fileDropped.find(".tbl") == fileDropped.length()-4))
{
LoadTable(fileDropped.c_str());
}
else
{
std::string str = "Could not open " + fileDropped;
MessageBox(hwnd, str.c_str(), "File error", 0);
}
}
}
break;
case WM_VSCROLL: case WM_VSCROLL:
ZeroMemory(&si, sizeof(SCROLLINFO)); ZeroMemory(&si, sizeof(SCROLLINFO));
@ -1606,6 +1638,9 @@ void DoMemView() {
ShowWindow (hMemView, SW_SHOW) ; ShowWindow (hMemView, SW_SHOW) ;
UpdateCaption(); UpdateCaption();
} }
DragAcceptFiles(hMemView, 1);
if (hMemView) { if (hMemView) {
//UpdateMemView(0); //UpdateMemView(0);
//MemViewDoBlit(); //MemViewDoBlit();