コード例 #1
0
        // ctor
        public Monitor()
        {
            // filter style
            filter_style = new GUIStyle(HighLogic.Skin.label);
            filter_style.normal.textColor = new Color(0.66f, 0.66f, 0.66f, 1.0f);
            filter_style.stretchWidth     = true;
            filter_style.fontSize         = Styles.ScaleInteger(12);
            filter_style.alignment        = TextAnchor.MiddleLeft;
            filter_style.fixedHeight      = Styles.ScaleFloat(16.0f);
            filter_style.border           = new RectOffset(0, 0, 0, 0);

            // vessel config style
            config_style = new GUIStyle(HighLogic.Skin.label);
            config_style.normal.textColor = Color.white;
            config_style.padding          = new RectOffset(0, 0, 0, 0);
            config_style.alignment        = TextAnchor.MiddleLeft;
            config_style.imagePosition    = ImagePosition.ImageLeft;
            config_style.fontSize         = Styles.ScaleInteger(9);

            // initialize panel
            panel = new Panel();

            // by default don't show hidden vessels
            filter_types.Add(VesselType.Unknown);

            // auto-switch selected vessel on scene changes
            GameEvents.onVesselChange.Add((Vessel v) => { if (selected_id != Guid.Empty)
                                                          {
                                                              selected_id = v.id;
                                                          }
                                          });
        }
コード例 #2
0
		// ctor
		public Monitor()
		{
			// filter style
			filter_style = new GUIStyle(HighLogic.Skin.label);
			filter_style.normal.textColor = new Color(0.66f, 0.66f, 0.66f, 1.0f);
			filter_style.stretchWidth = true;
			filter_style.fontSize = Styles.ScaleInteger(12);
			filter_style.alignment = TextAnchor.MiddleCenter;
			filter_style.fixedHeight = Styles.ScaleFloat(16.0f);
			filter_style.border = new RectOffset(0, 0, 0, 0);

			// vessel config style
			config_style = new GUIStyle(HighLogic.Skin.label);
			config_style.normal.textColor = Color.white;
			config_style.padding = new RectOffset(0, 0, 0, 0);
			config_style.alignment = TextAnchor.MiddleLeft;
			config_style.imagePosition = ImagePosition.ImageLeft;
			config_style.fontSize = Styles.ScaleInteger(9);

			// group texfield style
			group_style = new GUIStyle(config_style);
			group_style.imagePosition = ImagePosition.TextOnly;
			group_style.stretchWidth = true;
			group_style.fixedHeight = Styles.ScaleFloat(11.0f);
			group_style.normal.textColor = Color.yellow;

			// initialize panel
			panel = new Panel();

			// auto-switch selected vessel on scene changes
			GameEvents.onVesselChange.Add((Vessel v) => { if (selected_id != Guid.Empty) selected_id = v.id; });
		}
コード例 #3
0
		static void render_sample(Panel p, string filename, Sample sample, Drive drive, bool short_strings)
		{
			// get experiment info
			ExperimentInfo exp = Science.experiment(filename);

			// 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(exp.situation, 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>", exp.situation, "</color>"
			);
			double exp_value = Science.value(filename, sample.size);
			if (exp_value > double.Epsilon) exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableScience(exp_value), "</b>");

			p.content(exp_label, Lib.HumanReadableDataSize(sample.size), exp_tooltip);
			p.icon(sample.analyze ? Icons.lab_cyan : Icons.lab_black, "Flag the file for analysis in a <b>laboratory</b>", () => { sample.analyze = !sample.analyze; });
			p.icon(Icons.toggle_red, "Dump the sample", () => Lib.Popup
			(
			  "Warning!",
			   Lib.BuildString("Do you really want to dump ", exp.fullname, "?"),
			   new DialogGUIButton("Dump it", () => drive.samples.Remove(filename)),
			   new DialogGUIButton("Keep it", () => { })
			));
		}
