bool PlayResource(const TCHAR *resource_name) { #ifdef ANDROID if (_tcsstr(resource_name, _T(".wav"))) return SoundUtil::PlayExternal(Java::GetEnv(), context->Get(), resource_name); return SoundUtil::Play(Java::GetEnv(), context->Get(), resource_name); #elif defined(_WIN32) if (_tcsstr(resource_name, TEXT(".wav"))) return sndPlaySound(resource_name, SND_ASYNC | SND_NODEFAULT); ResourceLoader::Data data = ResourceLoader::Load(resource_name, _T("WAVE")); return !data.IsNull() && sndPlaySound((LPCTSTR)data.data, SND_MEMORY | SND_ASYNC | SND_NODEFAULT); #elif defined(HAVE_PCM_PLAYER) if (nullptr == pcm_resource_player) return false; return pcm_resource_player->PlayResource(resource_name); #else return false; #endif }
void UnitSymbol::Load(ResourceId id) { #ifdef USE_MEMORY_CANVAS assert(IsScreenInitialized()); assert(buffer.data == nullptr); ResourceLoader::Data data = ResourceLoader::Load(id); assert(!data.IsNull()); const UncompressedImage uncompressed = LoadPNG(data.data, data.size); assert(uncompressed.GetFormat() == UncompressedImage::Format::GRAY); const size_t size = uncompressed.GetPitch() * uncompressed.GetHeight(); buffer.data = new Luminosity8[size]; memcpy(buffer.data, uncompressed.GetData(), size); buffer.pitch = uncompressed.GetPitch(); buffer.width = uncompressed.GetWidth(); buffer.height = uncompressed.GetHeight(); #else bitmap.Load(id, Bitmap::Type::MONO); size = bitmap.GetSize(); #endif }
bool PlayResource(const TCHAR *resource_name) { #ifdef ANDROID return SoundUtil::Play(Java::GetEnv(), context->Get(), resource_name); #elif defined(WIN32) && !defined(GNAV) if (_tcsstr(resource_name, TEXT(".wav"))) return sndPlaySound(resource_name, SND_ASYNC | SND_NODEFAULT); ResourceLoader::Data data = ResourceLoader::Load(resource_name, _T("WAVE")); return !data.IsNull() && sndPlaySound((LPCTSTR)data.data, SND_MEMORY | SND_ASYNC | SND_NODEFAULT); #else return false; #endif }