Restored the dialog titles for multiplayer screens (Fixes #13049)

Made the --nosound flag circumvent SDL sound initialization (which caused
resources to be opened anyway)
This commit is contained in:
Philippe Plantier 2005-06-06 20:12:47 +00:00
parent cd3d4c212c
commit 836accc55a
8 changed files with 34 additions and 16 deletions

View file

@ -476,7 +476,7 @@ void connect::side::resolve_random()
connect::connect(display& disp, const config& game_config, const game_data& data,
chat& c, config& gamelist, const create::parameters& params,
mp::controller default_controller) :
mp::ui(disp, game_config, c, gamelist),
mp::ui(disp, _("Game Lobby"), game_config, c, gamelist),
game_data_(data),
level_(),
@ -790,9 +790,6 @@ void connect::layout_children(const SDL_Rect& rect)
waiting_label_.set_location(ai_.location().x + ai_.location().w + 8,
bottom-left_button->height() + 4);
// Title and labels
gui::draw_dialog_title(left,top,&video(),_("Game Lobby"));
type_title_label_.set_location(left+30, top+35);
faction_title_label_.set_location((left+145), top+35);
team_title_label_.set_location((left+260), top+35);

View file

@ -31,7 +31,7 @@ const SDL_Rect null_rect = {0, 0, 0, 0};
namespace mp {
create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
ui(disp, cfg, c, gamelist),
ui(disp, _("Create Game"), cfg, c, gamelist),
tooltip_manager_(disp.video()),
map_selection_(-1),
@ -383,7 +383,7 @@ void create::layout_children(const SDL_Rect& rect)
int ypos = ca.y;
// Dialog title
ypos += gui::draw_dialog_title(xpos, ypos, &video(), _("Create Game")).h + border_size;
ypos += title().height() + border_size;
// Name Entry
name_entry_label_.set_location(xpos, ypos);

View file

@ -19,6 +19,7 @@
#include "wml_separators.hpp"
#include "game_config.hpp"
#include "gettext.hpp"
#include "show_dialog.hpp"
namespace {
@ -101,7 +102,7 @@ bool lobby::lobby_sorter::less(int column, const gui::menu::item& row1, const gu
}
lobby::lobby(display& disp, const config& cfg, chat& c, config& gamelist) :
mp::ui(disp, cfg, c, gamelist),
mp::ui(disp, _("Game Lobby"), cfg, c, gamelist),
observe_game_(disp.video(), _("Observe Game")),
join_game_(disp.video(), _("Join Game")),
@ -135,8 +136,9 @@ void lobby::layout_children(const SDL_Rect& rect)
create_game_.set_location(observe_game_.location().x + observe_game_.location().w + 5,yscale(7));
quit_game_.set_location(create_game_.location().x + create_game_.location().w + 5,yscale(7));
games_menu_.set_width(xscale(832));
games_menu_.set_location(xscale(12),yscale(42));
games_menu_.set_location(client_area().x, client_area().y + title().height());
games_menu_.set_measurements(client_area().w, client_area().h
- title().height() - gui::ButtonVPadding);
}
void lobby::gamelist_updated(bool silent)

View file

@ -147,7 +147,7 @@ std::string chat::format_message(const msg& message)
return "<" + message.user + ">" + message.message + "\n";
}
ui::ui(display& disp, const config& cfg, chat& c, config& gamelist) :
ui::ui(display& disp, const std::string& title, const config& cfg, chat& c, config& gamelist) :
gui::widget(disp.video()),
disp_(disp),
initialized_(false),
@ -159,6 +159,7 @@ ui::ui(display& disp, const config& cfg, chat& c, config& gamelist) :
chat_(c),
gamelist_(gamelist),
title_(disp.video(), title, font::SIZE_LARGE, font::TITLE_COLOUR),
chat_textbox_(disp.video(), 100, "", false),
entry_textbox_(disp.video(), 100),
users_menu_(disp.video(), std::vector<std::string>()),
@ -341,6 +342,7 @@ void ui::process_network_connection(const network::connection sock)
void ui::hide_children(bool hide)
{
title_.hide(hide);
chat_textbox_.hide(hide);
entry_textbox_.hide(hide);
users_menu_.hide(hide);
@ -348,6 +350,7 @@ void ui::hide_children(bool hide)
void ui::layout_children(const SDL_Rect& rect)
{
title_.set_location(xscale(11)+4, xscale(42) + 4);
users_menu_.set_width(xscale(159));
users_menu_.set_location(xscale(856), yscale(42));
users_menu_.set_height(yscale(715));
@ -387,5 +390,11 @@ void ui::set_user_list(const std::vector<std::string>& list, bool silent)
users_menu_.set_items(user_list_);
}
const gui::widget& ui::title() const
{
return title_;
}
}

View file

@ -17,6 +17,7 @@
#include "hotkeys.hpp"
#include "network.hpp"
#include "preferences.hpp"
#include "widgets/label.hpp"
#include "widgets/button.hpp"
#include "widgets/menu.hpp"
#include "widgets/textbox.hpp"
@ -71,7 +72,8 @@ class ui : public gui::widget
public:
enum result { CONTINUE, JOIN, OBSERVE, CREATE, PLAY, QUIT };
ui(display& d, const config& cfg, chat& c, config& gamelist);
ui(display& d, const std::string& title,
const config& cfg, chat& c, config& gamelist);
// Asks the multiplayer_ui to pump some data from the network, and then
// to process it. The actual processing will be left to the child
@ -145,6 +147,9 @@ protected:
// Returns the current gamelist
config& gamelist() { return gamelist_; };
const gui::widget& title() const;
private:
/** Set to true when the widgets are intialized. Allows delayed
* initialization on first positioning. */
@ -163,6 +168,7 @@ private:
config& gamelist_;
gui::label title_;
gui::textbox chat_textbox_;
gui::textbox entry_textbox_;

View file

@ -142,7 +142,7 @@ std::string wait::leader_preview_pane::get_selected_leader()
}
wait::wait(display& disp, const config& cfg, const game_data& data, mp::chat& c, config& gamelist) :
ui(disp, cfg, c, gamelist),
ui(disp, _("Game Lobby"), cfg, c, gamelist),
cancel_button_(disp.video(), _("Cancel")),
start_label_(disp.video(), _("Waiting for game to start..."), font::SIZE_SMALL, font::LOBBY_COLOUR),
@ -270,8 +270,9 @@ void wait::layout_children(const SDL_Rect& rect)
const SDL_Rect ca = client_area();
int y = ca.y + ca.h - cancel_button_.height();
game_menu_.set_location(ca.x, ca.y);
game_menu_.set_measurements(ca.w, y - ca.y - gui::ButtonVPadding);
game_menu_.set_location(ca.x, ca.y + title().height());
game_menu_.set_measurements(ca.w, y - ca.y - title().height()
- gui::ButtonVPadding);
cancel_button_.set_location(ca.x + ca.w - cancel_button_.width(), y);
start_label_.set_location(ca.x, y + 4);
}

View file

@ -19,6 +19,7 @@
#include "sound.hpp"
#include "wesconfig.h"
#include "SDL.h"
#include "SDL_mixer.h"
#include <iostream>
@ -45,6 +46,8 @@ manager::manager(bool sound_on)
return;
}
SDL_Init(SDL_INIT_AUDIO);
//sounds don't sound good on Windows unless the buffer size is 4k,
//but this seems to cause crashes on other systems...
#ifdef WIN32

View file

@ -201,7 +201,7 @@ void update_whole_screen()
}
CVideo::CVideo() : bpp(0), fake_screen(false), help_string_(0), updatesLocked_(0)
{
const int res = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE);
const int res = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
if(res < 0) {
ERR_DP << "Could not initialize SDL: " << SDL_GetError() << "\n";
@ -212,7 +212,7 @@ CVideo::CVideo() : bpp(0), fake_screen(false), help_string_(0), updatesLocked_(0
CVideo::CVideo( int x, int y, int bits_per_pixel, int flags)
: bpp(0), fake_screen(false), help_string_(0), updatesLocked_(0)
{
const int res = SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE);
const int res = SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
if(res < 0) {
ERR_DP << "Could not initialize SDL: " << SDL_GetError() << "\n";
throw CVideo::error();