void KlondikeView::_LoadBitmaps() { BString suits[] = { "spade", "heart", "club", "diamond" }; // load images BString filename; for (short i = 0; i < CARDS_IN_SUIT; i++) { for (short j = 0; j < 4; j++) { filename = ""; filename << "Artwork/" << i + 1 << "_" << suits[j] << ".png"; fCards[j * CARDS_IN_SUIT + i] = BTranslationUtils::GetBitmap('rGFX', filename); } } fBack[0] = BTranslationUtils::GetBitmap('rGFX', "Artwork/back.png"); fEmpty = BTranslationUtils::GetBitmap('rGFX', "Artwork/empty.png"); // load audio fResources = be_app->AppResources(); fShuffle = _LoadSound("Artwork/shuffle.wav"); fFanfare = _LoadSound("Artwork/fanfare.wav"); // cache multiple backs in a row for (short i = 1; i < CACHED_BACKS; i++) { fBack[i] = new BBitmap(BRect(0, 0, CARD_WIDTH - 1, CARD_HEIGHT + i * 18), fBack[0]->ColorSpace(), true); BView* fBackView = new BView(fBack[i]->Bounds(), NULL, 0, 0); BRect destRect = fBack[0]->Bounds(); fBack[i]->AddChild(fBackView); fBack[i]->Lock(); fBackView->SetDrawingMode(B_OP_COPY); fBackView->DrawBitmap(fBack[0], destRect); destRect.top = i * 18; destRect.bottom = destRect.top + CARD_HEIGHT; fBackView->DrawBitmap(fBack[0], destRect); fBackView->SetDrawingMode(B_OP_ALPHA); for (short j = 0; j < i + 1; j++) { destRect.top = j * 18; destRect.bottom = destRect.top + CARD_HEIGHT; fBackView->DrawBitmap(fBack[0], destRect); } fBackView->Sync(); fBack[i]->Unlock(); } Invalidate(); }
Node::NodeSP SceneLoader::_LoadElement(const QDomElement& og_element, Node::NodeSP dt_node) { QString name = og_element.nodeName(); Node::NodeSP node = nullptr; if(name == SL_LIGHT) { node = _LoadLight(og_element, dt_node); //Light } else if(name == SL_CAMERA) { node = _LoadCamera(og_element, dt_node); //Camera } else if(name == SL_SOUND) { node = _LoadSound(og_element, dt_node); //Sound } else if(name == SL_NODE) { if(og_element.firstChildElement(SL_ENTITY).isNull() && og_element.firstChildElement(SL_PLANE).isNull()) { node = _LoadNode(og_element, dt_node); //Node } else { node = _LoadMesh(og_element, dt_node); //Mesh } } return node; }
void SoundHubObject::InitResources() { PyObject* pysounds = gGame->SceneCall<PyObject*>( "LoadAllSounds" ); PyObject *defname, *def, *pyfile, *ismusic; std::string file; Py_ssize_t unused = 0; while( PyDict_Next( pysounds, &unused, &defname, &def ) ) { const char* name = (const char*)PyUnicode_1BYTE_DATA( defname ); pyfile = PyObject_CallMethod( def, "Filename", nullptr ); file = (const char*)PyUnicode_1BYTE_DATA( pyfile ); Py_DECREF( pyfile ); file = "resource/snd/" + file; ismusic = PyObject_GetAttrString( def, "music" ); if( ismusic == Py_True ) _LoadMusic( name, file.c_str() ); else _LoadSound( name, file.c_str() ); Py_DECREF( ismusic ); } Py_DECREF( pysounds ); }
void SoundComponent::SetSoundFileName(const QString& sound_file_name) { if(sound_file_name != mSoundFileName && IsInitialized()) { // we got a new sound; load it _LoadSound(); } mSoundFileName = sound_file_name; }
SoundComponent::SoundComponent(const QString& sound_file_name, const QString& name) : Component(name), mSoundFileName(sound_file_name) { _LoadSound(); }
void SoundPlayer::Initialize() { if (SoundPlayer::singleton == nullptr) { SoundPlayer::singleton = new SoundPlayer(); _LoadSound(SoundPlayer::singleton, SoundBufferArrowsFlying, "ArrowsFlying"); _LoadSound(SoundPlayer::singleton, SoundBufferCavalryMarching, "CavalryMarching"); _LoadSound(SoundPlayer::singleton, SoundBufferCavalryRunning, "CavalryRunning"); _LoadSound(SoundPlayer::singleton, SoundBufferCommandAck, "CommandAck"); _LoadSound(SoundPlayer::singleton, SoundBufferCommandMod, "CommandMod"); _LoadSound(SoundPlayer::singleton, SoundBufferInfantryFighting, "InfantryFighting"); _LoadSound(SoundPlayer::singleton, SoundBufferInfantryGrunting, "InfantryGrunting"); _LoadSound(SoundPlayer::singleton, SoundBufferInfantryMarching, "InfantryMarching"); _LoadSound(SoundPlayer::singleton, SoundBufferInfantryRunning, "InfantryRunning"); _LoadSound(SoundPlayer::singleton, SoundBufferMatchlockFire1, "MatchlockFire1"); _LoadSound(SoundPlayer::singleton, SoundBufferMatchlockFire2, "MatchlockFire2"); _LoadSound(SoundPlayer::singleton, SoundBufferMatchlockFire3, "MatchlockFire3"); _LoadSound(SoundPlayer::singleton, SoundBufferMatchlockFire4, "MatchlockFire4"); } }