Changeset View
Changeset View
Standalone View
Standalone View
source/ps/scripting/JSInterface_UserReport.cpp
Show All 17 Lines | |||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "JSInterface_UserReport.h" | #include "JSInterface_UserReport.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/Pyrogenesis.h" | #include "ps/Pyrogenesis.h" | ||||
#include "ps/UserReport.h" | #include "ps/UserReport.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "scriptinterface/FunctionWrapper.h" | |||||
#include <string> | #include <string> | ||||
bool JSI_UserReport::IsUserReportEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | bool JSI_UserReport::IsUserReportEnabled() | ||||
{ | { | ||||
return g_UserReporter.IsReportingEnabled(); | return g_UserReporter.IsReportingEnabled(); | ||||
} | } | ||||
void JSI_UserReport::SetUserReportEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool enabled) | void JSI_UserReport::SetUserReportEnabled(bool enabled) | ||||
{ | { | ||||
g_UserReporter.SetReportingEnabled(enabled); | g_UserReporter.SetReportingEnabled(enabled); | ||||
} | } | ||||
std::string JSI_UserReport::GetUserReportStatus(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | std::string JSI_UserReport::GetUserReportStatus() | ||||
{ | { | ||||
return g_UserReporter.GetStatus(); | return g_UserReporter.GetStatus(); | ||||
} | } | ||||
std::string JSI_UserReport::GetUserReportLogPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | std::string JSI_UserReport::GetUserReportLogPath() | ||||
{ | { | ||||
return psLogDir().string8(); | return psLogDir().string8(); | ||||
} | } | ||||
std::string JSI_UserReport::GetUserReportConfigPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | std::string JSI_UserReport::GetUserReportConfigPath() | ||||
{ | { | ||||
OsPath configPath; | OsPath configPath; | ||||
WARN_IF_ERR(g_VFS->GetDirectoryRealPath("config/", configPath)); | WARN_IF_ERR(g_VFS->GetDirectoryRealPath("config/", configPath)); | ||||
return configPath.string8(); | return configPath.string8(); | ||||
} | } | ||||
void JSI_UserReport::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | void JSI_UserReport::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | ||||
{ | { | ||||
scriptInterface.RegisterFunction<bool, &IsUserReportEnabled>("IsUserReportEnabled"); | #define Register(name) ScriptWrapper::WrapAndRegister<decltype(&name), &name>(scriptInterface, #name) | ||||
scriptInterface.RegisterFunction<void, bool, &SetUserReportEnabled>("SetUserReportEnabled"); | Register(IsUserReportEnabled); | ||||
scriptInterface.RegisterFunction<std::string, &GetUserReportStatus>("GetUserReportStatus"); | Register(SetUserReportEnabled); | ||||
scriptInterface.RegisterFunction<std::string, &GetUserReportLogPath>("GetUserReportLogPath"); | Register(GetUserReportStatus); | ||||
scriptInterface.RegisterFunction<std::string, &GetUserReportConfigPath>("GetUserReportConfigPath"); | Register(GetUserReportLogPath); | ||||
Register(GetUserReportConfigPath); | |||||
#undef Register | |||||
} | } |
Wildfire Games · Phabricator