bool unit_animation_component::invalidate (const display & disp) { bool result = false; // Very early calls, anim not initialized yet if(get_animation()) { frame_parameters params; const gamemap & map = disp.get_map(); const t_translation::t_terrain terrain = map.get_terrain(u_.loc_); const terrain_type& terrain_info = map.get_terrain_info(terrain); int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * disp.get_zoom_factor()); if (u_.is_flying() && height_adjust < 0) { height_adjust = 0; } params.y -= height_adjust; params.halo_y -= height_adjust; params.image_mod = u_.image_mods(); params.halo_mod = u_.TC_image_mods(); params.image= u_.absolute_image(); result |= get_animation()->invalidate(params); } return result; }
void status_table(display& gui, int selected) { std::stringstream heading; heading << HEADING_PREFIX << _("Leader") << COLUMN_SEPARATOR << ' ' << COLUMN_SEPARATOR << _("Team") << COLUMN_SEPARATOR << _("Gold") << COLUMN_SEPARATOR << _("Villages") << COLUMN_SEPARATOR << _("status^Units") << COLUMN_SEPARATOR << _("Upkeep") << COLUMN_SEPARATOR << _("Income"); gui::menu::basic_sorter sorter; sorter.set_redirect_sort(0,1).set_alpha_sort(1).set_alpha_sort(2).set_numeric_sort(3) .set_numeric_sort(4).set_numeric_sort(5).set_numeric_sort(6).set_numeric_sort(7); std::vector<std::string> items; std::vector<bool> leader_bools; items.push_back(heading.str()); const gamemap& map = gui.get_map(); const unit_map& units = gui.get_units(); assert(&gui.get_teams() == resources::teams); const std::vector<team>& teams = gui.get_teams(); const team& viewing_team = teams[gui.viewing_team()]; unsigned total_villages = 0; // a variable to check if there are any teams to show in the table bool status_table_empty = true; //if the player is under shroud or fog, they don't get //to see details about the other sides, only their own //side, allied sides and a ??? is shown to demonstrate //lack of information about the other sides But he see //all names with in colors for(size_t n = 0; n != teams.size(); ++n) { if(teams[n].hidden()) { continue; } status_table_empty=false; const bool known = viewing_team.knows_about_team(n, network::nconnections() > 0); const bool enemy = viewing_team.is_enemy(n+1); std::stringstream str; const team_data data = gui.get_disp_context().calculate_team_data(teams[n],n+1); unit_map::const_iterator leader = units.find_leader(n + 1); std::string leader_name; //output the number of the side first, and this will //cause it to be displayed in the correct color if(leader != units.end()) { const bool fogged = viewing_team.fogged(leader->get_location()); // Add leader image. If it's fogged // show only a random leader image. if (!fogged || known || game_config::debug) { str << IMAGE_PREFIX << leader->absolute_image(); leader_bools.push_back(true); leader_name = leader->name(); } else { str << IMAGE_PREFIX << std::string("units/unknown-unit.png"); leader_bools.push_back(false); leader_name = "Unknown"; } // if (gamestate_.classification().campaign_type == game_classification::MULTIPLAYER) // leader_name = teams[n].current_player(); #ifndef LOW_MEM str << leader->image_mods(); #endif } else { leader_bools.push_back(false); } str << COLUMN_SEPARATOR << team::get_side_highlight(n) << leader_name << COLUMN_SEPARATOR << (data.teamname.empty() ? teams[n].team_name() : data.teamname) << COLUMN_SEPARATOR; if(!known && !game_config::debug) { // We don't spare more info (only name) // so let's go on next side ... items.push_back(str.str()); continue; } if(game_config::debug) { str << utils::half_signed_value(data.gold) << COLUMN_SEPARATOR; } else if(enemy && viewing_team.uses_fog()) { str << ' ' << COLUMN_SEPARATOR; } else { str << utils::half_signed_value(data.gold) << COLUMN_SEPARATOR; } str << data.villages; if(!(viewing_team.uses_fog() || viewing_team.uses_shroud())) { str << "/" << map.villages().size(); } str << COLUMN_SEPARATOR << data.units << COLUMN_SEPARATOR << data.upkeep << COLUMN_SEPARATOR << (data.net_income < 0 ? font::BAD_TEXT : font::NULL_MARKUP) << utils::signed_value(data.net_income); total_villages += data.villages; items.push_back(str.str()); } if (total_villages > map.villages().size()) { //TODO // ERR_NG << "Logic error: map has " << map.villages().size() // << " villages but status table shows " << total_villages << " owned in total\n"; } if (status_table_empty) { // no sides to show - display empty table std::stringstream str; str << " "; for (int i=0;i<7;++i) str << COLUMN_SEPARATOR << " "; leader_bools.push_back(false); items.push_back(str.str()); } int result = 0; { leader_scroll_dialog slist(gui, _("Current Status"), leader_bools, selected, gui::DIALOG_FORWARD); slist.add_button(new gui::dialog_button(gui.video(), _("More >"), gui::button::TYPE_PRESS, gui::DIALOG_FORWARD), gui::dialog::BUTTON_EXTRA_LEFT); slist.set_menu(items, &sorter); slist.get_menu().move_selection(selected); result = slist.show(); selected = slist.get_menu().selection(); } // this will kill the dialog before scrolling if (result >= 0) { //TODO // gui.scroll_to_leader(units_, selected+1); } else if (result == gui::DIALOG_FORWARD) scenario_settings_table(gui, selected); }