Esempio n. 1
0
void GameSwitcher::logic() {
	// reset the mouse cursor
	curs->logic();

	// Check if a the game state is to be changed and change it if necessary, deleting the old state
	GameState* newState = currentState->getRequestedGameState();
	if (newState != NULL) {
		if (currentState->reload_backgrounds || render_device->reloadGraphics())
			loadBackgroundList();

		delete currentState;
		currentState = newState;
		currentState->load_counter++;

		// reload the fps meter position
		loadFPS();

		// if this game state does not provide music, use the title theme
		if (!currentState->hasMusic)
			if (!snd->isPlayingMusic())
				loadMusic();

		// if this game state shows a background image, load it here
		if (currentState->has_background)
			loadBackgroundImage();
		else
			freeBackground();
	}

	// resize background image when window is resized
	if (inpt->window_resized && currentState->has_background) {
		refreshBackground();
	}

	currentState->logic();

	// Check if the GameState wants to quit the application
	done = currentState->isExitRequested();

	if (currentState->reload_music) {
		loadMusic();
		currentState->reload_music = false;
	}
}
Esempio n. 2
0
static void startDatabaseTree(void)
{
    loadMusic();
    DatabaseBox *dbbox = new DatabaseBox(GetMythMainWindow(),
                         chooseCD(), "music_select", "music-", "music database");
    dbbox->exec();
    delete dbbox;

    gPlayer->constructPlaylist();
}
Esempio n. 3
0
	void loadAssets()
	{
		log("loading fonts"); 		loadFonts();
		log("loading sounds"); 		loadSounds();
		log("loading music"); 		loadMusic();
		log("loading music data"); 	loadMusicData();
		log("loading style data"); 	loadStyleData();
		log("loading level data");	loadLevelData();
		log("loading scores"); 		loadScores();
	}
