Changeset 34
- Timestamp:
- 04/08/07 23:07:08 (2 years ago)
- Files:
-
- trunk/src/defines.h (modified) (1 diff)
- trunk/src/xtra1.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/defines.h
r30 r34 486 486 /* 487 487 * Some screen locations for various display routines 488 * Currently, row 8 and 15 are the only "blank" rows. 489 * That leaves a "border" around the "stat" values. 490 */ 491 492 #define ROW_RACE 1 493 #define COL_RACE 0 /* <race name> */ 494 495 #define ROW_CLASS 2 496 #define COL_CLASS 0 /* <class name> */ 497 498 #define ROW_TITLE 3 499 #define COL_TITLE 0 /* <title> or <mode> */ 500 501 #define ROW_LEVEL 4 502 #define COL_LEVEL 0 /* "LEVEL xxxxxx" */ 503 504 #define ROW_EXP 5 505 #define COL_EXP 0 /* "EXP xxxxxxxx" */ 506 507 #define ROW_GOLD 6 508 #define COL_GOLD 0 /* "AU xxxxxxxxx" */ 509 510 #define ROW_EQUIPPY 7 511 #define COL_EQUIPPY 0 /* equippy chars */ 512 513 #define ROW_STAT 8 514 #define COL_STAT 0 /* "xxx xxxxxx" */ 515 516 #define ROW_AC 15 517 #define COL_AC 0 /* "Cur AC xxxxx" */ 518 519 #define ROW_MAXHP 16 520 #define COL_MAXHP 0 /* "Max HP xxxxx" */ 521 522 #define ROW_CURHP 17 523 #define COL_CURHP 0 /* "Cur HP xxxxx" */ 524 525 #define ROW_MAXSP 18 526 #define COL_MAXSP 0 /* "Max SP xxxxx" */ 527 528 #define ROW_CURSP 19 529 #define COL_CURSP 0 /* "Cur SP xxxxx" */ 530 531 #define ROW_INFO 20 532 #define COL_INFO 0 /* "xxxxxxxxxxxx" */ 533 534 #define ROW_CUT 21 535 #define COL_CUT 0 /* <cut> */ 536 537 #define ROW_STUN 22 538 #define COL_STUN 0 /* <stun> */ 539 488 */ 540 489 #define ROW_HUNGRY (Term->hgt - 1) 541 490 #define COL_HUNGRY 0 /* "Weak" / "Hungry" / "Full" / "Gorged" */ trunk/src/xtra1.c
r30 r34 298 298 * Prints Cur hit points 299 299 */ 300 static void prt_cur_hp(int row, int col) 301 { 302 char tmp[32]; 303 300 static void prt_hp(int row, int col) 301 { 302 char cur_hp[32], max_hp[32]; 304 303 byte color; 305 304 306 307 put_str("Cur HP ", row, col); 308 309 sprintf( tmp, "%5d", p_ptr->chp);305 put_str("HP ", row, col); 306 307 sprintf(max_hp, "%4d", p_ptr->mhp); 308 sprintf(cur_hp, "%4d", p_ptr->chp); 310 309 311 310 if (p_ptr->chp >= p_ptr->mhp) 312 {313 311 color = TERM_L_GREEN; 314 }315 312 else if (p_ptr->chp > (p_ptr->mhp * op_ptr->hitpoint_warn) / 10) 316 {317 313 color = TERM_YELLOW; 318 }319 314 else 320 {321 315 color = TERM_RED; 322 } 323 324 c_put_str(color, tmp, row, col + 7); 325 } 326 327 328 /* 329 * Prints Max hit points 330 */ 331 static void prt_max_hp(int row, int col) 332 { 333 char tmp[32]; 334 335 put_str("Max HP ", row, col); 336 337 sprintf(tmp, "%5d", p_ptr->mhp); 338 339 c_put_str(TERM_L_GREEN, tmp, row, col + 7); 316 317 c_put_str(color, cur_hp, row, col + 3); 318 c_put_str(TERM_WHITE, "/", row, col + 7); 319 c_put_str(TERM_L_GREEN, max_hp, row, col + 8); 340 320 } 341 321 … … 344 324 * Prints players max/cur spell points 345 325 */ 346 static void prt_ cur_sp(int row, int col)347 { 348 char tmp[32];326 static void prt_sp(int row, int col) 327 { 328 char cur_sp[32], max_sp[32]; 349 329 byte color; 350 351 330 352 331 /* Do not show mana unless it matters */ 353 332 if (!cp_ptr->spell_book) return; 354 333 355 put_str("Cur SP ", row, col); 356 357 sprintf(tmp, "%5d", p_ptr->csp); 334 put_str("SP ", row, col); 335 336 sprintf(max_sp, "%4d", p_ptr->msp); 337 sprintf(cur_sp, "%4d", p_ptr->csp); 358 338 359 339 if (p_ptr->csp >= p_ptr->msp) 360 {361 340 color = TERM_L_GREEN; 362 }363 341 else if (p_ptr->csp > (p_ptr->msp * op_ptr->hitpoint_warn) / 10) 364 {365 342 color = TERM_YELLOW; 366 }367 343 else 368 {369 344 color = TERM_RED; 370 }371 345 372 346 /* Show mana */ 373 c_put_str(color, tmp, row, col + 7); 374 } 375 376 377 /* 378 * Prints players max/cur spell points 379 */ 380 static void prt_max_sp(int row, int col) 381 { 382 char tmp[32]; 383 384 /* Do not show mana unless it matters */ 385 if (!cp_ptr->spell_book) return; 386 387 put_str("Max SP ", row, col); 388 389 sprintf(tmp, "%5d", p_ptr->msp); 390 391 c_put_str(TERM_L_GREEN, tmp, row, col + 7); 392 } 347 c_put_str(color, cur_sp, row, col + 3); 348 c_put_str(TERM_WHITE, "/", row, col + 7); 349 c_put_str(TERM_L_GREEN, max_sp, row, col + 8); 350 } 351 393 352 394 353 … … 1096 1055 1097 1056 /* Hitpoints */ 1098 prt_max_hp(row++, col); 1099 prt_cur_hp(row++, col); 1057 prt_hp(row++, col); 1100 1058 1101 1059 /* Spellpoints */ 1102 prt_max_sp(row++, col); 1103 prt_cur_sp(row++, col); 1060 prt_sp(row++, col); 1104 1061 1105 1062 /* Special */ … … 2939 2896 2940 2897 2898 /* Some simple wrapper functions, done somewhat lazily */ 2899 #define PRT_STAT(N, n) \ 2900 void N(int row, int col) { prt_stat(n, row, col); } 2901 2902 PRT_STAT(prt_str, A_STR) 2903 PRT_STAT(prt_dex, A_DEX) 2904 PRT_STAT(prt_wis, A_WIS) 2905 PRT_STAT(prt_int, A_INT) 2906 PRT_STAT(prt_con, A_CON) 2907 PRT_STAT(prt_chr, A_CHR) 2908 2909 void prt_race(int row, int col) { prt_field(p_name + rp_ptr->name, row, col); } 2910 void prt_class(int row, int col) { prt_field(c_name + cp_ptr->name, row, col); } 2911 2912 2913 /* 2914 * This prints the sidebar, using a clever method which means that it will only 2915 * print as much as can be displayed on <24-line screens. 2916 * 2917 * Each row is given a priority; the least important higher numbers and the most 2918 * important lower numbers. As the screen gets smaller, the rows start to 2919 * disappear in the order of lowest to highest importance. 2920 */ 2921 void prt_side(void) 2922 { 2923 struct sidebar_entry 2924 { 2925 void (*hook)(int, int); /* int row, int col */ 2926 int priority; /* 1 is most important (always displayed) */ 2927 u32b flag; /* PR_* flag this corresponds to */ 2928 } display_list[] = 2929 { 2930 { prt_race, 20, PR_MISC }, 2931 { prt_class, 19, PR_MISC }, 2932 { prt_title, 18, PR_TITLE }, 2933 { prt_level, 10, PR_LEV }, 2934 { prt_exp, 15, PR_EXP }, 2935 { prt_gold, 11, PR_GOLD }, 2936 { prt_equippy, 17, PR_EQUIPPY }, 2937 { prt_str, 6, PR_STATS }, 2938 { prt_int, 5, PR_STATS }, 2939 { prt_wis, 4, PR_STATS }, 2940 { prt_dex, 3, PR_STATS }, 2941 { prt_con, 2, PR_STATS }, 2942 { prt_chr, 1, PR_STATS }, 2943 { NULL, 14, 0 }, 2944 { prt_ac, 7, PR_ARMOR }, 2945 { prt_hp, 8, PR_HP }, 2946 { prt_sp, 9, PR_MANA }, 2947 { NULL, 22, 0 }, 2948 { health_redraw, 12, PR_HEALTH }, 2949 { NULL, 21, 0 }, 2950 { prt_cut, 13, PR_CUT }, 2951 { prt_stun, 16, PR_STUN } 2952 }; 2953 2954 int x, y; 2955 int max_priority; 2956 int i, row; 2957 u32b to_clear = 0; 2958 2959 /* We have from row 1 to row Term->hgt-1 to display in */ 2960 Term_get_size(&x, &y); 2961 max_priority = y - 2; 2962 2963 /* Display list entries */ 2964 for (i = 0, row = 1; i < (int)N_ELEMENTS(display_list); i++) 2965 { 2966 struct sidebar_entry *q = &display_list[i]; 2967 2968 /* If this is high enough priority, display it */ 2969 if (q->priority <= max_priority) 2970 { 2971 /* If the redraw flag it set, and there is a hook */ 2972 if ((p_ptr->redraw & q->flag) && q->hook) 2973 { 2974 /* Mark flag for removal */ 2975 to_clear |= q->flag; 2976 2977 /* Display at the current row */ 2978 q->hook(row, 0); 2979 } 2980 2981 /* Increment for next time */ 2982 row++; 2983 } 2984 } 2985 2986 /* Clear flags */ 2987 p_ptr->redraw &= ~(to_clear); 2988 } 2989 2990 2991 2941 2992 /* 2942 2993 * Handle "p_ptr->redraw" … … 2979 3030 } 2980 3031 2981 if (p_ptr->redraw & (PR_MISC))2982 {2983 p_ptr->redraw &= ~(PR_MISC);2984 prt_field(p_name + rp_ptr->name, ROW_RACE, COL_RACE);2985 prt_field(c_name + cp_ptr->name, ROW_CLASS, COL_CLASS);2986 }2987 2988 if (p_ptr->redraw & (PR_TITLE))2989 {2990 p_ptr->redraw &= ~(PR_TITLE);2991 prt_title(ROW_TITLE, COL_TITLE);2992 }2993 2994 if (p_ptr->redraw & (PR_LEV))2995 {2996 p_ptr->redraw &= ~(PR_LEV);2997 prt_level(ROW_LEVEL, COL_LEVEL);2998 }2999 3000 if (p_ptr->redraw & (PR_EXP))3001 {3002 p_ptr->redraw &= ~(PR_EXP);3003 prt_exp(ROW_EXP, COL_EXP);3004 }3005 3006 if (p_ptr->redraw & (PR_STATS))3007 {3008 int i;3009 3010 for (i = 0; i < A_MAX; i++)3011 prt_stat(i, ROW_STAT + i, COL_STAT);3012 3013 p_ptr->redraw &= ~(PR_STATS);3014 }3015 3016 if (p_ptr->redraw & (PR_ARMOR))3017 {3018 p_ptr->redraw &= ~(PR_ARMOR);3019 prt_ac(ROW_AC, COL_AC);3020 }3021 3022 3032 if (p_ptr->redraw & (PR_HP)) 3023 3033 { 3024 p_ptr->redraw &= ~(PR_HP);3025 prt_cur_hp(ROW_CURHP, COL_CURHP);3026 prt_max_hp(ROW_MAXHP, COL_MAXHP);3027 3028 3034 /* 3029 3035 * hack: redraw player, since the player's color … … 3036 3042 lite_spot(p_ptr->py, p_ptr->px); 3037 3043 } 3038 3039 } 3040 3041 if (p_ptr->redraw & (PR_MANA)) 3042 { 3043 p_ptr->redraw &= ~(PR_MANA); 3044 prt_cur_sp(ROW_CURSP, COL_CURSP); 3045 prt_max_sp(ROW_MAXSP, COL_MAXSP); 3046 } 3047 3048 if (p_ptr->redraw & (PR_GOLD)) 3049 { 3050 p_ptr->redraw &= ~(PR_GOLD); 3051 prt_gold(ROW_GOLD, COL_GOLD); 3052 } 3053 3054 if (p_ptr->redraw & (PR_EQUIPPY)) 3055 { 3056 p_ptr->redraw &= ~(PR_EQUIPPY); 3057 prt_equippy(ROW_EQUIPPY, COL_EQUIPPY); 3058 } 3044 } 3045 3046 /* Redraw the sidebar */ 3047 prt_side(); 3048 3059 3049 3060 3050 if (p_ptr->redraw & (PR_DEPTH)) … … 3072 3062 } 3073 3063 3074 if (p_ptr->redraw & (PR_HEALTH))3075 {3076 p_ptr->redraw &= ~(PR_HEALTH);3077 health_redraw(ROW_INFO, COL_INFO);3078 }3079 3080 if (p_ptr->redraw & (PR_CUT))3081 {3082 p_ptr->redraw &= ~(PR_CUT);3083 prt_cut(ROW_CUT, COL_CUT);3084 }3085 3086 if (p_ptr->redraw & (PR_STUN))3087 {3088 p_ptr->redraw &= ~(PR_STUN);3089 prt_stun(ROW_STUN, COL_STUN);3090 }3091 3092 3064 if (p_ptr->redraw & (PR_HUNGER)) 3093 3065 {
