KEMINI - resetting an experiment does not allow re-run #8

Closed
opened 2016-10-12 15:00:41 +02:00 by mwerle · 3 comments
mwerle commented 2016-10-12 15:00:41 +02:00 (Migrated from github.com)

Actual: If an experiment is reset, it disappears.
Expect: experiment to be available for a re-run after reset.

TODO: Work out how to capture "reset" button click in KSP and hook logic onto that.

Actual: If an experiment is reset, it disappears. Expect: experiment to be available for a re-run after reset. TODO: Work out how to capture "reset" button click in KSP and hook logic onto that.
mwerle commented 2017-11-25 20:43:40 +01:00 (Migrated from github.com)

Just found this which could be interesting:

Just found this which could be interesting: * [ExperimentsResultDialog](https://kerbalspaceprogram.com/api/class_k_s_p_1_1_u_i_1_1_screens_1_1_flight_1_1_dialogs_1_1_experiments_result_dialog.html) * [ExperimentResultDialogPage](https://kerbalspaceprogram.com/api/classexperiment_result_dialog_page.html)
mwerle commented 2019-04-07 18:29:41 +02:00 (Migrated from github.com)

And just worked this out (Found some code giving me the start here). Now we can disable the "Reset" button. Presumably we can also hook into the onButtonPressed event and do other stuff.

(Hooking into onButton: replace the event with our own callback, and then optionally call the original one)

        private bool isExperimentsResultDialogOpen = false;
        public override void OnUpdate()
        {
            base.OnUpdate();
            // check experiments result dialog has closed on this frame
            if (isExperimentsResultDialogOpen && ExperimentsResultDialog.Instance == null)
            {
                // Do stuff if it closed
            }
            if (ExperimentsResultDialog.Instance != null)
            {
                // check experiments result dialog has opened on this frame
                if (isExperimentsResultDialogOpen == false)
                {
                    // Do stuff if it just opened

                    ExperimentsResultDialog erd = ExperimentsResultDialog.Instance;
                    // TODO: Hook into callbacks?
                    // TODO: Ensure current page is for KEES!
                    if (erd.currentPage.pageData.subjectID.Contains("NE_KEES"))
                    {
                        UnityEngine.UI.Button[] buttons = erd.GetComponentsInChildren<UnityEngine.UI.Button>();
                        foreach (UnityEngine.UI.Button b in buttons)
                        {
                            // Disable the Reset and Lab buttons
                            if (b.name == "ButtonReset" || b.name == "ButtonLab")
                            {
                                b.interactable = false;
                            }
                        }

                        // This doesn't seem to do anything
                        //erd.currentPage.showReset = false;
                    }
                }
            }

            // update experiments result dialog open state
            isExperimentsResultDialogOpen = (ExperimentsResultDialog.Instance != null);
        }
And just worked this out (Found some code giving me the start [here](https://github.com/CYBUTEK/StoreMyReports/blob/master/StoreMyReports/StoreMyReports.cs)). Now we can disable the "Reset" button. Presumably we can also hook into the onButtonPressed event and do other stuff. (Hooking into onButton: replace the event with our own callback, and then optionally call the original one) ``` private bool isExperimentsResultDialogOpen = false; public override void OnUpdate() { base.OnUpdate(); // check experiments result dialog has closed on this frame if (isExperimentsResultDialogOpen && ExperimentsResultDialog.Instance == null) { // Do stuff if it closed } if (ExperimentsResultDialog.Instance != null) { // check experiments result dialog has opened on this frame if (isExperimentsResultDialogOpen == false) { // Do stuff if it just opened ExperimentsResultDialog erd = ExperimentsResultDialog.Instance; // TODO: Hook into callbacks? // TODO: Ensure current page is for KEES! if (erd.currentPage.pageData.subjectID.Contains("NE_KEES")) { UnityEngine.UI.Button[] buttons = erd.GetComponentsInChildren<UnityEngine.UI.Button>(); foreach (UnityEngine.UI.Button b in buttons) { // Disable the Reset and Lab buttons if (b.name == "ButtonReset" || b.name == "ButtonLab") { b.interactable = false; } } // This doesn't seem to do anything //erd.currentPage.showReset = false; } } } // update experiments result dialog open state isExperimentsResultDialogOpen = (ExperimentsResultDialog.Instance != null); } ```
mwerle commented 2019-06-25 18:38:05 +02:00 (Migrated from github.com)

Fixed by disabling the Reset button instead of allowing reset.

Fixed by disabling the Reset button instead of allowing reset.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ksp/NehemiahEngineeringOrbitalScience#8
No description provided.