Enable the preferences hotkey in the lobby.

Also add a helper wrapper so a void member function can be used as
hotkey callback.
This commit is contained in:
Mark de Wever 2009-12-06 15:45:47 +00:00
parent 2d6e99969b
commit 01d5fa6a78
3 changed files with 42 additions and 1 deletions

View file

@ -302,7 +302,9 @@ tlobby_main::tlobby_main(const config& game_config
, filter_text_(NULL)
, selected_game_id_()
, player_list_()
, player_list_dirty_(false), disp_(disp)
, player_list_dirty_(false)
, disp_(disp)
, preferences_wrapper_()
{
}
@ -375,11 +377,25 @@ twindow* tlobby_main::build_window(CVideo& video)
window->register_hotkey(hotkey::HOTKEY_FULLSCREEN
, boost::bind(fullscreen, boost::ref(video)));
/** @todo Remove this code once the resizing in twindow is finished. */
window->connect_signal<event::SDL_VIDEO_RESIZE>(
boost::bind(&signal_handler_sdl_video_resize
, _2, _3, _4, _5, boost::ref(video))
, event::tdispatcher::front_child);
/*** Local hotkeys. ***/
preferences_wrapper_ = boost::bind(
&tlobby_main::show_preferences_button_callback
, this
, boost::ref(*window));
window->register_hotkey(
hotkey::HOTKEY_PREFERENCES
, boost::bind(function_wrapper<bool, boost::function<void()> >
, true
, boost::cref(preferences_wrapper_)));
return window;
}

View file

@ -359,6 +359,9 @@ private:
bool player_list_dirty_;
display& disp_;
/** Wrapper for the preferences hotkey. */
boost::function<void()> preferences_wrapper_;
};
} // namespace gui2

View file

@ -203,6 +203,28 @@ tpoint get_mouse_position();
*/
std::string debug_truncate(const std::string& text);
/**
* Helper for function wrappers.
*
* For boost bind the a function sometimes needs to return a value althought
* the function called doesn't return one. This wrapper function can return a
* fixed result for a certain functor.
*
* @tparam R The return type.
* @tparam F The type of the functor.
*
* @param result The result value.
* @param function The functor to call.
*
* @returns result.
*/
template<class R, class F>
R function_wrapper(const R result, const F& function)
{
function();
return result;
}
} // namespace gui2
#endif