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.

This commit is contained in:
adelikat 2008-11-15 01:35:29 +00:00
parent f1ad20b749
commit 9ac49d11a1
4 changed files with 26 additions and 14 deletions

View File

@ -34,6 +34,7 @@
#include "memwatch.h" #include "memwatch.h"
#include "fceu.h" #include "fceu.h"
#include "file.h" #include "file.h"
#include "texthook.h"
extern CFGSTRUCT NetplayConfig[]; extern CFGSTRUCT NetplayConfig[];
extern CFGSTRUCT InputConfig[]; extern CFGSTRUCT InputConfig[];
@ -195,6 +196,8 @@ static CFGSTRUCT fceuconfig[] = {
AC(GGConv_wndy), AC(GGConv_wndy),
AC(TasEdit_wndx), AC(TasEdit_wndx),
AC(TasEdit_wndy), AC(TasEdit_wndy),
AC(TextHookerPosX),
AC(TextHookerPosY),
AC(pauseAfterPlayback), AC(pauseAfterPlayback),
AC(AFon), AC(AFon),

View File

@ -694,7 +694,7 @@ int TextHookerSaveTableFile(){
ofn.hwndOwner = hCDLogger; ofn.hwndOwner = hCDLogger;
//get the file name or quit //get the file name or quit
if(!GetSaveFileName(&ofn))return -1; if(!GetSaveFileName(&ofn))return 0;
//open the file //open the file
FP = fopen(nameo,"wb"); FP = fopen(nameo,"wb");
@ -747,7 +747,7 @@ int TextHookerSaveTableFile(){
fputs( "\r\n[words]\r\n", FP ); fputs( "\r\n[words]\r\n", FP );
//get a pointer to the first word //get a pointer to the first word
llword *current = words->next; llword *current = words;
//write all the words //write all the words
while( current != NULL ) { while( current != NULL ) {
@ -791,6 +791,7 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
llword *previous = NULL; llword *previous = NULL;
int charcounter; int charcounter;
int si; 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( str, 0, sizeof( char ) * 2048 );
memset( bufferstr, 0, sizeof( char ) * 10240 ); memset( bufferstr, 0, sizeof( char ) * 10240 );
@ -1298,11 +1299,14 @@ BOOL CALLBACK TextHookerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
break; break;
case 113: //save table case 113: //save table
if ( TextHookerSaveTableFile() == -1 ) { saveFileErrorCheck = TextHookerSaveTableFile();
MessageBox( NULL, "File successfully saved!", "HOORAY!", MB_OK ); switch (saveFileErrorCheck)
} else { case -1:
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 ); MessageBox( NULL, "File successfully saved!", "", MB_OK );
} case 0:
break;
default:
MessageBox( NULL, "There was a problem saving the table file.", "", MB_OK );
break; break;
case 133: //save word case 133: //save word
@ -1549,17 +1553,18 @@ int excitecojp() {
/* /*
* ALL SYSTEMS GO! * ALL SYSTEMS GO!
*/ */
void DoTextHooker() { void DoTextHooker()
/* {
if (!GI) { if (!GameInfo)
{
FCEUD_PrintError("You must have a game loaded before you can use the Text Hooker."); FCEUD_PrintError("You must have a game loaded before you can use the Text Hooker.");
return; 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."); FCEUD_PrintError("Silly chip-tunes enthusiast, you can't use the Text Hooker with NSFs.");
return; 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); if (!hTextHooker) hTextHooker = CreateDialog(fceu_hInstance,"TEXTHOOKER",NULL,TextHookerCallB);
DWORD ret = GetLastError(); DWORD ret = GetLastError();

View File

@ -6,6 +6,8 @@ extern int TextHooker;
extern uint8 hScroll; extern uint8 hScroll;
extern uint8 vScroll; extern uint8 vScroll;
extern int callTextHooker; extern int callTextHooker;
extern int TextHookerPosX;
extern int TextHookerPosY;
void TextHookerDoBlit(); void TextHookerDoBlit();
void UpdateTextHooker(); void UpdateTextHooker();

View File

@ -58,6 +58,7 @@
#ifdef WIN32 #ifdef WIN32
#include "drivers/win/main.h" #include "drivers/win/main.h"
#include "drivers/win/cheat.h" #include "drivers/win/cheat.h"
#include "drivers/win/texthook.h"
#else #else
#include "drivers/sdl/sdl.h" #include "drivers/sdl/sdl.h"
@ -582,6 +583,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
#ifdef WIN32 #ifdef WIN32
UpdateCheatList(); UpdateCheatList();
UpdateTextHooker();
// FCEUI_AviVideoUpdate(XBuf); // FCEUI_AviVideoUpdate(XBuf);
#endif #endif