[[Dialog fixes]]
- show_dialog now restores the screen to they way it was before the displaying of the dialog - Minor updates to the Game Lobby dialog
This commit is contained in:
parent
3f6c6bbdfe
commit
a4dfbe5baf
2 changed files with 77 additions and 14 deletions
|
@ -491,9 +491,38 @@ int play_multiplayer(display& disp, game_data& units_data, config cfg,
|
|||
gui::draw_dialog_frame((disp.x()-width)/2, (disp.y()-height)/2,
|
||||
width, height, disp);
|
||||
|
||||
//Buttons
|
||||
gui::button launch2_game(disp,"Launch");
|
||||
launch2_game.set_xy((disp.x()/2)-launch2_game.width()/2,(disp.y()-height)/2+height-29);
|
||||
|
||||
//Title
|
||||
SDL_Rect labelr;
|
||||
font::draw_text(&disp,disp.screen_area(),24,font::NORMAL_COLOUR,
|
||||
"Game Lobby",-1,(disp.y()-height)/2+5);
|
||||
labelr.x=0; labelr.y=0; labelr.w=disp.x(); labelr.h=disp.y();
|
||||
labelr = font::draw_text(NULL,labelr,14,font::GOOD_COLOUR,
|
||||
"Player/Type",0,0);
|
||||
font::draw_text(&disp,disp.screen_area(),14,font::GOOD_COLOUR,
|
||||
"Player/Type",((disp.x()-width)/2+30)+(launch2_game.width()/2)-(labelr.w/2),
|
||||
(disp.y()-height)/2+35);
|
||||
labelr.x=0; labelr.y=0; labelr.w=disp.x(); labelr.h=disp.y();
|
||||
labelr = font::draw_text(NULL,labelr,14,font::GOOD_COLOUR,
|
||||
"Race",0,0);
|
||||
font::draw_text(&disp,disp.screen_area(),14,font::GOOD_COLOUR,
|
||||
"Race",((disp.x()-width)/2+145)+(launch2_game.width()/2)-(labelr.w/2),
|
||||
(disp.y()-height)/2+35);
|
||||
labelr.x=0; labelr.y=0; labelr.w=disp.x(); labelr.h=disp.y();
|
||||
labelr = font::draw_text(NULL,labelr,14,font::GOOD_COLOUR,
|
||||
"Team",0,0);
|
||||
font::draw_text(&disp,disp.screen_area(),14,font::GOOD_COLOUR,
|
||||
"Team",((disp.x()-width)/2+260)+(launch2_game.width()/2)-(labelr.w/2),
|
||||
(disp.y()-height)/2+35);
|
||||
labelr.x=0; labelr.y=0; labelr.w=disp.x(); labelr.h=disp.y();
|
||||
labelr = font::draw_text(NULL,labelr,14,font::GOOD_COLOUR,
|
||||
"Color",0,0);
|
||||
font::draw_text(&disp,disp.screen_area(),14,font::GOOD_COLOUR,
|
||||
"Color",((disp.x()-width)/2+375)+(launch2_game.width()/2)-(labelr.w/2),
|
||||
(disp.y()-height)/2+35);
|
||||
|
||||
//Options
|
||||
std::vector<std::string> player_type;
|
||||
|
@ -532,28 +561,24 @@ int play_multiplayer(display& disp, game_data& units_data, config cfg,
|
|||
for(sd = sides.begin(); sd != sides.end(); ++sd) {
|
||||
font::draw_text(&disp,disp.screen_area(),24,font::GOOD_COLOUR,
|
||||
(*sd)->values["side"],(disp.x()-width)/2+10,
|
||||
(disp.y()-height)/2+38+(30*counter));
|
||||
(disp.y()-height)/2+53+(30*counter));
|
||||
combo_type.push_back(gui::combo(disp,player_type));
|
||||
combo_type[counter].set_xy((disp.x()-width)/2+30,
|
||||
(disp.y()-height)/2+40+(30*counter));
|
||||
(disp.y()-height)/2+55+(30*counter));
|
||||
combo_race.push_back(gui::combo(disp,player_race));
|
||||
combo_race[counter].set_xy((disp.x()-width)/2+150,
|
||||
(disp.y()-height)/2+40+(30*counter));
|
||||
combo_race[counter].set_xy((disp.x()-width)/2+145,
|
||||
(disp.y()-height)/2+55+(30*counter));
|
||||
combo_team.push_back(gui::combo(disp,player_team));
|
||||
combo_team[counter].set_xy((disp.x()-width)/2+270,
|
||||
(disp.y()-height)/2+40+(30*counter));
|
||||
combo_team[counter].set_xy((disp.x()-width)/2+260,
|
||||
(disp.y()-height)/2+55+(30*counter));
|
||||
combo_team[counter].set_selected(counter);
|
||||
combo_color.push_back(gui::combo(disp,player_color));
|
||||
combo_color[counter].set_xy((disp.x()-width)/2+390,
|
||||
(disp.y()-height)/2+40+(30*counter));
|
||||
combo_color[counter].set_xy((disp.x()-width)/2+375,
|
||||
(disp.y()-height)/2+55+(30*counter));
|
||||
combo_color[counter].set_selected(counter);
|
||||
counter++;
|
||||
}
|
||||
|
||||
//Buttons
|
||||
gui::button launch2_game(disp,"Launch");
|
||||
launch2_game.set_xy((disp.x()/2)-launch2_game.width()/2,(disp.y()-height)/2+height-29);
|
||||
|
||||
update_whole_screen();
|
||||
|
||||
for(;;) {
|
||||
|
|
|
@ -400,6 +400,12 @@ int show_dialog(display& disp, SDL_Surface* image,
|
|||
button_offset += buttons[button_num].width();
|
||||
}
|
||||
|
||||
SDL_Rect dlgr;
|
||||
dlgr.x=xloc-10;
|
||||
dlgr.y=yloc-10;
|
||||
dlgr.w=total_width+20;
|
||||
dlgr.h=total_height+20;
|
||||
SDL_Surface *original = get_surface_portion(disp.video().getSurface(),dlgr);
|
||||
draw_dialog_frame(xloc,yloc,total_width,total_height,disp);
|
||||
|
||||
if(menu_.height() > 0)
|
||||
|
@ -491,13 +497,22 @@ int show_dialog(display& disp, SDL_Surface* image,
|
|||
*text_widget_text = text_widget.text();
|
||||
|
||||
if(menu_.height() == 0) {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return 0;
|
||||
} else {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return menu_.selection();
|
||||
}
|
||||
}
|
||||
|
||||
if(!key_down && key[SDLK_ESCAPE] && type == MESSAGE) {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -505,8 +520,14 @@ int show_dialog(display& disp, SDL_Surface* image,
|
|||
(type == YES_NO || type == OK_CANCEL)) {
|
||||
|
||||
if(menu_.height() == 0) {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return 1;
|
||||
} else {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -536,12 +557,17 @@ int show_dialog(display& disp, SDL_Surface* image,
|
|||
if(menu_.height() > 0) {
|
||||
const int res = menu_.process(mousex,mousey,new_left_button,
|
||||
!up_arrow && new_up_arrow,
|
||||
!down_arrow && new_down_arrow,
|
||||
!down_arrow && new_down_arrow,
|
||||
!page_up && new_page_up,
|
||||
!page_down && new_page_down,
|
||||
select_item);
|
||||
if(res != -1)
|
||||
return res;
|
||||
{
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
up_arrow = new_up_arrow;
|
||||
|
@ -575,11 +601,20 @@ int show_dialog(display& disp, SDL_Surface* image,
|
|||
//item selected if the last button is not pressed, and
|
||||
//cancel (-1) otherwise
|
||||
if(menu_.height() == 0) {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return button_it - buttons.begin();
|
||||
} else if(buttons.size() <= 1 ||
|
||||
size_t(button_it-buttons.begin()) != buttons.size()-1) {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return menu_.selection();
|
||||
} else {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -588,6 +623,9 @@ int show_dialog(display& disp, SDL_Surface* image,
|
|||
if(action != NULL) {
|
||||
const int act = action->do_action();
|
||||
if(act != dialog_action::CONTINUE_DIALOG) {
|
||||
SDL_BlitSurface(original,NULL,disp.video().getSurface(),&dlgr);
|
||||
SDL_FreeSurface(original);
|
||||
update_rect(dlgr);
|
||||
return act;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue