commit
148cb82f90
4 changed files with 28 additions and 4 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "gui/widgets/slider.hpp"
|
||||
#include "utils/foreach.tpp"
|
||||
|
||||
#include "../../game_preferences.hpp"
|
||||
#include "../../gamestatus.hpp"
|
||||
#include "../../log.hpp"
|
||||
#include "../../resources.hpp"
|
||||
|
@ -134,9 +135,9 @@ public:
|
|||
std::string nick_prefix = "<span color=\""+color+"\">";
|
||||
std::string nick_suffix ="</span> ";
|
||||
if (me) {
|
||||
str << nick_prefix << "<" << escape(t.nick()) << escape(t.text().substr(3))<<">" <<nick_suffix << std::endl;
|
||||
str << nick_prefix << "<" << escape(preferences::get_chat_timestamp(t.time())) << escape(t.nick()) << escape(t.text().substr(3))<<">" <<nick_suffix << std::endl;
|
||||
} else {
|
||||
str << nick_prefix << "<" << escape(t.nick()) << ">"<< nick_suffix << escape(t.text()) << std::endl;
|
||||
str << nick_prefix << "<" << escape(preferences::get_chat_timestamp(t.time())) << escape(t.nick()) << ">"<< nick_suffix << escape(t.text()) << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2562,6 +2562,10 @@ void menu_handler::send_chat_message(const std::string& message, bool allies_onl
|
|||
config cfg;
|
||||
cfg["id"] = preferences::login();
|
||||
cfg["message"] = message;
|
||||
const time_t time = ::time(NULL);
|
||||
std::stringstream ss;
|
||||
ss << time;
|
||||
cfg["time"] = ss.str();
|
||||
|
||||
const int side = is_observer() ? 0 : gui_->viewing_side();
|
||||
if(!is_observer()) {
|
||||
|
@ -2579,7 +2583,7 @@ void menu_handler::send_chat_message(const std::string& message, bool allies_onl
|
|||
}
|
||||
|
||||
recorder.speak(cfg);
|
||||
add_chat_message(time(NULL), cfg["id"], side, message,
|
||||
add_chat_message(time, cfg["id"], side, message,
|
||||
private_message ? events::chat_handler::MESSAGE_PRIVATE : events::chat_handler::MESSAGE_PUBLIC);
|
||||
|
||||
}
|
||||
|
|
|
@ -125,6 +125,22 @@ static void verify(const unit_map& units, const config& cfg) {
|
|||
LOG_REPLAY << "verification passed\n";
|
||||
}
|
||||
|
||||
static time_t get_time(const config &speak)
|
||||
{
|
||||
time_t time;
|
||||
if (!speak["time"].empty())
|
||||
{
|
||||
std::stringstream ss(speak["time"].str());
|
||||
ss >> time;
|
||||
}
|
||||
else
|
||||
{
|
||||
//fallback in case sender uses wesnoth that doesn't send timestamps
|
||||
time = ::time(NULL);
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
// FIXME: this one now has to be assigned with set_random_generator
|
||||
// from play_level or similar. We should surely hunt direct
|
||||
// references to it from this very file and move it out of here.
|
||||
|
@ -149,6 +165,7 @@ chat_msg::chat_msg(const config &cfg)
|
|||
} else {
|
||||
color_ = team::get_side_highlight_pango(side-1);
|
||||
}
|
||||
time_ = get_time(cfg);
|
||||
/*
|
||||
} else if (side==1) {
|
||||
color_ = "red";
|
||||
|
@ -937,7 +954,7 @@ bool do_replay_handle(int side_num, const std::string &do_untill)
|
|||
get_replay_source().add_chat_message_location();
|
||||
if (!get_replay_source().is_skipping() || is_whisper) {
|
||||
int side = child["side"];
|
||||
resources::screen->add_chat_message(time(NULL), speaker_name, side, message,
|
||||
resources::screen->add_chat_message(get_time(child), speaker_name, side, message,
|
||||
(team_name.empty() ? events::chat_handler::MESSAGE_PUBLIC
|
||||
: events::chat_handler::MESSAGE_PRIVATE),
|
||||
preferences::message_bell());
|
||||
|
|
|
@ -37,12 +37,14 @@ public:
|
|||
const std::string &text() const { return text_; }
|
||||
const std::string &nick() const { return nick_; }
|
||||
const std::string &color() const { return color_; }
|
||||
const time_t &time() const { return time_; }
|
||||
chat_msg(const config &cfg);
|
||||
virtual ~chat_msg();
|
||||
private:
|
||||
std::string color_;
|
||||
std::string nick_;
|
||||
std::string text_;
|
||||
time_t time_;
|
||||
};
|
||||
|
||||
class replay: public rand_rng::rng
|
||||
|
|
Loading…
Add table
Reference in a new issue