[KSPEvent(guiName = "#LOC_KSPIE_ScienceGenerator_ReviewData", active = true, guiActive = true)]//Review Data
 public void ReviewData()
 {
     if (science_data != null)
     {
         if (merdp == null || !data_gend)
         {
             merdp = new ExperimentResultDialogPage(
                 part,
                 science_data,
                 1f,
                 0f,
                 false,
                 "",
                 true,
                 new ScienceLabSearch(vessel, science_data),
                 endExperiment,
                 keepData,
                 sendDataToComms,
                 sendDataToLab);
         }
         ExperimentsResultDialog.DisplayResult(merdp);
     }
     else
     {
         ResetExperiment();
     }
 }
Example #2
0
            public Result <object, string> TransmitData()
            {
                ScienceData[] data = experiment.GetData();
                ScienceData   scienceData;

                for (int i = 0; i < data.Length; ++i)
                {
                    scienceData = data[i];

                    ExperimentResultDialogPage page = new ExperimentResultDialogPage(
                        partModule.part, scienceData, scienceData.baseTransmitValue, scienceData.transmitBonus,
                        false, "", false,
                        new ScienceLabSearch(vesselAdapter.vessel, scienceData),
                        null, null, null, null);
                }

                IScienceDataTransmitter bestTransmitter = ScienceUtil.GetBestTransmitter(vesselAdapter.vessel);

                if (bestTransmitter != null)
                {
                    bestTransmitter.TransmitData(data.ToList());
                    Array.ForEach(experiment.GetData(), experiment.DumpData);
                    if (experiment.useCooldown)
                    {
                        experiment.cooldownToGo = experiment.cooldownTimer;
                    }

                    return(Result.Ok <object, string>(null));
                }

                return(Result.Err <object, string>("No transmitters available on this vessel or no data to transmit."));
            }
Example #3
0
        void Hijack(ScienceData data, bool send)
        {
            // shortcut
            ExperimentResultDialogPage page = dialog.currentPage;

            // collect and deduce all data necessary just once
            MetaData meta = new MetaData(data, page.host);

            if (!meta.is_collectable)
            {
                dialog.Dismiss();
                return;
            }

            // hijack the dialog
            if (!meta.is_rerunnable)
            {
                popup = Lib.Popup
                        (
                    "Warning!",
                    "Recording the data will render this module inoperable.\n\nRestoring functionality will require a scientist.",
                    new DialogGUIButton("Record data", () => Record(meta, data, send)),
                    new DialogGUIButton("Discard data", () => Dismiss(data))
                        );
            }
            else
            {
                Record(meta, data, send);
            }
        }
 private void experimentResultsPage(ScienceData data)
 {
     if (scienceReports.Count > 0)
     {
         ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.baseTransmitValue, data.transmitBonus, false, "", true, new ScienceLabSearch(vessel, data), new Callback <ScienceData>(onDiscardData), new Callback <ScienceData>(onKeepData), new Callback <ScienceData>(onTransmitData), new Callback <ScienceData>(onSendToLab));
         resultsDialog = ExperimentsResultDialog.DisplayResult(page);
     }
 }
 private void experimentResultsPage(ScienceData data)
 {
     if (scienceReports.Count > 0)
     {
         ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, transmitValue, ModuleScienceLab.GetBoostForVesselData(vessel, data), false, "", true, new ScienceLabSearch(vessel, data), new Callback <ScienceData>(onDiscardData), new Callback <ScienceData>(onKeepData), new Callback <ScienceData>(onTransmitData), new Callback <ScienceData>(onSendToLab));
         ExperimentsResultDialog.DisplayResult(page);
     }
 }
Example #6
0
        /* These methods handle generating and interacting with the science results page */

        private void newResultPage()
        {
            if (dataList.Count > 0)
            {
                ScienceData data = dataList[0];
                ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.baseTransmitValue, 0, !rerunnable, transmitWarningText, true, new ScienceLabSearch(vessel, data), new Callback <ScienceData>(onDiscardData), new Callback <ScienceData>(onKeepData), new Callback <ScienceData>(onTransmitData), new Callback <ScienceData>(onSendToLab));
                resultsDialog = ExperimentsResultDialog.DisplayResult(page);
            }
        }
Example #7
0
 private void initialResultsPage()
 {
     if (scienceReports.Count > 0)
     {
         ScienceData data = scienceReports[0];
         ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, labDataBoost, (experimentsReturned >= (experimentLimit - 1)) && !rerunnable, transmitWarningText, true, data.labBoost < 1 && checkLabOps() && xmitDataScalar < 1, new Callback <ScienceData>(onDiscardInitialData), new Callback <ScienceData>(onKeepInitialData), new Callback <ScienceData>(onTransmitInitialData), new Callback <ScienceData>(onSendInitialToLab));
         ExperimentsResultDialog.DisplayResult(page);
     }
 }
