diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-06-16 18:22:29 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-06-16 18:22:29 +0000 |
commit | 42bde3cb0caf63ea19cfca4237d957c86390b977 (patch) | |
tree | d4d11ebac689677a05cd6b66e4383ff98ecba955 /crawl-ref | |
parent | 678e0a6c132e04803d98aed21c28a284568e9dda (diff) | |
download | crawl-ref-42bde3cb0caf63ea19cfca4237d957c86390b977.tar.gz crawl-ref-42bde3cb0caf63ea19cfca4237d957c86390b977.zip |
Apply my mouse speed-up commit to trunk.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9987 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/defines.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/tilepick.cc | 28 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.cc | 13 | ||||
-rw-r--r-- | crawl-ref/source/tilesdl.cc | 135 |
5 files changed, 95 insertions, 100 deletions
diff --git a/crawl-ref/source/defines.h b/crawl-ref/source/defines.h index 198603d682..435041cddd 100644 --- a/crawl-ref/source/defines.h +++ b/crawl-ref/source/defines.h @@ -281,6 +281,7 @@ enum mouse_mode MOUSE_MODE_COMMAND, MOUSE_MODE_TARGET, MOUSE_MODE_TARGET_DIR, + MOUSE_MODE_TARGET_PATH, MOUSE_MODE_MORE, MOUSE_MODE_MACRO }; diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index eaeb19075f..15a174c59a 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -1027,7 +1027,8 @@ void direction(dist& moves, targeting_type restricts, } cursor_control con(!Options.use_fake_cursor); - mouse_control mc(MOUSE_MODE_TARGET); + mouse_control mc(needs_path && !just_looking ? MOUSE_MODE_TARGET_PATH + : MOUSE_MODE_TARGET); range_view_annotator rva(range); int dir = 0; @@ -1130,18 +1131,19 @@ void direction(dist& moves, targeting_type restricts, if (key_command == CMD_TARGET_MOUSE_SELECT) { key_command = CMD_TARGET_SELECT; - +// Do we really need this? (jpeg) +// Looks like the redrawing routine already handles it. +#if 0 if (needs_path && range > 0) { ray_def raycopy = ray; int l = 0; - while (raycopy.pos() != moves.target && l < range) - { - l++; + while (raycopy.pos() != moves.target && range > l++) raycopy.advance_through(moves.target); - } + moves.target = raycopy.pos(); } +#endif } } else @@ -1176,8 +1178,8 @@ void direction(dist& moves, targeting_type restricts, } bool need_beam_redraw = false; - bool force_redraw = false; - bool loop_done = false; + bool force_redraw = false; + bool loop_done = false; coord_def old_target = moves.target; if (skip_iter) diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index e736c2f5da..1035271e68 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -3283,34 +3283,6 @@ void tilep_scan_parts(char *fbuf, int *parts) else parts[p] = idx2; } -/* - if (p == TILEP_PART_BASE) - { - int p0 = (parts[p]-1) & (0xfe); - if (((1-idx) & 1) == 1) - p0++; - parts[p] = p0 + 1; - } - else if (idx == TILEP_SHOW_EQUIP) - parts[p] = TILEP_SHOW_EQUIP; - else - parts[p] = 0; -*/ -/* - else if (idx < TILE_MAIN_MAX) - parts[p] = TILE_MAIN_MAX; - else if (idx >= TILEP_PLAYER_MAX) - parts[p] = TILEP_PLAYER_MAX - 1; - else if (idx < 0) - parts[p] = 0; - // TODO enne - is this right? did the old count end at idx not just subtotal? - else if (idx >= tile_player_part_count[p]) - parts[p] = tile_player_part_count[p] - 1; -// else if (idx > tilep_parts_total[p]) // bound it -// parts[p] = tilep_parts_total[p]; - else - parts[p] = idx; -*/ } } diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 32231aafec..ace47f8066 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -323,15 +323,13 @@ static void _load_doll_data(const char *fn, dolls_data *doll) else { memset(fbuf, 0, sizeof(fbuf)); - int cur = 0; - if (fscanf(fp, "%s", fbuf) != EOF) + if (fscanf(fp, "%s", fbuf) == EOF) { -#if 0 - mpr("Read MODE."); - if (strcmp(fbuf, "MODE=LOADING") == 0) - mode0 = TILEP_M_LOADING; -#endif + // We're currently not interested in the MODE setting. (jpeg) + fclose(fp); + return; } + int cur = 0; if (fscanf(fp, "%s", fbuf) != EOF) { if (strncmp(fbuf, "NUM=", 4) == 0) @@ -932,6 +930,7 @@ int DungeonRegion::handle_mouse(MouseEvent &event) return 0; if (mouse_control::current_mode() == MOUSE_MODE_TARGET + || mouse_control::current_mode() == MOUSE_MODE_TARGET_PATH || mouse_control::current_mode() == MOUSE_MODE_TARGET_DIR) { if (event.event == MouseEvent::MOVE) diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 9ba2f854df..22d6f4d1e8 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -597,10 +597,10 @@ static int _translate_keysym(SDL_keysym &keysym) } // Alt does not get baked into keycodes like shift and ctrl, so handle it. - int key_offset = (mod & MOD_ALT) ? 3000 : 0; + const int key_offset = (mod & MOD_ALT) ? 3000 : 0; - bool is_ascii = ((keysym.unicode & 0xFF80) == 0); - return is_ascii ? (keysym.unicode & 0x7F) + key_offset : 0; + const bool is_ascii = ((keysym.unicode & 0xFF80) == 0); + return (is_ascii ? (keysym.unicode & 0x7F) + key_offset : 0); } @@ -709,7 +709,7 @@ static unsigned int _timer_callback(unsigned int ticks) SDL_PushEvent(&event); unsigned int res = Options.tile_tooltip_ms; - return res; + return (res); } // Convenience struct for holding mouse location on screen. @@ -733,7 +733,6 @@ struct cursor_loc int cx, cy; }; - int TilesFramework::getch_ck() { flush_prev_message(); @@ -744,47 +743,58 @@ int TilesFramework::getch_ck() int key = 0; - const unsigned int ticks_per_redraw = 80; + const unsigned int ticks_per_redraw = 100; unsigned int last_redraw_tick = 0; unsigned int res = Options.tile_tooltip_ms; SDL_SetTimer(res, &_timer_callback); + m_tooltip.clear(); + m_region_msg->alt_text().clear(); + if (m_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; if (SDL_WaitEvent(&event)) { - ticks = SDL_GetTicks(); + if (!mouse_target_mode) + { + ticks = SDL_GetTicks(); - last_loc = cur_loc; + last_loc = cur_loc; - if (event.type != SDL_USEREVENT) - { - tiles.clear_text_tags(TAG_CELL_DESC); - m_region_msg->alt_text().clear(); - } + if (event.type != SDL_USEREVENT) + { + tiles.clear_text_tags(TAG_CELL_DESC); + m_region_msg->alt_text().clear(); + } - // TODO enne - need to find a better time to decide when - // to generate a tip or some way to say "yes, but unchanged". - if (ticks > m_last_tick_moved) - { - m_region_msg->alt_text().clear(); - for (unsigned int i = 0; - i < m_layers[m_active_layer].m_regions.size(); i++) + // 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) { - Region *reg = m_layers[m_active_layer].m_regions[i]; - if (!reg->inside(m_mouse.x, m_mouse.y)) - continue; - if (reg->update_alt_text(m_region_msg->alt_text())) - break; + m_region_msg->alt_text().clear(); + for (unsigned int i = 0; + i < m_layers[m_active_layer].m_regions.size(); ++i) + { + Region *reg = m_layers[m_active_layer].m_regions[i]; + if (!reg->inside(m_mouse.x, m_mouse.y)) + continue; + if (reg->update_alt_text(m_region_msg->alt_text())) + break; + } } } @@ -819,7 +829,7 @@ int TilesFramework::getch_ck() MouseEvent mouse_event; _translate_event(event.motion, mouse_event); mouse_event.held = m_buttons_held; - mouse_event.mod = m_key_mod; + mouse_event.mod = m_key_mod; key = handle_mouse(mouse_event); // find mouse location @@ -880,42 +890,53 @@ int TilesFramework::getch_ck() } } - bool timeout = ((ticks - m_last_tick_moved - > (unsigned int)Options.tile_tooltip_ms) - && ticks > m_last_tick_moved); - if (timeout) - tip_loc = cur_loc; - - if (tip_loc == cur_loc) + if (mouse_target_mode) { - tiles.clear_text_tags(TAG_CELL_DESC); - if (m_tooltip.empty()) - { - for (unsigned int i = 0; - i < m_layers[m_active_layer].m_regions.size(); i++) - { - Region *reg = m_layers[m_active_layer].m_regions[i]; - if (!reg->inside(m_mouse.x, m_mouse.y)) - continue; - if (reg->update_tip_text(m_tooltip)) - break; - } - m_need_redraw = true; - } + if (get_cursor() == you.pos()) + redraw(); } else { - if (last_loc != cur_loc) - m_need_redraw = true; + const bool timeout = (ticks > m_last_tick_moved + && (ticks - m_last_tick_moved + > (unsigned int)Options.tile_tooltip_ms)); - m_tooltip.clear(); - tip_loc.reset(); - } + if (timeout) + tip_loc = cur_loc; - if ((ticks - last_redraw_tick > ticks_per_redraw) || need_redraw()) - { - redraw(); - last_redraw_tick = ticks; + if (tip_loc == cur_loc) + { + tiles.clear_text_tags(TAG_CELL_DESC); + if (Options.tile_tooltip_ms > 0 && m_tooltip.empty()) + { + for (unsigned int i = 0; + i < m_layers[m_active_layer].m_regions.size(); ++i) + { + Region *reg = m_layers[m_active_layer].m_regions[i]; + if (!reg->inside(m_mouse.x, m_mouse.y)) + continue; + if (reg->update_tip_text(m_tooltip)) + 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 + m_tooltip.clear(); + tip_loc.reset(); + } + + if ((ticks - last_redraw_tick > ticks_per_redraw) || need_redraw()) + { + redraw(); + last_redraw_tick = ticks; + } } } @@ -1209,7 +1230,7 @@ void TilesFramework::redraw() m_layers[m_active_layer].m_regions[i]->render(); // Draw tooltip - if (!m_tooltip.empty()) + if (Options.tile_tooltip_ms > 0 && !m_tooltip.empty()) { const coord_def min_pos(0, 0); FTFont *font = m_fonts[m_tip_font].font; |