void floating_textbox::update_location(game_display& gui) { if (box_ == NULL) return; const SDL_Rect& area = gui.map_outside_area(); const int border_size = 10; const int ypos = area.y+area.h-30 - (check_ != NULL ? check_->height() + border_size : 0); if (label_ != 0) font::remove_floating_label(label_); font::floating_label flabel(label_string_); flabel.set_color(font::YELLOW_COLOR); flabel.set_position(area.x + border_size, ypos); flabel.set_alignment(font::LEFT_ALIGN); flabel.set_clip_rect(area); label_ = font::add_floating_label(flabel); if (label_ == 0) return; const SDL_Rect& label_area = font::get_floating_label_rect(label_); const int textbox_width = area.w - label_area.w - border_size*3; if(textbox_width <= 0) { font::remove_floating_label(label_); return; } if(box_ != NULL) { box_->set_volatile(true); const SDL_Rect rect = create_rect( area.x + label_area.w + border_size * 2 , ypos , textbox_width , box_->height()); box_->set_location(rect); } if(check_ != NULL) { check_->set_volatile(true); check_->set_location(box_->location().x,box_->location().y + box_->location().h + border_size); } }
void floating_textbox::update_location(game_display& gui) { if (box_ == NULL) return; const SDL_Rect& area = gui.map_outside_area(); const int border_size = 10; const int ypos = area.y+area.h-30 - (check_ != NULL ? check_->height() + border_size : 0); if (label_ != 0) font::remove_floating_label(label_); label_ = font::add_floating_label(label_string_,font::SIZE_NORMAL, font::YELLOW_COLOUR,area.x+border_size,ypos,0,0,-1, area,font::LEFT_ALIGN); if (label_ == 0) return; const SDL_Rect& label_area = font::get_floating_label_rect(label_); const int textbox_width = area.w - label_area.w - border_size*3; if(textbox_width <= 0) { font::remove_floating_label(label_); return; } if(box_ != NULL) { box_->set_volatile(true); const SDL_Rect rect = { area.x + label_area.w + border_size*2, ypos, textbox_width, box_->height() }; box_->set_location(rect); } if(check_ != NULL) { check_->set_volatile(true); check_->set_location(box_->location().x,box_->location().y + box_->location().h + border_size); } }