Implement chat log again.

Applies patch #2892 and fixes bug #7254.
This commit is contained in:
Mark de Wever 2011-08-11 19:37:25 +00:00
parent 9e7c002c76
commit d007c9aaa3
6 changed files with 43 additions and 11 deletions

View file

@ -23,6 +23,8 @@ Version 1.9.8+svn:
* Fixed 'agriculture' not getting translated sometimes and research
for agriculture not getting counted if the research order wasn't changed
(bug #16477)
* Added "chat_message_aging" advanced preference to allow setting the
ingame chat message aging interval
* Unit changes and balancing:
* Increased the XP requirements of the Arif from 40 to 47
* Increased the cost of the Falcon from 10 to 12

View file

@ -127,6 +127,17 @@
# max=50
#[/advanced_preference]
[advanced_preference]
field=chat_message_aging
name=_"Chat message aging"
description=_"Number of minutes to wait before clearing an ingame chat message. Disable aging with 0."
type=int
default=20
min=0
max=60
step=1
[/advanced_preference]
[advanced_preference]
field=joystick_support_enabled
name=_"Joystick Support"

View file

@ -1147,6 +1147,9 @@
name = "sylecn"
email = "sylecn_AT_gmail.com"
[/entry]
[entry]
name = "Tamas K. (negusnyul)"
[/entry]
[entry]
name = "Thibault Févry (iwontbecreative)"
comment = "Some GCI tasks and utils/wiki_grabber.py cleanup."

View file

@ -1424,19 +1424,22 @@ void game_display::add_chat_message(const time_t& time, const std::string& speak
void game_display::prune_chat_messages(bool remove_all)
{
unsigned message_ttl = remove_all ? 0 : 1200000;
unsigned max_chat_messages = preferences::chat_lines();
const unsigned message_aging = preferences::chat_message_aging();
const unsigned message_ttl = remove_all ? 0 : message_aging * 60 * 1000;
const unsigned max_chat_messages = preferences::chat_lines();
int movement = 0;
while (!chat_messages_.empty() &&
(chat_messages_.front().created_at + message_ttl < SDL_GetTicks() ||
chat_messages_.size() > max_chat_messages))
{
const chat_message &old = chat_messages_.front();
movement += font::get_floating_label_rect(old.handle).h;
font::remove_floating_label(old.speaker_handle);
font::remove_floating_label(old.handle);
chat_messages_.erase(chat_messages_.begin());
if(message_aging != 0 || remove_all || chat_messages_.size() > max_chat_messages) {
while (!chat_messages_.empty() &&
(chat_messages_.front().created_at + message_ttl < SDL_GetTicks() ||
chat_messages_.size() > max_chat_messages))
{
const chat_message &old = chat_messages_.front();
movement += font::get_floating_label_rect(old.handle).h;
font::remove_floating_label(old.speaker_handle);
font::remove_floating_label(old.handle);
chat_messages_.erase(chat_messages_.begin());
}
}
foreach (const chat_message &cm, chat_messages_) {

View file

@ -795,6 +795,16 @@ void set_chat_lines(int lines)
preferences::set("chat_lines", lines);
}
void set_chat_message_aging(const int aging)
{
preferences::set("chat_message_aging", aging);
}
int chat_message_aging()
{
return lexical_cast_default<int>(preferences::get("chat_message_aging"), 20);
}
std::set<std::string> &encountered_units() {
return encountered_units_set;
}

View file

@ -192,6 +192,9 @@ namespace preferences {
int chat_lines();
void set_chat_lines(int lines);
int chat_message_aging();
void set_chat_message_aging(const int aging);
bool compress_saves();
bool startup_effect();