mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-29 21:29:29 +00:00
added scrollbar to map selection in multiplayer
This commit is contained in:
parent
87538d7016
commit
f78e028f59
12
src/game.cpp
12
src/game.cpp
@ -1189,7 +1189,9 @@ bool game_controller::play_multiplayer()
|
||||
const std::string sep(1,gui::menu::HELP_STRING_SEPERATOR);
|
||||
host_or_join.push_back(std::string("&icons/icon-server.png,") + _("Join Official Server") + sep + _("Log on to the official Wesnoth multiplayer server"));
|
||||
host_or_join.push_back(std::string("&icons/icon-serverother.png,") + _("Join Game") + sep + _("Join a server or hosted game"));
|
||||
host_or_join.push_back(std::string("&icons/icon-hostgame.png,") + _("Host Multiplayer Game") + sep + _("Host a game without using a server"));
|
||||
host_or_join.push_back(std::string("&icons/icon-hostgame.png,") + _("Host Networked Game") + sep + _("Host a game without using a server"));
|
||||
host_or_join.push_back(std::string(",") + _("Hotseat Game") + sep + _("Play a multiplayer game sharing the same machine"));
|
||||
host_or_join.push_back(std::string(",") + _("Human vs AI") + sep + _("Play a game against AI opponents"));
|
||||
|
||||
std::string login = preferences::login();
|
||||
const int res = gui::show_dialog(disp(),NULL,_("Multiplayer"),"",gui::OK_CANCEL,&host_or_join,NULL,_("Login") + std::string(": "),&login);
|
||||
@ -1204,10 +1206,14 @@ bool game_controller::play_multiplayer()
|
||||
config game_config;
|
||||
read_game_cfg(defines_map_,line_src,game_config,use_caching_);
|
||||
|
||||
if(res == 2) {
|
||||
if(res >= 2) {
|
||||
std::vector<std::string> chat;
|
||||
config game_data;
|
||||
multiplayer_game_setup_dialog mp_dialog(disp(),units_data_,game_config,state_,true);
|
||||
|
||||
const std::string controller = (res == 2 ? "network" : (res == 3 ? "human" : "ai"));
|
||||
const bool is_server = res == 2;
|
||||
|
||||
multiplayer_game_setup_dialog mp_dialog(disp(),units_data_,game_config,state_,is_server,controller);
|
||||
lobby::RESULT res = lobby::CONTINUE;
|
||||
while(res == lobby::CONTINUE) {
|
||||
res = lobby::enter(disp(),game_data,game_config,&mp_dialog,chat);
|
||||
|
@ -55,12 +55,12 @@ network_game_manager::~network_game_manager()
|
||||
|
||||
multiplayer_game_setup_dialog::multiplayer_game_setup_dialog(
|
||||
display& disp, game_data& units_data,
|
||||
const config& cfg, game_state& state, bool server)
|
||||
const config& cfg, game_state& state, bool server, const std::string& controller)
|
||||
: disp_(disp), units_data_(units_data), cfg_(cfg), state_(state), server_(server), level_(NULL), map_selection_(-1),
|
||||
maps_menu_(NULL), turns_slider_(NULL), village_gold_slider_(NULL), xp_modifier_slider_(NULL),
|
||||
fog_game_(NULL), shroud_game_(NULL), observers_game_(NULL),
|
||||
cancel_game_(NULL), launch_game_(NULL), regenerate_map_(NULL), generator_settings_(NULL),
|
||||
era_combo_(NULL), vision_combo_(NULL), name_entry_(NULL), generator_(NULL)
|
||||
era_combo_(NULL), vision_combo_(NULL), name_entry_(NULL), generator_(NULL), controller_(controller)
|
||||
{
|
||||
std::cerr << "setup dialog ctor\n";
|
||||
|
||||
@ -74,18 +74,18 @@ multiplayer_game_setup_dialog::multiplayer_game_setup_dialog(
|
||||
//build the list of scenarios to play
|
||||
get_files_in_dir(get_user_data_dir() + "/editor/maps",&user_maps_,NULL,FILE_NAME_ONLY);
|
||||
|
||||
std::vector<std::string> options = user_maps_;
|
||||
map_options_ = user_maps_;
|
||||
|
||||
const config::child_list& levels = cfg.get_children("multiplayer");
|
||||
for(config::child_list::const_iterator j = levels.begin(); j != levels.end(); ++j){
|
||||
options.push_back((**j)["name"]);
|
||||
map_options_.push_back((**j)["name"]);
|
||||
}
|
||||
|
||||
//add the 'load game' option
|
||||
options.push_back(_("Load Game") + std::string("..."));
|
||||
map_options_.push_back(_("Load Game") + std::string("..."));
|
||||
|
||||
//create the scenarios menu
|
||||
maps_menu_.assign(new gui::menu(disp_,options));
|
||||
maps_menu_.assign(new gui::menu(disp_,map_options_));
|
||||
maps_menu_->set_numeric_keypress_selection(false);
|
||||
|
||||
SDL_Rect rect = {0,0,0,0};
|
||||
@ -191,6 +191,9 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
|
||||
const int map_label_height = font::draw_text(&disp_,disp_.screen_area(),font::SIZE_SMALL,font::GOOD_COLOUR,
|
||||
_("Map to play") + std::string(":"),xpos + minimap_width + border_size,ypos).h;
|
||||
|
||||
maps_menu_->set_max_width(area.x + area.w - (xpos + minimap_width) - 250);
|
||||
maps_menu_->set_max_height(area.y + area.h - (ypos + map_label_height));
|
||||
maps_menu_->set_items(map_options_);
|
||||
maps_menu_->set_loc(xpos + minimap_width + border_size,ypos + map_label_height + border_size);
|
||||
maps_menu_->set_dirty();
|
||||
|
||||
@ -509,7 +512,7 @@ void multiplayer_game_setup_dialog::start_game()
|
||||
|
||||
std::cerr << "loading connector...\n";
|
||||
//Connector
|
||||
mp_connect connector(disp_, name_entry_->text(), cfg_, units_data_, state_);
|
||||
mp_connect connector(disp_, name_entry_->text(), cfg_, units_data_, state_, false, controller_);
|
||||
|
||||
std::cerr << "done loading connector...\n";
|
||||
|
||||
|
@ -40,7 +40,7 @@ class multiplayer_game_setup_dialog : public lobby::dialog, public font::floatin
|
||||
{
|
||||
public:
|
||||
multiplayer_game_setup_dialog(display& disp, game_data& units_data,
|
||||
const config& cfg, game_state& state, bool server=false);
|
||||
const config& cfg, game_state& state, bool server=false, const std::string& controller="ai");
|
||||
|
||||
void set_area(const SDL_Rect& area);
|
||||
lobby::RESULT process();
|
||||
@ -59,7 +59,7 @@ private:
|
||||
|
||||
int map_selection_;
|
||||
|
||||
std::vector<std::string> user_maps_;
|
||||
std::vector<std::string> user_maps_, map_options_;
|
||||
config scenario_data_;
|
||||
|
||||
util::scoped_ptr<gui::menu> maps_menu_;
|
||||
@ -75,6 +75,8 @@ private:
|
||||
|
||||
surface_restorer turns_restorer_, village_gold_restorer_, xp_restorer_, playernum_restorer_,
|
||||
minimap_restorer_;
|
||||
|
||||
const std::string controller_;
|
||||
};
|
||||
|
||||
//function to host a multiplayer game. If server is true, then the
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
mp_connect::mp_connect(display& disp, std::string game_name,
|
||||
const config &cfg, game_data& data, game_state& state,
|
||||
bool join) :
|
||||
bool join, const std::string& default_controller) :
|
||||
disp_(&disp), cfg_(&cfg), data_(&data), state_(&state),
|
||||
show_replay_(false), save_(false), join_(join),
|
||||
player_types_(), player_races_(), player_teams_(),
|
||||
@ -48,7 +48,7 @@ mp_connect::mp_connect(display& disp, std::string game_name,
|
||||
ai_(gui::button(disp, _(" Computer vs Computer "))),
|
||||
launch_(gui::button(disp, _("I'm Ready"))),
|
||||
cancel_(gui::button(disp, _("Cancel"))),
|
||||
message_full_(true)
|
||||
message_full_(true), default_controller_(default_controller)
|
||||
{
|
||||
// Send Initial information
|
||||
config response;
|
||||
@ -205,7 +205,7 @@ int mp_connect::load_map(const std::string& era, config& scenario_data, int num_
|
||||
(**sd)["description"] = preferences::login();
|
||||
first = false;
|
||||
} else {
|
||||
(**sd)["controller"] = "ai";
|
||||
(**sd)["controller"] = default_controller_;
|
||||
(**sd)["description"] = "";
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ class mp_connect : public lobby::dialog
|
||||
public:
|
||||
mp_connect(display& disp, std::string game_name,
|
||||
const config &cfg, game_data& units_data,
|
||||
game_state& state, bool join = false);
|
||||
game_state& state, bool join = false,
|
||||
const std::string& default_controller="ai");
|
||||
~mp_connect();
|
||||
|
||||
int load_map(const std::string& era, config& scenario, int num_turns, int village_gold, int xpmodifier,
|
||||
@ -102,6 +103,8 @@ private:
|
||||
bool message_full_;
|
||||
|
||||
std::deque<config> network_data_;
|
||||
|
||||
const std::string default_controller_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1603,7 +1603,6 @@ void turn_info::recruit()
|
||||
std::vector<std::string> items;
|
||||
const std::set<std::string>& recruits = current_team.recruits();
|
||||
for(std::set<std::string>::const_iterator it = recruits.begin(); it != recruits.end(); ++it) {
|
||||
item_keys.push_back(*it);
|
||||
const std::map<std::string,unit_type>::const_iterator
|
||||
u_type = gameinfo_.unit_types.find(*it);
|
||||
if(u_type == gameinfo_.unit_types.end()) {
|
||||
@ -1611,6 +1610,8 @@ void turn_info::recruit()
|
||||
return;
|
||||
}
|
||||
|
||||
item_keys.push_back(*it);
|
||||
|
||||
const unit_type& type = u_type->second;
|
||||
|
||||
//display units that we can't afford to recruit in red
|
||||
|
@ -128,6 +128,11 @@ int menu::width() const
|
||||
width_ += scrollbar_.get_max_width();
|
||||
}
|
||||
}
|
||||
|
||||
if(max_width_ > 0 && width_ > max_width_) {
|
||||
width_ = max_width_;
|
||||
}
|
||||
|
||||
return width_;
|
||||
}
|
||||
|
||||
@ -149,7 +154,7 @@ void menu::set_loc(int x, int y)
|
||||
buffer_.assign(get_surface_portion(screen, portion));
|
||||
|
||||
if(show_scrollbar()) {
|
||||
const int menu_width = width() - scrollbar_.get_max_width();
|
||||
const int menu_width = w - scrollbar_.get_max_width();
|
||||
|
||||
scrollbar_.enable(true);
|
||||
int scr_width = scrollbar_.get_width();
|
||||
|
Loading…
x
Reference in New Issue
Block a user