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
This commit is contained in:
parent
9d37dce64c
commit
62dd3f8aac
10 changed files with 125 additions and 18 deletions
|
@ -19,6 +19,8 @@ Version 1.3.7+svn:
|
|||
* 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
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ Version 1.3.7+svn:
|
|||
|
||||
* 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,
|
||||
|
|
|
@ -62,7 +62,6 @@ namespace {
|
|||
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,12 +76,16 @@ display::display(CVideo& video, const gamemap& map, const config& theme_cfg, con
|
|||
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);
|
||||
|
||||
image::set_zoom(zoom_);
|
||||
|
@ -1499,6 +1502,11 @@ double display::turbo_speed() const
|
|||
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())
|
||||
|
|
|
@ -259,6 +259,12 @@ public:
|
|||
|
||||
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,
|
||||
//! it is pure highlighting. These hexes will be highlighted
|
||||
|
@ -434,6 +440,9 @@ private:
|
|||
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.
|
||||
|
|
|
@ -101,8 +101,9 @@ private:
|
|||
|
||||
//
|
||||
// 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 @@ private:
|
|||
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 @@ public:
|
|||
//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 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
|
|||
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 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
|
|||
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 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
|
|||
}
|
||||
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 @@ handler_vector preferences_dialog::handler_members()
|
|||
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 @@ handler_vector preferences_dialog::handler_members()
|
|||
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 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
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 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
|
|||
// 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 @@ void preferences_dialog::process_event()
|
|||
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 @@ void preferences_dialog::set_selection(int index)
|
|||
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);
|
||||
|
|
|
@ -141,6 +141,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()
|
||||
{
|
||||
return prefs["locale"];
|
||||
|
|
|
@ -63,6 +63,12 @@ namespace preferences {
|
|||
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);
|
||||
|
||||
|
|
|
@ -174,6 +174,20 @@ void set_colour_cursors(bool 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 {
|
||||
class escape_handler : public events::handler {
|
||||
public:
|
||||
|
|
|
@ -33,6 +33,10 @@ namespace preferences {
|
|||
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);
|
||||
|
|
|
@ -1757,7 +1757,12 @@ const unit_animation* unit::start_animation(const game_display &disp, const game
|
|||
}
|
||||
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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue