public override void OnStart(StartState state)
        {
            if (state == StartState.Editor || state == StartState.None || state == StartState.PreLaunch)
            {
                return;
            }

            transmitter = part.FindModuleImplementing <ModuleDataTransmitter>();

            if (transmitter != null)
            {
                // add event to update cache when antenna be extended or retracted
                ModuleDeployableAntenna deployMod = part.FindModuleImplementing <ModuleDeployableAntenna>();
                if (deployMod != null)
                {
                    deployMod.OnStop.Add(OnAntennaDeployment);
                }

                // I hide it because it don't show the right information (should be antenna_power * rangeModifier)
                transmitter.Fields["powerText"].guiActive             = false;
                transmitter.Fields["statusText"].guiActive            = false;
                transmitter.Events["StartTransmission"].active        = false;
                transmitter.Events["TransmitIncompleteToggle"].active = false;

                // Show transmissiter rate
                if (transmitter.antennaType != AntennaType.INTERNAL)
                {
                    Rate  = Lib.HumanReadableDataRate(rate);
                    power = KSPUtil.PrintSI(transmitter.antennaPower * Antenna_Info.rangeModifier, string.Empty, 3, false);
                    Fields["Rate"].guiActive  = true;
                    Fields["power"].guiActive = true;
                }
            }
            base.OnStart(state);
        }
Пример #2
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);
        }
Пример #3
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            specs.add("Researcher", new CrewSpecs(researcher).info());
            specs.add("EC rate", Lib.HumanReadableRate(ec_rate));
            specs.add("Analysis rate", Lib.HumanReadableDataRate(analysis_rate));
            return(specs);
        }
Пример #4
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            specs.Add(Local.Laboratory_Researcher, new CrewSpecs(researcher).Info());
            if (cleaner)
            {
                specs.Add(Local.Laboratory_CanClean);
            }
            specs.Add(Local.Laboratory_ECrate, Lib.HumanReadableRate(ec_rate));
            specs.Add(Local.Laboratory_rate, Lib.HumanReadableDataRate(analysis_rate));
            return(specs);
        }
Пример #5
0
        // specifics support
        public Specifics Specs()
        {
            Specifics specs = new Specifics();

            specs.Add(Localizer.Format("#KERBALISM_Laboratory_Researcher"), new CrewSpecs(researcher).Info());
            if (cleaner)
            {
                specs.Add(Localizer.Format("#KERBALISM_Laboratory_CanClean"));
            }
            specs.Add(Localizer.Format("#KERBALISM_Laboratory_ECrate"), Lib.HumanReadableRate(ec_rate));
            specs.Add(Localizer.Format("#KERBALISM_Laboratory_rate"), Lib.HumanReadableDataRate(analysis_rate));
            return(specs);
        }
Пример #6
0
        public override string GetInfo()
        {
            Specifics specs = new Specifics();

            specs.Add(Lib.Color(Local.Module_Experiment_Specifics_info8, Lib.Kolor.Cyan, true));            //"Needs:"
            if (ec_rate > 0.0)
            {
                specs.Add(Local.Module_Experiment_Specifics_info9, Lib.HumanReadableRate(ec_rate));                           //"EC"
            }
            if (comms_rate > 0.0)
            {
                specs.Add(Local.Module_Experiment_Specifics_info2, Lib.HumanReadableDataRate(comms_rate));                               // "Data rate"
            }
            return(specs.Info());
        }
Пример #7
0
        public override void OnStart(StartState state)
        {
            // don't break tutorial scenarios
            if (Lib.DisableScenario(this))
            {
                return;
            }

            // assume extended if there is no animator
            extended |= part.FindModuleImplementing <ModuleAnimationGroup>() == null;

            if (cost == 0)
            {
                cost = dist / 50000000;
            }
            if (rate == 0)
            {
                rate = cost * 0.064;
            }

            // create data stream, used if science system is disabled
            stream = new DataStream();

            // in flight
            if (Lib.IsFlight())
            {
#if DEBUG
                ecCost = cost.ToString() + "/s";
                Rate   = Lib.HumanReadableDataRate(rate);
                power  = Lib.HumanReadableRange(dist);
#endif
                // get animator module, if any
                var anim = part.FindModuleImplementing <ModuleAnimationGroup>();
                if (anim != null)
                {
                    // resync extended state from animator
                    // - rationale: extending in editor doesn't set extended to true,
                    //   leading to spurious signal loss for 1 tick on prelaunch
                    extended = anim.isDeployed;

                    // allow extending/retracting
                    anim.Events["DeployModule"].guiActiveUncommand  = Settings.UnlinkedControl == UnlinkedCtrl.full; //  "true" has been changed
                    anim.Events["RetractModule"].guiActiveUncommand = Settings.UnlinkedControl == UnlinkedCtrl.full; //  "true" has been changed
                }
            }
        }
        static bool Prefix(ModuleDataTransmitter __instance, ref string __result)
        {
            // Patch only if science is enabled
            if (!Features.Science)
            {
                return(true);
            }

            string text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(__instance.antennaType.displayDescription());

            // Antenna type: direct
            string result = Localizer.Format("#autoLOC_7001005", text);

            // Antenna rating: 500km
            result += Localizer.Format("#autoLOC_7001006", Lib.HumanReadableDistance(__instance.antennaPower));
            result += "\n";

            var dsn1 = CommNet.CommNetScenario.RangeModel.GetMaximumRange(__instance.antennaPower, GameVariables.Instance.GetDSNRange(0f));
            var dsn2 = CommNet.CommNetScenario.RangeModel.GetMaximumRange(__instance.antennaPower, GameVariables.Instance.GetDSNRange(0.5f));
            var dsn3 = CommNet.CommNetScenario.RangeModel.GetMaximumRange(__instance.antennaPower, GameVariables.Instance.GetDSNRange(1f));

            result += Lib.BuildString(Localizer.Format("#autoLOC_236834"), " ", Lib.HumanReadableDistance(dsn1));
            result += Lib.BuildString(Localizer.Format("#autoLOC_236835"), " ", Lib.HumanReadableDistance(dsn2));
            result += Lib.BuildString(Localizer.Format("#autoLOC_236836"), " ", Lib.HumanReadableDistance(dsn3));

            double ec = __instance.DataResourceCost * __instance.DataRate;

            Specifics specs = new Specifics();

            specs.Add(Local.DataTransmitter_ECidle, Lib.Color(Lib.HumanReadableRate(ec * Settings.TransmitterPassiveEcFactor), Lib.Kolor.Orange));            //"EC (idle)"

            if (__instance.antennaType != AntennaType.INTERNAL)
            {
                specs.Add(Local.DataTransmitter_ECTX, Lib.Color(Lib.HumanReadableRate(ec * Settings.TransmitterActiveEcFactor), Lib.Kolor.Orange)); //"EC (transmitting)"
                specs.Add("");
                specs.Add(Local.DataTransmitter_Maxspeed, Lib.HumanReadableDataRate(__instance.DataRate));                                          //"Max. speed"
            }

            __result = Lib.BuildString(result, "\n\n", specs.Info());

            // don't call default implementation
            return(false);
        }
Пример #9
0
        // specifics support
        public Specifics Specs()
        {
            var specs = new Specifics();

            specs.add("Name", ResearchAndDevelopment.GetExperiment(experiment).experimentTitle);
            specs.add("Data rate", Lib.HumanReadableDataRate(data_rate));
            specs.add("EC required", Lib.HumanReadableRate(ec_rate));
            if (crew.Length > 0)
            {
                specs.add("Operator", new CrewSpecs(crew).info());
            }
            specs.add(string.Empty);
            specs.add("<color=#00ffff>Situations:</color>", string.Empty);
            var tokens = Lib.Tokenize(situations, ',');

            foreach (string s in tokens)
            {
                specs.add(Lib.BuildString("• <b>", s, "</b>"));
            }
            return(specs);
        }
Пример #10
0
        // specifics support
        public Specifics Specs()
        {
            double[] ranges = new double[12];
            for (int i = 0; i < 12; ++i)
            {
                ranges[i] = dist / 13.0 * (double)(i + 1);
            }

            Specifics specs = new Specifics();

            specs.add("Type", type == AntennaType.low_gain ? "low-gain" : "high-gain");
            specs.add("Transmission cost", Lib.BuildString(cost.ToString("F2"), " EC/s"));
            specs.add("Nominal rate", Lib.HumanReadableDataRate(rate));
            specs.add("Nominal distance", Lib.HumanReadableRange(dist));
            specs.add(string.Empty);
            specs.add("<color=#00ffff><b>Transmission rates</b></color>");
            foreach (double range in ranges)
            {
                specs.add(Lib.BuildString(Lib.HumanReadableRange(range), "\t<b>", Lib.HumanReadableDataRate(calculate_rate(range * 0.99, dist, rate)), "</b>"));
            }
            return(specs);
        }
