diff --git a/src/sdl-instead/game.c b/src/sdl-instead/game.c index 5451bde..cae667e 100644 --- a/src/sdl-instead/game.c +++ b/src/sdl-instead/game.c @@ -1693,6 +1693,8 @@ struct el *look_obj(int x, int y) return NULL; } +static xref_t get_nearest_xref(int i, int mx, int my); + xref_t look_xref(int x, int y, struct el **elem) { struct el *o; @@ -1708,6 +1710,24 @@ xref_t look_xref(int x, int y, struct el **elem) xref = txt_layout_xref(o->p.lay, x - o->x, y - o->y); else if (type == elt_box) xref = txt_box_xref(o->p.box, x - o->x, y - o->y); +#ifdef ANDROID + if (!xref) { + int xc, yc, r; + xref = get_nearest_xref(o->id, x, y); + if (!xref) + return NULL; + r = fnt_height(txt_layout_font(xref_layout(xref))) * 2; /* radius is here */ + if (!xref_position(xref, &xc, &yc)) { + if (o->type == elt_box && yc) + yc -= txt_box_off(el_box(o->id)); + xc += o->x; + yc += o->y; + if (((x - xc)*(x - xc) + (y - yc)*(y - yc)) < (r * r)) + return xref; + } + return NULL; + } +#endif return xref; } @@ -2128,7 +2148,6 @@ static int select_ref(int prev, int last); static xref_t get_xref(int i, int last); static void xref_jump(xref_t xref, struct el* elem); -static xref_t get_nearest_xref(int i, int mx, int my); static void select_frame(int prev) { diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c index e5bd193..0ce4afe 100644 --- a/src/sdl-instead/graphics.c +++ b/src/sdl-instead/graphics.c @@ -2176,6 +2176,12 @@ static void word_render(struct layout *layout, struct word *word, int x, int y) gfx_draw(s, x, y); } +fnt_t txt_layout_font(layout_t lay) +{ + struct layout *layout = lay; + return layout->fn; +} + static int vertical_align(struct word *w, int *hh) { int h; diff --git a/src/sdl-instead/graphics.h b/src/sdl-instead/graphics.h index 36bdeaf..0b0b002 100644 --- a/src/sdl-instead/graphics.h +++ b/src/sdl-instead/graphics.h @@ -102,6 +102,8 @@ extern void txt_layout_draw(layout_t lay, int x, int y); extern void txt_layout_free(layout_t lay); extern xref_t txt_layout_xref(layout_t lay, int x, int y); extern void txt_layout_color(layout_t lay, color_t fg); +extern fnt_t txt_layout_font(layout_t lay); + extern void txt_layout_link_color(layout_t lay, color_t link); extern void txt_layout_active_color(layout_t lay, color_t link); extern void txt_layout_link_style(layout_t lay, int style);