summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tilereg-popup.cc
blob: 172c722ed15f5fcdff1b6dd6ab4eae219bf16528 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "AppHdr.h"

#ifdef USE_TILE_LOCAL

#include "tilereg-popup.h"
#include "tilereg-menu.h"

#include "menu.h"
#include "macro.h"
#include "tilebuf.h"
#include "tilefont.h"
#include "cio.h"

PopupRegion::PopupRegion(ImageManager *im, FontWrapper *entry) :
    MenuRegion(im, entry),
    m_retval(0)
{
}

int PopupRegion::handle_mouse(MouseEvent &event)
{
    // if mouse is outside popup box, pretend to handle event (to prevent
    // clash with other regions)
    int retval = MenuRegion::handle_mouse(event);
    return retval == 0 ? CK_NO_KEY : retval;
}

void PopupRegion::render()
{
#ifdef DEBUG_TILES_REDRAW
    cprintf("rendering PopupRegion\n");
#endif
    if (m_dirty)
        place_entries();

    MenuRegion::set_transform();
    m_shape_buf.draw();
    m_line_buf.draw();
    for (int i = 0; i < TEX_MAX; i++)
        m_tile_buf[i].draw();
    m_font_buf.draw();
}

void PopupRegion::place_entries()
{
    _clear_buffers();
    const VColour bgcolour(0, 0, 0, 63);
    const VColour border(255, 255, 255, 255);
    const VColour panel(0, 0, 0, 255);
    m_shape_buf.add(0, 0, ex, ey, bgcolour);
    m_shape_buf.add(ex / 4 - 2, ey / 4 - 2,
                    ex * 3 / 4 + 2, ey * 3 / 4 + 2, border);
    m_shape_buf.add(ex / 4, ey / 4, ex * 3 / 4, ey * 3 / 4, panel);
    _place_entries(ex / 4, ey / 4, ex / 2);
}

void PopupRegion::run()
{
    m_retval = getchm(KMC_CONFIRM);
}

int PopupRegion::get_retval()
{
    return m_retval;
}
#endif