From 9ac49d11a1d0b21aba12e15edd17166399adae58 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 15 Nov 2008 01:35:29 +0000 Subject: [PATCH] Win32 - texthooker fixes - 1) reinstalled error checking on dialog startup. 2) Fixed crash on save file 3) Texthooker updates while game is playing 3) Remembers window position 4) Fixed bug where cancel save gives error message. --- src/drivers/win/config.cpp | 3 +++ src/drivers/win/texthook.cpp | 33 +++++++++++++++++++-------------- src/drivers/win/texthook.h | 2 ++ src/fceu.cpp | 2 ++ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 1f650bb1..145a6ab7 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -34,6 +34,7 @@ #include "memwatch.h" #include "fceu.h" #include "file.h" +#include "texthook.h" extern CFGSTRUCT NetplayConfig[]; extern CFGSTRUCT InputConfig[]; @@ -195,6 +196,8 @@ static CFGSTRUCT fceuconfig[] = { AC(GGConv_wndy), AC(TasEdit_wndx), AC(TasEdit_wndy), + AC(TextHookerPosX), + AC(TextHookerPosY), AC(pauseAfterPlayback), AC(AFon), diff --git a/src/drivers/win/texthook.cpp b/src/drivers/win/texthook.cpp index cdc54eec..95efde8c 100644 --- a/src/drivers/win/texthook.cpp +++ b/src/drivers/win/texthook.cpp @@ -694,7 +694,7 @@ int TextHookerSaveTableFile(){ ofn.hwndOwner = hCDLogger; //get the file name or quit - if(!GetSaveFileName(&ofn))return -1; + if(!GetSaveFileName(&ofn))return 0; //open the file FP = fopen(nameo,"wb"); @@ -747,7 +747,7 @@ int TextHookerSaveTableFile(){ fputs( "\r\n[words]\r\n", FP ); //get a pointer to the first word - llword *current = words->next; + llword *current = words; //write all the words while( current != NULL ) { @@ -791,7 +791,8 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa llword *previous = NULL; int charcounter; int si; - + int saveFileErrorCheck = 0; //used to display error message that may have arised from saving a file + memset( str, 0, sizeof( char ) * 2048 ); memset( bufferstr, 0, sizeof( char ) * 10240 ); @@ -1298,12 +1299,15 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; case 113: //save table - if ( TextHookerSaveTableFile() == -1 ) { - MessageBox( NULL, "File successfully saved!", "HOORAY!", MB_OK ); - } else { - MessageBox( NULL, "There was a problem saving the table file.\r\nI'd tell you more but I'm a lazy coder and don't feel like doing proper error checking.", "OH NO!", MB_OK ); - } - break; + saveFileErrorCheck = TextHookerSaveTableFile(); + switch (saveFileErrorCheck) + case -1: + MessageBox( NULL, "File successfully saved!", "", MB_OK ); + case 0: + break; + default: + MessageBox( NULL, "There was a problem saving the table file.", "", MB_OK ); + break; case 133: //save word //add the word to the words list @@ -1549,17 +1553,18 @@ int excitecojp() { /* * ALL SYSTEMS GO! */ -void DoTextHooker() { - /* - if (!GI) { +void DoTextHooker() +{ + if (!GameInfo) + { FCEUD_PrintError("You must have a game loaded before you can use the Text Hooker."); return; } - if (GI->type==GIT_NSF) { + if (GameInfo->type==GIT_NSF) + { FCEUD_PrintError("Silly chip-tunes enthusiast, you can't use the Text Hooker with NSFs."); return; } - */ //adelikat - Who needs error messages? (in fceuxdspce, GI = FCEUGI typedef and no longer exists, but it shouldn't be hard to find another way to determine these conditions. if (!hTextHooker) hTextHooker = CreateDialog(fceu_hInstance,"TEXTHOOKER",NULL,TextHookerCallB); DWORD ret = GetLastError(); diff --git a/src/drivers/win/texthook.h b/src/drivers/win/texthook.h index 18ccbf73..334b2c79 100644 --- a/src/drivers/win/texthook.h +++ b/src/drivers/win/texthook.h @@ -6,6 +6,8 @@ extern int TextHooker; extern uint8 hScroll; extern uint8 vScroll; extern int callTextHooker; +extern int TextHookerPosX; +extern int TextHookerPosY; void TextHookerDoBlit(); void UpdateTextHooker(); diff --git a/src/fceu.cpp b/src/fceu.cpp index d02af59c..d78d2502 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -58,6 +58,7 @@ #ifdef WIN32 #include "drivers/win/main.h" #include "drivers/win/cheat.h" +#include "drivers/win/texthook.h" #else #include "drivers/sdl/sdl.h" @@ -582,6 +583,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski #ifdef WIN32 UpdateCheatList(); + UpdateTextHooker(); // FCEUI_AviVideoUpdate(XBuf); #endif