1 /* SCCS Id: @(#)gnstatus.c 3.3 2000/07/16 */
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
11 extern const char *hu_stat[]; /* from eat.c */
12 extern const char *enc_stat[]; /* from botl.c */
13
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);
20
21 static void ghack_fade_highlighting();
22 static void ghack_highlight_widget( GtkWidget* widget, GtkStyle* oldStyle,
23 GtkStyle* newStyle);
24
25 /* some junk to handle when to fade the highlighting */
26 #define NUM_TURNS_HIGHLIGHTED 3
27
28 static GList *s_HighLightList;
29
30 typedef struct {
31 GtkWidget* widget;
32 GtkStyle* oldStyle;
33 int nTurnsLeft;
34 } Highlight;
35
36
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;
77
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
ghack_status_window_clear(GtkWidget * win,gpointer data)115 void ghack_status_window_clear( GtkWidget *win, gpointer data)
116 {
117 /* Don't think we need this at all */
118 }
119
ghack_status_window_destroy(GtkWidget * win,gpointer data)120 void ghack_status_window_destroy(GtkWidget *win, gpointer data)
121 {
122 while (s_HighLightList) {
123 g_free( (Highlight*)s_HighLightList->data);
124 s_HighLightList = s_HighLightList->next;
125 }
126 g_list_free( s_HighLightList );
127 }
128
ghack_status_window_display(GtkWidget * win,boolean block,gpointer data)129 void ghack_status_window_display( GtkWidget *win, boolean block, gpointer data)
130 {
131 gtk_widget_show_all( GTK_WIDGET(win));
132 }
133
ghack_status_window_cursor_to(GtkWidget * win,int x,int y,gpointer data)134 void ghack_status_window_cursor_to( GtkWidget *win, int x, int y, gpointer data)
135 {
136 /* Don't think we need this at all */
137 }
138
ghack_status_window_put_string(GtkWidget * win,int attr,const char * text,gpointer data)139 void ghack_status_window_put_string( GtkWidget *win, int attr, const char* text, gpointer data)
140 {
141 ghack_status_window_update_stats();
142 }
143
144
145
ghack_init_status_window()146 GtkWidget* ghack_init_status_window ()
147 {
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;
153
154 /* Set up a (ridiculous) initial state */
155 lastDepth = 9999;
156 lastStr = 9999;
157 lastInt = 9999;
158 lastWis = 9999;
159 lastDex = 9999;
160 lastCon = 9999;
161 lastCha = 9999;
162 lastAu = 9999;
163 lastHP = 9999;
164 lastMHP = 9999;
165 lastLevel = 9999;
166 lastPOW = 9999;
167 lastMPOW = 9999;
168 lastAC = 9999;
169 lastExp = 9999;
170 lastAlignment = A_NEUTRAL; /* start off guessing neutral */
171 lastHungr = 9999;
172 lastConf = 9999;
173 lastBlind = 9999;
174 lastStun = 9999;
175 lastHalu = 9999;
176 lastSick = 9999;
177 lastEncumb = 9999;
178
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);
182
183
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);
188 if (!normalStyle)
189 normalStyle = gtk_style_copy (
190 gtk_widget_get_style (GTK_WIDGET (titleLabel)));
191
192 /* Set up some styles to draw stuff with */
193 if (!redStyle) {
194 g_assert (greenStyle == NULL);
195 g_assert (bigStyle == NULL);
196 g_assert (bigRedStyle == NULL);
197 g_assert (bigGreenStyle == NULL);
198
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);
204
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;
209
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-*-*-*-*-*-*-*");
214
215 gdk_font_unref (bigStyle->font);
216 bigStyle->font = gdk_font_load ("-misc-fixed-*-*-*-*-20-*-*-*-*-*-*-*");
217 }
218 gtk_widget_set_style (GTK_WIDGET (titleLabel), bigStyle);
219
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);
225
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);
230
231
232 /* Begin the fourth row */
233 statsHBox = gtk_hbox_new (TRUE, 0);
234
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);
241
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);
248
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);
255
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);
262
263
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);
270
271
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);
278
279 gtk_table_attach( GTK_TABLE( statTable), GTK_WIDGET(statsHBox),
280 0, 8, 3, 4, GTK_FILL, 0, 0, 0);
281
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);
286
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);
291
292 acLabel = gtk_label_new( "AC: ");
293 gtk_table_attach( GTK_TABLE( statTable), acLabel,
294 2, 3, 5, 6, GTK_FILL, 0, 0, 0);
295
296 powLabel = gtk_label_new( "Power: ");
297 gtk_table_attach( GTK_TABLE( statTable), powLabel,
298 4, 5, 5, 6, GTK_FILL, 0, 0, 0);
299
300 goldLabel = gtk_label_new( "Au: ");
301 gtk_table_attach( GTK_TABLE( statTable), goldLabel,
302 6, 7, 5, 6, GTK_FILL, 0, 0, 0);
303
304
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);
309
310
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);
315
316 expLabel = gtk_label_new( "Exp: ");
317 gtk_table_attach( GTK_TABLE( statTable), expLabel,
318 2, 3, 7, 8, GTK_FILL, 0, 0, 0);
319
320 timeLabel = gtk_label_new( "Time: ");
321 gtk_table_attach( GTK_TABLE( statTable), timeLabel,
322 4, 5, 7, 8, GTK_FILL, 0, 0, 0);
323
324 scoreLabel = gtk_label_new( "Score: ");
325 gtk_table_attach( GTK_TABLE( statTable), scoreLabel,
326 6, 7, 7, 8, GTK_FILL, 0, 0, 0);
327
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);
332
333 /* Begin the tenth and last row */
334 statHBox = gtk_hbox_new (FALSE, 0);
335
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);
342
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);
349
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);
356
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);
363
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);
370
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);
377
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);
384
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);
391
392 gtk_table_attach( GTK_TABLE( statTable), GTK_WIDGET(statHBox),
393 0, 8, 9, 10, GTK_FILL, GTK_FILL, 0, 0);
394
395 /* Set up the necessary signals */
396 gtk_signal_connect (GTK_OBJECT (statTable),
397 "ghack_fade_highlight",
398 GTK_SIGNAL_FUNC (ghack_fade_highlighting),
399 NULL);
400
401 gtk_signal_connect (GTK_OBJECT (statTable),
402 "ghack_putstr",
403 GTK_SIGNAL_FUNC (ghack_status_window_put_string),
404 NULL);
405
406 gtk_signal_connect (GTK_OBJECT (statTable),
407 "ghack_clear",
408 GTK_SIGNAL_FUNC (ghack_status_window_clear),
409 NULL);
410
411 gtk_signal_connect (GTK_OBJECT (statTable),
412 "ghack_curs",
413 GTK_SIGNAL_FUNC (ghack_status_window_cursor_to),
414 NULL);
415 gtk_signal_connect(GTK_OBJECT (statTable),
416 "gnome_delay_output",
417 GTK_SIGNAL_FUNC(ghack_delay),
418 NULL);
419
420 /* Lastly, show the status window and everything in it */
421 gtk_widget_show_all( statTable);
422
423 return GTK_WIDGET(statTable);
424 }
425
426
427
ghack_status_window_update_stats()428 void ghack_status_window_update_stats()
429 {
430 char buf[BUFSZ];
431 gchar *buf1;
432 const char* hung;
433 const char* enc;
434 static int firstTime=TRUE;
435
436 /* First, fill in the player name and the dungeon level */
437 strcpy(buf, plname);
438 if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a';
439 strcat(buf, " the ");
440 if (u.mtimedone) {
441 char mname[BUFSZ];
442 int k = 0;
443
444 strcpy(mname, mons[u.umonnum].mname);
445 while(mname[k] != 0) {
446 if ((k == 0 || (k > 0 && mname[k-1] == ' '))
447 && 'a' <= mname[k] && mname[k] <= 'z')
448 {
449 mname[k] += 'A' - 'a';
450 }
451 k++;
452 }
453 strcat(buf, mname);
454 } else {
455 strcat(buf, rank_of(u.ulevel, pl_character[0], flags.female));
456 }
457 gtk_label_get( GTK_LABEL( titleLabel), &buf1);
458 if (strcmp( buf1, buf) != 0 && firstTime==FALSE) {
459 /* Ok, this changed so add it to the highlighing list */
460 ghack_highlight_widget( titleLabel, bigStyle, bigGreenStyle);
461 }
462 gtk_label_set( GTK_LABEL( titleLabel), buf);
463
464
465 if (In_endgame(&u.uz)) {
466 strcpy(buf, (Is_astralevel(&u.uz) ? "Astral Plane":"End Game"));
467 } else {
468 sprintf(buf, "%s, level %d", dungeons[u.uz.dnum].dname, depth(&u.uz));
469 }
470 if (lastDepth > depth(&u.uz) && firstTime==FALSE) {
471 /* Ok, this changed so add it to the highlighing list */
472 ghack_highlight_widget( dgnLevelLabel, bigStyle, bigRedStyle);
473 }
474 else if (lastDepth < depth(&u.uz) && firstTime==FALSE) {
475 /* Ok, this changed so add it to the highlighing list */
476 ghack_highlight_widget( dgnLevelLabel, bigStyle, bigGreenStyle);
477 }
478 lastDepth = depth(&u.uz);
479 gtk_label_set( GTK_LABEL( dgnLevelLabel), buf);
480
481 /* Next, fill in the player's stats */
482 if (ACURR(A_STR) > 118) {
483 sprintf(buf,"STR:%d",ACURR(A_STR)-100);
484 } else if (ACURR(A_STR)==118) {
485 sprintf(buf,"STR:18/**");
486 } else if(ACURR(A_STR) > 18) {
487 sprintf(buf,"STR:18/%02d",ACURR(A_STR)-18);
488 } else {
489 sprintf(buf,"STR:%d",ACURR(A_STR));
490 }
491 if (lastStr < ACURR(A_STR) && firstTime==FALSE) {
492 /* Ok, this changed so add it to the highlighing list */
493 ghack_highlight_widget( strLabel, normalStyle, greenStyle);
494 }
495 else if (lastStr > ACURR(A_STR) && firstTime==FALSE) {
496 /* Ok, this changed so add it to the highlighing list */
497 ghack_highlight_widget( strLabel, normalStyle, redStyle);
498 }
499 lastStr = ACURR(A_STR);
500 gtk_label_set( GTK_LABEL( strLabel), buf);
501
502 sprintf(buf,"INT:%d",ACURR(A_INT));
503 if (lastInt < ACURR(A_INT) && firstTime==FALSE) {
504 /* Ok, this changed so add it to the highlighing list */
505 ghack_highlight_widget( intLabel, normalStyle, greenStyle);
506 }
507 else if (lastInt > ACURR(A_INT) && firstTime==FALSE) {
508 /* Ok, this changed so add it to the highlighing list */
509 ghack_highlight_widget( intLabel, normalStyle, redStyle);
510 }
511 lastInt = ACURR(A_INT);
512 gtk_label_set( GTK_LABEL( intLabel), buf);
513
514 sprintf(buf,"WIS:%d",ACURR(A_WIS));
515 if (lastWis < ACURR(A_WIS) && firstTime==FALSE) {
516 /* Ok, this changed so add it to the highlighing list */
517 ghack_highlight_widget( wisLabel, normalStyle, greenStyle);
518 }
519 else if (lastWis > ACURR(A_WIS) && firstTime==FALSE) {
520 /* Ok, this changed so add it to the highlighing list */
521 ghack_highlight_widget( wisLabel, normalStyle, redStyle);
522 }
523 lastWis = ACURR(A_WIS);
524 gtk_label_set( GTK_LABEL( wisLabel), buf);
525
526 sprintf(buf,"DEX:%d",ACURR(A_DEX));
527 if (lastDex < ACURR(A_DEX) && firstTime==FALSE) {
528 /* Ok, this changed so add it to the highlighing list */
529 ghack_highlight_widget( dexLabel, normalStyle, greenStyle);
530 }
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 }
543 else if (lastCon > ACURR(A_CON) && firstTime==FALSE) {
544 /* Ok, this changed so add it to the highlighing list */
545 ghack_highlight_widget( conLabel, normalStyle, redStyle);
546 }
547 lastCon = ACURR(A_CON);
548 gtk_label_set( GTK_LABEL( conLabel), buf);
549
550 sprintf(buf,"CHA:%d",ACURR(A_CHA));
551 if (lastCha < ACURR(A_CHA) && firstTime==FALSE) {
552 /* Ok, this changed so add it to the highlighing list */
553 ghack_highlight_widget( chaLabel, normalStyle, greenStyle);
554 }
555 else if (lastCha > ACURR(A_CHA) && firstTime==FALSE) {
556 /* Ok, this changed so add it to the highlighing list */
557 ghack_highlight_widget( chaLabel, normalStyle, redStyle);
558 }
559 lastCha = ACURR(A_CHA);
560 gtk_label_set( GTK_LABEL( chaLabel), buf);
561
562 /* Now do the non-pixmaped stats (gold and such) */
563 sprintf(buf,"Au:%ld", u.ugold);
564 if (lastAu < u.ugold && firstTime==FALSE) {
565 /* Ok, this changed so add it to the highlighing list */
566 ghack_highlight_widget( goldLabel, normalStyle, greenStyle);
567 }
568 else if (lastAu > u.ugold && firstTime==FALSE) {
569 /* Ok, this changed so add it to the highlighing list */
570 ghack_highlight_widget( goldLabel, normalStyle, redStyle);
571 }
572 lastAu = u.ugold;
573 gtk_label_set( GTK_LABEL( goldLabel), buf);
574
575 if (u.mtimedone) {
576 /* special case: when polymorphed, show "HD", disable exp */
577 sprintf(buf,"HP:%d/%d", ( (u.mh > 0)? u.mh : 0), u.mhmax);
578 if ((lastHP < u.mh || lastMHP < u.mhmax ) && firstTime==FALSE) {
579 /* Ok, this changed so add it to the highlighing list */
580 ghack_highlight_widget( hpLabel, normalStyle, greenStyle);
581 }
582 else if ((lastHP > u.mh || lastMHP > u.mhmax ) && firstTime==FALSE) {
583 /* Ok, this changed so add it to the highlighing list */
584 ghack_highlight_widget( hpLabel, normalStyle, redStyle);
585 }
586 lastHP = u.mh;
587 lastMHP = u.mhmax;
588 } else {
589 sprintf(buf,"HP:%d/%d", ( (u.uhp > 0)? u.uhp : 0), u.uhpmax);
590 if ((lastHP < u.uhp || lastMHP < u.uhpmax ) && firstTime==FALSE) {
591 /* Ok, this changed so add it to the highlighing list */
592 ghack_highlight_widget( hpLabel, normalStyle, greenStyle);
593 }
594 else if ((lastHP > u.uhp || lastMHP > u.uhpmax ) && firstTime==FALSE) {
595 /* Ok, this changed so add it to the highlighing list */
596 ghack_highlight_widget( hpLabel, normalStyle, redStyle);
597 }
598 lastHP = u.uhp;
599 lastMHP = u.uhpmax;
600 }
601 gtk_label_set( GTK_LABEL( hpLabel), buf);
602
603 if (u.mtimedone) {
604 /* special case: when polymorphed, show "HD", disable exp */
605 sprintf(buf,"HD:%d", mons[u.umonnum].mlevel);
606 if (lastLevel < mons[u.umonnum].mlevel && firstTime==FALSE) {
607 /* Ok, this changed so add it to the highlighing list */
608 ghack_highlight_widget( levlLabel, normalStyle, greenStyle);
609 }
610 else if (lastLevel > mons[u.umonnum].mlevel && firstTime==FALSE) {
611 /* Ok, this changed so add it to the highlighing list */
612 ghack_highlight_widget( levlLabel, normalStyle, redStyle);
613 }
614 lastLevel = mons[u.umonnum].mlevel;
615 } else {
616 sprintf(buf,"Level:%d", u.ulevel);
617 if (lastLevel < u.ulevel && firstTime==FALSE) {
618 /* Ok, this changed so add it to the highlighing list */
619 ghack_highlight_widget( levlLabel, normalStyle, greenStyle);
620 }
621 else if (lastLevel > u.ulevel && firstTime==FALSE) {
622 /* Ok, this changed so add it to the highlighing list */
623 ghack_highlight_widget( levlLabel, normalStyle, redStyle);
624 }
625 lastLevel = u.ulevel;
626 }
627 gtk_label_set( GTK_LABEL( levlLabel), buf);
628
629 sprintf(buf,"Power:%d/%d", u.uen, u.uenmax);
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, greenStyle);
633 }
634 if ((lastPOW > u.uen || lastMPOW > u.uenmax) && firstTime==FALSE) {
635 /* Ok, this changed so add it to the highlighing list */
636 ghack_highlight_widget( powLabel, normalStyle, redStyle);
637 }
638 lastPOW = u.uen;
639 lastMPOW = u.uenmax;
640 gtk_label_set( GTK_LABEL( powLabel), buf);
641
642 sprintf(buf,"AC:%d", u.uac);
643 if (lastAC > u.uac && firstTime==FALSE) {
644 /* Ok, this changed so add it to the highlighing list */
645 ghack_highlight_widget( acLabel, normalStyle, greenStyle);
646 }
647 else if (lastAC < u.uac && firstTime==FALSE) {
648 /* Ok, this changed so add it to the highlighing list */
649 ghack_highlight_widget( acLabel, normalStyle, redStyle);
650 }
651 lastAC = u.uac;
652 gtk_label_set( GTK_LABEL( acLabel), buf);
653
654 #ifdef EXP_ON_BOTL
655 if (flags.showexp) {
656 sprintf(buf,"Exp:%ld", u.uexp);
657 if (lastExp < u.uexp && firstTime==FALSE) {
658 /* Ok, this changed so add it to the highlighing list */
659 ghack_highlight_widget( expLabel, normalStyle, greenStyle);
660 }
661 else if (lastExp > u.uexp && firstTime==FALSE) {
662 /* Ok, this changed so add it to the highlighing list */
663 ghack_highlight_widget( expLabel, normalStyle, redStyle);
664 }
665 lastExp = u.uexp;
666 gtk_label_set( GTK_LABEL( expLabel), buf);
667 } else
668 #endif
669 {
670 gtk_label_set( GTK_LABEL( expLabel), "");
671 }
672
673 if (flags.time) {
674 sprintf(buf,"Time:%ld", moves);
675 gtk_label_set( GTK_LABEL( timeLabel), buf);
676 }
677 else
678 gtk_label_set( GTK_LABEL( timeLabel), "");
679 #ifdef SCORE_ON_BOTL
680 if (flags.showscore) {
681 sprintf(buf,"Score:%ld", botl_score());
682 gtk_label_set( GTK_LABEL( scoreLabel), buf);
683 } else
684 gtk_label_set( GTK_LABEL( scoreLabel), "");
685 #else
686 {
687 gtk_label_set( GTK_LABEL( scoreLabel), "");
688 }
689 #endif
690
691 /* See if their alignment has changed */
692 if (lastAlignment != u.ualign.type) {
693 if (firstTime==FALSE) {
694 /* Ok, this changed so add it to the highlighing list */
695 ghack_highlight_widget( alignLabel, normalStyle, redStyle);
696 }
697
698 lastAlignment = u.ualign.type;
699 /* looks like their alignment has changed -- change out the icon */
700 if (u.ualign.type==A_CHAOTIC) {
701 gtk_label_set( GTK_LABEL( alignLabel), "Chaotic");
702 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(alignPix), chaotic_xpm);
703 } else if (u.ualign.type==A_NEUTRAL) {
704 gtk_label_set( GTK_LABEL( alignLabel), "Neutral");
705 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(alignPix), neutral_xpm);
706 } else {
707 gtk_label_set( GTK_LABEL( alignLabel), "Lawful");
708 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(alignPix), lawful_xpm);
709 }
710 }
711
712 hung=hu_stat[u.uhs];
713 if (lastHungr != u.uhs) {
714 if (firstTime==FALSE) {
715 /* Ok, this changed so add it to the highlighing list */
716 ghack_highlight_widget( hungerLabel, normalStyle, redStyle);
717 }
718
719 lastHungr = u.uhs;
720 if (hung[0]==' ') {
721 gtk_label_set( GTK_LABEL( hungerLabel), " ");
722 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(hungerPix), nothing_xpm);
723 } else
724 if (u.uhs == 0 /* SATIATED */) {
725 gtk_label_set( GTK_LABEL( hungerLabel), hung);
726 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(hungerPix), satiated_xpm);
727 } else {
728 gtk_label_set( GTK_LABEL( hungerLabel), hung);
729 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(hungerPix), hungry_xpm);
730 }
731 }
732
733 if (lastConf != Confusion) {
734 if (firstTime==FALSE) {
735 /* Ok, this changed so add it to the highlighing list */
736 ghack_highlight_widget( confuLabel, normalStyle, redStyle);
737 }
738
739 lastConf = Confusion;
740 if (Confusion) {
741 gtk_label_set( GTK_LABEL( confuLabel), "Confused");
742 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(confuPix), confused_xpm);
743 }
744 else {
745 gtk_label_set( GTK_LABEL( confuLabel), " ");
746 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(confuPix), nothing_xpm);
747 }
748 }
749
750 if (lastBlind != Blind) {
751 if (firstTime==FALSE) {
752 /* Ok, this changed so add it to the highlighing list */
753 ghack_highlight_widget( blindLabel, normalStyle, redStyle);
754 }
755
756 lastBlind = Blind;
757 if (Blind) {
758 gtk_label_set( GTK_LABEL( blindLabel), "Blind");
759 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(blindPix), blind_xpm);
760 }
761 else {
762 gtk_label_set( GTK_LABEL( blindLabel), " ");
763 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(blindPix), nothing_xpm);
764 }
765 }
766 if (lastStun != Stunned) {
767 if (firstTime==FALSE) {
768 /* Ok, this changed so add it to the highlighing list */
769 ghack_highlight_widget( stunLabel, normalStyle, redStyle);
770 }
771
772 lastStun = Stunned;
773 if (Stunned) {
774 gtk_label_set( GTK_LABEL( stunLabel), "Stun");
775 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(stunPix), stunned_xpm);
776 }
777 else {
778 gtk_label_set( GTK_LABEL( stunLabel), " ");
779 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(stunPix), nothing_xpm);
780 }
781 }
782
783 if (lastHalu != Hallucination) {
784 if (firstTime==FALSE) {
785 /* Ok, this changed so add it to the highlighing list */
786 ghack_highlight_widget( halluLabel, normalStyle, redStyle);
787 }
788
789 lastHalu = Hallucination;
790 if (Hallucination) {
791 gtk_label_set( GTK_LABEL( halluLabel), "Hallu");
792 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(halluPix), hallu_xpm);
793 }
794 else {
795 gtk_label_set( GTK_LABEL( halluLabel), " ");
796 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(halluPix), nothing_xpm);
797 }
798 }
799
800 if (lastSick != Sick) {
801 if (firstTime==FALSE) {
802 /* Ok, this changed so add it to the highlighing list */
803 ghack_highlight_widget( sickLabel, normalStyle, redStyle);
804 }
805
806 lastSick = Sick;
807 if (Sick) {
808 if (u.usick_type & SICK_VOMITABLE) {
809 gtk_label_set( GTK_LABEL( sickLabel), "FoodPois");
810 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(sickPix), sick_fp_xpm);
811 } else if (u.usick_type & SICK_NONVOMITABLE) {
812 gtk_label_set( GTK_LABEL( sickLabel), "Ill");
813 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(sickPix), sick_il_xpm);
814 } else {
815 gtk_label_set( GTK_LABEL( sickLabel), "FoodPois");
816 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(sickPix), sick_fp_xpm);
817 }
818 } else {
819 gtk_label_set( GTK_LABEL( sickLabel), " ");
820 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(sickPix), nothing_xpm);
821 }
822 }
823
824 enc=enc_stat[near_capacity()];
825 if (lastEncumb != near_capacity()) {
826 if (firstTime==FALSE) {
827 /* Ok, this changed so add it to the highlighing list */
828 ghack_highlight_widget( encumbLabel, normalStyle, redStyle);
829 }
830
831 lastEncumb = near_capacity();
832 switch ( lastEncumb ) {
833 case 0:
834 gtk_label_set( GTK_LABEL( encumbLabel), " ");
835 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), nothing_xpm);
836 break;
837 case 1:
838 gtk_label_set( GTK_LABEL( encumbLabel), enc);
839 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), slt_enc_xpm);
840 break;
841 case 2:
842 gtk_label_set( GTK_LABEL( encumbLabel), enc);
843 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), mod_enc_xpm);
844 break;
845 case 3:
846 gtk_label_set( GTK_LABEL( encumbLabel), enc);
847 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), hvy_enc_xpm);
848 break;
849 case 4:
850 gtk_label_set( GTK_LABEL( encumbLabel), enc);
851 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), ext_enc_xpm);
852 break;
853 case 5:
854 gtk_label_set( GTK_LABEL( encumbLabel), enc);
855 gnome_pixmap_load_xpm_d( GNOME_PIXMAP(encumbPix), ovr_enc_xpm);
856 }
857 }
858 firstTime=FALSE;
859 }
860
ghack_fade_highlighting()861 static void ghack_fade_highlighting()
862 {
863 GList *item;
864 Highlight *highlt;
865
866 /* Remove any items from the queue if their time is up */
867 for (item = g_list_first( s_HighLightList) ; item ; ) {
868 highlt = (Highlight*) item->data;
869 if (highlt) {
870 if ( highlt->nTurnsLeft <= 0) {
871 gtk_widget_set_style( GTK_WIDGET( highlt->widget),
872 highlt->oldStyle);
873 s_HighLightList = g_list_remove_link(s_HighLightList, item);
874 g_free( highlt);
875 g_list_free_1( item);
876 item = g_list_first( s_HighLightList);
877 continue;
878 } else
879 (highlt->nTurnsLeft)--;
880 }
881 if (item)
882 item=item->next;
883 else
884 break;
885 }
886 }
887
888 /* Widget changed, so add it to the highlighing list */
ghack_highlight_widget(GtkWidget * widget,GtkStyle * oldStyle,GtkStyle * newStyle)889 static void ghack_highlight_widget( GtkWidget* widget, GtkStyle* oldStyle,
890 GtkStyle* newStyle)
891 {
892 Highlight *highlt;
893 GList *item;
894
895 /* Check if this widget is already in the queue. If so then
896 * remove it, so we will only have the new entry in the queue */
897 for (item = g_list_first( s_HighLightList) ; item ; ) {
898 highlt = (Highlight*) item->data;
899 if (highlt) {
900 if ( highlt->widget == widget) {
901 s_HighLightList = g_list_remove_link(s_HighLightList, item);
902 g_free( highlt);
903 g_list_free_1( item);
904 break;
905 }
906 }
907 if (item)
908 item=item->next;
909 else
910 break;
911 }
912
913 /* Ok, now highlight this widget and add it into the fade
914 * highlighting queue */
915 highlt = g_new( Highlight, 1);
916 highlt->nTurnsLeft=NUM_TURNS_HIGHLIGHTED;
917 highlt->oldStyle=oldStyle;
918 highlt->widget=widget;
919 s_HighLightList = g_list_prepend (s_HighLightList, highlt);
920 gtk_widget_set_style( GTK_WIDGET( widget), newStyle);
921
922 }
923
924
925