void ONScripter::executeSystemMenu() { current_font = &menu_font; if ( menuselectvoice_file_name[MENUSELECTVOICE_OPEN] ) playSound(menuselectvoice_file_name[MENUSELECTVOICE_OPEN], SOUND_CHUNK, false, MIX_WAVE_CHANNEL); text_info.fill( 0, 0, 0, 0 ); flush( refreshMode() ); menu_font.num_xy[0] = rmenu_link_width; menu_font.num_xy[1] = rmenu_link_num; 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] - rmenu_link_width) / 2, (menu_font.num_xy[1] - rmenu_link_num) / 2 ); RMenuLink *link = root_rmenu_link.next; int counter = 1; while( link ){ ButtonLink *button = getSelectableSentence( link->label, &menu_font, false ); root_button_link.insert( button ); button->no = counter++; link = link->next; flush( refreshMode() ); } flushEvent(); refreshMouseOverButton(); event_mode = WAIT_BUTTON_MODE; do waitEventSub(-1); while (current_button_state.button == 0); deleteButtonLink(); if ( current_button_state.button == -1 ){ if ( menuselectvoice_file_name[MENUSELECTVOICE_CANCEL] ) playSound(menuselectvoice_file_name[MENUSELECTVOICE_CANCEL], SOUND_CHUNK, false, MIX_WAVE_CHANNEL); leaveSystemCall(); return; } if ( menuselectvoice_file_name[MENUSELECTVOICE_CLICK] ) playSound(menuselectvoice_file_name[MENUSELECTVOICE_CLICK], SOUND_CHUNK, false, MIX_WAVE_CHANNEL); link = root_rmenu_link.next; counter = 1; while ( link ){ if ( current_button_state.button == counter++ ){ system_menu_mode = link->system_call_no; break; } link = link->next; } }
int PonscripterLabel::clickWait(bool display_char) { const char* c = script_h.getStrBuf(string_buffer_offset); if ((skip_flag || draw_one_page_flag || ctrl_pressed_status) && !textgosub_label) { clickstr_state = CLICK_NONE; skip_to_wait = 0; int bytes; if (display_char) bytes = drawChar(c, &sentence_font, false, true, accumulation_surface, &text_info); else { bytes = 1; // @, \, etc...? flush(refreshMode()); } string_buffer_offset += bytes; num_chars_in_sentence = 0; return RET_CONTINUE | RET_NOREAD; } else { if (current_read_language == -1 || current_read_language == current_language) { clickstr_state = CLICK_WAIT; } if (skip_to_wait || (sentence_font.wait_time == 0)) { skip_to_wait = 0; flush(refreshMode()); } key_pressed_flag = false; if (display_char) { drawChar(c, &sentence_font, false, true, accumulation_surface, &text_info); ++num_chars_in_sentence; } if (textgosub_label) { const char* next_text = c + 1; saveoffCommand("saveoff"); textgosub_clickstr_state = (next_text[0] == 0x0a) ? CLICK_WAITEOL : CLICK_WAIT; gosubDoTextgosub(); indent_offset = 0; // Do we want to reset all these? line_enter_status = 0; string_buffer_offset = 0; return RET_CONTINUE; } doClickEnd(); return RET_WAIT | RET_NOREAD; } }
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) ); } } }
int ONScripterLabel::clickNewPage( char *out_text ) { if ( out_text ){ drawDoubleChars( out_text, &sentence_font, true, true, accumulation_surface, &text_info ); num_chars_in_sentence++; } if ( skip_flag || draw_one_page_flag || ctrl_pressed_status ) flush( refreshMode() ); if ( (skip_flag || ctrl_pressed_status) && !textgosub_label ){ event_mode = WAIT_SLEEP_MODE; advancePhase(); num_chars_in_sentence = 0; clickstr_state = CLICK_NEWPAGE; } else{ key_pressed_flag = false; if ( textgosub_label ){ saveoffCommand(); textgosub_clickstr_state = CLICK_NEWPAGE; gosubReal( textgosub_label, script_h.getNext() ); indent_offset = 0; line_enter_status = 0; page_enter_status = 0; string_buffer_offset = 0; return RET_CONTINUE; } clickstr_state = CLICK_NEWPAGE; doClickEnd(); } return RET_WAIT | RET_NOREAD; }
void PonscripterLabel::executeSystemLookback() { current_font = &sentence_font; if (event_mode & WAIT_BUTTON_MODE) { if (current_button_state.button == 0 || (current_text_buffer == start_text_buffer && current_button_state.button == -2)) return; if (current_button_state.button == -1 || (current_button_state.button == -3 && current_text_buffer->next == cached_text_buffer) || current_button_state.button <= -4) { event_mode = IDLE_EVENT_MODE; deleteButtons(); if (lookback_sp[0] >= 0) sprite_info[lookback_sp[0]].visible(false); if (lookback_sp[1] >= 0) sprite_info[lookback_sp[1]].visible(false); leaveSystemCall(); return; } if (current_button_state.button == 1 || current_button_state.button == -2) { current_text_buffer = current_text_buffer->previous; } else current_text_buffer = current_text_buffer->next; } else { current_text_buffer = current_text_buffer->previous; if (current_text_buffer->empty()) { if (lookback_sp[0] >= 0) sprite_info[lookback_sp[0]].visible(false); if (lookback_sp[1] >= 0) sprite_info[lookback_sp[1]].visible(false); leaveSystemCall(); return; } event_mode = WAIT_BUTTON_MODE; system_menu_mode = SYSTEM_LOOKBACK; } setupLookbackButton(); refreshMouseOverButton(); rgb_t color = sentence_font.color; sentence_font.color = lookback_color; restoreTextBuffer(); sentence_font.color = color; dirty_rect.fill(screen_width, screen_height); flush(refreshMode()); }
void PonscripterLabel::leaveSystemCall(bool restore_flag) { current_font = &sentence_font; display_mode = shelter_display_mode; system_menu_mode = SYSTEM_NULL; system_menu_enter_flag = false; yesno_caller = SYSTEM_NULL; key_pressed_flag = false; if (restore_flag) { current_text_buffer = cached_text_buffer; restoreTextBuffer(); buttons.swap(shelter_buttons); shelter_buttons.clear(); select_links.swap(shelter_select_links); shelter_select_links.clear(); event_mode = shelter_event_mode; draw_cursor_flag = shelter_draw_cursor_flag; if (event_mode & WAIT_BUTTON_MODE) { SDL_WarpMouseInWindow(screen, shelter_mouse_state.x, shelter_mouse_state.y); } } dirty_rect.fill(screen_width, screen_height); flush(refreshMode()); //printf("leaveSystemCall %d %d\n",event_mode, clickstr_state); refreshMouseOverButton(); advancePhase(); }
void ONScripter::leaveSystemCall( bool restore_flag ) { current_font = &sentence_font; display_mode = shelter_display_mode; if ( restore_flag ){ current_page = cached_page; restoreTextBuffer(); root_button_link.next = shelter_button_link; root_select_link.next = shelter_select_link; event_mode = shelter_event_mode; draw_cursor_flag = shelter_draw_cursor_flag; if ( event_mode & WAIT_BUTTON_MODE ){ int x = shelter_mouse_state.x * screen_device_width / screen_width; int y = shelter_mouse_state.y * screen_device_width / screen_width; SDL_WarpMouse(x, y); } } dirty_rect.fill( screen_width, screen_height ); flush( refreshMode() ); //printf("leaveSystemCall %d %d\n",event_mode, clickstr_state); refreshMouseOverButton(); system_menu_mode = SYSTEM_NULL; }
bool ONScripter::clickWait( char *out_text ) { flush( REFRESH_NONE_MODE ); skip_mode &= ~SKIP_TO_EOL; if (script_h.checkClickstr(script_h.getStringBuffer() + string_buffer_offset) != 1) string_buffer_offset++; string_buffer_offset++; if ( (skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status) && !textgosub_label ){ clickstr_state = CLICK_NONE; if ( out_text ){ drawChar( out_text, &sentence_font, false, true, accumulation_surface, &text_info ); } else{ // called on '@' flush(refreshMode()); } num_chars_in_sentence = 0; event_mode = IDLE_EVENT_MODE; if ( waitEvent(0) ) return false; } else{ if ( out_text ){ drawChar( out_text, &sentence_font, true, true, accumulation_surface, &text_info ); num_chars_in_sentence++; } while( (!(script_h.getEndStatus() & ScriptHandler::END_1BYTE_CHAR) && script_h.getStringBuffer()[ string_buffer_offset ] == ' ') || script_h.getStringBuffer()[ string_buffer_offset ] == '\t' ) string_buffer_offset ++; if ( textgosub_label ){ saveon_flag = false; textgosub_clickstr_state = CLICK_WAIT; if (script_h.getStringBuffer()[string_buffer_offset] == 0x0) textgosub_clickstr_state |= CLICK_EOL; gosubReal( textgosub_label, script_h.getNext(), true ); event_mode = IDLE_EVENT_MODE; waitEvent(0); return false; } // if this is the end of the line, pretext becomes enabled if (script_h.getStringBuffer()[string_buffer_offset] == 0x0) line_enter_status = 0; clickstr_state = CLICK_WAIT; if (doClickEnd()) return false; clickstr_state = CLICK_NONE; if (pagetag_flag) processEOT(); page_enter_status = 0; } return true; }
void ONScripter::processEOT() { int i, n; if ( skip_mode & SKIP_TO_EOL ){ flush( refreshMode() ); skip_mode &= ~SKIP_TO_EOL; } if (!sentence_font.isLineEmpty() && !new_line_skip_flag){ // if sentence_font.isLineEmpty() is true, newPage() might be already issued if (page_enter_status == 1){ n = sentence_font.num_xy[0] - sentence_font.xy[0]/2; for (i=0 ; i<n ; i++){ current_page->add(0x81); current_page->add(0x40); sentence_font.advanceCharInHankaku(2); } } else{ if (!sentence_font.isEndOfLine()) current_page->add( 0x0a ); } sentence_font.newLine(); } if (!new_line_skip_flag && !pagetag_flag) line_enter_status = 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() ); }
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; }
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; }
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; }
int PonscripterLabel::clickNewPage(bool display_char) { const char* c = script_h.getStrBuf(string_buffer_offset); if (current_read_language != -1 && current_read_language != current_language) { clickstr_state = CLICK_NEWPAGE; } if (display_char) { drawChar(c, &sentence_font, true, true, accumulation_surface, &text_info); ++num_chars_in_sentence; } if (skip_flag || draw_one_page_flag || skip_to_wait || ctrl_pressed_status || (sentence_font.wait_time == 0)) flush(refreshMode()); skip_to_wait = 0; if ((skip_flag || ctrl_pressed_status) && !textgosub_label) { event_mode = WAIT_SLEEP_MODE; advancePhase(); num_chars_in_sentence = 0; } else { key_pressed_flag = false; if (textgosub_label) { saveoffCommand("saveoff"); textgosub_clickstr_state = CLICK_NEWPAGE; gosubReal(textgosub_label, script_h.getNext()); indent_offset = 0; line_enter_status = 0; string_buffer_offset = 0; return RET_CONTINUE; } doClickEnd(); } return RET_WAIT | RET_NOREAD; }
int ONScripterLabel::clickWait( char *out_text ) { if ( (skip_flag || draw_one_page_flag || ctrl_pressed_status) && !textgosub_label ){ clickstr_state = CLICK_NONE; if ( out_text ){ drawDoubleChars( out_text, &sentence_font, false, true, accumulation_surface, &text_info ); if (out_text[1]) string_buffer_offset++; string_buffer_offset++; } else{ // called on '@' flush(refreshMode()); string_buffer_offset++; } num_chars_in_sentence = 0; return RET_CONTINUE | RET_NOREAD; } else{ key_pressed_flag = false; if ( out_text ){ drawDoubleChars( out_text, &sentence_font, true, true, accumulation_surface, &text_info ); num_chars_in_sentence++; } if ( textgosub_label ){ saveoffCommand(); textgosub_clickstr_state = CLICK_WAIT; if (script_h.getNext()[0] == 0x0a) textgosub_clickstr_state |= CLICK_EOL; gosubReal( textgosub_label, script_h.getNext() ); indent_offset = 0; line_enter_status = 0; page_enter_status = 0; string_buffer_offset = 0; return RET_CONTINUE; } clickstr_state = CLICK_WAIT; doClickEnd(); return RET_WAIT | RET_NOREAD; } }
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() ); }
int PonscripterLabel::processText() { if (string_buffer_restore > 0) { string_buffer_offset = string_buffer_restore; string_buffer_restore = -1; } if (debug_level > 1) { fprintf(stderr,"processText: %d:'%s", string_buffer_offset, script_h.getStrBuf(string_buffer_offset)); } if (event_mode & (WAIT_INPUT_MODE | WAIT_SLEEP_MODE)) { draw_cursor_flag = false; if (script_h.readStrBuf(string_buffer_offset) == '!') { string_buffer_offset++; if (script_h.readStrBuf(string_buffer_offset) == 'w' || script_h.readStrBuf(string_buffer_offset) == 'd') { ++string_buffer_offset; while (script_h.isadigit(script_h.readStrBuf(string_buffer_offset))) { ++string_buffer_offset; } while (script_h.isawspace(script_h.readStrBuf(string_buffer_offset))) ++string_buffer_offset; } } else if (clickstr_state == CLICK_WAIT) { string_buffer_offset += file_encoding->NextCharSizeWithLigatures (script_h.getStrBuf(string_buffer_offset), &sentence_font); clickstr_state = CLICK_NONE; } else if (clickstr_state == CLICK_NEWPAGE) { event_mode = IDLE_EVENT_MODE; string_buffer_offset += file_encoding->NextCharSizeWithLigatures (script_h.getStrBuf(string_buffer_offset), &sentence_font); newPage(true); clickstr_state = CLICK_NONE; return RET_CONTINUE | RET_NOREAD; } else string_buffer_offset += file_encoding->NextCharSizeWithLigatures (script_h.getStrBuf(string_buffer_offset), &sentence_font); event_mode = IDLE_EVENT_MODE; } if (script_h.readStrBuf(string_buffer_offset) == 0x0a || script_h.readStrBuf(string_buffer_offset) == 0x00) { indent_offset = 0; // redundant skip_to_wait = 0; return RET_CONTINUE; } new_line_skip_flag = false; char ch = script_h.readStrBuf(string_buffer_offset); // Chronotrig, multilang inline command hack, ignore ! and # commands when current language isn't being read if (current_read_language != -1 && current_read_language != current_language) { int startingChar = string_buffer_offset; if (ch == '!') { string_buffer_offset++; if (script_h.readStrBuf(string_buffer_offset) == 'w' || script_h.readStrBuf(string_buffer_offset) == 'd') { ++string_buffer_offset; while (script_h.isadigit(script_h.readStrBuf(string_buffer_offset))) { ++string_buffer_offset; } while (script_h.isawspace(script_h.readStrBuf(string_buffer_offset))) ++string_buffer_offset; } else if (script_h.readStrBuf(string_buffer_offset) == 's') { string_buffer_offset++; if (script_h.readStrBuf(string_buffer_offset) == 'd') { string_buffer_offset++; } else { while (script_h.isadigit(script_h.readStrBuf(string_buffer_offset))) { ++string_buffer_offset; } while (script_h.isawspace(script_h.readStrBuf(string_buffer_offset))) ++string_buffer_offset; } } if (string_buffer_offset - startingChar > 3) { return RET_CONTINUE; } else { string_buffer_offset = startingChar; } } else if (ch == '#') { char hexchecker; bool isValidHex = true; for (int i = 0; i <= 5; ++i) { hexchecker = script_h.readStrBuf(string_buffer_offset + i + 1); if (!script_h.isaxdigit(hexchecker)) { isValidHex = false; } } if (isValidHex) { string_buffer_offset += 7; return RET_CONTINUE; } } } if (ch == '@') { // wait for click return clickWait(false); } else if (ch == '\\') { // new page return clickNewPage(false); } else if (ch == '_') { // Ignore following forced return clickstr_state = CLICK_IGNORE; ++string_buffer_offset; return RET_CONTINUE | RET_NOREAD; } else if (ch == '!') { ++string_buffer_offset; if (script_h.readStrBuf(string_buffer_offset) == 's') { ++string_buffer_offset; bool in_skip = (skip_flag || ctrl_pressed_status); int prev_t = sentence_font.wait_time; if (script_h.readStrBuf(string_buffer_offset) == 'd') { sentence_font.wait_time = -1; ++string_buffer_offset; } else { int t = 0; while (script_h.isadigit(script_h.readStrBuf(string_buffer_offset))) { t = t * 10 + script_h.readStrBuf(string_buffer_offset) -'0'; ++string_buffer_offset; } sentence_font.wait_time = t; while (script_h.isawspace(script_h.readStrBuf(string_buffer_offset))) ++string_buffer_offset; } if (!in_skip && (prev_t == 0) && (sentence_font.wait_time != 0)) flush(refreshMode()); } else if (script_h.readStrBuf(string_buffer_offset) == 'w' || script_h.readStrBuf(string_buffer_offset) == 'd') { bool flag = false; bool in_skip = (skip_flag || draw_one_page_flag || ctrl_pressed_status); if (script_h.readStrBuf(string_buffer_offset) == 'd') flag = true; ++string_buffer_offset; int tmp_string_buffer_offset = string_buffer_offset; int t = 0; while (script_h.isadigit(script_h.readStrBuf(string_buffer_offset))) { t = t * 10 + script_h.readStrBuf(string_buffer_offset) - '0'; ++string_buffer_offset; } while (script_h.isawspace(script_h.readStrBuf(string_buffer_offset))) string_buffer_offset++; flush(refreshMode()); if (flag && in_skip) { skip_to_wait = 0; return RET_CONTINUE | RET_NOREAD; } else { if (!flag && in_skip) { //Mion: instead of skipping entirely, let's do a shortened wait (safer) if (t > 100) { t = t / 10; } else if (t > 10) { t = 10; } } skip_to_wait = 0; event_mode = WAIT_SLEEP_MODE; if (flag) event_mode |= WAIT_INPUT_MODE; key_pressed_flag = false; startTimer(t); string_buffer_offset = tmp_string_buffer_offset - 2; return RET_WAIT | RET_NOREAD; } } else { --string_buffer_offset; goto notacommand; } return RET_CONTINUE | RET_NOREAD; } else if (ch == '#') { char hexchecker; for (int i = 0; i <= 5; ++i) { hexchecker = script_h.readStrBuf(string_buffer_offset + i + 1); if (!script_h.isaxdigit(hexchecker)) goto notacommand; } sentence_font.color = readColour(script_h.getStrBuf(string_buffer_offset)); string_buffer_offset += 7; return RET_CONTINUE | RET_NOREAD; } else if (ch == '/') { if (script_h.readStrBuf(string_buffer_offset + 1) != 0x0a) goto notacommand; else { // skip new line new_line_skip_flag = true; string_buffer_offset++; return RET_CONTINUE; // skip the following eol } } else { notacommand: if (clickstr_state == CLICK_IGNORE) { clickstr_state = CLICK_NONE; } else { const char* c = script_h.getStrBuf(string_buffer_offset); if (script_h.checkClickstr(c)) { if (sentence_font.isNoRoomForLines(clickstr_line)) return clickNewPage(true); else return clickWait(true); } } bool flush_flag = !(skip_flag || draw_one_page_flag || skip_to_wait || ctrl_pressed_status || (sentence_font.wait_time == 0) || (current_read_language != -1 && current_read_language != current_language)); drawChar(script_h.getStrBuf(string_buffer_offset), &sentence_font, flush_flag, true, accumulation_surface, &text_info); ++num_chars_in_sentence; if (flush_flag) { event_mode = WAIT_SLEEP_MODE; int wait_time = 0; if ( sentence_font.wait_time == -1 ) wait_time = default_text_speed[text_speed_no]; else wait_time = sentence_font.wait_time; advancePhase(wait_time * 100 / global_speed_modifier); return RET_WAIT | RET_NOREAD; } event_mode = IDLE_EVENT_MODE; //Mion: hack using RET_CONTINUE | RET_WAIT for unflushed text return RET_CONTINUE | RET_WAIT | RET_NOREAD; } return RET_NOMATCH; }
// 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; }
void ONScripter::executeSystemLookback() { int i; uchar3 color; current_font = &sentence_font; current_page = current_page->previous; if ( current_page->text_count == 0 ){ if ( lookback_sp[0] >= 0 ) sprite_info[ lookback_sp[0] ].visible = false; if ( lookback_sp[1] >= 0 ) sprite_info[ lookback_sp[1] ].visible = false; leaveSystemCall(); return; } while(1){ setupLookbackButton(); refreshMouseOverButton(); dirty_rect.fill( screen_width, screen_height ); flush( refreshMode() & ~REFRESH_TEXT_MODE); for ( i=0 ; i<3 ; i++ ){ color[i] = sentence_font.color[i]; sentence_font.color[i] = lookback_color[i]; } restoreTextBuffer(accumulation_surface); for ( i=0 ; i<3 ; i++ ) sentence_font.color[i] = color[i]; flush( REFRESH_NONE_MODE ); event_mode = WAIT_BUTTON_MODE; waitEventSub(-1); if ( current_button_state.button == 0 || ( current_page == start_page && current_button_state.button == -2 ) ){ continue; } if ( current_button_state.button == -1 || ( current_button_state.button == -3 && current_page->next == cached_page ) || current_button_state.button <= -4 ) { event_mode = IDLE_EVENT_MODE; deleteButtonLink(); if ( lookback_sp[0] >= 0 ) sprite_info[ lookback_sp[0] ].visible = false; if ( lookback_sp[1] >= 0 ) sprite_info[ lookback_sp[1] ].visible = false; leaveSystemCall(); return; } if ( current_button_state.button == 1 || current_button_state.button == -2 ){ current_page = current_page->previous; } else current_page = current_page->next; } }
bool ONScripter::executeSystemYesNo( int caller, int file_no ) { current_font = &menu_font; text_info.fill( 0, 0, 0, 0 ); dirty_rect.fill( screen_width, screen_height ); char name[64] = {'\0'}; if ( caller == SYSTEM_SAVE ){ SaveFileInfo save_file_info; searchSaveFile( save_file_info, file_no ); sprintf( name, MESSAGE_SAVE_CONFIRM, save_item_name, save_file_info.sjis_no ); } else if ( caller == SYSTEM_LOAD ){ SaveFileInfo save_file_info; searchSaveFile( save_file_info, file_no ); sprintf( name, MESSAGE_LOAD_CONFIRM, save_item_name, save_file_info.sjis_no ); } else if ( caller == SYSTEM_RESET ) strcpy( name, MESSAGE_RESET_CONFIRM ); else if ( caller == SYSTEM_END ) strcpy( name, MESSAGE_END_CONFIRM ); menu_font.num_xy[0] = strlen(name)/2; menu_font.num_xy[1] = 3; 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(0, 0); uchar3 color = {0xff, 0xff, 0xff}; drawString( name, color, &menu_font, true, accumulation_surface, NULL, &text_info ); flush( refreshMode() ); int offset1 = strlen(name)/5; int offset2 = strlen(name)/2 - offset1; strcpy( name, MESSAGE_YES ); menu_font.setXY(offset1-2, 2); ButtonLink *button = getSelectableSentence( name, &menu_font, false ); root_button_link.insert( button ); button->no = 1; strcpy( name, MESSAGE_NO ); menu_font.setXY(offset2, 2); button = getSelectableSentence( name, &menu_font, false ); root_button_link.insert( button ); button->no = 2; flush( refreshMode() ); refreshMouseOverButton(); event_mode = WAIT_BUTTON_MODE; do waitEventSub(-1); while (current_button_state.button == 0); deleteButtonLink(); if ( current_button_state.button == 1 ){ // yes is selected if ( menuselectvoice_file_name[MENUSELECTVOICE_YES] ) playSound(menuselectvoice_file_name[MENUSELECTVOICE_YES], SOUND_CHUNK, false, MIX_WAVE_CHANNEL); return true; } else{ if ( menuselectvoice_file_name[MENUSELECTVOICE_NO] ) playSound(menuselectvoice_file_name[MENUSELECTVOICE_NO], SOUND_CHUNK, false, MIX_WAVE_CHANNEL); return false; } }
void ONScripterLabel::executeSystemSave() { 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] = (ContractPos(screen_width) - menu_font.num_xy[0] * menu_font.pitch_xy[0]) / 2; menu_font.top_xy[1] = (ContractPos(screen_height) - menu_font.num_xy[1] * menu_font.pitch_xy[1]) / 2; menu_font.setXY((menu_font.num_xy[0] - (strlen( save_menu_name )+1) / 2 ) / 2, 0); //Mion: fixed the menu title bug noted in the past by Seung Park: // the menu title must be drawn close to last during refresh, // not in the textwindow, since there could be sprites above the // window if windowback is used. if (system_menu_title){ dirty_rect.add( system_menu_title->pos ); delete system_menu_title; system_menu_title = NULL; } system_menu_title = getSentence( save_menu_name, &menu_font, 1, false ); menu_font.newLine(); flush( refreshMode() ); bool nofile_flag; int slen = strlen(save_item_name); char *buffer = new char[ slen + (slen % 2) + 30 + 3 ]; for ( unsigned int i=1 ; i<=num_save_file ; i++ ){ SaveFileInfo save_file_info; searchSaveFile( save_file_info, i ); menu_font.setXY( (menu_font.num_xy[0] - ((strlen( save_item_name )+1) / 2 + 15) ) / 2 ); if ( save_file_info.valid ){ sprintf( buffer, getMessageString(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, getMessageString(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; do waitEventSub(-1); while (current_button_state.button == 0); deleteButtonLink(); if (system_menu_title){ dirty_rect.add( system_menu_title->pos ); delete system_menu_title; system_menu_title = NULL; } if ( current_button_state.button > 0 ){ int file_no = current_button_state.button; if (executeSystemYesNo( SYSTEM_SAVE, file_no )){ saveSaveFile( file_no ); leaveSystemCall(); } return; } leaveSystemCall(); }
void PonscripterLabel::createSaveLoadMenu(bool is_save) { SaveFileInfo save_file_info; text_info.fill(0, 0, 0, 0); // Set up formatting details for saved games. const float sw = float (screen_width * screen_ratio2) / float (screen_ratio1); const int spacing = 16; pstring buffer, saveless_line; float linew, lw, ew, line_offs_x, item_x; float *label_inds = NULL, *save_inds = NULL; int num_label_ind = 0, num_save_ind = 0; { float max_lw = 0, max_ew = 0; for (unsigned int i = 1; i <= num_save_file; i++) { searchSaveFile(save_file_info, i); lw = processMessage(buffer, locale.message_save_label, save_file_info, &label_inds, &num_label_ind); if (max_lw < lw) max_lw = lw; if (save_file_info.valid) { ew = processMessage(buffer, locale.message_save_exist, save_file_info, &save_inds, &num_save_ind); if (max_ew < ew) max_ew = ew; } } pstring tm = file_encoding->TextMarker(); if (save_inds == NULL) { saveless_line = tm; for (int j=0; j<24; j++) saveless_line += locale.message_empty; max_ew = current_font->StringAdvance(saveless_line); } else { // Avoid possible ugliness of ligatures pstring long_empty; for (int j=0; j<6; j++) long_empty += locale.message_empty; saveless_line = tm; while (current_font->StringAdvance(saveless_line) < max_ew) saveless_line += long_empty; if (max_ew < current_font->StringAdvance(saveless_line)) max_ew = current_font->StringAdvance(saveless_line); } item_x = max_lw + spacing; linew = ceil(item_x + max_ew + spacing); line_offs_x = (sw - linew) / 2; } // Set up the menu. current_font->area_x = int(linew); current_font->area_y = current_font->line_top(num_save_file + 2); current_font->top_x = int(line_offs_x); current_font->top_y = (screen_height * screen_ratio2 / screen_ratio1 - current_font->area_y) / 2; pstring& menu_name = is_save ? save_menu_name : load_menu_name; current_font->SetXY((linew - current_font->StringAdvance(menu_name)) / 2, 0); buttons[0] = getSelectableSentence(menu_name, current_font, false); current_font->newLine(); flush(refreshMode()); bool disable = false; for (unsigned int i = 1; i <= num_save_file; i++) { searchSaveFile(save_file_info, i); lw = processMessage(buffer, locale.message_save_label, save_file_info, &label_inds, &num_label_ind, false); current_font->SetXY(0); pstring tmp = ""; if (script_h.is_ponscripter) tmp.format("~x%d~", int(item_x)); else { int num_sp = ceil((spacing + 0.0) / current_font->StringAdvance(locale.message_space)); for (int j=0; j<num_sp; j++) tmp += locale.message_space; } buffer += tmp; if (save_file_info.valid) { processMessage(tmp, locale.message_save_exist, save_file_info, &save_inds, &num_save_ind, false); disable = false; } else { tmp = saveless_line; disable = !is_save; } buffer += tmp; buttons[i] = getSelectableSentence(buffer, current_font, false, disable); flush(refreshMode()); } if (label_inds) delete[] label_inds; if (save_inds) delete[] save_inds; event_mode = WAIT_BUTTON_MODE; refreshMouseOverButton(); }
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::executeSystemYesNo( int caller, int file_no ) { current_font = &menu_font; text_info.fill( 0, 0, 0, 0 ); dirty_rect.fill( screen_width, screen_height ); char name[64] = {'\0'}; if ( caller == SYSTEM_SAVE ){ SaveFileInfo save_file_info; searchSaveFile( save_file_info, file_no ); sprintf( name, getMessageString(MESSAGE_SAVE_CONFIRM), save_item_name, save_file_info.sjis_no ); } else if ( caller == SYSTEM_LOAD ){ SaveFileInfo save_file_info; searchSaveFile( save_file_info, file_no ); sprintf( name, getMessageString(MESSAGE_LOAD_CONFIRM), save_item_name, save_file_info.sjis_no ); } else if ( caller == SYSTEM_RESET ) strcpy( name, getMessageString(MESSAGE_RESET_CONFIRM) ); else if ( caller == SYSTEM_END ) strcpy( name, getMessageString(MESSAGE_END_CONFIRM) ); menu_font.num_xy[0] = strlen(name)/2; menu_font.num_xy[1] = 3; menu_font.top_xy[0] = (ContractPos(screen_width) - menu_font.num_xy[0] * menu_font.pitch_xy[0]) / 2; menu_font.top_xy[1] = (ContractPos(screen_height) - menu_font.num_xy[1] * menu_font.pitch_xy[1]) / 2; menu_font.setXY(0, 0); //Mion: fixed the menu title bug noted in the past by Seung Park: // the menu title must be drawn close to last during refresh, // not in the textwindow, since there could be sprites above the // window if windowback is used. if (system_menu_title){ dirty_rect.add( system_menu_title->pos ); delete system_menu_title; system_menu_title = NULL; } system_menu_title = getSentence( name, &menu_font, 1, false ); flush( refreshMode() ); int offset1 = strlen(name)/5; int offset2 = strlen(name)/2 - offset1; strcpy( name, getMessageString(MESSAGE_YES) ); menu_font.setXY(offset1-2, 2); ButtonLink *button = getSelectableSentence( name, &menu_font, false ); root_button_link.insert( button ); button->no = 1; strcpy( name, getMessageString(MESSAGE_NO) ); menu_font.setXY(offset2, 2); button = getSelectableSentence( name, &menu_font, false ); root_button_link.insert( button ); button->no = 2; flush( refreshMode() ); refreshMouseOverButton(); event_mode = WAIT_BUTTON_MODE; do waitEventSub(-1); while (current_button_state.button == 0); deleteButtonLink(); if (system_menu_title){ dirty_rect.add( system_menu_title->pos ); delete system_menu_title; system_menu_title = NULL; } if ( current_button_state.button == 1 ){ // yes is selected if ( menuselectvoice_file_name[MENUSELECTVOICE_YES] ) playSound(menuselectvoice_file_name[MENUSELECTVOICE_YES], SOUND_WAVE|SOUND_OGG, false, MIX_WAVE_CHANNEL); return true; } else{ if ( menuselectvoice_file_name[MENUSELECTVOICE_NO] ) playSound(menuselectvoice_file_name[MENUSELECTVOICE_NO], SOUND_WAVE|SOUND_OGG, false, MIX_WAVE_CHANNEL); return false; } }
void PonscripterLabel::executeSystemMenu() { int counter = 1; current_font = &menu_font; if (event_mode & WAIT_BUTTON_MODE) { if (current_button_state.button == 0) return; event_mode = IDLE_EVENT_MODE; deleteButtons(); if (current_button_state.button == -1) { playSound(menuselectvoice_file_name[MENUSELECTVOICE_CANCEL], SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL); leaveSystemCall(); return; } playSound(menuselectvoice_file_name[MENUSELECTVOICE_CLICK], SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL); for (RMenuElt::iterator it = rmenu.begin(); it != rmenu.end(); ++it) { if (current_button_state.button == counter++) { system_menu_mode = it->system_call_no; break; } } advancePhase(); } else { playSound(menuselectvoice_file_name[MENUSELECTVOICE_OPEN], SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL); system_menu_mode = SYSTEM_MENU; yesno_caller = SYSTEM_MENU; text_info.fill(0, 0, 0, 0); flush(refreshMode()); current_font->area_x = screen_width * screen_ratio2 / screen_ratio1; current_font->area_y = current_font->line_top(rmenu.size()); current_font->top_x = 0; current_font->top_y = (screen_height * screen_ratio2 / screen_ratio1 - current_font->area_y) / 2; current_font->SetXY(0, 0); for (RMenuElt::iterator it = rmenu.begin(); it != rmenu.end(); ++it) { const float sw = float (screen_width * screen_ratio2) / float (screen_ratio1); current_font->SetXY((sw - current_font->StringAdvance(it->label)) / 2); buttons[counter++] = getSelectableSentence(it->label, current_font, false); flush(refreshMode()); } flushEvent(); event_mode = WAIT_BUTTON_MODE; refreshMouseOverButton(); } }
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; }
void PonscripterLabel::executeSystemYesNo() { current_font = &menu_font; if (event_mode & WAIT_BUTTON_MODE) { if (current_button_state.button == 0) return; event_mode = IDLE_EVENT_MODE; deleteButtons(); if (current_button_state.button == 1) { // yes is selected playSound(menuselectvoice_file_name[MENUSELECTVOICE_YES], SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL); if (yesno_caller == SYSTEM_SAVE) { saveSaveFile(yesno_selected_file_no); leaveSystemCall(); } else if (yesno_caller == SYSTEM_LOAD) { current_font = &sentence_font; if (loadSaveFile(yesno_selected_file_no)) { system_menu_mode = yesno_caller; advancePhase(); return; } leaveSystemCall(false); saveon_flag = true; internal_saveon_flag = true; text_on_flag = false; indent_offset = 0; line_enter_status = 0; string_buffer_offset = 0; string_buffer_restore = -1; break_flag = false; if (loadgosub_label) gosubReal(loadgosub_label, script_h.getCurrent()); readToken(); } else if (yesno_caller == SYSTEM_RESET) { resetCommand("reset"); readToken(); event_mode = IDLE_EVENT_MODE; leaveSystemCall(false); } else if (yesno_caller == SYSTEM_END) { endCommand("end"); } } else { playSound(menuselectvoice_file_name[MENUSELECTVOICE_NO], SOUND_WAVE | SOUND_OGG, false, MIX_WAVE_CHANNEL); system_menu_mode = yesno_caller & 0xf; if (yesno_caller == SYSTEM_RESET) leaveSystemCall(); advancePhase(); } } else { text_info.fill(0, 0, 0, 0); pstring name; if (yesno_caller == SYSTEM_SAVE) { SaveFileInfo save_file_info; searchSaveFile(save_file_info, yesno_selected_file_no); processMessage(name, locale.message_save_confirm, save_file_info); } else if (yesno_caller == SYSTEM_LOAD) { SaveFileInfo save_file_info; searchSaveFile(save_file_info, yesno_selected_file_no); processMessage(name, locale.message_load_confirm, save_file_info); } else if (yesno_caller == SYSTEM_RESET) name = locale.message_reset_confirm; else if (yesno_caller == SYSTEM_END) name = locale.message_end_confirm; current_font->area_x = int (ceil(current_font->StringAdvance(name))); current_font->area_y = current_font->line_top(4); current_font->top_x = (screen_width * screen_ratio2 / screen_ratio1 - current_font->area_x) / 2; current_font->top_y = (screen_height * screen_ratio2 / screen_ratio1 - current_font->area_y) / 2; current_font->SetXY(0, 0); buttons[0] = getSelectableSentence(name, current_font, false); flush(refreshMode()); float yes_len = current_font->StringAdvance(locale.message_yes), no_len = current_font->StringAdvance(locale.message_no); name = locale.message_yes; current_font->SetXY(float (current_font->area_x) / 4 - yes_len / 2, current_font->line_top(2)); buttons[1] = getSelectableSentence(name, current_font, false); name = locale.message_no; current_font->SetXY(float (current_font->area_x) * 3 / 4 - no_len / 2, current_font->line_top(2)); buttons[2] = getSelectableSentence(name, current_font, false); flush(refreshMode()); event_mode = WAIT_BUTTON_MODE; refreshMouseOverButton(); } }
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::keyPressEvent( SDL_KeyboardEvent *event ) { current_button_state.button = 0; current_button_state.down_flag = false; if ( automode_flag ){ automode_flag = false; return false; } if ( event->type == SDL_KEYUP ){ if ( variable_edit_mode ){ variableEditMode( event ); return false; } if ( edit_flag && event->keysym.sym == SDLK_z ){ variable_edit_mode = EDIT_SELECT_MODE; variable_edit_sign = 1; variable_edit_num = 0; sprintf( wm_edit_string, "%s%s", EDIT_MODE_PREFIX, EDIT_SELECT_STRING ); SDL_WM_SetCaption( wm_edit_string, wm_icon_string ); } } if (event->type == SDL_KEYUP) skip_mode &= ~SKIP_NORMAL; if ( shift_pressed_status && event->keysym.sym == SDLK_q && current_mode == NORMAL_MODE ){ endCommand(); } if ( (trap_mode & TRAP_LEFT_CLICK) && (event->keysym.sym == SDLK_RETURN || event->keysym.sym == SDLK_KP_ENTER || event->keysym.sym == SDLK_SPACE ) ){ if (trapHandler()) return true; } else if ( (trap_mode & TRAP_RIGHT_CLICK) && (event->keysym.sym == SDLK_ESCAPE) ){ if (trapHandler()) return true; } if ( event_mode & WAIT_BUTTON_MODE && (((event->type == SDL_KEYUP || btndown_flag) && ((!getenter_flag && event->keysym.sym == SDLK_RETURN) || (!getenter_flag && event->keysym.sym == SDLK_KP_ENTER))) || ((spclclk_flag || !useescspc_flag) && event->keysym.sym == SDLK_SPACE)) ){ if ( event->keysym.sym == SDLK_RETURN || event->keysym.sym == SDLK_KP_ENTER || (spclclk_flag && event->keysym.sym == SDLK_SPACE) ){ current_button_state.button = current_over_button; if (current_over_button == -1){ if (!bexec_flag) current_button_state.button = 0; sprintf(current_button_state.str, "RETURN"); } else{ sprintf(current_button_state.str, "S%d", current_over_button); if (bexec_flag && current_button_link){ ButtonLink *cbl = current_button_link; if ( current_button_link->exbtn_ctl[2] ){ SDL_Rect check_src_rect = cbl->image_rect; SDL_Rect check_dst_rect = {0, 0, 0, 0}; decodeExbtnControl( cbl->exbtn_ctl[2], &check_src_rect, &check_dst_rect ); } else{ sprite_info[ cbl->sprite_no ].visible = true; sprite_info[ cbl->sprite_no ].setCell(2); dirty_rect.add( cbl->image_rect ); } flush( refreshMode() ); } } if ( event->type == SDL_KEYDOWN ) current_button_state.down_flag = true; } else{ current_button_state.button = -1; if (!bexec_flag) current_button_state.button = 0; sprintf(current_button_state.str, "SPACE"); } playClickVoice(); stopAnimation( clickstr_state ); return true; } if ( event->type == SDL_KEYDOWN ) return false; if ( ( event_mode & (WAIT_INPUT_MODE | WAIT_BUTTON_MODE) ) && ( autoclick_time == 0 || (event_mode & WAIT_BUTTON_MODE)) ){ if ( !useescspc_flag && event->keysym.sym == SDLK_ESCAPE){ current_button_state.button = -1; sprintf(current_button_state.str, "RCLICK"); if (rmode_flag && event_mode & WAIT_TEXT_MODE){ if (root_rmenu_link.next) system_menu_mode = SYSTEM_MENU; else system_menu_mode = SYSTEM_WINDOWERASE; } } else if ( useescspc_flag && event->keysym.sym == SDLK_ESCAPE ){ current_button_state.button = -10; } else if ( !spclclk_flag && useescspc_flag && event->keysym.sym == SDLK_SPACE ){ current_button_state.button = -11; } else if (((!getcursor_flag && event->keysym.sym == SDLK_LEFT) || event->keysym.sym == SDLK_h) && (event_mode & WAIT_TEXT_MODE || (usewheel_flag && !getcursor_flag && event_mode & WAIT_BUTTON_MODE) || system_menu_mode == SYSTEM_LOOKBACK)){ current_button_state.button = -2; if (event_mode & WAIT_TEXT_MODE) system_menu_mode = SYSTEM_LOOKBACK; } else if (((!getcursor_flag && event->keysym.sym == SDLK_RIGHT) || event->keysym.sym == SDLK_l) && ((enable_wheeldown_advance_flag && event_mode & WAIT_TEXT_MODE) || (usewheel_flag && event_mode & WAIT_BUTTON_MODE) || system_menu_mode == SYSTEM_LOOKBACK)){ if (event_mode & WAIT_TEXT_MODE) current_button_state.button = 0; else current_button_state.button = -3; } else if (((!getcursor_flag && event->keysym.sym == SDLK_UP) || event->keysym.sym == SDLK_k || event->keysym.sym == SDLK_p) && event_mode & WAIT_BUTTON_MODE){ shiftCursorOnButton(1); return false; } else if (((!getcursor_flag && event->keysym.sym == SDLK_DOWN) || event->keysym.sym == SDLK_j || event->keysym.sym == SDLK_n) && event_mode & WAIT_BUTTON_MODE){ shiftCursorOnButton(-1); return false; } else if ( getpageup_flag && event->keysym.sym == SDLK_PAGEUP ){ current_button_state.button = -12; sprintf(current_button_state.str, "PAGEUP"); } else if ( getpagedown_flag && event->keysym.sym == SDLK_PAGEDOWN ){ current_button_state.button = -13; sprintf(current_button_state.str, "PAGEDOWN"); } else if ( (getenter_flag && event->keysym.sym == SDLK_RETURN) || (getenter_flag && event->keysym.sym == SDLK_KP_ENTER) ){ current_button_state.button = -19; } else if ( gettab_flag && event->keysym.sym == SDLK_TAB ){ current_button_state.button = -20; } else if ( getcursor_flag && event->keysym.sym == SDLK_UP ){ current_button_state.button = -40; sprintf(current_button_state.str, "UP"); } else if ( getcursor_flag && event->keysym.sym == SDLK_RIGHT ){ current_button_state.button = -41; sprintf(current_button_state.str, "RIGHT"); } else if ( getcursor_flag && event->keysym.sym == SDLK_DOWN ){ current_button_state.button = -42; sprintf(current_button_state.str, "DOWN"); } else if ( getcursor_flag && event->keysym.sym == SDLK_LEFT ){ current_button_state.button = -43; sprintf(current_button_state.str, "LEFT"); } else if ( getinsert_flag && event->keysym.sym == SDLK_INSERT ){ current_button_state.button = -50; } else if ( getzxc_flag && event->keysym.sym == SDLK_z ){ current_button_state.button = -51; } else if ( getzxc_flag && event->keysym.sym == SDLK_x ){ current_button_state.button = -52; } else if ( getzxc_flag && event->keysym.sym == SDLK_c ){ current_button_state.button = -53; } else if ( getfunction_flag && event->keysym.sym >= SDLK_F1 && event->keysym.sym <= SDLK_F12 ){ current_button_state.button = -21-(event->keysym.sym - SDLK_F1); sprintf(current_button_state.str, "F%d", event->keysym.sym - SDLK_F1+1); } else if ( bexec_flag && event->keysym.sym >= SDLK_0 && event->keysym.sym <= SDLK_9 ){ current_button_state.button = -1; // dummy sprintf(current_button_state.str, "%d", event->keysym.sym - SDLK_0); } else if ( bexec_flag && event->keysym.sym >= SDLK_a && event->keysym.sym <= SDLK_z ){ current_button_state.button = -1; // dummy sprintf(current_button_state.str, "%c", 'A' + event->keysym.sym - SDLK_a); } else if ( bexec_flag && (event->keysym.sym == SDLK_RSHIFT || event->keysym.sym == SDLK_LSHIFT) ){ current_button_state.button = -1; // dummy sprintf(current_button_state.str, "SHIFT"); } if ( current_button_state.button != 0 ){ stopAnimation( clickstr_state ); return true; } } if ( event_mode & WAIT_INPUT_MODE && ( autoclick_time == 0 || (event_mode & WAIT_BUTTON_MODE)) ){ if (event->keysym.sym == SDLK_RETURN || event->keysym.sym == SDLK_KP_ENTER || event->keysym.sym == SDLK_SPACE ){ if (!(event_mode & WAIT_TEXT_MODE)) skip_mode |= SKIP_TO_EOL; playClickVoice(); stopAnimation( clickstr_state ); return true; } } if ( event_mode & WAIT_INPUT_MODE ){ if (event->keysym.sym == SDLK_s && !automode_flag ){ skip_mode |= SKIP_NORMAL; printf("toggle skip to true\n"); stopAnimation( clickstr_state ); return true; } else if (event->keysym.sym == SDLK_o){ if (skip_mode & SKIP_TO_EOP) skip_mode &= ~SKIP_TO_EOP; else skip_mode |= SKIP_TO_EOP; printf("toggle draw one page flag to %s\n", (skip_mode & SKIP_TO_EOP?"true":"false") ); if ( skip_mode & SKIP_TO_EOP ){ stopAnimation( clickstr_state ); return true; } } else if ( event->keysym.sym == SDLK_a && !automode_flag ){ automode_flag = true; skip_mode &= ~SKIP_NORMAL; printf("change to automode\n"); stopAnimation( clickstr_state ); return true; } else if ( event->keysym.sym == SDLK_0 ){ if (++text_speed_no > 2) text_speed_no = 0; sentence_font.wait_time = -1; } else if ( event->keysym.sym == SDLK_1 ){ text_speed_no = 0; sentence_font.wait_time = -1; } else if ( event->keysym.sym == SDLK_2 ){ text_speed_no = 1; sentence_font.wait_time = -1; } else if ( event->keysym.sym == SDLK_3 ){ text_speed_no = 2; sentence_font.wait_time = -1; } } if ( event_mode & ( WAIT_INPUT_MODE | WAIT_BUTTON_MODE ) ){ if ( event->keysym.sym == SDLK_f ){ if ( fullscreen_mode ) menu_windowCommand(); else menu_fullCommand(); } } return false; }
void ONScripter::executeSystemSave() { 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( save_menu_name ) / 2 ) / 2, 0); uchar3 color = {0xff, 0xff, 0xff}; drawString( save_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 ]; for ( unsigned int i=1 ; i<=num_save_file ; i++ ){ SaveFileInfo save_file_info; 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; do waitEventSub(-1); while (current_button_state.button == 0); deleteButtonLink(); if ( current_button_state.button > 0 ){ int file_no = current_button_state.button; if (executeSystemYesNo( SYSTEM_SAVE, file_no )){ if (saveon_flag && internal_saveon_flag) saveSaveFile(-1); saveSaveFile( file_no ); leaveSystemCall(); } return; } leaveSystemCall(); }