Esempio n. 4
0
GameSwitcher::GameSwitcher() {

	// The initial state is the title screen
	currentState = new GameStateTitle();
	
	done = false;
	music = NULL;
	loadMusic();
	
}
void SoundManager2::playMusic( const char* filename ){   
     if(isActive()){
        loadMusic(filename);
        FSOUND_PlaySound (musicChannel, musicHandle);
        if(isDebug()){
            printf("Music Started on Channel: %i\n", musicChannel);
        }
        //TODO cycle the music channels using swapMusicHandle and swapMusicChannel 
        //allowing a fade in/fade out kinda deal
     }
}
Esempio n. 6
0
static void startPlayback(void)
{
    loadMusic();
    PlaybackBoxMusic *pbb;
    pbb = new PlaybackBoxMusic(GetMythMainWindow(),
                               "music_play", "music-", chooseCD(), "music_playback");
    pbb->exec();
    qApp->processEvents();

    delete pbb;
}
Esempio n. 7
0
static void runScan(void)
{
    loadMusic();

    if ("" != gMusicData->startdir)
    {
        FileScanner *fscan = new FileScanner();
        fscan->SearchDir(gMusicData->startdir);
        gMusicData->reloadMusic();
        delete fscan;
    }
}
Esempio n. 8
0
void Sound::playMusic(const std::string &filename)
{
    mCurrentMusicFile = filename;

    if (!mInstalled)
        return;

    haltMusic();

    if ((mMusic = loadMusic(filename)))
        Mix_PlayMusic(mMusic, -1); // Loop forever
}
Esempio n. 9
0
void SDL::playMusic( string musicFile )
{
	/// stop all other music
	Mix_HaltMusic();

	if( musics.find(musicFile) == musics.end() )
	{
		loadMusic( musicFile );
	}

	Mix_PlayMusic( musics[musicFile], -1 );
}
Esempio n. 10
0
static void runScan(void)
{
    // maybe we haven't loaded the music yet in which case we wont have a valid music dir set
    if (gMusicData->musicDir.isEmpty())
    {
        QString startdir = gCoreContext->GetSetting("MusicLocation");
        startdir = QDir::cleanPath(startdir);
        if (!startdir.isEmpty() && !startdir.endsWith("/"))
            startdir += "/";

        gMusicData->musicDir = startdir;
    }

    // if we still don't have a valid start dir warn the user and give up
    if (gMusicData->musicDir.isEmpty())
    {
        ShowOkPopup(QObject::tr("You need to tell me where to find your music on the "
                                "'General Settings' page of MythMusic's settings pages."));
       return;
    }

    if (!QFile::exists(gMusicData->musicDir))
    {
        ShowOkPopup(QObject::tr("Can't find your music directory. Have you set it correctly on the "
                                "'General Settings' page of MythMusic's settings pages?"));
       return;
    }

    LOG(VB_GENERAL, LOG_INFO, QString("Scanning '%1' for music files").arg(gMusicData->musicDir));

    FileScanner *fscan = new FileScanner();
    fscan->SearchDir(gMusicData->musicDir);

    // save anything that may have changed
    if (gMusicData->all_music && gMusicData->all_music->cleanOutThreads())
        gMusicData->all_music->save();

    if (gMusicData->all_playlists && gMusicData->all_playlists->cleanOutThreads())
    {
        gMusicData->all_playlists->save();
        int x = gMusicData->all_playlists->getPending();
        SavePending(x);
    }

    // force a complete reload of the tracks and playlists
    gPlayer->stop(true);
    delete gMusicData;

    gMusicData = new MusicData;
    loadMusic();

    delete fscan;
}
Esempio n. 11
0
void Sound::fadeInMusic(const std::string &path, int ms)
{
    mCurrentMusicFile = path;

    if (!mInstalled)
        return;

    haltMusic();

    if ((mMusic = loadMusic(path.c_str())))
        Mix_FadeInMusic(mMusic, -1, ms); // Loop forever
}
Esempio n. 12
0
static void startStreamPlayback(void)
{
    loadMusic();

    MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();

    StreamView *view = new StreamView(mainStack);

    if (view->Create())
        mainStack->AddScreen(view);
    else
        delete view;
}
Esempio n. 13
0
void playLoadedMusic()
{
    if (strcmpignorecase(musicName, "NO_MUSIC") == 0)
    {
        return;
    }

    loadMusic(musicName);

    Mix_PlayMusic(music, -1);

    Mix_VolumeMusic(game.musicDefaultVolume * VOLUME_STEPS);
}
Esempio n. 14
0
static void startDatabaseTree(void)
{
    loadMusic();

    MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();

    QString lastView = gCoreContext->GetSetting("MusicPlaylistEditorView", "tree");
    PlaylistEditorView *view = new PlaylistEditorView(mainStack, lastView);

    if (view->Create())
        mainStack->AddScreen(view);
    else
        delete view;
}
Esempio n. 15
0
Plateau::Plateau(se::Application& application) : myApplication(application),myPopTime(4000000),MAX_ENNEMI(15), myZikIndex(3), myBlastIndex(2)
{
    auto scene = application.getCurrentScene();

    scene->loadMusic(MUSIC[myZikIndex++%3]);
    scene->playMusic();
    myClock.restart();
    myJoueur = std::make_shared<Joueur>(application,*this);

    myApplication.getCurrentScene()->registerRenderable(myJoueur->myEntity);
    myApplication.getCurrentScene()->registerRenderable(myJoueur->myShadow);
    myApplication.getCurrentScene()->registerRenderable(myJoueur);

}
Esempio n. 16
0
void playDefaultBossMusic()
{
    loadMusic("BOSS_MUSIC");

#if DEV == 1
    if (game.gameType == REPLAYING)
    {
        printf("%f BOSS_MUSIC\n", (float)game.frames / 60);
    }
#endif

    Mix_PlayMusic(music, -1);

    Mix_VolumeMusic(game.musicDefaultVolume * VOLUME_STEPS);
}
Esempio n. 17
0
void playBossMusic(char *name)
{
    loadMusic(name);

#if DEV == 1
    if (game.gameType == REPLAYING)
    {
        printf("%f %s\n", (float)game.frames / 60, name);
    }
#endif

    Mix_PlayMusic(music, -1);

    Mix_VolumeMusic(game.musicDefaultVolume * VOLUME_STEPS);
}
Esempio n. 18
0
void Sound::fadeInMusic(const std::string &fileName, int ms)
{
    mCurrentMusicFile = fileName;

    if (!mInstalled || !mPlayMusic)
        return;

    haltMusic();

    if (!fileName.empty())
    {
        mMusic = loadMusic(fileName);
        if (mMusic)
            mMusic->play(-1, ms);
    }
}
Esempio n. 19
0
void Player_Mac::startSound(int nr) {
	Common::StackLock lock(_mutex);
	debug(5, "Player_Mac::startSound(%d)", nr);

	stopAllSounds_Internal();

	const byte *ptr = _vm->getResourceAddress(rtSound, nr);
	assert(ptr);

	if (!loadMusic(ptr)) {
		return;
	}

	_vm->_res->lock(rtSound, nr);
	_soundPlaying = nr;
}
Esempio n. 20
0
static void playGameOverMusic()
{
    STRNCPY(musicName, "GAMEOVER_MUSIC", MAX_VALUE_LENGTH);

    if (game.audio == FALSE || game.musicDefaultVolume == 0)
    {
        return;
    }

    Mix_HookMusicFinished(NULL);

    loadMusic("GAMEOVER_MUSIC");

    Mix_PlayMusic(music, -1);

    Mix_VolumeMusic(game.musicDefaultVolume * VOLUME_STEPS);
}
Esempio n. 21
0
bool LoadingScene::init(){
	if (!Layer::init())
	{
		return false;
	}
	count = 1;
	//loading picture matter
	loadPicture();
	auto logo = Sprite::create(LOGO_FILENAME);
	logo->setVisible(true);
	logo->setPosition(480, 320);
	this->addChild(logo);

	//loading music matter
	loadMusic();
	return true;
}
Esempio n. 22
0
int mythplugin_config(void)
{
    //TODO do we need this here?
    loadMusic();

    gMusicData->paths = gCoreContext->GetSetting("TreeLevels");
    gMusicData->startdir = gCoreContext->GetSetting("MusicLocation");
    gMusicData->startdir = QDir::cleanPath(gMusicData->startdir);

    if (!gMusicData->startdir.endsWith("/"))
        gMusicData->startdir += "/";

    Metadata::SetStartdir(gMusicData->startdir);

    Decoder::SetLocationFormatUseTags();

    return runMenu("music_settings.xml");
}
Esempio n. 23
0
static void startImport(void)
{
    loadMusic();

    MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();

    ImportMusicDialog *import = new ImportMusicDialog(mainStack);

    if (import->Create())
    {
        mainStack->AddScreen(import);
        QObject::connect(import, SIGNAL(importFinished()),
                gMusicData, SLOT(reloadMusic()),
                Qt::QueuedConnection);
    }
    else
        delete import;
}
Esempio n. 24
0
GameSwitcher::GameSwitcher() {

    // The initial state is the intro cutscene and then title screen
    GameStateTitle *title=new GameStateTitle();
    GameStateCutscene *intro = new GameStateCutscene(title);

    currentState = intro;

    if (!intro->load("cutscenes/intro.txt")) {
        delete intro;
        currentState = title;
    }

    label_fps = new WidgetLabel();
    done = false;
    loadMusic();
    loadFPS();
}
Esempio n. 25
0
static void MusicCallback(void *data, QString &selection)
{
    (void) data;

    QString sel = selection.toLower();
    if (sel == "music_create_playlist")
        startDatabaseTree();
    else if (sel == "music_play")
        startPlayback();
    else if (sel == "music_rip")
    {
        startRipper();
    }
    else if (sel == "music_import")
    {
        startImport();
    }
    else if (sel == "settings_scan")
    {
        if ("" != gMusicData->startdir)
        {
            loadMusic();
            FileScanner *fscan = new FileScanner();
            fscan->SearchDir(gMusicData->startdir);
            gMusicData->reloadMusic();
            delete fscan;
        }
    }
    else if (sel == "music_set_general")
    {
        MusicGeneralSettings settings;
        settings.exec();
    }
    else if (sel == "music_set_player")
    {
        MusicPlayerSettings settings;
        settings.exec();
    }
    else if (sel == "music_set_ripper")
    {
        MusicRipperSettings settings;
        settings.exec();
    }
}
Esempio n. 26
0
void AGOSEngine::vc62_fastFadeOut() {
	vc29_stopAllSounds();

	if (!_fastFadeOutFlag) {
		uint i, fadeSize, fadeCount;

		_fastFadeCount = 256;
		if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
			if (_windowNum == 4)
				_fastFadeCount = 208;
		}

		if (getGameType() == GType_FF || getGameType() == GType_PP) {
			if (getGameType() == GType_FF && getBitFlag(75)) {
				fadeCount = 4;
				fadeSize = 64;
			} else {
				fadeCount = 32;
				fadeSize = 8;
			}
		} else {
			fadeCount = 64;
			fadeSize = 4;
		}

		for (i = fadeCount; i != 0; --i) {
			paletteFadeOut(_currentPalette, _fastFadeCount, fadeSize);
			_system->setPalette(_currentPalette, 0, _fastFadeCount);
			delay(5);
		}

		if (getGameType() == GType_WW || getGameType() == GType_FF || getGameType() == GType_PP) {
			clearSurfaces();
		} else {
			if (_windowNum != 4) {
				clearSurfaces();
			}
		}
	}
	if (getGameType() == GType_SIMON2) {
		if (_nextMusicToPlay != -1)
			loadMusic(_nextMusicToPlay);
	}
}
Esempio n. 27
0
Music::Music()
{
   // qDebug()<<"making music...";
    status=Open;
    loadMusic();
    QString fileDir="../chess/music/bg.wav";
    QFileInfo file(fileDir);
    if (file.exists()){
        background = new QSound(fileDir);
    }else{
        background = new QSound(":/music/music/background.wav");
    }
    background->setLoops(QSound::Infinite);


    background->play();

    qDebug()<<"music maked";
}
Esempio n. 28
0
void PreLoad::onEnterTransitionDidFinish(){
	//调用父类的OnEnterTransitionDidFinish方法
	Layer::onEnterTransitionDidFinish();
	//加载preloadResources.plist配置文件,读取文件中的游戏资源名称列表,返回一个ValueMap对象
	ValueMap map = FileUtils::getInstance()->getValueMapFromFile("preloadResources.plist");
	//通过key值取出每种不同类型资源的ValueVector数组
	ValueVector spriteSheets = map.at("SpriteSheets").asValueVector();
	ValueVector effects = map.at("Sounds").asValueVector();
	ValueVector musics = map.at("Musics").asValueVector();
	//多个ValueVector数组的size相加得到需要加载的资源总数量
	_sourceCount = spriteSheets.size() + effects.size() + musics.size();
	//设置进度条更新进度=100 /_sourceCount
	_progressInterval = 100 / _sourceCount;
	//依次加载资源
	loadMusic(musics);
	loadEffect(effects);
	loadSpriteSheets(spriteSheets);

}
Esempio n. 29
0
static void runRipCD(void)
{
    loadMusic();

#ifndef USING_MINGW
    MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();

    Ripper *rip = new Ripper(mainStack, chooseCD());

    if (rip->Create())
        mainStack->AddScreen(rip);
    else
        delete rip;

    QObject::connect(rip, SIGNAL(ripFinished()),
                     gMusicData, SLOT(reloadMusic()),
                     Qt::QueuedConnection);
#endif
}
Esempio n. 30
0
void SoundManager::playMusic(const std::string &fileName)
{
    if (!mInstalled || !mPlayMusic)
        return;

    if (mCurrentMusicFile == fileName)
        return;

    mCurrentMusicFile = fileName;

    haltMusic();

    if (!fileName.empty())
    {
        mMusic = loadMusic(fileName);
        if (mMusic)
            mMusic->play();
    }
}