int PonscripterLabel::leaveTextDisplayMode(bool force_leave_flag)
{
    if (!force_leave_flag && (skip_flag || draw_one_page_flag || ctrl_pressed_status)) {
        did_leavetext = true;
        return RET_NOMATCH;
    }
    if (force_leave_flag) did_leavetext = false;

    if (!did_leavetext && (display_mode & TEXT_DISPLAY_MODE) &&
        (force_leave_flag || (erase_text_window_mode != 0))) {

        if (event_mode & EFFECT_EVENT_MODE) {
            if (doEffect(window_effect, false) == RET_CONTINUE) {
                display_mode = NORMAL_DISPLAY_MODE;
                return RET_CONTINUE | RET_NOREAD;
            }

            return RET_WAIT | RET_REREAD;
        }
        else {
            dirty_rect.add(sentence_font_info.pos);
            refreshSurface(backup_surface, &dirty_rect.bounding_box, REFRESH_NORMAL_MODE);
            SDL_BlitSurface(backup_surface, NULL, effect_dst_surface, NULL);
            SDL_BlitSurface(accumulation_surface, NULL, backup_surface, NULL);

            return setEffect(window_effect, false, false);
        }
    }

    return RET_NOMATCH;
}
void ONScripterLabel::executeWindowErase()
{
    if (windowchip_sprite_no >= 0)
        sprite_info[windowchip_sprite_no].visible = false;

#if 0 //windoweffect w/windowerase broken currently FIXME
    refreshSurface(effect_dst_surface, NULL,
                   mode_saya_flag ? REFRESH_SAYA_MODE : REFRESH_NORMAL_MODE);

    //use the windoweffect when executing the erase
    int shelter_menu_mode = system_menu_mode;
    system_menu_mode = SYSTEM_NULL;  //prevents infinite event looping
    if (!setEffect(&window_effect, false, false)) {
        while(doEffect(&window_effect, false));
    }
    system_menu_mode = shelter_menu_mode;
#else
    display_mode = DISPLAY_MODE_NORMAL;
    flush(mode_saya_flag ? REFRESH_SAYA_MODE : REFRESH_NORMAL_MODE);
#endif

    event_mode = WAIT_TIMER_MODE | WAIT_BUTTON_MODE;
    waitEventSub(-1);

    if (windowchip_sprite_no >= 0)
        sprite_info[windowchip_sprite_no].visible = true;

    leaveSystemCall();
}
int PonscripterLabel::enterTextDisplayMode(bool text_flag)
{
    if (line_enter_status <= 1 && saveon_flag && internal_saveon_flag &&
    text_flag && current_read_language == 1) {
        saveSaveFile(-1);
        internal_saveon_flag = false;
    }

    did_leavetext = false;
    if (!(display_mode & TEXT_DISPLAY_MODE)) {
        if (event_mode & EFFECT_EVENT_MODE) {
            if (doEffect(window_effect, false) == RET_CONTINUE) {
                display_mode = TEXT_DISPLAY_MODE;
                text_on_flag = true;
                return RET_CONTINUE | RET_NOREAD;
            }
            return RET_WAIT | RET_REREAD;
        }
        else {
            dirty_rect.clear();
            dirty_rect.add(sentence_font_info.pos);
            refreshSurface(effect_dst_surface, NULL, refresh_shadow_text_mode);

            return setEffect(window_effect, false, true);
        }
    }

    return RET_NOMATCH;
}
int PonscripterLabel::setEffect(Effect& effect, bool generate_effect_dst, bool update_backup_surface)
{
    if (effect.effect == 0) return RET_CONTINUE;

    if (update_backup_surface)
        refreshSurface(backup_surface, &dirty_rect.bounding_box,
                       REFRESH_NORMAL_MODE);

    int effect_no = effect.effect;
    if (effect_cut_flag && skip_flag) effect_no = 1;

    SDL_BlitSurface(accumulation_surface, NULL, effect_src_surface, NULL);

    if (generate_effect_dst) {
        int refresh_mode = refreshMode();
        if (update_backup_surface && refresh_mode == REFRESH_NORMAL_MODE) {
            SDL_BlitSurface(backup_surface, &dirty_rect.bounding_box,
                            effect_dst_surface, &dirty_rect.bounding_box);
        }
        else {
            if (effect_no == 1)
                refreshSurface(effect_dst_surface, &dirty_rect.bounding_box,
                               refresh_mode);
            else
                refreshSurface(effect_dst_surface, NULL, refresh_mode);
        }
    }

    /* Load mask image */
    if (effect_no == 15 || effect_no == 18) {
        if (!effect.anim.image_surface) {
            parseTaggedString(&effect.anim, true);
            setupAnimationInfo(&effect.anim);
        }
    }
    if (effect_no == 11 || effect_no == 12 || effect_no == 13 ||
            effect_no == 14 || effect_no == 16 || effect_no == 17)
        dirty_rect.fill( screen_width, screen_height );

    effect_counter = 0;
    effect_start_time_old = SDL_GetTicks();
    event_mode = EFFECT_EVENT_MODE;
    advancePhase();

    return RET_WAIT | RET_REREAD;
}
void ONScripterLabel::leaveSystemCall( bool restore_flag )
{
    bool tmp = txtbtn_show;
    txtbtn_show = false;

    current_font = &sentence_font;
    key_pressed_flag = false;
    current_button_state.reset();

    if ( restore_flag ){

        current_page = cached_page;
        text_info.deepcopy(shelter_text_info);
        shelter_text_info.reset();
        root_button_link.next = shelter_button_link;
        root_select_link.next = shelter_select_link;
        exbtn_d_button_link = exbtn_d_shelter_button_link;
#if 0 //broken atm
        //use windoweffect on a return from windowerase systemcall
        if (system_menu_mode == SYSTEM_WINDOWERASE) {
            display_mode = shelter_display_mode;
            refreshSurface( effect_dst_surface, NULL, refreshMode() );
            system_menu_mode = SYSTEM_NULL;
            if (!setEffect(&window_effect, false, true)) {
                while(doEffect(&window_effect, false));
            }
        }
#endif
        erasetextbtnCommand();
        event_mode = shelter_event_mode;
        draw_cursor_flag = shelter_draw_cursor_flag;
        if ( event_mode & WAIT_BUTTON_MODE ){
            SDL_WarpMouse( shelter_mouse_state.x, shelter_mouse_state.y );
        }
    }
    display_mode = shelter_display_mode;
    dirty_rect.fill( screen_width, screen_height );
    flush( refreshMode() );

    //printf("leaveSystemCall %d %d\n",event_mode, clickstr_state);

    refreshMouseOverButton();
    txtbtn_show = tmp;

    system_menu_mode = SYSTEM_NULL;
}
Exemplo n.º 6
0
void ONScripter::enterTextDisplayMode(bool text_flag)
{
    if (line_enter_status <= 1 && saveon_flag && internal_saveon_flag && text_flag){
        saveSaveFile( -1 );
        internal_saveon_flag = false;
    }
    
    if (!(display_mode & DISPLAY_MODE_TEXT)){
        refreshSurface( effect_dst_surface, NULL, refresh_shadow_text_mode );
        dirty_rect.clear();
        dirty_rect.add( sentence_font_info.pos );

        if (setEffect(&window_effect, false, true)) return;
        while(doEffect(&window_effect, false));

        display_mode = DISPLAY_MODE_TEXT;
        text_on_flag = true;
    }
}
bool ONScripter::executeSystemLoad()
{
    current_font = &menu_font;

    text_info.fill( 0, 0, 0, 0 );
        
    menu_font.num_xy[0] = (strlen(save_item_name)+1)/2+2+13;
    menu_font.num_xy[1] = num_save_file+2;
    menu_font.top_xy[0] = (screen_width * screen_ratio2 / screen_ratio1 - menu_font.num_xy[0] * menu_font.pitch_xy[0]) / 2;
    menu_font.top_xy[1] = (screen_height * screen_ratio2 / screen_ratio1  - menu_font.num_xy[1] * menu_font.pitch_xy[1]) / 2;
    menu_font.setXY( (menu_font.num_xy[0] - strlen( load_menu_name ) / 2) / 2, 0 );
    uchar3 color = {0xff, 0xff, 0xff};
    drawString( load_menu_name, color, &menu_font, true, accumulation_surface, NULL, &text_info );
    menu_font.newLine();
    menu_font.newLine();
        
    flush( refreshMode() );
        
    bool nofile_flag;
    char *buffer = new char[ strlen( save_item_name ) + 31 + 1 ];

    SaveFileInfo save_file_info;
    for ( unsigned int i=1 ; i<=num_save_file ; i++ ){
        searchSaveFile( save_file_info, i );
        menu_font.setXY( (menu_font.num_xy[0] - (strlen( save_item_name ) / 2 + 15) ) / 2 );

        if ( save_file_info.valid ){
            sprintf( buffer, MESSAGE_SAVE_EXIST,
                     save_item_name,
                     save_file_info.sjis_no,
                     save_file_info.sjis_month,
                     save_file_info.sjis_day,
                     save_file_info.sjis_hour,
                     save_file_info.sjis_minute );
            nofile_flag = false;
        }
        else{
            sprintf( buffer, MESSAGE_SAVE_EMPTY,
                     save_item_name,
                     save_file_info.sjis_no );
            nofile_flag = true;
        }
        ButtonLink *button = getSelectableSentence( buffer, &menu_font, false, nofile_flag );
        root_button_link.insert( button );
        button->no = i;
        flush( refreshMode() );
    }
    delete[] buffer;

    refreshMouseOverButton();

    event_mode = WAIT_BUTTON_MODE;
    int file_no = 0;
    while(1){
        waitEventSub(-1);

        if ( current_button_state.button > 0 ){
            file_no = current_button_state.button;
            searchSaveFile( save_file_info, file_no );
            if ( !save_file_info.valid ) continue;
        }

        if (current_button_state.button != 0) break;
    }

    if ( current_button_state.button > 0 ){
        deleteButtonLink();

        if (executeSystemYesNo( SYSTEM_LOAD, file_no )){
            current_font = &sentence_font;
            system_menu_mode = NULL; // for fadeout in mp3stopCommand()
            if ( loadSaveFile( file_no ) )
                return false;

            leaveSystemCall( false );
            refreshSurface(backup_surface, NULL, REFRESH_NORMAL_MODE);
            saveon_flag = true;
            internal_saveon_flag = true;
            text_on_flag = false;
            indent_offset = 0;
            line_enter_status = 0;
            page_enter_status = 0;
            string_buffer_offset = 0;
            break_flag = false;

            flushEvent();

            if (loadgosub_label)
                gosubReal( loadgosub_label, script_h.getCurrent() );

            return true;
        }

        return false;
    }

    deleteButtonLink();
    leaveSystemCall();
    
    return false;
}
bool ONScripter::setEffect( EffectLink *effect, bool generate_effect_dst, bool update_backup_surface )
{
    if ( effect->effect == 0 ) return true;

    if (update_backup_surface)
        refreshSurface(backup_surface, &dirty_rect.bounding_box, REFRESH_NORMAL_MODE);
    
    int effect_no = effect->effect;
    if (effect_cut_flag && (skip_mode & SKIP_NORMAL || ctrl_pressed_status)) 
        effect_no = 1;

    SDL_BlitSurface( accumulation_surface, NULL, effect_src_surface, NULL );
        
    if (generate_effect_dst){
        int refresh_mode = refreshMode();
        if (update_backup_surface && refresh_mode == REFRESH_NORMAL_MODE){
            SDL_BlitSurface( backup_surface, &dirty_rect.bounding_box, effect_dst_surface, &dirty_rect.bounding_box );
        }
        else{
            if (effect_no == 1)
                refreshSurface( effect_dst_surface, &dirty_rect.bounding_box, refresh_mode );
            else
                refreshSurface( effect_dst_surface, NULL, refresh_mode );
        }
    }
    
    /* Load mask image */
    if ( effect_no == 15 || effect_no == 18 ){
        if ( !effect->anim.image_surface ){
            parseTaggedString( &effect->anim );
            setupAnimationInfo( &effect->anim );
        }
    }
    if ( effect_no == 11 || effect_no == 12 || effect_no == 13 || effect_no == 14 ||
         effect_no == 16 || effect_no == 17 )
        dirty_rect.fill( screen_width, screen_height );

    if (effect_no == 99){ // dll-based
        if (effect->anim.image_name != NULL){
            printf("dll effect: Got dll '%s'\n", effect->anim.image_name);
            if (!strncmp(effect->anim.image_name, "breakup.dll", 11))
                initBreakup(effect->anim.image_name);
            dirty_rect.fill( screen_width, screen_height );
        }
    }

    effect_counter = 0;

    effect_duration = effect->duration;
    if (skip_mode & SKIP_NORMAL || ctrl_pressed_status){
        // shorten the duration of effects while skipping
        if ( effect_cut_flag ) effect_duration = 0;
        else if (effect_duration > 100){
            effect_duration = effect_duration / 10;
        } else if (effect_duration > 10){
            effect_duration = 10;
        } else {
            effect_duration = 1;
        }
    }
    
    return false;
}
bool ONScripterLabel::setEffect( EffectLink *effect, bool generate_effect_dst, bool update_backup_surface )
{
    if ( effect->effect == 0 ) return true;

    if (update_backup_surface)
        refreshSurface(backup_surface, &dirty_rect.bounding_box, REFRESH_NORMAL_MODE);
    
    int effect_no = effect->effect;

    SDL_BlitSurface( accumulation_surface, NULL, effect_src_surface, NULL );

    if (generate_effect_dst){
        int refresh_mode = refreshMode();
        if (update_backup_surface && refresh_mode == REFRESH_NORMAL_MODE){
            SDL_BlitSurface( backup_surface, &dirty_rect.bounding_box, effect_dst_surface, &dirty_rect.bounding_box );
        }
        else{
            if (effect_no == 1)
                refreshSurface( effect_dst_surface, &dirty_rect.bounding_box, refresh_mode );
            else
                refreshSurface( effect_dst_surface, NULL, refresh_mode );
        }
    }
    
    effect_counter = 0;
    effect_start_time_old = SDL_GetTicks();
    effect_duration = effect->duration;
    if (ctrl_pressed_status || skip_mode & SKIP_NORMAL) {
        // shorten the duration of effects while skipping
        if ( effect_cut_flag ) {
            effect_duration = 0;
            return false; //don't parse effects if effectcut skip
        } else if (effect_duration > 100) {
            effect_duration = effect_duration / 10;
        } else if (effect_duration > 10) {
            effect_duration = 10;
        } else {
            effect_duration = 1;
        }
    } else if (effectspeed == EFFECTSPEED_INSTANT) {
        effect_duration = 0;
        return false; //don't parse effects if instant speed
    } else if (effectspeed == EFFECTSPEED_QUICKER) {
        effect_duration = effect_duration / 2;
        if (effect_duration <= 0)
            effect_duration = 1;
    }

    /* Load mask image */
    if ( effect_no == 15 || effect_no == 18 ){
        if ( !effect->anim.image_surface ){
            parseTaggedString( &effect->anim, true );
#ifdef RCA_SCALE
            setupAnimationInfo( &effect->anim, NULL, scr_stretch_x, scr_stretch_y );
#else
            setupAnimationInfo( &effect->anim );
#endif
        }
    }
    if ( effect_no == 11 || effect_no == 12 || effect_no == 13 || effect_no == 14 ||
         effect_no == 16 || effect_no == 17 )
        dirty_rect.fill( screen_width, screen_height );

    dll = params = NULL;
    if (effect_no == 99) { // dll-based
        dll = effect->anim.image_name;
        if (dll != NULL) { //just in case no dll is given
            if (debug_level > 0)
                printf("dll effect: Got dll/params '%s'\n", dll);

            params = dll;
            while (*params != 0 && *params != '/') params++;
            if (*params == '/') params++;

            if (!strncmp(dll, "whirl.dll", 9)) {
                buildSinTable();
                buildCosTable();
                buildWhirlTable();
                dirty_rect.fill( screen_width, screen_height );
            }
            else if (!strncmp(dll, "trvswave.dll", 12)) {
                buildSinTable();
                dirty_rect.fill( screen_width, screen_height );
            }
            else if (!strncmp(dll, "breakup.dll", 11)) {
                initBreakup(params);
                dirty_rect.fill( screen_width, screen_height );
            }
            else {
                dirty_rect.fill( screen_width, screen_height );
            }
        }
    }

    return false;
}
Exemplo n.º 10
0
void Texto::setText(char *str){
	texto = str;
	refreshSurface();
}