Made the gui2 recruit dialog feature complete.

This commit is contained in:
Fabian Müller 2011-02-12 16:43:20 +00:00
parent ea138d748f
commit 20c97a92b1
3 changed files with 29 additions and 2 deletions

View file

@ -67,7 +67,7 @@ void twml_message_::update_unit_list(twindow& window) {
resources::screen->scroll_to_tile(loc,
game_display::SCROLL, true);
} else {
//TODO add code to draw units we can't scroll to.
chosen_unit_->draw_report();
}
window.canvas(1).set_variable("portrait_image", variant(
@ -180,6 +180,8 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
chosen_unit_->big_profile()));
window.set_dirty();
chosen_unit_->draw_report();
//TODO make it optional
connect_signal_mouse_left_click(
find_widget<tbutton>(&window, "help", true)
@ -256,6 +258,14 @@ void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
false);
profile_button->set_visible(twidget::INVISIBLE);
units.set_visible(twidget::INVISIBLE);
tbutton* help_button = find_widget<tbutton> (&window, "help", false,
false);
help_button->set_visible(twidget::INVISIBLE);
tbutton* cancel_button = find_widget<tbutton> (&window, "cancel", false,
false);
cancel_button->set_visible(twidget::INVISIBLE);
}
// Find the option list related fields.

View file

@ -50,6 +50,9 @@ static lg::log_domain log_config("config");
#define WRN_CF LOG_STREAM(warn, log_config)
#define ERR_CONFIG LOG_STREAM(err, log_config)
//TODO this works here but is ugly
unit* unit::selected_unit_ = NULL;
namespace {
const std::string ModificationTypes[] = { "advance", "trait", "object" };
const size_t NumModificationTypes = sizeof(ModificationTypes)/
@ -2799,12 +2802,20 @@ unit_map::iterator find_visible_unit(const map_location &loc,
unit *get_visible_unit(const map_location &loc,
const team &current_team, bool see_all)
{
if (unit::selected_unit_ != NULL) return unit::selected_unit_;
unit_map::iterator ui = find_visible_unit(loc,
current_team, see_all);
if (ui == resources::units->end()) return NULL;
return &*ui;
}
void unit::draw_report() {
selected_unit_ = this;
resources::screen->invalidate_unit();
resources::screen->draw(false, false);
selected_unit_ = NULL;
}
void unit::refresh()
{
if (state_ == STATE_FORGET && anim_ && anim_->animation_finished_potential())
@ -2912,7 +2923,6 @@ void unit::remove_attacks_ai()
set_attacks(0);
}
void unit::remove_movement_ai()
{
if (movement_left() == total_movement()) {

View file

@ -185,6 +185,8 @@ public:
/** draw a unit. */
void redraw_unit();
/** draw the unit's report. Used to display units that are offmap */
void draw_report();
/** Clear unit_halo_ */
void clear_haloes();
@ -330,7 +332,12 @@ public:
const tportrait* portrait(
const unsigned size, const tportrait::tside side) const;
//TODO move to the right place
static unit* selected_unit_;// = NULL;
private:
void advance_to(const config &old_cfg, const unit_type *t,
bool use_traits, game_state *state);