Example #8
0
 public float TransmitValue()
 {
     // By using ExperimentResultDialogPage we ensure that the logic calculating the value is exactly the same
     // as that used KSP's dialog.  The page type doesn't include any UI code itself, it just does the math to
     // confirm the values, and stores some callbacks for the UI to call when buttons are pressed.
     ExperimentResultDialogPage page = new ExperimentResultDialogPage(
         hostPart, scienceData, scienceData.baseTransmitValue, scienceData.transmitBonus, // the parameters with data we care aboue
         false, "", false, // disable transmit warning and reset option, these are used for the UI only
         new ScienceLabSearch(hostPart.vessel, scienceData), // this is used to calculate the transmit bonus, I think...
         null, null, null, null); // null callbacks, no sense in creating objects when we won't actually perform the callback.
     return page.baseTransmitValue * page.TransmitBonus;
 }
Example #9
0
        public float TransmitValue()
        {
            // By using ExperimentResultDialogPage we ensure that the logic calculating the value is exactly the same
            // as that used KSP's dialog.  The page type doesn't include any UI code itself, it just does the math to
            // confirm the values, and stores some callbacks for the UI to call when buttons are pressed.
            ExperimentResultDialogPage page = new ExperimentResultDialogPage(
                hostPart, scienceData, scienceData.baseTransmitValue, scienceData.transmitBonus, // the parameters with data we care aboue
                false, "", false,                                                                // disable transmit warning and reset option, these are used for the UI only
                new ScienceLabSearch(hostPart.vessel, scienceData),                              // this is used to calculate the transmit bonus, I think...
                null, null, null, null);                                                         // null callbacks, no sense in creating objects when we won't actually perform the callback.

            return(page.baseTransmitValue * page.TransmitBonus);
        }
 public void DumpData(ScienceData science_data)
 {
     if (science_data == this.science_data)
     {
         this.science_data = null;
         merdp             = null;
         result_string     = ""; // null causes error in save process
         result_title      = ""; // null causes error in save proccess
         transmit_value    = 0;
         recovery_value    = 0;
         Deployed          = false;
     }
 }
Example #11
0
        protected void sendDataToComms(ScienceData science_data)
        {
            List <IScienceDataTransmitter> list = base.vessel.FindPartModulesImplementing <IScienceDataTransmitter>();

            if (list.Any <IScienceDataTransmitter>() && science_data != null && data_gend)
            {
                merdp = null;
                List <ScienceData> list2 = new List <ScienceData>();
                list2.Add(science_data);
                list.OrderBy(ScienceUtil.GetTransmitterScore).First <IScienceDataTransmitter>().TransmitData(list2);
                endExperiment(science_data);
            }
        }
Example #12
0
        public void TakeKometSample()
        {
            ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment(kometExperimentID);
            ScienceSubject    subject    = ResearchAndDevelopment.GetExperimentSubject(experiment, ScienceUtil.GetExperimentSituation(part.vessel),
                                                                                       part.vessel.mainBody, string.Empty, string.Empty);

            //Create science data.
            ScienceData data = new ScienceData(experiment.baseValue, scienceXmitScalar, 1f, subject.id, subject.title);

            //Show results
            ScienceLabSearch           labSearch = new ScienceLabSearch(this.part.vessel, data);
            ExperimentResultDialogPage page      = new ExperimentResultDialogPage(part, data, data.baseTransmitValue, data.transmitBonus, false, "", true, labSearch, resetExperiment, keepResults, null, null);
            ExperimentsResultDialog    dlg       = ExperimentsResultDialog.DisplayResult(page);
        }
Example #13
0
        void Dismiss(ScienceData data)
        {
            // shortcut
            ExperimentResultDialogPage page = dialog.currentPage;

            // dump the data
            page.OnDiscardData(data);

            // close the confirm popup, if it is open
            if (popup != null)
            {
                popup.Dismiss();
                popup = null;
            }
        }
