From: Holger Schemel Date: Tue, 11 Feb 2014 00:46:13 +0000 (+0100) Subject: rnd-20140211-1-src X-Git-Tag: 4.0.0.0-rc1~403 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=439b24a7e57f7af4081ef917fabe6b3cb78d902d rnd-20140211-1-src --- diff --git a/src/conf_gfx.c b/src/conf_gfx.c index eb8d100d..f0c258b4 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6744,6 +6744,9 @@ struct ConfigInfo image_config[] = { "request.step_offset", "10" }, { "request.step_delay", "20" }, { "request.anim_mode", "default" }, + { "request.autowrap", "false" }, + { "request.centered", "true" }, + { "request.wrap_single_words", "true" }, { "global.use_envelope_request", "false" }, diff --git a/src/conf_var.c b/src/conf_var.c index bee7f5ab..f6a55cf1 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -5472,6 +5472,18 @@ struct TokenIntPtrInfo image_config_vars[] = "request.anim_mode", &request.anim_mode }, + { + "request.autowrap", + &request.autowrap + }, + { + "request.centered", + &request.centered + }, + { + "request.wrap_single_words", + &request.wrap_single_words + }, { "global.use_envelope_request", &global.use_envelope_request diff --git a/src/conftime.h b/src/conftime.h index 0d1832c9..314aa87d 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-02-05 23:30" +#define COMPILE_DATE_STRING "2014-02-11 01:44" diff --git a/src/editor.c b/src/editor.c index 005a1a2a..c6d6ecfa 100644 --- a/src/editor.c +++ b/src/editor.c @@ -6733,8 +6733,8 @@ static boolean PrepareSavingIntoPersonalLevelSet() return TRUE; } - if (!Request("This level is read only ! " - "Save into personal level set ?", REQ_ASK)) + if (!Request("This level is read only! " + "Save into personal level set?", REQ_ASK)) return FALSE; // "cd" to personal level set dir (for writing copy the first time) @@ -7012,13 +7012,13 @@ static boolean CopyCustomElement(int element_old, int element_new, } else if (IS_CUSTOM_ELEMENT(element_old) && !IS_CUSTOM_ELEMENT(element_new)) { - Request("Please choose custom element !", REQ_CONFIRM); + Request("Please choose custom element!", REQ_CONFIRM); return FALSE; } else if (IS_GROUP_ELEMENT(element_old) && !IS_GROUP_ELEMENT(element_new)) { - Request("Please choose group element !", REQ_CONFIRM); + Request("Please choose group element!", REQ_CONFIRM); return FALSE; } @@ -7243,7 +7243,7 @@ static void CopyCustomElementPropertiesToGame(int element) if (level.use_custom_template) { - if (Request("Copy and modify level template ?", REQ_ASK)) + if (Request("Copy and modify level template?", REQ_ASK)) { level.use_custom_template = FALSE; ModifyGadget(level_editor_gadget[GADGET_ID_CUSTOM_USE_TEMPLATE], @@ -10878,7 +10878,7 @@ static void HandleCounterButtons(struct GadgetInfo *gi) if ((level_changed && pressed) || (!level_changed && released)) return; - if (level_changed && !Request("Level has changed ! Discard changes ?", + if (level_changed && !Request("Level has changed! Discard changes?", REQ_ASK)) { if (gadget_id == counterbutton_info[counter_id].gadget_id_text) @@ -11051,11 +11051,11 @@ static void HandleTextbuttonGadgets(struct GadgetInfo *gi) CopyPlayfield(Feld, level.field); if (new_template || - Request("Save this template and kill the old ?", REQ_ASK)) + Request("Save this template and kill the old?", REQ_ASK)) SaveLevelTemplate(); if (new_template) - Request("Template saved !", REQ_CONFIRM); + Request("Template saved!", REQ_CONFIRM); /* restore original "level.field" (needed to track playfield changes) */ CopyPlayfield(FieldBackup, level.field); @@ -11171,7 +11171,7 @@ static void HandleCheckbuttons(struct GadgetInfo *gi) if (level.use_custom_template && !fileExists(template_filename)) { - Request("No level template found !", REQ_CONFIRM); + Request("No level template found!", REQ_CONFIRM); level.use_custom_template = FALSE; ModifyGadget(gi, GDI_CHECKED, FALSE, GDI_END); @@ -11404,7 +11404,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) case GADGET_ID_UNDO: if (undo_buffer_steps == 0) { - Request("Undo buffer empty !", REQ_CONFIRM); + Request("Undo buffer empty!", REQ_CONFIRM); break; } @@ -11478,7 +11478,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) new_level = !fileExists(level_filename); if (new_level || - Request("Save this level and kill the old ?", REQ_ASK)) + Request("Save this level and kill the old?", REQ_ASK)) { if (leveldir_former->readonly) ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name); @@ -11494,10 +11494,10 @@ static void HandleControlButtons(struct GadgetInfo *gi) if (leveldir_former->readonly) sprintf(level_saved_msg, - "Level saved as level %d into personal level set !", + "Level saved as level %d into personal level set!", level_nr); else - strcpy(level_saved_msg, "Level saved !"); + strcpy(level_saved_msg, "Level saved!"); Request(level_saved_msg, REQ_CONFIRM); } @@ -12003,7 +12003,7 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed, { if (!ask_if_level_has_changed || !LevelChanged() || - Request("Level has changed ! Exit without saving ?", + Request("Level has changed! Exit without saving?", REQ_ASK | REQ_STAY_OPEN)) { CloseDoor(DOOR_CLOSE_1); diff --git a/src/events.c b/src/events.c index a189082a..071796d8 100644 --- a/src/events.c +++ b/src/events.c @@ -570,12 +570,14 @@ void HandleFingerEvent(FingerEvent *event) event->x < 5.0 / 6.0 ? setup.input[0].key.left : setup.input[0].key.right) : KSYM_UNDEFINED); +#if 0 char *key_name = (key == setup.input[0].key.snap ? "SNAP" : key == setup.input[0].key.drop ? "DROP" : key == setup.input[0].key.up ? "UP" : key == setup.input[0].key.down ? "DOWN" : key == setup.input[0].key.left ? "LEFT" : key == setup.input[0].key.right ? "RIGHT" : "(unknown)"); +#endif char *key_status_name = (key_status == KEY_RELEASED ? "KEY_RELEASED" : "KEY_PRESSED"); #else diff --git a/src/files.c b/src/files.c index 487793f0..fb2e1d3c 100644 --- a/src/files.c +++ b/src/files.c @@ -10176,12 +10176,12 @@ boolean SaveLevelChecked(int nr) boolean new_level = !fileExists(filename); boolean level_saved = FALSE; - if (new_level || Request("Save this level and kill the old ?", REQ_ASK)) + if (new_level || Request("Save this level and kill the old?", REQ_ASK)) { SaveLevel(nr); if (new_level) - Request("Level saved !", REQ_CONFIRM); + Request("Level saved!", REQ_CONFIRM); level_saved = TRUE; } @@ -11111,7 +11111,7 @@ void SaveTape(int nr) if (fileExists(filename)) { new_tape = FALSE; - if (!Request("Replace old tape ?", REQ_ASK)) + if (!Request("Replace old tape?", REQ_ASK)) return; } #endif @@ -11156,7 +11156,7 @@ void SaveTape(int nr) #if 0 if (new_tape) - Request("Tape saved !", REQ_CONFIRM); + Request("Tape saved!", REQ_CONFIRM); #endif } @@ -11166,12 +11166,12 @@ boolean SaveTapeChecked(int nr) boolean new_tape = !fileExists(filename); boolean tape_saved = FALSE; - if (new_tape || Request("Replace old tape ?", REQ_ASK)) + if (new_tape || Request("Replace old tape?", REQ_ASK)) { SaveTape(nr); if (new_tape) - Request("Tape saved !", REQ_CONFIRM); + Request("Tape saved!", REQ_CONFIRM); tape_saved = TRUE; } diff --git a/src/game.c b/src/game.c index e16e5b1b..09faa8b1 100644 --- a/src/game.c +++ b/src/game.c @@ -12126,9 +12126,9 @@ void GameActions() /* detect endless loops, caused by custom element programming */ if (recursion_loop_detected && recursion_loop_depth == 0) { - char *message = getStringCat3("Internal Error ! Element ", + char *message = getStringCat3("Internal Error! Element ", EL_NAME(recursion_loop_element), - " caused endless loop ! Quit the game ?"); + " caused endless loop! Quit the game?"); Error(ERR_WARN, "element '%s' caused endless loop in game engine", EL_NAME(recursion_loop_element)); @@ -16286,7 +16286,7 @@ void RequestQuitGame(boolean ask_if_really_quit) boolean skip_request = AllPlayersGone || quick_quit; RequestQuitGameExt(skip_request, quick_quit, - "Do you really want to quit the game ?"); + "Do you really want to quit the game?"); } diff --git a/src/main.h b/src/main.h index 835e8f41..17fec5ca 100644 --- a/src/main.h +++ b/src/main.h @@ -2312,6 +2312,9 @@ struct RequestInfo int step_offset; int step_delay; int anim_mode; + boolean autowrap; + boolean centered; + boolean wrap_single_words; }; struct PreviewInfo diff --git a/src/network.c b/src/network.c index 823d1b50..655f9c8f 100644 --- a/src/network.c +++ b/src/network.c @@ -439,7 +439,7 @@ static void Handle_OP_NUMBER_WANTED() { char request[100]; - sprintf(request, "Sorry ! Player %d already exists ! You are player %d !", + sprintf(request, "Sorry! Player %d already exists! You are player %d!", index_nr_wanted + 1, new_index_nr + 1); Request(request, REQ_CONFIRM); @@ -571,7 +571,7 @@ static void Handle_OP_STOP_PLAYING() else if (buffer[2] == NETWORK_STOP_BY_ERROR) Request("Network game stopped due to internal error!", REQ_CONFIRM); else - Request("Network game stopped !", REQ_CONFIRM); + Request("Network game stopped!", REQ_CONFIRM); } game_status = GAME_MODE_MAIN; diff --git a/src/screens.c b/src/screens.c index 6ddc6044..e2f3f27f 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1755,7 +1755,7 @@ void HandleMainMenu_SelectLevel(int step, int direction) { /* skipping levels is only allowed when trying to skip single level */ if (setup.skip_levels && step == 1 && - Request("Level still unsolved ! Skip despite handicap ?", REQ_ASK)) + Request("Level still unsolved! Skip despite handicap?", REQ_ASK)) { leveldir_current->handicap_level++; SaveLevelSetup_SeriesInfo(); @@ -1904,7 +1904,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { if (leveldir_current->readonly && !strEqual(setup.player_name, "Artsoft")) - Request("This level is read only !", REQ_CONFIRM); + Request("This level is read only!", REQ_CONFIRM); game_status = GAME_MODE_EDITOR; @@ -1940,7 +1940,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); - if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED)) + if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED)) game_status = GAME_MODE_QUIT; } } diff --git a/src/tape.c b/src/tape.c index 1d8a3ed0..2ab6f4be 100644 --- a/src/tape.c +++ b/src/tape.c @@ -1079,7 +1079,7 @@ void TapeQuickSave() { if (game_status == GAME_MODE_MAIN) { - Request("No game that can be saved !", REQ_CONFIRM); + Request("No game that can be saved!", REQ_CONFIRM); return; } @@ -1092,7 +1092,7 @@ void TapeQuickSave() if (TAPE_IS_EMPTY(tape)) { - Request("No tape that can be saved !", REQ_CONFIRM); + Request("No tape that can be saved!", REQ_CONFIRM); return; } @@ -1107,12 +1107,12 @@ void TapeQuickLoad() if (!fileExists(filename)) { - Request("No tape for this level !", REQ_CONFIRM); + Request("No tape for this level!", REQ_CONFIRM); return; } - if (tape.recording && !Request("Stop recording and load tape ?", + if (tape.recording && !Request("Stop recording and load tape?", REQ_ASK | REQ_STAY_CLOSED)) { OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); @@ -1157,7 +1157,7 @@ void TapeQuickLoad() { int reopen_door = (game_status == GAME_MODE_PLAYING ? REQ_REOPEN : 0); - Request("No tape for this level !", REQ_CONFIRM | reopen_door); + Request("No tape for this level!", REQ_CONFIRM | reopen_door); } } @@ -1169,7 +1169,7 @@ void InsertSolutionTape() LoadSolutionTape(level_nr); if (TAPE_IS_EMPTY(tape)) - Request("No solution tape for this level !", REQ_CONFIRM); + Request("No solution tape for this level!", REQ_CONFIRM); DrawCompleteVideoDisplay(); } @@ -1458,7 +1458,7 @@ static void HandleTapeButtonsExt(int id) LoadTape(level_nr); if (TAPE_IS_EMPTY(tape)) - Request("No tape for this level !", REQ_CONFIRM); + Request("No tape for this level!", REQ_CONFIRM); } else { diff --git a/src/tools.c b/src/tools.c index 95f12fc1..d7b94cb0 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2475,9 +2475,11 @@ void DrawEnvelopeBackgroundTiles(int graphic, int startx, int starty, int dst_y = starty + y * tile_height; int width = graphic_info[graphic].width; int height = graphic_info[graphic].height; - int inner_width = MAX(width - 2 * tile_width, tile_width); - int inner_height = MAX(height - 2 * tile_height, tile_height); - int inner_sx = (width >= 3 * tile_width ? tile_width : 0); + int inner_width_raw = MAX(width - 2 * tile_width, tile_width); + int inner_height_raw = MAX(height - 2 * tile_height, tile_height); + int inner_width = inner_width_raw - (inner_width_raw % tile_width); + int inner_height = inner_height_raw - (inner_height_raw % tile_height); + int inner_sx = (width >= 3 * tile_width ? tile_width : 0); int inner_sy = (height >= 3 * tile_height ? tile_height : 0); boolean draw_masked = graphic_info[graphic].draw_masked; @@ -2644,6 +2646,8 @@ static void setRequestPosition(int *x, int *y, boolean add_border_size) void DrawEnvelopeRequest(char *text) { + char *text_final = text; + char *text_door_style = NULL; int graphic = IMG_BACKGROUND_REQUEST; Bitmap *src_bitmap = graphic_info[graphic].bitmap; int mask_mode = (src_bitmap != NULL ? BLIT_MASKED : BLIT_ON_BACKGROUND); @@ -2657,8 +2661,6 @@ void DrawEnvelopeRequest(char *text) int text_height = request.height - 2 * border_size; int line_length = text_width / font_width; int max_lines = text_height / line_height; - boolean autowrap = FALSE; - boolean centered = TRUE; int width = request.width; int height = request.height; int tile_size = request.step_offset; @@ -2667,6 +2669,33 @@ void DrawEnvelopeRequest(char *text) int sx, sy; int i, x, y; + if (request.wrap_single_words) + { + char *src_text_ptr, *dst_text_ptr; + + text_door_style = checked_malloc(2 * strlen(text) + 1); + + src_text_ptr = text; + dst_text_ptr = text_door_style; + + while (*src_text_ptr) + { + if (*src_text_ptr == ' ' || + *src_text_ptr == '?' || + *src_text_ptr == '!') + *dst_text_ptr++ = '\n'; + + if (*src_text_ptr != ' ') + *dst_text_ptr++ = *src_text_ptr; + + src_text_ptr++; + } + + *dst_text_ptr = '\0'; + + text_final = text_door_style; + } + setRequestPosition(&sx, &sy, FALSE); ClearRectangle(backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE); @@ -2677,9 +2706,9 @@ void DrawEnvelopeRequest(char *text) x, y, x_steps, y_steps, tile_size, tile_size); - DrawTextBuffer(sx + border_size, sy + border_size, text, font_nr, + DrawTextBuffer(sx + border_size, sy + border_size, text_final, font_nr, line_length, -1, max_lines, line_spacing, mask_mode, - autowrap, centered, FALSE); + request.autowrap, request.centered, FALSE); for (i = 0; i < NUM_TOOL_BUTTONS; i++) RedrawGadget(tool_gadget[i]); @@ -2704,11 +2733,14 @@ void DrawEnvelopeRequest(char *text) Delay(1000); #endif + + if (text_door_style) + free(text_door_style); } #if 1 -void AnimateEnvelopeRequest(char *text, int anim_mode, int action) +void AnimateEnvelopeRequest(int anim_mode, int action) { int graphic = IMG_BACKGROUND_REQUEST; boolean draw_masked = graphic_info[graphic].draw_masked; @@ -3046,12 +3078,14 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) int anim_mode = graphic_info[graphic].anim_mode; int main_anim_mode = (anim_mode == ANIM_NONE ? ANIM_VERTICAL|ANIM_HORIZONTAL: anim_mode == ANIM_DEFAULT ? ANIM_VERTICAL : anim_mode); +#if 0 char *text_copy = getStringCopy(text); char *text_ptr; for (text_ptr = text_copy; *text_ptr; text_ptr++) if (*text_ptr == ' ') *text_ptr = '\n'; +#endif #if 1 if (game_status == GAME_MODE_PLAYING) @@ -3093,7 +3127,11 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) } #endif +#if 1 + DrawEnvelopeRequest(text); +#else DrawEnvelopeRequest(text_copy); +#endif if (game_status != GAME_MODE_MAIN) InitAnimation(); @@ -3110,9 +3148,9 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) PlayMenuSoundStereo(sound_opening, SOUND_MIDDLE); if (anim_mode == ANIM_DEFAULT) - AnimateEnvelopeRequest(text, ANIM_DEFAULT, ACTION_OPENING); + AnimateEnvelopeRequest(ANIM_DEFAULT, ACTION_OPENING); - AnimateEnvelopeRequest(text, main_anim_mode, ACTION_OPENING); + AnimateEnvelopeRequest(main_anim_mode, ACTION_OPENING); #if 0 if (tape.playing) @@ -3126,10 +3164,10 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) PlayMenuSoundStereo(sound_closing, SOUND_MIDDLE); if (anim_mode != ANIM_NONE) - AnimateEnvelopeRequest(text, main_anim_mode, ACTION_CLOSING); + AnimateEnvelopeRequest(main_anim_mode, ACTION_CLOSING); if (anim_mode == ANIM_DEFAULT) - AnimateEnvelopeRequest(text, ANIM_DEFAULT, ACTION_CLOSING); + AnimateEnvelopeRequest(ANIM_DEFAULT, ACTION_CLOSING); } game.envelope_active = FALSE; @@ -3181,7 +3219,9 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) BackToFront(); #endif +#if 0 free(text_copy); +#endif } void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) @@ -4394,10 +4434,14 @@ static boolean RequestDoor(char *text, unsigned int req_state) for (tl = 0, tx = 0; tx < max_request_line_len; tl++, tx++) { tc = *(text_ptr + tx); - if (!tc || tc == ' ') + // if (!tc || tc == ' ') + if (!tc || tc == ' ' || tc == '?' || tc == '!') break; } + if ((tc == '?' || tc == '!') && tl == 0) + tl = 1; + if (!tl) { text_ptr++; @@ -4413,6 +4457,7 @@ static boolean RequestDoor(char *text, unsigned int req_state) text_line, font_nr); text_ptr += tl + (tc == ' ' ? 1 : 0); + // text_ptr += tl + (tc == ' ' || tc == '?' || tc == '!' ? 1 : 0); } game_status = last_game_status; /* restore current game status */