Events: remove pump_info
Only two places actually made use of the only thing it was useful for (the current tick count), the countdown clock and the music thinker. The former was simpler to do without, and though it was slightly useful for the latter, the music thinker really needs to be rethought. The only thing this could be useful for is providing a stable timestamp for every process call. That wasn't how it was designed, however. ticks() would populate its value the first time it was called. Even if (as I considered doing) you change it to register the tick when constructing the pump_info object, it's still easier (and easier to read) to just call steady_clock::now directly as needed.
This commit is contained in:
parent
12fa8f2844
commit
6fcf46a208
14 changed files with 14 additions and 32 deletions
|
@ -274,7 +274,7 @@ void controller_base::handle_event(const SDL_Event& event)
|
|||
}
|
||||
}
|
||||
|
||||
void controller_base::process(events::pump_info&)
|
||||
void controller_base::process()
|
||||
{
|
||||
if(gui2::is_in_dialog()) {
|
||||
return;
|
||||
|
|
|
@ -156,7 +156,7 @@ protected:
|
|||
// No action by default
|
||||
}
|
||||
|
||||
virtual void process(events::pump_info&) override;
|
||||
virtual void process() override;
|
||||
|
||||
/** Process keydown (always). Overridden in derived classes */
|
||||
virtual void process_keydown_event(const SDL_Event& /*event*/)
|
||||
|
|
|
@ -56,7 +56,7 @@ void countdown_clock::update_team()
|
|||
}
|
||||
|
||||
//make sure we think about countdown even while dialogs are open
|
||||
void countdown_clock::process(events::pump_info&)
|
||||
void countdown_clock::process()
|
||||
{
|
||||
if(timer_refresh_rate.poll()) {
|
||||
update();
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
void update_team();
|
||||
|
||||
/** Inherited from pump_monitor */
|
||||
virtual void process(events::pump_info& info) override;
|
||||
virtual void process() override;
|
||||
|
||||
/** @returns whether there is time left */
|
||||
bool update();
|
||||
|
|
|
@ -483,8 +483,6 @@ void pump()
|
|||
return;
|
||||
}
|
||||
|
||||
pump_info info;
|
||||
|
||||
SDL_Event temp_event;
|
||||
int poll_count = 0;
|
||||
int begin_ignoring = 0;
|
||||
|
@ -716,7 +714,7 @@ void pump()
|
|||
|
||||
// Inform the pump monitors that an events::pump() has occurred
|
||||
for(auto monitor : pump_monitors) {
|
||||
monitor->process(info);
|
||||
monitor->process();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,15 +756,6 @@ void process_tooltip_strings(int mousex, int mousey)
|
|||
}
|
||||
}
|
||||
|
||||
int pump_info::ticks()
|
||||
{
|
||||
if(!ticks_) {
|
||||
ticks_ = ::SDL_GetTicks();
|
||||
}
|
||||
|
||||
return ticks_;
|
||||
}
|
||||
|
||||
/* The constants for the minimum and maximum are picked from the headers. */
|
||||
#define INPUT_MIN 0x300
|
||||
#define INPUT_MAX 0x8FF
|
||||
|
|
|
@ -150,19 +150,12 @@ void draw();
|
|||
inline void pump_and_draw() { pump(); draw(); }
|
||||
// TODO: draw_manager - should this also raise_process_event? Some things do some don't
|
||||
|
||||
struct pump_info {
|
||||
pump_info() : ticks_(0) {}
|
||||
int ticks();
|
||||
private:
|
||||
int ticks_; //0 if not calculated
|
||||
};
|
||||
|
||||
class pump_monitor {
|
||||
//pump_monitors receive notification after an events::pump() occurs
|
||||
public:
|
||||
pump_monitor();
|
||||
virtual ~pump_monitor();
|
||||
virtual void process(pump_info& info) = 0;
|
||||
virtual void process() = 0;
|
||||
};
|
||||
|
||||
void raise_process_event();
|
||||
|
|
|
@ -150,7 +150,7 @@ void loading_screen::raise()
|
|||
}
|
||||
|
||||
// This will be run inside the window::show() loop.
|
||||
void loading_screen::process(events::pump_info&)
|
||||
void loading_screen::process()
|
||||
{
|
||||
if (load_funcs_.empty()) {
|
||||
return;
|
||||
|
|
|
@ -123,7 +123,7 @@ private:
|
|||
virtual void post_show() override;
|
||||
|
||||
/** Inherited from events::pump_monitor. */
|
||||
virtual void process(events::pump_info&) override;
|
||||
virtual void process() override;
|
||||
|
||||
/** Called by draw_manager to assign concrete layout. */
|
||||
virtual void layout() override;
|
||||
|
|
|
@ -29,7 +29,7 @@ using namespace std::chrono_literals;
|
|||
|
||||
REGISTER_DIALOG(network_transmission)
|
||||
|
||||
void network_transmission::pump_monitor::process(events::pump_info&)
|
||||
void network_transmission::pump_monitor::process()
|
||||
{
|
||||
if(!window_)
|
||||
return;
|
||||
|
|
|
@ -51,7 +51,7 @@ private:
|
|||
{
|
||||
public:
|
||||
connection_data*& connection_;
|
||||
virtual void process(events::pump_info&);
|
||||
virtual void process();
|
||||
|
||||
pump_monitor(connection_data*& connection)
|
||||
: connection_(connection), window_()
|
||||
|
|
|
@ -775,7 +775,7 @@ void play_music_config(const config& music_node, bool allow_interrupt_current_tr
|
|||
}
|
||||
}
|
||||
|
||||
void music_thinker::process(events::pump_info&)
|
||||
void music_thinker::process()
|
||||
{
|
||||
if(Mix_FadingMusic() != MIX_NO_FADING) {
|
||||
// Do not block everything while fading.
|
||||
|
|
|
@ -101,7 +101,7 @@ void play_UI_sound(const std::string& files);
|
|||
|
||||
// A class to periodically check for new music that needs to be played
|
||||
class music_thinker : public events::pump_monitor {
|
||||
void process(events::pump_info &info);
|
||||
void process();
|
||||
};
|
||||
|
||||
// A class to mute music when the game is in background
|
||||
|
|
|
@ -455,7 +455,7 @@ namespace {
|
|||
~ucm_process_scope() { ucm_in_proccess = false; }
|
||||
};
|
||||
}
|
||||
void user_choice_manager::process(events::pump_info&)
|
||||
void user_choice_manager::process()
|
||||
{
|
||||
if(!oos_ && !finished() && !ucm_in_proccess)
|
||||
{
|
||||
|
|
|
@ -119,6 +119,6 @@ public:
|
|||
*/
|
||||
static std::map<int, config> get_user_choice_internal(const std::string &name, const mp_sync::user_choice &uch, const std::set<int>& sides);
|
||||
/** Inherited from events::pump_monitor */
|
||||
void process(events::pump_info&);
|
||||
void process();
|
||||
events::generic_event changed_event_;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue