* support for dragdrop
* support for loading ROMs via command line (except it will try to get the BIOS/firmware from where the ROM is. derp) * re-add missing BIOS/firmware dialog. fix libui to allow dialogs without a parent window.
This commit is contained in:
parent
14b7cf1987
commit
f52322ee20
|
@ -111,6 +111,7 @@ _UI_EXTERN void uiWindowSetBorderless(uiWindow *w, int borderless);
|
|||
_UI_EXTERN void uiWindowSetChild(uiWindow *w, uiControl *child);
|
||||
_UI_EXTERN int uiWindowMargined(uiWindow *w);
|
||||
_UI_EXTERN void uiWindowSetMargined(uiWindow *w, int margined);
|
||||
_UI_EXTERN void uiWindowSetDropTarget(uiWindow* w, int drop);
|
||||
_UI_EXTERN uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar);
|
||||
|
||||
_UI_EXTERN void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// - when a dialog is active, tab navigation in other windows stops working
|
||||
// - when adding uiOpenFolder(), use IFileDialog as well - https://msdn.microsoft.com/en-us/library/windows/desktop/bb762115%28v=vs.85%29.aspx
|
||||
|
||||
#define windowHWND(w) ((HWND) uiControlHandle(uiControl(w)))
|
||||
#define windowHWND(w) (w ? (HWND) uiControlHandle(uiControl(w)) : NULL)
|
||||
|
||||
char *commonItemDialog(HWND parent, REFCLSID clsid, REFIID iid, char* filter, char* initpath, FILEOPENDIALOGOPTIONS optsadd)
|
||||
{
|
||||
|
|
|
@ -482,6 +482,12 @@ void uiWindowSetMargined(uiWindow *w, int margined)
|
|||
windowRelayout(w);
|
||||
}
|
||||
|
||||
|
||||
void uiWindowSetDropTarget(uiWindow* w, int drop)
|
||||
{
|
||||
DragAcceptFiles(w->hwnd, drop?TRUE:FALSE);
|
||||
}
|
||||
|
||||
// see http://blogs.msdn.com/b/oldnewthing/archive/2003/09/11/54885.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/09/13/54917.aspx
|
||||
// TODO use clientSizeToWindowSize()
|
||||
static void setClientSize(uiWindow *w, int width, int height, BOOL hasMenubar, DWORD style, DWORD exstyle)
|
||||
|
|
|
@ -297,7 +297,22 @@ int OnCloseWindow(uiWindow* window, void* blarg)
|
|||
|
||||
void OnDropFile(uiWindow* window, char* file, void* blarg)
|
||||
{
|
||||
printf("DROP: %s\n", file);
|
||||
char* ext = &file[strlen(file)-3];
|
||||
|
||||
if (!strcasecmp(ext, "nds") || !strcasecmp(ext, "srl"))
|
||||
{
|
||||
if (RunningSomething)
|
||||
{
|
||||
EmuRunning = 2;
|
||||
while (EmuStatus != 2);
|
||||
}
|
||||
|
||||
strncpy(ROMPath, file, 1023);
|
||||
ROMPath[1023] = '\0';
|
||||
|
||||
NDS::LoadROM(ROMPath, Config::DirectBoot);
|
||||
Run();
|
||||
}
|
||||
}
|
||||
|
||||
void OnGetFocus(uiWindow* window, void* blarg)
|
||||
|
@ -336,7 +351,6 @@ void OnOpenFile(uiMenuItem* item, uiWindow* window, void* blarg)
|
|||
// so we don't have to free it after use
|
||||
|
||||
NDS::LoadROM(ROMPath, Config::DirectBoot);
|
||||
|
||||
Run();
|
||||
}
|
||||
|
||||
|
@ -392,6 +406,15 @@ void OnStop(uiMenuItem* item, uiWindow* window, void* blarg)
|
|||
}
|
||||
|
||||
|
||||
bool _fileexists(char* name)
|
||||
{
|
||||
FILE* f = fopen(name, "rb");
|
||||
if (!f) return false;
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
srand(time(NULL));
|
||||
|
@ -420,6 +443,23 @@ int main(int argc, char** argv)
|
|||
|
||||
Config::Load();
|
||||
|
||||
if (!_fileexists("bios7.bin") || !_fileexists("bios9.bin") || !_fileexists("firmware.bin"))
|
||||
{
|
||||
uiMsgBoxError(
|
||||
NULL,
|
||||
"BIOS/Firmware not found",
|
||||
"One or more of the following required files don't exist or couldn't be accessed:\n\n"
|
||||
"bios7.bin -- ARM7 BIOS\n"
|
||||
"bios9.bin -- ARM9 BIOS\n"
|
||||
"firmware.bin -- firmware image\n\n"
|
||||
"Dump the files from your DS and place them in the directory you run melonDS from.\n"
|
||||
"Make sure that the files can be accessed.");
|
||||
|
||||
uiUninit();
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uiMenu* menu;
|
||||
uiMenuItem* menuitem;
|
||||
|
||||
|
@ -446,7 +486,10 @@ int main(int argc, char** argv)
|
|||
|
||||
MainWindow = uiNewWindow("melonDS " MELONDS_VERSION, 256, 384, 1);
|
||||
uiWindowOnClosing(MainWindow, OnCloseWindow, NULL);
|
||||
|
||||
uiWindowSetDropTarget(MainWindow, 1);
|
||||
uiWindowOnDropFile(MainWindow, OnDropFile, NULL);
|
||||
|
||||
uiWindowOnGetFocus(MainWindow, OnGetFocus, NULL);
|
||||
uiWindowOnLoseFocus(MainWindow, OnLoseFocus, NULL);
|
||||
|
||||
|
@ -469,6 +512,21 @@ int main(int argc, char** argv)
|
|||
RunningSomething = false;
|
||||
EmuThread = SDL_CreateThread(EmuThreadFunc, "melonDS magic", NULL);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
char* file = argv[1];
|
||||
char* ext = &file[strlen(file)-3];
|
||||
|
||||
if (!strcasecmp(ext, "nds") || !strcasecmp(ext, "srl"))
|
||||
{
|
||||
strncpy(ROMPath, file, 1023);
|
||||
ROMPath[1023] = '\0';
|
||||
|
||||
NDS::LoadROM(ROMPath, Config::DirectBoot);
|
||||
Run();
|
||||
}
|
||||
}
|
||||
|
||||
uiControlShow(uiControl(MainWindow));
|
||||
uiControlSetFocus(uiControl(MainDrawArea));
|
||||
uiMain();
|
||||
|
@ -490,7 +548,7 @@ int main(int argc, char** argv)
|
|||
int CALLBACK WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int cmdshow)
|
||||
{
|
||||
char cmdargs[16][256];
|
||||
int arg = 0;
|
||||
int arg = 1;
|
||||
int j = 0;
|
||||
bool inquote = false;
|
||||
int len = strlen(cmdline);
|
||||
|
@ -514,8 +572,16 @@ int CALLBACK WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int cmdsho
|
|||
}
|
||||
if (j > 255) j = 255;
|
||||
if (arg < 16) cmdargs[arg][j] = '\0';
|
||||
if (len > 0) arg++;
|
||||
|
||||
return main(arg, (char**)cmdargs);
|
||||
// FIXME!!
|
||||
strncpy(cmdargs[0], "melonDS.exe", 256);
|
||||
|
||||
char* cmdargptr[16];
|
||||
for (int i = 0; i < 16; i++)
|
||||
cmdargptr[i] = &cmdargs[i][0];
|
||||
|
||||
return main(arg, cmdargptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue