Esempio n. 1
0
        void Indicator_signal(Panel p, Vessel v, Vessel_info vi)
        {
            ConnectionInfo conn = vi.connection;

            // signal strength
            string signal_str = conn.strength > Double.Epsilon ? Lib.HumanReadablePerc(Math.Ceiling(conn.strength * 10000) / 10000, "F2") : Lib.Color("#ffaa00", Lib.Italic(Localizer.Format("#KERBALISM_Generic_NO")));

            // target name
            string target_str = conn.linked ? conn.target_name : Localizer.Format("#KERBALISM_Generic_NONE");

            // transmitting info
            string comms_str = conn.linked ? Localizer.Format("#KERBALISM_UI_telemetry") : Localizer.Format("#KERBALISM_Generic_NOTHING");

            if (vi.transmitting.Length > 0)
            {
                ExperimentInfo exp = Science.Experiment(vi.transmitting);
                comms_str = exp.name;
            }

            // create tooltip
            string tooltip = Lib.BuildString
                             (
                "<align=left />",
                String.Format("{0,-14}\t<b>{1}</b>\n", Localizer.Format("#KERBALISM_UI_DSNconnected"), conn.linked ?
                              Lib.Color("green", Localizer.Format("#KERBALISM_Generic_YES")) : Lib.Color("#ffaa00", Lib.Italic(Localizer.Format("#KERBALISM_Generic_NO")))),
                String.Format("{0,-14}\t<b>{1}</b>\n", Localizer.Format("#KERBALISM_UI_sciencerate"), Lib.HumanReadableDataRate(conn.rate)),
                String.Format("{0,-14}\t<b>{1}</b>\n", Localizer.Format("#KERBALISM_UI_strength"), signal_str),
                String.Format("{0,-14}\t<b>{1}</b>\n", Localizer.Format("#KERBALISM_UI_target"), target_str),
                String.Format("{0,-14}\t<b>{1}</b>", Localizer.Format("#KERBALISM_UI_transmitting"), comms_str)
                             );

            // create icon status
            Texture2D image = Icons.signal_red;

            switch (conn.status)
            {
            case LinkStatus.direct_link:
                image = conn.strength > 0.05 ? Icons.signal_white : Icons.iconSwitch(Icons.signal_yellow, image);                           // or 5% signal strength
                break;

            case LinkStatus.indirect_link:
                image    = conn.strength > 0.05 ? Icons.signal_white : Icons.iconSwitch(Icons.signal_yellow, image);                        // or 5% signal strength
                tooltip += Lib.Color("yellow", "\n" + Localizer.Format("#KERBALISM_UI_Signalrelayed"));
                break;

            case LinkStatus.plasma:
                tooltip += Lib.Color("red", Lib.Italic("\n" + Localizer.Format("#KERBALISM_UI_Plasmablackout")));
                break;

            case LinkStatus.storm:
                tooltip += Lib.Color("red", Lib.Italic("\n" + Localizer.Format("#KERBALISM_UI_Stormblackout")));
                break;
            }

            p.AddIcon(image, tooltip, () => UI.Open((p2) => p2.ConnMan(v)));
        }
Esempio n. 2
0
 public override string info()
 {
   float intensity = Lib.Proto.GetFloat(emitter, "intensity");
   return Lib.BuildString
   (
     "<color=", intensity > float.Epsilon ? "green" : "red", ">",
     "intensity: ", Lib.HumanReadablePerc(intensity),
     "</color>"
   );
 }
Esempio n. 3
0
 public override string info()
 {
   if (!ring.opened) return "<color=red>closed</color>";
   return Lib.BuildString
   (
     "<color=", ring.speed > float.Epsilon ? "green" : "red", ">",
     "speed: ", Lib.HumanReadablePerc(ring.speed),
     "</color>"
   );
 }
Esempio n. 4
0
 public override string info()
 {
   double lamps = Lib.Proto.GetFloat(greenhouse, "lamps");
   return Lib.BuildString
   (
     "<color=", lamps > double.Epsilon ? "green" : "red", ">",
     "lamps: ", Lib.HumanReadablePerc(lamps),
     "</color>"
   );
 }
Esempio n. 5
0
        protected virtual void Init()
        {
            if (!antennaInfo.powered || v.connection == null)
            {
                antennaInfo.linked = false;
                antennaInfo.status = (int)LinkStatus.no_link;
                return;
            }

            // force CommNet update of unloaded vessels
            if (!v.loaded)
            {
                Lib.ReflectionValue(v.connection, "unloadedDoOnce", true);
            }

            // are we connected to DSN
            if (v.connection.IsConnected)
            {
                antennaInfo.linked = true;
                var link = v.connection.ControlPath.First;
                antennaInfo.status   = link.hopType == CommNet.HopType.Home ? (int)LinkStatus.direct_link : (int)LinkStatus.indirect_link;
                antennaInfo.strength = link.signalStrength;

                antennaInfo.rate *= Math.Pow(link.signalStrength, Settings.DataRateDampingExponent);

                antennaInfo.target_name = Lib.Ellipsis(Localizer.Format(v.connection.ControlPath.First.end.displayName).Replace("Kerbin", "DSN"), 20);

                if (antennaInfo.status != (int)LinkStatus.direct_link)
                {
                    Vessel firstHop = Lib.CommNodeToVessel(v.Connection.ControlPath.First.end);
                    // Get rate from the firstHop, each Hop will do the same logic, then we will have the min rate for whole path
                    antennaInfo.rate = Math.Min(Cache.VesselInfo(FlightGlobals.FindVessel(firstHop.id)).connection.rate, antennaInfo.rate);
                }
            }
            // is loss of connection due to plasma blackout
            else if (Lib.ReflectionValue <bool>(v.connection, "inPlasma"))             // calling InPlasma causes a StackOverflow :(
            {
                antennaInfo.status = (int)LinkStatus.plasma;
            }

            antennaInfo.control_path = new List <string[]>();
            foreach (CommLink link in v.connection.ControlPath)
            {
                double antennaPower   = link.end.isHome ? link.start.antennaTransmit.power + link.start.antennaRelay.power : link.start.antennaTransmit.power;
                double signalStrength = 1 - ((link.start.position - link.end.position).magnitude / Math.Sqrt(antennaPower * link.end.antennaRelay.power));
                signalStrength = (3 - (2 * signalStrength)) * Math.Pow(signalStrength, 2);

                string name    = Lib.Ellipsis(Localizer.Format(link.end.name).Replace("Kerbin", "DSN"), 35);
                string value   = Lib.HumanReadablePerc(Math.Ceiling(signalStrength * 10000) / 10000, "F2");
                string tooltip = "Distance: " + Lib.HumanReadableRange((link.start.position - link.end.position).magnitude) +
                                 "\nMax Distance: " + Lib.HumanReadableRange(Math.Sqrt((link.start.antennaTransmit.power + link.start.antennaRelay.power) * link.end.antennaRelay.power));
                antennaInfo.control_path.Add(new string[] { name, value, tooltip });
            }
        }
Esempio n. 6
0
		// specifics support
		public Specifics Specs()
		{
			Specifics specs = new Specifics();
			specs.add("type", ((HarvestTypes)type).ToString());
			specs.add("resource", resource);
			if (min_abundance > double.Epsilon) specs.add("min abundance", Lib.HumanReadablePerc(min_abundance, "F2"));
			if (type == 2 && min_pressure > double.Epsilon) specs.add("min pressure", Lib.HumanReadablePressure(min_pressure));
			specs.add("extraction rate", Lib.HumanReadableRate(rate));
			if (ec_rate > double.Epsilon) specs.add("ec consumption", Lib.HumanReadableRate(ec_rate));
			return specs;
		}
Esempio n. 7
0
        public override string Info()
        {
            var exp             = ResearchAndDevelopment.GetExperiment(experiment.experiment_id);
            var sampleSize      = (exp.scienceCap * exp.dataScale);
            var recordedPercent = Lib.HumanReadablePerc(experiment.dataSampled / sampleSize);
            var eta             = experiment.data_rate < double.Epsilon || experiment.dataSampled >= sampleSize ? " done" : " T-" + Lib.HumanReadableDuration((sampleSize - experiment.dataSampled) / experiment.data_rate);

            return(!experiment.recording
                          ? "<color=red>" + Localizer.Format("#KERBALISM_Generic_DISABLED") + " </color>"
                          : experiment.issue.Length == 0 ? "<color=cyan>" + Lib.BuildString(recordedPercent, eta) + "</color>"
                          : Lib.BuildString("<color=yellow>", experiment.issue.ToLower(), "</color>"));
        }
Esempio n. 8
0
 public override string info()
 {
   bool opened = Lib.Proto.GetBool(ring, "opened");
   double speed = Lib.Proto.GetFloat(ring, "speed");
   if (!opened) return "<color=red>closed</color>";
   return Lib.BuildString
   (
     "<color=", speed > double.Epsilon ? "green" : "red", ">",
     "speed: ", Lib.HumanReadablePerc(speed),
     "</color>"
   );
 }
