project64/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_alert.cpp

23 lines
577 B
C++
Raw Normal View History

2022-09-21 05:16:07 +00:00
#include "stdafx.h"
#include "ScriptAPI.h"
2022-09-21 05:16:07 +00:00
#include <windows.h>
2022-09-21 05:16:07 +00:00
void ScriptAPI::Define_alert(duk_context * ctx)
{
DefineGlobalFunction(ctx, "alert", js_alert);
}
2022-09-21 05:16:07 +00:00
duk_ret_t ScriptAPI::js_alert(duk_context * ctx)
{
2022-09-21 05:16:07 +00:00
CheckArgs(ctx, {Arg_Any, Arg_OptAny});
duk_idx_t nargs = duk_get_top(ctx);
2022-09-21 05:16:07 +00:00
const char * message = duk_safe_to_string(ctx, 0);
const char * caption = (nargs == 2) ? duk_safe_to_string(ctx, 1) : "";
HWND mainWindow = (HWND)g_Plugins->MainWindow()->GetWindowHandle();
MessageBoxA(mainWindow, message, caption, MB_OK);
return 0;
}