void ONScripter::proceedAnimation() { for (int i=0 ; i<3 ; i++) if (tachi_info[i].proceedAnimation()) flushDirect(tachi_info[i].pos, refreshMode() | (draw_cursor_flag?REFRESH_CURSOR_MODE:0)); for (int i=MAX_SPRITE_NUM-1 ; i>=0 ; i--) if (sprite_info[i].proceedAnimation()) flushDirect(sprite_info[i].pos, refreshMode() | (draw_cursor_flag?REFRESH_CURSOR_MODE:0)); #ifdef USE_LUA if (lua_handler.is_animatable && !script_h.isExternalScript()){ if (lua_handler.remaining_time == 0){ lua_handler.remaining_time = lua_handler.duration_time; int tmp_event_mode = event_mode; int tmp_remaining_time = remaining_time; int tmp_string_buffer_offset = string_buffer_offset; char *current = script_h.getCurrent(); if (lua_handler.isCallbackEnabled(LUAHandler::LUA_ANIMATION)) if (lua_handler.callFunction(true, "animation")) errorAndExit( lua_handler.error_str ); script_h.setCurrent(current); readToken(); string_buffer_offset = tmp_string_buffer_offset; remaining_time = tmp_remaining_time; event_mode = tmp_event_mode; } } #endif if (!textgosub_label && (clickstr_state == CLICK_WAIT || clickstr_state == CLICK_NEWPAGE)){ AnimationInfo *anim; if (clickstr_state == CLICK_WAIT) anim = &cursor_info[0]; else if (clickstr_state == CLICK_NEWPAGE) anim = &cursor_info[1]; if (anim->proceedAnimation()){ SDL_Rect dst_rect = anim->pos; if (!anim->abs_flag){ dst_rect.x += sentence_font.x() * screen_ratio1 / screen_ratio2; dst_rect.y += sentence_font.y() * screen_ratio1 / screen_ratio2; } flushDirect( dst_rect, refreshMode() | (draw_cursor_flag?REFRESH_CURSOR_MODE:0) ); } } }
void ONScripterLabel::stopAnimation( int click ) { int no; if ( !(event_mode & WAIT_TIMER_MODE) ) return; event_mode &= ~WAIT_TIMER_MODE; remaining_time = -1; if ( textgosub_label ) return; if ( click == CLICK_WAIT ) no = CURSOR_WAIT_NO; else if ( click == CLICK_NEWPAGE ) no = CURSOR_NEWPAGE_NO; else return; if (cursor_info[no].image_surface == NULL) return; SDL_Rect dst_rect = cursor_info[ no ].pos; if ( !cursor_info[ no ].abs_flag ){ dst_rect.x += sentence_font.x() * screen_ratio1 / screen_ratio2; dst_rect.y += sentence_font.y() * screen_ratio1 / screen_ratio2; } flushDirect( dst_rect, refreshMode() ); }
int ONScripterLabel::estimateNextDuration( AnimationInfo *anim, SDL_Rect &rect, int minimum ) { if ( anim->remaining_time == 0 ){ if ( minimum == -1 || minimum > anim->duration_list[ anim->current_cell ] ) minimum = anim->duration_list[ anim->current_cell ]; if ( anim->proceedAnimation() ) flushDirect( rect, refreshMode() | (draw_cursor_flag?REFRESH_CURSOR_MODE:0) ); } else{ if ( minimum == -1 || minimum > anim->remaining_time ) minimum = anim->remaining_time; } return minimum; }
void ONScripter::stopAnimation( int click ) { int no; if ( textgosub_label ) return; if ( click == CLICK_WAIT ) no = 0; else if ( click == CLICK_NEWPAGE ) no = 1; else return; if (cursor_info[no].image_surface == NULL) return; SDL_Rect dst_rect = cursor_info[ no ].pos; if ( !cursor_info[ no ].abs_flag ){ dst_rect.x += sentence_font.x() * screen_ratio1 / screen_ratio2; dst_rect.y += sentence_font.y() * screen_ratio1 / screen_ratio2; } flushDirect( dst_rect, refreshMode() ); }
void ONScripter::drawChar( char* text, FontInfo *info, bool flush_flag, bool lookback_flag, SDL_Surface *surface, AnimationInfo *cache_info, SDL_Rect *clip ) { //printf("draw %x-%x[%s] %d, %d\n", text[0], text[1], text, info->xy[0], info->xy[1] ); if ( info->ttf_font == NULL ){ if ( info->openFont( font_file, screen_ratio1, screen_ratio2 ) == NULL ){ fprintf( stderr, "can't open font file: %s\n", font_file ); quit(); exit(-1); } } #if defined(PSP) else info->openFont( font_file, screen_ratio1, screen_ratio2 ); #endif if ( info->isEndOfLine() ){ info->newLine(); for (int i=0 ; i<indent_offset ; i++){ if (lookback_flag){ current_page->add(0x81); current_page->add(0x40); } info->advanceCharInHankaku(2); } } old_xy[0] = info->x(); old_xy[1] = info->y(); char text2[2] = {text[0], 0}; if (IS_TWO_BYTE(text[0])) text2[1] = text[1]; for (int i=0 ; i<2 ; i++){ int xy[2]; xy[0] = info->x() * screen_ratio1 / screen_ratio2; xy[1] = info->y() * screen_ratio1 / screen_ratio2; SDL_Color color; SDL_Rect dst_rect; if ( info->is_shadow ){ color.r = color.g = color.b = 0; drawGlyph(surface, info, color, text2, xy, true, cache_info, clip, dst_rect); } color.r = info->color[0]; color.g = info->color[1]; color.b = info->color[2]; drawGlyph( surface, info, color, text2, xy, false, cache_info, clip, dst_rect ); if ( surface == accumulation_surface && !flush_flag && (!clip || AnimationInfo::doClipping( &dst_rect, clip ) == 0) ){ dirty_rect.add( dst_rect ); } else if ( flush_flag ){ info->addShadeArea(dst_rect, shade_distance); flushDirect( dst_rect, REFRESH_NONE_MODE ); } if (IS_TWO_BYTE(text[0])){ info->advanceCharInHankaku(2); break; } info->advanceCharInHankaku(1); text2[0] = text[1]; if (text2[0] == 0) break; } if ( lookback_flag ){ current_page->add( text[0] ); if (text[1]) current_page->add( text[1] ); } }
// Returns character bytes. // This is where we process ligatures for display text! int PonscripterLabel::drawChar(const char* text, Fontinfo* info, bool flush_flag, bool lookback_flag, SDL_Surface* surface, AnimationInfo* cache_info, SDL_Rect* clip) { int bytes; wchar unicode = file_encoding->DecodeWithLigatures(text, *info, bytes); bool code = info->processCode(text); bool hidden_language = (current_read_language != -1 && current_read_language != current_language); if (!code && !hidden_language) { // info->doSize() called in GlyphAdvance wchar next = file_encoding->DecodeWithLigatures(text + bytes, *info); float adv = info->GlyphAdvance(unicode, next); if (isNonspacing(unicode)) info->advanceBy(-adv); if (info->isNoRoomFor(adv)) info->newLine(); float x = info->GetX() * screen_ratio1 / screen_ratio2; if (info->getRTL()) x -= adv; int y = info->GetY() * screen_ratio1 / screen_ratio2; SDL_Color color; SDL_Rect dst_rect; if (info->is_shadow) { color.r = color.g = color.b = 0; drawGlyph(surface, info, color, unicode, x, y, true, cache_info, clip, dst_rect); } color.r = info->color.r; color.g = info->color.g; color.b = info->color.b; drawGlyph(surface, info, color, unicode, x, y, false, cache_info, clip, dst_rect); info->addShadeArea(dst_rect, shade_distance); if (surface == accumulation_surface && !flush_flag && (!clip || AnimationInfo::doClipping(&dst_rect, clip) == 0)) { dirty_rect.add(dst_rect); } else if (flush_flag) { if (surface == accumulation_surface) flush(refreshMode()); // hack to fix skip refresh bug flushDirect(dst_rect, REFRESH_NONE_MODE); } /* ---------------------------------------- */ /* Update text buffer */ info->advanceBy(adv); } // textbufferchange int j; for (j = 0; j < 2; j++) { if (current_read_language == j || current_read_language == -1) { if (lookback_flag) { current_text_buffer[j]->addBytes(text, bytes); if (text[0] == '~') current_text_buffer[j]->addBytes(text, bytes); } } } TextBuffer_dumpstate(1); return bytes; }