Esempio n. 9
0
		static void Render_crew(Panel p, List<ProtoCrewMember> crew)
		{
			// do nothing if there isn't a crew, or if there are no rules
			if (crew.Count == 0 || Profile.rules.Count == 0) return;

			// panel section
			p.AddSection("VITALS");

			// for each crew
			foreach (ProtoCrewMember kerbal in crew)
			{
				// get kerbal data from DB
				KerbalData kd = DB.Kerbal(kerbal.name);

				// analyze issues
				UInt32 health_severity = 0;
				UInt32 stress_severity = 0;

				// generate tooltip
				List<string> tooltips = new List<string>();
				foreach (Rule r in Profile.rules)
				{
					// get rule data
					RuleData rd = kd.Rule(r.name);

					// add to the tooltip
					tooltips.Add(Lib.BuildString("<b>", Lib.HumanReadablePerc(rd.problem / r.fatal_threshold), "</b>\t", Lib.SpacesOnCaps(r.name).ToLower()));

					// analyze issue
					if (rd.problem > r.danger_threshold)
					{
						if (!r.breakdown) health_severity = Math.Max(health_severity, 2);
						else stress_severity = Math.Max(stress_severity, 2);
					}
					else if (rd.problem > r.warning_threshold)
					{
						if (!r.breakdown) health_severity = Math.Max(health_severity, 1);
						else stress_severity = Math.Max(stress_severity, 1);
					}
				}
				string tooltip = Lib.BuildString("<align=left />", String.Join("\n", tooltips.ToArray()));

				// generate kerbal name
				string name = kerbal.name.ToLower().Replace(" kerman", string.Empty);

				// render selectable title
				p.AddContent(Lib.Ellipsis(name, Styles.ScaleStringLength(30)), kd.disabled ? "<color=#00ffff>HYBERNATED</color>" : string.Empty);
				p.AddIcon(health_severity == 0 ? Icons.health_white : health_severity == 1 ? Icons.health_yellow : Icons.health_red, tooltip);
				p.AddIcon(stress_severity == 0 ? Icons.brain_white : stress_severity == 1 ? Icons.brain_yellow : Icons.brain_red, tooltip);
			}
		}
Esempio n. 10
0
		void problem_poisoning(vessel_info info, ref List<Texture> icons, ref List<string> tooltips)
		{
			string poisoning_str = Lib.BuildString("CO2 level in internal atmosphere: <b>", Lib.HumanReadablePerc(info.poisoning), "</b>");
			if (info.poisoning >= 0.05)
			{
				icons.Add(Icons.recycle_red);
				tooltips.Add(poisoning_str);
			}
			else if (info.poisoning > 0.025)
			{
				icons.Add(Icons.recycle_yellow);
				tooltips.Add(poisoning_str);
			}
		}
Esempio n. 11
0
		void Problem_poisoning(Vessel_info info, ref List<Texture2D> icons, ref List<string> tooltips)
		{
			string poisoning_str = Lib.BuildString("CO2 level in internal atmosphere: <b>", Lib.HumanReadablePerc(info.poisoning), "</b>");
			if (info.poisoning >= Settings.PoisoningThreshold)
			{
				icons.Add(Icons.recycle_red);
				tooltips.Add(poisoning_str);
			}
			else if (info.poisoning > Settings.PoisoningThreshold / 1.25)
			{
				icons.Add(Icons.recycle_yellow);
				tooltips.Add(poisoning_str);
			}
		}
Esempio n. 12
0
        // create a particle mesh by fitting points on an implicit surface defined by a signed distance field
        public ParticleMesh(Func <Vector3, float> dist_func, Vector3 domain_hsize, Vector3 domain_offset, int particle_count, float quality)
        {
            // store stuff
            Vector3 p;
            float   D;

            // hard-limit on sample count, to avoid infinite sampling when the distance function is positive everywhere
            int sample_limit = particle_count * 1000;

            // divide once
            float thickness = 1.0f / quality;

            // preallocate position container
            points = new List <Vector3>(particle_count);

            // particle-fitting
            int samples = 0;
            int i       = 0;

            while (i < particle_count && samples < sample_limit)
            {
                // generate random position inside bounding volume
                p.x = Lib.FastRandomFloat() * domain_hsize.x + domain_offset.x;
                p.y = Lib.FastRandomFloat() * domain_hsize.y + domain_offset.y;
                p.z = Lib.FastRandomFloat() * domain_hsize.z + domain_offset.z;

                // calculate signed distance
                D = dist_func(p);

                if (D <= 0.0f)                 // if inside
                {
                    // this displays the exact radiation field border
                    if (D <= 0.0 && D > -thickness)
                    {
                        points.Add(p);
                        ++i;
                    }
                }

                // count samples
                ++samples;
            }

            // some feedback on the samples going above the limit
            if (i < particle_count)
            {
                Lib.Log("particle-fitting reached hard limit at " + Lib.HumanReadablePerc((double)i / (double)particle_count));
            }
        }
Esempio n. 13
0
  GUIContent indicator_ec(Vessel v)
  {
    resource_info ec = ResourceCache.Info(v, "ElectricCharge");

    GUIContent state = new GUIContent();
    state.tooltip = ec.capacity > 0.0 ? "EC: " + Lib.HumanReadablePerc(ec.level) : "";
    state.image = icon_battery_nominal;

    double low_threshold = 0.15;
    if (Kerbalism.ec_rule != null) low_threshold = Kerbalism.ec_rule.low_threshold;

    if (ec.level <= 0.005) state.image = icon_battery_danger;
    else if (ec.level <= low_threshold) state.image = icon_battery_warning;
    return state;
  }
Esempio n. 14
0
        void Problem_poisoning(VesselData vd, ref List <Texture2D> icons, ref List <string> tooltips)
        {
            string poisoning_str = Lib.BuildString(Local.Monitor_CO2level, " <b>", Lib.HumanReadablePerc(vd.Poisoning), "</b>");            //CO2 level in internal atmosphere:

            if (vd.Poisoning >= Settings.PoisoningThreshold)
            {
                icons.Add(Textures.recycle_red);
                tooltips.Add(poisoning_str);
            }
            else if (vd.Poisoning > Settings.PoisoningThreshold / 1.25)
            {
                icons.Add(Textures.recycle_yellow);
                tooltips.Add(poisoning_str);
            }
        }
Esempio n. 15
0
  void render_greenhouse(vessel_info vi)
  {
    // do nothing without greenhouses
    if (vi.greenhouses.Count == 0) return;

    // select a greenhouse
    var greenhouse = vi.greenhouses[greenhouse_index % vi.greenhouses.Count];

    // render it
    render_title("GREENHOUSE", ref greenhouse_index, vi.greenhouses.Count);
    render_content("lighting", Lib.HumanReadablePerc(greenhouse.lighting));
    render_content("growth", Lib.HumanReadablePerc(greenhouse.growth));
    render_content("harvest", Lib.HumanReadableDuration(greenhouse.growing > double.Epsilon ? (1.0 - greenhouse.growth) / greenhouse.growing : 0.0));
    render_space();
  }
Esempio n. 16
0
        static void Render_habitat(Panel p, Vessel v, Vessel_info vi)
        {
            // if habitat feature is disabled, do not show the panel
            if (!Features.Habitat)
            {
                return;
            }

            // if vessel is unmanned, do not show the panel
            if (vi.crew_count == 0)
            {
                return;
            }

            // render panel, add some content based on enabled features
            p.AddSection("HABITAT");
            if (Features.Poisoning)
            {
                p.AddContent("co2 level", Lib.Color(Lib.HumanReadablePerc(vi.poisoning, "F2"), vi.poisoning > Settings.PoisoningThreshold, "yellow"));
            }
            if (!v.isEVA)
            {
                if (Features.Humidity)
                {
                    p.AddContent("humidity", Lib.Color(Lib.HumanReadablePerc(vi.humidity, "F2"), vi.humidity > Settings.HumidityThreshold, "yellow"));
                }
                if (Features.Pressure)
                {
                    p.AddContent("pressure", Lib.HumanReadablePressure(vi.pressure * Sim.PressureAtSeaLevel()));
                }
                if (Features.Shielding)
                {
                    p.AddContent("shielding", Habitat.Shielding_to_string(vi.shielding));
                }
                if (Features.LivingSpace)
                {
                    p.AddContent("living space", Habitat.Living_space_to_string(vi.living_space));
                }
                if (Features.Comfort)
                {
                    p.AddContent("comfort", vi.comforts.Summary(), vi.comforts.Tooltip());
                }
                if (Features.Pressure)
                {
                    p.AddContent("EVA's available", vi.breathable ? "infinite" : Lib.HumanReadableInteger(vi.evas), vi.breathable ? "breathable atmosphere" : "approx (derived from stored N2)");
                }
            }
        }
Esempio n. 17
0
        public string tooltip()
        {
            const string yes = "<b><color=#00ff00>yes</color></b>";
            const string no  = "<b><color=#ff0000>no</color></b>";

            return(Lib.BuildString
                   (
                       "<align=left />",
                       "firm ground\t", firm_ground ? yes : no, "\n",
                       "exercise\t\t", exercise ? yes : no, "\n",
                       "not alone\t", not_alone ? yes : no, "\n",
                       "call home\t", call_home ? yes : no, "\n",
                       "panorama\t", panorama ? yes : no, "\n",
                       "<i>factor</i>\t\t", Lib.HumanReadablePerc(factor)
                   ));
        }
Esempio n. 18
0
        public override string Info()
        {
            bool   recording   = Lib.Proto.GetBool(proto, "recording");
            string issue       = Lib.Proto.GetString(proto, "issue");
            double dataSampled = Lib.Proto.GetDouble(proto, "dataSampled");
            double data_rate   = Lib.Proto.GetDouble(proto, "data_rate");

            var exp             = ResearchAndDevelopment.GetExperiment(prefab.experiment_id);
            var sampleSize      = (exp.scienceCap * exp.dataScale);
            var recordedPercent = Lib.HumanReadablePerc(dataSampled / sampleSize);
            var eta             = data_rate < double.Epsilon || dataSampled >= sampleSize ? " done" : " T-" + Lib.HumanReadableDuration((sampleSize - dataSampled) / data_rate);

            return(!recording
                          ? "<color=red>" + Localizer.Format("#KERBALISM_Generic_STOPPED") + " </color>"
                          : issue.Length == 0 ? "<color=cyan>" + Lib.BuildString(recordedPercent, eta) + "</color>"
                          : Lib.BuildString("<color=yellow>", issue.ToLower(), "</color>"));
        }
Esempio n. 19
0
        public string Tooltip()
        {
            string yes = Lib.BuildString("<b><color=#00ff00>", Local.Generic_YES, " </color></b>");
            string no  = Lib.BuildString("<b><color=#ffaa00>", Local.Generic_NO, " </color></b>");

            return(Lib.BuildString
                   (
                       "<align=left />",
                       String.Format("{0,-14}\t{1}\n", Local.Comfort_firmground, firm_ground ? yes : no),
                       String.Format("{0,-14}\t{1}\n", Local.Comfort_exercise, exercise ? yes : no),
                       String.Format("{0,-14}\t{1}\n", Local.Comfort_notalone, not_alone ? yes : no),
                       String.Format("{0,-14}\t{1}\n", Local.Comfort_callhome, call_home ? yes : no),
                       String.Format("{0,-14}\t{1}\n", Local.Comfort_panorama, panorama ? yes : no),
                       String.Format("{0,-14}\t{1}\n", Local.Comfort_plants, plants ? yes : no),
                       String.Format("<i>{0,-14}</i>\t{1}", Local.Comfort_factor, Lib.HumanReadablePerc(factor))
                   ));
        }
Esempio n. 20
0
        public override string Info()
        {
            var state = Experiment.GetState(experiment.scienceValue, experiment.issue, experiment.recording, experiment.forcedRun);

            if (state == Experiment.State.WAITING)
            {
                return("waiting...");
            }
            var exp             = Science.Experiment(experiment.experiment_id);
            var recordedPercent = Lib.HumanReadablePerc(experiment.dataSampled / exp.max_amount);
            var eta             = experiment.data_rate < double.Epsilon || Experiment.Done(exp, experiment.dataSampled) ? " done" : " " + Lib.HumanReadableCountdown((exp.max_amount - experiment.dataSampled) / experiment.data_rate);

            return(!experiment.recording
                          ? "<color=red>" + Localizer.Format("#KERBALISM_Generic_DISABLED") + " </color>"
                          : experiment.issue.Length == 0 ? "<color=cyan>" + Lib.BuildString(recordedPercent, eta) + "</color>"
                          : Lib.BuildString("<color=yellow>", experiment.issue.ToLower(), "</color>"));
        }
Esempio n. 21
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("<align=left /><b>name\t\tlevel\tduration</b>");
                        }

                        tooltips.Add(Lib.BuildString
                                     (
                                         res.level <= 0.005 ? "<color=#ff0000>" : res.level <= supply.low_threshold ? "<color=#ffff00>" : "<color=#cccccc>",
                                         supply.resource,
                                         supply.resource != "Ammonia" ? "\t\t" : "\t", //< hack: make ammonia fit damn it
                                         Lib.HumanReadablePerc(res.level), "\t",
                                         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);
                    }
                }
            }

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

            p.SetIcon(image, string.Join("\n", tooltips.ToArray()));
        }
Esempio n. 22
0
  static void render_habitat(Panel p, Vessel v, vessel_info vi)
  {
    // if habitat feature is disabled, do not show the panel
    if (!Features.Habitat) return;

    // if vessel is unmanned, do not show the panel
    if (vi.crew_count == 0) return;

    // render panel, add some content based on enabled features
    p.section("HABITAT");
    if (Features.Poisoning) p.content("co2 level", Lib.Color(Lib.HumanReadablePerc(vi.poisoning, "F2"), vi.poisoning > Settings.PoisoningThreshold, "yellow"));
    if (!v.isEVA)
    {
      if (Features.Pressure) p.content("pressure", Lib.HumanReadablePressure(vi.pressure * Sim.PressureAtSeaLevel()));
      if (Features.Shielding) p.content("shielding", Habitat.shielding_to_string(vi.shielding));
      if (Features.LivingSpace) p.content("living space", Habitat.living_space_to_string(vi.living_space));
      if (Features.Comfort) p.content("comfort", vi.comforts.summary(), vi.comforts.tooltip());
    }
  }
