1 /* SCCS Id: @(#)gnbind.c 3.4 2002/04/15 */
2 /* Copyright (C) 2002, Dylan Alex Simon */
3 /* NetHack may be freely redistributed. See license for details. */
14 #define WORN_OBJECT_LIST /* struct obj *[WORN_HEIGHT][WORN_WIDTH] = */ { \
15 { uquiver, uarmh, u.twoweap ? NULL : uswapwep }, \
16 { u.twoweap ? uswapwep : NULL, ublindf, uwep }, \
17 { uleft, uamul, uright }, \
18 { uarms, uarmc, uarmg }, \
19 { uarmu, uarm, uskin }, \
20 { uball, uarmf, uchain } \
23 #define WORN_OBJECT_LIST /* struct obj *[WORN_HEIGHT][WORN_WIDTH] = */ { \
24 { uquiver, uarmh, u.twoweap ? NULL : uswapwep }, \
25 { u.twoweap ? uswapwep : NULL, ublindf, uwep }, \
26 { uleft, uamul, uright }, \
27 { uarms, uarmc, uarmg }, \
28 { NULL, uarm, uskin }, \
29 { uball, uarmf, uchain } \
33 static GtkWidget *worn_contents[WORN_HEIGHT][WORN_WIDTH];
34 static struct obj *last_worn_objects[WORN_HEIGHT][WORN_WIDTH];
36 GdkImlibImage *image_of_worn_object(struct obj *o);
37 void ghack_worn_display(GtkWidget *win, boolean block, gpointer data);
40 ghack_init_worn_window()
44 GtkWidget *tablealign;
48 top = gtk_vbox_new(FALSE, 2);
50 table = gtk_table_new(WORN_HEIGHT, WORN_WIDTH, TRUE);
51 for (i = 0; i < WORN_HEIGHT; i++) {
52 for (j = 0; j < WORN_WIDTH; j++) {
54 gnome_pixmap_new_from_imlib(image_of_worn_object(NULL));
55 last_worn_objects[i][j] = NULL; /* a pointer that will never be */
56 gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(worn_contents[i][j]),
57 j, j+1, i, i+1, 0, 0, 0, 0);
60 tablealign = gtk_alignment_new(0.5, 0.0, 0.0, 1.0);
61 gtk_box_pack_start(GTK_BOX(top), tablealign, FALSE, FALSE, 0);
62 gtk_container_add(GTK_CONTAINER(tablealign), table);
64 label = gtk_label_new("Equipment");
65 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
66 gtk_box_pack_start(GTK_BOX(top), label, FALSE, FALSE, 0);
68 gtk_signal_connect(GTK_OBJECT(top), "ghack_display",
69 GTK_SIGNAL_FUNC(ghack_worn_display), NULL);
75 image_of_worn_object(struct obj *o)
81 glyph = obj_to_glyph(o);
83 glyph = cmap_to_glyph(S_stone);
85 im = ghack_image_from_glyph(glyph, FALSE);
91 ghack_worn_display(GtkWidget *win, boolean block, gpointer data)
94 struct obj *worn_objects[WORN_HEIGHT][WORN_WIDTH] = WORN_OBJECT_LIST;
96 for (i = 0; i < WORN_HEIGHT; i++) {
97 for (j = 0; j < WORN_WIDTH; j++) {
98 if (worn_objects[i][j] != last_worn_objects[i][j]) {
99 last_worn_objects[i][j] = worn_objects[i][j];
100 gnome_pixmap_load_imlib(GNOME_PIXMAP(worn_contents[i][j]),
101 image_of_worn_object(worn_objects[i][j]));