00001
00002
00003
00004
00005
00006
00007 #ifndef MESSAGE_H
00008 #define MESSAGE_H
00009
00010 #include <string>
00011 #include <streambuf>
00012 #include <iostream>
00013
00014 #include "enum.h"
00015 #include "mpr.h"
00016
00017
00018 void display_message_window();
00019 void clear_message_window();
00020
00021 void scroll_message_window(int n);
00022
00023 void mesclr(bool force = false);
00024
00025 void flush_prev_message();
00026
00027 void more(bool user_forced = false);
00028
00029 class formatted_string;
00030
00031 void formatted_mpr(const formatted_string& fs,
00032 msg_channel_type channel = MSGCH_PLAIN, int param = 0);
00033
00034 void formatted_message_history(const std::string &st,
00035 msg_channel_type channel = MSGCH_PLAIN,
00036 int param = 0,
00037 int wrap_col = 0);
00038
00039
00040 void mpr_comma_separated_list(const std::string prefix,
00041 const std::vector<std::string> list,
00042 const std::string &andc = ", and ",
00043 const std::string &comma = ", ",
00044 const msg_channel_type channel = MSGCH_PLAIN,
00045 const int param = 0);
00046
00047 #include "cio.h"
00048
00049
00050
00051 void msgwin_set_temporary(bool temp);
00052
00053
00054 void msgwin_clear_temporary();
00055
00056 void msgwin_prompt(std::string prompt);
00057 void msgwin_reply(std::string reply);
00058
00059 unsigned int msgwin_lines();
00060
00061
00062
00063 void msgwin_got_input();
00064
00065 int msgwin_get_line(std::string prompt,
00066 char *buf, int len,
00067 input_history *mh = NULL,
00068 int (*keyproc)(int &c) = NULL);
00069
00070
00071
00072 template<int> static int msgwin_get_line_autohist_temp(std::string prompt,
00073 char *buf, int len)
00074 {
00075 static input_history hist(10);
00076 return msgwin_get_line(prompt, buf, len, &hist);
00077 }
00078
00079
00080
00081 #define msgwin_get_line_autohist(prompt, buf, len) \
00082 msgwin_get_line_autohist_temp<__LINE__>(prompt, buf, len)
00083
00084
00085
00086 void msgwin_new_cmd();
00087
00088 void msgwin_new_turn();
00089
00090 class no_messages
00091 {
00092 public:
00093 no_messages();
00094 ~no_messages();
00095 private:
00096 bool msuppressed;
00097 };
00098
00099 void save_messages(writer& outf);
00100 void load_messages(reader& inf);
00101 void clear_message_store();
00102
00103
00104 bool any_messages();
00105
00106 void replay_messages();
00107
00108 void set_more_autoclear(bool on);
00109
00110 std::string get_last_messages(int mcount);
00111
00112 inline std::vector<std::string> get_recent_messages(int &message_pos,
00113 bool dumpworthy_only = true,
00114 std::vector<int> *channels = NULL)
00115 {
00116 return std::vector<std::string>();
00117 }
00118
00119
00120 int channel_to_colour(msg_channel_type channel, int param = 0);
00121
00122 namespace msg
00123 {
00124 extern std::ostream stream;
00125 std::ostream& streams(msg_channel_type chan = MSGCH_PLAIN);
00126
00127 struct setparam
00128 {
00129 setparam(int param);
00130 int m_param;
00131 };
00132
00133 struct mute
00134 {
00135 mute(bool value = true);
00136 bool m_value;
00137 };
00138
00139 class mpr_stream_buf : public std::streambuf
00140 {
00141 public:
00142 mpr_stream_buf(msg_channel_type chan);
00143 virtual ~mpr_stream_buf() {}
00144 void set_param(int p);
00145 void set_muted(bool m);
00146 protected:
00147 int overflow(int c);
00148 private:
00149 static const int INTERNAL_LENGTH = 500;
00150 char internal_buf[500];
00151 int internal_count;
00152 int param;
00153 bool muted;
00154 msg_channel_type channel;
00155 };
00156
00157 void initialise_mpr_streams();
00158 void deinitialise_mpr_streams();
00159 }
00160
00161 std::ostream& operator<<(std::ostream& os, const msg::setparam& sp);
00162
00163 void set_msg_dump_file(FILE* file);
00164
00165 #endif