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.

This commit is contained in:
adelikat 2009-05-08 13:52:28 +00:00
parent 63200b09c8
commit 5936de5a32
3 changed files with 48 additions and 5 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -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))
{