From e915bc5842bce8d548107ce109a6bd0af63b3618 Mon Sep 17 00:00:00 2001 From: "p.kosyh" Date: Sat, 12 Dec 2009 14:13:22 +0000 Subject: [PATCH] xref hl optimization --- src/sdl-instead/game.c | 8 +++----- src/sdl-instead/graphics.c | 8 ++++++++ src/sdl-instead/graphics.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/sdl-instead/game.c b/src/sdl-instead/game.c index ca29aa8..2760b24 100644 --- a/src/sdl-instead/game.c +++ b/src/sdl-instead/game.c @@ -1518,21 +1518,19 @@ int game_highlight(int x, int y, int on) struct el *elem = NULL; static struct el *oel = NULL; static xref_t hxref = NULL; - xref_t xref = NULL; - int up = 0; + xref_t xref = NULL; if (on) { xref = look_xref(x, y, &elem); - if (xref && opt_hl) { + if (xref && opt_hl && !xref_get_active(xref)) { xref_set_active(xref, 1); game_xref_update(xref, elem->x, elem->y); } } if (hxref != xref && oel) { - if (hxref != use_xref) { + if (hxref != use_xref && xref_get_active(hxref)) { xref_set_active(hxref, 0); game_xref_update(hxref, oel->x, oel->y); - up = 1; } hxref = NULL; } diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c index e170108..ed1961e 100644 --- a/src/sdl-instead/graphics.c +++ b/src/sdl-instead/graphics.c @@ -2626,6 +2626,14 @@ void xref_set_active(xref_t x, int val) xref->active = val; } +int xref_get_active(xref_t x) +{ + struct xref *xref = (struct xref*)x; + if (!xref) + return 0; + return xref->active; +} + layout_t txt_layout(fnt_t fn, int align, int width, int height) { diff --git a/src/sdl-instead/graphics.h b/src/sdl-instead/graphics.h index f478012..8bd0d5f 100644 --- a/src/sdl-instead/graphics.h +++ b/src/sdl-instead/graphics.h @@ -118,6 +118,7 @@ extern img_t txt_box_render(textbox_t tbox); extern char *xref_get_text(xref_t x); extern void xref_set_active(xref_t x, int val); +extern int xref_get_active(xref_t x); extern xref_t xref_next(xref_t x); extern xref_t xref_prev(xref_t x);