Add filter for bot-hosted games.
Bot-hosted games are now shown in a separate tab from player-hosted games, based on the new auto_hosted attribute on the game creation WML. This is not something that's available to be selected during game creation since it's assumed it will instead be set by the bot implementation. Note that this isn't *really* putting games into two separate tabs, it just looks that way for UI/UX reasons. Resolves #6939
This commit is contained in:
parent
8e9c333ed6
commit
08e79f4e36
6 changed files with 146 additions and 6 deletions
|
@ -3,6 +3,117 @@
|
|||
### Definition of the lobby screen
|
||||
###
|
||||
|
||||
#define _GUI_LOBBY_TABS
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = all
|
||||
border_size = 5
|
||||
|
||||
[horizontal_listbox]
|
||||
id = "games_list_tab_bar"
|
||||
horizontal_scrollbar_mode = "never"
|
||||
vertical_scrollbar_mode = "never"
|
||||
|
||||
[list_definition]
|
||||
[row]
|
||||
[column]
|
||||
[toggle_panel]
|
||||
linked_group = "tabs"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = all
|
||||
border_size = 5
|
||||
|
||||
[spacer][/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = all
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "tab_label"
|
||||
wrap = true
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = all
|
||||
border_size = 5
|
||||
|
||||
[spacer][/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/toggle_panel]
|
||||
[/column]
|
||||
[/row]
|
||||
[/list_definition]
|
||||
|
||||
[list_data]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
||||
[widget]
|
||||
id = "tab_label"
|
||||
label = _ "Player Hosted"
|
||||
[/widget]
|
||||
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
|
||||
[widget]
|
||||
id = "tab_label"
|
||||
label = _ "Bot Hosted"
|
||||
[/widget]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/list_data]
|
||||
[/horizontal_listbox]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = true
|
||||
vertical_grow = true
|
||||
|
||||
{_GUI_GAME_LIST}
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
#enddef
|
||||
|
||||
#define _GUI_GAME_LIST
|
||||
[listbox]
|
||||
id = "game_list"
|
||||
|
@ -593,6 +704,12 @@
|
|||
id = "tooltip"
|
||||
[/helptip]
|
||||
|
||||
[linked_group]
|
||||
id = "tabs"
|
||||
fixed_width = true
|
||||
fixed_height = true
|
||||
[/linked_group]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
@ -741,7 +858,7 @@
|
|||
border_size = 5
|
||||
|
||||
{GUI_FORCE_WIDGET_MINIMUM_SIZE 0 "((screen_height * 35) / 100)" (
|
||||
{_GUI_GAME_LIST}
|
||||
{_GUI_LOBBY_TABS}
|
||||
)}
|
||||
[/column]
|
||||
[/row]
|
||||
|
@ -816,6 +933,12 @@
|
|||
id = "tooltip"
|
||||
[/helptip]
|
||||
|
||||
[linked_group]
|
||||
id = "tabs"
|
||||
fixed_width = true
|
||||
fixed_height = true
|
||||
[/linked_group]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
@ -861,8 +984,6 @@
|
|||
[/column]
|
||||
[/row]
|
||||
|
||||
#{GUI_HORIZONTAL_SPACER_LINE}
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
[column]
|
||||
|
@ -871,12 +992,10 @@
|
|||
horizontal_grow = true
|
||||
vertical_grow = true
|
||||
|
||||
{_GUI_GAME_LIST}
|
||||
{_GUI_LOBBY_TABS}
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
#{GUI_HORIZONTAL_SPACER_LINE}
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
|
@ -914,3 +1033,4 @@
|
|||
#undef _GUI_FILTER_AREA
|
||||
#undef _GUI_GAME_LIST
|
||||
#undef _GUI_PLAYER_TREE_AREA
|
||||
#undef _GUI_LOBBY_TABS
|
||||
|
|
|
@ -749,6 +749,7 @@ void connect_engine::send_level_data() const
|
|||
"name", params_.name,
|
||||
"password", params_.password,
|
||||
"ignored", preferences::get_ignored_delim(),
|
||||
"auto_hosted", false,
|
||||
},
|
||||
});
|
||||
mp::send_to_server(level_);
|
||||
|
|
|
@ -143,6 +143,7 @@ game_info::game_info(const config& game, const std::vector<std::string>& install
|
|||
, have_all_mods(true)
|
||||
, has_friends(false)
|
||||
, has_ignored(false)
|
||||
, auto_hosted(game["auto_hosted"].to_bool())
|
||||
, display_status(disp_status::NEW)
|
||||
, required_addons()
|
||||
, addons_outcome(addon_req::SATISFIED)
|
||||
|
|
|
@ -106,6 +106,7 @@ struct game_info
|
|||
|
||||
bool has_friends;
|
||||
bool has_ignored;
|
||||
bool auto_hosted;
|
||||
|
||||
enum class disp_status {
|
||||
CLEAN,
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/toggle_panel.hpp"
|
||||
#include "gui/widgets/stacked_widget.hpp"
|
||||
#include "gui/dialogs/server_info_dialog.hpp"
|
||||
|
||||
#include "addon/client.hpp"
|
||||
|
@ -657,6 +658,9 @@ void mp_lobby::pre_show(window& window)
|
|||
}
|
||||
}
|
||||
|
||||
listbox& tab_bar = find_widget<listbox>(&window, "games_list_tab_bar", false);
|
||||
connect_signal_notify_modified(tab_bar, std::bind(&mp_lobby::tab_switch_callback, this));
|
||||
|
||||
// Set up Lua plugin context
|
||||
plugins_context_.reset(new plugins_context("Multiplayer Lobby"));
|
||||
|
||||
|
@ -679,6 +683,12 @@ void mp_lobby::pre_show(window& window)
|
|||
plugins_context_->set_accessor("game_list", [this](const config&) { return lobby_info_.gamelist(); });
|
||||
}
|
||||
|
||||
void mp_lobby::tab_switch_callback()
|
||||
{
|
||||
filter_auto_hosted_ = !filter_auto_hosted_;
|
||||
update_gamelist_filter();
|
||||
}
|
||||
|
||||
void mp_lobby::open_profile_url()
|
||||
{
|
||||
const mp::user_info* info = player_list_.get_selected_info();
|
||||
|
@ -948,6 +958,10 @@ void mp_lobby::game_filter_init()
|
|||
return filter_slots_->get_widget_value() ? info.vacant_slots > 0 : true;
|
||||
});
|
||||
|
||||
lobby_info_.add_game_filter([this](const mp::game_info& info) {
|
||||
return info.auto_hosted == filter_auto_hosted_;
|
||||
});
|
||||
|
||||
lobby_info_.set_game_filter_invert(
|
||||
[this](bool val) { return filter_invert_->get_widget_value() ? !val : val; });
|
||||
}
|
||||
|
|
|
@ -115,6 +115,8 @@ private:
|
|||
|
||||
void open_profile_url();
|
||||
|
||||
void tab_switch_callback();
|
||||
|
||||
void refresh_lobby();
|
||||
|
||||
void game_filter_init();
|
||||
|
@ -145,6 +147,7 @@ private:
|
|||
field_bool* filter_ignored_;
|
||||
field_bool* filter_slots_;
|
||||
field_bool* filter_invert_;
|
||||
bool filter_auto_hosted_;
|
||||
|
||||
text_box* filter_text_;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue