Пример #1
0
static int
l_fire_legacy_event(lua_State *L)
{
  const char *event = lua_tostring(L, 1);

  if (event == nullptr)
    return luaL_error(L, "No InputEvent specified");

  auto *event_function = InputEvents::findEvent(UTF8ToWideConverter(event));
  if (event_function == nullptr)
    return luaL_error(L, "Unknown InputEvent");

  const char *parameter = lua_tostring(L, 2);
  if (parameter == nullptr)
    parameter = "";

  event_function(UTF8ToWideConverter(parameter));
  return 0;
}
Пример #2
0
RasterTerrain *
RasterTerrain::OpenTerrain(FileCache *cache, OperationEnvironment &operation)
try {
  const auto path = Profile::GetPath(ProfileKeys::MapFile);
  if (path.IsNull())
    return nullptr;

  RasterTerrain *rt = new RasterTerrain(ZipArchive(path));
  if (!rt->Load(path, cache, operation)) {
    delete rt;
    return nullptr;
  }

  return rt;
} catch (const std::runtime_error &e) {
  operation.SetErrorMessage(UTF8ToWideConverter(e.what()));
  return nullptr;
}
Пример #3
0
PixelSize
TextCache::GetSize(const Font &font, const char *text)
{
#ifndef ENABLE_OPENGL
  const Poco::ScopedLock<Poco::Mutex> protect(text_cache_mutex);
#endif

  TextCacheKey key(font, text);
  const PixelSize *cached = size_cache.Get(key);
  if (cached != nullptr)
    return *cached;

#ifdef UNICODE
  PixelSize size = font.TextSize(UTF8ToWideConverter(text));
#else
  PixelSize size = font.TextSize(text);
#endif

  key.Allocate();
  size_cache.Put(std::move(key), std::move(size));
  return size;
}
Пример #4
0
void
ShowError(std::exception_ptr e, const TCHAR *caption) noexcept
{
  ShowMessageBox(UTF8ToWideConverter(GetFullMessage(e).c_str()), caption,
                 MB_OK|MB_ICONEXCLAMATION);
}
Пример #5
0
void
ShowError(const Error &error, const TCHAR *caption)
{
  ShowMessageBox(UTF8ToWideConverter(error.GetMessage()), caption,
                 MB_OK|MB_ICONEXCLAMATION);
}
Пример #6
0
void
ShowError(const std::exception &exception, const TCHAR *caption)
{
  ShowMessageBox(UTF8ToWideConverter(exception.what()), caption,
                 MB_OK|MB_ICONEXCLAMATION);
}