fixed problem where some menus would have scroll buttons displayed...

...in top-left corner
This commit is contained in:
uid68803 2004-02-20 16:08:38 +00:00
parent c44e408d62
commit cda417bc99
6 changed files with 26 additions and 14 deletions

View file

@ -219,7 +219,7 @@ SDL_Rect draw_text_line(display* gui, const SDL_Rect& area, int size,
SDL_Rect src = dest;
src.x = 0;
src.y = 0;
SDL_BlitSurface(surface,&src,gui->video().getSurface(),&dest);
sdl_safe_blit(surface,&src,gui->video().getSurface(),&dest);
}
if(use_tooltips) {

View file

@ -261,8 +261,12 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& game_config,
gui.add_overlay(gamemap::location(**overlay),(**overlay)["image"]);
}
gui.scroll_to_tile(map.starting_position(1).x,map.starting_position(1).y,
display::WARP);
if(first_human_team != -1) {
clear_shroud(gui,status,map,gameinfo,units,teams,first_human_team);
gui.scroll_to_tile(map.starting_position(first_human_team+1).x,map.starting_position(first_human_team+1).y,display::WARP);
}
gui.scroll_to_tile(map.starting_position(1).x,map.starting_position(1).y,display::WARP);
bool replaying = (recorder.at_end() == false);
@ -283,7 +287,6 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& game_config,
if(first_time) {
const hotkey::basic_handler key_events_handler(gui);
clear_shroud(gui,status,map,gameinfo,units,teams,0);
std::cerr << "first_time..." << (recorder.skipping() ? "skipping" : "no skip") << "\n";
update_locker lock_display(gui,recorder.skipping());

View file

@ -701,15 +701,13 @@ void show_hotkeys_dialog (display & disp)
menu_items.push_back (str.str ());
}
gui::menu menu_ (disp, menu_items, 0);;
menu_.set_loc (xpos + 20, ypos + 30);
gui::menu menu_ (disp, menu_items);
menu_.set_width(400);
menu_.set_loc (xpos + 20, ypos + 30);
gui::button close_button (disp, string_table["close_window"]);
close_button.set_x (xpos + width -
close_button.width () -30 );
close_button.set_y (ypos + height - close_button.height () -
70);
close_button.set_x (xpos + width - close_button.width () - 30);
close_button.set_y (ypos + height - close_button.height () - 70);
gui::button change_button (disp, string_table["change_hotkey_button"]);
change_button.set_x (xpos + width -

View file

@ -128,6 +128,10 @@ bool button::enabled() const
void button::draw()
{
if(x_ <= 0 && y_ <= 0) {
return;
}
if(type_ == TYPE_CHECK) {
hide();
backup_background();

View file

@ -83,7 +83,7 @@ void menu::set_loc(int x, int y)
SDL_Surface* const screen = display_->video().getSurface();
buffer_.assign(get_surface_portion(screen, portion));
if(items_.size() > max_items_onscreen()) {
if(show_scrollbar()) {
uparrow_.set_x(x_);
uparrow_.set_y(y_);
downarrow_.set_x(x_);
@ -299,6 +299,11 @@ int menu::process(int x, int y, bool button,bool up_arrow,bool down_arrow,
}
}
bool menu::show_scrollbar() const
{
return items_.size() > max_items_onscreen();
}
bool menu::double_clicked() const
{
return double_clicked_;
@ -394,7 +399,7 @@ void menu::draw()
drawn_ = true;
// update enabled/disabled status for up/down buttons
if(items_.size() > max_items_onscreen()) {
if(show_scrollbar()) {
if(first_item_on_screen_ == 0) {
uparrow_.enable(false);
uparrow_.hide();
@ -497,7 +502,7 @@ size_t menu::get_item_height(int item) const
int menu::items_start() const
{
if(items_.size() > max_items_onscreen())
if(show_scrollbar())
return uparrow_.height();
else
return 0;
@ -505,7 +510,7 @@ int menu::items_start() const
int menu::items_end() const
{
if(items_.size() > max_items_onscreen())
if(show_scrollbar())
return height() - downarrow_.height();
else
return height();

View file

@ -49,6 +49,8 @@ private:
void handle_event(const SDL_Event& event);
bool show_scrollbar() const;
display* display_;
int x_, y_;
std::vector<std::vector<std::string> > items_;