Project

General

Profile

Feedback #21829

API Request - How to intercept/control the "Science Results" window

Added by micha over 5 years ago.

Status:
New
Severity:
Low
Assignee:
-
Category:
Plugins/Add-Ons
Target version:
-
Version:
Platform:
Linux, Windows
Expansion:
Core Game
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

It would be nice if Mods could intercept, or at least be notified of, events happening with the "Science Results" window.

There's currently no event for when it opens (unlike various other Dialogs).

There's no events for when the user clicks on any of the buttons (that I've discovered).

There's no (easy) way to disable some of the buttons.

It would be great if any/all of the above could be added to the API so that a mod can perform some custom processing depending on user action.

Incidentally, I've finally figured out a way to hook into it programmatically, but it requires polling on every frame as well as Part introspection to access the Buttons. Not ideal, but my limited testing so far does imply that this request is not necessary, just "nice to have".

eg:

void OnExperimentResultDialogOpened(ExperimentsResultDialog erd)
{
    // We want to block the reset button
    erd.resetButtonEnabled = false;

    // NB: This actually sortof exists in the API, but doesn't appear to do anything..
    // erd.currentPage.showReset = false;
}

void OnExperimentResultResetClicked(ExperimentsResultDialog erd)
{
  // Check if the current page is for my experiment, if so, return it.
  // (Bonus points if there's some way to register the callback only for the experiment(s) I'm interested in)
  MyExperiment exp = getMyExperimentFromResultWindow(erd.currentPage);

  // Do some custom resetting
  exp?.doReset(); != null ) {
}

The ExperimentsResultDialog.onButtonClicked() handler should then do something like:

void onClicked()
{
  for( all registered event handlers "eh" )
  {
    call(eh);
  }
  // Do my default processing
}

Also available in: Atom PDF