MCPcopy Create free account
hub / github.com/TASEmulators/fceux / doPopup

Function doPopup

src/lua-engine.cpp:5438–5656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5436
5437
5438static int doPopup(lua_State *L, const char* deftype, const char* deficon) {
5439 const char *str = luaL_checkstring(L, 1);
5440 const char* type = lua_type(L,2) == LUA_TSTRING ? lua_tostring(L,2) : deftype;
5441 const char* icon = lua_type(L,3) == LUA_TSTRING ? lua_tostring(L,3) : deficon;
5442
5443 int itype = -1, iters = 0;
5444 while(itype == -1 && iters++ < 2)
5445 {
5446 if(!stricmp(type, "ok")) itype = 0;
5447 else if(!stricmp(type, "yesno")) itype = 1;
5448 else if(!stricmp(type, "yesnocancel")) itype = 2;
5449 else if(!stricmp(type, "okcancel")) itype = 3;
5450 else if(!stricmp(type, "abortretryignore")) itype = 4;
5451 else type = deftype;
5452 }
5453 assert(itype >= 0 && itype <= 4);
5454 if(!(itype >= 0 && itype <= 4)) itype = 0;
5455
5456 int iicon = -1; iters = 0;
5457 while(iicon == -1 && iters++ < 2)
5458 {
5459 if(!stricmp(icon, "message") || !stricmp(icon, "notice")) iicon = 0;
5460 else if(!stricmp(icon, "question")) iicon = 1;
5461 else if(!stricmp(icon, "warning")) iicon = 2;
5462 else if(!stricmp(icon, "error")) iicon = 3;
5463 else icon = deficon;
5464 }
5465 assert(iicon >= 0 && iicon <= 3);
5466 if(!(iicon >= 0 && iicon <= 3)) iicon = 0;
5467
5468#ifdef __WIN_DRIVER__
5469 static const char * const titles [] = {"Notice", "Question", "Warning", "Error"};
5470 const char* answer = "ok";
5471
5472 static const int etypes [] = {MB_OK, MB_YESNO, MB_YESNOCANCEL, MB_OKCANCEL, MB_ABORTRETRYIGNORE};
5473 static const int eicons [] = {MB_ICONINFORMATION, MB_ICONQUESTION, MB_ICONWARNING, MB_ICONERROR};
5474 //StopSound(); //mbg merge 7/27/08
5475 int ianswer = MessageBox(hAppWnd, str, titles[iicon], etypes[itype] | eicons[iicon]);
5476 switch(ianswer)
5477 {
5478 case IDOK: answer = "ok"; break;
5479 case IDCANCEL: answer = "cancel"; break;
5480 case IDABORT: answer = "abort"; break;
5481 case IDRETRY: answer = "retry"; break;
5482 case IDIGNORE: answer = "ignore"; break;
5483 case IDYES: answer = "yes"; break;
5484 case IDNO: answer = "no"; break;
5485 }
5486
5487 lua_pushstring(L, answer);
5488 return 1;
5489#else
5490
5491 const char *t;
5492#ifdef __linux
5493
5494 int pid; // appease compiler
5495

Callers 2

gui_popupFunction · 0.85
input_popupFunction · 0.85

Calls 5

lua_typeFunction · 0.85
lua_pushstringFunction · 0.85
luaL_errorFunction · 0.85
FCEU_dmallocFunction · 0.85
FCEU_printfFunction · 0.85

Tested by

no test coverage detected