コード例 #4
0
		static void Render_file(Panel p, string filename, File file, Drive drive, bool short_strings)
		{
			// get experiment info
			ExperimentInfo exp = Science.Experiment(filename);

			// 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(exp.situation, 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>", exp.situation, "</color>"
			);
			double exp_value = Science.Value(filename, file.size);
			if (exp_value > double.Epsilon) exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableScience(exp_value), "</b>");

			p.AddContent(exp_label, Lib.HumanReadableDataSize(file.size), exp_tooltip);
			p.AddIcon(file.send ? Icons.send_cyan : Icons.send_black, "Flag the file for transmission to <b>DSN</b>", () => { file.send = !file.send; });
			p.AddIcon(Icons.toggle_red, "Delete the file", () => Lib.Popup
			(
			  "Warning!",
			  Lib.BuildString("Do you really want to delete ", exp.fullname, "?"),
			  new DialogGUIButton("Delete it", () => drive.files.Remove(filename)),
			  new DialogGUIButton("Keep it", () => { })
			));
		}
コード例 #5
0
		bool render_vessel(Panel p, Vessel v)
		{
			// get vessel info
			vessel_info vi = Cache.VesselInfo(v);

			// skip invalid vessels
			if (!vi.is_valid) return false;

			// get data from db
			VesselData vd = DB.Vessel(v);

			// determine if filter must be shown
			show_filter |= vd.group.Length > 0 && vd.group != "NONE";

			// skip filtered vessels
			if (filtered() && vd.group != filter) return false;

			// get resource handler
			vessel_resources resources = ResourceCache.Get(v);

			// get vessel crew
			List<ProtoCrewMember> crew = Lib.CrewList(v);

			// get vessel name
			string vessel_name = v.isEVA ? crew[0].name : v.vesselName;

			// get body name
			string body_name = v.mainBody.name.ToUpper();

			// render entry
			p.header
			(
			  Lib.BuildString("<b>",
			  Lib.Ellipsis(vessel_name, Styles.ScaleStringLength(((page == MonitorPage.data || page == MonitorPage.log || selected_id == Guid.Empty) && !Lib.IsFlight()) ? 50 : 30)),
			  "</b> <size=", Styles.ScaleInteger(9).ToString(),
			  "><color=#cccccc>", Lib.Ellipsis(body_name, Styles.ScaleStringLength(8)), "</color></size>"),
			  string.Empty,
			  () => { selected_id = selected_id != v.id ? v.id : Guid.Empty; }
			);

			// problem indicator
			indicator_problems(p, v, vi, crew);

			// battery indicator
			indicator_ec(p, v, vi);

			// supply indicator
			if (Features.Supplies) indicator_supplies(p, v, vi);

			// reliability indicator
			if (Features.Reliability) indicator_reliability(p, v, vi);

			// signal indicator
			if (RemoteTech.Enabled() || HighLogic.fetch.currentGame.Parameters.Difficulty.EnableCommNet) indicator_signal(p, v, vi);

			// done
			return true;
		}
コード例 #6
0
ファイル: FileManager.cs プロジェクト: gotmachine/Kerbalism-1
        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", () => { }));
            }
                      );
        }
コード例 #7
0
ファイル: FileManager.cs プロジェクト: tinygrox/Kerbalism
        static void Render_sample(Panel p, uint partId, Sample sample, Drive drive, bool short_strings)
        {
            // render experiment name
            string exp_label = Lib.BuildString
                               (
                "<b>",
                Lib.Ellipsis(sample.subjectData.ExperimentTitle, Styles.ScaleStringLength(short_strings ? 24 : 38)),
                "</b> <size=", Styles.ScaleInteger(10).ToString(), ">",
                Lib.Ellipsis(sample.subjectData.SituationTitle, Styles.ScaleStringLength((short_strings ? 32 : 62) - Lib.Ellipsis(sample.subjectData.ExperimentTitle, Styles.ScaleStringLength(short_strings ? 24 : 38)).Length)),
                "</size>"
                               );
            string exp_tooltip = Lib.BuildString
                                 (
                sample.subjectData.ExperimentTitle, "\n",
                Lib.Color(sample.subjectData.SituationTitle, Lib.Kolor.LightGrey)
                                 );

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

            if (exp_value >= 0.1)
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableScience(exp_value, false), "</b>");
            }
            if (sample.mass > Double.Epsilon)
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableMass(sample.mass), "</b>");
            }
            if (!string.IsNullOrEmpty(sample.resultText))
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n", Lib.WordWrapAtLength(sample.resultText, 50));
            }

            p.AddContent(exp_label, Lib.HumanReadableSampleSize(sample.size), exp_tooltip, (Action)null, () => Highlighter.Set(partId, Color.cyan));
            p.AddRightIcon(sample.analyze ? Textures.lab_cyan : Textures.lab_black, Local.FILEMANAGER_analysis, () => { sample.analyze = !sample.analyze; }); //"Flag the file for analysis in a <b>laboratory</b>"
            p.AddRightIcon(Textures.toggle_red, Local.FILEMANAGER_Dumpsample, () =>                                                                           //"Dump the sample"
            {
                Lib.Popup(Local.FILEMANAGER_Warning_title,                                                                                                    //"Warning!"
                          Local.FILEMANAGER_DumpConfirm.Format(sample.subjectData.FullTitle),                                                                 //"Do you really want to dump <<1>>?",
                          new DialogGUIButton(Local.FILEMANAGER_DumpConfirm_button1, () => drive.Delete_sample(sample.subjectData)),                          //"Dump it"
                          new DialogGUIButton(Local.FILEMANAGER_DumpConfirm_button2, () => { }));                                                             //"Keep it"
            }
                           );
        }
