mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-02 09:47:58 +03:00
Move Scripting files so interface and internal files are separated again.
(cherry picked from commit 6f542dde7337ddc633a20537af2e719320dc7ac4)
This commit is contained in:
parent
105b713464
commit
e678d2f64b
66 changed files with 0 additions and 0 deletions
47
TombEngine/Scripting/Internal/ScriptAssert.cpp
Normal file
47
TombEngine/Scripting/Internal/ScriptAssert.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "framework.h"
|
||||
#include "ScriptAssert.h"
|
||||
|
||||
static ErrorMode ScriptErrorMode = ErrorMode::Warn;
|
||||
|
||||
void ScriptWarn(std::string const& msg)
|
||||
{
|
||||
switch (ScriptErrorMode)
|
||||
{
|
||||
case ErrorMode::Terminate:
|
||||
case ErrorMode::Warn:
|
||||
TENLog(msg, LogLevel::Warning, LogConfig::All);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ScriptAssert(bool cond, std::string const& msg, std::optional<ErrorMode> forceMode)
|
||||
{
|
||||
if (!cond)
|
||||
{
|
||||
ErrorMode mode = forceMode ? *forceMode : ScriptErrorMode;
|
||||
switch (mode)
|
||||
{
|
||||
case ErrorMode::Warn:
|
||||
TENLog(msg, LogLevel::Error, LogConfig::All);
|
||||
break;
|
||||
case ErrorMode::Terminate:
|
||||
TENLog(msg, LogLevel::Error, LogConfig::All);
|
||||
throw TENScriptException(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
|
||||
void SetScriptErrorMode(ErrorMode mode)
|
||||
{
|
||||
ScriptErrorMode = mode;
|
||||
}
|
||||
|
||||
ErrorMode GetScriptErrorMode()
|
||||
{
|
||||
return ScriptErrorMode;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue