From 5936de5a320160dc3400a329d7bd0e362ab49c73 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 8 May 2009 13:52:28 +0000 Subject: [PATCH] Win32 - main.cpp now keeps track of current RomName. Set up a GetRomName() function to return name of ROM (useful for default filenames on OPENFILENAME dialogs. Ramwatch - uses romname for default .wch filename. --- desmume/src/windows/main.cpp | 40 +++++++++++++++++++++++++++++++- desmume/src/windows/main.h | 4 +++- desmume/src/windows/ramwatch.cpp | 9 ++++--- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 4f96a6949..f1ee648ce 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -100,6 +100,11 @@ const unsigned int baseid = IDM_RECENT_RESERVED1; //Base identifier for the re static HMENU recentromsmenu; //Handle to the recent ROMs submenu //-------------------------------------- +//----RomName--------------------------- +string RomName = ""; //Stores the name of the Rom currently loaded in memory +void SetRomName(char *filename); +//-------------------------------------- + void UpdateHotkeyAssignments(); //Appends hotkey mappings to corresponding menu items static HMENU mainMenu; //Holds handle to the main DeSmuME menu @@ -1374,7 +1379,7 @@ BOOL LoadROM(char * filename, const char *cflash_disk_image) OpenRWRecentFile(0); RamWatchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMWATCH), MainWindow->getHWnd(), (DLGPROC) RamWatchProc); } - + SetRomName(filename); return TRUE; } INFO("Loading %s FAILED.\n",filename); @@ -3986,4 +3991,37 @@ void UpdateHotkeyAssignments() HWND GetMainHWND() { return MainWindow->getHWnd(); +} + +/*** + * Author: adelikat + * Date Added: May 8, 2009 + * Description: Sets the Global variable RomName + * Known Usage: + * LoadRom + **/ +void SetRomName(char *filename) +{ + string str = filename; + + //Truncate the path from filename + int x = str.find_last_of("/\\"); + if (x > 0) + str = str.substr(x+1); + RomName = str; + int y = 0; +} + +/*** + * Author: adelikat + * Date Added: May 8, 2009 + * Description: Returns the Global variable RomName + * Known Usage: + * included in main.h + * ramwatch.cpp - SaveStrings + **/ + +const char *GetRomName() +{ + return RomName.c_str(); } \ No newline at end of file diff --git a/desmume/src/windows/main.h b/desmume/src/windows/main.h index b64c91ee9..6dff84573 100644 --- a/desmume/src/windows/main.h +++ b/desmume/src/windows/main.h @@ -31,6 +31,8 @@ extern bool ShowLagFrameCounter; extern int backupmemorytype; extern u32 backupmemorysize; -HWND GetMainHWND(); //adelikat: returns the main window handle +HWND GetMainHWND(); //adelikat: returns the main window handle + +const char* GetRomName(); //adelikat: return the name of the Rom currently loaded #endif diff --git a/desmume/src/windows/ramwatch.cpp b/desmume/src/windows/ramwatch.cpp index 5feb77f55..a7342e97d 100644 --- a/desmume/src/windows/ramwatch.cpp +++ b/desmume/src/windows/ramwatch.cpp @@ -1,4 +1,5 @@ +#include "main.h" #include "resource.h" #include "common.h" #include "NDSSystem.h" @@ -12,7 +13,7 @@ HWND RamWatchHWnd; char Str_Tmp[1024]; -char Rom_Name[64] = "test"; +std::string Rom_Name; static HMENU ramwatchmenu; static HMENU rwrecentmenu; @@ -445,7 +446,8 @@ int Change_File_S(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, H bool Save_Watches() { - strncpy(Str_Tmp,Rom_Name,512); + Rom_Name = GetRomName(); + strncpy(Str_Tmp,Rom_Name.c_str(),512); strcat(Str_Tmp,".wch"); if(Change_File_S(Str_Tmp, Gens_Path, "Save Watches", "GENs Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd)) { @@ -578,7 +580,8 @@ int Change_File_L(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, H bool Load_Watches(bool clear) { - strncpy(Str_Tmp,Rom_Name,512); + Rom_Name = GetRomName(); + strncpy(Str_Tmp,Rom_Name.c_str(),512); strcat(Str_Tmp,".wch"); if(Change_File_L(Str_Tmp, Watch_Dir, "Load Watches", "GENs Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd)) {