// specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            specs.add("Havest size", Lib.HumanReadableAmount(crop_size, " " + crop_resource));
            specs.add("Harvest time", Lib.HumanReadableDuration(1.0 / crop_rate));
            specs.add("Lighting tolerance", Lib.HumanReadableFlux(light_tolerance));
            if (pressure_tolerance > double.Epsilon)
            {
                specs.add("Pressure tolerance", Lib.HumanReadablePressure(Sim.PressureAtSeaLevel() * pressure_tolerance));
            }
            if (radiation_tolerance > double.Epsilon)
            {
                specs.add("Radiation tolerance", Lib.HumanReadableRadiation(radiation_tolerance));
            }
            specs.add("Lamps EC rate", Lib.HumanReadableRate(ec_rate));
            specs.add(string.Empty);
            specs.add("<color=#00ffff>Required resources</color>");
            foreach (ModuleResource input in resHandler.inputResources)
            {
                specs.add(input.name, Lib.BuildString("<color=#ff0000>", Lib.HumanReadableRate(input.rate), "</color>"));
            }
            specs.add(string.Empty);
            specs.add("<color=#00ffff>By-products</color>");
            foreach (ModuleResource output in resHandler.outputResources)
            {
                specs.add(output.name, Lib.BuildString("<color=#00ff00>", Lib.HumanReadableRate(output.rate), "</color>"));
            }
            return(specs);
        }
Exemple #2
0
 GUIContent indicator_supplies(Vessel v, vessel_info vi)
 {
   GUIContent state = new GUIContent();
   List<string> tooltips = new List<string>();
   uint max_severity = 0;
   if (Lib.CrewCount(v) > 0)
   {
     foreach(Rule r in Kerbalism.supply_rules)
     {
       var vmon = vi.vmon[r.name];
       string deplete_str = vmon.depletion <= double.Epsilon
         ? ", depleted"
         : double.IsNaN(vmon.depletion)
         ? ""
         : ", deplete in <b>" + Lib.HumanReadableDuration(vmon.depletion) + "</b>";
       tooltips.Add(r.resource_name + ": <b>" + (vmon.level * 100.0).ToString("F0") + "%</b>" + deplete_str);
       uint severity = vmon.level <= double.Epsilon ? 2u : vmon.level <= r.low_threshold ? 1u : 0;
       max_severity = Math.Max(max_severity, severity);
     }
   }
   switch(max_severity)
   {
     case 0: state.image = icon_supplies_nominal; break;
     case 1: state.image = icon_supplies_warning; break;
     case 2: state.image = icon_supplies_danger; break;
   }
   state.tooltip = string.Join("\n", tooltips.ToArray());
   return state;
 }
Exemple #3
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            if (redundancy.Length > 0)
            {
                specs.Add("Redundancy", redundancy);
            }
            specs.Add("Repair", new CrewSpecs(repair).Info());
            specs.Add(string.Empty);
            specs.Add("<color=#00ffff>Standard quality</color>");
            specs.Add("MTBF", Lib.HumanReadableDuration(mtbf));
            specs.Add(string.Empty);
            specs.Add("<color=#00ffff>High quality</color>");
            specs.Add("MTBF", Lib.HumanReadableDuration(mtbf * Settings.QualityScale));
            if (extra_cost > double.Epsilon)
            {
                specs.Add("Extra cost", Lib.HumanReadableCost(extra_cost * part.partInfo.cost));
            }
            if (extra_mass > double.Epsilon)
            {
                specs.Add("Extra mass", Lib.HumanReadableMass(extra_mass * part.partInfo.partPrefab.mass));
            }
            return(specs);
        }
Exemple #4
0
 // editor/r&d info
 public override string GetInfo()
 {
   return "Grow food in space.\n\n"
        + "- Harvest size: <b>" + harvest_size + " Food</b>\n"
        + "- Harvest time: <b>" + Lib.HumanReadableDuration(1.0 / growth_rate) + "</b>\n"
        + "- Lamps EC rate: <b> " + Lib.HumanReadableRate(ec_rate) + "</b>";
 }
Exemple #5
0
 GUIContent indicator_supplies(Vessel v, vessel_info vi)
 {
   GUIContent state = new GUIContent();
   List<string> tooltips = new List<string>();
   uint max_severity = 0;
   if (vi.crew_count > 0)
   {
     foreach(Rule r in Kerbalism.supply_rules)
     {
       resource_info res = ResourceCache.Info(v, r.resource_name);
       if (res.capacity > double.Epsilon)
       {
         double depletion = r.Depletion(v, res);
         string deplete_str = depletion <= double.Epsilon
           ? ", depleted"
           : double.IsNaN(depletion)
           ? ""
           : Lib.BuildString(", deplete in <b>", Lib.HumanReadableDuration(depletion), "</b>");
         tooltips.Add(Lib.BuildString(r.resource_name, ": <b>", Lib.HumanReadablePerc(res.level), "</b>", deplete_str));
         uint severity = res.level <= 0.005 ? 2u : res.level <= r.low_threshold ? 1u : 0;
         max_severity = Math.Max(max_severity, severity);
       }
     }
   }
   switch(max_severity)
   {
     case 0: state.image = icon_supplies_nominal; break;
     case 1: state.image = icon_supplies_warning; break;
     case 2: state.image = icon_supplies_danger;  break;
   }
   state.tooltip = string.Join("\n", tooltips.ToArray());
   return state;
 }
Exemple #6
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs   = new Specifics();
            Process   process = Profile.processes.Find(k => k.modifiers.Contains(resource));

            if (process != null)
            {
                foreach (KeyValuePair <string, double> pair in process.inputs)
                {
                    if (!process.modifiers.Contains(pair.Key))
                    {
                        specs.Add(pair.Key, Lib.BuildString("<color=#ffaa00>", Lib.HumanReadableRate(pair.Value * capacity), "</color>"));
                    }
                    else
                    {
                        specs.Add(Local.ProcessController_info1, Lib.HumanReadableDuration(0.5 / pair.Value));                        //"Half-life"
                    }
                }
                foreach (KeyValuePair <string, double> pair in process.outputs)
                {
                    specs.Add(pair.Key, Lib.BuildString("<color=#00ff00>", Lib.HumanReadableRate(pair.Value * capacity), "</color>"));
                }
            }
            return(specs);
        }
Exemple #7
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;
			}
		}
Exemple #8
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);
        }
        void Indicator_EC(Panel p, Vessel v, Vessel_Info vi)
        {
            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>"
                             );

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

            p.SetIcon(image, tooltip);
        }
Exemple #10
0
  void render_environment(environment_data env)
  {
    bool in_atmosphere = env.landed && env.body.atmosphere;
    string temperature_str = in_atmosphere
      ? Lib.HumanReadableTemp(env.atmo_temp)
      : Lib.HumanReadableTemp(env.light_temp) + "</b> / <b>"
      + Lib.HumanReadableTemp(env.shadow_temp);
    string temperature_tooltip = in_atmosphere
      ? "atmospheric"
      : "sunlight / shadow\n"
      + "solar: <b>" + Lib.HumanReadableTemp(env.sun_temp) + "</b>\n"
      + "albedo (sunlight): <b>" + Lib.HumanReadableTemp(env.body_temp) + "</b>\n"
      + "albedo (shadow): <b>" + Lib.HumanReadableTemp(env.body_back_temp) + "</b>\n"
      + "background: <b>" + Lib.HumanReadableTemp(env.background_temp) + "</b>";
    string atmosphere_tooltip = in_atmosphere
      ? "light absorption: <b>" + ((1.0 - env.atmo_factor) * 100.0).ToString("F0") + "%</b>\n"
      + "pressure: <b>" + env.body.atmospherePressureSeaLevel.ToString("F0") + " kPa</b>\n"
      + "breathable: <b>" + (env.body.atmosphereContainsOxygen ? "yes" : "no") + "</b>"
      : "";
    string shadowtime_str = Lib.HumanReadableDuration(env.shadow_period) + " (" + (env.shadow_time * 100.0).ToString("F0") + "%)";

    render_title("ENVIRONMENT");
    render_content("temperature", temperature_str, temperature_tooltip);
    render_content("temp diff", env.temp_diff.ToString("F0") + "K", "average difference between\nexternal and survival temperature");
    render_content("inside atmosphere", in_atmosphere ? "yes" : "no", atmosphere_tooltip);
    render_content("shadow time", shadowtime_str);
    render_space();
  }
Exemple #11
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            specs.Add("Harvest size", Lib.HumanReadableAmount(crop_size, " " + crop_resource));
            specs.Add("Harvest time", Lib.HumanReadableDuration(1.0 / crop_rate));
            specs.Add("Lighting tolerance", Lib.HumanReadableFlux(light_tolerance));
            if (pressure_tolerance > double.Epsilon)
            {
                specs.Add("Pressure tolerance", Lib.HumanReadablePressure(Sim.PressureAtSeaLevel() * pressure_tolerance));
            }
            if (radiation_tolerance > double.Epsilon)
            {
                specs.Add("Radiation tolerance", Lib.HumanReadableRadiation(radiation_tolerance));
            }
            specs.Add("Lamps EC rate", Lib.HumanReadableRate(ec_rate));
            specs.Add(string.Empty);
            specs.Add("<color=#00ffff>Required resources</color>");

            // do we have combined WasteAtmosphere and CO2
            Set_WACO2();
            bool dis_WACO2 = false;

            foreach (ModuleResource input in resHandler.inputResources)
            {
                // combine WasteAtmosphere and CO2 if both exist
                if (WACO2 && (input.name == "WasteAtmosphere" || input.name == "CarbonDioxide"))
                {
                    if (dis_WACO2)
                    {
                        continue;
                    }
                    ModuleResource sec;
                    if (input.name == "WasteAtmosphere")
                    {
                        sec = resHandler.inputResources.Find(x => x.name.Contains("CarbonDioxide"));
                    }
                    else
                    {
                        sec = resHandler.inputResources.Find(x => x.name.Contains("WasteAtmosphere"));
                    }
                    specs.Add("CarbonDioxide", Lib.BuildString("<color=#ffaa00>", Lib.HumanReadableRate(input.rate + sec.rate), "</color>"));
                    specs.Add("Crops can also use the CO2 in the atmosphere without a scrubber.");
                    dis_WACO2 = true;
                }
                else
                {
                    specs.Add(input.name, Lib.BuildString("<color=#ffaa00>", Lib.HumanReadableRate(input.rate), "</color>"));
                }
            }
            specs.Add(string.Empty);
            specs.Add("<color=#00ffff>By-products</color>");
            foreach (ModuleResource output in resHandler.outputResources)
            {
                specs.Add(output.name, Lib.BuildString("<color=#00ff00>", Lib.HumanReadableRate(output.rate), "</color>"));
            }
            return(specs);
        }
Exemple #12
0
        // specifics support
        public Specifics Specs()
        {
            if (exp == null)
            {
                exp = ResearchAndDevelopment.GetExperiment(experiment_id);
            }

            var specs = new Specifics();

            specs.Add(Lib.BuildString("<b>", ResearchAndDevelopment.GetExperiment(experiment_id).experimentTitle, "</b>"));

            if (!string.IsNullOrEmpty(experiment_desc))
            {
                specs.Add(Lib.BuildString("<i>", experiment_desc, "</i>"));
            }
            specs.Add(string.Empty);

            double expSize = exp.scienceCap * exp.dataScale;

            if (sample_mass < float.Epsilon)
            {
                specs.Add("Data", Lib.HumanReadableDataSize(expSize));
                specs.Add("Data rate", Lib.HumanReadableDataRate(data_rate));
                specs.Add("Duration", Lib.HumanReadableDuration(expSize / data_rate));
            }
            else
            {
                specs.Add("Sample size", Lib.HumanReadableSampleSize(expSize));
                specs.Add("Sample mass", Lib.HumanReadableMass(sample_mass));
                specs.Add("Duration", Lib.HumanReadableDuration(expSize / data_rate));
            }

            specs.Add("EC required", Lib.HumanReadableRate(ec_rate));
            if (crew_operate.Length > 0)
            {
                specs.Add("Opration", new CrewSpecs(crew_operate).Info());
            }
            if (crew_reset.Length > 0)
            {
                specs.Add("Reset", new CrewSpecs(crew_reset).Info());
            }
            if (crew_prepare.Length > 0)
            {
                specs.Add("Preparation", new CrewSpecs(crew_prepare).Info());
            }

            if (!string.IsNullOrEmpty(requires))
            {
                specs.Add(string.Empty);
                specs.Add("<color=#00ffff>Requirements:</color>", string.Empty);
                var tokens = Lib.Tokenize(requires, ',');
                foreach (string s in tokens)
                {
                    specs.Add(Lib.BuildString("• <b>", Science.RequirementText(s), "</b>"));
                }
            }
            return(specs);
        }
Exemple #13
0
        public static void Update(Vessel v, Vessel_Info vi, VesselData vd, double elapsed_s)
        {
            // do nothing if storms are disabled
            if (!Features.SpaceWeather)
            {
                return;
            }

            // only consider vessels in interplanetary space
            if (v.mainBody.flightGlobalsIndex != 0)
            {
                return;
            }

            // skip unmanned vessels
            if (vi.crew_count == 0)
            {
                return;
            }

            // generate storm time if necessary
            if (vd.storm_time <= double.Epsilon)
            {
                vd.storm_time = Settings.StormMinTime + (Settings.StormMaxTime - Settings.StormMinTime) * Lib.RandomDouble();
            }

            // accumulate age
            vd.storm_age += elapsed_s * Storm_Frequency(vi.sun_dist);

            // if storm is over
            if (vd.storm_age > vd.storm_time && vd.storm_state == 2)
            {
                vd.storm_age   = 0.0;
                vd.storm_time  = 0.0;
                vd.storm_state = 0;

                // send message
                Message.Post(Severity.relax, Lib.BuildString("The solar storm around <b>", v.vesselName, "</b> is over"));
            }
            // if storm is in progress
            else if (vd.storm_age > vd.storm_time - Settings.StormDuration && vd.storm_state == 1)
            {
                vd.storm_state = 2;

                // send message
                Message.Post(Severity.danger, Lib.BuildString("The coronal mass ejection hit <b>", v.vesselName, "</b>"),
                             Lib.BuildString("Storm duration: ", Lib.HumanReadableDuration(TimeLeftCME(vd.storm_time, vd.storm_age))));
            }
            // if storm is incoming
            else if (vd.storm_age > vd.storm_time - Settings.StormDuration - Time_to_Impact(vi.sun_dist) && vd.storm_state == 0)
            {
                vd.storm_state = 1;

                // send message
                Message.Post(Severity.warning, Lib.BuildString("Our observatories report a coronal mass ejection directed toward <b>", v.vesselName, "</b>"),
                             Lib.BuildString("Time to impact: ", Lib.HumanReadableDuration(TimeBeforeCME(vd.storm_time, vd.storm_age))));
            }
        }
Exemple #14
0
        public static void Update(Vessel v, VesselData vd, double elapsed_s)
        {
            // do nothing if storms are disabled
            if (!Features.SpaceWeather)
            {
                return;
            }

            // only consider vessels in interplanetary space
            if (!Lib.IsSun(v.mainBody))
            {
                return;
            }

            // disregard EVAs
            if (v.isEVA)
            {
                return;
            }

            var bd = vd.stormData;

            CreateStorm(bd, v.mainBody, vd.EnvMainSun.Distance);

            if (vd.cfg_storm)
            {
                switch (bd.storm_state)
                {
                case 0:     // no storm
                    if (bd.msg_storm == 2)
                    {
                        // send message
                        Message.Post(Severity.relax, Local.Storm_msg4.Format("<b>" + v.vesselName + "</b>")); //Lib.BuildString("The solar storm around <<1>> is over")
                        vd.msg_signal = false;                                                                // used to avoid sending 'signal is back' messages en-masse after the storm is over
                    }
                    break;

                case 2:     // storm in progress
                    if (bd.msg_storm < 2)
                    {
                        Message.Post(Severity.danger, Local.Storm_msg5.Format("<b>", v.vesselName, "</b>"),                                //Lib.BuildString("The coronal mass ejection hit <<1>>)
                                     Lib.BuildString(Local.Storm_msg1text, " ", Lib.HumanReadableDuration(bd.displayed_duration)));        //"Storm duration:"
                    }
                    break;

                case 1:     // storm incoming
                    if (bd.msg_storm < 1 && bd.display_warning)
                    {
                        var tti = bd.storm_time - Planetarium.GetUniversalTime();
                        Message.Post(Severity.warning, Local.Storm_msg6.Format("<b>" + v.vesselName + "</b>"),                              //Lib.BuildString("Our observatories report a coronal mass ejection directed toward <<1>>)
                                     Lib.BuildString(Local.Storm_msg2text, " ", Lib.HumanReadableDuration(tti)));                           //"Time to impact:
                    }
                    break;
                }
            }
            bd.msg_storm = bd.storm_state;
        }
Exemple #15
0
 void render_qol(qol_data qol)
 {
   render_title("QUALITY OF LIFE");
   render_content("living space", QualityOfLife.LivingSpaceToString(qol.living_space));
   render_content("entertainment", QualityOfLife.EntertainmentToString(qol.entertainment));
   render_content("other factors", qol.factors);
   render_content("time to instability", Lib.HumanReadableDuration(qol.time_to_instability));
   render_space();
 }
Exemple #16
0
 void render_food(food_data food)
 {
   render_title("FOOD");
   render_content("storage", Lib.ValueOrNone(food.storage));
   render_content("consumed", Lib.HumanReadableRate(food.consumed));
   render_content("cultivated", Lib.HumanReadableRate(food.cultivated), food.cultivated_tooltip);
   render_content("life expectancy", Lib.HumanReadableDuration(food.life_expectancy));
   render_space();
 }
Exemple #17
0
 // editor/r&d info
 public override string GetInfo()
 {
   return Lib.BuildString
   (
       Lib.Specifics("Grow food in space."),
       Lib.Specifics(true, "Harvest size", Lib.BuildString(harvest_size.ToString("F0"), " ", resource_name)),
       Lib.Specifics(true, "Harvest time", Lib.HumanReadableDuration(1.0 / growth_rate)),
       Lib.Specifics(true, "Lamps EC rate", Lib.HumanReadableRate(ec_rate))
   );
 }
Exemple #18
0
  void render_oxygen(oxygen_data oxygen)
  {
    string recycled_tooltip = "efficiency: " + (oxygen.scrubber_efficiency * 100.0).ToString("F0") + "%";

    render_title("OXYGEN");
    render_content("storage", Lib.ValueOrNone(oxygen.storage));
    render_content("consumed", Lib.HumanReadableRate(oxygen.consumed));
    render_content("recycled", Lib.HumanReadableRate(oxygen.recycled), recycled_tooltip);
    render_content("life expectancy", Lib.HumanReadableDuration(oxygen.life_expectancy));
    render_space();
  }
Exemple #19
0
 public override string GetInfo()
 {
     return(Lib.BuildString
            (
                Lib.Specifics(Lib.BuildString("The ", type, " can malfunction")),
                Lib.Specifics(true, "MTBF <i>(basic quality)</i>", Lib.HumanReadableDuration(mtbf)),
                Lib.Specifics(true, "MTBF <i>(max quality)</i>", Lib.HumanReadableDuration(mtbf * 5.0)),
                Lib.Specifics(true, "Repair specialization", trait.Length > 0 ? trait : "Any"),
                Lib.Specifics(true, "Repair experience level", level.ToString()),
                Lib.Specifics(true, "Effect", desc)
            ));
 }
Exemple #20
0
  // editor/r&d info
  public override string GetInfo()
  {
    string input_str = input_name.Length > 0 && input_rate > 0.0
      ? "\n\n<color=cyan>Require:</color>\n- " + input_name + ": <b>" + Lib.HumanReadableRate(input_rate) + "</b>"
      : "";

    return "Grow food in space.\n\n"
         + "- Harvest size: <b>" + harvest_size + " " + resource_name + "</b>\n"
         + "- Harvest time: <b>" + Lib.HumanReadableDuration(1.0 / growth_rate) + "</b>\n"
         + "- Lamps EC rate: <b> " + Lib.HumanReadableRate(ec_rate) + "</b>"
         + input_str;
  }
Exemple #21
0
 void problem_storm(Vessel v, ref List<Texture> icons, ref List<string> tooltips)
 {
   if (Storm.Incoming(v.mainBody))
   {
     icons.Add(icon_storm_warning);
     tooltips.Add("Coronal mass ejection incoming <i>(" + Lib.HumanReadableDuration(Storm.TimeBeforeCME(v.mainBody)) + ")</i>");
   }
   if (Storm.InProgress(v.mainBody))
   {
     icons.Add(icon_storm_danger);
     tooltips.Add("Solar storm in progress <i>(" + Lib.HumanReadableDuration(Storm.TimeLeftCME(v.mainBody)) + ")</i>");
   }
 }
Exemple #22
0
  void render_ec(ec_data ec)
  {
    bool shadow_different = Math.Abs(ec.generated_sunlight - ec.generated_shadow) > double.Epsilon;
    string generated_str = Lib.HumanReadableRate(ec.generated_sunlight) + (shadow_different ? "</b> / <b>" + Lib.HumanReadableRate(ec.generated_shadow) : "");
    string life_str = Lib.HumanReadableDuration(ec.life_expectancy_sunlight) + (shadow_different ? "</b> / <b>" + Lib.HumanReadableDuration(ec.life_expectancy_shadow) : "");

    render_title("ELECTRIC CHARGE");
    render_content("storage", Lib.ValueOrNone(ec.storage));
    render_content("consumed", Lib.HumanReadableRate(ec.consumed));
    render_content("generated", generated_str, "sunlight / shadow");
    render_content("life expectancy", life_str, "sunlight / shadow");
    render_space();
  }
Exemple #23
0
 void Problem_storm(Vessel v, ref List <Texture2D> icons, ref List <string> tooltips)
 {
     if (Storm.Incoming(v))
     {
         icons.Add(Icons.storm_yellow);
         tooltips.Add(Lib.BuildString("Coronal mass ejection incoming <i>(", Lib.HumanReadableDuration(Storm.TimeBeforeCME(v)), ")</i>"));
     }
     if (Storm.InProgress(v))
     {
         icons.Add(Icons.storm_red);
         tooltips.Add(Lib.BuildString("Solar storm in progress <i>(", Lib.HumanReadableDuration(Storm.TimeLeftCME(v)), ")</i>"));
     }
 }
Exemple #24
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();
  }
Exemple #25
0
        public static void Update(CelestialBody body, double elapsed_s)
        {
            // do nothing if storms are disabled
            if (!Features.SpaceWeather)
            {
                return;
            }

            StormData bd = DB.Storm(body.name);

            CreateStorm(bd, body, body.orbit.semiMajorAxis);

            // send messages

            if (Body_is_relevant(body))
            {
                switch (bd.storm_state)
                {
                case 2:
                    if (bd.msg_storm < 2)
                    {
                        Message.Post(Severity.danger, Lib.BuildString("The coronal mass ejection hit <b>", body.name, "</b> system"),
                                     Lib.BuildString("Storm duration: ", Lib.HumanReadableDuration(bd.displayed_duration)));
                    }
                    break;

                case 1:
                    if (bd.msg_storm < 1 && bd.display_warning)
                    {
                        var tti = bd.storm_time - Planetarium.GetUniversalTime();
                        Message.Post(Severity.warning, Lib.BuildString("Our observatories report a coronal mass ejection directed toward <b>", body.name, "</b> system"),
                                     Lib.BuildString("Time to impact: ", Lib.HumanReadableDuration(tti)));
                    }
                    break;

                case 0:
                    if (bd.msg_storm == 2)
                    {
                        Message.Post(Severity.relax, Lib.BuildString("The solar storm at <b>", body.name, "</b> system is over"));
                    }
                    break;
                }
            }

            bd.msg_storm = bd.storm_state;
        }