Example #14
0
        public System.Collections.IEnumerator ReviewDataCoroutine(ScienceData data)
        {
            yield return(new WaitForEndOfFrame());

            ExperimentResultDialogPage page = new ExperimentResultDialogPage(FlightGlobals.ActiveVessel.rootPart, data, 1.0f, 0, false, "", false, false,
                                                                             new Callback <ScienceData>(_onPageDiscard), new Callback <ScienceData>(_onPageKeep), new Callback <ScienceData>(_onPageTransmit), new Callback <ScienceData>(_onPageSendToLab));

            page.scienceValue = 0.0f;

            ExperimentsResultDialog dialog = ExperimentsResultDialog.DisplayResult(page);

            progressStyle            = dialog.guiSkin.customStyles.Where(n => n.name == "progressBarFill2").First();
            progressStyle.fixedWidth = 0.1f;
            progressStyle.border     = new RectOffset(0, 0, 0, 0);
            progressStyle.overflow   = new RectOffset(0, 0, 0, 0);

            //progressStyleBGCopy = new Texture2D(progressStyle.normal.background.width, progressStyle.normal.background.height);
            //progressStyleBGCopy = progressStyle.normal.background;
            //if (!fullRecovery)

            if (!dataAsteroid)
            {
                GUIStyle style = dialog.guiSkin.box;
                styleDefault = style.normal;
                styleStored  = style;
                skinStored   = dialog.guiSkin;

                print("Attempting to access " + CactEyeVars.root + storedPath);
                if (System.IO.File.Exists(CactEyeVars.root + storedPath))
                {
                    WWW www = new WWW("file://" + CactEyeVars.root + storedPath);
                    yield return(www);

                    www.LoadImageIntoTexture(tex);
                    style.normal.background = tex;

                    dialog.guiSkin.window.fixedWidth = 587f;
                    style.fixedWidth  = 512f;
                    style.fixedHeight = 288f;

                    page.resultText = "Screenshot saved to " + storedPath;
                }
                else
                {
                    print("Unable to find " + storedPath + " !");
                }
            }
        }
        public void onPageChange()
        {
            if (resultsDialog == null)
            {
                return;
            }

            currentPage = resultsDialog.currentPage;

            if (currentPage.pageData != null)
            {
                currentPage.pageData.baseTransmitValue = currentPage.xmitDataScalar;
            }

            popupDismiss();
        }
        private void onClose(ExperimentsResultDialog dialog)
        {
            if (dialog == null || resultsDialog == null)
            {
                return;
            }

            if (dialog == resultsDialog)
            {
                resultsDialog  = null;
                transferButton = null;
                currentPage    = null;
            }

            popupDismiss();
        }
        public void ReviewDataItem(ScienceData data)
        {
            ScienceLabSearch           labSearch = new ScienceLabSearch(FlightGlobals.ActiveVessel, data);
            ExperimentResultDialogPage page      = new ExperimentResultDialogPage(
                part,
                data,
                data.baseTransmitValue,
                data.transmitBonus,
                true,
                Localizer.Format("#autoLOC_TST_0051", Mathf.Round(data.baseTransmitValue * 100)),     //#autoLOC_TST_0051 = If you transmit this data it will only be worth: <<1>>% of the full science value
                true,
                labSearch,
                _onPageDiscard,
                _onPageKeep,
                _onPageTransmit,
                _onPageSendToLab);

            ExperimentsResultDialog.DisplayResult(page);
        }
        public void ReviewDataItem(ScienceData data)
        {
            ScienceLabSearch           labSearch = new ScienceLabSearch(FlightGlobals.ActiveVessel, data);
            ExperimentResultDialogPage page      = new ExperimentResultDialogPage(
                part,
                data,
                xmitDataScalar,
                data.transmitBonus,
                true,
                Localizer.Format("#autoLOC_TST_0051", Mathf.Round(data.baseTransmitValue * 100)),
                true,
                labSearch,
                _onPageDiscard,
                _onPageKeep,
                _onPageTransmit,
                _onPageSendToLab);

            ExperimentsResultDialog.DisplayResult(page);
        }
Example #19
0
        public void ReviewDataItem(ScienceData data)
        {
            ScienceLabSearch           labSearch = new ScienceLabSearch(FlightGlobals.ActiveVessel, data);
            ExperimentResultDialogPage page      = new ExperimentResultDialogPage(
                part,
                data,
                xmitDataScalar,
                data.labBoost,
                true,
                "If you transmit this data it will only be worth: " + Mathf.Round(data.transmitValue * 100) + "% of the full science value",
                true,
                labSearch,
                _onPageDiscard,
                _onPageKeep,
                _onPageTransmit,
                _onPageSendToLab);

            ExperimentsResultDialog.DisplayResult(page);
        }
