1 /* aNetHack 0.0.1 gnstatus.c $ANH-Date: 1432512806 2015/05/25 00:13:26 $ $ANH-Branch: master $:$ANH-Revision: 1.15 $ */
2 /* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
3 /* aNetHack may be freely redistributed. See license for details. */
10 extern const char *hu_stat
[]; /* from eat.c */
11 extern const char *enc_stat
[]; /* from botl.c */
13 void ghack_status_window_update_stats();
14 void ghack_status_window_clear(GtkWidget
*win
, gpointer data
);
15 void ghack_status_window_destroy(GtkWidget
*win
, gpointer data
);
16 void ghack_status_window_display(GtkWidget
*win
, boolean block
,
18 void ghack_status_window_cursor_to(GtkWidget
*win
, int x
, int y
,
20 void ghack_status_window_put_string(GtkWidget
*win
, int attr
,
21 const char *text
, gpointer data
);
23 static void ghack_fade_highlighting();
24 static void ghack_highlight_widget(GtkWidget
*widget
, GtkStyle
*oldStyle
,
27 /* some junk to handle when to fade the highlighting */
28 #define NUM_TURNS_HIGHLIGHTED 3
30 static GList
*s_HighLightList
;
38 /* Ok, now for a LONG list of widgets... */
39 static GtkWidget
*statTable
= NULL
;
40 static GtkWidget
*titleLabel
= NULL
;
41 static GtkWidget
*dgnLevelLabel
= NULL
;
42 static GtkWidget
*strPix
= NULL
;
43 static GtkWidget
*strLabel
= NULL
;
44 static GtkWidget
*dexPix
= NULL
;
45 static GtkWidget
*dexLabel
= NULL
;
46 static GtkWidget
*intPix
= NULL
;
47 static GtkWidget
*intLabel
= NULL
;
48 static GtkWidget
*wisPix
= NULL
;
49 static GtkWidget
*wisLabel
= NULL
;
50 static GtkWidget
*conPix
= NULL
;
51 static GtkWidget
*conLabel
= NULL
;
52 static GtkWidget
*chaPix
= NULL
;
53 static GtkWidget
*chaLabel
= NULL
;
54 static GtkWidget
*goldLabel
= NULL
;
55 static GtkWidget
*hpLabel
= NULL
;
56 static GtkWidget
*powLabel
= NULL
;
57 static GtkWidget
*acLabel
= NULL
;
58 static GtkWidget
*levlLabel
= NULL
;
59 static GtkWidget
*expLabel
= NULL
;
60 static GtkWidget
*timeLabel
= NULL
;
61 static GtkWidget
*scoreLabel
= NULL
;
62 static GtkWidget
*alignPix
= NULL
;
63 static GtkWidget
*alignLabel
= NULL
;
64 static GtkWidget
*hungerPix
= NULL
;
65 static GtkWidget
*hungerLabel
= NULL
;
66 static GtkWidget
*sickPix
= NULL
;
67 static GtkWidget
*sickLabel
= NULL
;
68 static GtkWidget
*blindPix
= NULL
;
69 static GtkWidget
*blindLabel
= NULL
;
70 static GtkWidget
*stunPix
= NULL
;
71 static GtkWidget
*stunLabel
= NULL
;
72 static GtkWidget
*halluPix
= NULL
;
73 static GtkWidget
*halluLabel
= NULL
;
74 static GtkWidget
*confuPix
= NULL
;
75 static GtkWidget
*confuLabel
= NULL
;
76 static GtkWidget
*encumbPix
= NULL
;
77 static GtkWidget
*encumbLabel
= NULL
;
79 static GtkStyle
*normalStyle
= NULL
;
80 static GtkStyle
*bigStyle
= NULL
;
81 static GtkStyle
*redStyle
= NULL
;
82 static GtkStyle
*greenStyle
= NULL
;
83 static GtkStyle
*bigRedStyle
= NULL
;
84 static GtkStyle
*bigGreenStyle
= NULL
;
87 static GdkColor color_red
= { 0, 0xff00, 0, 0 };
88 /* ForestGreen (looks better than just pure green) */
89 static GdkColor color_green
= { 0, 0x2200, 0x8b00, 0x2200 };
101 static int lastLevel
;
106 static aligntyp lastAlignment
;
107 static unsigned lastHungr
;
108 static long lastConf
;
109 static long lastBlind
;
110 static long lastStun
;
111 static long lastHalu
;
112 static long lastSick
;
113 static int lastEncumb
;
116 ghack_status_window_clear(GtkWidget
*win
, gpointer data
)
118 /* Don't think we need this at all */
122 ghack_status_window_destroy(GtkWidget
*win
, gpointer data
)
124 while (s_HighLightList
) {
125 g_free((Highlight
*) s_HighLightList
->data
);
126 s_HighLightList
= s_HighLightList
->next
;
128 g_list_free(s_HighLightList
);
132 ghack_status_window_display(GtkWidget
*win
, boolean block
, gpointer data
)
134 gtk_widget_show_all(GTK_WIDGET(win
));
138 ghack_status_window_cursor_to(GtkWidget
*win
, int x
, int y
, gpointer data
)
140 /* Don't think we need this at all */
144 ghack_status_window_put_string(GtkWidget
*win
, int attr
, const char *text
,
147 ghack_status_window_update_stats();
151 ghack_init_status_window()
153 GtkWidget
*horizSep0
, *horizSep1
, *horizSep2
, *horizSep3
;
154 GtkWidget
*statsHBox
, *strVBox
, *dexVBox
, *intVBox
, *statHBox
;
155 GtkWidget
*wisVBox
, *conVBox
, *chaVBox
;
156 GtkWidget
*alignVBox
, *hungerVBox
, *sickVBox
, *blindVBox
;
157 GtkWidget
*stunVBox
, *halluVBox
, *confuVBox
, *encumbVBox
;
159 /* Set up a (ridiculous) initial state */
175 lastAlignment
= A_NEUTRAL
; /* start off guessing neutral */
184 statTable
= gtk_table_new(10, 8, FALSE
);
185 gtk_table_set_row_spacings(GTK_TABLE(statTable
), 1);
186 gtk_table_set_col_spacings(GTK_TABLE(statTable
), 1);
188 /* Begin the first row of the table -- the title */
189 titleLabel
= gtk_label_new(_("GnomeHack!"));
190 gtk_table_attach(GTK_TABLE(statTable
), titleLabel
, 0, 8, 0, 1, GTK_FILL
,
194 gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(titleLabel
)));
196 /* Set up some styles to draw stuff with */
198 g_assert(greenStyle
== NULL
);
199 g_assert(bigStyle
== NULL
);
200 g_assert(bigRedStyle
== NULL
);
201 g_assert(bigGreenStyle
== NULL
);
203 greenStyle
= gtk_style_copy(normalStyle
);
204 redStyle
= gtk_style_copy(normalStyle
);
205 bigRedStyle
= gtk_style_copy(normalStyle
);
206 bigGreenStyle
= gtk_style_copy(normalStyle
);
207 bigStyle
= gtk_style_copy(normalStyle
);
209 greenStyle
->fg
[GTK_STATE_NORMAL
] = color_green
;
210 redStyle
->fg
[GTK_STATE_NORMAL
] = color_red
;
211 bigRedStyle
->fg
[GTK_STATE_NORMAL
] = color_red
;
212 bigGreenStyle
->fg
[GTK_STATE_NORMAL
] = color_green
;
214 gdk_font_unref(bigRedStyle
->font
);
215 gdk_font_unref(bigGreenStyle
->font
);
217 gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
218 bigGreenStyle
->font
=
219 gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
221 gdk_font_unref(bigStyle
->font
);
223 gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
225 gtk_widget_set_style(GTK_WIDGET(titleLabel
), bigStyle
);
227 /* Begin the second row */
228 dgnLevelLabel
= gtk_label_new(_("Nethack for Gnome"));
229 gtk_table_attach(GTK_TABLE(statTable
), dgnLevelLabel
, 0, 8, 1, 2,
231 gtk_widget_set_style(GTK_WIDGET(dgnLevelLabel
), bigStyle
);
233 /* Begin the third row */
234 horizSep0
= gtk_hseparator_new();
235 gtk_table_attach(GTK_TABLE(statTable
), horizSep0
, 0, 8, 2, 3, GTK_FILL
,
238 /* Begin the fourth row */
239 statsHBox
= gtk_hbox_new(TRUE
, 0);
241 strVBox
= gtk_vbox_new(FALSE
, 0);
242 strPix
= gnome_pixmap_new_from_xpm_d(str_xpm
);
243 strLabel
= gtk_label_new("STR: ");
244 gtk_box_pack_start(GTK_BOX(strVBox
), strPix
, TRUE
, TRUE
, 2);
245 gtk_box_pack_start(GTK_BOX(strVBox
), strLabel
, TRUE
, TRUE
, 2);
246 gtk_box_pack_start(GTK_BOX(statsHBox
), GTK_WIDGET(strVBox
), TRUE
, TRUE
,
249 dexVBox
= gtk_vbox_new(FALSE
, 0);
250 dexPix
= gnome_pixmap_new_from_xpm_d(dex_xpm
);
251 dexLabel
= gtk_label_new("DEX: ");
252 gtk_box_pack_start(GTK_BOX(dexVBox
), dexPix
, TRUE
, TRUE
, 2);
253 gtk_box_pack_start(GTK_BOX(dexVBox
), dexLabel
, TRUE
, TRUE
, 2);
254 gtk_box_pack_start(GTK_BOX(statsHBox
), GTK_WIDGET(dexVBox
), TRUE
, TRUE
,
257 conVBox
= gtk_vbox_new(FALSE
, 0);
258 conPix
= gnome_pixmap_new_from_xpm_d(cns_xpm
);
259 conLabel
= gtk_label_new("CON: ");
260 gtk_box_pack_start(GTK_BOX(conVBox
), conPix
, TRUE
, TRUE
, 2);
261 gtk_box_pack_start(GTK_BOX(conVBox
), conLabel
, TRUE
, TRUE
, 2);
262 gtk_box_pack_start(GTK_BOX(statsHBox
), GTK_WIDGET(conVBox
), TRUE
, TRUE
,
265 intVBox
= gtk_vbox_new(FALSE
, 0);
266 intPix
= gnome_pixmap_new_from_xpm_d(int_xpm
);
267 intLabel
= gtk_label_new("INT: ");
268 gtk_box_pack_start(GTK_BOX(intVBox
), intPix
, TRUE
, TRUE
, 2);
269 gtk_box_pack_start(GTK_BOX(intVBox
), intLabel
, TRUE
, TRUE
, 2);
270 gtk_box_pack_start(GTK_BOX(statsHBox
), GTK_WIDGET(intVBox
), TRUE
, TRUE
,
273 wisVBox
= gtk_vbox_new(FALSE
, 0);
274 wisPix
= gnome_pixmap_new_from_xpm_d(wis_xpm
);
275 wisLabel
= gtk_label_new("WIS: ");
276 gtk_box_pack_start(GTK_BOX(wisVBox
), wisPix
, TRUE
, TRUE
, 2);
277 gtk_box_pack_start(GTK_BOX(wisVBox
), wisLabel
, TRUE
, TRUE
, 2);
278 gtk_box_pack_start(GTK_BOX(statsHBox
), GTK_WIDGET(wisVBox
), TRUE
, TRUE
,
281 chaVBox
= gtk_vbox_new(FALSE
, 0);
282 chaPix
= gnome_pixmap_new_from_xpm_d(cha_xpm
);
283 chaLabel
= gtk_label_new("CHA: ");
284 gtk_box_pack_start(GTK_BOX(chaVBox
), chaPix
, TRUE
, TRUE
, 2);
285 gtk_box_pack_start(GTK_BOX(chaVBox
), chaLabel
, TRUE
, TRUE
, 2);
286 gtk_box_pack_start(GTK_BOX(statsHBox
), GTK_WIDGET(chaVBox
), TRUE
, TRUE
,
289 gtk_table_attach(GTK_TABLE(statTable
), GTK_WIDGET(statsHBox
), 0, 8, 3, 4,
292 /* Begin the fifth row */
293 horizSep1
= gtk_hseparator_new();
294 gtk_table_attach(GTK_TABLE(statTable
), horizSep1
, 0, 8, 4, 5, GTK_FILL
,
297 /* Begin the sixth row */
298 hpLabel
= gtk_label_new("HP: ");
299 gtk_table_attach(GTK_TABLE(statTable
), hpLabel
, 0, 1, 5, 6, GTK_FILL
, 0,
302 acLabel
= gtk_label_new("AC: ");
303 gtk_table_attach(GTK_TABLE(statTable
), acLabel
, 2, 3, 5, 6, GTK_FILL
, 0,
306 powLabel
= gtk_label_new("Power: ");
307 gtk_table_attach(GTK_TABLE(statTable
), powLabel
, 4, 5, 5, 6, GTK_FILL
, 0,
310 goldLabel
= gtk_label_new("Au: ");
311 gtk_table_attach(GTK_TABLE(statTable
), goldLabel
, 6, 7, 5, 6, GTK_FILL
, 0,
314 /* Begin the seventh row */
315 horizSep2
= gtk_hseparator_new();
316 gtk_table_attach(GTK_TABLE(statTable
), horizSep2
, 0, 8, 6, 7, GTK_FILL
,
319 /* Begin the eigth row */
320 levlLabel
= gtk_label_new("Level: ");
321 gtk_table_attach(GTK_TABLE(statTable
), levlLabel
, 0, 1, 7, 8, GTK_FILL
, 0,
324 expLabel
= gtk_label_new("Exp: ");
325 gtk_table_attach(GTK_TABLE(statTable
), expLabel
, 2, 3, 7, 8, GTK_FILL
, 0,
328 timeLabel
= gtk_label_new("Time: ");
329 gtk_table_attach(GTK_TABLE(statTable
), timeLabel
, 4, 5, 7, 8, GTK_FILL
, 0,
332 scoreLabel
= gtk_label_new("Score: ");
333 gtk_table_attach(GTK_TABLE(statTable
), scoreLabel
, 6, 7, 7, 8, GTK_FILL
,
336 /* Begin the ninth row */
337 horizSep3
= gtk_hseparator_new();
338 gtk_table_attach(GTK_TABLE(statTable
), horizSep3
, 0, 8, 8, 9, GTK_FILL
,
341 /* Begin the tenth and last row */
342 statHBox
= gtk_hbox_new(FALSE
, 0);
344 alignVBox
= gtk_vbox_new(FALSE
, 0);
345 alignPix
= gnome_pixmap_new_from_xpm_d(neutral_xpm
);
346 alignLabel
= gtk_label_new("Neutral");
347 gtk_box_pack_start(GTK_BOX(alignVBox
), alignPix
, TRUE
, TRUE
, 2);
348 gtk_box_pack_start(GTK_BOX(alignVBox
), alignLabel
, TRUE
, TRUE
, 2);
349 gtk_box_pack_start(GTK_BOX(statHBox
), GTK_WIDGET(alignVBox
), TRUE
, FALSE
,
352 hungerVBox
= gtk_vbox_new(FALSE
, 0);
353 hungerPix
= gnome_pixmap_new_from_xpm_d(hungry_xpm
);
354 hungerLabel
= gtk_label_new("Hungry");
355 gtk_box_pack_start(GTK_BOX(hungerVBox
), hungerPix
, TRUE
, TRUE
, 2);
356 gtk_box_pack_start(GTK_BOX(hungerVBox
), hungerLabel
, TRUE
, TRUE
, 2);
357 gtk_box_pack_start(GTK_BOX(statHBox
), GTK_WIDGET(hungerVBox
), TRUE
, FALSE
,
360 sickVBox
= gtk_vbox_new(FALSE
, 0);
361 sickPix
= gnome_pixmap_new_from_xpm_d(sick_fp_xpm
);
362 sickLabel
= gtk_label_new("FoodPois");
363 gtk_box_pack_start(GTK_BOX(sickVBox
), sickPix
, TRUE
, TRUE
, 2);
364 gtk_box_pack_start(GTK_BOX(sickVBox
), sickLabel
, TRUE
, TRUE
, 2);
365 gtk_box_pack_start(GTK_BOX(statHBox
), GTK_WIDGET(sickVBox
), TRUE
, FALSE
,
368 blindVBox
= gtk_vbox_new(FALSE
, 0);
369 blindPix
= gnome_pixmap_new_from_xpm_d(blind_xpm
);
370 blindLabel
= gtk_label_new("Blind");
371 gtk_box_pack_start(GTK_BOX(blindVBox
), blindPix
, TRUE
, TRUE
, 2);
372 gtk_box_pack_start(GTK_BOX(blindVBox
), blindLabel
, TRUE
, TRUE
, 2);
373 gtk_box_pack_start(GTK_BOX(statHBox
), GTK_WIDGET(blindVBox
), TRUE
, FALSE
,
376 stunVBox
= gtk_vbox_new(FALSE
, 0);
377 stunPix
= gnome_pixmap_new_from_xpm_d(stunned_xpm
);
378 stunLabel
= gtk_label_new("Stun");
379 gtk_box_pack_start(GTK_BOX(stunVBox
), stunPix
, TRUE
, TRUE
, 2);
380 gtk_box_pack_start(GTK_BOX(stunVBox
), stunLabel
, TRUE
, TRUE
, 2);
381 gtk_box_pack_start(GTK_BOX(statHBox
), GTK_WIDGET(stunVBox
), TRUE
, FALSE
,
384 confuVBox
= gtk_vbox_new(FALSE
, 0);
385 confuPix
= gnome_pixmap_new_from_xpm_d(confused_xpm
);
386 confuLabel
= gtk_label_new("Confused");
387 gtk_box_pack_start(GTK_BOX(confuVBox
), confuPix
, TRUE
, TRUE
, 2);
388 gtk_box_pack_start(GTK_BOX(confuVBox
), confuLabel
, TRUE
, TRUE
, 2);
389 gtk_box_pack_start(GTK_BOX(statHBox
), GTK_WIDGET(confuVBox
), TRUE
, FALSE
,
392 halluVBox
= gtk_vbox_new(FALSE
, 0);
393 halluPix
= gnome_pixmap_new_from_xpm_d(hallu_xpm
);
394 halluLabel
= gtk_label_new("Hallu");
395 gtk_box_pack_start(GTK_BOX(halluVBox
), halluPix
, TRUE
, TRUE
, 2);
396 gtk_box_pack_start(GTK_BOX(halluVBox
), halluLabel
, TRUE
, TRUE
, 2);
397 gtk_box_pack_start(GTK_BOX(statHBox
), GTK_WIDGET(halluVBox
), TRUE
, FALSE
,
400 encumbVBox
= gtk_vbox_new(FALSE
, 0);
401 encumbPix
= gnome_pixmap_new_from_xpm_d(slt_enc_xpm
);
402 encumbLabel
= gtk_label_new("Burdened");
403 gtk_box_pack_start(GTK_BOX(encumbVBox
), encumbPix
, TRUE
, TRUE
, 2);
404 gtk_box_pack_start(GTK_BOX(encumbVBox
), encumbLabel
, TRUE
, TRUE
, 2);
405 gtk_box_pack_start(GTK_BOX(statHBox
), GTK_WIDGET(encumbVBox
), TRUE
, FALSE
,
408 gtk_table_attach(GTK_TABLE(statTable
), GTK_WIDGET(statHBox
), 0, 8, 9, 10,
409 GTK_FILL
, GTK_FILL
, 0, 0);
411 /* Set up the necessary signals */
412 gtk_signal_connect(GTK_OBJECT(statTable
), "ghack_fade_highlight",
413 GTK_SIGNAL_FUNC(ghack_fade_highlighting
), NULL
);
415 gtk_signal_connect(GTK_OBJECT(statTable
), "ghack_putstr",
416 GTK_SIGNAL_FUNC(ghack_status_window_put_string
), NULL
);
418 gtk_signal_connect(GTK_OBJECT(statTable
), "ghack_clear",
419 GTK_SIGNAL_FUNC(ghack_status_window_clear
), NULL
);
421 gtk_signal_connect(GTK_OBJECT(statTable
), "ghack_curs",
422 GTK_SIGNAL_FUNC(ghack_status_window_cursor_to
), NULL
);
423 gtk_signal_connect(GTK_OBJECT(statTable
), "gnome_delay_output",
424 GTK_SIGNAL_FUNC(ghack_delay
), NULL
);
426 /* Lastly, show the status window and everything in it */
427 gtk_widget_show_all(statTable
);
429 return GTK_WIDGET(statTable
);
433 ghack_status_window_update_stats()
439 static int firstTime
= TRUE
;
442 /* First, fill in the player name and the dungeon level */
444 if ('a' <= buf
[0] && buf
[0] <= 'z')
446 strcat(buf
, " the ");
451 strcpy(mname
, mons
[u
.umonnum
].mname
);
452 while (mname
[k
] != 0) {
453 if ((k
== 0 || (k
> 0 && mname
[k
- 1] == ' ')) && 'a' <= mname
[k
]
454 && mname
[k
] <= 'z') {
455 mname
[k
] += 'A' - 'a';
461 strcat(buf
, rank_of(u
.ulevel
, pl_character
[0], flags
.female
));
463 gtk_label_get(GTK_LABEL(titleLabel
), &buf1
);
464 if (strcmp(buf1
, buf
) != 0 && firstTime
== FALSE
) {
465 /* Ok, this changed so add it to the highlighing list */
466 ghack_highlight_widget(titleLabel
, bigStyle
, bigGreenStyle
);
468 gtk_label_set(GTK_LABEL(titleLabel
), buf
);
470 if (In_endgame(&u
.uz
)) {
471 strcpy(buf
, (Is_astralevel(&u
.uz
) ? "Astral Plane" : "End Game"));
473 sprintf(buf
, "%s, level %d", dungeons
[u
.uz
.dnum
].dname
, depth(&u
.uz
));
475 if (lastDepth
> depth(&u
.uz
) && firstTime
== FALSE
) {
476 /* Ok, this changed so add it to the highlighing list */
477 ghack_highlight_widget(dgnLevelLabel
, bigStyle
, bigRedStyle
);
478 } else if (lastDepth
< depth(&u
.uz
) && firstTime
== FALSE
) {
479 /* Ok, this changed so add it to the highlighing list */
480 ghack_highlight_widget(dgnLevelLabel
, bigStyle
, bigGreenStyle
);
482 lastDepth
= depth(&u
.uz
);
483 gtk_label_set(GTK_LABEL(dgnLevelLabel
), buf
);
485 /* Next, fill in the player's stats */
486 if (ACURR(A_STR
) > 118) {
487 sprintf(buf
, "STR:%d", ACURR(A_STR
) - 100);
488 } else if (ACURR(A_STR
) == 118) {
489 sprintf(buf
, "STR:18/**");
490 } else if (ACURR(A_STR
) > 18) {
491 sprintf(buf
, "STR:18/%02d", ACURR(A_STR
) - 18);
493 sprintf(buf
, "STR:%d", ACURR(A_STR
));
495 if (lastStr
< ACURR(A_STR
) && firstTime
== FALSE
) {
496 /* Ok, this changed so add it to the highlighing list */
497 ghack_highlight_widget(strLabel
, normalStyle
, greenStyle
);
498 } else if (lastStr
> ACURR(A_STR
) && firstTime
== FALSE
) {
499 /* Ok, this changed so add it to the highlighing list */
500 ghack_highlight_widget(strLabel
, normalStyle
, redStyle
);
502 lastStr
= ACURR(A_STR
);
503 gtk_label_set(GTK_LABEL(strLabel
), buf
);
505 sprintf(buf
, "INT:%d", ACURR(A_INT
));
506 if (lastInt
< ACURR(A_INT
) && firstTime
== FALSE
) {
507 /* Ok, this changed so add it to the highlighing list */
508 ghack_highlight_widget(intLabel
, normalStyle
, greenStyle
);
509 } else if (lastInt
> ACURR(A_INT
) && firstTime
== FALSE
) {
510 /* Ok, this changed so add it to the highlighing list */
511 ghack_highlight_widget(intLabel
, normalStyle
, redStyle
);
513 lastInt
= ACURR(A_INT
);
514 gtk_label_set(GTK_LABEL(intLabel
), buf
);
516 sprintf(buf
, "WIS:%d", ACURR(A_WIS
));
517 if (lastWis
< ACURR(A_WIS
) && firstTime
== FALSE
) {
518 /* Ok, this changed so add it to the highlighing list */
519 ghack_highlight_widget(wisLabel
, normalStyle
, greenStyle
);
520 } else if (lastWis
> ACURR(A_WIS
) && firstTime
== FALSE
) {
521 /* Ok, this changed so add it to the highlighing list */
522 ghack_highlight_widget(wisLabel
, normalStyle
, redStyle
);
524 lastWis
= ACURR(A_WIS
);
525 gtk_label_set(GTK_LABEL(wisLabel
), buf
);
527 sprintf(buf
, "DEX:%d", ACURR(A_DEX
));
528 if (lastDex
< ACURR(A_DEX
) && firstTime
== FALSE
) {
529 /* Ok, this changed so add it to the highlighing list */
530 ghack_highlight_widget(dexLabel
, normalStyle
, greenStyle
);
531 } else if (lastDex
> ACURR(A_DEX
) && firstTime
== FALSE
) {
532 /* Ok, this changed so add it to the highlighing list */
533 ghack_highlight_widget(dexLabel
, normalStyle
, redStyle
);
535 lastDex
= ACURR(A_DEX
);
536 gtk_label_set(GTK_LABEL(dexLabel
), buf
);
538 sprintf(buf
, "CON:%d", ACURR(A_CON
));
539 if (lastCon
< ACURR(A_CON
) && firstTime
== FALSE
) {
540 /* Ok, this changed so add it to the highlighing list */
541 ghack_highlight_widget(conLabel
, normalStyle
, greenStyle
);
542 } else if (lastCon
> ACURR(A_CON
) && firstTime
== FALSE
) {
543 /* Ok, this changed so add it to the highlighing list */
544 ghack_highlight_widget(conLabel
, normalStyle
, redStyle
);
546 lastCon
= ACURR(A_CON
);
547 gtk_label_set(GTK_LABEL(conLabel
), buf
);
549 sprintf(buf
, "CHA:%d", ACURR(A_CHA
));
550 if (lastCha
< ACURR(A_CHA
) && firstTime
== FALSE
) {
551 /* Ok, this changed so add it to the highlighing list */
552 ghack_highlight_widget(chaLabel
, normalStyle
, greenStyle
);
553 } else if (lastCha
> ACURR(A_CHA
) && firstTime
== FALSE
) {
554 /* Ok, this changed so add it to the highlighing list */
555 ghack_highlight_widget(chaLabel
, normalStyle
, redStyle
);
557 lastCha
= ACURR(A_CHA
);
558 gtk_label_set(GTK_LABEL(chaLabel
), buf
);
560 /* Now do the non-pixmaped stats (gold and such) */
561 umoney
= money_cnt(invent
);
562 sprintf(buf
, "Au:%ld", umoney
);
563 if (lastAu
< umoney
&& firstTime
== FALSE
) {
564 /* Ok, this changed so add it to the highlighing list */
565 ghack_highlight_widget(goldLabel
, normalStyle
, greenStyle
);
566 } else if (lastAu
> umoney
&& firstTime
== FALSE
) {
567 /* Ok, this changed so add it to the highlighing list */
568 ghack_highlight_widget(goldLabel
, normalStyle
, redStyle
);
571 gtk_label_set(GTK_LABEL(goldLabel
), buf
);
574 /* special case: when polymorphed, show "HD", disable exp */
575 sprintf(buf
, "HP:%d/%d", ((u
.mh
> 0) ? u
.mh
: 0), u
.mhmax
);
576 if ((lastHP
< u
.mh
|| lastMHP
< u
.mhmax
) && firstTime
== FALSE
) {
577 /* Ok, this changed so add it to the highlighing list */
578 ghack_highlight_widget(hpLabel
, normalStyle
, greenStyle
);
579 } else if ((lastHP
> u
.mh
|| lastMHP
> u
.mhmax
)
580 && firstTime
== FALSE
) {
581 /* Ok, this changed so add it to the highlighing list */
582 ghack_highlight_widget(hpLabel
, normalStyle
, redStyle
);
587 sprintf(buf
, "HP:%d/%d", ((u
.uhp
> 0) ? u
.uhp
: 0), u
.uhpmax
);
588 if ((lastHP
< u
.uhp
|| lastMHP
< u
.uhpmax
) && firstTime
== FALSE
) {
589 /* Ok, this changed so add it to the highlighing list */
590 ghack_highlight_widget(hpLabel
, normalStyle
, greenStyle
);
591 } else if ((lastHP
> u
.uhp
|| lastMHP
> u
.uhpmax
)
592 && firstTime
== FALSE
) {
593 /* Ok, this changed so add it to the highlighing list */
594 ghack_highlight_widget(hpLabel
, normalStyle
, redStyle
);
599 gtk_label_set(GTK_LABEL(hpLabel
), buf
);
602 /* special case: when polymorphed, show "HD", disable exp */
603 sprintf(buf
, "HD:%d", mons
[u
.umonnum
].mlevel
);
604 if (lastLevel
< mons
[u
.umonnum
].mlevel
&& firstTime
== FALSE
) {
605 /* Ok, this changed so add it to the highlighing list */
606 ghack_highlight_widget(levlLabel
, normalStyle
, greenStyle
);
607 } else if (lastLevel
> mons
[u
.umonnum
].mlevel
&& firstTime
== FALSE
) {
608 /* Ok, this changed so add it to the highlighing list */
609 ghack_highlight_widget(levlLabel
, normalStyle
, redStyle
);
611 lastLevel
= mons
[u
.umonnum
].mlevel
;
613 sprintf(buf
, "Level:%d", u
.ulevel
);
614 if (lastLevel
< u
.ulevel
&& firstTime
== FALSE
) {
615 /* Ok, this changed so add it to the highlighing list */
616 ghack_highlight_widget(levlLabel
, normalStyle
, greenStyle
);
617 } else if (lastLevel
> u
.ulevel
&& firstTime
== FALSE
) {
618 /* Ok, this changed so add it to the highlighing list */
619 ghack_highlight_widget(levlLabel
, normalStyle
, redStyle
);
621 lastLevel
= u
.ulevel
;
623 gtk_label_set(GTK_LABEL(levlLabel
), buf
);
625 sprintf(buf
, "Power:%d/%d", u
.uen
, u
.uenmax
);
626 if ((lastPOW
< u
.uen
|| lastMPOW
< u
.uenmax
) && firstTime
== FALSE
) {
627 /* Ok, this changed so add it to the highlighing list */
628 ghack_highlight_widget(powLabel
, normalStyle
, greenStyle
);
630 if ((lastPOW
> u
.uen
|| lastMPOW
> u
.uenmax
) && firstTime
== FALSE
) {
631 /* Ok, this changed so add it to the highlighing list */
632 ghack_highlight_widget(powLabel
, normalStyle
, redStyle
);
636 gtk_label_set(GTK_LABEL(powLabel
), buf
);
638 sprintf(buf
, "AC:%d", u
.uac
);
639 if (lastAC
> u
.uac
&& firstTime
== FALSE
) {
640 /* Ok, this changed so add it to the highlighing list */
641 ghack_highlight_widget(acLabel
, normalStyle
, greenStyle
);
642 } else if (lastAC
< u
.uac
&& firstTime
== FALSE
) {
643 /* Ok, this changed so add it to the highlighing list */
644 ghack_highlight_widget(acLabel
, normalStyle
, redStyle
);
647 gtk_label_set(GTK_LABEL(acLabel
), buf
);
650 sprintf(buf
, "Exp:%ld", u
.uexp
);
651 if (lastExp
< u
.uexp
&& firstTime
== FALSE
) {
652 /* Ok, this changed so add it to the highlighing list */
653 ghack_highlight_widget(expLabel
, normalStyle
, greenStyle
);
654 } else if (lastExp
> u
.uexp
&& firstTime
== FALSE
) {
655 /* Ok, this changed so add it to the highlighing list */
656 ghack_highlight_widget(expLabel
, normalStyle
, redStyle
);
659 gtk_label_set(GTK_LABEL(expLabel
), buf
);
661 gtk_label_set(GTK_LABEL(expLabel
), "");
665 sprintf(buf
, "Time:%ld", moves
);
666 gtk_label_set(GTK_LABEL(timeLabel
), buf
);
668 gtk_label_set(GTK_LABEL(timeLabel
), "");
670 if (flags
.showscore
) {
671 sprintf(buf
, "Score:%ld", botl_score());
672 gtk_label_set(GTK_LABEL(scoreLabel
), buf
);
674 gtk_label_set(GTK_LABEL(scoreLabel
), "");
677 gtk_label_set(GTK_LABEL(scoreLabel
), "");
681 /* See if their alignment has changed */
682 if (lastAlignment
!= u
.ualign
.type
) {
683 if (firstTime
== FALSE
) {
684 /* Ok, this changed so add it to the highlighing list */
685 ghack_highlight_widget(alignLabel
, normalStyle
, redStyle
);
688 lastAlignment
= u
.ualign
.type
;
689 /* looks like their alignment has changed -- change out the icon */
690 if (u
.ualign
.type
== A_CHAOTIC
) {
691 gtk_label_set(GTK_LABEL(alignLabel
), "Chaotic");
692 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(alignPix
), chaotic_xpm
);
693 } else if (u
.ualign
.type
== A_NEUTRAL
) {
694 gtk_label_set(GTK_LABEL(alignLabel
), "Neutral");
695 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(alignPix
), neutral_xpm
);
697 gtk_label_set(GTK_LABEL(alignLabel
), "Lawful");
698 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(alignPix
), lawful_xpm
);
702 hung
= hu_stat
[u
.uhs
];
703 if (lastHungr
!= u
.uhs
) {
704 if (firstTime
== FALSE
) {
705 /* Ok, this changed so add it to the highlighing list */
706 ghack_highlight_widget(hungerLabel
, normalStyle
, redStyle
);
710 if (hung
[0] == ' ') {
711 gtk_label_set(GTK_LABEL(hungerLabel
), " ");
712 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(hungerPix
), nothing_xpm
);
713 } else if (u
.uhs
== 0 /* SATIATED */) {
714 gtk_label_set(GTK_LABEL(hungerLabel
), hung
);
715 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(hungerPix
), satiated_xpm
);
717 gtk_label_set(GTK_LABEL(hungerLabel
), hung
);
718 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(hungerPix
), hungry_xpm
);
722 if (lastConf
!= Confusion
) {
723 if (firstTime
== FALSE
) {
724 /* Ok, this changed so add it to the highlighing list */
725 ghack_highlight_widget(confuLabel
, normalStyle
, redStyle
);
728 lastConf
= Confusion
;
730 gtk_label_set(GTK_LABEL(confuLabel
), "Confused");
731 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(confuPix
), confused_xpm
);
733 gtk_label_set(GTK_LABEL(confuLabel
), " ");
734 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(confuPix
), nothing_xpm
);
738 if (lastBlind
!= Blind
) {
739 if (firstTime
== FALSE
) {
740 /* Ok, this changed so add it to the highlighing list */
741 ghack_highlight_widget(blindLabel
, normalStyle
, redStyle
);
746 gtk_label_set(GTK_LABEL(blindLabel
), "Blind");
747 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(blindPix
), blind_xpm
);
749 gtk_label_set(GTK_LABEL(blindLabel
), " ");
750 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(blindPix
), nothing_xpm
);
753 if (lastStun
!= Stunned
) {
754 if (firstTime
== FALSE
) {
755 /* Ok, this changed so add it to the highlighing list */
756 ghack_highlight_widget(stunLabel
, normalStyle
, redStyle
);
761 gtk_label_set(GTK_LABEL(stunLabel
), "Stun");
762 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(stunPix
), stunned_xpm
);
764 gtk_label_set(GTK_LABEL(stunLabel
), " ");
765 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(stunPix
), nothing_xpm
);
769 if (lastHalu
!= Hallucination
) {
770 if (firstTime
== FALSE
) {
771 /* Ok, this changed so add it to the highlighing list */
772 ghack_highlight_widget(halluLabel
, normalStyle
, redStyle
);
775 lastHalu
= Hallucination
;
777 gtk_label_set(GTK_LABEL(halluLabel
), "Hallu");
778 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(halluPix
), hallu_xpm
);
780 gtk_label_set(GTK_LABEL(halluLabel
), " ");
781 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(halluPix
), nothing_xpm
);
785 if (lastSick
!= Sick
) {
786 if (firstTime
== FALSE
) {
787 /* Ok, this changed so add it to the highlighing list */
788 ghack_highlight_widget(sickLabel
, normalStyle
, redStyle
);
793 if (u
.usick_type
& SICK_VOMITABLE
) {
794 gtk_label_set(GTK_LABEL(sickLabel
), "FoodPois");
795 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(sickPix
), sick_fp_xpm
);
796 } else if (u
.usick_type
& SICK_NONVOMITABLE
) {
797 gtk_label_set(GTK_LABEL(sickLabel
), "Ill");
798 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(sickPix
), sick_il_xpm
);
800 gtk_label_set(GTK_LABEL(sickLabel
), "FoodPois");
801 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(sickPix
), sick_fp_xpm
);
804 gtk_label_set(GTK_LABEL(sickLabel
), " ");
805 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(sickPix
), nothing_xpm
);
809 enc
= enc_stat
[near_capacity()];
810 if (lastEncumb
!= near_capacity()) {
811 if (firstTime
== FALSE
) {
812 /* Ok, this changed so add it to the highlighing list */
813 ghack_highlight_widget(encumbLabel
, normalStyle
, redStyle
);
816 lastEncumb
= near_capacity();
817 switch (lastEncumb
) {
819 gtk_label_set(GTK_LABEL(encumbLabel
), " ");
820 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix
), nothing_xpm
);
823 gtk_label_set(GTK_LABEL(encumbLabel
), enc
);
824 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix
), slt_enc_xpm
);
827 gtk_label_set(GTK_LABEL(encumbLabel
), enc
);
828 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix
), mod_enc_xpm
);
831 gtk_label_set(GTK_LABEL(encumbLabel
), enc
);
832 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix
), hvy_enc_xpm
);
835 gtk_label_set(GTK_LABEL(encumbLabel
), enc
);
836 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix
), ext_enc_xpm
);
839 gtk_label_set(GTK_LABEL(encumbLabel
), enc
);
840 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix
), ovr_enc_xpm
);
847 ghack_fade_highlighting()
852 /* Remove any items from the queue if their time is up */
853 for (item
= g_list_first(s_HighLightList
); item
;) {
854 highlt
= (Highlight
*) item
->data
;
856 if (highlt
->nTurnsLeft
<= 0) {
857 gtk_widget_set_style(GTK_WIDGET(highlt
->widget
),
859 s_HighLightList
= g_list_remove_link(s_HighLightList
, item
);
862 item
= g_list_first(s_HighLightList
);
865 (highlt
->nTurnsLeft
)--;
874 /* Widget changed, so add it to the highlighing list */
876 ghack_highlight_widget(GtkWidget
*widget
, GtkStyle
*oldStyle
,
882 /* Check if this widget is already in the queue. If so then
883 * remove it, so we will only have the new entry in the queue */
884 for (item
= g_list_first(s_HighLightList
); item
;) {
885 highlt
= (Highlight
*) item
->data
;
887 if (highlt
->widget
== widget
) {
888 s_HighLightList
= g_list_remove_link(s_HighLightList
, item
);
900 /* Ok, now highlight this widget and add it into the fade
901 * highlighting queue */
902 highlt
= g_new(Highlight
, 1);
903 highlt
->nTurnsLeft
= NUM_TURNS_HIGHLIGHTED
;
904 highlt
->oldStyle
= oldStyle
;
905 highlt
->widget
= widget
;
906 s_HighLightList
= g_list_prepend(s_HighLightList
, highlt
);
907 gtk_widget_set_style(GTK_WIDGET(widget
), newStyle
);