mail[Wesnoth-commits] r20049 - in /trunk: ./ src/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by uso on September 02, 2007 - 06:53:
Author: uso
Date: Sun Sep  2 06:52:26 2007
New Revision: 20049

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20049&view=rev
Log:
rearrange buttons in the display preferences, new button and slider to switch
unit idle animations on and off and set their frequency (adresses bug #9024),
changes are applied only after the next idle animation of a unit (and for new
units), maybe we need a loop over all units after a preference change

Modified:
    trunk/changelog
    trunk/players_changelog
    trunk/src/display.cpp
    trunk/src/display.hpp
    trunk/src/game_preferences_display.cpp
    trunk/src/preferences.cpp
    trunk/src/preferences.hpp
    trunk/src/preferences_display.cpp
    trunk/src/preferences_display.hpp
    trunk/src/unit.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Sep  2 06:52:26 2007
@@ -19,6 +19,8 @@
  * graphics:
    * new graphics for the highwayman
    * no more idle animations for units next to an enemy unit
+   * new button and slider in preferences to switch unit idle animations on
+     and off and set their frequency
  * miscellaneous and bug fixes
    * various bug fixes and code cleanups
 

Modified: trunk/players_changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/players_changelog?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/players_changelog (original)
+++ trunk/players_changelog Sun Sep  2 06:52:26 2007
@@ -9,6 +9,8 @@
 
   * Graphics
     * New graphics for Highwayman.
+    * New button and slider in preferences to switch unit idle animations on
+      and off and set their frequency.
 
   * Language and translations
     * Updated translations: Bulgarian, Danish, Dutch, Finnish, French, 
German, 

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sun Sep  2 06:52:26 2007
@@ -62,7 +62,6 @@
        size_t sunset_timer = 0;
 
        bool benchmark = false;
-
 }
 
 display::display(CVideo& video, const gamemap& map, const config& theme_cfg, 
const config& cfg, const config& level) :
@@ -77,11 +76,15 @@
        invalidateGameStatus_(true),
        map_labels_(*this,map, 0),
        _scroll_event("scrolled"),
-       nextDraw_(0), fps_handle_(0)
+       nextDraw_(0), fps_handle_(0),
+       idle_anim_(preferences::idle_anim()),
+       idle_anim_rate_(1.0)
 {
        if(non_interactive()) {
                screen_.lock_updates(true);
        }
+
+       set_idle_anim_rate(preferences::idle_anim_rate());
 
        std::fill(reportRects_,reportRects_+reports::NUM_REPORTS,empty_rect);
 
@@ -1499,6 +1502,11 @@
                return 1.0;
 }
 
+void display::set_idle_anim_rate(int rate)
+{
+       idle_anim_rate_ = pow(2.0, -rate/10.0);
+}
+
 void display::redraw_everything()
 {
        if(screen_.update_locked())

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Sun Sep  2 06:52:26 2007
@@ -258,6 +258,12 @@
        double turbo_speed() const;
 
        void set_turbo_speed(const double speed) { turbo_speed_ = speed; }
+
+       // control unit idle animations and their frequency
+       void set_idle_anim(bool ison) { idle_anim_ = ison; }
+       bool idle_anim() const { return idle_anim_; }
+       void set_idle_anim_rate(int rate);
+       double idle_anim_rate() const { return idle_anim_rate_; }
 
        //! Add a location to highlight.
        //! Note that this has nothing to do with selecting hexes,
@@ -434,6 +440,9 @@
        std::vector<surface> tile_stack_;
        //! Handle for the label which displays frames per second.
        int fps_handle_;
+
+       bool idle_anim_;
+       double idle_anim_rate_;
 };
 
 //! Simplified display class for the editor.

Modified: trunk/src/game_preferences_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences_display.cpp?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/src/game_preferences_display.cpp (original)
+++ trunk/src/game_preferences_display.cpp Sun Sep  2 06:52:26 2007
@@ -101,8 +101,9 @@
 
 //
        // change
-       gui::slider music_slider_, sound_slider_, UI_sound_slider_, 
bell_slider_, scroll_slider_,
-                               gamma_slider_, chat_lines_slider_, 
buffer_size_slider_;
+       gui::slider music_slider_, sound_slider_, UI_sound_slider_, 
bell_slider_,
+                   scroll_slider_, gamma_slider_, chat_lines_slider_,
+                   buffer_size_slider_, idle_anim_slider_;
        gui::list_slider<double> turbo_slider_;
        gui::button fullscreen_button_, turbo_button_, show_ai_moves_button_,
                        show_grid_button_, save_replays_button_, 
delete_autosaves_button_,
@@ -122,10 +123,11 @@
                        advanced_sound_button_, normal_sound_button_,
                        UI_sound_button_, sample_rate_button1_,
                        sample_rate_button2_, sample_rate_button3_,
-                       confirm_sound_button_;
-       gui::label music_label_, sound_label_, UI_sound_label_, bell_label_, 
scroll_label_,
-                               gamma_label_, chat_lines_label_, 
turbo_slider_label_,
-                               sample_rate_label_, buffer_size_label_;
+                       confirm_sound_button_, idle_anim_button_;
+       gui::label music_label_, sound_label_, UI_sound_label_, bell_label_,
+                  scroll_label_, gamma_label_, chat_lines_label_,
+                  turbo_slider_label_, sample_rate_label_, 
buffer_size_label_,
+                  idle_anim_slider_label_;
        gui::textbox sample_rate_input_, friends_input_;
 
        unsigned slider_label_width_;
@@ -146,10 +148,11 @@
 //change
 preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
        : gui::preview_pane(disp.video()),
-         music_slider_(disp.video()), sound_slider_(disp.video()), 
UI_sound_slider_(disp.video()),
-         bell_slider_(disp.video()),
-         scroll_slider_(disp.video()), gamma_slider_(disp.video()), 
chat_lines_slider_(disp.video()),
-         buffer_size_slider_(disp.video()), turbo_slider_(disp.video()),
+         music_slider_(disp.video()), sound_slider_(disp.video()),
+         UI_sound_slider_(disp.video()), bell_slider_(disp.video()),
+         scroll_slider_(disp.video()), gamma_slider_(disp.video()),
+         chat_lines_slider_(disp.video()), buffer_size_slider_(disp.video()),
+         idle_anim_slider_(disp.video()), turbo_slider_(disp.video()),
 
          fullscreen_button_(disp.video(), _("Toggle Full Screen"), 
gui::button::TYPE_CHECK),
          turbo_button_(disp.video(), _("Accelerated Speed"), 
gui::button::TYPE_CHECK),
@@ -189,6 +192,7 @@
          sample_rate_button2_(disp.video(), "44100", 
gui::button::TYPE_CHECK),
          sample_rate_button3_(disp.video(), _("Custom"), 
gui::button::TYPE_CHECK),
          confirm_sound_button_(disp.video(), _("Apply")),
+         idle_anim_button_(disp.video(), _("Show Unit Idle Animations"), 
gui::button::TYPE_CHECK),
 
          music_label_(disp.video(), _("Music Volume:")), 
sound_label_(disp.video(), _("SFX Volume:")),
          UI_sound_label_(disp.video(), _("UI Sound Volume:")),
@@ -196,6 +200,7 @@
          gamma_label_(disp.video(), _("Gamma:")), 
chat_lines_label_(disp.video(), ""),
          turbo_slider_label_(disp.video(), "", font::SIZE_SMALL ),
          sample_rate_label_(disp.video(), _("Sample Rate (Hz):")), 
buffer_size_label_(disp.video(), ""),
+         idle_anim_slider_label_(disp.video(), _("Frequency:")),
 
          sample_rate_input_(disp.video(), 70),
          friends_input_(disp.video(), 170),
@@ -312,6 +317,15 @@
        }
        turbo_slider_.set_help_string(_("Units move and fight speed"));
 
