summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/godmenu.cc
blob: 487c65c16135a451bed9e3244ed24f7532e1c01d (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
/**
 * @file
 * @brief Code for the god menu.
 * @todo The god menu.
 */

#include "AppHdr.h"
#include "godmenu.h"

#include "colour.h"
#include "libutil.h"
#include "religion.h"

GodMenuEntry::GodMenuEntry(god_type god_, bool long_name) :
    MenuEntry(god_name(god_, long_name), MEL_ITEM, 1, 0, false),
    god(god_)
{
    if (god == GOD_SHINING_ONE)
        hotkeys.push_back('1');
    else
    {
        hotkeys.push_back(text.at(0));
        hotkeys.push_back(toalower(text.at(0)));
    }
    int c = god_message_altar_colour(god);
    colour_text = colour_to_str(c);
    data = &text;
}

string GodMenuEntry::get_text(const bool unused) const
{
    if (level == MEL_ITEM && hotkeys.size())
    {
        char buf[300];
        snprintf(buf, sizeof buf, " <%s>%c</%s> %c %s",  colour_text.c_str(),
                 hotkeys[0], colour_text.c_str(), preselected ? '+' : '-', text.c_str());
        return string(buf);
    }
    return text;
}