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

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

imlib: use vec2i for image::size and unroll all necessary changes
everywhere else in the code.

File size: 1.4 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 or
8 *  Jonathan Clark.
9 */
10
11#include "config.h"
12
13#include "common.h"
14
15#include "tools.h"
16
17
18
19tool_picker::~tool_picker()
20{ delete old_pal;
21  delete map;
22  for (int i=0; i<total_icons; i++)
23    delete icons[i];                   // delete visual object, which should be a "shell"
24}
25
26void tool_picker::remap(palette *pal, image *screen)
27{
28  delete map;
29  map=new filter(old_pal,pal);
30  draw_first(screen);
31}
32
33tool_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) :
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;
42  for (int i=0; i<total_ic; i++)
43  {
44    if (icons[i]->width()>iw) iw=icons[i]->width();
45    if (icons[i]->height()>ih) ih=icons[i]->height();
46  }
47  map=new filter(icon_palette,pal);
48  old_pal=icon_palette->copy();
49  reconfigure();
50}
51
52void tool_picker::draw_item(image *screen, int x, int y, int num, int active)
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());
58  icons[num]->draw(screen,x,y,map);
59}
60
Note: See TracBrowser for help on using the repository browser.