summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/message.h
blob: 96a2094f4048ac7d5e8b91846f7268d5a7510961 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 *  File:       message.cc
 *  Summary:    Functions used to print messages.
 *  Written by: Linley Henzell
 *
 *  Modified for Crawl Reference by $Author$ on $Date$
 *
 *  Change History (most recent first):
 *
 *               <2>     5/08/99        JDJ             mpr takes a const char* instead of a char array.
 *               <1>     -/--/--        LRH             Created
 */

#ifndef MESSAGE_H
#define MESSAGE_H

#include <string>
#include <streambuf>

#include "externs.h"

struct message_item {
    int                 channel;        // message channel
    int                 param;          // param for channel (god, enchantment)
    std::string         text;           // text of message
};


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: ability - acr - command - direct - effects - item_use -
 *              misc - player - spell - spl-book - spells1 - spells2 -
 *              spells3
 * *********************************************************************** */
void mesclr( bool force = false );


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: acr - bang - beam - decks - fight - files - it_use3 -
 *              item_use - items - message - misc - ouch - player -
 *              religion - spell - spells - spells2 - spells3
 * *********************************************************************** */
void more(void);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: ability - acr - bang - beam - chardump - command - debug -
 *              decks - direct - effects - fight - files - food - it_use2 -
 *              it_use3 - item_use - items - macro - misc - monplace -
 *              monstuff - mstuff2 - mutation - ouch - overmap - player -
 *              religion - shopping - skills - spell - spl-book - spells -
 *              spells1 - spells2 - spells3 - spells4 - stuff - transfor -
 *              view
 * *********************************************************************** */
void mpr(const char *inf, int channel = MSGCH_PLAIN, int param = 0);

class formatted_string;

void formatted_mpr(const formatted_string& fs, int channel = MSGCH_PLAIN,
                   int param = 0);
                   
void formatted_message_history(const std::string st,
                               int channel = MSGCH_PLAIN, int param = 0);
                               
// 4.1-style mpr, currently named mprf for minimal disruption.
void mprf( int channel, int param, const char *format, ... );
void mprf( int channel, const char *format, ... );
void mprf( const char *format, ... );

class no_messages
{
public:
    no_messages();
    ~no_messages();
private:
    bool msuppressed;
};

// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: acr
 * *********************************************************************** */
void replay_messages(void);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: acr - it_use3 - items - religion
 * *********************************************************************** */
void set_colour(char set_message_colour);


// last updated 18mar2001 {dlb}
/* ***********************************************************************
 * called from: acr
 * *********************************************************************** */
bool any_messages(void);

// last updated 13oct2003 {dlb}
/* ***********************************************************************
 * called from: chardump
 * *********************************************************************** */
std::string get_last_messages(int mcount);

int channel_to_colour( int channel, int param = 0 );

struct setchan
{
    setchan(msg_channel_type chan);
    msg_channel_type m_chan;
};

struct setparam
{
    setparam(int param);
    int m_param;
};

std::ostream& operator<<(std::ostream& os, const setchan& sc);
std::ostream& operator<<(std::ostream& os, const setparam& sp);

class mpr_stream_buf : public std::streambuf
{
public:
    mpr_stream_buf();
protected:
    int overflow(int c);
private:
    static const int INTERNAL_LENGTH = 500;
    char internal_buf[500]; // if your terminal is wider than this, too bad
    int internal_count;
};

extern std::ostream mpr_stream;


#endif