1 /* SCCS Id: @(#)gnstatus.c 3.4 2000/07/16 */
2 /* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
3 /* NetHack may be freely redistributed. See license for details. */
11 extern const char *hu_stat[]; /* from eat.c */
12 extern const char *enc_stat[]; /* from botl.c */
14 void ghack_status_window_update_stats();
15 void ghack_status_window_clear(GtkWidget *win, gpointer data);
16 void ghack_status_window_destroy(GtkWidget *win, gpointer data);
17 void ghack_status_window_display(GtkWidget *win, boolean block, gpointer data);
18 void ghack_status_window_cursor_to(GtkWidget *win, int x, int y, gpointer data);
19 void ghack_status_window_put_string(GtkWidget *win, int attr, const char* text, gpointer data);
21 static void ghack_fade_highlighting();
22 static void ghack_highlight_widget( GtkWidget* widget, GtkStyle* oldStyle,
25 /* some junk to handle when to fade the highlighting */
26 #define NUM_TURNS_HIGHLIGHTED 3
28 static GList *s_HighLightList;
37 /* Ok, now for a LONG list of widgets... */
38 static GtkWidget* statTable = NULL;
39 static GtkWidget* titleLabel = NULL;
40 static GtkWidget* dgnLevelLabel = NULL;
41 static GtkWidget* strPix = NULL;
42 static GtkWidget* strLabel = NULL;
43 static GtkWidget* dexPix = NULL;
44 static GtkWidget* dexLabel = NULL;
45 static GtkWidget* intPix = NULL;
46 static GtkWidget* intLabel = NULL;
47 static GtkWidget* wisPix = NULL;
48 static GtkWidget* wisLabel = NULL;
49 static GtkWidget* conPix = NULL;
50 static GtkWidget* conLabel = NULL;
51 static GtkWidget* chaPix = NULL;
52 static GtkWidget* chaLabel = NULL;
53 static GtkWidget* goldLabel = NULL;
54 static GtkWidget* hpLabel = NULL;
55 static GtkWidget* powLabel = NULL;
56 static GtkWidget* acLabel = NULL;
57 static GtkWidget* levlLabel = NULL;
58 static GtkWidget* expLabel = NULL;
59 static GtkWidget* timeLabel = NULL;
60 static GtkWidget* scoreLabel = NULL;
61 static GtkWidget* alignPix = NULL;
62 static GtkWidget* alignLabel = NULL;
63 static GtkWidget* hungerPix = NULL;
64 static GtkWidget* hungerLabel = NULL;
65 static GtkWidget* sickPix = NULL;
66 static GtkWidget* sickLabel = NULL;
67 static GtkWidget* blindPix = NULL;
68 static GtkWidget* blindLabel = NULL;
69 static GtkWidget* stunPix = NULL;
70 static GtkWidget* stunLabel = NULL;
71 static GtkWidget* halluPix = NULL;
72 static GtkWidget* halluLabel = NULL;
73 static GtkWidget* confuPix = NULL;
74 static GtkWidget* confuLabel = NULL;
75 static GtkWidget* encumbPix = NULL;
76 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;
115 void ghack_status_window_clear( GtkWidget *win, gpointer data)
117 /* Don't think we need this at all */
120 void ghack_status_window_destroy(GtkWidget *win, gpointer data)
122 while (s_HighLightList) {
123 g_free( (Highlight*)s_HighLightList->data);
124 s_HighLightList = s_HighLightList->next;
126 g_list_free( s_HighLightList );
129 void ghack_status_window_display( GtkWidget *win, boolean block, gpointer data)
131 gtk_widget_show_all( GTK_WIDGET(win));
134 void ghack_status_window_cursor_to( GtkWidget *win, int x, int y, gpointer data)
136 /* Don't think we need this at all */
139 void ghack_status_window_put_string( GtkWidget *win, int attr, const char* text, gpointer data)
141 ghack_status_window_update_stats();
146 GtkWidget* ghack_init_status_window ()
148 GtkWidget *horizSep0, *horizSep1, *horizSep2, *horizSep3;
149 GtkWidget *statsHBox, *strVBox, *dexVBox, *intVBox, *statHBox;
150 GtkWidget *wisVBox, *conVBox, *chaVBox;
151 GtkWidget *alignVBox, *hungerVBox, *sickVBox, *blindVBox;
152 GtkWidget *stunVBox, *halluVBox, *confuVBox, *encumbVBox;
154 /* Set up a (ridiculous) initial state */
170 lastAlignment = A_NEUTRAL; /* start off guessing neutral */
179 statTable = gtk_table_new( 10, 8, FALSE);
180 gtk_table_set_row_spacings( GTK_TABLE( statTable), 1);
181 gtk_table_set_col_spacings( GTK_TABLE( statTable), 1);
184 /* Begin the first row of the table -- the title */
185 titleLabel = gtk_label_new( _("GnomeHack!"));
186 gtk_table_attach( GTK_TABLE( statTable), titleLabel,
187 0, 8, 0, 1, GTK_FILL, 0, 0, 0);
189 normalStyle = gtk_style_copy (
190 gtk_widget_get_style (GTK_WIDGET (titleLabel)));
192 /* Set up some styles to draw stuff with */
194 g_assert (greenStyle == NULL);
195 g_assert (bigStyle == NULL);
196 g_assert (bigRedStyle == NULL);
197 g_assert (bigGreenStyle == NULL);
199 greenStyle = gtk_style_copy (normalStyle);
200 redStyle = gtk_style_copy (normalStyle);
201 bigRedStyle = gtk_style_copy (normalStyle);
202 bigGreenStyle = gtk_style_copy (normalStyle);
203 bigStyle = gtk_style_copy (normalStyle);
205 greenStyle->fg[GTK_STATE_NORMAL] = color_green;
206 redStyle->fg[GTK_STATE_NORMAL] = color_red;
207 bigRedStyle->fg[GTK_STATE_NORMAL] = color_red;
208 bigGreenStyle->fg[GTK_STATE_NORMAL] = color_green;
210 gdk_font_unref (bigRedStyle->font);
211 gdk_font_unref (bigGreenStyle->font);
212 bigRedStyle->font = gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
213 bigGreenStyle->font = gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
215 gdk_font_unref (bigStyle->font);
216 bigStyle->font = gdk_font_load ("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
218 gtk_widget_set_style (GTK_WIDGET (titleLabel), bigStyle);
220 /* Begin the second row */
221 dgnLevelLabel = gtk_label_new (_ ("Nethack for Gnome"));
222 gtk_table_attach (GTK_TABLE (statTable), dgnLevelLabel,
223 0, 8, 1, 2, GTK_FILL, 0, 0, 0);
224 gtk_widget_set_style (GTK_WIDGET (dgnLevelLabel), bigStyle);
226 /* Begin the third row */
227 horizSep0 = gtk_hseparator_new ();
228 gtk_table_attach (GTK_TABLE (statTable), horizSep0,
229 0, 8, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
232 /* Begin the fourth row */
233 statsHBox = gtk_hbox_new (TRUE, 0);
235 strVBox = gtk_vbox_new (FALSE, 0);
236 strPix = gnome_pixmap_new_from_xpm_d( str_xpm);
237 strLabel = gtk_label_new( "STR: ");
238 gtk_box_pack_start (GTK_BOX (strVBox), strPix, TRUE, TRUE, 2);
239 gtk_box_pack_start (GTK_BOX (strVBox), strLabel, TRUE, TRUE, 2);
240 gtk_box_pack_start (GTK_BOX(statsHBox), GTK_WIDGET(strVBox), TRUE, TRUE, 2);
242 dexVBox = gtk_vbox_new (FALSE, 0);
243 dexPix = gnome_pixmap_new_from_xpm_d( dex_xpm);
244 dexLabel = gtk_label_new( "DEX: ");
245 gtk_box_pack_start (GTK_BOX (dexVBox), dexPix, TRUE, TRUE, 2);
246 gtk_box_pack_start (GTK_BOX (dexVBox), dexLabel, TRUE, TRUE, 2);
247 gtk_box_pack_start (GTK_BOX(statsHBox), GTK_WIDGET(dexVBox), TRUE, TRUE, 2);
249 conVBox = gtk_vbox_new (FALSE, 0);
250 conPix = gnome_pixmap_new_from_xpm_d( cns_xpm);
251 conLabel = gtk_label_new( "CON: ");
252 gtk_box_pack_start (GTK_BOX (conVBox), conPix, TRUE, TRUE, 2);
253 gtk_box_pack_start (GTK_BOX (conVBox), conLabel, TRUE, TRUE, 2);
254 gtk_box_pack_start (GTK_BOX(statsHBox), GTK_WIDGET(conVBox), TRUE, TRUE, 2);
256 intVBox = gtk_vbox_new (FALSE, 0);
257 intPix = gnome_pixmap_new_from_xpm_d( int_xpm);
258 intLabel = gtk_label_new( "INT: ");
259 gtk_box_pack_start (GTK_BOX (intVBox), intPix, TRUE, TRUE, 2);
260 gtk_box_pack_start (GTK_BOX (intVBox), intLabel, TRUE, TRUE, 2);
261 gtk_box_pack_start (GTK_BOX(statsHBox), GTK_WIDGET(intVBox), TRUE, TRUE, 2);
264 wisVBox = gtk_vbox_new (FALSE, 0);
265 wisPix = gnome_pixmap_new_from_xpm_d( wis_xpm);
266 wisLabel = gtk_label_new( "WIS: ");
267 gtk_box_pack_start (GTK_BOX (wisVBox), wisPix, TRUE, TRUE, 2);
268 gtk_box_pack_start (GTK_BOX (wisVBox), wisLabel, TRUE, TRUE, 2);
269 gtk_box_pack_start (GTK_BOX(statsHBox), GTK_WIDGET(wisVBox), TRUE, TRUE, 2);
272 chaVBox = gtk_vbox_new (FALSE, 0);
273 chaPix = gnome_pixmap_new_from_xpm_d( cha_xpm);
274 chaLabel = gtk_label_new( "CHA: ");
275 gtk_box_pack_start (GTK_BOX (chaVBox), chaPix, TRUE, TRUE, 2);
276 gtk_box_pack_start (GTK_BOX (chaVBox), chaLabel, TRUE, TRUE, 2);
277 gtk_box_pack_start (GTK_BOX(statsHBox), GTK_WIDGET(chaVBox), TRUE, TRUE, 2);
279 gtk_table_attach( GTK_TABLE( statTable), GTK_WIDGET(statsHBox),
280 0, 8, 3, 4, GTK_FILL, 0, 0, 0);
282 /* Begin the fifth row */
283 horizSep1 = gtk_hseparator_new();
284 gtk_table_attach( GTK_TABLE( statTable), horizSep1,
285 0, 8, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
287 /* Begin the sixth row */
288 hpLabel = gtk_label_new( "HP: ");
289 gtk_table_attach( GTK_TABLE( statTable), hpLabel,
290 0, 1, 5, 6, GTK_FILL, 0, 0, 0);
292 acLabel = gtk_label_new( "AC: ");
293 gtk_table_attach( GTK_TABLE( statTable), acLabel,
294 2, 3, 5, 6, GTK_FILL, 0, 0, 0);
296 powLabel = gtk_label_new( "Power: ");
297 gtk_table_attach( GTK_TABLE( statTable), powLabel,
298 4, 5, 5, 6, GTK_FILL, 0, 0, 0);
300 goldLabel = gtk_label_new( "Au: ");
301 gtk_table_attach( GTK_TABLE( statTable), goldLabel,
302 6, 7, 5, 6, GTK_FILL, 0, 0, 0);
305 /* Begin the seventh row */
306 horizSep2 = gtk_hseparator_new();
307 gtk_table_attach( GTK_TABLE( statTable), horizSep2,
308 0, 8, 6, 7, GTK_FILL, GTK_FILL, 0, 0);
311 /* Begin the eigth row */
312 levlLabel = gtk_label_new( "Level: ");
313 gtk_table_attach( GTK_TABLE( statTable), levlLabel,
314 0, 1, 7, 8, GTK_FILL, 0, 0, 0);
316 expLabel = gtk_label_new( "Exp: ");
317 gtk_table_attach( GTK_TABLE( statTable), expLabel,
318 2, 3, 7, 8, GTK_FILL, 0, 0, 0);
320 timeLabel = gtk_label_new( "Time: ");
321 gtk_table_attach( GTK_TABLE( statTable), timeLabel,
322 4, 5, 7, 8, GTK_FILL, 0, 0, 0);
324 scoreLabel = gtk_label_new( "Score: ");
325 gtk_table_attach( GTK_TABLE( statTable), scoreLabel,
326 6, 7, 7, 8, GTK_FILL, 0, 0, 0);
328 /* Begin the ninth row */
329 horizSep3 = gtk_hseparator_new();
330 gtk_table_attach( GTK_TABLE( statTable), horizSep3,
331 0, 8, 8, 9, GTK_FILL, GTK_FILL, 0, 0);
333 /* Begin the tenth and last row */
334 statHBox = gtk_hbox_new (FALSE, 0);
336 alignVBox = gtk_vbox_new (FALSE, 0);
337 alignPix = gnome_pixmap_new_from_xpm_d( neutral_xpm);
338 alignLabel = gtk_label_new( "Neutral");
339 gtk_box_pack_start (GTK_BOX (alignVBox), alignPix, TRUE, TRUE, 2);
340 gtk_box_pack_start (GTK_BOX (alignVBox), alignLabel, TRUE, TRUE, 2);
341 gtk_box_pack_start (GTK_BOX(statHBox), GTK_WIDGET(alignVBox), TRUE, FALSE, 2);
343 hungerVBox = gtk_vbox_new (FALSE, 0);
344 hungerPix = gnome_pixmap_new_from_xpm_d( hungry_xpm);
345 hungerLabel = gtk_label_new( "Hungry");
346 gtk_box_pack_start (GTK_BOX (hungerVBox), hungerPix, TRUE, TRUE, 2);
347 gtk_box_pack_start (GTK_BOX (hungerVBox), hungerLabel, TRUE, TRUE, 2);
348 gtk_box_pack_start (GTK_BOX(statHBox), GTK_WIDGET(hungerVBox), TRUE, FALSE, 2);
350 sickVBox = gtk_vbox_new (FALSE, 0);
351 sickPix = gnome_pixmap_new_from_xpm_d( sick_fp_xpm);
352 sickLabel = gtk_label_new( "FoodPois");
353 gtk_box_pack_start (GTK_BOX (sickVBox), sickPix, TRUE, TRUE, 2);
354 gtk_box_pack_start (GTK_BOX (sickVBox), sickLabel, TRUE, TRUE, 2);
355 gtk_box_pack_start (GTK_BOX(statHBox), GTK_WIDGET(sickVBox), TRUE, FALSE, 2);
357 blindVBox = gtk_vbox_new (FALSE, 0);
358 blindPix = gnome_pixmap_new_from_xpm_d( blind_xpm);
359 blindLabel = gtk_label_new( "Blind");
360 gtk_box_pack_start (GTK_BOX (blindVBox), blindPix, TRUE, TRUE, 2);
361 gtk_box_pack_start (GTK_BOX (blindVBox), blindLabel, TRUE, TRUE, 2);
362 gtk_box_pack_start (GTK_BOX(statHBox), GTK_WIDGET(blindVBox), TRUE, FALSE, 2);
364 stunVBox = gtk_vbox_new (FALSE, 0);
365 stunPix = gnome_pixmap_new_from_xpm_d( stunned_xpm);
366 stunLabel = gtk_label_new( "Stun");
367 gtk_box_pack_start (GTK_BOX (stunVBox), stunPix, TRUE, TRUE, 2);
368 gtk_box_pack_start (GTK_BOX (stunVBox), stunLabel, TRUE, TRUE, 2);
369 gtk_box_pack_start (GTK_BOX(statHBox), GTK_WIDGET(stunVBox), TRUE, FALSE, 2);
371 confuVBox = gtk_vbox_new (FALSE, 0);
372 confuPix = gnome_pixmap_new_from_xpm_d( confused_xpm);
373 confuLabel = gtk_label_new( "Confused");
374 gtk_box_pack_start (GTK_BOX (confuVBox), confuPix, TRUE, TRUE, 2);
375 gtk_box_pack_start (GTK_BOX (confuVBox), confuLabel, TRUE, TRUE, 2);
376 gtk_box_pack_start (GTK_BOX(statHBox), GTK_WIDGET(confuVBox), TRUE, FALSE, 2);
378 halluVBox = gtk_vbox_new (FALSE, 0);
379 halluPix = gnome_pixmap_new_from_xpm_d( hallu_xpm);
380 halluLabel = gtk_label_new( "Hallu");
381 gtk_box_pack_start (GTK_BOX (halluVBox), halluPix, TRUE, TRUE, 2);
382 gtk_box_pack_start (GTK_BOX (halluVBox), halluLabel, TRUE, TRUE, 2);
383 gtk_box_pack_start (GTK_BOX(statHBox), GTK_WIDGET(halluVBox), TRUE, FALSE, 2);
385 encumbVBox = gtk_vbox_new (FALSE, 0);
386 encumbPix = gnome_pixmap_new_from_xpm_d( slt_enc_xpm);
387 encumbLabel = gtk_label_new( "Burdened");
388 gtk_box_pack_start (GTK_BOX (encumbVBox), encumbPix, TRUE, TRUE, 2);
389 gtk_box_pack_start (GTK_BOX (encumbVBox), encumbLabel, TRUE, TRUE, 2);
390 gtk_box_pack_start (GTK_BOX(statHBox), GTK_WIDGET(encumbVBox), TRUE, FALSE, 2);
392 gtk_table_attach( GTK_TABLE( statTable), GTK_WIDGET(statHBox),
393 0, 8, 9, 10, GTK_FILL, GTK_FILL, 0, 0);
395 /* Set up the necessary signals */
396 gtk_signal_connect (GTK_OBJECT (statTable),
397 "ghack_fade_highlight",
398 GTK_SIGNAL_FUNC (ghack_fade_highlighting),
401 gtk_signal_connect (GTK_OBJECT (statTable),
403 GTK_SIGNAL_FUNC (ghack_status_window_put_string),
406 gtk_signal_connect (GTK_OBJECT (statTable),
408 GTK_SIGNAL_FUNC (ghack_status_window_clear),
411 gtk_signal_connect (GTK_OBJECT (statTable),
413 GTK_SIGNAL_FUNC (ghack_status_window_cursor_to),
415 gtk_signal_connect(GTK_OBJECT (statTable),
416 "gnome_delay_output",
417 GTK_SIGNAL_FUNC(ghack_delay),
420 /* Lastly, show the status window and everything in it */
421 gtk_widget_show_all( statTable);
423 return GTK_WIDGET(statTable);
428 void ghack_status_window_update_stats()
434 static int firstTime=TRUE;
439 /* First, fill in the player name and the dungeon level */
441 if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a';
442 strcat(buf, " the ");
447 strcpy(mname, mons[u.umonnum].mname);
448 while(mname[k] != 0) {
449 if ((k == 0 || (k > 0 && mname[k-1] == ' '))
450 && 'a' <= mname[k] && mname[k] <= 'z')
452 mname[k] += 'A' - 'a';
458 strcat(buf, rank_of(u.ulevel, pl_character[0], flags.female));
460 gtk_label_get( GTK_LABEL( titleLabel), &buf1);
461 if (strcmp( buf1, buf) != 0 && firstTime==FALSE) {
462 /* Ok, this changed so add it to the highlighing list */
463 ghack_highlight_widget( titleLabel, bigStyle, bigGreenStyle);
465 gtk_label_set( GTK_LABEL( titleLabel), buf);
468 if (In_endgame(&u.uz)) {
469 strcpy(buf, (Is_astralevel(&u.uz) ? "Astral Plane":"End Game"));
471 sprintf(buf, "%s, level %d", dungeons[u.uz.dnum].dname, depth(&u.uz));
473 if (lastDepth > depth(&u.uz) && firstTime==FALSE) {
474 /* Ok, this changed so add it to the highlighing list */
475 ghack_highlight_widget( dgnLevelLabel, bigStyle, bigRedStyle);
477 else if (lastDepth < depth(&u.uz) && firstTime==FALSE) {
478 /* Ok, this changed so add it to the highlighing list */
479 ghack_highlight_widget( dgnLevelLabel, bigStyle, bigGreenStyle);
481 lastDepth = depth(&u.uz);
482 gtk_label_set( GTK_LABEL( dgnLevelLabel), buf);
484 /* Next, fill in the player's stats */
485 if (ACURR(A_STR) > 118) {
486 sprintf(buf,"STR:%d",ACURR(A_STR)-100);
487 } else if (ACURR(A_STR)==118) {
488 sprintf(buf,"STR:18/**");
489 } else if(ACURR(A_STR) > 18) {
490 sprintf(buf,"STR:18/%02d",ACURR(A_STR)-18);
492 sprintf(buf,"STR:%d",ACURR(A_STR));
494 if (lastStr < ACURR(A_STR) && firstTime==FALSE) {
495 /* Ok, this changed so add it to the highlighing list */
496 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);
510 else if (lastInt > ACURR(A_INT) && firstTime==FALSE) {
511 /* Ok, this changed so add it to the highlighing list */
512 ghack_highlight_widget( intLabel, normalStyle, redStyle);
514 lastInt = ACURR(A_INT);
515 gtk_label_set( GTK_LABEL( intLabel), buf);
517 sprintf(buf,"WIS:%d",ACURR(A_WIS));
518 if (lastWis < ACURR(A_WIS) && firstTime==FALSE) {
519 /* Ok, this changed so add it to the highlighing list */
520 ghack_highlight_widget( wisLabel, normalStyle, greenStyle);
522 else if (lastWis > ACURR(A_WIS) && firstTime==FALSE) {
523 /* Ok, this changed so add it to the highlighing list */
524 ghack_highlight_widget( wisLabel, normalStyle, redStyle);
526 lastWis = ACURR(A_WIS);
527 gtk_label_set( GTK_LABEL( wisLabel), buf);
529 sprintf(buf,"DEX:%d",ACURR(A_DEX));
530 if (lastDex < ACURR(A_DEX) && firstTime==FALSE) {
531 /* Ok, this changed so add it to the highlighing list */
532 ghack_highlight_widget( dexLabel, normalStyle, greenStyle);
534 else if (lastDex > ACURR(A_DEX) && firstTime==FALSE) {
535 /* Ok, this changed so add it to the highlighing list */
536 ghack_highlight_widget( dexLabel, normalStyle, redStyle);
538 lastDex = ACURR(A_DEX);
539 gtk_label_set( GTK_LABEL( dexLabel), buf);
541 sprintf(buf,"CON:%d",ACURR(A_CON));
542 if (lastCon < ACURR(A_CON) && firstTime==FALSE) {
543 /* Ok, this changed so add it to the highlighing list */
544 ghack_highlight_widget( conLabel, normalStyle, greenStyle);
546 else if (lastCon > ACURR(A_CON) && firstTime==FALSE) {
547 /* Ok, this changed so add it to the highlighing list */
548 ghack_highlight_widget( conLabel, normalStyle, redStyle);
550 lastCon = ACURR(A_CON);
551 gtk_label_set( GTK_LABEL( conLabel), buf);
553 sprintf(buf,"CHA:%d",ACURR(A_CHA));
554 if (lastCha < ACURR(A_CHA) && firstTime==FALSE) {
555 /* Ok, this changed so add it to the highlighing list */
556 ghack_highlight_widget( chaLabel, normalStyle, greenStyle);
558 else if (lastCha > ACURR(A_CHA) && firstTime==FALSE) {
559 /* Ok, this changed so add it to the highlighing list */
560 ghack_highlight_widget( chaLabel, normalStyle, redStyle);
562 lastCha = ACURR(A_CHA);
563 gtk_label_set( GTK_LABEL( chaLabel), buf);
565 /* Now do the non-pixmaped stats (gold and such) */
567 sprintf(buf,"Au:%ld", u.ugold);
568 if (lastAu < u.ugold && firstTime==FALSE) {
570 umoney = money_cnt(invent);
571 sprintf(buf,"Au:%ld", umoney);
572 if (lastAu < umoney && firstTime==FALSE) {
574 /* Ok, this changed so add it to the highlighing list */
575 ghack_highlight_widget( goldLabel, normalStyle, greenStyle);
578 else if (lastAu > u.ugold && firstTime==FALSE) {
580 else if (lastAu > umoney && firstTime==FALSE) {
582 /* Ok, this changed so add it to the highlighing list */
583 ghack_highlight_widget( goldLabel, normalStyle, redStyle);
590 gtk_label_set( GTK_LABEL( goldLabel), buf);
593 /* special case: when polymorphed, show "HD", disable exp */
594 sprintf(buf,"HP:%d/%d", ( (u.mh > 0)? u.mh : 0), u.mhmax);
595 if ((lastHP < u.mh || lastMHP < u.mhmax ) && firstTime==FALSE) {
596 /* Ok, this changed so add it to the highlighing list */
597 ghack_highlight_widget( hpLabel, normalStyle, greenStyle);
599 else if ((lastHP > u.mh || lastMHP > u.mhmax ) && firstTime==FALSE) {
600 /* Ok, this changed so add it to the highlighing list */
601 ghack_highlight_widget( hpLabel, normalStyle, redStyle);
606 sprintf(buf,"HP:%d/%d", ( (u.uhp > 0)? u.uhp : 0), u.uhpmax);
607 if ((lastHP < u.uhp || lastMHP < u.uhpmax ) && firstTime==FALSE) {
608 /* Ok, this changed so add it to the highlighing list */
609 ghack_highlight_widget( hpLabel, normalStyle, greenStyle);
611 else if ((lastHP > u.uhp || lastMHP > u.uhpmax ) && firstTime==FALSE) {
612 /* Ok, this changed so add it to the highlighing list */
613 ghack_highlight_widget( hpLabel, normalStyle, redStyle);
618 gtk_label_set( GTK_LABEL( hpLabel), buf);
621 /* special case: when polymorphed, show "HD", disable exp */
622 sprintf(buf,"HD:%d", mons[u.umonnum].mlevel);
623 if (lastLevel < mons[u.umonnum].mlevel && firstTime==FALSE) {
624 /* Ok, this changed so add it to the highlighing list */
625 ghack_highlight_widget( levlLabel, normalStyle, greenStyle);
627 else if (lastLevel > mons[u.umonnum].mlevel && firstTime==FALSE) {
628 /* Ok, this changed so add it to the highlighing list */
629 ghack_highlight_widget( levlLabel, normalStyle, redStyle);
631 lastLevel = mons[u.umonnum].mlevel;
633 sprintf(buf,"Level:%d", u.ulevel);
634 if (lastLevel < u.ulevel && firstTime==FALSE) {
635 /* Ok, this changed so add it to the highlighing list */
636 ghack_highlight_widget( levlLabel, normalStyle, greenStyle);
638 else if (lastLevel > u.ulevel && firstTime==FALSE) {
639 /* Ok, this changed so add it to the highlighing list */
640 ghack_highlight_widget( levlLabel, normalStyle, redStyle);
642 lastLevel = u.ulevel;
644 gtk_label_set( GTK_LABEL( levlLabel), buf);
646 sprintf(buf,"Power:%d/%d", u.uen, u.uenmax);
647 if ((lastPOW < u.uen || lastMPOW < u.uenmax) && firstTime==FALSE) {
648 /* Ok, this changed so add it to the highlighing list */
649 ghack_highlight_widget( powLabel, normalStyle, greenStyle);
651 if ((lastPOW > u.uen || lastMPOW > u.uenmax) && firstTime==FALSE) {
652 /* Ok, this changed so add it to the highlighing list */
653 ghack_highlight_widget( powLabel, normalStyle, redStyle);
657 gtk_label_set( GTK_LABEL( powLabel), buf);
659 sprintf(buf,"AC:%d", u.uac);
660 if (lastAC > u.uac && firstTime==FALSE) {
661 /* Ok, this changed so add it to the highlighing list */
662 ghack_highlight_widget( acLabel, normalStyle, greenStyle);
664 else if (lastAC < u.uac && firstTime==FALSE) {
665 /* Ok, this changed so add it to the highlighing list */
666 ghack_highlight_widget( acLabel, normalStyle, redStyle);
669 gtk_label_set( GTK_LABEL( acLabel), buf);
673 sprintf(buf,"Exp:%ld", u.uexp);
674 if (lastExp < u.uexp && firstTime==FALSE) {
675 /* Ok, this changed so add it to the highlighing list */
676 ghack_highlight_widget( expLabel, normalStyle, greenStyle);
678 else if (lastExp > u.uexp && firstTime==FALSE) {
679 /* Ok, this changed so add it to the highlighing list */
680 ghack_highlight_widget( expLabel, normalStyle, redStyle);
683 gtk_label_set( GTK_LABEL( expLabel), buf);
687 gtk_label_set( GTK_LABEL( expLabel), "");
691 sprintf(buf,"Time:%ld", moves);
692 gtk_label_set( GTK_LABEL( timeLabel), buf);
695 gtk_label_set( GTK_LABEL( timeLabel), "");
697 if (flags.showscore) {
698 sprintf(buf,"Score:%ld", botl_score());
699 gtk_label_set( GTK_LABEL( scoreLabel), buf);
701 gtk_label_set( GTK_LABEL( scoreLabel), "");
704 gtk_label_set( GTK_LABEL( scoreLabel), "");
708 /* See if their alignment has changed */
709 if (lastAlignment != u.ualign.type) {
710 if (firstTime==FALSE) {
711 /* Ok, this changed so add it to the highlighing list */
712 ghack_highlight_widget( alignLabel, normalStyle, redStyle);
715 lastAlignment = u.ualign.type;
716 /* looks like their alignment has changed -- change out the icon */
717 if (u.ualign.type==A_CHAOTIC) {
718 gtk_label_set( GTK_LABEL( alignLabel), "Chaotic");
719 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(alignPix), chaotic_xpm);
720 } else if (u.ualign.type==A_NEUTRAL) {
721 gtk_label_set( GTK_LABEL( alignLabel), "Neutral");
722 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(alignPix), neutral_xpm);
724 gtk_label_set( GTK_LABEL( alignLabel), "Lawful");
725 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(alignPix), lawful_xpm);
730 if (lastHungr != u.uhs) {
731 if (firstTime==FALSE) {
732 /* Ok, this changed so add it to the highlighing list */
733 ghack_highlight_widget( hungerLabel, normalStyle, redStyle);
738 gtk_label_set( GTK_LABEL( hungerLabel), " ");
739 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(hungerPix), nothing_xpm);
741 if (u.uhs == 0 /* SATIATED */) {
742 gtk_label_set( GTK_LABEL( hungerLabel), hung);
743 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(hungerPix), satiated_xpm);
745 gtk_label_set( GTK_LABEL( hungerLabel), hung);
746 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(hungerPix), hungry_xpm);
750 if (lastConf != Confusion) {
751 if (firstTime==FALSE) {
752 /* Ok, this changed so add it to the highlighing list */
753 ghack_highlight_widget( confuLabel, normalStyle, redStyle);
756 lastConf = Confusion;
758 gtk_label_set( GTK_LABEL( confuLabel), "Confused");
759 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(confuPix), confused_xpm);
762 gtk_label_set( GTK_LABEL( confuLabel), " ");
763 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(confuPix), nothing_xpm);
767 if (lastBlind != Blind) {
768 if (firstTime==FALSE) {
769 /* Ok, this changed so add it to the highlighing list */
770 ghack_highlight_widget( blindLabel, normalStyle, redStyle);
775 gtk_label_set( GTK_LABEL( blindLabel), "Blind");
776 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(blindPix), blind_xpm);
779 gtk_label_set( GTK_LABEL( blindLabel), " ");
780 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(blindPix), nothing_xpm);
783 if (lastStun != Stunned) {
784 if (firstTime==FALSE) {
785 /* Ok, this changed so add it to the highlighing list */
786 ghack_highlight_widget( stunLabel, normalStyle, redStyle);
791 gtk_label_set( GTK_LABEL( stunLabel), "Stun");
792 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(stunPix), stunned_xpm);
795 gtk_label_set( GTK_LABEL( stunLabel), " ");
796 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(stunPix), nothing_xpm);
800 if (lastHalu != Hallucination) {
801 if (firstTime==FALSE) {
802 /* Ok, this changed so add it to the highlighing list */
803 ghack_highlight_widget( halluLabel, normalStyle, redStyle);
806 lastHalu = Hallucination;
808 gtk_label_set( GTK_LABEL( halluLabel), "Hallu");
809 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(halluPix), hallu_xpm);
812 gtk_label_set( GTK_LABEL( halluLabel), " ");
813 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(halluPix), nothing_xpm);
817 if (lastSick != Sick) {
818 if (firstTime==FALSE) {
819 /* Ok, this changed so add it to the highlighing list */
820 ghack_highlight_widget( sickLabel, normalStyle, redStyle);
825 if (u.usick_type & SICK_VOMITABLE) {
826 gtk_label_set( GTK_LABEL( sickLabel), "FoodPois");
827 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(sickPix), sick_fp_xpm);
828 } else if (u.usick_type & SICK_NONVOMITABLE) {
829 gtk_label_set( GTK_LABEL( sickLabel), "Ill");
830 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(sickPix), sick_il_xpm);
832 gtk_label_set( GTK_LABEL( sickLabel), "FoodPois");
833 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(sickPix), sick_fp_xpm);
836 gtk_label_set( GTK_LABEL( sickLabel), " ");
837 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(sickPix), nothing_xpm);
841 enc=enc_stat[near_capacity()];
842 if (lastEncumb != near_capacity()) {
843 if (firstTime==FALSE) {
844 /* Ok, this changed so add it to the highlighing list */
845 ghack_highlight_widget( encumbLabel, normalStyle, redStyle);
848 lastEncumb = near_capacity();
849 switch ( lastEncumb ) {
851 gtk_label_set( GTK_LABEL( encumbLabel), " ");
852 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), nothing_xpm);
855 gtk_label_set( GTK_LABEL( encumbLabel), enc);
856 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), slt_enc_xpm);
859 gtk_label_set( GTK_LABEL( encumbLabel), enc);
860 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), mod_enc_xpm);
863 gtk_label_set( GTK_LABEL( encumbLabel), enc);
864 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), hvy_enc_xpm);
867 gtk_label_set( GTK_LABEL( encumbLabel), enc);
868 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), ext_enc_xpm);
871 gtk_label_set( GTK_LABEL( encumbLabel), enc);
872 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), ovr_enc_xpm);
878 static void ghack_fade_highlighting()
883 /* Remove any items from the queue if their time is up */
884 for (item = g_list_first( s_HighLightList) ; item ; ) {
885 highlt = (Highlight*) item->data;
887 if ( highlt->nTurnsLeft <= 0) {
888 gtk_widget_set_style( GTK_WIDGET( highlt->widget),
890 s_HighLightList = g_list_remove_link(s_HighLightList, item);
892 g_list_free_1( item);
893 item = g_list_first( s_HighLightList);
896 (highlt->nTurnsLeft)--;
905 /* Widget changed, so add it to the highlighing list */
906 static void ghack_highlight_widget( GtkWidget* widget, GtkStyle* oldStyle,
912 /* Check if this widget is already in the queue. If so then
913 * remove it, so we will only have the new entry in the queue */
914 for (item = g_list_first( s_HighLightList) ; item ; ) {
915 highlt = (Highlight*) item->data;
917 if ( highlt->widget == widget) {
918 s_HighLightList = g_list_remove_link(s_HighLightList, item);
920 g_list_free_1( item);
930 /* Ok, now highlight this widget and add it into the fade
931 * highlighting queue */
932 highlt = g_new( Highlight, 1);
933 highlt->nTurnsLeft=NUM_TURNS_HIGHLIGHTED;
934 highlt->oldStyle=oldStyle;
935 highlt->widget=widget;
936 s_HighLightList = g_list_prepend (s_HighLightList, highlt);
937 gtk_widget_set_style( GTK_WIDGET( widget), newStyle);