Jump to content

[1.12.x] Filter Extensions, no Localization for now


linuxgurugamer

Recommended Posts

Originally written by @Crzyrndm, he is not active and gave permission for me to continue this.  Original thread is here:  https://forum.kerbalspaceprogram.com/index.php?/topic/93955-130-filter-extensions-304-jul-11/

Release is here:

With the stock editor now supporting custom filters in a reasonable way, creating more and better filters is the next logical step. However, the requirement for categories to be managed via code is just a terrible idea. Not to mention that there is no easy way to be compatible with anyone else. Filter Extensions allows the usage of .cfg files to create, edit, or delete all categories and sub-categories. It uses standard config files allowing for patches to be applied and dependencies allowed for using Module Manager.

Github - https://github.com/linuxgurugamer/FilterExtension

Downloadhttps://github.com/linuxgurugamer/FilterExtension/releases

It will be available on CKAN when I do a full release, probably on Sunday

License:
Icons and configs distributed with FE are under CC-BY-SA 4.0
Plugin is covered by GPLv3.

sBqMgMx.jpg
 

Configs and Icons

Configs and icons contributed by users are distributed with the download. Think something is missing and you can fill the gap? Just send the cfg's or icons my way :wink:

Docs are in the Filter Extensions Wiki

Spoiler
CATEGORY:NEEDS[B9_Aerospace]
{
    // Normal stuff: name, icon, colour, etc.
    name = B9 Aerospace
    icon = B9_Aerospace
    colour = #FFF0F0F0
    all = true
    // type = engine, stock <-- valid types. Engine will add subcategories of all engine variants (based on propellant combinations). stock must be specified to edit stock categories
	// value = replace <-- only valid value, only used with stock types
    // This is the template to be added to subcategories in this category. Subcategories in this category require parts to match one of the category Filters as well as their own unless using the "dont template" key
    FILTER
    {
        CHECK
        {
            type = folder
            value = B9_Aerospace
        }
    }
      // This is the subcategories listed by name. The number is the order they will appear in
    SUBCATEGORIES
    {
        list = 0,Pods
        list = 1,Fuel Tanks
        list = 2,Engines
        list = 3,Command and Control
        list = 4,Structural
        list = 5,Aerodynamics
        list = 6,Utility
        list = 7,Science
        list = Undefined // subcategories listed without an index will be added after all other subcategories are accounted for
        list = Undefined, dont template // the key "dont template" as the final element tells the subcategory to not use any of the category filters
	}
}

CATEGORY
{
	name = Filter by Function
	type = stock // If this isn't present it will go and make a new category
	value = replace
	// Tells it to clear all existing subcategories and completely redefine the subcategories present. If not used, the listed subcategories 
	// will just be added to the end of the list. Refer to the first spoiler for details on templating and addressing subcategories.
	// It's all the same
}

 


SUBCATEGORY
{
	// Same stuff as v1.x, but the category is no longer specified
	name = Air Intake
	icon = AirIntake
	FILTER
	{
		CHECK
		{
			type = moduleName
			value = ModuleResourceIntake
		}
	}
}
FilterRename
{
	name = LiquidFuel/Oxidizer, Rockets // name = <originalName>, <newName>
	name = ElectricCharge/XenonGas, Ions
	name = IntakeAir/LiquidFuel, Jets
	name = SolidFuel, SRBs
	name = MonoPropellant, MonoProp
}
FilterSetIcon
{
	icon = Rockets, EngineLFO // icon = <subCategoryName>, <iconName>
	icon = Ions, EngineIon
	icon = Jets, EngineJet
	icon = SRBs, EngineSolid
	icon = MonoProp, EngineMono
}
FilterRemove
{
	remove = subcategoryName
}

 

 

 

 

Some additional explanation of the cfg structure

Spoiler

All the things that make changes are in subdirectories of this folder. The "default" subdirectory is the one containing all the additions to Filter by Function, the rework folder has a different setup for the stock subcategories. All of the extra categories are individual .cfg's inside the "default" subdirectory. If you don't want it, delete it. The additional subcategories in Filter by Function are in the StockCategories.cfg (along with the improved cross section and resources categories) The replacement subcategories in Filter by Function are here. Just remove that folder if you want the stock layout