Пример #11
0
        static void Render_science(Panel p, Vessel v, VesselData vd)
        {
            // don't show env panel in eva kerbals
            if (v.isEVA)
            {
                return;
            }

            p.AddSection(Local.TELEMETRY_TRANSMISSION);            //"TRANSMISSION"

            // comm status
            if (vd.filesTransmitted.Count > 0)
            {
                double        transmitRate = 0.0;
                StringBuilder tooltip      = new StringBuilder();
                tooltip.Append(string.Format("<align=left /><b>{0,-15}\t{1}</b>\n", Local.TELEMETRY_TRANSMISSION_rate, Local.TELEMETRY_filetransmitted));                //"rate""file transmitted"
                for (int i = 0; i < vd.filesTransmitted.Count; i++)
                {
                    transmitRate += vd.filesTransmitted[i].transmitRate;
                    tooltip.Append(string.Format("{0,-15}\t{1}", Lib.HumanReadableDataRate(vd.filesTransmitted[i].transmitRate), Lib.Ellipsis(vd.filesTransmitted[i].subjectData.FullTitle, 40u)));
                    if (i < vd.filesTransmitted.Count - 1)
                    {
                        tooltip.Append("\n");
                    }
                }

                p.AddContent(Local.TELEMETRY_transmitting, Lib.BuildString(vd.filesTransmitted.Count.ToString(), vd.filesTransmitted.Count > 1 ? " files at " : " file at ", Lib.HumanReadableDataRate(transmitRate)), tooltip.ToString());                 //"transmitting"
            }
            else
            {
                p.AddContent(Local.TELEMETRY_maxtransmissionrate, Lib.HumanReadableDataRate(vd.Connection.rate));                //"max transmission rate"
            }

            p.AddContent(Local.TELEMETRY_target, vd.Connection.target_name);            //"target"

            // total science gained by vessel
            p.AddContent(Local.TELEMETRY_totalsciencetransmitted, Lib.HumanReadableScience(vd.scienceTransmitted, false));            //"total science transmitted"
        }
Пример #12
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)));
        }
Пример #13
0
        // specifics support
        public Specifics Specs()
        {
            var specs = new Specifics();
            var exp   = Science.Experiment(experiment_id);

            if (exp == null)
            {
                specs.Add(Localizer.Format("#KERBALISM_ExperimentInfo_Unknown"));
                return(specs);
            }

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

            specs.Add(string.Empty);
            double expSize = exp.max_amount;

            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));
                if (!sample_collecting && Math.Abs(sample_reservoir - sample_mass) > double.Epsilon && sample_mass > double.Epsilon)
                {
                    specs.Add("Experiments", "" + Math.Round(sample_reservoir / sample_mass, 0));
                }
                specs.Add("Duration", Lib.HumanReadableDuration(expSize / data_rate));
            }

            List <string> situations = exp.Situations();

            if (situations.Count > 0)
            {
                specs.Add(string.Empty);
                specs.Add("<color=#00ffff>Situations:</color>", string.Empty);
                foreach (string s in situations)
                {
                    specs.Add(Lib.BuildString("• <b>", s, "</b>"));
                }
            }

            specs.Add(string.Empty);
            specs.Add("<color=#00ffff>Needs:</color>");

            specs.Add("EC", Lib.HumanReadableRate(ec_rate));
            foreach (var p in KerbalismProcess.ParseResources(resources))
            {
                specs.Add(p.Key, Lib.HumanReadableRate(p.Value));
            }

            if (crew_prepare.Length > 0)
            {
                var cs = new CrewSpecs(crew_prepare);
                specs.Add("Preparation", cs ? cs.Info() : "none");
            }
            if (crew_operate.Length > 0)
            {
                var cs = new CrewSpecs(crew_operate);
                specs.Add("Operation", cs ? cs.Info() : "unmanned");
            }
            if (crew_reset.Length > 0)
            {
                var cs = new CrewSpecs(crew_reset);
                specs.Add("Reset", cs ? cs.Info() : "none");
            }

            if (!string.IsNullOrEmpty(requires))
            {
                specs.Add(string.Empty);
                specs.Add("<color=#00ffff>Requires:</color>", string.Empty);
                var tokens = Lib.Tokenize(requires, ',');
                foreach (string s in tokens)
                {
                    specs.Add(Lib.BuildString("• <b>", Science.RequirementText(s), "</b>"));
                }
            }

            return(specs);
        }