Esempio n. 23
0
  void indicator_ec(Panel p, Vessel v)
  {
    Texture image;
    string tooltip;

    resource_info ec = ResourceCache.Info(v, "ElectricCharge");

    tooltip = ec.capacity > 0.0 ? "EC: " + Lib.HumanReadablePerc(ec.level) : "";
    image = Icons.battery_white;

    Supply supply = Profile.supplies.Find(k => k.resource == "ElectricCharge");
    double low_threshold = supply != null ? supply.low_threshold : 0.15;

    if (ec.level <= 0.005) image = Icons.battery_red;
    else if (ec.level <= low_threshold) image = Icons.battery_yellow;


    p.icon(image, tooltip);
  }
Esempio n. 24
0
        static void Render_greenhouse(Panel p, VesselData vd)
        {
            // do nothing without greenhouses
            if (vd.Greenhouses.Count == 0)
            {
                return;
            }

            // panel section
            p.AddSection(Local.TELEMETRY_GREENHOUSE);            //"GREENHOUSE"

            // for each greenhouse
            for (int i = 0; i < vd.Greenhouses.Count; ++i)
            {
                var greenhouse = vd.Greenhouses[i];

                // state string
                string state = greenhouse.issue.Length > 0
                                  ? Lib.Color(greenhouse.issue, Lib.Kolor.Yellow)
                                  : greenhouse.growth >= 0.99
                                  ? Lib.Color(Local.TELEMETRY_readytoharvest, Lib.Kolor.Green) //"ready to harvest"
                                  : Local.TELEMETRY_growing;                                   //"growing"

                // tooltip with summary
                string tooltip = greenhouse.growth < 0.99 ? Lib.BuildString
                                 (
                    "<align=left />",
                    Local.TELEMETRY_timetoharvest, "\t<b>", Lib.HumanReadableDuration(greenhouse.tta), "</b>\n",        //"time to harvest"
                    Local.TELEMETRY_growth, "\t\t<b>", Lib.HumanReadablePerc(greenhouse.growth), "</b>\n",              //"growth"
                    Local.TELEMETRY_naturallighting, "\t<b>", Lib.HumanReadableFlux(greenhouse.natural), "</b>\n",      //"natural lighting"
                    Local.TELEMETRY_artificiallighting, "\t<b>", Lib.HumanReadableFlux(greenhouse.artificial), "</b>"   //"artificial lighting"
                                 ) : string.Empty;

                // render it
                p.AddContent(Lib.BuildString(Local.TELEMETRY_crop, " #", (i + 1).ToString()), state, tooltip);                //"crop"

                // issues too, why not
                p.AddRightIcon(greenhouse.issue.Length == 0 ? Textures.plant_white : Textures.plant_yellow, tooltip);
            }
        }
Esempio n. 25
0
        static void Render_greenhouse(Panel p, Vessel_info vi)
        {
            // do nothing without greenhouses
            if (vi.greenhouses.Count == 0)
            {
                return;
            }

            // panel section
            p.AddSection("GREENHOUSE");

            // for each greenhouse
            for (int i = 0; i < vi.greenhouses.Count; ++i)
            {
                var greenhouse = vi.greenhouses[i];

                // state string
                string state = greenhouse.issue.Length > 0
                                  ? Lib.BuildString("<color=yellow>", greenhouse.issue, "</color>")
                                  : greenhouse.growth >= 0.99
                                  ? "<color=green>ready to harvest</color>"
                                  : "growing";

                // tooltip with summary
                string tooltip = greenhouse.growth < 0.99 ? Lib.BuildString
                                 (
                    "<align=left />",
                    "time to harvest\t<b>", Lib.HumanReadableDuration(greenhouse.tta), "</b>\n",
                    "growth\t\t<b>", Lib.HumanReadablePerc(greenhouse.growth), "</b>\n",
                    "natural lighting\t<b>", Lib.HumanReadableFlux(greenhouse.natural), "</b>\n",
                    "artificial lighting\t<b>", Lib.HumanReadableFlux(greenhouse.artificial), "</b>"
                                 ) : string.Empty;

                // render it
                p.AddContent(Lib.BuildString("crop #", (i + 1).ToString()), state, tooltip);

                // issues too, why not
                p.AddIcon(greenhouse.issue.Length == 0 ? Icons.plant_white : Icons.plant_yellow, tooltip);
            }
        }
Esempio n. 26
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            specs.Add(Local.Harvester_info1, ((HarvestTypes)type).ToString()); //"type"
            specs.Add(Local.Harvester_info2, resource);                        //"resource"
            if (min_abundance > double.Epsilon)
            {
                specs.Add(Local.Harvester_info3, Lib.HumanReadablePerc(min_abundance, "F2"));                                            //"min abundance"
            }
            if (type == 2 && min_pressure > double.Epsilon)
            {
                specs.Add(Local.Harvester_info4, Lib.HumanReadablePressure(min_pressure)); //"min pressure"
            }
            specs.Add(Local.Harvester_info5, Lib.HumanReadableRate(rate));                 //"extraction rate"
            specs.Add(Local.Harvester_info6, Lib.HumanReadablePerc(abundance_rate, "F2")); //"at abundance"
            if (ec_rate > double.Epsilon)
            {
                specs.Add(Local.Harvester_info7, Lib.HumanReadableRate(ec_rate));                                      //"ec consumption"
            }
            return(specs);
        }