Exemple #26
0
        static void Render_file(Panel p, uint partId, string filename, File file, Drive drive, bool short_strings, Vessel v)
        {
            // get experiment info
            ExperimentInfo exp  = Science.Experiment(filename);
            double         rate = Cache.VesselInfo(v).connection.rate;

            // render experiment name
            string exp_label = Lib.BuildString
                               (
                "<b>",
                Lib.Ellipsis(exp.name, Styles.ScaleStringLength(short_strings ? 24 : 38)),
                "</b> <size=", Styles.ScaleInteger(10).ToString(), ">",
                Lib.Ellipsis(ExperimentInfo.Situation(filename), Styles.ScaleStringLength((short_strings ? 32 : 62) - Lib.Ellipsis(exp.name, Styles.ScaleStringLength(short_strings ? 24 : 38)).Length)),
                "</size>"
                               );
            string exp_tooltip = Lib.BuildString
                                 (
                exp.name, "\n",
                "<color=#aaaaaa>", ExperimentInfo.Situation(filename), "</color>"
                                 );
            double exp_value = Science.Value(filename, file.size);

            if (exp_value >= 0.1)
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableScience(exp_value), "</b>");
            }
            if (rate > 0)
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n<i>" + Lib.HumanReadableDuration(file.size / rate) + "</i>");
            }
            p.AddContent(exp_label, Lib.HumanReadableDataSize(file.size), exp_tooltip, (Action)null, () => Highlighter.Set(partId, Color.cyan));

            bool send = drive.GetFileSend(filename);

            p.AddIcon(send ? Icons.send_cyan : Icons.send_black, "Flag the file for transmission to <b>DSN</b>", () => { drive.Send(filename, !send); });
            p.AddIcon(Icons.toggle_red, "Delete the file", () =>
            {
                Lib.Popup("Warning!",
                          Lib.BuildString("Do you really want to delete ", exp.FullName(filename), "?"),
                          new DialogGUIButton("Delete it", () => drive.Delete_file(filename, double.MaxValue, v.protoVessel)),
                          new DialogGUIButton("Keep it", () => { }));
            }
                      );
        }
        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()));
        }
Exemple #28
0
 void render_supplies(Vessel v, vessel_info vi)
 {
   if (Kerbalism.supply_rules.Count > 0 || Kerbalism.ec_rule != null)
   {
     render_title("SUPPLIES");
     if (Kerbalism.ec_rule != null)
     {
       resource_info res = ResourceCache.Info(v, "ElectricCharge");
       render_content("battery", res.level > double.Epsilon ? Lib.HumanReadableDuration(Kerbalism.ec_rule.Depletion(v, res)) : "none", res.rate);
     }
     if (vi.crew_capacity > 0)
     {
       foreach(Rule r in Kerbalism.supply_rules)
       {
         resource_info res = ResourceCache.Info(v, r.resource_name);
         render_content(r.resource_name.AddSpacesOnCaps().ToLower(), res.level > double.Epsilon ? Lib.HumanReadableDuration(r.Depletion(v, res)) : "none", res.rate);
       }
     }
     render_space();
   }
 }
Exemple #29
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);
            }
        }
Exemple #30
0
        public void Update()
        {
            // set lamps emissive object
            if (lamps_rdr != null)
            {
                float intensity = Lib.IsFlight() ? (active ? (float)(artificial / light_tolerance) : 0.0f) : (active ? 1.0f : 0.0f);
                lamps_rdr.material.SetColor("_EmissiveColor", new Color(intensity, intensity, intensity, 1.0f));
            }

            // in flight
            if (Lib.IsFlight())
            {
                // still-play plants animation
                if (plants_anim != null)
                {
                    plants_anim.Still(growth);
                }

                // update ui
                string status = issue.Length > 0 ? Lib.BuildString("<color=yellow>", issue, "</color>") : growth > 0.99 ? "ready to harvest" : "growing";
                Events["Toggle"].guiName              = Lib.StatusToggle("Greenhouse", active ? status : "disabled");
                Fields["status_natural"].guiActive    = active && growth < 0.99;
                Fields["status_artificial"].guiActive = active && growth < 0.99;
                Fields["status_tta"].guiActive        = active && growth < 0.99;
                status_natural    = Lib.HumanReadableFlux(natural);
                status_artificial = Lib.HumanReadableFlux(artificial);
                status_tta        = Lib.HumanReadableDuration(tta);

                // show/hide harvest buttons
                bool manned = FlightGlobals.ActiveVessel.isEVA || Lib.CrewCount(vessel) > 0;
                Events["Harvest"].active          = manned && growth >= 0.99;
                Events["EmergencyHarvest"].active = manned && growth >= 0.5 && growth < 0.99;
            }
            // in editor
            else
            {
                // update ui
                Events["Toggle"].guiName = Lib.StatusToggle("Greenhouse", active ? "enabled" : "disabled");
            }
        }