| 284 | } |
| 285 | |
| 286 | void |
| 287 | ghack_map_cursor_to(GtkWidget *win, int x, int y, gpointer data) |
| 288 | { |
| 289 | GnomeCanvasGroup *group; |
| 290 | static GnomeCanvasRE *cursor = NULL; |
| 291 | |
| 292 | double x1, y1, x2, y2; |
| 293 | float hp; |
| 294 | guint r, g, b; |
| 295 | |
| 296 | x1 = x * ghack_glyph_width() - 1; |
| 297 | y1 = y * ghack_glyph_height() - 1; |
| 298 | x2 = x1 + ghack_glyph_width() + 2; |
| 299 | y2 = y1 + ghack_glyph_height() + 2; |
| 300 | hp = u.mtimedone ? (u.mhmax ? (float) u.mh / u.mhmax : 1) |
| 301 | : (u.uhpmax ? (float) u.uhp / u.uhpmax : 1); |
| 302 | |
| 303 | r = 255; |
| 304 | g = (hp >= 0.75) ? 255 : (hp >= 0.25 ? 255 * 2 * (hp - 0.25) : 0); |
| 305 | b = (hp >= 0.75) ? 255 * 4 * (hp - 0.75) |
| 306 | : (hp >= 0.25 ? 0 : 255 * 4 * (0.25 - hp)); |
| 307 | |
| 308 | group = gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas)); |
| 309 | |
| 310 | if (!cursor) { |
| 311 | cursor = GNOME_CANVAS_RE(gnome_canvas_item_new( |
| 312 | group, gnome_canvas_rect_get_type(), "width_units", 1.0, NULL)); |
| 313 | } |
| 314 | gnome_canvas_item_set(GNOME_CANVAS_ITEM(cursor), "outline_color_rgba", |
| 315 | GNOME_CANVAS_COLOR(r, g, b), "x1", x1, "y1", y1, |
| 316 | "x2", x2, "y2", y2, NULL); |
| 317 | |
| 318 | gnome_canvas_item_raise_to_top(GNOME_CANVAS_ITEM(cursor)); |
| 319 | gnome_canvas_item_show(GNOME_CANVAS_ITEM(cursor)); |
| 320 | } |
| 321 | |
| 322 | void |
| 323 | ghack_map_putstr(GtkWidget *win, int attr, const char *text, gpointer data) |
no test coverage detected