Changeset 985
- Timestamp:
- 07/12/08 02:11:37 (2 months ago)
- Files:
-
- trunk/src/gtk/main-gtk.c (modified) (6 diffs)
- trunk/src/gtk/main-gtk.h (modified) (3 diffs)
- trunk/src/xtra3.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/gtk/main-gtk.c
r984 r985 656 656 657 657 /* Save the game */ 658 #ifdef ZANGBAND659 do_cmd_save_game(FALSE);660 #else661 658 do_cmd_save_game(); 662 #endif663 659 } 664 660 … … 2416 2412 FREE(race_count); 2417 2413 } 2418 static byte monst_color(const monster_type *m_ptr)2419 {2420 byte attr = TERM_WHITE;2421 int pct = 0;2422 2423 if (m_ptr->maxhp)2424 pct = (m_ptr->hp * 100) / m_ptr->maxhp;2425 2426 2427 /* Badly wounded */2428 if (pct >= 10) attr = TERM_L_RED;2429 2430 /* Wounded */2431 if (pct >= 25) attr = TERM_ORANGE;2432 2433 /* Somewhat Wounded */2434 if (pct >= 60) attr = TERM_YELLOW;2435 2436 /* Healthy */2437 if (pct >= 100) attr = TERM_L_GREEN;2438 2439 2440 /* Afraid */2441 if (m_ptr->monfear) attr = TERM_VIOLET;2442 2443 /* Confused */2444 if (m_ptr->confused) attr = TERM_UMBER;2445 2446 /* Stunned */2447 if (m_ptr->stunned) attr = TERM_L_BLUE;2448 2449 /* Asleep */2450 if (m_ptr->csleep) attr = TERM_BLUE;2451 2452 return attr;2453 }2454 2414 2455 2415 static void draw_xtra_cr_text(xtra_win_data *xd, int x, int y, byte color, cptr str) … … 2541 2501 static void handle_sidebar(game_event_type type, game_event_data *data, void *user) 2542 2502 { 2543 char str[80], str2[80]; 2544 byte color; 2503 char str[80]/*, str2[80]*/; 2545 2504 cairo_rectangle_t r; 2546 2505 … … 2548 2507 long xp = (long)p_ptr->exp; 2549 2508 monster_type *m_ptr = &mon_list[p_ptr->health_who]; 2550 int sidebar_length = 12;2509 int i = 0, sidebar_length = 12; 2551 2510 2552 2511 /* Calculate XP for next level */ … … 2577 2536 2578 2537 /* Char Level */ 2579 strnfmt(str, sizeof(str), "Level:"); 2580 strnfmt(str2, sizeof(str2), "%i", p_ptr->lev); 2581 cr_aligned_text_print(xd, 0, 4, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2538 strnfmt(str, sizeof(str), "%i", p_ptr->lev); 2539 cr_aligned_text_print(xd, 0, 4, sidebar_text[4], TERM_WHITE, str, TERM_L_GREEN, sidebar_length); 2582 2540 2583 2541 /* Char xp */ 2584 2542 if (p_ptr->lev != 50) 2585 strnfmt(s tr, sizeof(str), "Next: ");2543 strnfmt(sidebar_text[5], sizeof(str), "Next: "); 2586 2544 else 2587 strnfmt(s tr, sizeof(str), "XP: ");2588 strnfmt(str 2, sizeof(str2), "%ld", xp);2589 cr_aligned_text_print(xd, 0, 5, s tr, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length);2545 strnfmt(sidebar_text[5], sizeof(str), "XP: "); 2546 strnfmt(str, sizeof(str), "%ld", xp); 2547 cr_aligned_text_print(xd, 0, 5, sidebar_text[5], TERM_WHITE, str, TERM_L_GREEN, sidebar_length); 2590 2548 2591 2549 /* Char Gold */ 2592 strnfmt(str, sizeof(str), "Gold:"); 2593 strnfmt(str2, sizeof(str2), "%ld", p_ptr->au); 2594 cr_aligned_text_print(xd, 0, 6, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2550 strnfmt(str, sizeof(str), "%ld", p_ptr->au); 2551 cr_aligned_text_print(xd, 0, 6, sidebar_text[6], TERM_WHITE, str, TERM_L_GREEN, sidebar_length); 2595 2552 2596 2553 /* Equippy chars is 0,7 */ … … 2598 2555 2599 2556 /* Char Stats */ 2600 strnfmt(str, sizeof(str), "STR:"); 2601 cnv_stat(p_ptr->stat_use[A_STR], str2, sizeof(str2)); 2602 cr_aligned_text_print(xd, 0, 8, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2603 2604 strnfmt(str, sizeof(str), "INT:"); 2605 cnv_stat(p_ptr->stat_use[A_INT], str2, sizeof(str2)); 2606 cr_aligned_text_print(xd, 0, 9, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2607 2608 strnfmt(str, sizeof(str), "WIS:"); 2609 cnv_stat(p_ptr->stat_use[A_WIS], str2, sizeof(str2)); 2610 cr_aligned_text_print(xd, 0, 10, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2611 2612 strnfmt(str, sizeof(str), "DEX:"); 2613 cnv_stat(p_ptr->stat_use[A_DEX], str2, sizeof(str2)); 2614 cr_aligned_text_print(xd, 0, 11, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2615 2616 strnfmt(str, sizeof(str), "CON:"); 2617 cnv_stat(p_ptr->stat_use[A_CON], str2, sizeof(str2)); 2618 cr_aligned_text_print(xd, 0, 12, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2619 2620 strnfmt(str, sizeof(str), "CHR:"); 2621 cnv_stat(p_ptr->stat_use[A_CHR], str2, sizeof(str2)); 2622 cr_aligned_text_print(xd, 0, 13, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2557 for (i = A_STR; i <= A_CHR; i++) 2558 { 2559 cnv_stat(p_ptr->stat_use[i], str, sizeof(str)); 2560 cr_aligned_text_print(xd, 0, i+8, sidebar_text[i+8], TERM_WHITE, str, TERM_L_GREEN, sidebar_length); 2561 } 2623 2562 2624 2563 /* 14 is a blank row */ 2625 2564 2626 2565 /* Char AC */ 2627 strnfmt(str, sizeof(str), "AC:"); 2628 strnfmt(str2, sizeof(str2), "%i", p_ptr->dis_ac + p_ptr->dis_to_a); 2629 cr_aligned_text_print(xd, 0, 15, str, TERM_WHITE, str2, TERM_L_GREEN, sidebar_length); 2566 strnfmt(str, sizeof(str), "%i", p_ptr->dis_ac + p_ptr->dis_to_a); 2567 cr_aligned_text_print(xd, 0, 15, sidebar_text[15], TERM_WHITE, str, TERM_L_GREEN, sidebar_length); 2630 2568 2631 2569 /* Char HP */ 2632 strnfmt(str, sizeof(str), "HP:"); 2633 strnfmt(str2, sizeof(str2), "%4d/%4d", p_ptr->chp, p_ptr->mhp); 2634 if (p_ptr->chp >= p_ptr->mhp) 2635 color = TERM_L_GREEN; 2636 else if (p_ptr->chp > (p_ptr->mhp * op_ptr->hitpoint_warn) / 10) 2637 color = TERM_YELLOW; 2638 else 2639 color = TERM_RED; 2640 2641 cr_aligned_text_print(xd, 0, 16, str, TERM_WHITE, str2, color, sidebar_length); 2642 xtra_drawn_progress_bar(xd, 0, 17, p_ptr->chp, p_ptr->mhp, color, 13); 2570 strnfmt(str, sizeof(str), "%4d/%4d", p_ptr->chp, p_ptr->mhp); 2571 cr_aligned_text_print(xd, 0, 16, sidebar_text[16], TERM_WHITE, str, player_hp_attr(), sidebar_length); 2572 xtra_drawn_progress_bar(xd, 0, 17, p_ptr->chp, p_ptr->mhp, player_hp_attr(), 13); 2643 2573 2644 2574 /* Char MP */ 2645 strnfmt(str, sizeof(str), "SP:"); 2646 strnfmt(str2, sizeof(str2), "%4d/%4d", p_ptr->csp, p_ptr->msp); 2647 if (p_ptr->csp >= p_ptr->msp) 2648 color = TERM_L_GREEN; 2649 else if (p_ptr->csp > (p_ptr->msp * op_ptr->hitpoint_warn) / 10) 2650 color = TERM_YELLOW; 2651 else 2652 color = TERM_RED; 2653 cr_aligned_text_print(xd, 0, 18, str, TERM_WHITE, str2, color, sidebar_length); 2654 2655 xtra_drawn_progress_bar(xd, 0, 19, p_ptr->csp, p_ptr->msp, color, 13); 2575 strnfmt(str, sizeof(str), "%4d/%4d", p_ptr->csp, p_ptr->msp); 2576 cr_aligned_text_print(xd, 0, 18,sidebar_text[18], TERM_WHITE, str, player_sp_attr(), sidebar_length); 2577 xtra_drawn_progress_bar(xd, 0, 19, p_ptr->csp, p_ptr->msp, player_sp_attr(), 13); 2656 2578 2657 2579 /* 20 is blank */ 2658 2580 2659 xtra_drawn_progress_bar(xd, 0, 21, m_ptr->hp, m_ptr->maxhp, monst _color(m_ptr), 13);2581 xtra_drawn_progress_bar(xd, 0, 21, m_ptr->hp, m_ptr->maxhp, monster_health_attr(), 13); 2660 2582 2661 2583 /* Print the level */ 2662 2584 strnfmt(str, sizeof(str), "%d' (L%d)", p_ptr->depth * 50, p_ptr->depth); 2663 strnfmt(s tr2, sizeof(str2), "%-*s", sidebar_length, str);2664 draw_xtra_cr_text(xd, 0, 22, TERM_WHITE, s tr2);2585 strnfmt(sidebar_text[22], sizeof(sidebar_text[22]), "%-*s", sidebar_length, str); 2586 draw_xtra_cr_text(xd, 0, 22, TERM_WHITE, sidebar_text[22]); 2665 2587 2666 2588 invalidate_drawing_area(xd->drawing_area, r); trunk/src/gtk/main-gtk.h
r984 r985 126 126 char xtra_font_button_names[MAX_XTRA_WIN_DATA][20] = 127 127 { "message_font", "inv_font", "equip_font", "monst_list_font", "debug_font", "status_font" }; 128 129 char sidebar_text[24][20] = 130 { 131 "","","","","Level:", "XP: ", "Gold:", "", "STR:", "INT:", "WIS:", "DEX:", "CON:", "CHR:", "", "AC:", "HP:", "", "SP:", "", "","", "", "" 132 }; 128 133 /* 129 134 * An array of "term_data" structures, one for each "sub-window" … … 400 405 static void handle_mons_list(game_event_type type, game_event_data *data, void *user); 401 406 402 /* Return the color of the monster bar */403 static byte monst_color(const monster_type *m_ptr);404 405 407 /* Print the sidebar */ 406 408 static void handle_sidebar(game_event_type type, game_event_data *data, void *user); … … 429 431 430 432 static void force_redraw(); 433 434 /* From xtra3.h */ 435 extern byte monster_health_attr(); 436 extern byte player_sp_attr(); 437 extern byte player_hp_attr(); 431 438 #endif /* INCLUDED_MAIN_GTK_H */ trunk/src/xtra3.c
r979 r985 275 275 } 276 276 277 /* 278 * Calculate the hp color separately, for ports. 279 */ 280 byte player_hp_attr() 281 { 282 byte attr; 283 284 if (p_ptr->chp >= p_ptr->mhp) 285 attr = TERM_L_GREEN; 286 else if (p_ptr->chp > (p_ptr->mhp * op_ptr->hitpoint_warn) / 10) 287 attr = TERM_YELLOW; 288 else 289 attr = TERM_RED; 290 291 return attr; 292 } 277 293 278 294 /* … … 282 298 { 283 299 char cur_hp[32], max_hp[32]; 284 byte color ;300 byte color = player_hp_attr(); 285 301 286 302 put_str("HP ", row, col); … … 288 304 strnfmt(max_hp, sizeof(max_hp), "%4d", p_ptr->mhp); 289 305 strnfmt(cur_hp, sizeof(cur_hp), "%4d", p_ptr->chp); 290 291 if (p_ptr->chp >= p_ptr->mhp) 292 color = TERM_L_GREEN; 293 else if (p_ptr->chp > (p_ptr->mhp * op_ptr->hitpoint_warn) / 10) 294 color = TERM_YELLOW; 295 else 296 color = TERM_RED; 297 306 298 307 c_put_str(color, cur_hp, row, col + 3); 299 308 c_put_str(TERM_WHITE, "/", row, col + 7); … … 301 310 } 302 311 312 /* 313 * Calculate the sp color separately, for ports. 314 */ 315 byte player_sp_attr() 316 { 317 byte attr; 318 319 if (p_ptr->csp >= p_ptr->msp) 320 attr = TERM_L_GREEN; 321 else if (p_ptr->csp > (p_ptr->msp * op_ptr->hitpoint_warn) / 10) 322 attr = TERM_YELLOW; 323 else 324 attr = TERM_RED; 325 326 return attr; 327 } 303 328 304 329 /* … … 308 333 { 309 334 char cur_sp[32], max_sp[32]; 310 byte color ;335 byte color = player_sp_attr(); 311 336 312 337 /* Do not show mana unless it matters */ … … 317 342 strnfmt(max_sp, sizeof(max_sp), "%4d", p_ptr->msp); 318 343 strnfmt(cur_sp, sizeof(cur_sp), "%4d", p_ptr->csp); 319 320 if (p_ptr->csp >= p_ptr->msp)321 color = TERM_L_GREEN;322 else if (p_ptr->csp > (p_ptr->msp * op_ptr->hitpoint_warn) / 10)323 color = TERM_YELLOW;324 else325 color = TERM_RED;326 344 327 345 /* Show mana */ … … 331 349 } 332 350 351 /* 352 * Calculate the monster bar color separately, for ports. 353 */ 354 byte monster_health_attr() 355 { 356 byte attr = TERM_WHITE; 357 358 /* Not tracking */ 359 if (!p_ptr->health_who) 360 attr = TERM_DARK; 361 362 /* Tracking an unseen, hallucinatory, or dead monster */ 363 else if ((!mon_list[p_ptr->health_who].ml) || 364 (p_ptr->timed[TMD_IMAGE]) || 365 (!mon_list[p_ptr->health_who].hp < 0)) 366 { 367 /* The monster health is "unknown" */ 368 attr = TERM_WHITE; 369 } 370 371 else 372 { 373 int pct; 374 375 monster_type *m_ptr = &mon_list[p_ptr->health_who]; 376 377 /* Default to almost dead */ 378 attr = TERM_RED; 379 380 /* Extract the "percent" of health */ 381 pct = 100L * m_ptr->hp / m_ptr->maxhp; 382 383 /* Badly wounded */ 384 if (pct >= 10) attr = TERM_L_RED; 385 386 /* Wounded */ 387 if (pct >= 25) attr = TERM_ORANGE; 388 389 /* Somewhat Wounded */ 390 if (pct >= 60) attr = TERM_YELLOW; 391 392 /* Healthy */ 393 if (pct >= 100) attr = TERM_L_GREEN; 394 395 /* Afraid */ 396 if (m_ptr->monfear) attr = TERM_VIOLET; 397 398 /* Confused */ 399 if (m_ptr->confused) attr = TERM_UMBER; 400 401 /* Stunned */ 402 if (m_ptr->stunned) attr = TERM_L_BLUE; 403 404 /* Asleep */ 405 if (m_ptr->csleep) attr = TERM_BLUE; 406 } 407 408 return attr; 409 } 333 410 334 411 /* … … 344 421 static void prt_health(int row, int col) 345 422 { 423 byte attr = monster_health_attr(); 424 346 425 /* Not tracking */ 347 426 if (!p_ptr->health_who) … … 351 430 } 352 431 353 /* Tracking an unseen monster */ 354 else if (!mon_list[p_ptr->health_who].ml) 355 { 356 /* Indicate that the monster health is "unknown" */ 357 Term_putstr(col, row, 12, TERM_WHITE, "[----------]"); 358 } 359 360 /* Tracking a hallucinatory monster */ 361 else if (p_ptr->timed[TMD_IMAGE]) 362 { 363 /* Indicate that the monster health is "unknown" */ 364 Term_putstr(col, row, 12, TERM_WHITE, "[----------]"); 365 } 366 367 /* Tracking a dead monster (?) */ 368 else if (!mon_list[p_ptr->health_who].hp < 0) 369 { 370 /* Indicate that the monster health is "unknown" */ 371 Term_putstr(col, row, 12, TERM_WHITE, "[----------]"); 432 /* Tracking an unseen, hallucinatory, or dead monster */ 433 else if ((!mon_list[p_ptr->health_who].ml) || /* Unseen */ 434 (p_ptr->timed[TMD_IMAGE]) || /* Hallucination */ 435 (!mon_list[p_ptr->health_who].hp < 0)) /* Dead (?) */ 436 { 437 /* The monster health is "unknown" */ 438 Term_putstr(col, row, 12, attr, "[----------]"); 372 439 } 373 440 … … 379 446 monster_type *m_ptr = &mon_list[p_ptr->health_who]; 380 447 381 /* Default to almost dead */382 byte attr = TERM_RED;383 384 448 /* Extract the "percent" of health */ 385 449 pct = 100L * m_ptr->hp / m_ptr->maxhp; 386 387 /* Badly wounded */388 if (pct >= 10) attr = TERM_L_RED;389 390 /* Wounded */391 if (pct >= 25) attr = TERM_ORANGE;392 393 /* Somewhat Wounded */394 if (pct >= 60) attr = TERM_YELLOW;395 396 /* Healthy */397 if (pct >= 100) attr = TERM_L_GREEN;398 399 /* Afraid */400 if (m_ptr->monfear) attr = TERM_VIOLET;401 402 /* Confused */403 if (m_ptr->confused) attr = TERM_UMBER;404 405 /* Stunned */406 if (m_ptr->stunned) attr = TERM_L_BLUE;407 408 /* Asleep */409 if (m_ptr->csleep) attr = TERM_BLUE;410 450 411 451 /* Convert percent into "health" */
