/* -------------------- Initialization functions for the SoundManager2 class -------------------- */ bool SoundManager2::initialize( bool debug_flag ){ setDebug( debug_flag ); activate(); setMusicVolume(255); setSoundEffectVolume(255); setMusicChannel(1); setSwapMusicChannel(2); setInitialSoundEffectChannel(3); setSoundEffectChannel(getInitialSoundEffectChannel()); setMaxChannels(64); bool initialized = FSOUND_Init (44100, getMaxChannels(), 0); if(isDebug()){ printf("SoundManager Initialization (debug: %i):\n", isDebug()); printf("\tActive: %i\n", isActive()); printf("\tMusic Volume: %i\n", getMusicVolume()); printf("\tSound Effect Volume: %i\n", getSoundEffectVolume()); printf("\tSound Effect Channel: %i\n", getSoundEffectChannel()); printf("\tMusic Channel: %i\n", getMusicChannel()); printf("\tSwap Music Channel: %i\n", getSwapMusicChannel()); printf("\tInitial Sound Effect Channel: %i\n", getInitialSoundEffectChannel()); printf("\tMusic Channel: %i\n", getMusicChannel()); } return initialized; }
Menu::Menu(int m_x, int m_y, int m_w, int m_h) { this->m_x = m_x; this->m_y = m_y; this->m_w = m_w; this->m_h = m_h; running = true; bgrect.x = m_x; bgrect.y = m_y; bgrect.h = m_h; bgrect.w = m_w; int sliderCount = 1; int offset = (m_h/sliderCount+1)/(sliderCount+1); printf("%d", offset); for(int n = 0; n < sliderCount; ++n){ sliders.push_back(new Slider(m_x + 20, m_y + offset*((n)) + offset/2 + (m_h/(sliderCount+1))*n, m_w - 40, m_h / (sliderCount + 1))); } sliders[0]->setValue(getMusicVolume()); setMusicVolume(sliders[0]->getValue()); //sliders[1]->setValue(66); /*sliders.push_back(new Slider(m_x + 20, m_y + offset, m_w -40, m_h / (sliderCount+1))); // Pushback Slider* sliders.push_back(new Slider(m_x + 20, m_y + offset + 1*m_h /(sliderCount+1)+(offset*1), m_w -40, m_h/(sliderCount+1))); sliders.push_back(new Slider(m_x + 20, m_y + offset + 2*m_h /(sliderCount+1)+(offset*2), m_w -40, m_h/(sliderCount+1))); sliders.push_back(new Slider(m_x + 20, m_y + offset + 3*m_h /(sliderCount+1)+(offset*3), m_w -40, m_h/(sliderCount+1))); sliders.push_back(new Slider(m_x + 20, m_y + offset + 4*m_h /(sliderCount+1)+(offset*4), m_w -40, m_h/(sliderCount+1))); */ }
MusicData::MusicData(string mId, string mFileName, string mName, string mAlbum, string mAuthor) : id{mId}, fileName{mFileName}, name{mName}, album{mAlbum}, author{mAuthor} { musicPtr = getMusicPtr(mId); musicPtr->setLoop(true); musicPtr->setVolume(getMusicVolume()); }
// doDraw //--------------------------------------------------------------------------- void SoundView::doDraw(Surface &viewArea, Surface &clientArea) { MenuTemplateView::doDraw(viewArea, clientArea); char strBuf[256]; const int arrowButtonWidth = 16; iRect visualMeter; int x = optionsMeterStartX + arrowButtonWidth; int y = bodyTextRect.min.y + 15; int yOffset = 15; Surface tempSurface(optionsMeterWidth, 14, 1); // Sound Volume y += yOffset; tempSurface.fill(meterColor); tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor); sprintf(strBuf, "%d %%", getSoundVolume()); tempSurface.bltStringCenter(strBuf, meterTextColor); tempSurface.blt(clientArea, x, y); // Music Volume y += yOffset*3; tempSurface.fill(meterColor); tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor); sprintf(strBuf, "%d %%", getMusicVolume()); tempSurface.bltStringCenter(strBuf, meterTextColor); tempSurface.blt(clientArea, x, y); //clientArea.bltStringCenter("Not available for preview", Color::white); } // end SoundView::doDraw
JNIEXPORT void JNICALL Java_com_nooskewl_monsterrpg2_MyBroadcastReceiver_pauseSound (JNIEnv *env, jobject obj) { backup_music_volume = getMusicVolume(); backup_ambience_volume = getAmbienceVolume(); setMusicVolume(0.0); setAmbienceVolume(0.0); }
void __fastcall__ addToMusicVolume(char add) { char musicVolume = getMusicVolume() + add; musicVolume &= 15; enterNumberInMenuItem(caMenus[menu][1] + 13, musicVolume); drawMenuItem(item); setMusicVolume(musicVolume); }
void loadMusic() { for(auto filePath : getAllFilePaths("Music/", ".ogg")) { string fileName = path(filePath).stem().string(); Music* music{new Music}; music->openFromFile(filePath); music->setVolume(getMusicVolume()); musicPtrsMap.insert(make_pair(fileName, music)); } }
void loadMusic(const string& mPath) { for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Music/", ".ogg")) { string fileName{getNameFromPath(filePath, mPath + "Music/", ".ogg")}; auto& music(assetManager.loadMusic(fileName, filePath)); music.openFromFile(filePath); music.setVolume(getMusicVolume()); music.setLoop(true); } }
// doDraw //--------------------------------------------------------------------------- void OptionsTemplateView::doDraw(Surface &viewArea, Surface &clientArea) { checkBoxFullscreen->setState(GameConfig::video_fullscreen); checkBoxBlendSmoke->setState(GameConfig::video_blendsmoke); checkBoxDrawAllShadows->setState(GameConfig::video_shadows); MenuTemplateView::doDraw(viewArea, clientArea); Surface tempSurface(optionsMeterWidth, 14, 1); // Scroll Rate tempSurface.fill(meterColor); tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor); char strBuf[256]; const int arrowButtonWidth = 16; int x = bodyTextRect.min.x + optionsMeterStartX + arrowButtonWidth; int y = bodyTextRect.min.y ; int yOffset = 17; y += yOffset*7; sprintf(strBuf, "%d %%", int((float(getScrollRate()) / float(gameconfig->scrollrate.getMax())) * 100.0f)); tempSurface.bltStringCenter(strBuf, meterTextColor); tempSurface.blt(clientArea, x, y); y += yOffset*2; // Sound Volume y += yOffset*3; tempSurface.fill(meterColor); tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor); sprintf(strBuf, "%d %%", getSoundVolume()); tempSurface.bltStringCenter(strBuf, meterTextColor); tempSurface.blt(clientArea, x, y); // Music Volume y += yOffset*3; tempSurface.fill(meterColor); tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor); sprintf(strBuf, "%d %%", getMusicVolume()); tempSurface.bltStringCenter(strBuf, meterTextColor); tempSurface.blt(clientArea, x, y); } // end VisualsView::doDraw
void ToucheEngine::redrawMenu(void *menu) { MenuData *menuData = (MenuData *)menu; Graphics::fillRect(_offscreenBuffer, kScreenWidth, 90, 102, 460, 196, 0xF8); Graphics::drawRect(_offscreenBuffer, kScreenWidth, 90, 102, 460, 196, 0xF7, 0xF9); Graphics::drawRect(_offscreenBuffer, kScreenWidth, 106, 118, 340, 164, 0xF9, 0xF7); switch (menuData->mode) { case kMenuSettingsMode: drawVolumeSlideBar(_offscreenBuffer, kScreenWidth, getMusicVolume()); menuData->buttonsTable[5].data = 0; menuData->buttonsTable[6].data = 0; menuData->buttonsTable[7].data = 0; menuData->buttonsTable[5 + _talkTextMode].data = -86; break; case kMenuLoadStateMode: case kMenuSaveStateMode: drawSaveGameStateDescriptions(_offscreenBuffer, kScreenWidth, menuData, _saveLoadCurrentPage, _saveLoadCurrentSlot); break; } for (uint i = 0; i < menuData->buttonsCount; ++i) { drawButton(&menuData->buttonsTable[i]); } }
void refreshVolumes() { for(const auto& pair : assetManager.getSounds()) pair.second->setVolume(getSoundVolume()); for(const auto& pair : assetManager.getMusics()) pair.second->setVolume(getMusicVolume()); }
// returns 1 if should restart char __fastcall__ runMenu(char canReturn) { if (canReturn) { playSound(SOUND_STNMOV); } waitForEscReleased(); drawLogo(); // printCentered("akronyme analogiker", 0); // printCentered("presents", 1); enterNumberInMenuItem(caMenus[2][0] + 15, getEffectsVolume()); enterNumberInMenuItem(caMenus[2][1] + 13, getMusicVolume()); menu = 0; item = 0; stackDepth = 0; drawMenu(canReturn); while (menu != 255) { oldKeys = moveKeys; oldCtrlKeys = ctrlKeys; moveKeys = readInput(); ctrlKeys = getControlKeys(); if (keyPressed(KEY_FORWARD)) { char oldItem = item; --item; if (item == 255) item = menuSize-1; drawMenuItem(oldItem); drawMenuItem(item); playSound(SOUND_STNMOV); } if (keyPressed(KEY_BACK)) { char oldItem = item; ++item; if (item == menuSize) item = 0; drawMenuItem(oldItem); drawMenuItem(item); playSound(SOUND_STNMOV); } if (menu == 2) { if (keyPressed(KEY_MOVERIGHT) || ctrlKeyPressed(KEY_RETURN)) { if (item == 0) { addToEffectsVolume(1); } else if (item == 1) { addToMusicVolume(1); } } if (keyPressed(KEY_MOVELEFT)) { if (item == 0) { addToEffectsVolume(255); } else if (item == 1) { addToMusicVolume(255); } } } if (ctrlKeyPressed(KEY_ESC)) { if (stackDepth == 0) { if (canReturn) { playSound(SOUND_OOF); waitForEscReleased(); return 0; } } else { playSound(SOUND_OOF); --stackDepth; menu = menuStack[stackDepth]; item = itemStack[stackDepth]; drawMenu(canReturn); } } if (ctrlKeyPressed(KEY_RETURN)) { signed char next; if (menu == 1) episode = item; next = nextMenu[menu][item]; if (next == -66) { playSound(SOUND_OOF); return 0; } else if (next != -10) { playSound(SOUND_PISTOL); if (next >= 0) { if (next > menu) { menuStack[stackDepth] = menu; itemStack[stackDepth] = item; ++stackDepth; item = 0; } else { --stackDepth; item = itemStack[stackDepth]; } menu = next; drawMenu(canReturn); } else { next = (-next)-1; clearScreen(); waitForRaster(30); load_full_text_screen(textScreens[next]); setupBitmap(8 + 2); // multicolor red drawLogo(); drawMenu(canReturn); } } else if (menu == 3) { stopMusic(); playSound(SOUND_PISTOL); clearScreen(); waitForRaster(30); difficulty = item; return 1; } } } }