1 /* aNetHack 0.0.1 gnworn.c 2009/05/06 10:58:06 1.3 */
3 * $ANH-Date: 1432512804 2015/05/25 00:13:24 $ $ANH-Branch: master $:$ANH-Revision: 1.10 $
5 /* Copyright (C) 2002, Dylan Alex Simon */
6 /* aNetHack may be freely redistributed. See license for details. */
16 #define WORN_OBJECT_LIST /* struct obj *[WORN_HEIGHT][WORN_WIDTH] = */ \
19 uquiver, uarmh, u.twoweap ? NULL : uswapwep \
21 , { u.twoweap ? uswapwep : NULL, ublindf, uwep }, \
22 { uleft, uamul, uright }, { uarms, uarmc, uarmg }, \
23 { uarmu, uarm, uskin }, \
25 uball, uarmf, uchain \
29 static GtkWidget
*worn_contents
[WORN_HEIGHT
][WORN_WIDTH
];
30 static struct obj
*last_worn_objects
[WORN_HEIGHT
][WORN_WIDTH
];
32 GdkImlibImage
*image_of_worn_object(struct obj
*o
);
33 void ghack_worn_display(GtkWidget
*win
, boolean block
, gpointer data
);
36 ghack_init_worn_window()
40 GtkWidget
*tablealign
;
44 top
= gtk_vbox_new(FALSE
, 2);
46 table
= gtk_table_new(WORN_HEIGHT
, WORN_WIDTH
, TRUE
);
47 for (i
= 0; i
< WORN_HEIGHT
; i
++) {
48 for (j
= 0; j
< WORN_WIDTH
; j
++) {
50 gnome_pixmap_new_from_imlib(image_of_worn_object(NULL
));
51 last_worn_objects
[i
][j
] = NULL
; /* a pointer that will never be */
52 gtk_table_attach(GTK_TABLE(table
),
53 GTK_WIDGET(worn_contents
[i
][j
]), j
, j
+ 1, i
,
57 tablealign
= gtk_alignment_new(0.5, 0.0, 0.0, 1.0);
58 gtk_box_pack_start(GTK_BOX(top
), tablealign
, FALSE
, FALSE
, 0);
59 gtk_container_add(GTK_CONTAINER(tablealign
), table
);
61 label
= gtk_label_new("Equipment");
62 gtk_label_set_justify(GTK_LABEL(label
), GTK_JUSTIFY_CENTER
);
63 gtk_box_pack_start(GTK_BOX(top
), label
, FALSE
, FALSE
, 0);
65 gtk_signal_connect(GTK_OBJECT(top
), "ghack_display",
66 GTK_SIGNAL_FUNC(ghack_worn_display
), NULL
);
72 image_of_worn_object(struct obj
*o
)
78 glyph
= obj_to_glyph(o
);
80 glyph
= cmap_to_glyph(S_stone
);
82 im
= ghack_image_from_glyph(glyph
, FALSE
);
88 ghack_worn_display(GtkWidget
*win
, boolean block
, gpointer data
)
91 struct obj
*worn_objects
[WORN_HEIGHT
][WORN_WIDTH
] = WORN_OBJECT_LIST
;
93 for (i
= 0; i
< WORN_HEIGHT
; i
++) {
94 for (j
= 0; j
< WORN_WIDTH
; j
++) {
95 if (worn_objects
[i
][j
] != last_worn_objects
[i
][j
]) {
96 last_worn_objects
[i
][j
] = worn_objects
[i
][j
];
97 gnome_pixmap_load_imlib(
98 GNOME_PIXMAP(worn_contents
[i
][j
]),
99 image_of_worn_object(worn_objects
[i
][j
]));