void SystemInfoView::UpdateIconSelections() { m_selectedBodyPath = SystemPath(); for (auto& bodyIcon : m_bodyIcons) { bodyIcon.second->SetSelected(false); RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem(); if (currentSys && currentSys->GetPath() == m_system->GetPath()) { //navtarget can be only set in current system if (Body* navtarget = Pi::player->GetNavTarget()) { const SystemPath& navpath = navtarget->GetSystemBody()->GetPath(); if (bodyIcon.first == navpath.bodyIndex) { bodyIcon.second->SetSelectColor(Color(0, 255, 0, 255)); bodyIcon.second->SetSelected(true); m_selectedBodyPath = navpath; } } } else { SystemPath selected = Pi::sectorView->GetSelected(); if (selected.IsSameSystem(m_system->GetPath()) && !selected.IsSystemPath()) { if (bodyIcon.first == selected.bodyIndex) { bodyIcon.second->SetSelectColor(Color(64, 96, 255, 255)); bodyIcon.second->SetSelected(true); m_selectedBodyPath = selected; } } } } }
SystemInfoView::RefreshType SystemInfoView::NeedsRefresh() { if (!m_system || !Pi::sectorView->GetSelected().IsSameSystem(m_system->GetPath())) return REFRESH_ALL; if (m_system->GetUnexplored()) return REFRESH_NONE; // Nothing can be selected and we reset in SystemChanged RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem(); if (!currentSys || currentSys->GetPath() != m_system->GetPath()) { // We are not currently in the selected system if (Pi::sectorView->GetSelected() != m_selectedBodyPath) return REFRESH_SELECTED; } else { Body *navTarget = Pi::player->GetNavTarget(); if (navTarget && navTarget->GetSystemBody()->GetType() != SystemBody::TYPE_STARPORT_SURFACE) { // Navigation target is something we show in the info view if (navTarget->GetSystemBody()->GetPath() != m_selectedBodyPath) return REFRESH_SELECTED; // and wasn't selected, yet } else { // nothing to be selected if (m_selectedBodyPath.IsBodyPath()) return REFRESH_SELECTED; // but there was something selected } } return REFRESH_NONE; }
void SystemInfoView::OnBodySelected(SystemBody *b) { { Output("\n"); Output("Gas, liquid, ice: %f, %f, %f\n", b->GetVolatileGas().ToFloat(), b->GetVolatileLiquid().ToFloat(), b->GetVolatileIces().ToFloat()); } SystemPath path = m_system->GetPathOf(b); RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem(); bool isCurrentSystem = (currentSys && currentSys->GetPath() == m_system->GetPath()); if (path == m_selectedBodyPath) { if (isCurrentSystem) { Pi::player->SetNavTarget(0); } } else { if (isCurrentSystem) { Body* body = Pi::game->GetSpace()->FindBodyForPath(&path); if(body != 0) Pi::player->SetNavTarget(body); } else if (b->GetSuperType() == SystemBody::SUPERTYPE_STAR) { // We allow hyperjump to any star of the system Pi::sectorView->SetSelected(path); } } UpdateIconSelections(); }
void SystemInfoView::UpdateIconSelections() { //navtarget can be only set in current system for (std::vector<std::pair<std::string, BodyIcon*> >::iterator it = m_bodyIcons.begin(); it != m_bodyIcons.end(); ++it) { (*it).second->SetSelected(false); RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem(); if (currentSys && currentSys->GetPath() == m_system->GetPath() && Pi::player->GetNavTarget() && (*it).first == Pi::player->GetNavTarget()->GetLabel()) { (*it).second->SetSelected(true); } } }
void SystemInfoView::OnBodySelected(SBody *b) { { printf("\n"); printf("Gas, liquid, ice: %f, %f, %f\n", b->m_volatileGas.ToFloat(), b->m_volatileLiquid.ToFloat(), b->m_volatileIces.ToFloat()); } SystemPath path = m_system->GetPathOf(b); RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem(); if (currentSys && currentSys->GetPath() == m_system->GetPath()) { Body* body = Pi::game->GetSpace()->FindBodyForPath(&path); if(body != 0) Pi::player->SetNavTarget(body); } UpdateIconSelections(); }