mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-10 12:36:45 +03:00
Move all scripting header files into new folder.
This commit is contained in:
parent
b43b9c704f
commit
a9d8b78c96
29 changed files with 0 additions and 0 deletions
|
@ -1,51 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
|
||||
enum class ERROR_MODE
|
||||
{
|
||||
SILENT,
|
||||
WARN,
|
||||
TERMINATE
|
||||
};
|
||||
|
||||
void SetScriptErrorMode(ERROR_MODE mode);
|
||||
ERROR_MODE GetScriptErrorMode();
|
||||
|
||||
void ScriptWarn(std::string const& msg);
|
||||
|
||||
bool ScriptAssert(bool cond, std::string const& msg, std::optional<ERROR_MODE> forceMode = std::nullopt);
|
||||
|
||||
template <typename ... Ts> bool ScriptAssertF(bool cond, std::string_view str, Ts...args)
|
||||
{
|
||||
if (!cond)
|
||||
{
|
||||
auto msg = fmt::format(str, args...);
|
||||
auto mode = GetScriptErrorMode();
|
||||
switch (mode)
|
||||
{
|
||||
case ERROR_MODE::WARN:
|
||||
TENLog(msg, LogLevel::Error, LogConfig::All);
|
||||
break;
|
||||
case ERROR_MODE::TERMINATE:
|
||||
TENLog(msg, LogLevel::Error, LogConfig::All);
|
||||
throw TENScriptException(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
template <typename ... Ts> bool ScriptAssertTerminateF(bool cond, std::string_view str, Ts...args)
|
||||
{
|
||||
if (!cond)
|
||||
{
|
||||
auto msg = fmt::format(str, args...);
|
||||
TENLog(msg, LogLevel::Error, LogConfig::All);
|
||||
throw TENScriptException(msg);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue