1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
//
//
#include "RocketSystemInterface.h"
#include "globalincs/pstypes.h"
#include "io/timer.h"
#include "localization/localize.h"
using namespace Rocket::Core;
namespace scpui {
RocketSystemInterface::RocketSystemInterface() = default;
float RocketSystemInterface::GetElapsedTime() { return timer_get_microseconds() / 1000000.f; }
int RocketSystemInterface::TranslateString(Rocket::Core::String& translated, const Rocket::Core::String& input)
{
SCP_string lcl_translated;
lcl_ext_localize(input.CString(), lcl_translated);
translated = lcl_translated.c_str();
return 0; // Everything is translated now
}
void RocketSystemInterface::JoinPath(Rocket::Core::String& translated_path,
const Rocket::Core::String& /*document_path*/, const Rocket::Core::String& path)
{
// We here at the SCP are rather simple. We just take the path that is in the document.
// Our file opening procedures take care of finding those files
translated_path = path;
}
bool RocketSystemInterface::LogMessage(Rocket::Core::Log::Type type, const Rocket::Core::String& message)
{
switch (type) {
case Log::LT_ERROR:
ReleaseWarning(LOCATION, "libRocket error: %s", message.CString());
break;
case Log::LT_WARNING:
Warning(LOCATION, "libRocket warning: %s", message.CString());
break;
case Log::LT_ASSERT:
os::dialogs::AssertMessage("libRocket assertion", LOCATION, "%s", message.CString());
break;
case Log::LT_ALWAYS:
case Log::LT_INFO:
case Log::LT_DEBUG:
// These always go into the standard log
mprintf(("libRocket message: %s\n", message.CString()));
break;
default:
break;
}
// We never break into the debugger
return false;
}
void RocketSystemInterface::ActivateKeyboard()
{
// TODO: Maybe extend libRocket to expose where the input currently is
SDL_StartTextInput();
}
void RocketSystemInterface::DeactivateKeyboard() { SDL_StopTextInput(); }
} // namespace scpui
|