Example #20
0
        public override void TransmitData()
        {
            ThrowIfNotCPUVessel();

            // This logic is mostly copied to DMScienceExperimentFields, make sure that changes here are copied there

            ScienceData[] data = container.GetData();
            ScienceData   scienceData;

            for (int i = 0; i < data.Length; ++i)
            {
                scienceData = data[i];
                // By using ExperimentResultDialogPage we ensure that the logic calculating the value is exactly the same
                // as that used KSP's dialog.  The page type doesn't include any UI code itself, it just does the math to
                // confirm the values, and stores some callbacks for the UI to call when buttons are pressed.
                ExperimentResultDialogPage page = new ExperimentResultDialogPage(
                    module.part, scienceData, scienceData.baseTransmitValue, scienceData.transmitBonus, // the parameters with data we care aboue
                    false, "", false,                                                                   // disable transmit warning and reset option, these are used for the UI only
                    new ScienceLabSearch(module.part.vessel, scienceData),                              // this is used to calculate the transmit bonus, I think...
                    null, null, null, null);                                                            // null callbacks, no sense in creating objects when we won't actually perform the callback.
                // The dialog page modifies the referenced object, so our reference has been updated.
            }

            // Logic pulled from ModuleScienceExperiment.sendDataToComms
            IScienceDataTransmitter bestTransmitter = ScienceUtil.GetBestTransmitter(module.vessel);

            if (bestTransmitter != null)
            {
                bestTransmitter.TransmitData(data.ToList());
                for (int i = 0; i < data.Length; ++i)
                {
                    container.DumpData(data[i]); // DumpData calls endExperiment, and handles setting as inoperable
                }
                if (module.useCooldown)
                {
                    module.cooldownToGo = module.cooldownTimer;
                }
            }
            else
            {
                ScreenMessages.PostScreenMessage("No transmitters available on this vessel or no data to transmit.", 4f, ScreenMessageStyle.UPPER_LEFT);
            }
        }
Example #21
0
        /* ************************************************************************************************
         * Function Name: ReviewDataCoroutine
         * Input: The current science experiment and a pretty screenshot
         * Output: None
         * Purpose: Called as a coroutine; the game will not wait for this function to finish executing
         * before the end of a frame. This displays the science report dialog box, of which the player can
         * interact with.
         * ************************************************************************************************/
        public System.Collections.IEnumerator ReviewDataCoroutine(ScienceData Data, Texture2D Screenshot)
        {
            yield return new WaitForEndOfFrame();

            //GUIStyle ProgressStyle;
            //GUIStyle ScienceStyle;
            
            ExperimentResultDialogPage page = new ExperimentResultDialogPage
                (
                FlightGlobals.ActiveVessel.rootPart,    //hosting part
                Data,                                   //Science data
                Data.transmitValue,                     //scalar for transmitting the data
                Data.labBoost,                          //scalar for lab bonuses
                false,                                  //bool for show transmit warning
                "",                                     //string for transmit warning
                false,                                  //show the reset button
                new ScienceLabSearch(this.part.vessel, Data),//show the lab option
                new Callback<ScienceData>(_onPageDiscard), 
                new Callback<ScienceData>(_onPageKeep), 
                new Callback<ScienceData>(_onPageTransmit), 
                new Callback<ScienceData>(_onPageSendToLab)
                );

            //page.scienceValue = 0f;
            ExperimentsResultDialog ScienceDialog = ExperimentsResultDialog.DisplayResult(page);

            //Store the old dialog gui information
//            ProgressStyle = ScienceDialog.guiSkin.customStyles.Where(n => n.name == "progressBarFill2").First();
//            GUIStyle style = ScienceDialog.guiSkin.box;
//            StyleDefault = style.normal;
//            SkinStored = ScienceDialog.guiSkin;

            ////Lets put a pretty picture on the science dialog.
//            ScienceStyle = ScienceDialog.guiSkin.box;
            ScienceStyle.normal.background = Screenshot;

//            ScienceDialog.guiSkin.window.fixedWidth = 587f;
            ScienceStyle.fixedWidth = 512f;
            ScienceStyle.fixedHeight = 288f;

            
        }
Example #22
0
        [KSPEvent(guiName = "#LOC_KSPIE_ScienceGenerator_ReviewData", active = true, guiActive = true)]//Review Data
        public void ReviewData()
        {
            if (science_data != null)
            {
                if (merdp == null || !data_gend)
                {
                    merdp = new ExperimentResultDialogPage(
                        base.part,
                        this.science_data,
                        1f,
                        0f,
                        false,
                        "",
                        true,
                        new ScienceLabSearch(this.vessel, this.science_data),
                        this.endExperiment,
                        this.keepData,
                        this.sendDataToComms,
                        this.sendDataToLab);

                    //merdp = new ModableExperimentResultDialogPage(
                    //		base.part,
                    //		this.science_data,
                    //		this.science_data.baseTransmitValue,
                    //		0,
                    //		false,
                    //		"",
                    //		true,
                    //		false,
                    //		new Callback<ScienceData>(this.endExperiment),
                    //		new Callback<ScienceData>(this.keepData),
                    //		new Callback<ScienceData>(this.sendDataToComms),
                    //		new Callback<ScienceData>(this.sendDataToLab));
                    //merdp.setUpScienceData(result_title, result_string, (float)transmit_value, (float)recovery_value, (float)data_size, xmit_scalar, ref_value);
                }
                ExperimentsResultDialog.DisplayResult(merdp);
            }
            else
            {
                ResetExperiment();
            }
        }
        public void ShowResults(ScienceData data, ModuleScienceLab lab = null)
        {
            scienceLab = lab;
            bool hasLab = scienceLab != null ? true : false;

            if (lab != null)
            {
                contextBonus   = lab.ContextBonus;
                surfaceBonus   = lab.SurfaceBonus;
                homeworldBonus = lab.homeworldMultiplier;

                lab.ContextBonus        = 0;
                lab.SurfaceBonus        = 0;
                lab.homeworldMultiplier = 0;
            }

            //Now show the dialog
            ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, data.labBoost, false, "", true, hasLab, Reset, Keep, Transmit, Process);
            ExperimentsResultDialog    dlg  = ExperimentsResultDialog.DisplayResult(page);
        }
        private void onSpawn(ExperimentsResultDialog dialog)
        {
            if (dialog == null)
            {
                return;
            }

            resultsDialog = dialog;

            var buttons = resultsDialog.GetComponentsInChildren <Button>(true);

            for (int i = buttons.Length - 1; i >= 0; i--)
            {
                Button b = buttons[i];

                if (b == null)
                {
                    continue;
                }

                if (b.name != "ButtonTransfer")
                {
                    continue;
                }

                transferButton = b;
                break;
            }

            currentPage = resultsDialog.currentPage;

            if (currentPage.pageData != null)
            {
                currentPage.pageData.baseTransmitValue = currentPage.xmitDataScalar;
            }

            transferButton.gameObject.SetActive(getConnectedVessels());
        }
Example #25
0
        public void Transmit(ScienceData data)
        {
            ExperimentsResultDialog    dlg  = ExperimentsResultDialog.Instance;
            ExperimentResultDialogPage page = dlg.currentPage;
            DialogCallbacks            dialogCallbacks;

            if (page == null)
            {
                return;
            }

            //Get the callbacks
            if (callbacks.ContainsKey(page) == false)
            {
                return;
            }
            dialogCallbacks = callbacks[page];

            //Original callback
            if (dialogCallbacks.originalTransmitCallback != null)
            {
                dialogCallbacks.originalTransmitCallback(data);
            }
        }
        private PopupDialog spawnDialog(ExperimentResultDialogPage page)
        {
            List <DialogGUIBase> dialog = new List <DialogGUIBase>();

            dialog.Add(new DialogGUILabel(Localizer.Format("#autoLOC_ScienceRelay_Transmit", page.pageData.title), false, false));

            transferAll = false;

            if (resultsDialog.pages.Count > 1)
            {
                dialog.Add(new DialogGUIToggle(false,
                                               Localizer.Format("#autoLOC_ScienceRelay_TransmitAll"),
                                               delegate(bool b)
                {
                    transferAll = !transferAll;
                })
                           );
            }

            List <DialogGUIHorizontalLayout> vessels = new List <DialogGUIHorizontalLayout>();

            for (int i = connectedVessels.Count - 1; i >= 0; i--)
            {
                KeyValuePair <Vessel, double> pair = connectedVessels[i];

                Vessel v = pair.Key;

                float boost = signalBoost((float)pair.Value, v, page.pageData, page.xmitDataScalar);

                DialogGUILabel label = null;

                if (settings.transmissionBoost)
                {
                    string transmit = string.Format("Xmit: {0:P0}", page.xmitDataScalar * (1 + boost));

                    if (boost > 0)
                    {
                        transmit += string.Format("(+{0:P0})", boost);
                    }

                    label = new DialogGUILabel(transmit, 130, 25);
                }

                DialogGUIBase button = null;

                if (settings.showTransmitWarning && page.showTransmitWarning)
                {
                    button = new DialogGUIButton(
                        v.vesselName,
                        delegate
                    {
                        spawnWarningDialog(
                            new ScienceRelayData()
                        {
                            _data   = page.pageData,
                            _host   = page.host,
                            _boost  = boost,
                            _source = FlightGlobals.ActiveVessel,
                            _target = v,
                        },
                            page.transmitWarningMessage);
                    },
                        160,
                        30,
                        true,
                        null);
                }
                else
                {
                    button = new DialogGUIButton <ScienceRelayData>(
                        v.vesselName,
                        transferToVessel,
                        new ScienceRelayData()
                    {
                        _data   = page.pageData,
                        _host   = page.host,
                        _boost  = boost,
                        _source = FlightGlobals.ActiveVessel,
                        _target = v,
                    },
                        true);

                    button.size = new Vector2(160, 30);
                }

                DialogGUIHorizontalLayout h = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { button });

                if (label != null)
                {
                    h.AddChild(label);
                }

                vessels.Add(h);
            }

            DialogGUIBase[] scrollList = new DialogGUIBase[vessels.Count + 1];

            scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true);

            for (int i = 0; i < vessels.Count; i++)
            {
                scrollList[i + 1] = vessels[i];
            }

            dialog.Add(new DialogGUIScrollList(new Vector2(270, 200), false, true,
                                               new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.MiddleLeft, scrollList)
                                               ));

            dialog.Add(new DialogGUISpace(4));

            dialog.Add(new DialogGUIHorizontalLayout(new DialogGUIBase[]
            {
                new DialogGUIFlexibleSpace(),
                new DialogGUIButton(Localizer.Format("#autoLOC_190768"), popupDismiss),
                new DialogGUIFlexibleSpace(),
                new DialogGUILabel(version, false, false)
            }));

            RectTransform resultRect = resultsDialog.GetComponent <RectTransform>();

            Rect pos = new Rect(0.5f, 0.5f, 300, 300);

            if (resultRect != null)
            {
                Vector2 resultPos = resultRect.position;

                float scale = GameSettings.UI_SCALE;

                int width  = Screen.width;
                int height = Screen.height;

                float xpos = (resultPos.x / scale) + width / 2;
                float ypos = (resultPos.y / scale) + height / 2;

                float yNorm = ypos / height;

                pos.y = yNorm;

                pos.x = xpos > (width - (550 * scale)) ? (xpos - 360) / width : (xpos + 360) / width;
            }

            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog(
                                                    "ScienceRelayDialog",
                                                    "",
                                                    Localizer.Format("#autoLOC_ScienceRelay_Title"),
                                                    UISkinManager.defaultSkin,
                                                    pos,
                                                    dialog.ToArray()), false, UISkinManager.defaultSkin));
        }
 private void experimentResultsPage(ScienceData data)
 {
     if (scienceReports.Count > 0)
     {
         ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, transmitValue, 0f, false, "", true, ModuleScienceLab.IsLabData(vessel, data), new Callback<ScienceData>(onDiscardData), new Callback<ScienceData>(onKeepData), new Callback<ScienceData>(onTransmitData), new Callback<ScienceData>(onSendToLab));
         ExperimentsResultDialog.DisplayResult(page);
     }
 }
 private void newResultPage()
 {
     if (storedScienceReports.Count > 0)
     {
         ScienceData data = storedScienceReports[dataIndex];
         ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, labDataBoost, (experimentsReturned >= (experimentLimit - 1)) && !rerunnable, transmitWarningText, true, ModuleScienceLab.IsLabData(vessel, data), new Callback<ScienceData>(onDiscardData), new Callback<ScienceData>(onKeepData), new Callback<ScienceData>(onTransmitData), new Callback<ScienceData>(onSendToLab));
         ExperimentsResultDialog.DisplayResult(page);
     }
 }
Example #29
0
        /* ************************************************************************************************
         * Function Name: ReviewDataCoroutine
         * Input: The current science experiment and a pretty screenshot
         * Output: None
         * Purpose: Called as a coroutine; the game will not wait for this function to finish executing
         * before the end of a frame. This displays the science report dialog box, of which the player can
         * interact with.
         * ************************************************************************************************/
        public System.Collections.IEnumerator ReviewDataCoroutine(ScienceData Data, Texture2D Screenshot)
        {
            yield return new WaitForEndOfFrame();

            //GUIStyle ProgressStyle;
            //GUIStyle ScienceStyle;

            ExperimentResultDialogPage page = new ExperimentResultDialogPage
                (
                FlightGlobals.ActiveVessel.rootPart,    //hosting part
                Data,                                   //Science data
                Data.transmitValue,                     //scalar for transmitting the data
                Data.labBoost,                          //scalar for lab bonuses
                false,                                  //bool for show transmit warning
                "",                                     //string for transmit warning
                false,                                  //show the reset button
                false,                                  //show the lab option
                new Callback<ScienceData>(_onPageDiscard),
                new Callback<ScienceData>(_onPageKeep),
                new Callback<ScienceData>(_onPageTransmit),
                new Callback<ScienceData>(_onPageSendToLab)
                );

            //page.scienceValue = 0f;
            ExperimentsResultDialog ScienceDialog = ExperimentsResultDialog.DisplayResult(page);

            //Store the old dialog gui information
            ProgressStyle = ScienceDialog.guiSkin.customStyles.Where(n => n.name == "progressBarFill2").First();
            GUIStyle style = ScienceDialog.guiSkin.box;
            StyleDefault = style.normal;
            SkinStored = ScienceDialog.guiSkin;

            ////Lets put a pretty picture on the science dialog.
            ScienceStyle = ScienceDialog.guiSkin.box;
            ScienceStyle.normal.background = Screenshot;

            ScienceDialog.guiSkin.window.fixedWidth = 587f;
            ScienceStyle.fixedWidth = 512f;
            ScienceStyle.fixedHeight = 288f;
        }
		private void initialResultsPage()
		{
			if (initialDataList.Count > 0)
			{
				ScienceData data = initialDataList[0];
				ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, labDataBoost, (experimentsReturned >= (experimentsLimit - 1)) && !rerunnable, transmitWarningText, true, new ScienceLabSearch(vessel, data), new Callback<ScienceData>(onDiscardInitialData), new Callback<ScienceData>(onKeepInitialData), new Callback<ScienceData>(onTransmitInitialData), new Callback<ScienceData>(onSendInitialToLab));
				ExperimentsResultDialog.DisplayResult(page);
			}
		}
 public void ReviewDataItem(ScienceData data)
 {
     var labSearch = new ScienceLabSearch(FlightGlobals.ActiveVessel, data);
     var page = new ExperimentResultDialogPage(
         part,
         data,
         xmitDataScalar,
         data.labBoost,
         false,
         "",
         true,
         labSearch,
         _onPageDiscard,
         _onPageKeep,
         _onPageTransmit,
         _onPageSendToLab);
     //If ResearchBodies is installed we check if the body is discovered or not. If it isn't we change the science results page text.
     if (Utilities.IsResearchBodiesInstalled && RBWrapper.RBactualAPI.enabled)
     {
         if (data.subjectID.Contains("TarsierSpaceTech.SpaceTelescope"))
         {
             if (data.title.Contains("Tarsier Space Telescope: Orbiting"))
             {
                 int index = data.title.IndexOf("looking at");
                 if (index != -1)
                 {
                     string bodyName = data.title.Substring(index + 11);
                     var keyvalue =
                         TSTMstStgs.Instance.RBCelestialBodies.FirstOrDefault(a => a.Key.theName == bodyName);
                     if (keyvalue.Key != null)
                     {
                         if (!keyvalue.Value.isResearched)
                         {
                             page.resultText =
                                 "We have collected a picture of a previously unknown body. If we return or transmit this data to home we will learn more about it.";
                             page.title = "Space Telescope picture of Unknown Body";
                         }
                     }
                 }
             }
         }
     }
     ExperimentsResultDialog.DisplayResult(page);
 }
        public void ShowResults(ScienceData data, ModuleScienceLab lab = null)
        {
            scienceLab = lab;
            bool hasLab = scienceLab != null ? true : false;

            if (lab != null)
            {
                contextBonus = lab.ContextBonus;
                surfaceBonus = lab.SurfaceBonus;
                homeworldBonus = lab.homeworldMultiplier;

                lab.ContextBonus = 0;
                lab.SurfaceBonus = 0;
                lab.homeworldMultiplier = 0;
            }

            //Now show the dialog
            ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, data.labBoost, false, "", true, hasLab, Reset, Keep, Transmit, Process);
            ExperimentsResultDialog dlg = ExperimentsResultDialog.DisplayResult(page);
        }
 public void ReviewDataItem(ScienceData data)
 {
     ExperimentResultDialogPage page = new ExperimentResultDialogPage(
         part,
         data,
         data.transmitValue,
         ModuleScienceLab.GetBoostForVesselData(part.vessel, data),
         false,
         "",
         false,
         ModuleScienceLab.IsLabData(vessel, data),
         new Callback<ScienceData>(onDiscardData),
         new Callback<ScienceData>(onKeepData),
         new Callback<ScienceData>(onTransmitData),
         new Callback<ScienceData>(onSendDataToLab));
     ExperimentsResultDialog.DisplayResult(page);
 }
Example #34
0
        public System.Collections.IEnumerator ReviewDataCoroutine(ScienceData data)
        {
            yield return new WaitForEndOfFrame();

            ExperimentResultDialogPage page = new ExperimentResultDialogPage(FlightGlobals.ActiveVessel.rootPart, data, 1.0f, 0, false, "", false, false,
                new Callback<ScienceData>(_onPageDiscard), new Callback<ScienceData>(_onPageKeep), new Callback<ScienceData>(_onPageTransmit), new Callback<ScienceData>(_onPageSendToLab));

            page.scienceValue = 0.0f;

            ExperimentsResultDialog dialog = ExperimentsResultDialog.DisplayResult(page);

            progressStyle = dialog.guiSkin.customStyles.Where(n => n.name == "progressBarFill2").First();
            progressStyle.fixedWidth = 0.1f;
            progressStyle.border = new RectOffset(0, 0, 0, 0);
            progressStyle.overflow = new RectOffset(0, 0, 0, 0);

            //progressStyleBGCopy = new Texture2D(progressStyle.normal.background.width, progressStyle.normal.background.height);
            //progressStyleBGCopy = progressStyle.normal.background;
            //if (!fullRecovery)

            if (!dataAsteroid)
            {
                GUIStyle style = dialog.guiSkin.box;
                styleDefault = style.normal;
                styleStored = style;
                skinStored = dialog.guiSkin;

                print("Attempting to access " + CactEyeVars.root + storedPath);
                if (System.IO.File.Exists(CactEyeVars.root + storedPath))
                {
                    WWW www = new WWW("file://" + CactEyeVars.root + storedPath);
                    yield return www;
                    www.LoadImageIntoTexture(tex);
                    style.normal.background = tex;

                    dialog.guiSkin.window.fixedWidth = 587f;
                    style.fixedWidth = 512f;
                    style.fixedHeight = 288f;

                    page.resultText = "Screenshot saved to " + storedPath;
                }
                else
                    print("Unable to find " + storedPath + " !");
            }
        }
        private void transferToVessel(ScienceRelayData RelayData)
        {
            if (resultsDialog != null)
            {
                resultsDialog.Dismiss();
            }

            if (RelayData._host == null || RelayData._data == null || RelayData._target == null || RelayData._source == null)
            {
                return;
            }

            List <ScienceRelayData> data = new List <ScienceRelayData>();

            if (transferAll)
            {
                for (int i = resultsDialog.pages.Count - 1; i >= 0; i--)
                {
                    ExperimentResultDialogPage page = resultsDialog.pages[i];

                    if (page == null)
                    {
                        continue;
                    }

                    if (page.pageData == null)
                    {
                        continue;
                    }

                    if (page.host == null)
                    {
                        continue;
                    }

                    ScienceRelayData relayData = new ScienceRelayData()
                    {
                        _data   = page.pageData,
                        _host   = page.host,
                        _boost  = signalBoost(RelayData._boost + 1, RelayData._target, page.pageData, page.xmitDataScalar),
                        _target = RelayData._target,
                        _source = RelayData._source,
                    };

                    relayData._data.baseTransmitValue = page.xmitDataScalar;

                    data.Add(relayData);
                }
            }
            else
            {
                RelayData._data.baseTransmitValue = currentPage.xmitDataScalar;
                data.Add(RelayData);
            }

            for (int i = data.Count - 1; i >= 0; i--)
            {
                ScienceData d = data[i]._data;

                Part host = data[i]._host;

                List <IScienceDataContainer> containers = host.FindModulesImplementing <IScienceDataContainer>();

                IScienceDataContainer hostContainer = null;

                for (int j = containers.Count - 1; j >= 0; j--)
                {
                    hostContainer = null;

                    IScienceDataContainer container = containers[j];

                    if (container == null)
                    {
                        continue;
                    }

                    ScienceData[] containerData = container.GetData();

                    for (int k = containerData.Length - 1; k >= 0; k--)
                    {
                        ScienceData dat = containerData[k];

                        if (dat.subjectID == d.subjectID)
                        {
                            hostContainer = container;
                            break;
                        }
                    }

                    if (hostContainer != null)
                    {
                        break;
                    }
                }

                IScienceDataTransmitter bestTransmitter = ScienceUtil.GetBestTransmitter(RelayData._source.FindPartModulesImplementing <IScienceDataTransmitter>());

                if (bestTransmitter == null)
                {
                    if (CommNetScenario.CommNetEnabled)
                    {
                        ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_238505"), 3, ScreenMessageStyle.UPPER_CENTER);
                    }
                    else
                    {
                        ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_238507"), 3, ScreenMessageStyle.UPPER_CENTER);
                    }
                }
                else
                {
                    d.triggered = true;

                    bestTransmitter.TransmitData(new List <ScienceData> {
                        d
                    });

                    queuedData.Add(data[i]);

                    if (hostContainer != null)
                    {
                        hostContainer.DumpData(d);
                    }
                }
            }
        }
 public void ReviewDataItem(ScienceData data)
 {
     ScienceLabSearch labSearch = new ScienceLabSearch(FlightGlobals.ActiveVessel, data);
     ExperimentResultDialogPage page = new ExperimentResultDialogPage(
             part,
             data,
             data.transmitValue,
             data.labBoost,
             true,
             "If you transmit this data it will only be worth: " + Mathf.Round(data.transmitValue * 100) + "% of the full science value",
             true,
             labSearch,
             _onPageDiscard,
             _onPageKeep,
             _onPageTransmit,
             _onPageSendToLab);
     ExperimentsResultDialog.DisplayResult(page);
 }