Пример #14
0
        void Indicator_signal(Panel p, Vessel v, VesselData vd)
        {
            ConnectionInfo conn = vd.Connection;

            // signal strength
            var    strength   = Math.Ceiling(conn.strength * 10000) / 10000;
            string signal_str = strength > 0.001 ? Lib.HumanReadablePerc(strength, "F2") : Lib.Color(Lib.Italic(Local.Generic_NO), Lib.Kolor.Orange);

            // target name
            string target_str = conn.linked ? conn.target_name : Local.Generic_NONE;

            // transmitting info
            string comms_str;

            if (!conn.linked)
            {
                comms_str = Local.Generic_NOTHING;
            }
            else if (vd.filesTransmitted.Count == 0)
            {
                comms_str = Local.UI_telemetry;
            }
            else
            {
                comms_str = Lib.BuildString(vd.filesTransmitted.Count.ToString(), vd.filesTransmitted.Count > 1 ? " files" : " file");
            }

            // create tooltip
            string tooltip = Lib.BuildString
                             (
                "<align=left />",
                String.Format("{0,-14}\t<b>{1}</b>\n", Local.UI_DSNconnected, conn.linked ?
                              Lib.Color(Local.Generic_YES, Lib.Kolor.Green) : Lib.Color(Lib.Italic(Local.Generic_NO), Lib.Kolor.Orange)),
                String.Format("{0,-14}\t<b>{1}</b>\n", Local.UI_sciencerate, Lib.HumanReadableDataRate(conn.rate)),
                String.Format("{0,-14}\t<b>{1}</b>\n", Local.UI_strength, signal_str),
                String.Format("{0,-14}\t<b>{1}</b>\n", Local.UI_target, target_str),
                String.Format("{0,-14}\t<b>{1}</b>", Local.UI_transmitting, comms_str)
                             );

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

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

            case LinkStatus.indirect_link:
                image    = conn.strength > 0.05 ? Textures.signal_white : Textures.iconSwitch(Textures.signal_yellow, image);                        // or 5% signal strength
                tooltip += Lib.Color("\n" + Local.UI_Signalrelayed, Lib.Kolor.Yellow);
                break;

            case LinkStatus.plasma:
                tooltip += Lib.Color(Lib.Italic("\n" + Local.UI_Plasmablackout), Lib.Kolor.Red);
                break;

            case LinkStatus.storm:
                tooltip += Lib.Color(Lib.Italic("\n" + Local.UI_Stormblackout), Lib.Kolor.Red);
                break;
            }

            p.AddRightIcon(image, tooltip, () => UI.Open((p2) => p2.ConnMan(v)));
        }
Пример #15
0
        static void Render_ConnectionDetail(Panel p, double range, double rate, short freq)
        {
            // render frequency
            string detail = Lib.BuildString("<size=10>", Lib.HumanReadableRange(range), "</size>");

            p.SetContent(Lib.BuildString("Frequency: <b>", freq.ToString(), "</b>"), detail, Lib.BuildString("<b>", Lib.HumanReadableDataRate(rate), "</b>"));
        }
Пример #16
0
        void Indicator_signal(Panel p, Vessel v, Vessel_info vi)
        {
            ConnectionInfo conn       = vi.connection;
            bool           remotetech = RemoteTech.Enabled;

            // signal strength or when using RemoteTech signal delay
            string signal_str = remotetech ?
                                !conn.linked ? "----" : conn.strength > Double.Epsilon ? KSPUtil.dateTimeFormatter.PrintTimeStampCompact(conn.strength) : Localizer.Format("#KERBALISM_Generic_NONE") :
                                Lib.HumanReadablePerc(conn.strength, "F2");

            // 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", remotetech ? Localizer.Format("#KERBALISM_UI_delay") : 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 = remotetech ? conn.strength <15.0 ? Icons.signal_white : Icons.signal_yellow :                               // 15 seconds for RemoteTech signal delay
                                                    conn.strength> 0.05 ? Icons.signal_white : Icons.signal_yellow;                 // or 5% signal strength
                break;

            case LinkStatus.indirect_link:
                image = remotetech ? conn.strength <15.0 ? Icons.signal_white: Icons.signal_yellow :                                // 15 seconds for RemoteTech signal delay
                                                    conn.strength> 0.05 ? Icons.signal_white : Icons.signal_yellow;                 // 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);
        }
