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 <= double.Epsilon) continue; // render panel title, if not done already if (supplies == 0) p.section("SUPPLIES"); // rate tooltip string rate_tooltip = Math.Abs(res.rate) >= 1e-10 ? Lib.BuildString ( res.rate > 0.0 ? "<color=#00ff00><b>" : "<color=#ff0000><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.content(label, Lib.HumanReadableDuration(res.Depletion(vi.crew_count)), rate_tooltip); ++supplies; } }
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.icon(image, tooltip); }
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.icon(image, string.Join("\n", tooltips.ToArray())); }
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); }