Beispiel #1
0
SystemInfoView::RefreshType SystemInfoView::NeedsRefresh()
{
	if (!m_system || !Pi::sectorView->GetSelected().IsSameSystem(m_system->GetSystemPath()))
		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->GetSystemPath() != m_system->GetSystemPath()) {
		// 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;
}
Beispiel #2
0
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->GetSystemPath() == m_system->GetSystemPath()) {
			//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->GetSystemPath()) && !selected.IsSystemPath()) {
				if (bodyIcon.first == selected.bodyIndex) {
					bodyIcon.second->SetSelectColor(Color(64, 96, 255, 255));
					bodyIcon.second->SetSelected(true);
					m_selectedBodyPath = selected;
				}
			}
		}
	}
}
Beispiel #3
0
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->GetSystemPath() == m_system->GetSystemPath());

	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();
}