コード例 #1
0
ファイル: music.c プロジェクト: DrItanium/moo
void pause_music(
	boolean pause)
{
	if(music_playing())
	{
		boolean pause_it= FALSE;

		/* If they want us to pause, and it is not already paused. */
		if(pause)
		{
			if(!(music_state->flags & _song_paused))
			{
				music_state->flags |= _song_paused;
				pause_it= TRUE;
			}
		} else {
			if(music_state->flags & _song_paused)
			{
				music_state->flags &= ~_song_paused;
				pause_it= TRUE;
			}
		}

		/* SndPauseFilePlay is a toggle */
		if(pause_it)
		{
			OSErr error;
			
			error= SndPauseFilePlay(music_state->channel);
			vwarn(error==noErr, csprintf(temporary, "Pause error: %d;g", error));
		}
	}
}
コード例 #2
0
ファイル: music.c プロジェクト: DrItanium/moo
void queue_song(
	short song_index)
{
	if (music_state && music_state->initialized && get_sound_volume())
	{
		if (!music_state->channel)
		{	
			allocate_music_channel();
		}
	
		if (music_state->channel)
		{
			if (music_playing())
			{
				/* By setting the song_index after we tell it to fade, we will */
				/*  cause the new song to start at the end of the fade. */
				fade_out_music(10*MACINTOSH_TICKS_PER_SECOND);
				music_state->song_index= song_index;
			}
			else
			{
				assert(music_state->state==_no_song_playing);
		
				/* Must be done everytime in case Jason killed it in sound.c */
				music_state->channel->userInfo= (long) music_state;
				music_state->song_index= song_index;
				music_state->state= _delaying_for_loop;
				music_state->phase= 1;
				music_state->ticks_at_last_update= TickCount();
				music_state->flags &= ~_song_completed;
				/* next time through we will start.. */
			}
		}
	}
}
コード例 #3
0
ファイル: music.c プロジェクト: DrItanium/moo
void fade_out_music(
	short duration)
{
	if(music_playing())
	{
		music_state->fade_duration= duration;
		music_state->phase= duration;
		music_state->state= _music_fading;
		music_state->ticks_at_last_update= TickCount();
		music_state->fade_interval_duration= 5;
		music_state->fade_interval_ticks= 5;
		music_state->song_index= NONE;
	}
}
コード例 #4
0
ファイル: newsroom.c プロジェクト: pakoito/openomf
int newsroom_create(scene *scene) {
    newsroom_local *local = malloc(sizeof(newsroom_local));

    local->news_id = rand_int(24)*2;
    local->screen = 0;
    menu_background_create(&local->news_bg, 280, 50);
    str_create(&local->news_str);
    str_create(&local->pilot1);
    str_create(&local->pilot2);
    str_create(&local->har1);
    str_create(&local->har2);

    if(!music_playing()) {
        char *filename = get_path_by_id(PSM_MENU);
        music_play(filename);
        free(filename);
    }

    game_player *p1 = game_state_get_player(scene->gs, 0);
    game_player *p2 = game_state_get_player(scene->gs, 1);

    int health = 0;
    if (p2->sp_wins > 0) {
        // AI won, player lost
        local->won = 0;
        health = game_player_get_score(p2)->health;
    } else {
        local->won = 1;
        health = game_player_get_score(p1)->health;
    }

    DEBUG("health is %d", health);

    if (health > 40 && local->won == 1) {
        local->news_id = rand_int(6)*2;
    } else if (local->won == 1) {
        local->news_id = 12+rand_int(6)*2;
    } else if (health < 40 && local->won == 0) {
        local->news_id = 38+rand_int(5)*2;
    } else {
        local->news_id = 24+rand_int(7)*2;
    }

    // XXX TODO get the real sex of pilot
    // XXX TODO strip spaces from the end of the pilots name
    // XXX TODO set winner/loser names properly
    newsroom_set_names(local, lang_get(20+p1->pilot_id),
                              lang_get(20+p2->pilot_id),
                              get_id_name(p1->har_id),
                              get_id_name(p2->har_id),
                              pilot_sex(p1->pilot_id), pilot_sex(p2->pilot_id));
    newsroom_fixup_str(local);


    // Continue Dialog
    dialog_create(&local->continue_dialog, DIALOG_STYLE_YES_NO, "DO YOU WISH TO CONTINUE?", 72, 60);
    local->continue_dialog.userdata = scene;
    local->continue_dialog.clicked = newsroom_continue_dialog_clicked;

    // Set callbacks
    scene_set_userdata(scene, local);
    scene_set_event_cb(scene, newsroom_event);
    scene_set_render_overlay_cb(scene, newsroom_overlay_render);
    scene_set_free_cb(scene, newsroom_free);
    scene_set_static_tick_cb(scene, newsroom_static_tick);

    // Pick renderer
    video_select_renderer(VIDEO_RENDERER_HW);

    return 0;
}