53 #define ERR_CF LOG_STREAM(err, log_config)
56 #define DBG_MP LOG_STREAM(debug, log_mp_create)
59 const SDL_Rect null_rect = {0, 0, 0, 0};
86 ui(video, wesnothd_connection,
_(
"Create Game"), cfg, c, gamelist),
87 tooltip_manager_(video),
98 no_era_label_(video,
_(
"No eras available\nfor this game."),
104 launch_game_(video,
_(
"Next")),
105 cancel_game_(video,
_(
"Cancel")),
106 regenerate_map_(video,
_(
"Regenerate")),
107 generator_settings_(video,
_(
"Settings...")),
108 load_game_(video,
_(
"Load Game...")),
110 filter_num_players_slider_(video),
111 description_(video, 100,
"", false),
113 image_restorer_(nullptr),
114 image_rect_(null_rect),
115 available_level_types_(),
116 engine_(video, state)
122 DBG_MP <<
"constructing multiplayer create dialog" << std::endl;
126 typedef std::pair<ng::level::TYPE, std::string> level_type_info;
127 std::vector<level_type_info> all_level_types;
129 all_level_types.push_back(std::make_pair(ng::level::TYPE::CAMPAIGN,
_(
"Campaigns")));
130 all_level_types.push_back(std::make_pair(ng::level::TYPE::USER_MAP,
_(
"User Maps")));
131 all_level_types.push_back(std::make_pair(ng::level::TYPE::USER_SCENARIO,
_(
"User Scenarios")));
132 all_level_types.push_back(std::make_pair(ng::level::TYPE::RANDOM_MAP,
_(
"Random Maps")));
135 all_level_types.push_back(std::make_pair(ng::level::TYPE::SP_CAMPAIGN,
139 std::vector<std::string> combo_level_names;
141 for (level_type_info type_info : all_level_types) {
144 combo_level_names.push_back(type_info.second);
155 size_t combo_new_selection = 0;
156 size_t level_new_selection = 0;
159 size_t type_index = 0;
166 if (type_index < available_level_types_.size()) {
167 combo_new_selection = type_index;
170 if (level_index != -1) {
171 level_new_selection = level_index;
178 const std::vector<std::string>& era_names =
180 if(era_names.empty()) {
235 DBG_MP <<
"destructing multiplayer create dialog - aborted game creation" << std::endl;
238 DBG_MP <<
"destructing multiplayer create dialog - a game will be created" << std::endl;
241 DBG_MP <<
"storing parameter values in preferences" << std::endl;
263 SDL_GetMouseState(&mousex,&mousey);
290 if (difficulty ==
"CANCEL") {
312 _(
"The level is invalid."));
327 if (!
load.load_game(*data.
filename,
false,
false,
false,
"",
true)) {
331 if (!
load.load_multiplayer_game()) {
336 if (
load.cancel_orders())
355 if (changed_mod != -1) {
388 level_changed =
true;
402 level_changed =
true;
406 std::stringstream players;
407 std::stringstream map_size;
409 players <<
_(
"Players: ");
419 case ng::level::TYPE::USER_MAP:
420 case ng::level::TYPE::USER_SCENARIO:
421 case ng::level::TYPE::RANDOM_MAP: {
426 assert(current_scenario);
429 map_size <<
_(
"Size: ") << current_scenario->
map_size();
433 case ng::level::TYPE::CAMPAIGN:
434 case ng::level::TYPE::SP_CAMPAIGN: {
438 assert(current_campaign);
444 players <<
" to " << current_campaign->
max_players();
462 std::stringstream ss;
464 ss <<
_(
"Number of players: any");
466 ss <<
_(
"Number of players: ") <<
val;
481 const std::vector<std::string>& menu_item_names =
509 DBG_MP <<
"Synchronizing with the dependency manager" << std::endl;
538 if (level_type_at_index ==
type) {
559 SDL_Color back_color = {0,0,0,SDL_ALPHA_OPAQUE};
561 video().getSurface());
565 SDL_MapRGB(display->format, 0, 0, 0));
585 DBG_MP << (hide ?
"hiding" :
"showing" ) <<
" children widgets" << std::endl;
630 DBG_MP <<
"laying out the children" << std::endl;
634 const int border_size = 6;
635 const int column_border_size = 10;
647 const int menu_width = (ca.w - 3 * column_border_size -
image_width) / 3;
657 int ypos_columntop = ypos;
661 ypos += image_width + border_size;
669 const int ypos1 = ypos;
670 const int xpos1 = xpos;
674 ypos = ypos_columntop;
675 xpos += image_width + column_border_size;
700 ypos = ypos_columntop;
701 xpos += menu_width + column_border_size;
707 const int levels_menu_y_offset = (ca.w < 900 || ca.h < 500) ?
731 ypos = ypos_columntop;
732 xpos += menu_width + column_border_size;
743 ypos += eras_menu_height;
763 #ifdef OK_BUTTON_ON_RIGHT
769 ca.y + ca.h - right_button->
height());
void set_current_mod_index(const size_t index)
const std::function< size_t(const config &, const std::string &, size_t) > get_size_t
TYPE
UNSCALED : image will be drawn "as is" without changing size, even in case of redraw SCALED_TO_ZOOM :...
std::vector< std::string > levels_menu_item_names() const
gui::textbox filter_name_
The class for loading a savefile.
void fill_rect(surface &dst, SDL_Rect *dst_rect, const Uint32 color)
Fill a rectangle on a given surface.
const std::string & set_text(const std::string &text)
gui::multimenu mods_menu_
const depcheck::manager & dependency_manager() const
static lg::log_domain log_mp_create("mp/create")
int player_num_filter() const
const mp_game_settings & get_parameters()
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
boost::optional< std::string > filename
GLuint GLuint GLsizei GLenum type
static l_noret error(LoadState *S, const char *why)
boost::scoped_ptr< plugins_context > plugins_context_
level & current_level() const
virtual std::string name() const
virtual void layout_children(const SDL_Rect &rect)
Lays the children out.
result get_result()
Returns the result of the current widget.
void generator_user_config(CVideo &v)
std::vector< level_ptr > get_levels_by_type_unfiltered(level::TYPE type) const
GLenum GLsizei GLenum GLenum const GLvoid * image
static config get_selected_helper(const ng::create_engine *eng_ptr)
void set_increment(int increment)
GLuint const GLfloat * val
gui::label map_generator_label_
void set_text(const std::string &text, const SDL_Color &color=font::NORMAL_COLOR)
void set_current_era_index(const size_t index, bool force=false)
void show_transient_message(CVideo &video, const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
const std::string text() const
unsigned image_width(const std::string &filename)
void set_current_level(const size_t index)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
gui::button regenerate_map_
const mp_game_settings & get_parameters()
void set_location(int x, int y)
void prepare_for_era_and_mods()
void prepare_for_scenario()
bool generator_assigned() const
bool toggle_current_mod(bool force=false)
std::string select_campaign_difficulty(int set_value=-1)
select_campaign_difficulty
virtual void hide_children(bool hide=true)
Hides or shows all gui::widget children of this widget.
void init_level_type_changed(size_t index)
This module controls the multiplayer lobby.
static game_config_manager * get()
static UNUSEDNOWARN std::string _(const char *str)
void set_level_type(int value)
virtual void layout_children(const SDL_Rect &rect)
Lays the children out.
A class that represents a TCP/IP connection to the wesnothd server.
result set_result(result res)
Sets the result of this dialog, to be checked by get_result().
gui::slider filter_num_players_slider_
void draw_centered_on_background(surface surf, const SDL_Rect &rect, const SDL_Color &color, surface target)
void synchronize_selections()
General settings and defaults for scenarios.
const config & game_config() const
Returns the main game config, as defined by loading the preprocessed WML files.
gui::button generator_settings_
const extras_metadata & current_extra(const MP_EXTRA extra_type) const
gui::label num_players_label_
void show_message(CVideo &video, const std::string &title, const std::string &message, const std::string &button_caption, const bool auto_close, const bool message_use_markup)
Shows a message to the user.
ng::create_engine engine_
const gui::label & title() const
void init_level_changed(size_t index)
virtual void set_metadata()=0
bool plugin_event_helper(const process_event_data &)
gui::label filter_num_players_label_
const config & data() const
gui::label map_size_label_
gui::label filter_name_label_
std::vector< std::string > & active_mods()
void apply_level_filter(const std::string &name)
void init_generated_level_data()
int find_extra_by_id(const MP_EXTRA extra_type, const std::string &id) const
static config find_helper(const ng::create_engine *eng_ptr, const config &cfg)
virtual surface create_image_surface(const SDL_Rect &image_rect)=0
virtual bool allow_era_choice() const
void set_level(const std::string &value)
void set_description(const std::string &description)
std::vector< std::string > extras_menu_item_names(const MP_EXTRA extra_type, bool escape_markup=true) const
void send_chat_message(const std::string &message, bool allies_only=false)
gui::label level_type_label_
static lg::log_domain log_config("config")
gui::combo level_type_combo_
level::TYPE find_level_type_by_id(const std::string &id) const
SDL_Rect client_area() const
void set_selected(int val)
const SDL_Color LOBBY_COLOR
void assign(const resource_type &o)
void set_items(const std::vector< std::string > &items)
Declarations for File-IO.
void prepare_for_campaign(const std::string &difficulty)
std::vector< ng::level::TYPE > available_level_types_
const std::string & level_name_filter() const
level::TYPE current_level_type() const
create(CVideo &v, twesnothd_connection *wesnothd_connection, const config &game_config, saved_game &state, chat &c, config &gamelist)
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
void select_level_type_helper(const std::string &str)
Contains the SDL_Rect helper code.
gui::textbox description_
virtual void process_event()
void set_modifications(const std::vector< std::string > &value, bool mp)
void swap(game_board &one, game_board &other)
this module manages the cache of images.
Standard logging facilities (interface).
const std::function< std::string(const config &, const std::string &) > get_str
virtual std::string description() const
void set_current_level_type(const level::TYPE)
virtual std::string icon() const
void set_era(const std::string &value)
void prepare_for_saved_game()
virtual std::string id() const
this class memorizes a chat session.
virtual void hide_children(bool hide=true)
Hides or shows all gui::widget children of this widget.
int find_level_by_id(const std::string &id) const
A config object defines a single node in a WML file, with access to child nodes.
std::string map_size() const
void prepare_for_new_level()
void update_rect(const SDL_Rect &)
void process_event_impl(const process_event_data &)
GLsizei const GLcharARB ** string
util::scoped_ptr< surface_restorer > image_restorer_
a base class for the different multiplayer base dialogs: game list, create game, wait game...
virtual void gamelist_updated(bool silent=true)
Called each time the gamelist_ variable is updated.