Пример #17
0
        static void Render_file(Panel p, uint partId, File file, Drive drive, bool short_strings, Vessel v)
        {
            // render experiment name
            string exp_label = Lib.BuildString
                               (
                "<b>",
                Lib.Ellipsis(file.subjectData.ExperimentTitle, Styles.ScaleStringLength(short_strings ? 24 : 38)),
                "</b> <size=", Styles.ScaleInteger(10).ToString(), ">",
                Lib.Ellipsis(file.subjectData.SituationTitle, Styles.ScaleStringLength((short_strings ? 32 : 62) - Lib.Ellipsis(file.subjectData.ExperimentTitle, Styles.ScaleStringLength(short_strings ? 24 : 38)).Length)),
                "</size>"
                               );
            string exp_tooltip = Lib.BuildString
                                 (
                file.subjectData.ExperimentTitle, "\n",
                Lib.Color(file.subjectData.SituationTitle, Lib.Kolor.LightGrey)
                                 );

            double exp_value = file.size * file.subjectData.SciencePerMB;

            if (file.subjectData.ScienceRemainingToRetrieve > 0f && file.size > 0.0)
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableScience(exp_value, false), "</b>");
            }
            if (file.transmitRate > 0.0)
            {
                if (file.size > 0.0)
                {
                    exp_tooltip = Lib.Color(Lib.BuildString(exp_tooltip, "\n", Local.FILEMANAGER_TransmittingRate.Format(Lib.HumanReadableDataRate(file.transmitRate)), " : <i>", Lib.HumanReadableCountdown(file.size / file.transmitRate), "</i>"), Lib.Kolor.Cyan);                    //Transmitting at <<1>>
                }
                else
                {
                    exp_tooltip = Lib.Color(Lib.BuildString(exp_tooltip, "\n", Local.FILEMANAGER_TransmittingRate.Format(Lib.HumanReadableDataRate(file.transmitRate))), Lib.Kolor.Cyan);                    //Transmitting at <<1>>
                }
            }
            else if (v.KerbalismData().Connection.rate > 0.0)
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n", Local.FILEMANAGER_Transmitduration, "<i>", Lib.HumanReadableDuration(file.size / v.KerbalismData().Connection.rate), "</i>");                //Transmit duration :
            }
            if (!string.IsNullOrEmpty(file.resultText))
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n", Lib.WordWrapAtLength(file.resultText, 50));
            }

            string size;

            if (file.transmitRate > 0.0)
            {
                if (file.size == 0.0)
                {
                    size = Lib.Color(Lib.BuildString("↑ ", Lib.HumanReadableDataRate(file.transmitRate)), Lib.Kolor.Cyan);
                }
                else
                {
                    size = Lib.Color(Lib.BuildString("↑ ", Lib.HumanReadableDataSize(file.size)), Lib.Kolor.Cyan);
                }
            }
            else
            {
                size = Lib.HumanReadableDataSize(file.size);
            }

            p.AddContent(exp_label, size, exp_tooltip, (Action)null, () => Highlighter.Set(partId, Color.cyan));

            bool send = drive.GetFileSend(file.subjectData.Id);

            p.AddRightIcon(send ? Textures.send_cyan : Textures.send_black, Local.FILEMANAGER_send, () => { drive.Send(file.subjectData.Id, !send); }); //"Flag the file for transmission to <b>DSN</b>"
            p.AddRightIcon(Textures.toggle_red, Local.FILEMANAGER_Delete, () =>                                                                         //"Delete the file"
            {
                Lib.Popup(Local.FILEMANAGER_Warning_title,                                                                                              //"Warning!"
                          Local.FILEMANAGER_DeleteConfirm.Format(file.subjectData.FullTitle),                                                           //Lib.BuildString(, "?"),//"Do you really want to delete <<1>>",
                          new DialogGUIButton(Local.FILEMANAGER_DeleteConfirm_button1, () => drive.Delete_file(file.subjectData)),                      //"Delete it"
                          new DialogGUIButton(Local.FILEMANAGER_DeleteConfirm_button2, () => { }));                                                     //"Keep it"
            }
                           );
        }
Пример #18
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);
		}
Пример #19
0
        // TODO: Implement support to CommNet frequency
        void Indicator_Signal(Panel p, Vessel v, Vessel_Info vi)
        {
            ConnectionInfo conn = vi.connection;

            // 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>Blackout</color>";
                break;
            }

            p.SetIcon(image, tooltip);
        }