source: abuse/branches/lol/src/imlib/tools.cpp @ 732

Last change on this file since 732 was 732, checked in by Sam Hocevar, 8 years ago

build: SDL2 compilation fixes.

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-2013 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 HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "common.h"
16
17#include "imlib/tools.h"
18
19AToolPicker::AToolPicker(ivec2 pos, int id,
20          int show_h, AVisualObject **Icons, int *Ids, int total_ic,
21          Palette *icon_palette, Palette *pal)
22  : AScrollPicker(pos, id, show_h, 1, 1, 0)
23{
24    iw = ih = 0;
25    icons = Icons;
26    ids = Ids;
27    total_icons = total_ic;
28    for (int i = 0; i < total_ic; i++)
29    {
30        iw = lol::max(iw, icons[i]->Size().x);
31        ih = lol::max(ih, icons[i]->Size().y);
32    }
33    map = new Filter(icon_palette, pal);
34    old_pal = icon_palette->Copy();
35    reconfigure();
36}
37
38AToolPicker::~AToolPicker()
39{
40    delete old_pal;
41    delete map;
42    for (int i = 0; i < total_icons; i++)
43        delete icons[i];                   // delete visual object, which should be a "shell"
44}
45
46void AToolPicker::remap(Palette *pal, AImage *screen)
47{
48    delete map;
49    map = new Filter(old_pal, pal);
50    draw_first(screen);
51}
52
53void AToolPicker::DrawItem(AImage *screen, ivec2 pos, int num, int active)
54{
55    screen->Bar(pos, pos + ivec2(iw - 1, ih - 1),
56                active ? wm->bright_color() : wm->black());
57    icons[num]->Draw(screen, pos, map);
58}
59
Note: See TracBrowser for help on using the repository browser.