Changeset 30

Show
Ignore:
Timestamp:
04/02/07 23:25:43 (1 year ago)
Author:
pmac
Message:

- Mouse on OSX does not follow screen drags.
- Check in hp_changes_color -- I keep dying in my test games...

(also changed some default values)

- Add killed count back into monster knowledge.
- Cleaner model for mouse directions in ui.c
- Change in menu model for knowledge browse broke the visual editor (you end up editing

the wrong object.)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/birth.c

    r28 r30  
    634634 * Display additional information about each race during the selection. 
    635635 */ 
    636 static void race_aux_hook(int race, const region *reg) 
     636static void race_aux_hook(int race, void *db, const region *reg) 
    637637{ 
    638638        int i; 
     
    661661 * Display additional information about each class during the selection. 
    662662 */ 
    663 static void class_aux_hook(int class_idx, const region *loc) 
     663static void class_aux_hook(int class_idx, void *db, const region *loc) 
    664664{ 
    665665        int i; 
     
    783783                "Your 'class' determines various intrinsic abilities and bonuses" }; 
    784784         
    785         typedef void (*browse_f) (int oid, const region *loc); 
     785        typedef void (*browse_f) (int oid, void *, const region *loc); 
    786786        browse_f browse [] = {NULL, race_aux_hook, class_aux_hook }; 
    787787        menu_type menu; 
  • trunk/src/cave.c

    r24 r30  
    991991                /* Get the "player" attr */ 
    992992                a = r_ptr->x_attr; 
     993                if ((hp_changes_color) && (arg_graphics == GRAPHICS_NONE)) 
     994                { 
     995                        switch(p_ptr->chp * 10 / p_ptr->mhp) 
     996                                { 
     997                                case 10: 
     998                                case  9:        a = TERM_WHITE  ;       break; 
     999                                case  8: 
     1000                                case  7:        a = TERM_YELLOW ;       break; 
     1001                                case  6: 
     1002                                case  5:        a = TERM_ORANGE ;       break; 
     1003                                case  4: 
     1004                                case  3:        a = TERM_L_RED  ;       break; 
     1005                                case  2: 
     1006                                case  1: 
     1007                                case  0:        a = TERM_RED    ;       break; 
     1008                                default:        a = TERM_WHITE  ;       break; 
     1009                                } 
     1010                } 
    9931011 
    9941012                /* Get the "player" char */ 
  • trunk/src/cmd4.c

    r29 r30  
    3939                bool (*aware)(object_type *obj); /* Object is known sufficiently for group */ 
    4040 
     41                /* summary function for the "object" information. */ 
     42                void (*summary)(int gid, const int *object_list, int n, int top, int row, int col); 
    4143} group_funcs; 
    4244 
    4345typedef struct { 
    4446 
     47                /* Print a tabular-formatted description for an oid */ 
     48                /* This includes things like kill-count, the current graphic, */ 
     49                /* any tile illumination info. Item id for Wizard mode and */ 
     50                /* autoinscription are handled by the caller */ 
    4551                void (*display_member)(int col, int row, bool cursor, int oid);  
    4652 
    4753                void (*lore)(int oid); /* Dump known lore to screen*/ 
     54 
    4855 
    4956                /* Required only for objects with modifiable display attributes */ 
     
    115122        { "k",          "Kobolds" }, 
    116123        { "L",          "Lichs" }, 
     124        { "tp",         "Men" }, 
    117125        { "$?!_",       "Mimics" }, 
    118126        { "m",          "Molds" }, 
     
    120128        { "n",          "Nagas" }, 
    121129        { "o",          "Orcs" }, 
    122         { "tp",         "Humans" }, 
    123130        { "q",          "Quadrupeds" }, 
    124131        { "Q",          "Quylthulgs" }, 
     
    305312} 
    306313 
    307 /* 
    308  * Display a list with a cursor 
    309  */ 
    310 static void display_group_list(int col, int row, int wid, int per_page, 
    311                                 int start, int max, int cursor, const cptr group_text[]) 
    312 { 
    313         int i, pos; 
    314  
    315         /* Display lines until done */ 
    316         for (i = 0, pos = start; i < per_page && pos < max; i++, pos++) 
    317         { 
    318                 char buffer[21]; 
    319                 byte attr = curs_attrs[CURS_KNOWN][cursor == pos]; 
    320  
    321                 /* Erase the line */ 
    322                 Term_erase(col, row + i, wid); 
    323  
    324                 /* Display it (width should not exceed 20) */ 
    325                 strncpy(buffer, group_text[pos], 20); 
    326                 buffer[20] = 0; 
    327                 c_put_str(attr, buffer, row + i, col); 
    328         } 
    329         /* Wipe the rest? */ 
    330 } 
    331314 
    332315static void display_group_member(menu_type *menu, int oid, 
     
    340323                c_put_str(TERM_YELLOW,quark_str(*o_funcs->note(oid)), row, 65); 
    341324        } 
     325        /* Print the interesting part */ 
    342326        o_funcs->display_member(col, row, cursor, oid); 
    343327 
     
    393377 
    394378        /* Panel state */ 
     379        /* These are swapped in parallel whenever the actively browsing " */ 
     380        /* changes */ 
    395381        int *active_cursor = &g_cur, *inactive_cursor = &o_cur; 
    396382        menu_type *active_menu = &group_menu, *inactive_menu = &object_menu; 
    397383        int panel = 0; 
     384 
    398385        void *swapspace; 
    399386        bool do_swap = FALSE; 
     
    446433 
    447434        region title_area = {0, 0, 0, 4}; 
    448         region group_region = {0, 6, g_name_len, -1}; 
     435        region group_region = {0, 6, g_name_len, -2}; 
    449436        region object_region = {g_name_len+3, 6, 0, -2}; 
     437 
     438        /* Leave room for the group summary information */ 
     439        if(g_funcs.summary) object_region.page_rows = -3; 
    450440 
    451441        WIPE(&group_menu, menu_type); 
    452442        group_menu.count = grp_cnt; 
    453         group_menu.cmd_keys = "\n\r6\x8C";  /* Don't treat this as motion */ 
     443        group_menu.cmd_keys = "\n\r6\x8C";  /* Ignore these as menu commands */ 
    454444        group_menu.menu_data = g_names; 
    455445 
     
    506496                        /* ... or just a single element in the group. */ 
    507497                        o_funcs.is_visual = TRUE; 
    508                         menu_set_filter(&object_menu, obj_list + o_cur, 1); 
     498                        menu_set_filter(&object_menu, obj_list + o_cur +g_offset[g_cur], 1); 
    509499                        object_menu.cursor = 0; 
    510500                } 
     
    536526                } 
    537527 
     528                if(g_funcs.summary && !visual_list) 
     529                        g_funcs.summary(g_cur, obj_list, g_o_count, g_offset[g_cur], 
     530                        object_menu.boundary.row + object_menu.boundary.page_rows, object_region.col); 
    538531                menu_refresh(inactive_menu); 
    539532                menu_refresh(active_menu); 
     
    542535                if (visual_list) 
    543536                { 
     537         
     538                        display_visual_list(g_name_len + 3, 7, browser_rows-1, 
     539                                   wid - (g_name_len + 3), attr_top, char_left); 
    544540                        place_visual_list_cursor(g_name_len + 3, 7, *o_funcs.xattr(oid),  
    545541                                                                                *o_funcs.xchar(oid), attr_top, char_left); 
     
    684680                                int d = target_dir(ke.key); 
    685681                                /* Handle key-driven motion between panels */ 
    686                                 if((ddx[d] < 0) && panel == 1) { 
     682                                if(ddx[d] && ((ddx[d] < 0) == (panel == 1))) { 
    687683                                        /* Silly hack -- diagonal arithmetic */ 
    688                                         g_cur += -(ddy[d] < 0) + (ddy[d] > 0); 
    689                                         if(g_cur < 0) g_cur = 0; 
    690                                         if(g_cur >= grp_cnt) g_cur = grp_cnt -1; 
    691                                         do_swap = TRUE; 
    692                                 } 
    693                                 else if((ddx[d] > 0) == (panel == 0)) { 
    694                                         o_cur += -(ddy[d] < 0) + (ddy[d] > 0); 
    695                                         if(o_cur < 0) o_cur = 0; 
    696                                         if(o_cur >= g_o_count) o_cur = g_o_count-1; 
     684                                        *inactive_cursor += ddy[d]; 
     685                                        if(*inactive_cursor < 0) *inactive_cursor = 0; 
     686                                        else if(g_cur >= grp_cnt) g_cur = grp_cnt -1; 
     687                                        else if(o_cur >= g_o_count) o_cur = g_o_count-1; 
    697688                                        do_swap = TRUE; 
    698689                                } 
     
    10271018static void mon_lore(int oid) { screen_roff(default_join[oid].oid); inkey_ex(); } 
    10281019 
     1020static void mon_summary(int gid, const int *object_list, int n, int top, int row, int col) 
     1021{ 
     1022        int i; 
     1023        int kills = 0; 
     1024 
     1025        for(i = 0; i < n; i++) { 
     1026                int oid = default_join[object_list[i+top]].oid; 
     1027                kills += l_list[oid].pkills; 
     1028        } 
     1029        if(gid == 0) { 
     1030                c_prt(TERM_L_BLUE, format("Known Uniques: %d, Slain Uniques: %d.", n, kills), 
     1031                                        row, col); 
     1032        } 
     1033        else  { 
     1034                int tkills = 0; 
     1035                for(i = 0; i < z_info->r_max; i++)  
     1036                        tkills += l_list[i].pkills; 
     1037                c_prt(TERM_L_BLUE, format("Creatures Slain: %d/%d (in group/in total)", kills, tkills), row, col); 
     1038        } 
     1039} 
     1040 
    10291041/* 
    10301042 * Display known monsters. 
     
    10321044static void do_cmd_knowledge_monsters(void) 
    10331045{ 
    1034                group_funcs r_funcs = {N_ELEMENTS(monster_group), FALSE, race_name, 
    1035                                                         m_cmp_race, default_group, 0}; 
     1046        group_funcs r_funcs = {N_ELEMENTS(monster_group), FALSE, race_name, 
     1047                                                        m_cmp_race, default_group, 0, mon_summary}; 
    10361048 
    10371049        member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, 0, 0}; 
     
    11721184{ 
    11731185        /* HACK -- should be TV_MAX */ 
    1174         group_funcs obj_f = {TV_GOLD, FALSE, kind_name, a_cmp_tval, art2tval, 0}; 
    1175         member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, 0}; 
     1186        group_funcs obj_f = {TV_GOLD, FALSE, kind_name, a_cmp_tval, art2tval, 0, 0}; 
     1187        member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, 0, 0}; 
    11761188 
    11771189 
     
    12941306{ 
    12951307        group_funcs obj_f = 
    1296                 {TV_GOLD, FALSE, ego_grp_name, e_cmp_tval, default_group, 0}; 
    1297  
    1298         member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, 0/*e_note */ }; 
     1308                {TV_GOLD, FALSE, ego_grp_name, e_cmp_tval, default_group, 0, 0}; 
     1309 
     1310        member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, 0, 0/*e_note */ }; 
    12991311 
    13001312        int *egoitems; 
     
    14501462static void do_cmd_knowledge_objects(void) 
    14511463{ 
    1452         group_funcs kind_f = {TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0}; 
     1464        group_funcs kind_f = {TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0, 0}; 
    14531465        member_funcs obj_f = {display_object, desc_obj_fake, o_xchar, o_xattr,0 /* o_note*/}; 
    14541466 
     
    15211533{ 
    15221534        group_funcs fkind_f = {N_ELEMENTS(feature_group_text), FALSE, 
    1523                                                         fkind_name, f_cmp_fkind, feat_order, 0}; 
     1535                                                        fkind_name, f_cmp_fkind, feat_order, 0, 0}; 
    15241536 
    15251537        member_funcs feat_f = {display_feature, feat_lore, f_xchar, f_xattr, 0}; 
  • trunk/src/defines.h

    r28 r30  
    25392539#define OPT_smart_monsters                      72 
    25402540#define OPT_smart_packs                         73 
    2541 /* xxx */ 
     2541#define OPT_hp_changes_color            74 
    25422542/* xxx */ 
    25432543/* xxx */ 
     
    26592659#define smart_monsters                  op_ptr->opt[OPT_smart_monsters] 
    26602660#define smart_packs                             op_ptr->opt[OPT_smart_packs] 
    2661 /* xxx */ 
     2661#define hp_changes_color                op_ptr->opt[OPT_hp_changes_color] 
    26622662/* xxx */ 
    26632663/* xxx */ 
  • trunk/src/main-crb.c

    r9 r30  
    854854 
    855855 
     856        BitMap tScreen; 
    856857        /* Get current screen */ 
    857         hibernate(); 
    858         BitMap tScreen; 
    859858        (void)GetQDGlobalsScreenBits(&tScreen); 
    860          
    861859        /* Verify the bottom */ 
    862860        if (td->r.top > tScreen.bounds.bottom - td->size_hgt) 
     
    864862                td->r.top = tScreen.bounds.bottom - td->size_hgt; 
    865863        } 
    866  
    867864        /* Verify the top */ 
    868         if (td->r.top < tScreen.bounds.top + GetMBarHeight()) 
    869         { 
    870                 td->r.top = tScreen.bounds.top + GetMBarHeight(); 
    871         } 
    872  
     865        if (td->r.top < tScreen.bounds.top + 2*GetMBarHeight()) 
     866        { 
     867                td->r.top = tScreen.bounds.top + 2*GetMBarHeight(); 
     868        } 
    873869        /* Verify the right */ 
    874870        if (td->r.left > tScreen.bounds.right - td->size_wid) 
     
    876872                td->r.left = tScreen.bounds.right - td->size_wid; 
    877873        } 
    878  
    879874        /* Verify the left */ 
    880875        if (td->r.left < tScreen.bounds.left) 
     
    28232818        int x, y; 
    28242819        WindowRef w = 0; 
     2820        unsigned flags; 
    28252821 
    28262822        term_data *td; 
    28272823        term *old = Term; 
     2824        int err ; 
    28282825 
    28292826        GetEventParameter(inEvent, kEventParamDirectObject, 
    28302827                                                        typeWindowRef, NULL, sizeof(w), NULL, &w); 
     2828        err = GetEventParameter(inEvent, kEventParamAttributes, 
     2829                                                        typeUInt32, NULL, sizeof(flags), NULL, &flags); 
    28312830 
    28322831        td = (term_data*) GetWRefCon(w); 
     
    28352834        if (!td) return noErr; 
    28362835 
     2836 
    28372837        /* Obtain geometry of resized window */ 
    2838          
     2838 
    28392839        Rect tmpR; 
    28402840        GetWindowBounds((WindowRef)td->w, kWindowContentRgn, &tmpR); 
     2841        td->r = tmpR; 
     2842        if(td->r.top < 40) td->r.top = 40; 
    28412843 
    28422844        /* Extract the new ClipRect size in pixels */ 
     
    28472849        td->rows = y / td->tile_hgt; 
    28482850        td->cols = x / td->tile_wid; 
     2851 
    28492852 
    28502853        /* Apply and Verify */ 
     
    32273230        p.x -= (BORDER_WID+td->r.left); 
    32283231        // Y coordinate relative to top of window content region. 
    3229         // HACK: assumes title width of 21 pixels. 
    3230         p.y -= (td->r.top + 21); 
     3232        p.y -= td->r.top; 
    32313233 
    32323234        Term_mousepress(p.x/td->tile_wid, p.y/td->tile_hgt, button); 
  • trunk/src/obj-info.c

    r1 r30  
    594594 
    595595        /* Wait for input */ 
    596         (void)inkey(); 
     596        (void)anykey(); 
    597597 
    598598        /* Load the screen */ 
  • trunk/src/osx/osx_tables.h

    r9 r30  
    125125#define WNUPD kEventWindowUpdate 
    126126#define WNRSZ kEventWindowResizeCompleted 
     127#define WNDRG kEventWindowDragCompleted 
    127128 
    128129#define HANDLERDEF(func) \ 
     
    180181 
    181182        { 'wind', WNRSZ,        ResizeCommand,   kWINDOW, NULL }, // Change window size 
     183        { 'wind', WNDRG,        ResizeCommand,   kWINDOW, NULL }, // Change window size 
    182184        { 'appl', kEventAppActivated, 
    183185                                                ResumeCommand,   0,             NULL }, 
  • trunk/src/tables.c

    r16 r30  
    14711471        "smart_monsters",                       /* OPT_smart_monsters */ 
    14721472        "smart_packs",                          /* OPT_smart_packs */ 
    1473         NULL,                                          /* xxx */ 
     1473        "hp_changes_color",                    /* OPT_hp_changes_color */ 
    14741474        NULL,                                           /* xxx */ 
    14751475        NULL,                                           /* xxx */ 
     
    17351735        "Monsters behave more intelligently",           /* OPT_smart_monsters */ 
    17361736        "Monsters act smarter in groups (v.slow)",      /* OPT_smart_packs */ 
    1737         NULL,                                                                          /* xxx */ 
     1737        "Player color indicates low hit points",       /* OPT_hp_changes_color */ 
    17381738        NULL,                                                                           /* xxx */ 
    17391739        NULL,                                                                           /* xxx */ 
     
    19411941        TRUE,           /* OPT_ring_bell */ 
    19421942        TRUE,           /* OPT_show_flavors */ 
    1943         TRUE,         /* OPT_run_ignore_stairs */ 
    1944         TRUE,         /* OPT_run_ignore_doors */ 
     1943        FALSE,                /* OPT_run_ignore_stairs */ 
     1944        FALSE,                /* OPT_run_ignore_doors */ 
    19451945        TRUE,           /* OPT_run_cut_corners */ 
    19461946        TRUE,           /* OPT_run_use_corners */ 
    1947         TRUE,         /* OPT_disturb_move */ 
     1947        FALSE,                /* OPT_disturb_move */ 
    19481948        TRUE,           /* OPT_disturb_near */ 
    19491949        TRUE,           /* OPT_disturb_panel */ 
     
    19641964        TRUE,           /* OPT_expand_list */ 
    19651965        TRUE,           /* OPT_view_perma_grids */ 
    1966         FALSE,                /* OPT_view_torch_grids */ 
     1966        TRUE,         /* OPT_view_torch_grids */ 
    19671967        TRUE,           /* OPT_dungeon_align */ 
    19681968        TRUE,           /* OPT_dungeon_stair */ 
    1969         FALSE,                /* OPT_flow_by_sound */ 
    1970         FALSE,                /* OPT_flow_by_smell */ 
     1969        TRUE,         /* OPT_flow_by_sound */ 
     1970        TRUE,         /* OPT_flow_by_smell */ 
    19711971        FALSE,          /* xxx track_follow */ 
    19721972        FALSE,          /* xxx track_target */ 
     
    19991999        FALSE,          /* OPT_smart_monsters */ 
    20002000        FALSE,          /* OPT_smart_packs */ 
    2001         FALSE,          /* xxx */ 
     2001        FALSE,          /* OPT_hp_changes_color */ 
    20022002        FALSE,          /* xxx */ 
    20032003        FALSE,          /* xxx */ 
     
    23062306                OPT_run_avoid_center, 
    23072307                OPT_show_piles, 
    2308                 OPT_NONE
     2308                OPT_hp_changes_color
    23092309                OPT_NONE, 
    23102310                OPT_NONE, 
  • trunk/src/ui.c

    r29 r30  
    289289{ 
    290290        int cursor = row - loc->row + top; 
    291         if(cursor < top) cursor = top-1; 
    292         else if(cursor > loc->page_rows) cursor = loc->page_rows; 
    293         if(cursor < 0) cursor = 0; 
    294         else if(cursor >= n) cursor = n-1; 
     291        if(cursor >= n) cursor = n-1; 
    295292 
    296293        return cursor; 
     
    523520        menu->skin->display_list(menu, menu->cursor, &menu->top, &menu->active); 
    524521        if(menu->browse_hook && oid >= 0) { 
    525                 menu->browse_hook(oid, loc); 
     522                menu->browse_hook(oid, menu->menu_data, loc); 
    526523        } 
    527524} 
     
    615612                        /* cursor movement */ 
    616613                        dir = target_dir(in->key); 
    617                         if(dir == 2 ) { 
    618                                 int ind; 
    619                                 out.type = EVT_MOVE; 
    620                                 for(ind = *cursor+1; ind < n && (TRUE != is_valid_row(menu, ind)); ind++) 
    621                                         ; 
    622                                 out.index = ind; 
    623                                 if(ind < n) *cursor = ind; 
    624                         } 
    625                         else if(dir == 8) { 
    626                                 int ind; 
    627                                 out.type = EVT_MOVE; 
    628                                 out.key = '\xff'; 
    629                                 for(ind = *cursor-1; ind >=0 && (TRUE != is_valid_row(menu, ind)); ind--) 
    630                                         ; 
    631                                 out.index = ind; 
    632                                 if(ind >= 0) *cursor = ind; 
    633                         } 
    634                         else if(dir == 4) { 
    635                                 out.type = EVT_BACK; 
     614                        if(ddx[dir] && ddy[dir]) return FALSE;          /* Reject diagonals */ 
     615                        else if(ddx[dir]) { 
     616                                out.type = ddx[dir] < 0 ? EVT_BACK : EVT_SELECT; 
    636617                                out.key = '\xff'; 
    637618                                out.index = *cursor; 
    638619                        } 
    639                         else if(dir == 6) {             /* Selection event */ 
    640                                 out.type = EVT_SELECT; 
    641                                 out.key = '\xff'; 
    642                                 out.index = *cursor; 
     620                        else if(ddy[dir]) {     /* Move up or down to the next valid & visible row */ 
     621                                int ind; 
     622                                int dy = ddy[dir]; 
     623                                out.type = EVT_MOVE; 
     624                                for(ind = *cursor + dy; ind < n && ind >= 0 
     625                                                        && (TRUE != is_valid_row(menu, ind)); ind += dy) ; 
     626                                out.index = ind; 
     627                                if(ind < n && ind >= 0) *cursor = ind; 
    643628                        } 
    644629                        else return FALSE; 
  • trunk/src/ui.h

    r29 r30  
    273273 
    274274        /* auxiliary browser help function */ 
    275         void (*browse_hook)(int oid, const region *loc); 
     275        void (*browse_hook)(int oid, void *db, const region *loc); 
    276276 
    277277 
  • trunk/src/xtra1.c

    r24 r30  
    30253025                prt_cur_hp(ROW_CURHP, COL_CURHP); 
    30263026                prt_max_hp(ROW_MAXHP, COL_MAXHP); 
     3027 
     3028                /* 
     3029                 * hack:  redraw player, since the player's color 
     3030                 * now indicates approximate health.  Note that 
     3031                 * using this command when graphics mode is on 
     3032                 * causes the character to be a black square. 
     3033                 */ 
     3034                if ((hp_changes_color) && (arg_graphics == GRAPHICS_NONE)) 
     3035                { 
     3036                        lite_spot(p_ptr->py, p_ptr->px); 
     3037                } 
     3038 
    30273039        } 
    30283040