~ubuntu-branches/ubuntu/intrepid/onscripter/intrepid

« back to all changes in this revision

Viewing changes to ONScripterLabel_file2.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2008-02-12 20:22:19 UTC
  • mfrom: (0.1.2 lenny) (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080212202219-jx4xdi0izczp0pcy
Tags: 20080121-0ubuntu1
* Fake-sync onscripter 0.0.20080121-1 from Debian unstable (LP: #187890).
  Drop the leading zeroes from the version due to different versioning in
  Debian and Ubuntu.
* debian/control:
  + Modify Maintainer value to match DebianMaintainerField spec.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 *  ONScripterLabel_file2.cpp - FILE I/O of ONScripter
4
4
 *
5
 
 *  Copyright (c) 2001-2005 Ogapee. All rights reserved.
 
5
 *  Copyright (c) 2001-2008 Ogapee. All rights reserved.
6
6
 *
7
7
 *  ogapee@aqua.dti2.ne.jp
8
8
 *
119
119
    readInt(); // 0
120
120
    readInt(); // 0
121
121
    
 
122
    if (file_version >= 203){
 
123
        readInt(); // -1
 
124
        readInt(); // -1
 
125
        readInt(); // -1
 
126
    }
 
127
    
122
128
    for ( i=0 ; i<MAX_SPRITE_NUM ; i++ ){
123
129
        sprite_info[i].remove();
124
130
        readStr( &sprite_info[i].image_name );
131
137
        if ( readInt() == 1 ) sprite_info[i].visible = true;
132
138
        else                  sprite_info[i].visible = false;
133
139
        sprite_info[i].current_cell = readInt();
 
140
        if (file_version >= 203) readInt(); // -1
134
141
    }
135
142
 
136
143
    readVariables( 0, script_h.global_variable_border );
185
192
    // Sound
186
193
    stopCommand();
187
194
    loopbgmstopCommand();
 
195
    stopAllDWAVE();
188
196
 
189
197
    readStr( &midi_file_name ); // MIDI file
190
198
    readStr( &wave_file_name ); // wave, waveloop
194
202
    // play, playonce MIDI
195
203
    if ( readInt() == 1 ){
196
204
        midi_play_loop_flag = true;
197
 
        internal_midi_play_loop_flag = true;
198
205
        current_cd_track = -2;
199
 
        playMIDIFile(midi_file_name);
 
206
        playSound(midi_file_name, SOUND_MIDI, midi_play_loop_flag);
200
207
    }
201
208
    else
202
209
        midi_play_loop_flag = false;
205
212
    if ( readInt() == 1 ) wave_play_loop_flag = true;
206
213
    else                  wave_play_loop_flag = false;
207
214
    if ( wave_file_name && wave_play_loop_flag )
208
 
        playWave( wave_file_name, wave_play_loop_flag, MIX_WAVE_CHANNEL );
 
215
        playSound(wave_file_name, SOUND_WAVE|SOUND_OGG, wave_play_loop_flag, MIX_WAVE_CHANNEL);
209
216
 
210
217
    // play, playonce
211
218
    if ( readInt() == 1 ) cd_play_loop_flag = true;
212
219
    else                  cd_play_loop_flag = false;
213
 
    if ( current_cd_track >= 0 ){
214
 
        if ( cdaudio_flag ){
215
 
            if ( cdrom_info ) playCDAudio( current_cd_track );
216
 
        }
217
 
        else{
218
 
            playMP3( current_cd_track );
219
 
        }
220
 
    }
 
220
    if ( current_cd_track >= 0 ) playCDAudio();
221
221
 
222
222
    // bgm, mp3, mp3loop
223
223
    if ( readInt() == 1 ) music_play_loop_flag = true;
226
226
    else                  mp3save_flag = false;
227
227
    readStr( &music_file_name );
228
228
    if ( music_file_name ){
229
 
        if ( playWave( music_file_name, music_play_loop_flag, MIX_BGM_CHANNEL ) )
230
 
#if defined(EXTERNAL_MUSIC_PLAYER)
231
 
            if (playMusicFile()){
232
 
#else
233
 
            if (playMP3( 0 )){
234
 
#endif
235
 
                internal_midi_play_loop_flag = music_play_loop_flag;
236
 
                playMIDIFile(music_file_name);
237
 
            }
 
229
        playSound(music_file_name,
 
230
                  SOUND_WAVE | SOUND_OGG_STREAMING | SOUND_MP3 | SOUND_MIDI,
 
231
                  music_play_loop_flag, MIX_BGM_CHANNEL);
238
232
    }
239
233
 
240
234
    erase_text_window_mode = readInt();
330
324
    readStr( &loop_bgm_name[0] );
331
325
    readStr( &loop_bgm_name[1] );
332
326
    if ( loop_bgm_name[0] ) {
333
 
        if ( loop_bgm_name[1] ) playWave( loop_bgm_name[1], false, MIX_LOOPBGM_CHANNEL1, WAVE_PRELOAD );
334
 
        playWave( loop_bgm_name[0], false, MIX_LOOPBGM_CHANNEL0 );
 
327
        if ( loop_bgm_name[1] )
 
328
            playSound(loop_bgm_name[1],
 
329
                      SOUND_PRELOAD|SOUND_WAVE|SOUND_OGG, false, MIX_LOOPBGM_CHANNEL1);
 
330
        playSound(loop_bgm_name[0],
 
331
                  SOUND_WAVE|SOUND_OGG, false, MIX_LOOPBGM_CHANNEL0);
335
332
    }
336
333
 
337
334
    if ( file_version >= 201 ){
340
337
        ruby_struct.font_size_xy[0] = readInt();
341
338
        ruby_struct.font_size_xy[1] = readInt();
342
339
        readStr( &ruby_struct.font_name );
 
340
        sentence_font.setRubyOnFlag(rubyon_flag);
 
341
    }
 
342
 
 
343
    if (file_version >= 204){
 
344
        readInt();
 
345
        
 
346
        for ( i=0 ; i<MAX_SPRITE2_NUM ; i++ ){
 
347
            sprite2_info[i].remove();
 
348
            readStr( &sprite2_info[i].image_name );
 
349
            if ( sprite2_info[i].image_name ){
 
350
                parseTaggedString( &sprite2_info[i] );
 
351
                setupAnimationInfo( &sprite2_info[i] );
 
352
            }
 
353
            sprite2_info[i].pos.x = readInt() * screen_ratio1 / screen_ratio2;
 
354
            sprite2_info[i].pos.y = readInt() * screen_ratio1 / screen_ratio2;
 
355
            sprite2_info[i].scale_x = readInt();
 
356
            sprite2_info[i].scale_y = readInt();
 
357
            sprite2_info[i].rot = readInt();
 
358
            if ( readInt() == 1 ) sprite2_info[i].visible = true;
 
359
            else                  sprite2_info[i].visible = false;
 
360
            j = readInt();
 
361
            if (j == -1)
 
362
                sprite2_info[i].trans = 256;
 
363
            else
 
364
                sprite2_info[i].trans = j;
 
365
            sprite2_info[i].blending_mode = readInt();
 
366
        }
 
367
        
 
368
        readInt();
 
369
        readInt();
 
370
        if (file_version >= 205) readInt(); // 1
 
371
        readInt();
 
372
        readInt();
 
373
        readInt();
 
374
        readInt();
 
375
        if (file_version >= 205) readChar(); // 0
343
376
    }
344
377
    
345
378
    int text_num = readInt();
346
 
    start_text_buffer = current_text_buffer;
 
379
    start_page = current_page;
347
380
    for ( i=0 ; i<text_num ; i++ ){
348
 
        clearCurrentTextBuffer();
 
381
        clearCurrentPage();
349
382
        do{
350
 
            current_text_buffer->buffer2[current_text_buffer->buffer2_count] = readChar();
 
383
            current_page->text[current_page->text_count] = readChar();
351
384
        }
352
 
        while( current_text_buffer->buffer2[current_text_buffer->buffer2_count++] );
353
 
        current_text_buffer->buffer2_count--;
354
 
        current_text_buffer = current_text_buffer->next;
 
385
        while( current_page->text[current_page->text_count++] );
 
386
        if (file_version == 203) readChar(); // 0
 
387
        current_page->text_count--;
 
388
        current_page = current_page->next;
355
389
    }
356
 
    clearCurrentTextBuffer();
 
390
    clearCurrentPage();
357
391
 
 
392
    if (file_version >= 205){
 
393
        Page *page = start_page;
 
394
        j = readInt();
 
395
        for (i=0 ; i<j ; i++){
 
396
            readStr(&page->tag);
 
397
            page = page->next;
 
398
        }
 
399
    }
 
400
    else if (file_version >= 204){
 
401
        readInt();
 
402
        readInt();
 
403
    }
 
404
    
358
405
    i = readInt();
359
406
    current_label_info = script_h.getLabelByLine( i );
360
407
    current_line = i - current_label_info.start_line;
368
415
    }
369
416
    script_h.setCurrent( buf );
370
417
 
371
 
    display_mode = next_display_mode = NORMAL_DISPLAY_MODE;
372
 
    current_refresh_mode = REFRESH_NORMAL_MODE;
373
 
 
 
418
    display_mode = shelter_display_mode = TEXT_DISPLAY_MODE;
374
419
    clickstr_state = CLICK_NONE;
375
420
    event_mode = 0;//WAIT_SLEEP_MODE;
376
421
    draw_cursor_flag = false;
436
481
    writeInt( 0, output_flag );
437
482
    writeInt( 0, output_flag );
438
483
    writeInt( 0, output_flag );
 
484
 
 
485
    writeInt( -1, output_flag );
 
486
    writeInt( -1, output_flag );
 
487
    writeInt( -1, output_flag );
439
488
    
440
489
    for ( i=0 ; i<MAX_SPRITE_NUM ; i++ ){
441
490
        writeStr( sprite_info[i].image_name, output_flag );
443
492
        writeInt( sprite_info[i].pos.y * screen_ratio2 / screen_ratio1, output_flag );
444
493
        writeInt( sprite_info[i].visible?1:0, output_flag );
445
494
        writeInt( sprite_info[i].current_cell, output_flag );
 
495
        writeInt( -1, output_flag );
446
496
    }
447
497
 
448
498
    writeVariables( 0, script_h.global_variable_border, output_flag );
542
592
        }
543
593
    }
