made multiplayer lobby work in modes below 1024x768
This commit is contained in:
parent
e33a45f397
commit
682376baad
7 changed files with 62 additions and 40 deletions
|
@ -45,8 +45,8 @@ Defeat:
|
|||
canrecruit=1
|
||||
controller=ai
|
||||
recruitment_pattern=fighter
|
||||
recruit=Swordsman,Heavy Infantry,Pikeman
|
||||
gold=100
|
||||
recruit=Swordsman,Heavy Infantry,Pikeman,Red Mage
|
||||
gold=200
|
||||
enemy=3
|
||||
[/side]
|
||||
[side]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
name=Royal Guard
|
||||
race=human
|
||||
image=human-royalguard.png
|
||||
hitpoints=60
|
||||
hitpoints=75
|
||||
movement_type=smallfoot
|
||||
movement=6
|
||||
experience=500
|
||||
|
|
|
@ -6,7 +6,7 @@ ability=regenerates
|
|||
hitpoints=55
|
||||
movement_type=largefoot
|
||||
movement=5
|
||||
experience=36
|
||||
experience=52
|
||||
level=2
|
||||
alignment=chaotic
|
||||
advanceto=Troll Warrior
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
|
||||
std::string recruit_unit(const gamemap& map, int side,
|
||||
std::map<gamemap::location,unit>& units, unit& new_unit,
|
||||
gamemap::location recruit_location, display* disp, bool need_castle)
|
||||
gamemap::location recruit_location, display* disp, bool need_castle, bool full_movement)
|
||||
{
|
||||
std::cerr << "recruiting unit for side " << side << "\n";
|
||||
typedef std::map<gamemap::location,unit> units_map;
|
||||
|
@ -89,8 +89,13 @@ std::string recruit_unit(const gamemap& map, int side,
|
|||
return string_table["no_recruit_location"];
|
||||
}
|
||||
|
||||
new_unit.set_movement(0);
|
||||
new_unit.set_attacked();
|
||||
if(full_movement) {
|
||||
new_unit.set_movement(new_unit.total_movement());
|
||||
} else {
|
||||
new_unit.set_movement(0);
|
||||
new_unit.set_attacked();
|
||||
}
|
||||
|
||||
units.insert(std::pair<gamemap::location,unit>(
|
||||
recruit_location,new_unit));
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
//describing why not will be returned. On success, the return string is empty
|
||||
std::string recruit_unit(const gamemap& map, int team, unit_map& units,
|
||||
unit& u, gamemap::location preferred_location,
|
||||
display *disp=NULL, bool need_castle=true);
|
||||
display *disp=NULL, bool need_castle=true, bool full_movement=false);
|
||||
|
||||
//a structure which defines all the statistics for a potential
|
||||
//battle that could take place.
|
||||
|
|
|
@ -542,7 +542,7 @@ void event_handler::handle_event_command(const queued_event& event_info, const s
|
|||
std::vector<unit>& avail = state_of_game->available_units;
|
||||
for(std::vector<unit>::iterator u = avail.begin(); u != avail.end(); ++u) {
|
||||
if(u->matches_filter(cfg)) {
|
||||
recruit_unit(*game_map,1,*units,*u,gamemap::location(),screen,false);
|
||||
recruit_unit(*game_map,1,*units,*u,gamemap::location(),screen,false,true);
|
||||
avail.erase(u);
|
||||
break;
|
||||
}
|
||||
|
@ -677,12 +677,23 @@ void event_handler::handle_event_command(const queued_event& event_info, const s
|
|||
}
|
||||
|
||||
const std::string& lang_message = string_table[id];
|
||||
int option_chosen = gui::show_dialog(*screen,surface,caption,
|
||||
lang_message.empty() ? cfg["message"] : lang_message,
|
||||
options.empty() ? gui::MESSAGE : gui::OK_ONLY,
|
||||
options.empty() ? NULL : &options);
|
||||
int option_chosen = -1;
|
||||
|
||||
//if we're not replaying, or if there is no choice to be made, show
|
||||
//the dialog.
|
||||
if(recorder.at_end() == false || options.empty()) {
|
||||
option_chosen = gui::show_dialog(*screen,surface,caption,
|
||||
lang_message.empty() ? cfg["message"] : lang_message,
|
||||
options.empty() ? gui::MESSAGE : gui::OK_ONLY,
|
||||
options.empty() ? NULL : &options);
|
||||
|
||||
if(screen->update_locked() && options.empty() == false) {
|
||||
if(options.empty() == false) {
|
||||
recorder.choose_option(option_chosen);
|
||||
}
|
||||
}
|
||||
|
||||
//otherwise if a choice has to be made, get it from the replay data
|
||||
else if(options.empty() == false) {
|
||||
const config* const action = recorder.get_next_action();
|
||||
if(action == NULL || action->get_children("choose").empty()) {
|
||||
std::cerr << "choice expected but none found\n";
|
||||
|
@ -695,11 +706,9 @@ void event_handler::handle_event_command(const queued_event& event_info, const s
|
|||
|
||||
const std::string& val = (*(action->get_children("choose").front()))["value"];
|
||||
option_chosen = atol(val.c_str());
|
||||
|
||||
} else if(options.empty() == false) {
|
||||
recorder.choose_option(option_chosen);
|
||||
}
|
||||
|
||||
//implement the consequences of the choice
|
||||
if(options.empty() == false) {
|
||||
assert(size_t(option_chosen) < menu_items.size());
|
||||
|
||||
|
|
|
@ -14,16 +14,23 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
namespace {
|
||||
int xscale(display& disp, int x)
|
||||
{
|
||||
return (x*disp.x())/1024;
|
||||
}
|
||||
|
||||
int yscale(display& disp, int y)
|
||||
{
|
||||
return (y*disp.y())/768;
|
||||
}
|
||||
}
|
||||
|
||||
namespace lobby {
|
||||
|
||||
RESULT enter(display& disp, config& game_data)
|
||||
{
|
||||
//prevent entry into the lobby if mode is less than 1024x768
|
||||
//FIXME: the lobby should be fixed properly
|
||||
if(disp.x() < 1024 || disp.y() < 768) {
|
||||
gui::show_dialog(disp,NULL,"","You currently cannot enter the lobby with a resolution of less than 1024x768 (we're working on this)",gui::OK_ONLY);
|
||||
return QUIT;
|
||||
}
|
||||
const events::resize_lock prevent_resizing;
|
||||
|
||||
CKey key;
|
||||
|
||||
|
@ -31,7 +38,8 @@ RESULT enter(display& disp, config& game_data)
|
|||
|
||||
gui::textbox message_entry(disp,500);
|
||||
|
||||
const scoped_sdl_surface background(image::get_image("misc/lobby.png",image::UNSCALED));
|
||||
scoped_sdl_surface background(image::get_image("misc/lobby.png",image::UNSCALED));
|
||||
background.assign(scale_surface(background,disp.x(),disp.y()));
|
||||
|
||||
update_whole_screen();
|
||||
|
||||
|
@ -39,8 +47,6 @@ RESULT enter(display& disp, config& game_data)
|
|||
if(background != NULL)
|
||||
SDL_BlitSurface(background, NULL, disp.video().getSurface(), NULL);
|
||||
|
||||
std::cerr << "game data: " << game_data.write() << "\n";
|
||||
|
||||
// Display Chats
|
||||
std::stringstream text;
|
||||
for(size_t n = messages.size() > 8 ? messages.size()-8 : 0;
|
||||
|
@ -48,9 +54,11 @@ RESULT enter(display& disp, config& game_data)
|
|||
text << messages[n] << "\n";
|
||||
}
|
||||
|
||||
font::draw_text(&disp,disp.screen_area(),12,font::NORMAL_COLOUR,
|
||||
text.str(),19,574);
|
||||
update_rect(19,574,832,130);
|
||||
const SDL_Rect chat_area = { xscale(disp,19), yscale(disp,574), xscale(disp,832), yscale(disp,130) };
|
||||
|
||||
font::draw_text(&disp,chat_area,12,font::NORMAL_COLOUR,
|
||||
text.str(),xscale(disp,19),yscale(disp,574));
|
||||
update_rect(chat_area);
|
||||
|
||||
// Game List GUI
|
||||
const config* const gamelist = game_data.child("gamelist");
|
||||
|
@ -88,17 +96,17 @@ RESULT enter(display& disp, config& game_data)
|
|||
gui::menu users_menu(disp,users);
|
||||
|
||||
// Set GUI locations
|
||||
users_menu.set_loc(869,23);
|
||||
users_menu.set_width(129);
|
||||
update_rect(869,23,129,725);
|
||||
games_menu.set_loc(19,23);
|
||||
games_menu.set_width(832);
|
||||
update_rect(19,23,832,520);
|
||||
join_game.set_xy(19,545);
|
||||
new_game.set_xy(19+join_game.width()+5,545);
|
||||
quit_game.set_xy(19+join_game.width()+5+new_game.width()+5,545);
|
||||
message_entry.set_position(19,725);
|
||||
message_entry.set_width(832);
|
||||
users_menu.set_loc(xscale(disp,869),yscale(disp,23));
|
||||
users_menu.set_width(xscale(disp,129));
|
||||
update_rect(xscale(disp,869),yscale(disp,23),xscale(disp,129),yscale(disp,725));
|
||||
games_menu.set_loc(xscale(disp,19),yscale(disp,23));
|
||||
games_menu.set_width(xscale(disp,832));
|
||||
update_rect(xscale(disp,19),yscale(disp,23),xscale(disp,832),yscale(disp,520));
|
||||
join_game.set_xy(xscale(disp,19),yscale(disp,545));
|
||||
new_game.set_xy(xscale(disp,19)+join_game.width()+5,yscale(disp,545));
|
||||
quit_game.set_xy(xscale(disp,19)+join_game.width()+5+new_game.width()+5,yscale(disp,545));
|
||||
message_entry.set_position(xscale(disp,19),yscale(disp,725));
|
||||
message_entry.set_width(xscale(disp,832));
|
||||
|
||||
update_whole_screen();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue