2022-09-21 05:16:07 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
2021-09-03 05:11:04 +00:00
|
|
|
#include "ScriptAPI.h"
|
2022-09-21 05:16:07 +00:00
|
|
|
#include <windows.h>
|
2021-09-03 05:11:04 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
void ScriptAPI::Define_alert(duk_context * ctx)
|
2021-09-03 05:11:04 +00:00
|
|
|
{
|
|
|
|
DefineGlobalFunction(ctx, "alert", js_alert);
|
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
duk_ret_t ScriptAPI::js_alert(duk_context * ctx)
|
2021-09-03 05:11:04 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
CheckArgs(ctx, {Arg_Any, Arg_OptAny});
|
2021-09-03 05:11:04 +00:00
|
|
|
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) : "";
|
2021-09-03 05:11:04 +00:00
|
|
|
|
|
|
|
HWND mainWindow = (HWND)g_Plugins->MainWindow()->GetWindowHandle();
|
|
|
|
MessageBoxA(mainWindow, message, caption, MB_OK);
|
|
|
|
return 0;
|
|
|
|
}
|