544
594
 
545
 
    writeInt( 1, output_flag );
 
595
    writeInt( 1, output_flag ); // unidentified (not 1) data in version 205
546
596
    writeInt( 0, output_flag );
547
597
    writeInt( 1, output_flag );
548
598
    writeStr( btndef_info.image_name, output_flag );
562
612
    writeInt( ruby_struct.font_size_xy[1], output_flag );
563
613
    writeStr( ruby_struct.font_name, output_flag );
564
614
    
565
 
    TextBuffer *tb = current_text_buffer;
566
 
    int text_num = 0;
567
 
    while( tb != start_text_buffer ){
568
 
        tb = tb->previous;
569
 
        text_num++;
570
 
    }
571
 
    writeInt( text_num, output_flag );
572
 
 
573
 
    for ( i=0 ; i<text_num ; i++ ){
574
 
        for ( j=0 ; j<tb->buffer2_count ; j++ )
575
 
            writeChar( tb->buffer2[j], output_flag );
576
 
        writeChar( 0, output_flag );
577
 
        tb = tb->next;
578
 
    }
579
 
 
 
615
    writeInt( 0, output_flag );
 
616
    
 
617
    for ( i=0 ; i<MAX_SPRITE2_NUM ; i++ ){
 
618
        writeStr( sprite2_info[i].image_name, output_flag );
 
619
        writeInt( sprite2_info[i].pos.x * screen_ratio2 / screen_ratio1, output_flag );
 
620
        writeInt( sprite2_info[i].pos.y * screen_ratio2 / screen_ratio1, output_flag );
 
621
        writeInt( sprite2_info[i].scale_x, output_flag );
 
622
        writeInt( sprite2_info[i].scale_y, output_flag );
 
623
        writeInt( sprite2_info[i].rot, output_flag );
 
624
        writeInt( sprite2_info[i].visible?1:0, output_flag );
 
625
        if (sprite2_info[i].trans == 256)
 
626
            writeInt( -1, output_flag );
 
627
        else
 
628
            writeInt( sprite2_info[i].trans, output_flag );
 
629
        writeInt( sprite2_info[i].blending_mode, output_flag );
 
630
    }
 
