-
Posts
522 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by Romfarer
-
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.
-
All plugins updated for 0.90 compatibility enjoy
-
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.
-
Never seen that bug before. How does it affect the lazor gui?
-
Please send me a persistence or save file with a little description of what exactly you have to do to reproduce this bug.
-
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...
-
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
-
Not anytime soon.
-
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.
-
@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.
-
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.
-
Ok guys, i have updated the documentation for the application launcher. Let me know if you have any questions. Suggestions are always welcome.
-
Timewarping within the atmoshere makes extra stress on your own craft as im sure you have noticed. Imagine the stress on vessels far away.
-
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.
-
Hmmm, what links?
-
First of all im going to need you to send me your output_log.txt. A description of what is happening when would also help greatly. Also, have you downloaded and installed version 34 of lazor?
-
In case you have tried adding your mod to the application launcher, please post your feedback here.
-
If you want to play with fire, rip "random" parts out of my source code, put it together in a plugin and see what happends In all honesty, i'm not going to "prosecute" you for taking a few lines out of my code and making it into a plugin, people have done this for a long time now. Just be aware that there is a good chanse those few lines require a whole lot of other stuff that is not so easy to see just by looking at the code. It is true that lazor resets the loading distances to default when timewarping and automatically restores your setting once timewarp is disengaged. The reason is quite simple: Say you have 10 vessels landed on the surface somewhere, you have a lazor enabled craft in orbit within the set loading distance from the landed vessels. If you then timewarp at max timewarp you will then rapidly load and unload those vessels every time you make a pass. This will eventually lead to a crash because the engine can't handle loading and unloading that fast.
-
Ok I made some changes to the plugin loading now and textures should be loading properly. Let me know.
-
Please send me your log file.
-
All plugins should now be 0.24 compatible. Enjoy Changelog v34 (July 22): All plugins: 0.24 Compatibility
-
The Application Launcher or applauncher is one of the new GUI features for KSP 0.24. This GUI is supposed to work as a toolbar for stock apps/widgets and mods. Subsequently it is divided into two lists separated with a border. On the right hand you have the stock ksp apps and on the left hand you have the mod apps. The list of mod applications is a little bit different from the stock list in the sense that it is able to hold as many mods as you want. Therefore it will also rest at a fixed size when the list gets to big for the gui. When this happens it will become scrollable. By design the stock apps are also mutually exclusive: only one app can stat visible at any given time. It is possible to make your mod share this behaviour. The details follows below. The goal of this guide is to explain how to use the applauncher with your mod. Requirements: In order to be able to use the applauncher in your mod you must include Assembly-CSharp-firstpass.dll when building your project. It is located in the same folder the regular ksp dll is in and you should already be familiar with how to include it. The reason is because we allow for animated buttons and they require a class which is located in that library. Add your mod to the applauncher: First of all you retrieve the applauncher instance with the static flag ApplicationLauncher.Instance. There are two methods to use for adding a mod to the applauncher: /// <summary> /// Add a MOD(3rd party) application to the Application Launcher. Use ApplicationLauncherButton.VisibleInScenes to set where the button should be displayed. /// </summary> /// <param name="onTrue">Callback for when the button is toggeled on</param> /// <param name="onFalse">Callback for when the button is toggeled off</param> /// <param name="onHover">Callback for when the mouse is hovering over the button</param> /// <param name="onHoverOut">Callback for when the mouse hoveris off the button</param> /// <param name="onEnable">Callback for when the button is shown or enabled by the application launcher</param> /// <param name="onDisable">Callback for when the button is hidden or disabled by the application launcher</param> /// <param name="visibleInScenes">The "scenes" this button will be visible in. For example VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW;</param> /// <param name="texture">The 38x38 Texture to use for the button icon.</param> /// <returns></returns> public ApplicationLauncherButton AddModApplication(RUIToggleButton.OnTrue onTrue, RUIToggleButton.OnFalse onFalse, RUIToggleButton.OnHover onHover, RUIToggleButton.OnHoverOut onHoverOut, RUIToggleButton.OnEnable onEnable, RUIToggleButton.OnDisable onDisable, ApplicationLauncher.AppScenes visibleInScenes, Texture texture) and /// <summary> /// Add a MOD(3rd party) application to the Application Launcher. Use ApplicationLauncherButton.VisibleInScenes to set where the button should be displayed. /// </summary> /// <param name="onTrue">Callback for when the button is toggeled on</param> /// <param name="onFalse">Callback for when the button is toggeled off</param> /// <param name="onHover">Callback for when the mouse is hovering over the button</param> /// <param name="onHoverOut">Callback for when the mouse hoveris off the button</param> /// <param name="onEnable">Callback for when the button is shown or enabled by the application launcher</param> /// <param name="onDisable">Callback for when the button is hidden or disabled by the application launcher</param> /// <param name="visibleInScenes">The "scenes" this button will be visible in. For example VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW;</param> /// <param name="sprite">The 38x38 PackedSprite animation to use for the button icon. Use ApplicationLauncherButton.PlayAnim() to play the animation.</param> /// <returns></returns> public ApplicationLauncherButton AddModApplication(RUIToggleButton.OnTrue onTrue, RUIToggleButton.OnFalse onFalse, RUIToggleButton.OnHover onHover, RUIToggleButton.OnHoverOut onHoverOut, RUIToggleButton.OnEnable onEnable, RUIToggleButton.OnDisable onDisable, ApplicationLauncher.AppScenes visibleInScenes, PackedSprite sprite) As you can see the only difference is in the last parameter Texture texture vs PackedSprite sprite. The first one is for textures and you should already be familiar with it. The second is for animations. Both of these are sized at 38x38 pixels. The callbacks listed are used mainly for showing and hiding the gui associated with the applauncher button. You can safely set most of them to null but you should at least define a delegate for the onTrue and onFalse callbacks. Note that the visibleInScenes is a reference to the [system.Flags] ApplicationLauncher.AppScenes and it has the following options: NEVER, SCPACECENTER, FLIGHT, MAPVIEW, VAB, SPH, ALWAYS. You can make your mod button display on the application launcher automatially by setting this. For example: VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.SPACECENTER; This will make your button show in flight and in the spacecenter. It is also possible to handle the hiding and showing of your mod button manually if you really want to. To pull this off you need to manually listen to other ksp events, the most important one being GameEvents.onGameSceneLoadRequested. This is fired at the point when applauncher becomes !Ready. Remove your mod from the applauncher: Removing an app from the applauncher is a lot easier than adding. Simply keep a reference to your button and make the following method call. ApplicationLauncher.Instance.RemoveModApplication(ApplicationLauncherButton button) When to add it: Applauncher becomes alive and is running when going from mainmenu to spacecenter. It has a static flag ApplicationLauncher.Ready which indicates when it is ready to receive add/remove commands. The event GameEvents.onGUIApplicationLauncherReady will fire when this happens. Applauncher will destroy itself when exiting to the mainmenu. GameEvents.onGUIApplicationLauncherDestroyed will be fired when this happens. If you are using applauncher with a mod that uses a partless loader, for example by adding this attribute to your class: [KSPAddon(KSPAddon.Startup.MainMenu, true)]. It is important that you listen to both events and re-add your button when necessary. Applauncher callbacks: If you want to use the application launcer in multiple scenes AND OR only in the space center scene you should also subscribe to the following events to make your mod gui hide with the launcher. These events are fired when the application launcher shows/hides itself. You can also pull this off by making the transform of your mod gui a child of the applauncher. AddOnShowCallback(OnShow del) RemoveOnShowCallback(OnShow del) AddOnHideCallback(OnHide del) RemoveOnHideCallback(OnHide del) All of these delegates have no parameters. If you use some form of "docking" (positioning your mod gui directly below the applauncher) for your mod gui you may also want to subscribe to the following events: AddOnRepositionCallback(OnShow del) RemoveOnRepositionCallback(OnShow del) This is usefull because the applauncher shows up in the bottom right position in the VAB/SPH. These callbacks are fired when it reposition and there is also a flag (IsPositionedAtTop) you can check to figure out where it is positioned. You can determine what position your gui should take by using the position field on the transform of your modApplicationButton, some trial and error is manditory. Also keep in mind that when the list of mod buttons in applauncher gets big it will become scrollable and depending on where your button is in the list, it is likely that it will be completely hidden at some points so it is reccommended to have the gui at a static position. Make your mod app mutually exclusive along with the stock KSP apps: In KSP 0.24.1 i added two methods you can use to make your mod mutually exclusive along with the stock KSP apps. This means that only one app can be visible at any given time. It makes use of the onTrue, onFalse, onHover and onHoverOut callbacks, so it is important that you subscribe to those callbacks if you want to use this feature. The methods are as follows: public void EnableMutuallyExclusive(ApplicationLauncherButton launcherButton) public void DisableMutuallyExclusive(ApplicationLauncherButton launcherButton) Advanced use: It is possible to hijack ksp stock buttons by taking over all the delegates in them or by getting a reference to the button and replacing it with your own. If you take the latter approach it is however likely that you will modify the order the stock apps are displayed in. //Get the buttons like this ApplicationLauncherButton button = ResourceDisplay.Instance.appLauncherButton; ApplicationLauncherButton button = ContractsApp.Instance.appLauncherButton; ApplicationLauncherButton button = MessageSystem.Instance.appLauncherButton; //Then make sure the app you want to take over is hidden or disabled. Just call: button.onDisable(); //take over the delagates like this button.toggleButton.onTrue = yourDelegate; button.toggleButton.onFalse = yourDelegate; button.toggleButton.onHover = yourDelegate; button.toggleButton.onHoverOut = yourDelegate; button.toggleButton.onEnable = yourDelegate; button.toggleButton.onDisable = yourDelegate; Keep in mind that there are probably parts of the code that will mess things up for you if you try to take over the button like this. For example the delegates used to hide and show the app when the applauncher shows so all in all you might just want to remove the button and replace it with your own, after all the system was not intended to be used like this. But do let me know how this works out. The currency widget app uses a slightly different system so it doesn't have a reference to the button atm. I wanted to include that and refactor a lot of other parts of the code but it will require testing to make sure it's stable and there simply wasn't time in this update. Finally, the Application Launcher will most likely get updates in the coming versions. Suggestions are most welcome.
-
The texture issue on mac should be fixed in the next version. This texture issue also effects the custom explosion effects and that's why you see white boxes. So in the next KSP update Lazor should actually be ready "on time" since i've been using it to test the new Application Launcher which is one of the systems i'm working on. I'm not sure if you have seen it but it's like a toolbar where you can add application buttons so everything is organized in one place, rather than having a lot of mod launch buttons overlapping eachother.
-
I just uploaded the correct files... Well spotted, thanks
-
Lazor will support the new stock toolbar which will come in the next version of KSP. Thanks for the report, i'll make sure to change the format of this file for the next update. Also Lazor System and all my mods are now on curse. Here -> http://www.curse.com/plugins/kerbal/220271-lazor-system All my mods are here btw.... -> http://www.curse.com/users/Romfarer