source: abuse/trunk/src/imlib/tools.cpp @ 655

Last change on this file since 655 was 655, checked in by Sam Hocevar, 12 years ago

imlib: refactor a few image methods so that they use vec2i.

File size: 1.5 KB
Line 
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, by
8 *  Jonathan Clark, or by Sam Hocevar.
9 */
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "common.h"
16
17#include "tools.h"
18
19
20
21tool_picker::~tool_picker()
22{ delete old_pal;
23  delete map;
24  for (int i=0; i<total_icons; i++)
25    delete icons[i];                   // delete visual object, which should be a "shell"
26}
27
28void tool_picker::remap(palette *pal, image *screen)
29{
30  delete map;
31  map=new Filter(old_pal,pal);
32  draw_first(screen);
33}
34
35tool_picker::tool_picker(int X, int Y, int ID,
36          int show_h, visual_object **Icons, int *Ids, int total_ic,
37             palette *icon_palette, palette *pal, ifield *Next) :
38  spicker(X,Y,ID,show_h,1,1,0,Next)
39{
40  iw=ih=0;
41  icons=Icons;
42  ids=Ids;
43  total_icons=total_ic;
44  for (int i=0; i<total_ic; i++)
45  {
46    if (icons[i]->width()>iw) iw=icons[i]->width();
47    if (icons[i]->height()>ih) ih=icons[i]->height();
48  }
49  map=new Filter(icon_palette,pal);
50  old_pal=icon_palette->copy();
51  reconfigure();
52}
53
54void tool_picker::draw_item(image *screen, int x, int y, int num, int active)
55{
56    screen->Bar(vec2i(x, y), vec2i(x + iw - 1, y + ih - 1),
57                active ? wm->bright_color() : wm->black());
58    icons[num]->draw(screen, x, y, map);
59}
60
Note: See TracBrowser for help on using the repository browser.