toolbar buttons limit framerate while held down
This commit is contained in:
@@ -1149,7 +1149,7 @@ bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) {
|
||||
|
||||
// Otherwise they're in a terrain view mode
|
||||
location cur_loc = is_out() ? univ.party.out_loc : center;
|
||||
auto button_hit = UI::toolbar.button_hit(mainPtr, the_point);
|
||||
auto button_hit = UI::toolbar.button_hit(mainPtr, the_point, fps_limiter);
|
||||
|
||||
// MARK: Then, handle a button being hit.
|
||||
switch(button_hit) {
|
||||
|
@@ -49,7 +49,7 @@ static const std::vector<eToolbarButton> fight_buttons = {TOOLBAR_MAGE, TOOLBAR_
|
||||
// Source rects for each button type in buttons.png.
|
||||
static const rectangle btn_src_rects[] = {{0,0,38,38}, {0,38,19,76}, {19,38,38,76}};
|
||||
|
||||
eToolbarButton cToolbar::button_hit(sf::RenderWindow& win, location click) {
|
||||
eToolbarButton cToolbar::button_hit(sf::RenderWindow& win, location click, cFramerateLimiter& fps_limiter) {
|
||||
rectangle dest_rect = win_to_rects[WINRECT_ACTBTNS];
|
||||
click.x -= dest_rect.left;
|
||||
click.y -= dest_rect.top;
|
||||
@@ -79,6 +79,7 @@ eToolbarButton cToolbar::button_hit(sf::RenderWindow& win, location click) {
|
||||
active = toolbar[i].bounds.contains(toPos) ? i : -1;
|
||||
}
|
||||
}
|
||||
fps_limiter.frame_finished();
|
||||
}
|
||||
play_sound(37, time_in_ticks(5));
|
||||
redraw_screen(REFRESH_NONE);
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include "location.hpp"
|
||||
#include "tools/framerate_limiter.hpp"
|
||||
|
||||
// These correspond to the icons in buttons.png
|
||||
enum eToolbarButton {
|
||||
@@ -41,7 +42,7 @@ class cToolbar {
|
||||
void init();
|
||||
public:
|
||||
void draw(sf::RenderTarget& targ);
|
||||
eToolbarButton button_hit(sf::RenderWindow& win, location click);
|
||||
eToolbarButton button_hit(sf::RenderWindow& win, location click, cFramerateLimiter& fps_limiter);
|
||||
};
|
||||
|
||||
namespace UI {
|
||||
|
Reference in New Issue
Block a user