Jump to content

Removing Resources in KSP 1.7.1


Recommended Posts

Before KSP 1.7.1 it used to work to either call part.RemoveResource()  or part.Resources.Remove or part.Resources.Clear() to remove a resource. Although the call itself removes the part.resources list, it is not removed from the visual representation in the context menu, almost as if it isn't properly updated or refreshed. Notice that once you close the context menu and reopen it, the removed resource it correctly removed, telling me this is clearly some gui refresh issue. Anyone have an idea to refresh of removed the resoures from the part context menu

Edited by FreeThinker
Link to comment
Share on other sites

10 hours ago, pap1723 said:

Don't know if you have your answer already, but I was told that the dirty Window call has been changed so you have to approach it differently to get an update. 

No not yet. I was aware it had something to do with the window dirt state. In the past, it did  try to get access to it but this handle through reflection bit it no longer appears to work. Would you know how?

Link to comment
Share on other sites

Alright I found the  solution:

        private void UpdatePartActionWindow()
        {
            var window = FindObjectsOfType<UIPartActionWindow>().FirstOrDefault(w => w.part == part);
            if (window != null)
            {
                foreach (UIPartActionWindow actionwindow in FindObjectsOfType<UIPartActionWindow>())
                {
                    if (window.part != part) continue;
                    actionwindow.ClearList();
                    actionwindow.displayDirty = true;
                }
            }
        }

 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...