Jump to content

Romfarer

Members
  • Posts

    522
  • Joined

  • Last visited

Reputation

108 Excellent

1 Follower

Profile Information

  • About me
    Developer

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Editor Toolbar Modding Guide: The editor toolbar runs of the class PartCategorizer. Each button on the toolbar is handled by the class PartCategorizer.Category and the actual button is a PartCategorizerButton. There are a myriad of ways to customize your custom filters using these classes but for simplicity i have added two static methods to PartCategorizer which simplifies the process of adding custom filters. How to add a simple custom filter: The following code example explains how to add a simple custom filter. //instantiate the icon Icon myIcon = new PartCategorizer.Icon("my icon", iconTexture_normal, iconTexture_selected); //add a custom filter to the toolbar Category myFilter = PartCategorizer.AddCustomFilter("my filter", myIcon, Color.yellow); //add subcategories to the filter you just added PartCategorizer.AddCustomSubcategoryFilter(myFilter, "filter 1", myIcon, p => p.name.Contains("engine")); PartCategorizer.AddCustomSubcategoryFilter(myFilter, "filter 2", myIcon, p => p.name.Contains("fuel")); PartCategorizer.AddCustomSubcategoryFilter(myFilter, "filter 3", myIcon, p => p.name.Contains("wing")); Lets break it down "line by line" Icon myIcon = new PartCategorizer.Icon("my icon", iconTexture_normal, iconTexture_selected); and the signature... /// <summary> /// Constructor for Icon /// </summary> /// <param name="name">The identifier of the icon</param> /// <param name="iconNormal">The "normal" state of the icon</param> /// <param name="iconSelected">The "selected" state of the icon</param> /// <param name="simple">If true you only have to specify the selected state of the icon. A black "normal" state will be generated automatically.</param> public Icon(string name, Texture iconNormal, Texture iconSelected, bool simple = false) Icons are instantiated using the PartCategorizer.Icon class. It's signature is Icon(string name, Texture iconNormal, Texture iconSelected, bool simple = false). "name" is not really important when instantiating the icons via code like this. But if you had loaded the icon by placing it in GameData\Squad\PartList\SimpleIcons or Icons this would be the identifier used to retrieve the icon with PartCategorizer.Instance.GetIcon("myIcon"); That said you can choose wether to instantiate the icon by code (leaving it for your button only) or put it in those folders and make it available for everyone to use on their custom categories. static public Category AddCustomFilter(string filterName, Icon icon, Color colorButton) and the signature... /// <summary> /// Adds a filter to the "right side" toolbar list. /// </summary> /// <param name="filterName">The name of the filter which will appear on the tooltip</param> /// <param name="icon">The icon for the button</param> /// <param name="colorButton">The color of the button</param> /// <returns>A reference to the Category wrapper</returns> static public Category AddCustomFilter(string filterName, Icon icon, Color colorButton) The signature is pretty much self explanatory. PartCategorizer.AddCustomSubcategoryFilter(myFilter, "filter 1", myIcon, p => p.name.Contains("engine")); and the signature... /// <summary> /// Adds a filter subcategory to the given filter which will appear on the right side of the toolbar /// </summary> /// <param name="mainFilter">The filter (Category) you are adding this filter to</param> /// <param name="subFilterName">The name of the filter which will appear on the tooltip</param> /// <param name="icon">The icon for the button</param> /// <param name="exclusionFilter">Lambda expression which specifies which parts to show when this filter is active</param> /// <returns>A reference to the Category wrapper</returns> static public Category AddCustomSubcategoryFilter(Category mainFilter, string subFilterName, Icon icon, Func<AvailablePart, bool> exclusionFilter) This is almost the same as the method to add a main filter. Except the exclusionFilter which is the whole point of the filter. In this simple example i have specified the expression p => p.name.Contains("engine"). All this does is filter out all parts where "engine" appears in the part name. "p" is a reference to AvailablePart and you can use any of it's fields to filter parts. Some additional examples: p => p.moduleInfos.Exists(q => q.moduleName == "Parachute") This will filter out all parts that has a partModule called "Parachute". p => p.resourceInfos.Exists(q => q.resourceName == "Liquid Fuel") This will filter out all parts containing "Liquid Fuel". p => p.manufacturer == "Probodobodyne Inc" This will filter out all parts made by Probodobodyne Inc. When to add custom filters: The editor toolbar is ready to receive custom filters when this GameEvent is fired. GameEvents.onGUIEditorToolbarReady How to add auto generated filters: You may also want to make filters in a more automated way. //instantiate the icon Icon myIcon = new PartCategorizer.Icon("my icon", PartCategorizer.Instance.fallbackIcon.iconNormal, PartCategorizer.Instance.fallbackIcon.iconSelected); //add a custom filter to the toolbar Category myFilter = PartCategorizer.AddCustomFilter("my resource filter", myIcon, Color.yellow); //Get a unique list of available resources List<String> resources = new List<string>(); foreach (AvailablePart ap in PartLoader.LoadedPartsList) foreach (AvailablePart.ResourceInfo apr in ap.resourceInfos) if (!resources.Contains(apr.resourceName)) resources.Add(apr.resourceName); foreach (string str in resources) { string myResourceName = str; //It is imperitive to declare this //add subcategories to the filter you just added PartCategorizer.AddCustomSubcategoryFilter(myFilter, "filter by " + myResourceName, myIcon, p => p.resourceInfos.Exists(q => q.resourceName == myResourceName)); } This is basically the same code we use to generate the stock resource filter and it filters parts by the resource it holds. Keep in mind, when you generate filters like this, it is important to declare the myResourceName string within the for loop.
  2. All plugins updated for 0.90 compatibility enjoy
  3. Ok the issue here is that the Application Launcher hides itself in GameEvents.onGameSceneLoadRequested as well. In 0.25 i'm therefore adding a second level event which will fire just before the Application Launcher is about to become !Ready. The event looks like it will be called GameEvents.onGUIApplicationLauncherUnreadifying and it will send with it the GameScene it is about to enter just like onGameSceneLoadRequested.
  4. Never seen that bug before. How does it affect the lazor gui?
  5. Please send me a persistence or save file with a little description of what exactly you have to do to reproduce this bug.
  6. If you can't see the texture you have to send me your log so i can figure out why it's not loading properly...
  7. Should work fine afaik, been playing around with it a bit myself lately testing some experimental planes. I flew around kerbin in this plane http://i.imgur.com/5Rk0BrP.png
  8. I see your point and it is a fair one. But i can't just revert it back to allowing timewarp at extended loading distances cause in my opinion that creates move havoc. So i guess the only option is to run a check for vessels that would be destroyed by activating timewarp and alerting the player about it.
  9. @montyben101 I'm having problems seeing what exactly causes the bug you are experiencing. From what you have said it involves the robotic arms, grabbing a kerbal on eva and not being able to recover. It's not much to go on.
  10. I'm confused. The extended loading range of my plugin sure adds stress on the engine and it is to be expected, after all there is a good reason why the loading range was set the way it is within the game. It was never the goal of my plugin to destroy any crafts or kerbals automatically, but sure, careless use of it will in some cases bring havoc where you don't expext it.
  11. Ok guys, i have updated the documentation for the application launcher. Let me know if you have any questions. Suggestions are always welcome.
  12. Timewarping within the atmoshere makes extra stress on your own craft as im sure you have noticed. Imagine the stress on vessels far away.
  13. What you should do is this, when starting up: check if ApplicationLauncher.Ready. If it is not ready just subscribe to the event GameEvents.onGUIApplicationLauncherReady. The applauncher starts up when you transition into space center from mainmenu and is destroyed when you exit to mainmenu. And it is Ready when it becomes alive in a scene, it becomes !Ready when you transition into a new scene. But of course, it's probably going to work even it it's not Ready, feel free to experiment and let me know what you discover ;-) More details will follow as i edit this thread.
×
×
  • Create New...