make the game list rows react to double click...

...by joining/observing the game (needs a fix)
This commit is contained in:
Tomasz Śniatowski 2009-07-21 17:47:13 +01:00
parent b6a908fe03
commit a8c68b2b04
3 changed files with 15 additions and 3 deletions

View file

@ -118,6 +118,7 @@
[column]
horizontal_grow = "true"
[toggle_panel]
id = "panel"
definition = "default"
{HORIZONTAL_BEGIN}
horizontal_alignment = "left"

View file

@ -25,6 +25,7 @@
#include "gui/widgets/multi_page.hpp"
#include "gui/widgets/text_box.hpp"
#include "gui/widgets/toggle_button.hpp"
#include "gui/widgets/toggle_panel.hpp"
#include "foreach.hpp"
#include "lobby_data.hpp"
@ -276,9 +277,8 @@ void tlobby_main::update_gamelist()
ss << "Games: Showing " << lobby_info_.games_filtered().size()
<< " out of " << lobby_info_.games().size();
gamelistbox_->get_widget<tlabel>("map", false).set_label(ss.str());
foreach (const game_info *gp, lobby_info_.games_filtered())
{
const game_info& game = *gp;
for (unsigned i = 0; i < lobby_info_.games_filtered().size(); ++i) {
const game_info& game = *lobby_info_.games_filtered()[i];
std::map<std::string, string_map> data;
add_label_data(data, "name", game.name);
@ -313,6 +313,9 @@ void tlobby_main::update_gamelist()
gamelistbox_->add_row(data);
tgrid* grid = gamelistbox_->get_row_grid(gamelistbox_->get_item_count() - 1);
ttoggle_panel& row_panel = grid->get_widget<ttoggle_panel>("panel", false);
row_panel.set_callback_mouse_left_double_click(boost::bind(
&tlobby_main::join_or_observe, this, i));
set_visible_if_exists(grid, "time_limit_icon", !game.time_limit.empty());
set_visible_if_exists(grid, "vision_fog", game.fog);
@ -812,6 +815,12 @@ void tlobby_main::join_global_button_callback(gui2::twindow &window)
}
}
void tlobby_main::join_or_observe(int idx)
{
const game_info& game = *lobby_info_.games_filtered()[idx];
do_game_join(idx, !game.can_join());
}
bool tlobby_main::do_game_join(int idx, bool observe)
{
if (idx < 0 || idx > static_cast<int>(lobby_info_.games_filtered().size())) {

View file

@ -251,6 +251,8 @@ private:
void observe_global_button_callback(twindow& window);
void join_or_observe(int index);
/**
* Assemble and send a game join request. Ask for password if the game
* requires one.