git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1411 c06c8d41-db1a-0410-9941-cceddc491573
BXXOYFMWNQY4TLLJBFYROSH43KO5F4JQTATU3ZEJNKGIJGOIQN4AC Y2VKZYSQXLYYQNB6OSQP44IYLT2M56SE2ZW2MHOAZUODKCVDHEAQC RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC SH6NU4H5TG4O7CRXRHZ7MDHABZLWWXQ77NJDBHI7KCVHXHQYK46QC SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC HYS3HXTXATFPN7GLN3WBGDCP22UT2D3JBVUS7SP5FE7L54TDCJRQC 2KTJHQUX2LTU2BCLS5YXVRRKMOYKKIZAPF2LBKORFGSHEN5IO3IAC 77H4BWWPPGLM3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC // last updated 12may2000 {dlb}/* ************************************************************************ called from: acr* *********************************************************************** */void replay_messages(void);
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(msg_channel_type chan);void set_param(int p);void set_muted(bool m);protected:int overflow(int c);private:static const int INTERNAL_LENGTH = 500;char internal_buf[500]; // if your terminal is wider than this, too badint internal_count;int param;bool muted;msg_channel_type channel;};
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 badint internal_count;};
void initialise_mpr_streams();void deinitalise_mpr_streams();}
std::ostream& operator<<(std::ostream& os, const setchan& sc){mpr_stream_channel = sc.m_chan;return os;}
void initialise_mpr_streams(){for (int i = 0; i < NUM_MESSAGE_CHANNELS; ++i){mpr_stream_buf* pmsb =new mpr_stream_buf(static_cast<msg_channel_type>(i));std::ostream* pos = new std::ostream(pmsb);(*pos) << std::nounitbuf;stream_ptrs.push_back(pos);}stream << std::nounitbuf;}
elseinternal_buf[internal_count++] = c;
// again, can be improvedint mpr_stream_buf::overflow(int c){if ( muted )return 0;if ( c == '\n' ){// null-terminate and print the stringinternal_buf[internal_count] = 0;mpr(internal_buf, channel, param);internal_count = 0;
if ( internal_count + 3 > INTERNAL_LENGTH ){mpr("oops, hit overflow", MSGCH_DANGER);internal_count = 0;return std::streambuf::traits_type::eof();
// reset to defaults (param changing isn't sticky)set_param(0);}elseinternal_buf[internal_count++] = c;if ( internal_count + 3 > INTERNAL_LENGTH ){mpr("oops, hit overflow", MSGCH_DANGER);internal_count = 0;return std::streambuf::traits_type::eof();}return 0;
mpr_stream << "Welcome, " << you.your_name << " the "<< species_name( you.species,you.experience_level )<< " " << you.class_name << "."<< std::endl;
msg::stream << "Welcome, " << you.your_name << " the "<< species_name( you.species,you.experience_level )<< " " << you.class_name << "."<< std::endl;
int ch = 'x';mpr_stream << setchan(MSGCH_TUTORIAL)<< "Press any key to start the tutorial intro, "<< "or Escape to skip it."<< std::endl;ch = c_getch();
msg::streams(MSGCH_TUTORIAL)<< "Press any key to start the tutorial intro, ""or Escape to skip it."<< std::endl;const int ch = c_getch();