Ejemplo n.º 1
0
		void indicator_signal(Panel p, Vessel v, vessel_info vi)
		{
			ConnectionInfo conn = vi.connection;
			if (RemoteTech.Enabled())
			{
				double signal_delay = RemoteTech.GetShortestSignalDelay(v.id);
				string signal_str = "";
				if (signal_delay < Double.Epsilon)
				{
					signal_str = "none";
				}
				else
				{
					signal_str = KSPUtil.dateTimeFormatter.PrintTimeStampCompact(signal_delay, false, false);
				}
				string tooltip_rt = Lib.BuildString(
				  "<align=left />",
				  "connected\t<b>", conn.linked ? "yes" : "no", "</b>\n",
				  "delay\t\t<b>", conn.linked ? signal_str : "no connection", "</b>\n",
				  "rate\t\t<b>", Lib.HumanReadableDataRate(vi.connection.rate), "</b>"
				);
				Texture image_rt = Icons.signal_red;
				if (RemoteTech.Connected(v.id)) image_rt = Icons.signal_white;
				if (RemoteTech.Connected(v.id) && !RemoteTech.ConnectedToKSC(v.id)) image_rt = Icons.signal_yellow;
				if (vi.blackout || RemoteTech.GetCommsBlackout(v.id))
				{
					image_rt = Icons.signal_red;
					tooltip_rt += "\n\n<color=red><i>Blackout</i></color>";
				}
				p.icon(image_rt, tooltip_rt);
				return;
			}

			// target name
			string target_str = string.Empty;
			switch (vi.connection.status)
			{
				case LinkStatus.direct_link: target_str = ("DSN"); break;
				case LinkStatus.indirect_link: target_str = vi.connection.path[vi.connection.path.Count - 1].vesselName; break;
				default: target_str = "none"; break;
			}

			// transmitted label, content and tooltip
			string comms_label = vi.relaying.Length == 0 ? "transmitting" : "relaying";
			string comms_str = vi.connection.linked ? "telemetry" : "nothing";
			string comms_tooltip = string.Empty;
			if (vi.relaying.Length > 0)
			{
				ExperimentInfo exp = Science.experiment(vi.relaying);
				comms_str = exp.name;
				comms_tooltip = exp.fullname;
			}
			else if (vi.transmitting.Length > 0)
			{
				ExperimentInfo exp = Science.experiment(vi.transmitting);
				comms_str = exp.name;
				comms_tooltip = exp.fullname;
			}

			string tooltip = Lib.BuildString
			(
			  "<align=left />",
			  "connected\t<b>", vi.connection.linked ? "yes" : "no", "</b>\n",
			  "rate\t\t<b>", Lib.HumanReadableDataRate(vi.connection.rate), "</b>\n",
			  "target\t\t<b>", target_str, "</b>\n",
			  comms_label, "\t<b>", comms_str, "</b>"
			);

			Texture image = Icons.signal_red;
			switch (conn.status)
			{
				case LinkStatus.direct_link:
					image = vi.connection.rate > 0.005 ? Icons.signal_white : Icons.signal_yellow;
					break;

				case LinkStatus.indirect_link:
					image = vi.connection.rate > 0.005 ? Icons.signal_white : Icons.signal_yellow;
					tooltip += "\n\n<color=yellow>Signal relayed</color>";
					break;

				case LinkStatus.no_link:
					image = Icons.signal_red;
					break;

				case LinkStatus.no_antenna:
					image = Icons.signal_red;
					tooltip += "\n\n<color=red>No antenna</color>";
					break;

				case LinkStatus.blackout:
					image = Icons.signal_red;
					tooltip += "\n\n<color=red><i>Blackout</i></color>";
					break;
			}

			p.icon(image, tooltip);
		}