void GraphicalSummaryWnd::MakeSummaries(int log_id) { m_summaries.clear(); if(!CombatLogAvailable(log_id)) { ErrorLogger() << "CombatReportWnd::CombatReportPrivate::MakeSummaries: Could not find log: " << log_id; } else { const CombatLog& log = GetCombatLog(log_id); for( std::set<int>::const_iterator it = log.object_ids.begin(); it != log.object_ids.end(); ++it) { TemporaryPtr<UniverseObject> object = Objects().Object(*it); if(object) { int owner_id = object->Owner(); int object_id = object->ID(); if( m_summaries.find(owner_id) == m_summaries.end() ) { m_summaries.insert( std::map<int, CombatSummary>::value_type(owner_id,CombatSummary(owner_id)) ); } std::map<int, CombatParticipantState>::const_iterator it = log.participant_states.find(object_id); if ( it != log.participant_states.end() ) { m_summaries[owner_id].AddUnit(object_id, it->second); } else { ErrorLogger() << "Participant state missing from log. Object id: " << object_id << " log id: " << log_id; } } } for(std::map<int, CombatSummary>::iterator it = m_summaries.begin(); it != m_summaries.end(); ++it ) { DebugLogger() << "MakeSummaries: empire " << it->first << " total health: " << it->second.total_current_health << " max health: " << it->second.total_max_health << " units: " << it->second.unit_summaries.size(); } } GenerateGraph(); }
void CombatLogWnd::CombatLogWndImpl::SetLog(int log_id) { if (!CombatLogAvailable(log_id)) { ErrorLogger() << "Couldn't find combat log with id: " << log_id; return; } m_wnd.DeleteChildren(); GG::Layout* layout = new GG::Layout(m_wnd.UpperLeft().x, m_wnd.UpperLeft().y , m_wnd.Width(), m_wnd.Height() , 1, 1 ///< numrows, numcols , 0, 0 ///< wnd margin, cell margin ); m_wnd.SetLayout(layout); const CombatLog& log = GetCombatLog(log_id); int client_empire_id = HumanClientApp::GetApp()->EmpireID(); // Write Header text DebugLogger() << "Setting log with " << log.combat_events.size() << " events"; TemporaryPtr<const System> system = GetSystem(log.system_id); const std::string& sys_name = (system ? system->PublicName(client_empire_id) : UserString("ERROR")); AddRow(DecorateLinkText(str(FlexibleFormat(UserString("ENC_COMBAT_LOG_DESCRIPTION_STR")) % LinkTaggedIDText(VarText::SYSTEM_ID_TAG, log.system_id, sys_name) % log.turn) + "\n" )); AddRow(DecorateLinkText(UserString("COMBAT_INITIAL_FORCES"))); AddRow(DecorateLinkText(CountsToText(CountByOwner(log.empire_ids, log.object_ids)))); std::stringstream summary_text; summary_text << std::endl << UserString("COMBAT_SUMMARY_DESTROYED") << std::endl << CountsToText(CountByOwner(log.empire_ids, log.destroyed_object_ids)); AddRow(DecorateLinkText(summary_text.str())); // Write Logs for (std::vector<CombatEventPtr>::const_iterator it = log.combat_events.begin(); it != log.combat_events.end(); ++it) { DebugLogger() << "event debug info: " << it->get()->DebugString(); std::vector<GG::Wnd *> flat_logs = MakeCombatLogPanel(m_font->SpaceWidth()*10, client_empire_id, *it); for (std::vector<GG::Wnd *>::iterator log_it = flat_logs.begin(); log_it != flat_logs.end(); ++log_it) { AddRow(*log_it); } } // Add a dummy row that the layout manager can use to add space. AddRow(DecorateLinkText("")); layout->SetRowStretch(layout->Rows() - 1, 1); HandleWndChanged(); }
void GraphicalSummaryWnd::MakeSummaries(int log_id) { m_summaries.clear(); if (!CombatLogAvailable(log_id)) { ErrorLogger() << "CombatReportWnd::CombatReportPrivate::MakeSummaries: Could not find log: " << log_id; } else { const CombatLog& log = GetCombatLog(log_id); for (std::set<int>::const_iterator it = log.object_ids.begin(); it != log.object_ids.end(); ++it) { int object_id = *it; if (object_id < 0) continue; // fighters and invalid objects TemporaryPtr<UniverseObject> object = GetUniverseObject(object_id); if (!object) { ErrorLogger() << "GraphicalSummaryWnd::MakeSummaries couldn't find object with id: " << object_id; continue; } int owner_id = object->Owner(); if (m_summaries.find(owner_id) == m_summaries.end()) m_summaries[owner_id] = CombatSummary(owner_id); std::map<int, CombatParticipantState>::const_iterator map_it = log.participant_states.find(object_id); if (map_it != log.participant_states.end()) { m_summaries[owner_id].AddUnit(object_id, map_it->second); } else { ErrorLogger() << "Participant state missing from log. Object id: " << object_id << " log id: " << log_id; } } for (std::map<int, CombatSummary>::iterator it = m_summaries.begin(); it != m_summaries.end(); ++it) { DebugLogger() << "MakeSummaries: empire " << it->first << " total health: " << it->second.total_current_health << " max health: " << it->second.total_max_health << " units: " << it->second.unit_summaries.size(); } } GenerateGraph(); }