+       idle_anim_button_.set_check(idle_anim());
+       idle_anim_button_.set_help_string(_("Show unit idle animations"));
+
+       // exponential scale (2^(n/10))
+       idle_anim_slider_.set_min(-40);
+       idle_anim_slider_.set_max(30);
+       idle_anim_slider_.set_value(idle_anim_rate());
+       idle_anim_slider_.set_help_string(_("Set the frequency of unit idle 
animations"));
+
        show_ai_moves_button_.set_check(!show_ai_moves());
        show_ai_moves_button_.set_help_string(_("Do not animate AI units 
moving"));
 
@@ -386,9 +400,11 @@
        h.push_back(&gamma_slider_);
        h.push_back(&chat_lines_slider_);
        h.push_back(&turbo_slider_);
+       h.push_back(&idle_anim_slider_);
        h.push_back(&buffer_size_slider_);
        h.push_back(&fullscreen_button_);
        h.push_back(&turbo_button_);
+       h.push_back(&idle_anim_button_);
        h.push_back(&show_ai_moves_button_);
        h.push_back(&save_replays_button_);
        h.push_back(&delete_autosaves_button_);
@@ -433,6 +449,7 @@
        h.push_back(&scroll_label_);
        h.push_back(&gamma_label_);
        h.push_back(&turbo_slider_label_);
+       h.push_back(&idle_anim_slider_label_);
        h.push_back(&chat_lines_label_);
        h.push_back(&sample_rate_label_);
        h.push_back(&buffer_size_label_);
@@ -458,7 +475,7 @@
        const int top_border = 28;
        const int bottom_border = 40;
        const int short_interline = 20;
-       const int item_interline = 50;
+       const int item_interline = 40;
 #endif
        const int bottom_row_y = rect.y + rect.h - bottom_border;
 
@@ -485,16 +502,22 @@
        // Display tab
        ypos = rect.y + top_border;
        gamma_button_.set_location(rect.x, ypos);
-       ypos += item_interline;
+       ypos += short_interline;
        gamma_label_.set_location(rect.x, ypos);
        SDL_Rect gamma_rect = { rect.x + gamma_label_.width(), ypos,
                                                        rect.w - 
gamma_label_.width() - right_border, 0 };
        gamma_slider_.set_location(gamma_rect);
+       ypos += item_interline; fullscreen_button_.set_location(rect.x, ypos);
+       ypos += item_interline; 
show_colour_cursors_button_.set_location(rect.x, ypos);
        ypos += item_interline; flip_time_button_.set_location(rect.x,ypos);
        ypos += item_interline; 
show_floating_labels_button_.set_location(rect.x, ypos);
-       ypos += item_interline; 
show_colour_cursors_button_.set_location(rect.x, ypos);
        ypos += item_interline; show_haloing_button_.set_location(rect.x, 
ypos);
-       ypos += item_interline; fullscreen_button_.set_location(rect.x, ypos);
+       ypos += item_interline; idle_anim_button_.set_location(rect.x, ypos);
+       ypos += short_interline;
+       idle_anim_slider_label_.set_location(rect.x, ypos);
+       SDL_Rect idle_anim_rect = { rect.x + idle_anim_slider_label_.width(), 
ypos,
+                                   rect.w - idle_anim_slider_label_.width() 
- right_border, 0 };
+       idle_anim_slider_.set_location(idle_anim_rect);
        video_mode_button_.set_location(rect.x, bottom_row_y - 
video_mode_button_.height());
        theme_button_.set_location(rect.x + video_mode_button_.width() + 10,
                                   bottom_row_y - theme_button_.height());
@@ -666,14 +689,23 @@
                        set_show_haloes(show_haloing_button_.checked());
                if (gamma_button_.pressed()) {
                        set_adjust_gamma(gamma_button_.checked());
-                       bool enable_gamma = adjust_gamma();
+                       const bool enable_gamma = adjust_gamma();
                        gamma_slider_.enable(enable_gamma);
                        gamma_label_.enable(enable_gamma);
                }
                if (flip_time_button_.pressed())
                        set_flip_time(flip_time_button_.checked());
+               if (idle_anim_button_.pressed()) {
+                       const bool enable_idle_anim = 
idle_anim_button_.checked();
+                       idle_anim_slider_label_.enable(enable_idle_anim);
+                       idle_anim_slider_.enable(enable_idle_anim);
+                       set_idle_anim(enable_idle_anim);
+                       if (!enable_idle_anim)
+                               idle_anim_slider_.set_value(0);
+               }
 
                set_gamma(gamma_slider_.value());
+               set_idle_anim_rate(idle_anim_slider_.value());
 
                return;
        }
@@ -976,6 +1008,11 @@
        show_colour_cursors_button_.hide(hide_display);
        show_haloing_button_.hide(hide_display);
        fullscreen_button_.hide(hide_display);
+       idle_anim_button_.hide(hide_display);
+       idle_anim_slider_label_.hide(hide_display);
+       idle_anim_slider_label_.enable(idle_anim());
+       idle_anim_slider_.hide(hide_display);
+       idle_anim_slider_.enable(idle_anim());
        video_mode_button_.hide(hide_display);
        theme_button_.hide(hide_display);
        flip_time_button_.hide(hide_display);

Modified: trunk/src/preferences.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/preferences.cpp?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/src/preferences.cpp (original)
+++ trunk/src/preferences.cpp Sun Sep  2 06:52:26 2007
@@ -139,6 +139,26 @@
 void save_turbo_speed(const double speed)
 {
        preferences::set("turbo_speed", lexical_cast<std::string>(speed));
+}
+
+bool idle_anim()
+{
+       return  utils::string_bool(get("idle_anim"), true);
+}
+
+void _set_idle_anim(const bool ison)
+{
+       prefs["idle_anim"] = (ison ? "yes" : "no");
+}
+
+int idle_anim_rate()
+{
+       return lexical_cast_default<int>(get("idle_anim_rate"), 0);
+}
+
+void _set_idle_anim_rate(const int rate)
+{
+       preferences::set("idle_anim_rate", lexical_cast<std::string>(rate));
 }
 
 const std::string& language()

Modified: trunk/src/preferences.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/preferences.hpp?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/src/preferences.hpp (original)
+++ trunk/src/preferences.hpp Sun Sep  2 06:52:26 2007
@@ -63,6 +63,12 @@
        double turbo_speed();
        void save_turbo_speed(const double speed);
 
+       bool idle_anim();
+       void _set_idle_anim(const bool ison);
+
+       int idle_anim_rate();
+       void _set_idle_anim_rate(const int rate);
+
        const std::string& language();
        void set_language(const std::string& s);
 

Modified: trunk/src/preferences_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/preferences_display.cpp?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/src/preferences_display.cpp (original)
+++ trunk/src/preferences_display.cpp Sun Sep  2 06:52:26 2007
@@ -172,6 +172,20 @@
        _set_colour_cursors(value);
 
        cursor::set();
+}
+
+void set_idle_anim(bool ison) {
+       _set_idle_anim(ison);
+       if(disp != NULL) {
+               disp->set_idle_anim(ison);
+       }
+}
+
+void set_idle_anim_rate(int rate) {
+       _set_idle_anim_rate(rate);
+       if(disp != NULL) {
+               disp->set_idle_anim_rate(rate);
+       }
 }
 
 namespace {

Modified: trunk/src/preferences_display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/preferences_display.hpp?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/src/preferences_display.hpp (original)
+++ trunk/src/preferences_display.hpp Sun Sep  2 06:52:26 2007
@@ -33,6 +33,10 @@
        void set_turbo_speed(double speed);
        void set_colour_cursors(bool value);
 
+       // control unit idle animations
+       void set_idle_anim(bool ison);
+       void set_idle_anim_rate(int rate);
+
        void show_preferences_dialog(display& disp, const config& game_cfg);
        bool show_video_mode_dialog(display& disp);
        bool show_theme_dialog(display& disp);

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=20049&r1=20048&r2=20049&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sun Sep  2 06:52:26 2007
@@ -1757,7 +1757,12 @@
        }
        anim_->start_animation(anim_->get_begin_time(), false, 
disp.turbo_speed());
        frame_begin_time_ = anim_->get_begin_time() -1;
-       next_idling_= get_current_animation_tick() +20000 +rand()%20000;
+       if (disp.idle_anim()) {
+               next_idling_ = get_current_animation_tick()
+                       + static_cast<int>((20000 + rand() % 20000) * 
disp.idle_anim_rate());
+       } else {
+               next_idling_ = INT_MAX;
+       }
        if(is_attack_anim) {
                return &((attack_animation*)anim_)->get_missile_anim();
        } else {




Related Messages


Powered by MHonArc, Updated Sun Sep 02 07:20:13 2007