51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
#include "scripting/ToastBindings.h"
|
|
#include "gui/Toast.h"
|
|
#include <angelscript.h>
|
|
#include <assert.h>
|
|
#include <string>
|
|
#include "../log/log.h"
|
|
// Toast binding functions
|
|
static void AS_ToastInfo(const std::string& message)
|
|
{
|
|
log_info("%s", message.c_str());
|
|
Toast::Info(message);
|
|
}
|
|
|
|
static void AS_ToastWarning(const std::string& message)
|
|
{
|
|
log_warn("%s", message.c_str());
|
|
Toast::Warning(message);
|
|
}
|
|
|
|
static void AS_ToastError(const std::string& message)
|
|
{
|
|
log_error("%s", message.c_str());
|
|
Toast::Error(message);
|
|
}
|
|
|
|
static void AS_ToastSuccess(const std::string& message)
|
|
{
|
|
log_info("%s", message.c_str());
|
|
Toast::Success(message);
|
|
}
|
|
|
|
void RegisterToastBindings(asIScriptEngine *engine)
|
|
{
|
|
int r;
|
|
|
|
engine->SetDefaultNamespace("Toast");
|
|
r = engine->RegisterGlobalFunction("void Info(const string &in)",
|
|
asFUNCTION(AS_ToastInfo), asCALL_CDECL);
|
|
assert(r >= 0);
|
|
r = engine->RegisterGlobalFunction("void Warning(const string &in)",
|
|
asFUNCTION(AS_ToastWarning), asCALL_CDECL);
|
|
assert(r >= 0);
|
|
r = engine->RegisterGlobalFunction("void Error(const string &in)",
|
|
asFUNCTION(AS_ToastError), asCALL_CDECL);
|
|
assert(r >= 0);
|
|
r = engine->RegisterGlobalFunction("void Success(const string &in)",
|
|
asFUNCTION(AS_ToastSuccess), asCALL_CDECL);
|
|
assert(r >= 0);
|
|
engine->SetDefaultNamespace("");
|
|
}
|