Sign in to follow this  
FreeThinker

Removing Resources in KSP 1.7.1

Recommended Posts

Posted (edited)

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

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

@FreeThinker You might look at the changes @Snark had to do in the latest release of his Simple Fuel Switch. It sounds like the same problem you are running into. 

This is where I reported the bug for you to see if it the same kind of problem.

 

Share this post


Link to post
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;
                }
            }
        }

 

Share this post


Link to post
Share on other sites

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.

Sign in to follow this