Esempio n. 1
0
int MacroLoad()
{
	int length;

	if (ui_get_filename( filename, "*.MAC", "LOAD MACRO" ))   {
		if (RecordBuffer) free( RecordBuffer );
		RecordBuffer = (UI_EVENT *)ReadFile( filename, &length );
		MacroNumEvents = RecordBuffer[0].data;
	}
	return 1;
}
Esempio n. 2
0
// Save game
// returns 1 if successful
//	returns 0 if unsuccessful
int SaveGameData()
{
	char Message[200];

	if (gamestate_not_restored) {
		sprintf( Message, "Game State has not been restored...\nContinue?\n");
		if (MessageBox( -2, -2, 2, Message, "NO", "Yes" )==1) 
			return 0;
		}
		
   if (ui_get_filename( game_filename, "*.LVL", "SAVE GAME" )) {
		int saved_flag;
		vms_vector save_pos = ConsoleObject->pos;
		vms_matrix save_orient = ConsoleObject->orient;
		int save_segnum = ConsoleObject->segnum;

      checkforgamext(game_filename);

		if (Perm_player_segnum > Highest_segment_index)
			Perm_player_segnum = -1;

		if (Perm_player_segnum!=-1) {
			if (get_seg_masks(&Perm_player_position,Perm_player_segnum,0).centermask==0) {
				ConsoleObject->pos = Perm_player_position;
				obj_relink(ConsoleObject-Objects,Perm_player_segnum);
				ConsoleObject->orient = Perm_player_orient;
			}
			else
				Perm_player_segnum=-1;		//position was bogus
		}
      saved_flag=save_level(game_filename);
		if (Perm_player_segnum!=-1) {
			int	found_save_segnum;

			if (save_segnum > Highest_segment_index)
				save_segnum = 0;

			ConsoleObject->pos = save_pos;
			found_save_segnum = find_point_seg(&save_pos,save_segnum);
			if (found_save_segnum == -1) {
				compute_segment_center(&save_pos, &(Segments[save_segnum]));
				found_save_segnum = save_segnum;
			}

			obj_relink(ConsoleObject-Objects,found_save_segnum);
			ConsoleObject->orient = save_orient;
		}
		if (saved_flag)
			return 0;
		mine_changed = 0;
	}
	return 1;
}
Esempio n. 3
0
int SaveMine()
{
    // Save mine
//	med_save_mine("TEMP.MIN");
    if (ui_get_filename( mine_filename, "*.MIN", "SAVE MINE" ))
    {
        checkforext(mine_filename, "MIN");
        if (med_save_mine(mine_filename))
            return 0;
        mine_changed = 0;
    }

    return 1;
}
Esempio n. 4
0
File: ui.c Progetto: hbkk/sequencer
static int
ui_load_state(ui_t *ui, char *filename)
{
    int i;
    smf_t *smf;
    smf_event_t *event;
    smf_track_t *track;
    jack_nframes_t frame;


    if (!filename) {
        ui->filename = ui_get_filename(ui, ".", "Load file: ");
    }

    if (ui->filename) {
        smf = smf_load(ui->filename);
        if (!smf) {
            free(ui->filename);
            ui->filename = NULL;

            return 0;
        }

        ui_send_clear(ui, ui->pattern);

        for (i = 0; i < 8; i++) {
            track = smf_get_track_by_number(smf, i + 1);
            if (!track) {
                continue;
            }

            while ((event = smf_track_get_next_event(track))) {
                if (smf_event_is_metadata(event)
                        || event->midi_buffer[0] == NOTEOFF) {
                    continue;
                }

                frame = ui_seconds_to_nframes(ui, event->time_seconds);

                ui_send_add(ui, event->midi_buffer[1], event->midi_buffer[2],
                    frame ? frame / (88200 / ui->steps) + 1 : 0, MAX_LEN, i);
            }
        }

        smf_delete(smf);
  	}

    return 1;
}
Esempio n. 5
0
//	-----------------------------------------------------------------------------
int SaveSituation(void)
{
    if (ui_get_filename( sit_filename, "*.SIT", "Save Situation" )) {
        set_extension(sit_filename, "MIN");
        if (med_save_mine(sit_filename)) {
            return 0;
        }

        set_extension(sit_filename, "SIT");
        if (med_save_situation(sit_filename))
            return 0;
    }

    return 1;
}
Esempio n. 6
0
//	-----------------------------------------------------------------------------
int SaveSituation(void)
{
	if (ui_get_filename( sit_filename, "*.SIT", "Save Situation" )) {
		set_extension(sit_filename, "MIN");
		if (med_save_mine(sit_filename)) {
			mprintf((0, "Unable to save mine in SaveSituation.\n"));
			return 0;
		}

		set_extension(sit_filename, "SIT");
		if (med_save_situation(sit_filename))
			return 0;
	}
	
	return 1;
}
Esempio n. 7
0
int MacroSave()
{

	if (MacroNumEvents < 1 )
	{
		MessageBox( -2, -2, 1, "No macro has been defined to save!", "Oops" );
		return 1;
	}

	if (ui_get_filename( filename, "*.MAC", "SAVE MACRO" ))   {
		RecordBuffer[0].type = 7;
		RecordBuffer[0].frame = 0;
		RecordBuffer[0].data = MacroNumEvents;
		WriteFile(  filename, RecordBuffer, sizeof(UI_EVENT)*MacroNumEvents );
	}
	return 1;
}
Esempio n. 8
0
//	-----------------------------------------------------------------------------
//	Load a situation file which consists of x,y,z, orientation matrix, mine name.
int LoadSituation(void)
{
    if (SafetyCheck())  {
        if (ui_get_filename( sit_filename, "*.sit", "Load Situation" ))	{
            checkforext(sit_filename, "SIT");
            if (med_load_situation(sit_filename))
                return 0;
            // set_view_target_from_segment(Cursegp);
            Update_flags = UF_WORLD_CHANGED;
            // SetPlayerFromCurseg();
            med_compress_mine();
            init_info = 1;
            mine_changed = 0;
        }
    }

    return 1;
}
Esempio n. 9
0
// returns 1 if successful
//	returns 0 if unsuccessful
int LoadGameData()
{
if (SafetyCheck())  {
	if (ui_get_filename( game_filename, "*.LVL", "LOAD GAME" ))
		{
		checkforgamext(game_filename);
		if (load_level(game_filename))
			return 0;
		Current_level_num = 0;			//not a real level
		gamestate_not_restored = 0;
		Update_flags = UF_WORLD_CHANGED;
		Perm_player_position = ConsoleObject->pos;
		Perm_player_orient = ConsoleObject->orient;
		Perm_player_segnum = ConsoleObject->segnum;
		}
	}
	return 1;
}
Esempio n. 10
0
File: ui.c Progetto: hbkk/sequencer
static int
ui_save_state(ui_t *ui, char *filename)
{
    int i;
    smf_t *smf;
    smf_track_t *track;
    jack_nframes_t frame;
    double seconds;
    list_t *pattern, *lp;
    note_t *note;

    /* TODO: check if file exists */
    if (!filename) {
        filename = ui_get_filename(ui, ".", "Save to: ");
    }

    ui->filename = filename;

    smf = smf_new();
    if (!smf) {
        return 0;
    }

    for (i = 0; i < 8; i++) {
        track = smf_track_new();
        if (!track) {
            smf_delete(smf);
            return 0;
        }

        smf_add_track(smf, track);

        pattern = ui->patterns[i];
        if (!pattern) {
            continue;
        }

        for (lp = pattern; lp; lp = list_next(lp)) {
            note = (note_t *)list_data(lp);

            frame = 88200 / ui->steps * note->step;
            seconds = ui_nframes_to_seconds(ui, frame);

            note_event_save(note, track, 0x90, seconds);

            /* TODO: decide if and how noteoffs should be saved */
            /* frame = 88200 / ui->steps */
            /*     * ((note->step + note->len) % ui->steps); */
            /* seconds = ui_nframes_to_seconds(ui, frame); */

            /* note_event_save(note, track, NOTEOFF, seconds); */
        }

        if (smf_track_add_eot_seconds(track, 2)) {
            return 0;
        }

    }

    if (smf_save(smf, ui->filename)) {
        return 0;
    }

    return 1;
}