コード例 #8
0
ファイル: FileManager.cs プロジェクト: gotmachine/Kerbalism-1
        static void Render_sample(Panel p, uint partId, string filename, Sample sample, Drive drive, bool short_strings)
        {
            // get experiment info
            ExperimentInfo exp = Science.Experiment(filename);

            // 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, sample.size);

            if (exp_value >= 0.1)
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableScience(exp_value), "</b>");
            }
            if (sample.mass > Double.Epsilon)
            {
                exp_tooltip = Lib.BuildString(exp_tooltip, "\n<b>", Lib.HumanReadableMass(sample.mass), "</b>");
            }

            p.AddContent(exp_label, Lib.HumanReadableSampleSize(sample.size), exp_tooltip, (Action)null, () => Highlighter.Set(partId, Color.cyan));
            p.AddIcon(sample.analyze ? Icons.lab_cyan : Icons.lab_black, "Flag the file for analysis in a <b>laboratory</b>", () => { sample.analyze = !sample.analyze; });
            p.AddIcon(Icons.toggle_red, "Dump the sample", () =>
            {
                Lib.Popup("Warning!",
                          Lib.BuildString("Do you really want to dump ", exp.FullName(filename), "?"),
                          new DialogGUIButton("Dump it", () => drive.samples.Remove(filename)),
                          new DialogGUIButton("Keep it", () => { }));
            }
                      );
        }
コード例 #9
0
		// ctor
		public Message()
		{
			// enable global access
			instance = this;

			// setup style
			style = new GUIStyle();
			style.normal.background = Lib.GetTexture("black-background");
			style.normal.textColor = new Color(0.66f, 0.66f, 0.66f, 1.0f);
			style.richText = true;
			style.stretchWidth = true;
			style.stretchHeight = true;
			style.fixedWidth = 0;
			style.fixedHeight = 0;
			style.fontSize = Styles.ScaleInteger(12);
			style.alignment = TextAnchor.MiddleCenter;
			style.border = new RectOffset(0, 0, 0, 0);
			style.padding = new RectOffset(Styles.ScaleInteger(2), Styles.ScaleInteger(2), Styles.ScaleInteger(2), Styles.ScaleInteger(2));

			if (all_logs == null)
			{
				all_logs = new List<MessageObject>();
			}
		}
