[56] | 1 | /* |
---|
| 2 | * Abuse - dark 2D side-scrolling platform game |
---|
| 3 | * Copyright (c) 1995 Crack dot Com |
---|
[494] | 4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
[56] | 5 | * |
---|
| 6 | * This software was released into the Public Domain. As with most public |
---|
| 7 | * domain software, no warranty is made or implied by Crack dot Com or |
---|
| 8 | * Jonathan Clark. |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | #include "config.h" |
---|
| 12 | |
---|
[512] | 13 | #include "common.h" |
---|
| 14 | |
---|
[481] | 15 | #include "tools.h" |
---|
[2] | 16 | |
---|
| 17 | |
---|
| 18 | |
---|
[124] | 19 | tool_picker::~tool_picker() |
---|
| 20 | { delete old_pal; |
---|
| 21 | delete map; |
---|
[494] | 22 | for (int i=0; i<total_icons; i++) |
---|
[124] | 23 | delete icons[i]; // delete visual object, which should be a "shell" |
---|
[2] | 24 | } |
---|
| 25 | |
---|
[106] | 26 | void tool_picker::remap(palette *pal, image *screen) |
---|
[2] | 27 | { |
---|
| 28 | delete map; |
---|
| 29 | map=new filter(old_pal,pal); |
---|
[106] | 30 | draw_first(screen); |
---|
[2] | 31 | } |
---|
| 32 | |
---|
[124] | 33 | tool_picker::tool_picker(int X, int Y, int ID, |
---|
| 34 | int show_h, visual_object **Icons, int *Ids, int total_ic, |
---|
| 35 | palette *icon_palette, palette *pal, ifield *Next) : |
---|
[2] | 36 | spicker(X,Y,ID,show_h,1,1,0,Next) |
---|
| 37 | { |
---|
| 38 | iw=ih=0; |
---|
| 39 | icons=Icons; |
---|
| 40 | ids=Ids; |
---|
| 41 | total_icons=total_ic; |
---|
[494] | 42 | for (int i=0; i<total_ic; i++) |
---|
[2] | 43 | { |
---|
[106] | 44 | if (icons[i]->width()>iw) iw=icons[i]->width(); |
---|
| 45 | if (icons[i]->height()>ih) ih=icons[i]->height(); |
---|
[2] | 46 | } |
---|
| 47 | map=new filter(icon_palette,pal); |
---|
| 48 | old_pal=icon_palette->copy(); |
---|
| 49 | reconfigure(); |
---|
| 50 | } |
---|
| 51 | |
---|
[106] | 52 | void tool_picker::draw_item(image *screen, int x, int y, int num, int active) |
---|
[2] | 53 | { |
---|
| 54 | if (!active) |
---|
| 55 | screen->bar(x,y,x+iw-1,y+ih-1,wm->black()); |
---|
| 56 | else |
---|
| 57 | screen->bar(x,y,x+iw-1,y+ih-1,wm->bright_color()); |
---|
[106] | 58 | icons[num]->draw(screen,x,y,map); |
---|
[2] | 59 | } |
---|
| 60 | |
---|