Jump to content

[SOLVED] Small Plugin: Problems Upgrading to 1.1 Due To New UI


Recommended Posts

I have a problem with my plugin that produces two bugs (listed below) that I don't understand. I was hoping someone could help. It probably has something to do with that fact that I'm not clear on how to properly start/spawn/despawn/destroy/etc my plugin.

I've spent a couple days trying to solve the problems myself, but came up empty. Besides MATLAB, I'm not a coder so even if I've already seen the solution in the forum posts about updating plugins to 1.1 that I've been looking at, I might not have understood it well enough to realize that what I read was the solution to my problems:confused: I'll continue to look, but if someone could lead me in the right direction at least, that would be awesome.

What you will need to look at my code and test in game:

Problems (tested only in 64-bit KSP)

  1. The plugin seems to repeat itself three times.
    • Reproduce:
      1. Start career game (64-bit)
      2. Open R&D center
      3. Quit game (Exit KSP)
      4. Check output_log.txt in KSP_x64_Data folder
      5. Search for HETTN. Notice that the log outputs the same logs three times
  2. The plugin deletes/resets Active and Completed contracts in the Mission Control Center. My plugin doesn't touch anything in the Mission Control Center, so I don't know what's going on here. I'm probably not calling or destroying something correctly.
    • Reproduce:
      1. Start career game (64-bit)
      2. Open Mission Control Center
      3. Accept some missions
      4. Confirm missions are in the Active tab
      5. Do any of the following (basically anything that requires loading a new scene):
        • Return to Main Menu, then return to career game
        • Go to VAB/SPH or Tracking Center, then return to KSC
        • Load a quicksave
        • Launch rocket or plane by clicking directly on launch pad or runway, then recover vessel
      6. Open Mission Control Center
      7. Notice that the Active tab is empty!

Explanation of code

My plugin simply takes the tech tree nodes in the R&D center, reads values of each node, and hides any nodes with no parts in them. It then reassigns the parents of nodes that do have parts in them, so that they are not connected to a now hidden node. It also increases how far you can zoom out in the R&D center.

My plugin is just two classes that I made called "changeScrollZoom" and "changeTheParents". They use the KSP classes RDGridArea, RDNode, and RDTechTree located in Assembly-CSharp -> KSP.UI.Screens (in 1.0.5, they were just located in Assembly-CSharp).

  • RDTechTree loads the tech tree node values (or is a list, or something like that)
  • "changeScrollZoom" uses RDGridArea. It simply reassigns some values for how far you can zoom out in the R&D center.
  • "changeTheParents" uses RDNode. It reads certain values for each node, and changes them if certain conditions are met.

Possible sources of problems 

The problem most likely lies within the parts before I define "changeScrollZoom". The lines that are commented out there are things that I have tried, but they did not fix the problem. Other things to note:

  1. I have no idea what KSP classes to use to call my classes, and how to spawn/despawn/destroy/etc properly.
  2. The Awake() class in RDTechTree I think is new to 1.1. My currently use of Awake() may be the source of the errors.

NOTE: The code as is works in 1.0.5, except it would probably help to delete "using KSP.UI.Screens;".

Thanks for ANY help (or coding advice)!!

Edited by ev0
Updated reproduction steps for problem 2
Link to comment
Share on other sites

I solved the first problem. I had my source code in the GameData folder (as I've seen others do before), and they have two extra copies of my plugin's .dll inside. So that's why it was repeating itself three times.

If anyone can help with the second problem, I'm sure it has something to do with proper usage of the GameEvents.onGUIRnDComplexSpawn class?

Edited by ev0
Link to comment
Share on other sites

Ugh, I solved my second problem. Apparently deleting that source folder also allowed my original code to work, minus adding the KSP.UI.Scenes namespace.

Apparently when all the .dlls in that source file were loaded, there were some incompatible ones that caused the problem.

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...