made it so the 'help' button is on the left side of dialog boxes.

Made an 'OK_BUTTON_ON_RIGHT' compile flag to use cancel-ok style
button ordering in dialog boxes
This commit is contained in:
Dave White 2004-06-21 22:09:02 +00:00
parent d8b70217ce
commit 4662c0c17a
10 changed files with 75 additions and 29 deletions

View file

@ -55,9 +55,9 @@ Defeat:
canrecruit=1
recruit=Orcish Warrior,Wolf Rider,Troll,Troll Whelp,Goblin Pillager
#ifdef HARD
gold=300
gold=400
#else
gold=200
gold=300
#endif
team_name=evil
[/side]

View file

@ -733,8 +733,11 @@ red="Red"
blue="Blue"
green="Green"
yellow="Yellow"
pink="Pink"
purple="Purple"
orange="Orange"
grey="Grey"
white="White"
brown="Brown"
#terrain
terrain="Terrain"

View file

@ -1443,6 +1443,7 @@ bool clear_shroud_unit(const gamemap& map,
for(std::vector<gamemap::location>::const_iterator it =
cleared_locations.begin(); it != cleared_locations.end(); ++it) {
if(units.count(*it)) {
if(seen_units == NULL || known_units == NULL) {
static const std::string sighted("sighted");
@ -1757,6 +1758,10 @@ size_t move_unit(display* disp, const game_data& gamedata,
disp->recalculate_minimap();
}
for(std::set<gamemap::location>::const_iterator seen = seen_units.begin(); seen != seen_units.end(); ++seen) {
game_events::fire("sighted",*seen,steps.back());
}
assert(steps.size() <= route.size());
return steps.size();

View file

@ -739,7 +739,12 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
gamemap::location loc;
bool remove_overlay = false;
if(filter != NULL) {
loc = gamemap::location(*filter);
for(unit_map::const_iterator u = units->begin(); u != units->end(); ++u) {
if(game_events::unit_matches_filter(u,*filter)) {
loc = u->first;
break;
}
}
}
if(loc.valid() == false) {

View file

@ -512,6 +512,7 @@ void extract_summary_data_from_save(const game_state& state, config& out)
}
out["leader"] = leader;
out["map_data"] = "";
if(!shrouded) {
if(has_snapshot) {

View file

@ -168,7 +168,7 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
int height = int(area.h);
const int left = area.x;
const int top = area.y;
const int border_size = 5;
const int border_size = 6;
const int right = left + width;
const int bottom = top + height;
@ -197,7 +197,7 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
SDL_Rect rect;
//the sliders and other options on the right side of the dialog
rect.x = xpos + minimap_width + maps_menu_->width() + border_size*2;
rect.x = xpos + minimap_width + maps_menu_->width() + border_size;
rect.y = ypos;
rect.w = maximum<int>(0,right - border_size - rect.x);
//a font sized "12" isn't necessarily 12 pixel high.
@ -205,38 +205,38 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
turns_restorer_ = surface_restorer(&disp_.video(),rect);
rect.y += rect.h + border_size*2;
rect.y += rect.h + border_size + 1;
turns_slider_->set_location(rect);
turns_slider_->set_dirty();
//Village Gold
rect.y += rect.h + border_size*2;
rect.y += rect.h + border_size + 1;
village_gold_restorer_ = surface_restorer(&disp_.video(),rect);
rect.y += rect.h + border_size*2;
rect.y += rect.h + border_size + 1;
village_gold_slider_->set_location(rect);
village_gold_slider_->set_dirty();
//Experience Modifier
rect.y += rect.h + border_size*2;
rect.y += rect.h + border_size + 1;
xp_restorer_ = surface_restorer(&disp_.video(),rect);
rect.y += rect.h + border_size*2;
rect.y += rect.h + border_size + 1;
xp_modifier_slider_->set_location(rect);
xp_modifier_slider_->set_dirty();
//FOG of war
rect.y += rect.h + border_size*2;
rect.y += rect.h + border_size + 1;
fog_game_->set_location(rect.x,rect.y);
fog_game_->set_dirty();
rect.y += fog_game_->location().h + border_size;
rect.y += fog_game_->location().h + border_size + 1;
//Shroud
shroud_game_->set_location(rect.x,rect.y);
@ -256,11 +256,16 @@ void multiplayer_game_setup_dialog::set_area(const SDL_Rect& area)
rect.y += vision_combo_->height() + border_size;
gui::button* left_button = launch_game_;
gui::button* right_button = cancel_game_;
#ifdef OK_BUTTON_ON_RIGHT
std::swap(left_button,right_button);
#endif
//Buttons
cancel_game_->set_location(right - cancel_game_->width() - gui::ButtonHPadding,
bottom - cancel_game_->height() - gui::ButtonVPadding);
launch_game_->set_location(right - cancel_game_->width() - launch_game_->width() - gui::ButtonHPadding*2,
bottom - launch_game_->height() - gui::ButtonVPadding);
right_button->set_location(right - right_button->width() - gui::ButtonHPadding,bottom - right_button->height() - gui::ButtonVPadding);
left_button->set_location(right - right_button->width() - left_button->width() - gui::ButtonHPadding*2,bottom - left_button->height() - gui::ButtonVPadding);
cancel_game_->set_dirty();
launch_game_->set_dirty();

View file

@ -343,9 +343,16 @@ void mp_connect::set_area(const SDL_Rect& rect)
// Wait to players, Configure players
//gui::draw_dialog_background(left, right, width, height, *disp_, "menu");
gui::button* left_button = &launch_;
gui::button* right_button = &cancel_;
#ifdef OK_BUTTON_ON_RIGHT
std::swap(left_button,right_button);
#endif
//Buttons
cancel_.set_location(right - cancel_.width() - gui::ButtonHPadding,bottom-cancel_.height()-gui::ButtonVPadding);
launch_.set_location(right - cancel_.width() - launch_.width() - gui::ButtonHPadding*2,bottom-launch_.height()-gui::ButtonVPadding);
right_button->set_location(right - right_button->width() - gui::ButtonHPadding,bottom-right_button->height()-gui::ButtonVPadding);
left_button->set_location(right - right_button->width() - left_button->width() - gui::ButtonHPadding*2,bottom-left_button->height()-gui::ButtonVPadding);
ai_.set_location(left+30,bottom-60);

View file

@ -185,7 +185,7 @@ SDL_Rect draw_dialog_title(int x, int y, display* disp, const std::string& text)
void draw_dialog(int x, int y, int w, int h, display& disp, const std::string& title,
const std::string* style, std::vector<button*>* buttons,
surface_restorer* restorer)
surface_restorer* restorer, button* help_button)
{
int border_size = 10;
SDL_Rect title_area = {0,0,0,0};
@ -209,9 +209,16 @@ void draw_dialog(int x, int y, int w, int h, display& disp, const std::string& t
buttons_area.w += ButtonHPadding;
}
size_t buttons_width = buttons_area.w;
if(help_button != NULL) {
buttons_width += help_button->width() + ButtonHPadding*2;
buttons_area.y = y + h;
}
const int xpos = x;
const int ypos = y - int(title_area.h);
const int width = maximum<int>(w,maximum<int>(int(title_area.w),int(buttons_area.w)));
const int width = maximum<int>(w,maximum<int>(int(title_area.w),int(buttons_width)));
const int height = title_area.h + buttons_area.h + h;
buttons_area.x += xpos + width;
@ -223,11 +230,19 @@ void draw_dialog(int x, int y, int w, int h, display& disp, const std::string& t
}
if(buttons != NULL) {
#ifdef OK_BUTTON_ON_RIGHT
std::reverse(buttons->begin(),buttons->end());
#endif
for(std::vector<button*>::const_iterator b = buttons->begin(); b != buttons->end(); ++b) {
(**b).set_location(buttons_area.x,buttons_area.y);
buttons_area.x += (**b).width() + ButtonHPadding;
}
}
if(help_button != NULL) {
help_button->set_location(x+ButtonHPadding,buttons_area.y);
}
}
void draw_rectangle(int x, int y, int w, int h, Uint32 colour,SDL_Surface* target)
@ -580,19 +595,15 @@ int show_dialog(display& disp, SDL_Surface* image,
buttons_ptr.push_back(&*bt);
}
button help_button(disp,string_table["action_help"]);
if(help_topic.empty() == false) {
buttons_ptr.push_back(&help_button);
}
frame_width += left_preview_pane_width + right_preview_pane_width;
frame_height += above_preview_pane_height;
surface_restorer restorer;
button help_button(disp,string_table["action_help"]);
const std::string& title = image == NULL ? caption : "";
draw_dialog(xframe,yframe,frame_width,frame_height,disp,title,dialog_style,&buttons_ptr,&restorer);
draw_dialog(xframe,yframe,frame_width,frame_height,disp,title,dialog_style,&buttons_ptr,&restorer,help_topic.empty() ? NULL : &help_button);
//calculate the positions of the preview panes to the sides of the dialog
if(preview_panes != NULL) {

View file

@ -71,7 +71,7 @@ SDL_Rect draw_dialog_title(int x, int y, display* disp, const std::string& text)
//to its original state after the dialog is drawn.
void draw_dialog(int x, int y, int w, int h, display& disp, const std::string& title,
const std::string* dialog_style=NULL, std::vector<button*>* buttons=NULL,
surface_restorer* restorer=NULL);
surface_restorer* restorer=NULL, button* help_button=NULL);
class dialog_action
{

View file

@ -895,6 +895,15 @@ void unit::add_modification(const std::string& type,
for(config::const_child_itors i = mod.child_range("effect");
i.first != i.second; ++i.first) {
//see if the effect only applies to certain unit types
const std::string& type_filter = (**i.first)["type"];
if(type_filter.empty() == false) {
const std::vector<std::string>& types = config::split(type_filter);
if(std::find(types.begin(),types.end(),this->type().name()) == types.end()) {
continue;
}
}
std::stringstream description;
const std::string& apply_to = (**i.first)["apply_to"];