From 53b94b89c7037837eb6bf00ea8b71d9f92963f35 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 21 Jun 2009 21:25:58 +0000 Subject: Apply commits r10013 and 10014 to trunk. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10015 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/options_guide.txt | 19 ++++++--- crawl-ref/settings/tiles_options.txt | 53 ++++++++++++----------- crawl-ref/source/cio.cc | 6 +-- crawl-ref/source/directn.cc | 24 +++++++---- crawl-ref/source/externs.h | 6 ++- crawl-ref/source/format.cc | 2 - crawl-ref/source/initfile.cc | 4 +- crawl-ref/source/libw32c.cc | 9 ++-- crawl-ref/source/stuff.cc | 2 +- crawl-ref/source/tile2.cc | 3 +- crawl-ref/source/tilereg.cc | 25 ++++++++++- crawl-ref/source/tilesdl.cc | 82 ++++++++++++++++++++++-------------- 12 files changed, 150 insertions(+), 85 deletions(-) diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index d263188a88..f70401d084 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -92,12 +92,13 @@ The contents of this text are: tile_mapped_wall_col, tile_door_col, tile_downstairs_col, tile_upstairs_col, tile_feature_col, tile_trap_col, tile_water_col, tile_lava_col, tile_excluded_col, - tile_excl_centre_col, tile_key_repeat_delay, tile_tooltip_ms, - tile_tag_pref, tile_window_width, tile_window_height, - tile_map_pixels, tile_full_screen, tile_font_crt_file, - tile_font_stat_file, tile_font_msg_file, tile_font_tip_file, - tile_font_lbl_file, tile_font_crt_size, tile_font_stat_size, - tile_font_msg_size, tile_font_tip_size, tile_font_lbl_size + tile_excl_centre_col, tile_update_rate, tile_key_repeat_delay, + tile_tooltip_ms, tile_tag_pref, tile_full_screen, + tile_window_width, tile_window_height, tile_map_pixels, + tile_font_crt_file, tile_font_stat_file, tile_font_msg_file, + tile_font_tip_file, tile_font_lbl_file, tile_font_crt_size, + tile_font_stat_size, tile_font_msg_size, tile_font_tip_size, + tile_font_lbl_size 5- Character Dump. 5-a Items and Kills. kill_map, dump_kill_places, dump_item_origins, @@ -1637,6 +1638,12 @@ the dungeon level. tile_floor_col and tile_item_col, only) tile_window_col - colour of the rectangular view window +tile_update_rate = 1000 + The number of milliseconds that tick by before the screen is redrawn + without any input. If game response is slow, try increasing this + number. If, on the other hand, response time is fine but it takes too + long for redrawings to happen, set it to a lower value. + tile_key_repeat_delay = 200 If you hold down a key, there's a delay until the pressed key will take action. This option controls this delay, in milliseconds. If it diff --git a/crawl-ref/settings/tiles_options.txt b/crawl-ref/settings/tiles_options.txt index 65d58fdbe3..ae4bd6a41a 100644 --- a/crawl-ref/settings/tiles_options.txt +++ b/crawl-ref/settings/tiles_options.txt @@ -9,38 +9,41 @@ ### The following lines define the colours of various objects within the ### tiles minimap. See options_guide.txt for more details. -# tile_player_col = white -# tile_monster_col = red -# tile_neutral_col = red -# tile_friendly_col = lightred -# tile_plant_col = darkgreen -# tile_item_col = green -# tile_unseen_col = black -# tile_floor_col = lightgrey -# tile_wall_col = darkgrey -# tile_mapped_wall_col = blue -# tile_door_col = brown -# tile_downstairs_col = magenta -# tile_upstairs_col = blue -# tile_feature_col = cyan -# tile_trap_col = yellow -# tile_water_col = grey -# tile_lava_col = grey -# tile_excluded_col = darkcyan -# tile_excl_centre = darkblue -# tile_window_col = yellow +# tile_player_col = white +# tile_monster_col = red +# tile_neutral_col = red +# tile_friendly_col = lightred +# tile_plant_col = darkgreen +# tile_item_col = green +# tile_unseen_col = black +# tile_floor_col = lightgrey +# tile_wall_col = darkgrey +# tile_mapped_wall_col = blue +# tile_door_col = brown +# tile_downstairs_col = magenta +# tile_upstairs_col = blue +# tile_feature_col = cyan +# tile_trap_col = yellow +# tile_water_col = grey +# tile_lava_col = grey +# tile_excluded_col = darkcyan +# tile_excl_centre = darkblue +# tile_window_col = yellow + +# If Crawl's response rate is to slow, try increasing the update rate. +# tile_update_rate = 1000 # tile_key_repeat_delay = 200 # tile_tooltip_ms = 500 # tile_tag_pref = enemy -### Note: setting window, map, or font sizes to '0' implies auto-sizing. +### Note: setting window, map or font sizes to '0' implies auto-sizing. -# tile_window_width = 1024 -# tile_window_height = 768 -# tile_map_pixels = 4 -# tile_full_screen = true +# tile_full_screen = true +# tile_window_width = 1024 +# tile_window_height = 768 +# tile_map_pixels = 4 # tile_font_crt_file = VeraMono.ttf # tile_font_crt_size = 15 diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc index d5c87f7e0a..f657204f88 100644 --- a/crawl-ref/source/cio.cc +++ b/crawl-ref/source/cio.cc @@ -415,7 +415,7 @@ int line_reader::read_line(bool clear_previous) if (history) history->go_end(); - for ( ; ; ) + while (true) { int ch = getchm(c_getch); @@ -514,8 +514,8 @@ int line_reader::process_key(int ch) if (!history) break; - const std::string *text = - ch == CK_UP ? history->prev() : history->next(); + const std::string *text = (ch == CK_UP) ? history->prev() + : history->next(); if (text) { diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index b30fce1734..49e6007702 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -523,8 +523,6 @@ void full_describe_view() InvMenu desc_menu(MF_SINGLESELECT | MF_ANYPRINTABLE | MF_ALLOW_FORMATTING | MF_SELECT_BY_PAGE); - // FIXME: Need different title for the opposite toggle: - // "Visible Monsters/Items (select for more detail, '!' to examine):" std::string title = ""; std::string action = ""; if (!list_mons.empty()) @@ -1067,6 +1065,7 @@ void direction(dist& moves, targeting_type restricts, } bool show_prompt = true; + bool moved_with_keys = true; while (true) { @@ -1084,7 +1083,6 @@ void direction(dist& moves, targeting_type restricts, { terse_describe_square(moves.target); } - show_prompt = false; } @@ -1097,7 +1095,9 @@ void direction(dist& moves, targeting_type restricts, moves.isEndpoint = false; moves.choseRay = false; - cursorxy( grid2viewX(moves.target.x), grid2viewY(moves.target.y) ); + // This probably is called too often for Tiles. (jpeg) + if (moved_with_keys) + cursorxy(grid2viewX(moves.target.x), grid2viewY(moves.target.y)); command_type key_command; @@ -1118,6 +1118,7 @@ void direction(dist& moves, targeting_type restricts, if (key_command == CMD_TARGET_MOUSE_MOVE || key_command == CMD_TARGET_MOUSE_SELECT) { + moved_with_keys = false; const coord_def &gc = tiles.get_cursor(); if (gc != Region::NO_CURSOR) { @@ -1149,6 +1150,8 @@ void direction(dist& moves, targeting_type restricts, key_command = CMD_NO_CMD; } } + else + moved_with_keys = true; #endif if (target_unshifted && moves.target == you.pos() @@ -1205,7 +1208,7 @@ void direction(dist& moves, targeting_type restricts, switch (key_command) { - // standard movement + // standard movement case CMD_TARGET_DOWN_LEFT: case CMD_TARGET_DOWN: case CMD_TARGET_DOWN_RIGHT: @@ -1612,7 +1615,7 @@ void direction(dist& moves, targeting_type restricts, } flush_prev_message(); - if (loop_done == true) + if (loop_done) { // Confirm that the loop is really done. If it is, // break out. If not, just continue looping. @@ -1643,12 +1646,15 @@ void direction(dist& moves, targeting_type restricts, } bool have_moved = false; - if (old_target != moves.target) { have_moved = true; - show_beam = show_beam && find_ray(you.pos(), moves.target, - true, ray, 0, true); + + if (show_beam) + { + show_beam = find_ray(you.pos(), moves.target, + true, ray, 0, true); + } } if (force_redraw) diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 3f8f1516d3..c479cc7396 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -2215,6 +2215,7 @@ public: char tile_excluded_col; char tile_excl_centre_col; char tile_window_col; + // font settings std::string tile_font_crt_file; int tile_font_crt_size; std::string tile_font_msg_file; @@ -2225,11 +2226,14 @@ public: int tile_font_lbl_size; std::string tile_font_tip_file; int tile_font_tip_size; - int tile_key_repeat_delay; + // window settings screen_mode tile_full_screen; int tile_window_width; int tile_window_height; int tile_map_pixels; + // display settings + int tile_update_rate; + int tile_key_repeat_delay; int tile_tooltip_ms; tag_pref tile_tag_pref; #endif diff --git a/crawl-ref/source/format.cc b/crawl-ref/source/format.cc index 012c64a181..d6c0d343c5 100644 --- a/crawl-ref/source/format.cc +++ b/crawl-ref/source/format.cc @@ -429,10 +429,8 @@ int formatted_string::find_last_colour() const if (!ops.empty()) { for (int i = ops.size() - 1; i >= 0; --i) - { if (ops[i].type == FSOP_COLOUR) return (ops[i].x); - } } return (LIGHTGREY); } diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 6b47f77579..b4591ef163 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -935,11 +935,12 @@ void game_options::reset_options() tile_window_width = 0; tile_window_height = 0; tile_map_pixels = 0; - tile_tag_pref = crawl_state.arena ? TAGPREF_NAMED : TAGPREF_ENEMY; // delays + tile_update_rate = 1000; tile_key_repeat_delay = 200; tile_tooltip_ms = 500; + tile_tag_pref = crawl_state.arena ? TAGPREF_NAMED : TAGPREF_ENEMY; #endif // map each colour to itself as default @@ -3161,6 +3162,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) else INT_OPTION(tile_window_height, 1, INT_MAX); else INT_OPTION(tile_map_pixels, 1, INT_MAX); else INT_OPTION(tile_tooltip_ms, 0, INT_MAX); + else INT_OPTION(tile_update_rate, 50, INT_MAX); else if (key == "tile_tag_pref") { tile_tag_pref = string2tag_pref(field.c_str()); diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc index ef456090a4..7e55786cdd 100644 --- a/crawl-ref/source/libw32c.cc +++ b/crawl-ref/source/libw32c.cc @@ -129,9 +129,9 @@ static DWORD crawlColorData[16] = void writeChar(char c) { - if ( c == '\t' ) + if (c == '\t') { - for ( int i = 0; i < 8; ++i ) + for (int i = 0; i < 8; ++i) writeChar(' '); return; } @@ -172,7 +172,7 @@ void writeChar(char c) if (chy < 0) chsx = cx; - chy = cy; + chy = cy; chex = cx; // if we're not buffering, flush @@ -182,7 +182,8 @@ void writeChar(char c) // update x position cx += 1; - if (cx >= screensize.X) cx = screensize.X - 1; + if (cx >= screensize.X) + cx = screensize.X - 1; } void enable_smart_cursor(bool cursor) diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 4fb4d9234f..43bcdb7a77 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -813,7 +813,7 @@ void redraw_screen(void) print_stats(); if (Options.delay_message_clear) - mesclr( true ); + mesclr(true); bool note_status = notes_are_active(); activate_notes(false); diff --git a/crawl-ref/source/tile2.cc b/crawl-ref/source/tile2.cc index ab0fdae775..3ffe311635 100644 --- a/crawl-ref/source/tile2.cc +++ b/crawl-ref/source/tile2.cc @@ -186,11 +186,12 @@ void tile_init_default_flavour() tile_default_flv(you.level_type, you.where_are_you, env.tile_default); } +// FIXME: Needs to be updated whenever the order of clouds or monsters changes. int get_clean_map_idx(int tile_idx) { int idx = tile_idx & TILE_FLAG_MASK; if (idx >= TILE_CLOUD_FIRE_0 && idx <= TILE_CLOUD_PURP_SMOKE - || idx >= TILEP_MONS_SHADOW && idx <= TILEP_MONS_WATER_ELEMENTAL + || idx >= TILEP_MONS_PANDEMONIUM_DEMON && idx <= TILEP_MONS_TEST_SPAWNER || idx >= TILEP_MCACHE_START) { return 0; diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 0280c9aea9..1710eab6ee 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -1008,8 +1008,12 @@ struct tag_def char type; }; +// #define DEBUG_TILES_REDRAW void DungeonRegion::render() { +#ifdef DEBUG_TILES_REDRAW + cprintf("rendering DungeonRegion\n"); +#endif if (m_dirty) { pack_buffers(); @@ -1629,6 +1633,9 @@ void InventoryRegion::render() if (m_buf_dngn.empty() && m_buf_main.empty()) return; +#ifdef DEBUG_TILES_REDRAW + cprintf("rendering InventoryRegion\n"); +#endif set_transform(); m_buf_dngn.draw(); m_buf_main.draw(); @@ -2312,6 +2319,9 @@ void MapRegion::render() if (m_min_gx > m_max_gx || m_min_gy > m_max_gy) return; +#ifdef DEBUG_TILES_REDRAW + cprintf("rendering MapRegion\n"); +#endif if (m_dirty) { pack_buffers(); @@ -2609,8 +2619,9 @@ void TextRegion::clear_to_end_of_line() void TextRegion::putch(unsigned char ch) { + // special case: check for '0' char: map to space if (ch == 0) - ch=32; + ch = ' '; addstr_aux((char *)&ch, 1); } @@ -2681,6 +2692,9 @@ void TextRegion::_setcursortype(int curstype) void TextRegion::render() { +#ifdef DEBUG_TILES_REDRAW + cprintf("rendering TextRegion\n"); +#endif if (this == TextRegion::cursor_region && cursor_x > 0 && cursor_y > 0) { int idx = cursor_x + mx * cursor_y; @@ -2786,6 +2800,9 @@ struct box_vert void MessageRegion::render() { +#ifdef DEBUG_TILES_REDRAW + cprintf("rendering MessageRegion\n"); +#endif int idx = -1; unsigned char char_back = 0; unsigned char col_back = 0; @@ -3122,6 +3139,9 @@ void MenuRegion::place_entries() void MenuRegion::render() { +#ifdef DEBUG_TILES_REDRAW + cprintf("rendering MenuRegion\n"); +#endif if (m_dirty) place_entries(); @@ -3271,6 +3291,9 @@ TitleRegion::TitleRegion(int width, int height) : void TitleRegion::render() { +#ifdef DEBUG_TILES_REDRAW + cprintf("rendering TitleRegion\n"); +#endif set_transform(); m_buf.draw(); } diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 54b9749dc2..dc13673f87 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -743,11 +743,16 @@ int TilesFramework::getch_ck() int key = 0; + // Don't update tool tips etc. in targetting mode. + const bool mouse_target_mode + = (mouse_control::current_mode() == MOUSE_MODE_TARGET_PATH + || mouse_control::current_mode() == MOUSE_MODE_TARGET_DIR); + // When moving the mouse via cursor when targeting update more often. // For beams, the beam drawing already handles this, and when not targeting // the normal drawing routines handle it. - const unsigned int ticks_per_redraw - = (mouse_control::current_mode() == MOUSE_MODE_TARGET ? 50 : 100); + const unsigned int ticks_per_cursor_redraw = (mouse_target_mode ? 100 : 30); + const unsigned int ticks_per_screen_redraw = Options.tile_update_rate; unsigned int last_redraw_tick = 0; @@ -757,29 +762,22 @@ int TilesFramework::getch_ck() m_tooltip.clear(); m_region_msg->alt_text().clear(); - if (m_need_redraw) + if (need_redraw()) { redraw(); last_redraw_tick = SDL_GetTicks(); } - // Don't update tool tips etc. in targetting mode. - const bool mouse_target_mode - = (mouse_control::current_mode() == MOUSE_MODE_TARGET_PATH - || mouse_control::current_mode() == MOUSE_MODE_TARGET_DIR); - while (!key) { unsigned int ticks = 0; + last_loc = cur_loc; if (SDL_WaitEvent(&event)) { + ticks = SDL_GetTicks(); if (!mouse_target_mode) { - ticks = SDL_GetTicks(); - - last_loc = cur_loc; - if (event.type != SDL_USEREVENT) { tiles.clear_text_tags(TAG_CELL_DESC); @@ -788,7 +786,8 @@ int TilesFramework::getch_ck() // TODO enne - need to find a better time to decide when // to generate a tip or some way to say "yes, but unchanged". - if (tip_loc != cur_loc && ticks > m_last_tick_moved) + if (tip_loc != cur_loc && ticks > m_last_tick_moved + && ticks - last_redraw_tick > ticks_per_cursor_redraw) { m_region_msg->alt_text().clear(); for (unsigned int i = 0; @@ -798,7 +797,10 @@ int TilesFramework::getch_ck() if (!reg->inside(m_mouse.x, m_mouse.y)) continue; if (reg->update_alt_text(m_region_msg->alt_text())) + { + set_need_redraw(); break; + } } } } @@ -895,10 +897,15 @@ int TilesFramework::getch_ck() } } - if (mouse_target_mode) + if (mouse_target_mode + || mouse_control::current_mode() == MOUSE_MODE_TARGET) { + // For some reason not handled in direction(). if (get_cursor() == you.pos()) + { redraw(); + last_redraw_tick = ticks; + } } else { @@ -907,10 +914,8 @@ int TilesFramework::getch_ck() > (unsigned int)Options.tile_tooltip_ms)); if (timeout) - tip_loc = cur_loc; - - if (tip_loc == cur_loc) { + tip_loc = cur_loc; tiles.clear_text_tags(TAG_CELL_DESC); if (Options.tile_tooltip_ms > 0 && m_tooltip.empty()) { @@ -921,23 +926,30 @@ int TilesFramework::getch_ck() if (!reg->inside(m_mouse.x, m_mouse.y)) continue; if (reg->update_tip_text(m_tooltip)) + { + set_need_redraw(); break; + } } - m_need_redraw = true; } } else { -// Don't redraw the cursor if we're just zooming by. -#if 0 - if (last_loc != cur_loc) - m_need_redraw = true; -#endif + // Don't redraw the cursor if we're just zooming by. + if (last_loc != cur_loc + && ticks > last_redraw_tick + && ticks - last_redraw_tick > ticks_per_cursor_redraw) + { + set_need_redraw(); + } + m_tooltip.clear(); tip_loc.reset(); } - if ((ticks - last_redraw_tick > ticks_per_redraw) || need_redraw()) + if (need_redraw() + || ticks > last_redraw_tick + && ticks - last_redraw_tick > ticks_per_screen_redraw) { redraw(); last_redraw_tick = ticks; @@ -945,16 +957,19 @@ int TilesFramework::getch_ck() } } + // We got some input, so we'll probably have to redraw something. + set_need_redraw(); + SDL_SetTimer(0, NULL); return key; } -static const int map_margin = 2; +static const int map_margin = 2; static const int map_stat_buffer = 4; -static const int crt_width = 80; -static const int crt_height = 30; -static const int margin = 4; +static const int crt_width = 80; +static const int crt_height = 30; +static const int margin = 4; void TilesFramework::do_layout() { @@ -1041,7 +1056,7 @@ void TilesFramework::do_layout() { m_region_msg->resize_to_fit(m_region_tile->wx, m_windowsz.y - m_region_msg->sy); - int msg_y = std::min(Options.msg_max_height, (int)m_region_msg->my); + int msg_y = std::min(Options.msg_max_height, (int) m_region_msg->my); m_region_msg->resize(m_region_msg->mx, msg_y); m_region_msg->ex = m_region_tile->ex; @@ -1158,7 +1173,8 @@ void TilesFramework::clrscr() cgotoxy(1,1); } -void TilesFramework::message_out(int which_line, int colour, const char *s, int firstcol, bool newline) +void TilesFramework::message_out(int which_line, int colour, const char *s, + int firstcol, bool newline) { if (!firstcol) firstcol = Options.delay_message_clear ? 2 : 1; @@ -1221,8 +1237,12 @@ void TilesFramework::cgotoxy(int x, int y, int region) TextRegion::cgotoxy(x, y); } +// #define DEBUG_TILES_REDRAW void TilesFramework::redraw() { +#ifdef DEBUG_TILES_REDRAW + cprintf("\nredrawing tiles"); +#endif m_need_redraw = false; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -1231,7 +1251,7 @@ void TilesFramework::redraw() glLoadIdentity(); glScalef(m_viewsc.x, m_viewsc.y, 1.0f); - for (unsigned int i = 0; i < m_layers[m_active_layer].m_regions.size(); i++) + for (unsigned int i = 0; i < m_layers[m_active_layer].m_regions.size(); ++i) m_layers[m_active_layer].m_regions[i]->render(); // Draw tooltip -- cgit v1.2.3-54-g00ecf