コード例 #10
0
ファイル: Monitor.cs プロジェクト: valerian/Kerbalism
        bool Render_vessel(Panel p, Vessel v, bool selected = false)
        {
            // get vessel info
            Vessel_info vi = Cache.VesselInfo(v);

            // skip invalid vessels
            if (!vi.is_valid)
            {
                return(false);
            }

            // get data from db
            VesselData vd = DB.Vessel(v);

            // get vessel crew
            List <ProtoCrewMember> crew = Lib.CrewList(v);

            // get vessel name
            string vessel_name = v.isEVA ? crew[0].name : v.vesselName;

            // get body name
            string body_name = v.mainBody.name.ToUpper();

            // skip filtered vessels
            if (!Filter_match(v.vesselType, vd.group + " " + body_name + " " + vessel_name))
            {
                return(false);
            }

            // render entry
            p.AddHeader
            (
                Lib.BuildString("<b>",
                                Lib.Ellipsis(vessel_name, Styles.ScaleStringLength(((page == MonitorPage.data || page == MonitorPage.log || selected_id == Guid.Empty) && !Lib.IsFlight()) ? 45 : 25)),
                                "</b> <size=", Styles.ScaleInteger(9).ToString(), ">", Lib.Color("#cccccc", Lib.Ellipsis(body_name, Styles.ScaleStringLength(8))), "</size>"),
                string.Empty,
                () => { selected_id = selected_id != v.id ? v.id : Guid.Empty; }
            );

            // vessel type icon
            if (!selected)
            {
                p.SetIcon(GetVesselTypeIcon(v.vesselType), v.vesselType.displayDescription(), () => { selected_id = selected_id != v.id ? v.id : Guid.Empty; });
            }
            else
            {
                if (FlightGlobals.ActiveVessel != v)
                {
                    if (Lib.IsFlight())
                    {
                        p.SetIcon(GetVesselTypeIcon(v.vesselType), "Go to vessel!", () => Lib.Popup
                                      ("Warning!",
                                      Lib.BuildString("Do you really want go to ", vessel_name, " vessel?"),
                                      new DialogGUIButton("Go", () => { GotoVessel.JumpToVessel(v); }),
                                      new DialogGUIButton("Target", () => { GotoVessel.SetVesselAsTarget(v); }),
                                      new DialogGUIButton("Stay", () => { })));
                    }
                    else
                    {
                        p.SetIcon(GetVesselTypeIcon(v.vesselType), "Go to vessel!", () => Lib.Popup
                                      ("Warning!",
                                      Lib.BuildString("Do you really want go to ", vessel_name, " vessel?"),
                                      new DialogGUIButton("Go", () => { GotoVessel.JumpToVessel(v); }),
                                      new DialogGUIButton("Stay", () => { })));
                    }
                }
                else
                {
                    p.SetIcon(GetVesselTypeIcon(v.vesselType), v.vesselType.displayDescription(), () => { });
                }
            }

            // problem indicator
            Indicator_problems(p, v, vi, crew);

            // battery indicator
            Indicator_ec(p, v, vi);

            // supply indicator
            if (Features.Supplies)
            {
                Indicator_supplies(p, v, vi);
            }

            // reliability indicator
            if (Features.Reliability)
            {
                Indicator_reliability(p, v, vi);
            }

            // signal indicator
            if (API.Comm.handlers.Count > 0 || HighLogic.fetch.currentGame.Parameters.Difficulty.EnableCommNet)
            {
                Indicator_signal(p, v, vi);
            }

            // done
            return(true);
        }
コード例 #11
0
ファイル: Styles.cs プロジェクト: JonnyOThan/Kerbalism
        static Styles()
        {
            blackBackground = Lib.GetTexture("black-background");

            // window container
            win = new GUIStyle(HighLogic.Skin.window)
            {
                padding =
                {
                    left   = ScaleInteger(6),
                    right  = ScaleInteger(6),
                    top    =               0,
                    bottom = 0
                }
            };

            // window title container
            title_container = new GUIStyle
            {
                stretchWidth = true,
                fixedHeight  = ScaleFloat(16.0f),
                margin       =
                {
                    bottom = ScaleInteger(2),
                    top    = ScaleInteger(2)
                }
            };

            // window title text
            title_text = new GUIStyle
            {
                fontStyle   = FontStyle.Bold,
                fontSize    = ScaleInteger(10),
                fixedHeight = ScaleFloat(16.0f),
                alignment   = TextAnchor.MiddleCenter
            };

            // subsection title container
            section_container = new GUIStyle
            {
                stretchWidth = true,
                fixedHeight  = ScaleFloat(16.0f),
                normal       = { background = blackBackground },
                margin       =
                {
                    bottom = ScaleInteger(4),
                    top    = ScaleInteger(4)
                }
            };

            // subsection title text
            section_text = new GUIStyle(HighLogic.Skin.label)
            {
                stretchWidth  = true,
                stretchHeight = true,
                fontSize      = ScaleInteger(12),
                alignment     = TextAnchor.MiddleCenter,
                normal        = { textColor = Color.white }
            };

            // entry row container
            entry_container = new GUIStyle
            {
                stretchWidth = true,
                fixedHeight  = ScaleFloat(16.0f)
            };

            // entry label text
            entry_label = new GUIStyle(HighLogic.Skin.label)
            {
                richText      = true,
                stretchWidth  = true,
                stretchHeight = true,
                fontSize      = ScaleInteger(12),
                alignment     = TextAnchor.MiddleLeft,
                normal        = { textColor = Color.white }
            };

            entry_label_nowrap = new GUIStyle(HighLogic.Skin.label)
            {
                richText      = true,
                wordWrap      = false,
                stretchWidth  = true,
                stretchHeight = true,
                fontSize      = ScaleInteger(12),
                alignment     = TextAnchor.MiddleLeft,
                normal        = { textColor = Color.white }
            };

            // entry value text
            entry_value = new GUIStyle(HighLogic.Skin.label)
            {
                richText      = true,
                stretchWidth  = true,
                stretchHeight = true,
                fontStyle     = FontStyle.Bold,
                fontSize      = ScaleInteger(12),
                alignment     = TextAnchor.MiddleRight,
                normal        = { textColor = Color.white }
            };

            // desc row container
            desc_container = new GUIStyle
            {
                stretchWidth  = true,
                stretchHeight = true
            };

            // entry multi-line description
            desc = new GUIStyle(entry_label)
            {
                fontStyle = FontStyle.Italic,
                alignment = TextAnchor.UpperLeft,
                margin    =
                {
                    top    = 0,
                    bottom = 0
                },
                padding =
                {
                    top    = 0,
                    bottom = ScaleInteger(10)
                }
            };

            // left icon
            left_icon = new GUIStyle
            {
                stretchWidth  = true,
                stretchHeight = true,
                fixedWidth    = ScaleFloat(16.0f),
                alignment     = TextAnchor.MiddleLeft
            };

            // right icon
            right_icon = new GUIStyle
            {
                stretchWidth  = true,
                stretchHeight = true,
                margin        = { left = ScaleInteger(8) },
                fixedWidth    = ScaleFloat(16.0f),
                alignment     = TextAnchor.MiddleRight
            };

            // tooltip label style
            tooltip = new GUIStyle(HighLogic.Skin.label)
            {
                stretchWidth  = true,
                stretchHeight = true,
                fontSize      = ScaleInteger(12),
                alignment     = TextAnchor.MiddleCenter,
                border        = new RectOffset(0, 0, 0, 0),
                normal        =
                {
                    textColor  = Color.white,
                    background = blackBackground
                },
                margin  = new RectOffset(0, 0, 0, 0),
                padding = new RectOffset(ScaleInteger(6), ScaleInteger(6), ScaleInteger(3), ScaleInteger(3))
            };

            tooltip.normal.background.wrapMode = TextureWrapMode.Repeat;

            // tooltip container style
            tooltip_container = new GUIStyle
            {
                stretchWidth  = true,
                stretchHeight = true
            };

            smallStationHead = new GUIStyle(HighLogic.Skin.label)
            {
                fontSize = ScaleInteger(12)
            };

            smallStationText = new GUIStyle(HighLogic.Skin.label)
            {
                fontSize = ScaleInteger(12),
                normal   = { textColor = Color.white }
            };

            message = new GUIStyle()
            {
                normal =
                {
                    background = blackBackground,
                    textColor  = new Color(0.66f, 0.66f, 0.66f, 1.0f)
                },
                richText      = true,
                stretchWidth  = true,
                stretchHeight = true,
                fixedWidth    = 0,
                fixedHeight   = 0,
                fontSize      = Styles.ScaleInteger(12),
                alignment     = TextAnchor.MiddleCenter,
                border        = new RectOffset(0, 0, 0, 0),
                padding       = new RectOffset(Styles.ScaleInteger(2), Styles.ScaleInteger(2), Styles.ScaleInteger(2), Styles.ScaleInteger(2))
            };
        }
コード例 #12
0
ファイル: FileManager.cs プロジェクト: tinygrox/Kerbalism
        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"
            }
                           );
        }