Esempio n. 27
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)
    {
      var supplies = Profile.supplies.FindAll(k => k.resource != "ElectricCharge");
      foreach(Supply supply in supplies)
      {
        resource_info res = ResourceCache.Info(v, supply.resource);
        if (res.capacity > double.Epsilon)
        {
          double depletion = res.Depletion(vi.crew_count);
          string deplete_str = depletion <= double.Epsilon
            ? ", depleted"
            : double.IsNaN(depletion)
            ? ""
            : Lib.BuildString(", deplete in <b>", Lib.HumanReadableDuration(depletion), "</b>");
          tooltips.Add(Lib.BuildString(supply.resource, ": <b>", Lib.HumanReadablePerc(res.level), "</b>", deplete_str));

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

    Texture image = Icons.box_white;
    switch(max_severity)
    {
      case 0: image = Icons.box_white; break;
      case 1: image = Icons.box_yellow; break;
      case 2: image = Icons.box_red;  break;
    }
    string tooltip = string.Join("\n", tooltips.ToArray());

    p.icon(image, tooltip);
  }
Esempio n. 28
0
        public void Update()
        {
            // in editor, merely update ui button label
            if (Lib.IsEditor())
            {
                Events["Toggle"].guiName = Lib.StatusToggle(title, running ? "running" : "stopped");
            }

            // if in flight, and the stock planet resource system is online
            if (Lib.IsFlight() && ResourceMap.Instance != null)
            {
                // sample abundance
                double abundance = SampleAbundance();

                // determine if resource can be extracted
                issue = DetectIssue(abundance);

                // TODO: Change Review
                double ecLeft = ResourceCache.Info(part.vessel, "ElectricCharge").amount;

                // update ui
                Events["Toggle"].guiActive    = deployed && ecLeft > double.Epsilon;
                Fields["Abundance"].guiActive = deployed && ecLeft > double.Epsilon;
                if (deployed)
                {
                    string status = !running
            ? "stopped"
            : issue.Length == 0
            ? "running"
            : Lib.BuildString("<color=yellow>", issue, "</color>");

                    Events["Toggle"].guiName = Lib.StatusToggle(title, status);
                    Abundance = abundance > double.Epsilon ? Lib.HumanReadablePerc(abundance, "F2") : "none";
                }
            }
        }
Esempio n. 29
0
        void Problem_humidity(Vessel_info info, ref List <Texture2D> icons, ref List <string> tooltips)
        {
            string humidity_str = Lib.BuildString("Humidity level in internal atmosphere: <b>", Lib.HumanReadablePerc(info.humidity), "</b>");

            if (info.humidity >= Settings.HumidityThreshold)
            {
                icons.Add(Icons.recycle_red);
                tooltips.Add(humidity_str);
            }
            else if (info.humidity > Settings.HumidityThreshold / 1.25)
            {
                icons.Add(Icons.recycle_yellow);
                tooltips.Add(humidity_str);
            }
        }
Esempio n. 30
0
        public static void Body_info(this Panel p)
        {
            // only show in mapview
            if (!MapView.MapIsEnabled)
            {
                return;
            }

            // only show if there is a selected body and that body is not the sun
            CelestialBody body = Lib.MapViewSelectedBody();

            if (body == null || (Lib.IsSun(body) && !Features.Radiation))
            {
                return;
            }

            // calculate radiation at body surface
            double surfaceRadiation = Radiation.ComputeSurface(body, Sim.GammaTransparency(body, 0.0));

            // for all bodies except sun(s)
            if (!Lib.IsSun(body))
            {
                CelestialBody mainSun;
                Vector3d      sun_dir;
                double        sun_dist;
                double        solar_flux = Sim.SolarFluxAtBody(body, false, out mainSun, out sun_dir, out sun_dist);
                solar_flux *= Sim.AtmosphereFactor(body, 0.7071);

                // calculate simulation values
                double albedo_flux = Sim.AlbedoFlux(body, body.position + sun_dir * body.Radius);
                double body_flux   = Sim.BodyFlux(body, 0.0);
                double total_flux  = solar_flux + albedo_flux + body_flux + Sim.BackgroundFlux();
                double temperature = body.atmosphere ? body.GetTemperature(0.0) : Sim.BlackBodyTemperature(total_flux);

                // calculate night-side temperature
                double total_flux_min  = Sim.AlbedoFlux(body, body.position - sun_dir * body.Radius) + body_flux + Sim.BackgroundFlux();
                double temperature_min = Sim.BlackBodyTemperature(total_flux_min);

                // surface panel
                string temperature_str = body.atmosphere
                                  ? Lib.HumanReadableTemp(temperature)
                                  : Lib.BuildString(Lib.HumanReadableTemp(temperature_min), " / ", Lib.HumanReadableTemp(temperature));
                p.AddSection(Local.BodyInfo_SURFACE);                                      //"SURFACE"
                p.AddContent(Local.BodyInfo_temperature, temperature_str);                 //"temperature"
                p.AddContent(Local.BodyInfo_solarflux, Lib.HumanReadableFlux(solar_flux)); //"solar flux"
                if (Features.Radiation)
                {
                    p.AddContent(Local.BodyInfo_radiation, Lib.HumanReadableRadiation(surfaceRadiation));                                    //"radiation"
                }
                // atmosphere panel
                if (body.atmosphere)
                {
                    p.AddSection(Local.BodyInfo_ATMOSPHERE);                                                                                      //"ATMOSPHERE"
                    p.AddContent(Local.BodyInfo_breathable, Sim.Breathable(body) ? Local.BodyInfo_breathable_yes : Local.BodyInfo_breathable_no); //"breathable""yes""no"
                    p.AddContent(Local.BodyInfo_lightabsorption, Lib.HumanReadablePerc(1.0 - Sim.AtmosphereFactor(body, 0.7071)));                //"light absorption"
                    if (Features.Radiation)
                    {
                        p.AddContent(Local.BodyInfo_gammaabsorption, Lib.HumanReadablePerc(1.0 - Sim.GammaTransparency(body, 0.0)));                                        //"gamma absorption"
                    }
                }
            }

            // radiation panel
            if (Features.Radiation)
            {
                p.AddSection(Local.BodyInfo_RADIATION);                //"RADIATION"

                string inner, outer, pause;
                double activity, cycle;
                RadiationLevels(body, out inner, out outer, out pause, out activity, out cycle);

                if (Storm.sun_observation_quality > 0.5 && activity > -1)
                {
                    string title = Local.BodyInfo_solaractivity;                    //"solar activity"

                    if (Storm.sun_observation_quality > 0.7)
                    {
                        title = Lib.BuildString(title, ": ", Lib.Color(Local.BodyInfo_stormcycle.Format(Lib.HumanReadableDuration(cycle)), Lib.Kolor.LightGrey));                        // <<1>> cycle
                    }

                    p.AddContent(title, Lib.HumanReadablePerc(activity));
                }

                if (Storm.sun_observation_quality > 0.8)
                {
                    p.AddContent(Local.BodyInfo_radiationonsurface, Lib.HumanReadableRadiation(surfaceRadiation));                    //"radiation on surface:"
                }

                p.AddContent(Lib.BuildString(Local.BodyInfo_innerbelt, " ", Lib.Color(inner, Lib.Kolor.LightGrey)),                                                                                           //"inner belt: "
                             Radiation.show_inner ? Lib.Color(Local.BodyInfo_show, Lib.Kolor.Green) : Lib.Color(Local.BodyInfo_hide, Lib.Kolor.Red), string.Empty, () => p.Toggle(ref Radiation.show_inner)); //"show""hide"
                p.AddContent(Lib.BuildString(Local.BodyInfo_outerbelt, " ", Lib.Color(outer, Lib.Kolor.LightGrey)),                                                                                           //"outer belt: "
                             Radiation.show_outer ? Lib.Color(Local.BodyInfo_show, Lib.Kolor.Green) : Lib.Color(Local.BodyInfo_hide, Lib.Kolor.Red), string.Empty, () => p.Toggle(ref Radiation.show_outer)); //"show""hide"
                p.AddContent(Lib.BuildString(Local.BodyInfo_magnetopause, " ", Lib.Color(pause, Lib.Kolor.LightGrey)),                                                                                        //"magnetopause: "
                             Radiation.show_pause ? Lib.Color(Local.BodyInfo_show, Lib.Kolor.Green) : Lib.Color(Local.BodyInfo_hide, Lib.Kolor.Red), string.Empty, () => p.Toggle(ref Radiation.show_pause)); //"show""hide"
            }

            // explain the user how to toggle the BodyInfo window
            p.AddContent(string.Empty);
            p.AddContent("<i>" + Local.BodyInfo_BodyInfoToggleHelp.Format("<b>B</b>") + "</i>");            //"Press <<1>> to open this window again"

            // set metadata
            p.Title(Lib.BuildString(Lib.Ellipsis(body.bodyName, Styles.ScaleStringLength(24)), " ", Lib.Color(Local.BodyInfo_title, Lib.Kolor.LightGrey)));            //"BODY INFO"
        }