win32: repair path-related things
This commit is contained in:
parent
4dea9cc186
commit
11509592e4
|
@ -141,4 +141,12 @@ void SetRomName(const char *filename)
|
||||||
const char *GetRomName()
|
const char *GetRomName()
|
||||||
{
|
{
|
||||||
return RomName.c_str();
|
return RomName.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetRomNameWithoutExtension()
|
||||||
|
{
|
||||||
|
int x = RomName.find_first_of(".");
|
||||||
|
if (x > 0)
|
||||||
|
return RomName.substr(0,x);
|
||||||
|
else return RomName;
|
||||||
}
|
}
|
|
@ -26,9 +26,11 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
extern u8 gba_header_data_0x04[156];
|
extern u8 gba_header_data_0x04[156];
|
||||||
const char* GetRomName(); //adelikat: return the name of the Rom currently loaded
|
const char* GetRomName(); //adelikat: return the name of the Rom currently loaded
|
||||||
|
std::string GetRomNameWithoutExtension();
|
||||||
void SetRomName(const char *filename);
|
void SetRomName(const char *filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
#include "../lua-engine.h"
|
#include "../lua-engine.h"
|
||||||
#include "7zip.h"
|
#include "7zip.h"
|
||||||
#include "pathsettings.h"
|
#include "pathsettings.h"
|
||||||
|
#include "utils/xstring.h"
|
||||||
|
|
||||||
#include "directx/ddraw.h"
|
#include "directx/ddraw.h"
|
||||||
|
|
||||||
|
@ -131,6 +132,8 @@ void wxTest() {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static BOOL OpenCore(const char* filename);
|
||||||
|
|
||||||
unsigned int lastSaveState = 0; //Keeps track of last savestate used for quick save/load functions
|
unsigned int lastSaveState = 0; //Keeps track of last savestate used for quick save/load functions
|
||||||
//----Recent ROMs menu globals----------
|
//----Recent ROMs menu globals----------
|
||||||
vector<string> RecentRoms; //The list of recent ROM filenames
|
vector<string> RecentRoms; //The list of recent ROM filenames
|
||||||
|
@ -1264,18 +1267,22 @@ void LoadSaveStateInfo()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL LoadROM(const char * filename)
|
static BOOL LoadROM(const char * filename, const char * logicalName)
|
||||||
{
|
{
|
||||||
ResetSaveStateTimes();
|
ResetSaveStateTimes();
|
||||||
NDS_Pause();
|
NDS_Pause();
|
||||||
//if (strcmp(filename,"")!=0) INFO("Attempting to load ROM: %s\n",filename);
|
//if (strcmp(filename,"")!=0) INFO("Attempting to load ROM: %s\n",filename);
|
||||||
|
|
||||||
|
//extract the internal part of the logical rom name
|
||||||
|
std::vector<std::string> parts = tokenize_str(logicalName,"|");
|
||||||
|
SetRomName(parts[parts.size()-1].c_str());
|
||||||
|
|
||||||
if (NDS_LoadROM(filename) > 0)
|
if (NDS_LoadROM(filename) > 0)
|
||||||
{
|
{
|
||||||
INFO("Loading %s was successful\n",filename);
|
INFO("Loading %s was successful\n",filename);
|
||||||
LoadSaveStateInfo();
|
LoadSaveStateInfo();
|
||||||
lagframecounter=0;
|
lagframecounter=0;
|
||||||
UpdateRecentRoms(filename);
|
UpdateRecentRoms(logicalName);
|
||||||
osd->setRotate(GPU_rotation);
|
osd->setRotate(GPU_rotation);
|
||||||
if (AutoRWLoad)
|
if (AutoRWLoad)
|
||||||
{
|
{
|
||||||
|
@ -1283,7 +1290,7 @@ static BOOL LoadROM(const char * filename)
|
||||||
OpenRWRecentFile(0);
|
OpenRWRecentFile(0);
|
||||||
RamWatchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMWATCH), MainWindow->getHWnd(), (DLGPROC) RamWatchProc);
|
RamWatchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMWATCH), MainWindow->getHWnd(), (DLGPROC) RamWatchProc);
|
||||||
}
|
}
|
||||||
SetRomName(filename);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
INFO("Loading %s FAILED.\n",filename);
|
INFO("Loading %s FAILED.\n",filename);
|
||||||
|
@ -1464,6 +1471,7 @@ std::string GetPrivateProfileStdString(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR
|
||||||
|
|
||||||
int _main()
|
int _main()
|
||||||
{
|
{
|
||||||
|
InitDecoder();
|
||||||
|
|
||||||
#ifdef WX_STUB
|
#ifdef WX_STUB
|
||||||
wxInitialize();
|
wxInitialize();
|
||||||
|
@ -1724,7 +1732,8 @@ int _main()
|
||||||
activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface);
|
activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
GetPrivateProfileString("General", "Language", "0", text, 80, IniName); //================================================== ???
|
|
||||||
|
GetPrivateProfileString("General", "Language", "0", text, 80, IniName);
|
||||||
CheckLanguage(IDC_LANGENGLISH+atoi(text));
|
CheckLanguage(IDC_LANGENGLISH+atoi(text));
|
||||||
|
|
||||||
GetPrivateProfileString("Video", "FrameSkip", "0", text, 80, IniName);
|
GetPrivateProfileString("Video", "FrameSkip", "0", text, 80, IniName);
|
||||||
|
@ -1822,7 +1831,7 @@ int _main()
|
||||||
|
|
||||||
if (cmdline.nds_file != "")
|
if (cmdline.nds_file != "")
|
||||||
{
|
{
|
||||||
if(LoadROM(cmdline.nds_file.c_str()))
|
if(OpenCore(cmdline.nds_file.c_str()))
|
||||||
{
|
{
|
||||||
romloaded = TRUE;
|
romloaded = TRUE;
|
||||||
if(!cmdline.start_paused)
|
if(!cmdline.start_paused)
|
||||||
|
@ -1837,8 +1846,6 @@ int _main()
|
||||||
HK_StateLoadSlot(cmdline.load_slot);
|
HK_StateLoadSlot(cmdline.load_slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitDecoder();
|
|
||||||
|
|
||||||
MainWindow->Show(SW_NORMAL);
|
MainWindow->Show(SW_NORMAL);
|
||||||
run();
|
run();
|
||||||
SaveRecentRoms();
|
SaveRecentRoms();
|
||||||
|
@ -2292,7 +2299,7 @@ void OpenRecentROM(int listNum)
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
strcpy(filename, RecentRoms[listNum].c_str());
|
strcpy(filename, RecentRoms[listNum].c_str());
|
||||||
//LOG("Attempting to load %s\n",filename);
|
//LOG("Attempting to load %s\n",filename);
|
||||||
if(LoadROM(filename))
|
if(OpenCore(filename))
|
||||||
{
|
{
|
||||||
romloaded = TRUE;
|
romloaded = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2314,6 +2321,31 @@ void OpenRecentROM(int listNum)
|
||||||
#include "OpenArchive.h"
|
#include "OpenArchive.h"
|
||||||
#include "utils/xstring.h"
|
#include "utils/xstring.h"
|
||||||
|
|
||||||
|
static BOOL OpenCore(const char* filename)
|
||||||
|
{
|
||||||
|
if(!strcmp(getExtension(filename).c_str(), "gz") || !strcmp(getExtension(filename).c_str(), "nds.gz")) {
|
||||||
|
if(LoadROM(filename,filename)) {
|
||||||
|
NDS_UnPause();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char LogicalName[1024], PhysicalName[1024];
|
||||||
|
|
||||||
|
const char* s_nonRomExtensions [] = {"txt", "nfo", "htm", "html", "jpg", "jpeg", "png", "bmp", "gif", "mp3", "wav", "lnk", "exe", "bat", "gmv", "gm2", "lua", "luasav", "sav", "srm", "brm", "cfg", "wch", "gs*"};
|
||||||
|
|
||||||
|
if(!ObtainFile(filename, LogicalName, PhysicalName, "rom", s_nonRomExtensions, ARRAY_SIZE(s_nonRomExtensions)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if(LoadROM(PhysicalName, LogicalName))
|
||||||
|
{
|
||||||
|
romloaded = TRUE;
|
||||||
|
NDS_UnPause();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT OpenFile()
|
LRESULT OpenFile()
|
||||||
{
|
{
|
||||||
HWND hwnd = MainWindow->getHWnd();
|
HWND hwnd = MainWindow->getHWnd();
|
||||||
|
@ -2367,8 +2399,6 @@ LRESULT OpenFile()
|
||||||
ofn.lpstrInitialDir = buffer;
|
ofn.lpstrInitialDir = buffer;
|
||||||
|
|
||||||
|
|
||||||
const char* s_nonRomExtensions [] = {"txt", "nfo", "htm", "html", "jpg", "jpeg", "png", "bmp", "gif", "mp3", "wav", "lnk", "exe", "bat", "gmv", "gm2", "lua", "luasav", "sav", "srm", "brm", "cfg", "wch", "gs*"};
|
|
||||||
|
|
||||||
if (GetOpenFileName(&ofn) == NULL) {
|
if (GetOpenFileName(&ofn) == NULL) {
|
||||||
NDS_UnPause();
|
NDS_UnPause();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2387,19 +2417,8 @@ LRESULT OpenFile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!OpenCore(filename))
|
||||||
char LogicalName[1024], PhysicalName[1024];
|
|
||||||
|
|
||||||
if(!strcmp(getExtension(filename).c_str(), "gz") || !strcmp(getExtension(filename).c_str(), "nds.gz")) {
|
|
||||||
if(LoadROM(filename)) {
|
|
||||||
NDS_UnPause();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ObtainFile(filename, LogicalName, PhysicalName, "rom", s_nonRomExtensions, sizeof(s_nonRomExtensions)/sizeof(*s_nonRomExtensions))) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
// if(!GetOpenFileName(&ofn))
|
// if(!GetOpenFileName(&ofn))
|
||||||
// {
|
// {
|
||||||
|
@ -2411,12 +2430,7 @@ LRESULT OpenFile()
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//LOG("%s\r\n", filename);
|
|
||||||
if(LoadROM(PhysicalName))
|
|
||||||
{
|
|
||||||
romloaded = TRUE;
|
|
||||||
NDS_UnPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2863,7 +2877,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
char filename[MAX_PATH] = "";
|
char filename[MAX_PATH] = "";
|
||||||
DragQueryFile((HDROP)wParam,0,filename,MAX_PATH);
|
DragQueryFile((HDROP)wParam,0,filename,MAX_PATH);
|
||||||
DragFinish((HDROP)wParam);
|
DragFinish((HDROP)wParam);
|
||||||
if(LoadROM(filename))
|
if(OpenCore(filename))
|
||||||
{
|
{
|
||||||
romloaded = TRUE;
|
romloaded = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ the default paths are saved on first load
|
||||||
#include "NDSSystem.h"
|
#include "NDSSystem.h"
|
||||||
#include "pathSettings.h"
|
#include "pathSettings.h"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
/*macros to forward messages
|
/*macros to forward messages
|
||||||
the dialog procedure was getting long and confusing for me
|
the dialog procedure was getting long and confusing for me
|
||||||
|
@ -191,9 +192,7 @@ void SwitchPath(Action action, KnownPath path, char * buffer, int maxCount)
|
||||||
//returns "filename"
|
//returns "filename"
|
||||||
void GetFilename(char *buffer, int maxCount)
|
void GetFilename(char *buffer, int maxCount)
|
||||||
{
|
{
|
||||||
char *lchr = strrchr(pathFilenameToROMwithoutExt, '\\');
|
strcpy(buffer,GetRomNameWithoutExtension().c_str());
|
||||||
lchr++;
|
|
||||||
strncpy(buffer, lchr, maxCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetFullPathNoExt(KnownPath path, char *buffer, int maxCount)
|
void GetFullPathNoExt(KnownPath path, char *buffer, int maxCount)
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue