win32-support funny languages for opening roms, through drag&drop, at least.

This commit is contained in:
zeromus 2012-06-08 21:15:37 +00:00
parent 385dd471d1
commit 601b1ad867
8 changed files with 44 additions and 31 deletions

View File

@ -365,7 +365,7 @@ void OpenProject()
LoadProject(nameo); LoadProject(nameo);
} }
} }
bool LoadProject(char* fullname) bool LoadProject(const char* fullname)
{ {
// try to load project // try to load project
if (project.load(fullname)) if (project.load(fullname))

View File

@ -14,7 +14,7 @@ void UpdateTasEditor();
void NewProject(); void NewProject();
void OpenProject(); void OpenProject();
bool LoadProject(char* fullname); bool LoadProject(const char* fullname);
bool SaveProject(); bool SaveProject();
bool SaveProjectAs(); bool SaveProjectAs();
void SaveCompact(); void SaveCompact();

View File

@ -158,7 +158,7 @@ bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool
return false; return false;
} }
} }
bool TASEDITOR_PROJECT::load(char* fullname) bool TASEDITOR_PROJECT::load(const char* fullname)
{ {
bool load_all = true; bool load_all = true;
EMUFILE_FILE ifs(fullname, "rb"); EMUFILE_FILE ifs(fullname, "rb");
@ -275,7 +275,7 @@ bool TASEDITOR_PROJECT::load(char* fullname)
return true; return true;
} }
void TASEDITOR_PROJECT::RenameProject(char* new_fullname, bool filename_is_correct) void TASEDITOR_PROJECT::RenameProject(const char* new_fullname, bool filename_is_correct)
{ {
projectFile = new_fullname; projectFile = new_fullname;
char drv[512], dir[512], name[512], ext[512]; // For getting the filename char drv[512], dir[512], name[512], ext[512]; // For getting the filename

View File

@ -40,9 +40,9 @@ public:
void update(); void update();
bool save(const char* different_name = 0, bool save_binary = true, bool save_markers = true, bool save_bookmarks = true, bool save_greenzone = true, bool save_history = true, bool save_piano_roll = true, bool save_selection = true); bool save(const char* different_name = 0, bool save_binary = true, bool save_markers = true, bool save_bookmarks = true, bool save_greenzone = true, bool save_history = true, bool save_piano_roll = true, bool save_selection = true);
bool load(char* fullname); bool load(const char* fullname);
void RenameProject(char* new_fullname, bool filename_is_correct); void RenameProject(const char* new_fullname, bool filename_is_correct);
std::string GetProjectFile(); std::string GetProjectFile();
std::string GetProjectName(); std::string GetProjectName();

View File

@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
//http://www.nubaria.com/en/blog/?p=289
// File description: Everything relevant for the main window should go here. This // File description: Everything relevant for the main window should go here. This
// does not include functions relevant for dialog windows. // does not include functions relevant for dialog windows.
@ -1009,7 +1011,7 @@ void CloseGame()
} }
} }
bool ALoad(char *nameo, char* innerFilename) bool ALoad(const char *nameo, char* innerFilename)
{ {
int oldPaused = EmulationPaused; int oldPaused = EmulationPaused;
@ -1374,13 +1376,14 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
case WM_DROPFILES: case WM_DROPFILES:
{ {
UINT len; UINT len;
char *ftmp;
len=DragQueryFile((HDROP)wParam,0,0,0)+1; len=DragQueryFileW((HDROP)wParam,0,0,0)+1;
if((ftmp=(char*)malloc(len))) wchar_t* wftmp;
wftmp=new wchar_t[len];
{ {
DragQueryFile((HDROP)wParam,0,ftmp,len); DragQueryFileW((HDROP)wParam,0,wftmp,len);
string fileDropped = ftmp; std::string fileDropped = wcstombs(wftmp);
delete[] wftmp;
//adelikat: Drag and Drop only checks file extension, the internal functions are responsible for file error checking //adelikat: Drag and Drop only checks file extension, the internal functions are responsible for file error checking
//------------------------------------------------------- //-------------------------------------------------------
@ -1441,8 +1444,8 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
if (GameInfo && !(fileDropped.find(".fm2") == string::npos)) if (GameInfo && !(fileDropped.find(".fm2") == string::npos))
{ {
//.fm2 is at the end of the filename so that must be the extension //.fm2 is at the end of the filename so that must be the extension
FCEUI_LoadMovie(ftmp, 1, false); //We are convinced it is a movie file, attempt to load it FCEUI_LoadMovie(fileDropped.c_str(), 1, false); //We are convinced it is a movie file, attempt to load it
FCEUX_LoadMovieExtras(ftmp); FCEUX_LoadMovieExtras(fileDropped.c_str());
} }
} }
//------------------------------------------------------- //-------------------------------------------------------
@ -1456,11 +1459,11 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{ {
//.fm3 is at the end of the filename so that must be the extension //.fm3 is at the end of the filename so that must be the extension
extern bool EnterTasEditor(); extern bool EnterTasEditor();
extern bool LoadProject(char* fullname); extern bool LoadProject(const char* fullname);
extern bool AskSaveProject(); extern bool AskSaveProject();
if (EnterTasEditor()) //We are convinced it is a TAS Editor project file, attempt to load in TAS Editor if (EnterTasEditor()) //We are convinced it is a TAS Editor project file, attempt to load in TAS Editor
if (AskSaveProject()) // in case there's unsaved project if (AskSaveProject()) // in case there's unsaved project
LoadProject(ftmp); LoadProject(fileDropped.c_str());
} }
} }
//------------------------------------------------------- //-------------------------------------------------------
@ -1482,7 +1485,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
#ifdef _S9XLUA_H #ifdef _S9XLUA_H
else if (!(fileDropped.find(".lua") == string::npos) && (fileDropped.find(".lua") == fileDropped.length()-4)) else if (!(fileDropped.find(".lua") == string::npos) && (fileDropped.find(".lua") == fileDropped.length()-4))
{ {
FCEU_LoadLuaCode(ftmp); FCEU_LoadLuaCode(fileDropped.c_str());
UpdateLuaConsole(fileDropped.c_str()); UpdateLuaConsole(fileDropped.c_str());
} }
#endif #endif
@ -1500,8 +1503,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
//------------------------------------------------------- //-------------------------------------------------------
else else
{ {
ALoad(ftmp); ALoad(fileDropped.c_str());
free(ftmp);
} }
} }
} }

View File

@ -32,7 +32,7 @@ void ByebyeWindow();
void DoTimingConfigFix(); void DoTimingConfigFix();
int CreateMainWindow(); int CreateMainWindow();
void UpdateCheckedMenuItems(); void UpdateCheckedMenuItems();
bool ALoad(char* nameo, char* innerFilename=0); bool ALoad(const char* nameo, char* innerFilename=0);
void LoadNewGamey(HWND hParent, const char *initialdir); void LoadNewGamey(HWND hParent, const char *initialdir);
int BrowseForFolder(HWND hParent, const char *htext, char *buf); int BrowseForFolder(HWND hParent, const char *htext, char *buf);
void SetMainWindowStuff(); void SetMainWindowStuff();

View File

@ -20,9 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
#include "emufile.h"
#include <vector> #include <vector>
#include "emufile.h"
#include "utils/xstring.h"
bool EMUFILE::readAllBytes(std::vector<u8>* dstbuf, const std::string& fname) bool EMUFILE::readAllBytes(std::vector<u8>* dstbuf, const std::string& fname)
{ {
@ -59,6 +59,24 @@ size_t EMUFILE_MEMORY::_fread(const void *ptr, size_t bytes){
return todo; return todo;
} }
void EMUFILE_FILE::open(const char* fname, const char* mode)
{
fp = fopen(fname,mode);
if(!fp)
{
#ifdef _MSC_VER
std::wstring wfname = mbstowcs((std::string)fname);
std::wstring wfmode = mbstowcs((std::string)mode);
fp = _wfopen(wfname.c_str(),wfmode.c_str());
#endif
if(!fp)
failbit = true;
}
this->fname = fname;
strcpy(this->mode,mode);
}
void EMUFILE_FILE::truncate(s32 length) void EMUFILE_FILE::truncate(s32 length)
{ {
::fflush(fp); ::fflush(fp);

View File

@ -268,14 +268,7 @@ protected:
char mode[16]; char mode[16];
private: private:
void open(const char* fname, const char* mode) void open(const char* fname, const char* mode);
{
fp = fopen(fname,mode);
if(!fp)
failbit = true;
this->fname = fname;
strcpy(this->mode,mode);
}
public: public: