1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
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 | |
---|
13 | #include "tools.h" |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | tool_picker::~tool_picker() |
---|
18 | { delete old_pal; |
---|
19 | delete map; |
---|
20 | for (int i=0; i<total_icons; i++) |
---|
21 | delete icons[i]; // delete visual object, which should be a "shell" |
---|
22 | } |
---|
23 | |
---|
24 | void tool_picker::remap(palette *pal, image *screen) |
---|
25 | { |
---|
26 | delete map; |
---|
27 | map=new filter(old_pal,pal); |
---|
28 | draw_first(screen); |
---|
29 | } |
---|
30 | |
---|
31 | tool_picker::tool_picker(int X, int Y, int ID, |
---|
32 | int show_h, visual_object **Icons, int *Ids, int total_ic, |
---|
33 | palette *icon_palette, palette *pal, ifield *Next) : |
---|
34 | spicker(X,Y,ID,show_h,1,1,0,Next) |
---|
35 | { |
---|
36 | iw=ih=0; |
---|
37 | icons=Icons; |
---|
38 | ids=Ids; |
---|
39 | total_icons=total_ic; |
---|
40 | for (int i=0; i<total_ic; i++) |
---|
41 | { |
---|
42 | if (icons[i]->width()>iw) iw=icons[i]->width(); |
---|
43 | if (icons[i]->height()>ih) ih=icons[i]->height(); |
---|
44 | } |
---|
45 | map=new filter(icon_palette,pal); |
---|
46 | old_pal=icon_palette->copy(); |
---|
47 | reconfigure(); |
---|
48 | } |
---|
49 | |
---|
50 | void tool_picker::draw_item(image *screen, int x, int y, int num, int active) |
---|
51 | { |
---|
52 | if (!active) |
---|
53 | screen->bar(x,y,x+iw-1,y+ih-1,wm->black()); |
---|
54 | else |
---|
55 | screen->bar(x,y,x+iw-1,y+ih-1,wm->bright_color()); |
---|
56 | icons[num]->draw(screen,x,y,map); |
---|
57 | } |
---|
58 | |
---|