Filter Extensions uses two root config node types, CATEGORY and SUBCATEGORYCATEGORY nodes set category name, icon, colour of its subcategories, which subcategories are present and in what order, and can restrict what parts show up in their subcategories using the same syntax as the FE subcategoriesSUBCATEGORY nodes do most of the work wrt which parts are actually visible. They only have 4 possible entries: name and icon, "showUnpurchased" to override the plugin setting, and a set of FILTER nodes which decide which parts are visible. The subcategories are referenced by name when setting up a category and can be added to as many categories as you like.

tl;dr Once you have the name of a subcategory, just add it to the category of choice with a unique position (between 0 and 999. Duplicates will overwrite each other) and enjoy (NOTE: No position also works, it just gets added to the end of the list)

Writing a set of FILTER nodes to get the parts you want: Using the Electric Charge subcategory as an example, what I was aiming to do was improve on the stock Filter by Resource EC category by removing all the parts that often have a capacity of no significance (eg. engines with an alternator have one because of how the stock resource generation works, but that doesn't help the player looking for a battery)

The parts I wanted must have storage for the resource Electric Charge and must not be a part that only has EC storage as buffer (through experimentation this was determined to be engines, command modules, and generators) If you're familiar with any programming languages, that would typically be expressed something like this


result = hasResource("ElectricCharge") && !hasModule("ModuleCommand" || "ModuleEngines" || "ModuleGenerator");

Each CHECK node contains a single condition a part must pass to be visible. Each FILTER contains one set of conditions. If a part passes all the conditions in a FILTER, it will be visible.
Multiple FILTER nodes can be used when required (eg. Manned Command, the KerbalSeat module doesn't have a crew capacity of one or more so it needs to be checked for separately), although the comma separated lists have made that quite rare now

The majority of check types are listed in the first post, and I'll probably get some time this weekend to put together at least a full listing of them (alternatively, check the code that handles the type)

 

Using Near Future Propulsion's Argon Gas resource as an example

To remove a subcategory that you don't want to show, only specify the category (Filter by /*Insert here*/) and the title shown ingame for the offending subcategory

 

 
SUBCATEGORY
{
	category = Filter by Resource
	oldTitle = Argon Gas
}

 

To change the icon and title displayed, use the keys title and icon.

 

 
SUBCATEGORY
{
	category = Filter by Resource
	title = Wheels
	oldTitle = Argon Gas
	icon = R&D_node_icon_fieldscience

}

 

 

 

 

Acknowledgements
stupid_chris
 through RealChute which I originally used as a template. Getting started would have been much more difficult without that reference.
Nertea for the idea of the icon auto-loader
KaiserSoze - Adapting many icons, sharing configs, and reporting bugs

Mod icons are mostly adaptions of:

  • Part Catalog icons - originally by BlackNecro
  • Flags, manufacturer icons, and toolbar icons included with a mod. You can find links to the mods for all included icons here

To everyone that has contributed icons and/or cfg's to make others life easier - Your generosity is sincerely appreciated

Reporting Bugs

There are two types of bugs, so depending on what your problem is, there are different steps you may need to follow

Exceptions: Red text in the alt+f2 log, functionality breaks down completely, etc.
I need the information specified here

Functional issues: If the log shows no errors, then I need

  • The config you were trying to use
  • The mod that this applies to
  • A description of the expected behaviour
  • A description of the behaviour experienced
Edited by linuxgurugamer
Link to comment
Share on other sites

Note that in the new beta will be a lot of changes and some of the stuff i copied isnt gonna work!
I copied that from the old threat, from Targa who postet this on page 22:
Found this helpful to create your own filter extensions categories.

TAC Life Support cfgs

This is what I did to create a new VAB/SPH Filter by Function category named "Life Support", place all the TAC-LS parts in it, and remove the TAC-LS parts from the Utility category. You're free to mess around with your own config files if you want something different from Filter Extensions.

Step 1: Download and install Filter Extensions mod. This should give you 2 folders. One named 000_FilterExtensions and another one named 000_FilterExtensions Configs.

Step 2: In the 000_FilterExtensions Configs folder, delete the subfolder named StockRework.

Step 3. In the 000_FilterExtensions Configs folder, open the file named FilterByFunction.cfg with Notepad or similar text editor. Add another line reading: list = 8,Life Support. It should look like the code below:

FilterByFunction.cfg - adds a new category named "Life Support"

Spoiler

CATEGORY
{
    name = Filter by Function
    type = stock
    value = replace

    SUBCATEGORIES
    {
        list = 0,Pods
        list = 1,Fuel Tanks
        list = 2,Engines
        list = 3,Command and Control
        list = 4,Structural
        list = 5,Aerodynamics
        list = 6,Utility
        list = 7,Science
        list = 8,Life Support
    }
}

Step 4: In the 000_FilterExtensions Configs folder, open the file named SubCategories_Stock.cfg. Scroll down until you find the line "name = Utility". In this section add a check for Life Support and TACLS title. The code of that part should look like this:

Subcategories_Stock.cfg - Removes TAC-LS parts from the Utility category

Spoiler

SUBCATEGORY
{
    name = Utility
    icon = stockIcon_utility

    FILTER
    {
        CHECK
        {
            type = title
            value = Life Support, TACLS
            invert = true
        }
        CHECK
        {
            type = category
            value = Utility
        }
    }
}

Step 5: In the 000_FilterExtensions Configs folder, create a new text document named Subcategories_LifeSupport.cfg, paste the following code into it and save:

Subcategories_LifeSupport.cfg - Adds all TAC-LS parts to the new Life Support filter by function category

Spoiler

SUBCATEGORY
{
    name = Life Support
    icon = StorageLS
    FILTER
    {
        CHECK
        {
            type = title
            value = Life Support, TACLS
        }
    }
}

Enjoy a spam-free Utility tab in the VAB/SPH!

Universal Storage parts for life support can also be added to these filters. If you wish to move them to the Life Support tab and remove them from the Utility tab, change the following two files that you've already edited to this:

Spoiler

SUBCATEGORY
{
    name = Utility
    icon = stockIcon_utility

    FILTER
    {
        CHECK
        {
            type = title
            value = Life Support, TACLS, water, supplies, oxygen, food, waste, CarbonDioxide
            invert = true
        }
        CHECK
        {
            type = category
            value = Utility
        }
    }
}

Subcategories_LifeSupport.cfg

Spoiler

SUBCATEGORY
{
    name = Life Support
    icon = StorageLS
    FILTER
    {
        CHECK
        {
            type = title
            value = Life Support, TACLS, water, supplies, oxygen, food, waste, CarbonDioxide
        }
    }
}

 

Edited by JohnMcLane
Link to comment
Share on other sites

I've been getting a lot of help from one person, @flart, who has been extremely helpful.

But he and I can't do it alone.  If I don't get anybody else testing, then I'll end up releasing something which will have problems, and everyone will get frustrated.

The localization of this mod is a real mess and a big pain, the more eyes which look at it, the better

Link to comment
Share on other sites

@linuxgurugamer The localisation is messing up many of the SUBCATEGORY entries (e.g. parachutes, launch clamps and many others). The problem seems to be that when the "name = fe_*" line gets localised it breaks the references in the CATEGORY blocks. Example in spoiler

Spoiler

Original category definition: https://github.com/linuxgurugamer/FilterExtension/blob/master/GameData/000_FilterExtensions_Configs/Default/04_Structural.cfg#L16

Original subcategory definition: https://github.com/linuxgurugamer/FilterExtension/blob/master/GameData/000_FilterExtensions_Configs/SubCategories_Structural.cfg#L72-L84

From my ModuleManager.ConfigCache showing post localisation values:


UrlConfig
{
	name = Structural Parts
	type = CATEGORY
	parentUrl = 000_FilterExtensions_Configs/Default/04_Structural
	url = 000_FilterExtensions_Configs/Default/04_Structural/Structural Parts
	CATEGORY
	{
		name = Structural Parts
		icon = StructuralParts
		colour = #FF90F090
		all = true
		SUBCATEGORIES
		{
			list = 0, fe_adapter
			list = 1, fe_multicoupler
			list = 2, fe_decouplers
			list = 3, fe_dockingPorts
			list = 4, fe_strut
			list = 5, fe_girder
			list = 6, fe_launchclamp
			list = 7, fe_ladders
		}
	}
}


UrlConfig
{
	name = Launch Clamp
	type = SUBCATEGORY
	parentUrl = 000_FilterExtensions_Configs/SubCategories_Structural
	url = 000_FilterExtensions_Configs/SubCategories_Structural/Launch Clamp
	SUBCATEGORY
	{
		name = Launch Clamp
		icon = LaunchClamp
		FILTER
		{
			CHECK
			{
				type = moduleName
				value = LaunchClamp, ExtendingLaunchClamp
			}
		}
	}
}

 

 

Suggestion - add a displayName field to CATEGORY and SUBCATEGORY for display in the GUI and apply localisations to that field with keys that don't clash with the names.

 

Link to comment
Share on other sites

@-MadMan-@Aelfhe1m, and anybody else:

I reverted back to the version before I started the localization and went at this a different way (ie: using a new field displayName).  This has the advantage of keeping compatibility with the pre-localized versions, so that any changes I do to the files themselves will work in the old version.

Please try this out and let me know how it goes:

 https://jenkins.spacetux.net/job/A-F/job/FilterExtension/lastSuccessfulBuild/artifact/000_FilterExtensions-original-3.1.0.6.zip

Link to comment
Share on other sites

@linuxgurugamer That latest build (#51) seems to have fixed all the issues with categories and sub-categories (at least in en-us :wink:). But the filter by manufacturer tab has reverted to stock behaviour rather than showing buttons per mod folder (the config setting has no effect either). This may be related to the following message in the log:

Quote

[Filter Extensions 3.0.1]: No category of this name was found to manipulate: lgg0 Filter by Manufacturer

 

Link to comment
Share on other sites

Just now, Aelfhe1m said:

@linuxgurugamer That latest build (#51) seems to have fixed all the issues with categories and sub-categories (at least in en-us :wink:). But the filter by manufacturer tab has reverted to stock behaviour rather than showing buttons per mod folder (the config setting has no effect either). This may be related to the following message in the log:

 

Ah.  Looks like a debug flag wasn't deleted, I'll get it fixed and updated in a minute

Link to comment
Share on other sites

That fixed the Manufacturers filter thanks.

New issue: if the player defines a custom category that doesn't have a displayName entry (it's new after all) then FE throws an exception to the log and stops working completely.

Spoiler

Example config


SUBCATEGORY
{
	name = Repulsors
	// displayName = Repulsors // works if this line is uncommented
	icon = FanEngine
	FILTER
	{
		CHECK
		{
			type = moduleName
			value = KSPWheelRepulsor
		}
	}
}

Log snippet:

Quote

[WRN 04:38:39.110] [Filter Extensions 3.0.1]: 
[LOG 04:38:39.111] [ModuleManager] Total loading Time = 42.463s
[LOG 04:38:39.150] [ApplicationLauncher] Awake False
[LOG 04:38:39.151] [ApplicationLauncher] SpawnSimpleLayout: VerticalTopDown
[LOG 04:38:39.159] [UiApp] Awake: MessageSystem
[LOG 04:38:39.159] [ApplicationLauncher] OnSceneLoadedGUIReady: scene MAINMENU ShouldBeVisible() True ShouldBeOnTop() True iIsPositionedAtTop True
[LOG 04:38:39.181] Before CategoryNode
[LOG 04:38:39.181] CategoryNode 1
[LOG 04:38:39.182] CategoryNode 2
[LOG 04:38:39.182] CategoryNode 3

SNIP...

[LOG 04:38:39.199] CategoryNode 1
[LOG 04:38:39.199] CategoryNode 2
[LOG 04:38:39.199] CategoryNode 3
[EXC 04:38:39.203] NullReferenceException: Object reference not set to an instance of an object
    FilterExtensions.ConfigNodes.SubcategoryNode..ctor (.ConfigNode node, FilterExtensions.LoadAndProcess data)
    FilterExtensions.LoadAndProcess.ProcessFilterDefinitions ()
    FilterExtensions.LoadAndProcess+<Start>c__Iterator0.MoveNext ()
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress)
 

There are no further FE messages or any exceptions in the log after that one.

 

Link to comment
Share on other sites

New beta, 3.1.0.9:

https://jenkins.spacetux.net/job/A-F/job/FilterExtension/66/artifact/000_FilterExtensions-original-3.1.0.9.zip

  • Updated the NearFutureTechnologies category with the rest of @Nertea's mods
  • Fixed nullref if no displayName was specified for a SubCategory
  • Added check for empty displayName, if so, set it equal to the SubCategory name

So it seems I am finally getting to the end.  I verified that the nullref for the subcategory wouldn't happen for the category, that code already had a check in there.

I'm hoping this will be it, please test.  If I get good reports by this evening, I'll do a full release and update CKAN

Edited by linuxgurugamer
Link to comment
Share on other sites

On 08/11/2017 at 10:45 AM, linuxgurugamer said:

Ummm, I'm not sure this is an issue.  It now requires the displayName, and if it's not there, it's bad data.

Garbage in, Garbage out.

I agree completely but some mods package their own filter extension configs and it would have taken a while for them to realise they needed to update and in the meantime you'd have had people complaining about FE being broken. But you've already fixed this so problem avoided :cool:.

The latest beta seems to be working perfectly as far as I can tell. I've also put a PR on GitHub with a few suggested updates to improve support for SSTU and KSPWheels.

Link to comment
Share on other sites

38 minutes ago, Aelfhe1m said:

I agree completely but some mods package their own filter extension configs and it would have taken a while for them to realise they needed to update and in the meantime you'd have had people complaining about FE being broken. But you've already fixed this so problem avoided :cool:.

The latest beta seems to be working perfectly as far as I can tell. I've also put a PR on GitHub with a few suggested updates to improve support for SSTU and KSPWheels.

Which is why I fixed it :D

I'll take a look at the PR, thanks.

Link to comment
Share on other sites

Home stretch beta:

https://jenkins.spacetux.net/job/A-F/job/FilterExtension/70/artifact/000_FilterExtensions-original-3.1.0.11.zip

  • Fixes a null ref if engines are included which don't a have a corresponding filter rename line for the fuel mixture
  • Following contributed by @Aelfhe1m:
    • Add repulsors category to landing filter
    • Update filter for KSPWheel modules
    • Add SSTU parachutes module to filter
    • Add SSTU module types to heat shield and fairing filters
    • Add SSTU module types to solar panels filter
Link to comment
Share on other sites

Engines using unrecognised fuel mixtures (from the rename list) are no longer appearing in the advanced=>engines category (e.g. Aerozine50,NTO from SSTU).

While it's easy enough to write an MM patch for an isolated instance or two (tested with the Az/NTO mix mentioned above), there is real fuels to consider... (probably KSPIE as well though I don't have either in a 1.3.1 install at the moment)

Link to comment
Share on other sites

1 hour ago, Aelfhe1m said:

Engines using unrecognised fuel mixtures (from the rename list) are no longer appearing in the advanced=>engines category (e.g. Aerozine50,NTO from SSTU).

While it's easy enough to write an MM patch for an isolated instance or two (tested with the Az/NTO mix mentioned above), there is real fuels to consider... (probably KSPIE as well though I don't have either in a 1.3.1 install at the moment)

The real question is, is that what was happening in the original mod?

Please try it with this:

https://github.com/linuxgurugamer/FilterExtension/releases/download/3.1.0/000_FilterExtensions-3.1.0.zip

which is the mod before I started working on it, and let me know.  The more info the better, including pictures and log file 

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

Just an FYI: as it stands, if you install the version from CKAN, the program crashes.  Elided error logs from various log files below.   Not its not a bug report, just an FYI.  Uninstalling fixed the problem, reinstalling caused it to happen again.

 

Quote

 

[UIMasterController]: ShowUI

Unity Player [version: Unity 5.4.0p4_b15b5ae035b7]
mono.dll caused an Access Violation (0xc0000005)
  in module mono.dll at 0033:0fed0e18.

Read from location 00000000 caused an access violation.

 

I have > 100 mods installed and do not have the time to sort out what might be causing the conflict. I'm happy to wait until other things get resolved until we go on a wild bug chase that might simply be a mod conflict. 

Edited by Murdabenne
Link to comment
Share on other sites

On 10.11.2017 at 8:13 PM, linuxgurugamer said:

Hey there. Thank you for your great work. I wanted to test the beta since I also end up with the access violation in mono.dll with the version from ckan. However, the link above seems to be dead for me...

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