631
 
 
632
    writeInt( 0, output_flag );
 
633
    writeInt( 0, output_flag );
 
634
    writeInt( 1, output_flag ); // added in version 205
 
635
    writeInt( 0, output_flag );
 
636
    writeInt( 0, output_flag );
 
637
    writeInt( 0, output_flag );
 
638
    writeInt( 0, output_flag );
 
639
    writeChar( 0, output_flag ); // added in version 205
 
640
    
 
641
    Page *page = current_page;
 
642
    int num_page = 0;
 
643
    while( page != start_page ){
 
644
        page = page->previous;
 
645
        num_page++;
 
646
    }
 
647
 
 
648
    writeInt( num_page, output_flag );
 
649
    for ( i=0 ; i<num_page ; i++ ){
 
650
        for ( j=0 ; j<page->text_count ; j++ )
 
651
            writeChar( page->text[j], output_flag );
 
652
        writeChar( 0, output_flag );
 
653
        page = page->next;
 
654
    }
 
655
 
 
656
    page = start_page;
 
657
    writeInt(num_page, output_flag);
 
658
    for (i=0 ; i<num_page ; i++){
 
659
        if (page->tag)
 
660
            for ( j=0 ; j<(int)strlen(page->tag) ; j++ )
 
661
                writeChar( page->tag[j], output_flag );
 
662
        writeChar( 0, output_flag );
 
663
        page = page->next;
 
664
    }
 
665
    
580
666
    writeInt( current_label_info.start_line + current_line, output_flag );
581
667
    char *buf = script_h.getAddressByLine( current_label_info.start_line + current_line );
582
668
    //printf("save %d:%d\n", current_label_info.start_line, current_line);