1 /* NetHack 3.6	gnstatus.c	$NHDT-Date: 1432512806 2015/05/25 00:13:26 $  $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */
2 /* Copyright (C) 1998 by Erik Andersen <andersee@debian.org> */
3 /* NetHack may be freely redistributed.  See license for details. */
4 
5 #include "gnstatus.h"
6 #include "gnsignal.h"
7 #include "gn_xpms.h"
8 #include "gnomeprv.h"
9 
10 extern const char *hu_stat[];  /* from eat.c */
11 extern const char *enc_stat[]; /* from botl.c */
12 
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,
17                                  gpointer data);
18 void ghack_status_window_cursor_to(GtkWidget *win, int x, int y,
19                                    gpointer data);
20 void ghack_status_window_put_string(GtkWidget *win, int attr,
21                                     const char *text, gpointer data);
22 
23 static void ghack_fade_highlighting();
24 static void ghack_highlight_widget(GtkWidget *widget, GtkStyle *oldStyle,
25                                    GtkStyle *newStyle);
26 
27 /* some junk to handle when to fade the highlighting */
28 #define NUM_TURNS_HIGHLIGHTED 3
29 
30 static GList *s_HighLightList;
31 
32 typedef struct {
33     GtkWidget *widget;
34     GtkStyle *oldStyle;
35     int nTurnsLeft;
36 } Highlight;
37 
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;
78 
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;
85 
86 /* Pure red */
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 };
90 
91 static int lastDepth;
92 static int lastStr;
93 static int lastInt;
94 static int lastWis;
95 static int lastDex;
96 static int lastCon;
97 static int lastCha;
98 static long lastAu;
99 static int lastHP;
100 static int lastMHP;
101 static int lastLevel;
102 static int lastPOW;
103 static int lastMPOW;
104 static int lastAC;
105 static int lastExp;
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;
114 
115 void
ghack_status_window_clear(GtkWidget * win,gpointer data)116 ghack_status_window_clear(GtkWidget *win, gpointer data)
117 {
118     /* Don't think we need this at all */
119 }
120 
121 void
ghack_status_window_destroy(GtkWidget * win,gpointer data)122 ghack_status_window_destroy(GtkWidget *win, gpointer data)
123 {
124     while (s_HighLightList) {
125         g_free((Highlight *) s_HighLightList->data);
126         s_HighLightList = s_HighLightList->next;
127     }
128     g_list_free(s_HighLightList);
129 }
130 
131 void
ghack_status_window_display(GtkWidget * win,boolean block,gpointer data)132 ghack_status_window_display(GtkWidget *win, boolean block, gpointer data)
133 {
134     gtk_widget_show_all(GTK_WIDGET(win));
135 }
136 
137 void
ghack_status_window_cursor_to(GtkWidget * win,int x,int y,gpointer data)138 ghack_status_window_cursor_to(GtkWidget *win, int x, int y, gpointer data)
139 {
140     /* Don't think we need this at all */
141 }
142 
143 void
ghack_status_window_put_string(GtkWidget * win,int attr,const char * text,gpointer data)144 ghack_status_window_put_string(GtkWidget *win, int attr, const char *text,
145                                gpointer data)
146 {
147     ghack_status_window_update_stats();
148 }
149 
150 GtkWidget *
ghack_init_status_window()151 ghack_init_status_window()
152 {
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;
158 
159     /* Set up a (ridiculous) initial state */
160     lastDepth = 9999;
161     lastStr = 9999;
162     lastInt = 9999;
163     lastWis = 9999;
164     lastDex = 9999;
165     lastCon = 9999;
166     lastCha = 9999;
167     lastAu = 9999;
168     lastHP = 9999;
169     lastMHP = 9999;
170     lastLevel = 9999;
171     lastPOW = 9999;
172     lastMPOW = 9999;
173     lastAC = 9999;
174     lastExp = 9999;
175     lastAlignment = A_NEUTRAL; /* start off guessing neutral */
176     lastHungr = 9999;
177     lastConf = 9999;
178     lastBlind = 9999;
179     lastStun = 9999;
180     lastHalu = 9999;
181     lastSick = 9999;
182     lastEncumb = 9999;
183 
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);
187 
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,
191                      0, 0, 0);
192     if (!normalStyle)
193         normalStyle =
194             gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(titleLabel)));
195 
196     /* Set up some styles to draw stuff with */
197     if (!redStyle) {
198         g_assert(greenStyle == NULL);
199         g_assert(bigStyle == NULL);
200         g_assert(bigRedStyle == NULL);
201         g_assert(bigGreenStyle == NULL);
202 
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);
208 
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;
213 
214         gdk_font_unref(bigRedStyle->font);
215         gdk_font_unref(bigGreenStyle->font);
216         bigRedStyle->font =
217             gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
218         bigGreenStyle->font =
219             gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
220 
221         gdk_font_unref(bigStyle->font);
222         bigStyle->font =
223             gdk_font_load("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
224     }
225     gtk_widget_set_style(GTK_WIDGET(titleLabel), bigStyle);
226 
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,
230                      GTK_FILL, 0, 0, 0);
231     gtk_widget_set_style(GTK_WIDGET(dgnLevelLabel), bigStyle);
232 
233     /* Begin the third row */
234     horizSep0 = gtk_hseparator_new();
235     gtk_table_attach(GTK_TABLE(statTable), horizSep0, 0, 8, 2, 3, GTK_FILL,
236                      GTK_FILL, 0, 0);
237 
238     /* Begin the fourth row */
239     statsHBox = gtk_hbox_new(TRUE, 0);
240 
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,
247                        2);
248 
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,
255                        2);
256 
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,
263                        2);
264 
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,
271                        2);
272 
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,
279                        2);
280 
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,
287                        2);
288 
289     gtk_table_attach(GTK_TABLE(statTable), GTK_WIDGET(statsHBox), 0, 8, 3, 4,
290                      GTK_FILL, 0, 0, 0);
291 
292     /* Begin the fifth row */
293     horizSep1 = gtk_hseparator_new();
294     gtk_table_attach(GTK_TABLE(statTable), horizSep1, 0, 8, 4, 5, GTK_FILL,
295                      GTK_FILL, 0, 0);
296 
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,
300                      0, 0);
301 
302     acLabel = gtk_label_new("AC: ");
303     gtk_table_attach(GTK_TABLE(statTable), acLabel, 2, 3, 5, 6, GTK_FILL, 0,
304                      0, 0);
305 
306     powLabel = gtk_label_new("Power: ");
307     gtk_table_attach(GTK_TABLE(statTable), powLabel, 4, 5, 5, 6, GTK_FILL, 0,
308                      0, 0);
309 
310     goldLabel = gtk_label_new("Au: ");
311     gtk_table_attach(GTK_TABLE(statTable), goldLabel, 6, 7, 5, 6, GTK_FILL, 0,
312                      0, 0);
313 
314     /* Begin the seventh row */
315     horizSep2 = gtk_hseparator_new();
316     gtk_table_attach(GTK_TABLE(statTable), horizSep2, 0, 8, 6, 7, GTK_FILL,
317                      GTK_FILL, 0, 0);
318 
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,
322                      0, 0);
323 
324     expLabel = gtk_label_new("Exp: ");
325     gtk_table_attach(GTK_TABLE(statTable), expLabel, 2, 3, 7, 8, GTK_FILL, 0,
326                      0, 0);
327 
328     timeLabel = gtk_label_new("Time: ");
329     gtk_table_attach(GTK_TABLE(statTable), timeLabel, 4, 5, 7, 8, GTK_FILL, 0,
330                      0, 0);
331 
332     scoreLabel = gtk_label_new("Score: ");
333     gtk_table_attach(GTK_TABLE(statTable), scoreLabel, 6, 7, 7, 8, GTK_FILL,
334                      0, 0, 0);
335 
336     /* Begin the ninth row */
337     horizSep3 = gtk_hseparator_new();
338     gtk_table_attach(GTK_TABLE(statTable), horizSep3, 0, 8, 8, 9, GTK_FILL,
339                      GTK_FILL, 0, 0);
340 
341     /* Begin the tenth and last row */
342     statHBox = gtk_hbox_new(FALSE, 0);
343 
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,
350                        2);
351 
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,
358                        2);
359 
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,
366                        2);
367 
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,
374                        2);
375 
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,
382                        2);
383 
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,
390                        2);
391 
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,
398                        2);
399 
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,
406                        2);
407 
408     gtk_table_attach(GTK_TABLE(statTable), GTK_WIDGET(statHBox), 0, 8, 9, 10,
409                      GTK_FILL, GTK_FILL, 0, 0);
410 
411     /* Set up the necessary signals */
412     gtk_signal_connect(GTK_OBJECT(statTable), "ghack_fade_highlight",
413                        GTK_SIGNAL_FUNC(ghack_fade_highlighting), NULL);
414 
415     gtk_signal_connect(GTK_OBJECT(statTable), "ghack_putstr",
416                        GTK_SIGNAL_FUNC(ghack_status_window_put_string), NULL);
417 
418     gtk_signal_connect(GTK_OBJECT(statTable), "ghack_clear",
419                        GTK_SIGNAL_FUNC(ghack_status_window_clear), NULL);
420 
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);
425 
426     /* Lastly, show the status window and everything in it */
427     gtk_widget_show_all(statTable);
428 
429     return GTK_WIDGET(statTable);
430 }
431 
432 void
ghack_status_window_update_stats()433 ghack_status_window_update_stats()
434 {
435     char buf[BUFSZ];
436     gchar *buf1;
437     const char *hung;
438     const char *enc;
439     static int firstTime = TRUE;
440     long umoney;
441 
442     /* First, fill in the player name and the dungeon level */
443     strcpy(buf, g.plname);
444     if ('a' <= buf[0] && buf[0] <= 'z')
445         buf[0] += 'A' - 'a';
446     strcat(buf, " the ");
447     if (u.mtimedone) {
448         char mname[BUFSZ];
449         int k = 0;
450 
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';
456             }
457             k++;
458         }
459         strcat(buf, mname);
460     } else {
461         strcat(buf, rank_of(u.ulevel, pl_character[0], flags.female));
462     }
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);
467     }
468     gtk_label_set(GTK_LABEL(titleLabel), buf);
469 
470     if (In_endgame(&u.uz)) {
471         strcpy(buf, (Is_astralevel(&u.uz) ? "Astral Plane" : "End Game"));
472     } else {
473         sprintf(buf, "%s, level %d", dungeons[u.uz.dnum].dname, depth(&u.uz));
474     }
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);
481     }
482     lastDepth = depth(&u.uz);
483     gtk_label_set(GTK_LABEL(dgnLevelLabel), buf);
484 
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);
492     } else {
493         sprintf(buf, "STR:%d", ACURR(A_STR));
494     }
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);
501     }
502     lastStr = ACURR(A_STR);
503     gtk_label_set(GTK_LABEL(strLabel), buf);
504 
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);
512     }
513     lastInt = ACURR(A_INT);
514     gtk_label_set(GTK_LABEL(intLabel), buf);
515 
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);
523     }
524     lastWis = ACURR(A_WIS);
525     gtk_label_set(GTK_LABEL(wisLabel), buf);
526 
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);
534     }
535     lastDex = ACURR(A_DEX);
536     gtk_label_set(GTK_LABEL(dexLabel), buf);
537 
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);
545     }
546     lastCon = ACURR(A_CON);
547     gtk_label_set(GTK_LABEL(conLabel), buf);
548 
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);
556     }
557     lastCha = ACURR(A_CHA);
558     gtk_label_set(GTK_LABEL(chaLabel), buf);
559 
560     /* Now do the non-pixmaped stats (gold and such) */
561     umoney = money_cnt(g.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);
569     }
570     lastAu = umoney;
571     gtk_label_set(GTK_LABEL(goldLabel), buf);
572 
573     if (u.mtimedone) {
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);
583         }
584         lastHP = u.mh;
585         lastMHP = u.mhmax;
586     } else {
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);
595         }
596         lastHP = u.uhp;
597         lastMHP = u.uhpmax;
598     }
599     gtk_label_set(GTK_LABEL(hpLabel), buf);
600 
601     if (u.mtimedone) {
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);
610         }
611         lastLevel = mons[u.umonnum].mlevel;
612     } else {
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);
620         }
621         lastLevel = u.ulevel;
622     }
623     gtk_label_set(GTK_LABEL(levlLabel), buf);
624 
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);
629     }
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);
633     }
634     lastPOW = u.uen;
635     lastMPOW = u.uenmax;
636     gtk_label_set(GTK_LABEL(powLabel), buf);
637 
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);
645     }
646     lastAC = u.uac;
647     gtk_label_set(GTK_LABEL(acLabel), buf);
648 
649     if (flags.showexp) {
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);
657         }
658         lastExp = u.uexp;
659         gtk_label_set(GTK_LABEL(expLabel), buf);
660     } else {
661         gtk_label_set(GTK_LABEL(expLabel), "");
662     }
663 
664     if (flags.time) {
665         sprintf(buf, "Time:%ld", g.moves);
666         gtk_label_set(GTK_LABEL(timeLabel), buf);
667     } else
668         gtk_label_set(GTK_LABEL(timeLabel), "");
669 #ifdef SCORE_ON_BOTL
670     if (flags.showscore) {
671         sprintf(buf, "Score:%ld", botl_score());
672         gtk_label_set(GTK_LABEL(scoreLabel), buf);
673     } else
674         gtk_label_set(GTK_LABEL(scoreLabel), "");
675 #else
676     {
677         gtk_label_set(GTK_LABEL(scoreLabel), "");
678     }
679 #endif
680 
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);
686         }
687 
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);
696         } else {
697             gtk_label_set(GTK_LABEL(alignLabel), "Lawful");
698             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(alignPix), lawful_xpm);
699         }
700     }
701 
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);
707         }
708 
709         lastHungr = u.uhs;
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);
716         } else {
717             gtk_label_set(GTK_LABEL(hungerLabel), hung);
718             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(hungerPix), hungry_xpm);
719         }
720     }
721 
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);
726         }
727 
728         lastConf = Confusion;
729         if (Confusion) {
730             gtk_label_set(GTK_LABEL(confuLabel), "Confused");
731             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(confuPix), confused_xpm);
732         } else {
733             gtk_label_set(GTK_LABEL(confuLabel), "        ");
734             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(confuPix), nothing_xpm);
735         }
736     }
737 
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);
742         }
743 
744         lastBlind = Blind;
745         if (Blind) {
746             gtk_label_set(GTK_LABEL(blindLabel), "Blind");
747             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(blindPix), blind_xpm);
748         } else {
749             gtk_label_set(GTK_LABEL(blindLabel), "     ");
750             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(blindPix), nothing_xpm);
751         }
752     }
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);
757         }
758 
759         lastStun = Stunned;
760         if (Stunned) {
761             gtk_label_set(GTK_LABEL(stunLabel), "Stun");
762             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(stunPix), stunned_xpm);
763         } else {
764             gtk_label_set(GTK_LABEL(stunLabel), "    ");
765             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(stunPix), nothing_xpm);
766         }
767     }
768 
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);
773         }
774 
775         lastHalu = Hallucination;
776         if (Hallucination) {
777             gtk_label_set(GTK_LABEL(halluLabel), "Hallu");
778             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(halluPix), hallu_xpm);
779         } else {
780             gtk_label_set(GTK_LABEL(halluLabel), "     ");
781             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(halluPix), nothing_xpm);
782         }
783     }
784 
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);
789         }
790 
791         lastSick = Sick;
792         if (Sick) {
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);
799             } else {
800                 gtk_label_set(GTK_LABEL(sickLabel), "FoodPois");
801                 gnome_pixmap_load_xpm_d(GNOME_PIXMAP(sickPix), sick_fp_xpm);
802             }
803         } else {
804             gtk_label_set(GTK_LABEL(sickLabel), "        ");
805             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(sickPix), nothing_xpm);
806         }
807     }
808 
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);
814         }
815 
816         lastEncumb = near_capacity();
817         switch (lastEncumb) {
818         case 0:
819             gtk_label_set(GTK_LABEL(encumbLabel), "        ");
820             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix), nothing_xpm);
821             break;
822         case 1:
823             gtk_label_set(GTK_LABEL(encumbLabel), enc);
824             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix), slt_enc_xpm);
825             break;
826         case 2:
827             gtk_label_set(GTK_LABEL(encumbLabel), enc);
828             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix), mod_enc_xpm);
829             break;
830         case 3:
831             gtk_label_set(GTK_LABEL(encumbLabel), enc);
832             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix), hvy_enc_xpm);
833             break;
834         case 4:
835             gtk_label_set(GTK_LABEL(encumbLabel), enc);
836             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix), ext_enc_xpm);
837             break;
838         case 5:
839             gtk_label_set(GTK_LABEL(encumbLabel), enc);
840             gnome_pixmap_load_xpm_d(GNOME_PIXMAP(encumbPix), ovr_enc_xpm);
841         }
842     }
843     firstTime = FALSE;
844 }
845 
846 static void
ghack_fade_highlighting()847 ghack_fade_highlighting()
848 {
849     GList *item;
850     Highlight *highlt;
851 
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;
855         if (highlt) {
856             if (highlt->nTurnsLeft <= 0) {
857                 gtk_widget_set_style(GTK_WIDGET(highlt->widget),
858                                      highlt->oldStyle);
859                 s_HighLightList = g_list_remove_link(s_HighLightList, item);
860                 g_free(highlt);
861                 g_list_free_1(item);
862                 item = g_list_first(s_HighLightList);
863                 continue;
864             } else
865                 (highlt->nTurnsLeft)--;
866         }
867         if (item)
868             item = item->next;
869         else
870             break;
871     }
872 }
873 
874 /* Widget changed, so add it to the highlighing list */
875 static void
ghack_highlight_widget(GtkWidget * widget,GtkStyle * oldStyle,GtkStyle * newStyle)876 ghack_highlight_widget(GtkWidget *widget, GtkStyle *oldStyle,
877                        GtkStyle *newStyle)
878 {
879     Highlight *highlt;
880     GList *item;
881 
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;
886         if (highlt) {
887             if (highlt->widget == widget) {
888                 s_HighLightList = g_list_remove_link(s_HighLightList, item);
889                 g_free(highlt);
890                 g_list_free_1(item);
891                 break;
892             }
893         }
894         if (item)
895             item = item->next;
896         else
897             break;
898     }
899 
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);
908 }
909