예제 #1
0
        void Indicator_ec(Panel p, Vessel v, Vessel_info vi)
        {
#if !KSP170 && !KSP16 && !KSP15 && !KSP14
            if (v.vesselType == VesselType.DeployedScienceController)
            {
                return;
            }
#endif

            Resource_info ec            = ResourceCache.Info(v, "ElectricCharge");
            Supply        supply        = Profile.supplies.Find(k => k.resource == "ElectricCharge");
            double        low_threshold = supply != null ? supply.low_threshold : 0.15;
            double        depletion     = ec.Depletion(vi.crew_count);

            string tooltip = Lib.BuildString
                             (
                "<align=left /><b>name\tlevel\tduration</b>\n",
                ec.level <= 0.005 ? "<color=#ff0000>" : ec.level <= low_threshold ? "<color=#ffff00>" : "<color=#cccccc>",
                "EC\t",
                Lib.HumanReadablePerc(ec.level), "\t",
                depletion <= double.Epsilon ? "depleted" : Lib.HumanReadableDuration(depletion),
                "</color>"
                             );

            Texture2D image = ec.level <= 0.005
                          ? Icons.battery_red
                          : ec.level <= low_threshold
                          ? Icons.battery_yellow
                          : Icons.battery_white;

            p.AddIcon(image, tooltip);
        }
예제 #2
0
		static void Render_supplies(Panel p, Vessel v, Vessel_info vi, Vessel_resources resources)
		{
			// for each supply
			int supplies = 0;
			foreach (Supply supply in Profile.supplies)
			{
				// get resource info
				Resource_info res = resources.Info(v, supply.resource);

				// only show estimate if the resource is present
				if (res.amount <= 1e-10) continue;

				// render panel title, if not done already
				if (supplies == 0) p.AddSection("SUPPLIES");

				// rate tooltip
				string rate_tooltip = Math.Abs(res.rate) >= 1e-10 ? Lib.BuildString
				(
				  res.rate > 0.0 ? "<color=#00ff00><b>" : "<color=#ffaa00><b>",
				  Lib.HumanReadableRate(Math.Abs(res.rate)),
				  "</b></color>"
				) : string.Empty;

				// determine label
				string label = supply.resource == "ElectricCharge"
				  ? "battery"
				  : Lib.SpacesOnCaps(supply.resource).ToLower();

				// finally, render resource supply
				p.AddContent(label, Lib.HumanReadableDuration(res.Depletion(vi.crew_count)), rate_tooltip);
				++supplies;
			}
		}
예제 #3
0
        void Indicator_supplies(Panel p, Vessel v, Vessel_info vi)
        {
            List <string> tooltips     = new List <string>();
            uint          max_severity = 0;

            if (vi.crew_count > 0)
            {
                foreach (Supply supply in Profile.supplies.FindAll(k => k.resource != "ElectricCharge"))
                {
                    Resource_info res       = ResourceCache.Info(v, supply.resource);
                    double        depletion = res.Depletion(vi.crew_count);

                    if (res.capacity > double.Epsilon)
                    {
                        if (tooltips.Count == 0)
                        {
                            tooltips.Add(String.Format("<align=left /><b>{0,-18}\tlevel\tduration</b>", "name"));
                        }
                        tooltips.Add(Lib.BuildString
                                     (
                                         res.level <= 0.005 ? "<color=#ff0000>" : res.level <= supply.low_threshold ? "<color=#ffff00>" : "<color=#cccccc>",
                                         String.Format("{0,-18}\t{1}\t{2}", supply.resource, Lib.HumanReadablePerc(res.level),
                                                       depletion <= double.Epsilon ? "depleted" : Lib.HumanReadableDuration(depletion)),
                                         "</color>"
                                     ));

                        uint severity = res.level <= 0.005 ? 2u : res.level <= supply.low_threshold ? 1u : 0;
                        max_severity = Math.Max(max_severity, severity);
                    }
                }
            }

            Texture2D image = max_severity == 2
                          ? Icons.box_red
                          : max_severity == 1
                          ? Icons.box_yellow
                          : Icons.box_white;

            p.AddIcon(image, string.Join("\n", tooltips.ToArray()));
        }