--- preferences.cpp 2005-04-16 21:35:32.000000000 +0200 +++ preferences.cpp.maj 2005-04-22 00:35:21.691770848 +0200 @@ -295,6 +295,8 @@ return prefs["adjust_gamma"] == "yes"; } + + void set_adjust_gamma(bool val) { //if we are turning gamma adjustment off, then set it to '1.0' @@ -737,6 +739,34 @@ prefs["flip_time"] = value ? "yes" : "no"; } +bool chat_timestamp() +{ + return prefs["chat_timestamp"] == "yes"; +} + +void set_chat_timestamp(bool value) +{ + prefs["chat_timestamp"] = value ? "yes" : "no"; +} + +int chat_lines() +{ + // defaults to 6 chat log lines displayed + static const int default_value = 6; + const string_map::const_iterator lines = prefs.values.find("chat_lines"); + if(lines != prefs.values.end() && lines->second.empty() == false) + return atoi(lines->second.c_str()); + else + return default_value; +} + +void set_chat_lines(int lines) +{ + std::stringstream stream; + stream << lines; + prefs["chat_lines"] = stream.str(); +} + bool show_fps() { return fps; @@ -810,16 +840,17 @@ void set_selection(int index); void update_location(SDL_Rect const &rect); - gui::slider music_slider_, sound_slider_, scroll_slider_, gamma_slider_; + gui::slider music_slider_, sound_slider_, scroll_slider_, gamma_slider_, + chat_lines_slider_; gui::button fullscreen_button_, turbo_button_, show_ai_moves_button_, show_grid_button_, show_floating_labels_button_, turn_dialog_button_, turn_bell_button_, show_team_colours_button_, show_colour_cursors_button_, show_haloing_button_, video_mode_button_, hotkeys_button_, gamma_button_, - flip_time_button_; - gui::label music_label_, sound_label_, scroll_label_, gamma_label_; + flip_time_button_, chat_timestamp_button_; + gui::label music_label_, sound_label_, scroll_label_, gamma_label_, chat_lines_label_; unsigned slider_label_width_; - enum TAB { GENERAL_TAB, DISPLAY_TAB, SOUND_TAB }; + enum TAB { GENERAL_TAB, DISPLAY_TAB, SOUND_TAB, MULTIPLAYER_TAB }; TAB tab_; display &disp_; }; @@ -828,6 +859,7 @@ : gui::preview_pane(disp.video()), music_slider_(disp.video()), sound_slider_(disp.video()), scroll_slider_(disp.video()), gamma_slider_(disp.video()), + chat_lines_slider_(disp.video()), fullscreen_button_(disp.video(), _("Toggle Full Screen"), gui::button::TYPE_CHECK), turbo_button_(disp.video(), _("Accelerated Speed"), gui::button::TYPE_CHECK), show_ai_moves_button_(disp.video(), _("Skip AI Moves"), gui::button::TYPE_CHECK), @@ -842,8 +874,10 @@ hotkeys_button_(disp.video(), _("Hotkeys")), gamma_button_(disp.video(), _("Adjust Gamma"), gui::button::TYPE_CHECK), flip_time_button_(disp.video(), _("Reverse Time Graphics"), gui::button::TYPE_CHECK), + chat_timestamp_button_(disp.video(), _("Chat Timestamping"), gui::button::TYPE_CHECK), music_label_(disp.video(), _("Music Volume:")), sound_label_(disp.video(), _("SFX Volume:")), scroll_label_(disp.video(), _("Scroll Speed:")), gamma_label_(disp.video(), _("Gamma:")), + chat_lines_label_(disp.video(), _("Chat Lines:")), slider_label_width_(0), tab_(GENERAL_TAB), disp_(disp) { // FIXME: this box should be vertically centered on the screen, but is not @@ -855,8 +889,9 @@ slider_label_width_ = maximum(music_label_.width(), maximum(sound_label_.width(), + maximum(chat_lines_label_.width(), maximum(scroll_label_.width(), - gamma_label_.width()))); + gamma_label_.width() )))); sound_slider_.set_min(1); sound_slider_.set_max(100); @@ -880,6 +915,14 @@ gamma_slider_.set_max(200); gamma_slider_.set_value(gamma()); gamma_slider_.set_help_string(_("Change the brightness of the display")); + + chat_lines_slider_.set_min(1); + chat_lines_slider_.set_max(20); + chat_lines_slider_.set_value(chat_lines()); + chat_lines_slider_.set_help_string(_("Set the amount of chat lines shown")); + + chat_timestamp_button_.set_check(chat_timestamp()); + chat_timestamp_button_.set_help_string(_("Add a timestamp to chat messages")); fullscreen_button_.set_check(fullscreen()); fullscreen_button_.set_help_string(_("Choose whether the game should run full screen or in a window")); @@ -971,6 +1014,14 @@ rect.w - slider_label_width_ - border, 0 }; sound_slider_.set_location(sound_rect); + // Multiplayer tab + ypos = rect.y; + chat_lines_label_.set_location(rect.x, ypos); + SDL_Rect chat_lines_rect = { rect.x + slider_label_width_, ypos, + rect.w - slider_label_width_ - border, 0 }; + chat_lines_slider_.set_location(chat_lines_rect); + ypos += item_interline; chat_timestamp_button_.set_location(rect.x, ypos); + set_selection(tab_); } @@ -1010,10 +1061,14 @@ } if (flip_time_button_.pressed()) set_flip_time(flip_time_button_.checked()); + if (chat_timestamp_button_.pressed()) + set_chat_timestamp(chat_timestamp_button_.checked()); + set_sound_volume(sound_slider_.value()); set_music_volume(music_slider_.value()); set_scroll_speed(scroll_slider_.value()); set_gamma(gamma_slider_.value()); + set_chat_lines(chat_lines_slider_.value()); } void preferences_dialog::set_selection(int index) @@ -1049,6 +1104,11 @@ music_slider_.hide(hide_sound); sound_label_.hide(hide_sound); sound_slider_.hide(hide_sound); + + bool hide_multiplayer = tab_ != MULTIPLAYER_TAB; + chat_lines_label_.hide(hide_multiplayer); + chat_lines_slider_.hide(hide_multiplayer); + chat_timestamp_button_.hide(hide_multiplayer); } } @@ -1062,6 +1122,7 @@ items.push_back(pre + "general.png" + sep + dsgettext(GETTEXT_DOMAIN,"Prefs section^General")); items.push_back(pre + "display.png" + sep + dsgettext(GETTEXT_DOMAIN,"Prefs section^Display")); items.push_back(pre + "music.png" + sep + dsgettext(GETTEXT_DOMAIN,"Prefs section^Sound")); + items.push_back(pre + "multiplayer.png" + sep + dsgettext(GETTEXT_DOMAIN,"Prefs section^Multiplayer")); for(;;) { try {