Valheim

File information

Last updated

Original upload

Created by

WxAaRoNxW

Uploaded by

WxAaRoNxW

Virus scan

Safe to use

Tags for this mod

negative filter (7 comments)

  1. arhmichal
    arhmichal
    • supporter
    • 0 kudos
    There is QoL Pins that allow you to toggle visibility of pins of any type on and off, like hide all dot pins and al fire pins.
    Your mod has a filter that allows you to hide every pin except the ones matching the filter text.

    I need something in between.
    A negative filter to hide every pin matching the filter text. A checkbox next to a filter textbox would be nice to switch to negative filter.

    Use Case: I'm marking all berries on my map for the sake of easy replenish supplies for 10-ppl-mega-base. It's handy to find berries and plan a fast route over all bushes on the island, but when i zoom out, it absolutely covers my entire map, i can't see the land, the shore, nothing but overlapping text and pins because the pin size and text size stays the same regardless of map's zoom.
    I love the alpha value in the color but it's not helping much in this case, the text stays 100% opaque and obstructive.

    I want to be able to temporarily hide all berries pins. In fact i want to hide multiple pins like berries, ore, sometimes also dungeons, all at once and only occasionally show them on the map.

    A default filter, always active one would be nice.

    Going even further on, please allow a regex in filter, probably enabling in config and with some runtime guard because people can mess up regexes soooo bad and write soooo slow regexes ... they can lag their own game and blame the mod dev.

    I think multiple filters active at once (no regex) can be a viable solution with better performance then regex and safer considering user input errors, but dynamically adding and removing filters in a collection and connecting it with UI ... only you can judge the complexity of this and if it is possible at all.
    1. WxAaRoNxW
      WxAaRoNxW
      • member
      • 0 kudos
      Good idea, I can create a negative text filter.

      as for the filter different pins based on their icon.
      I did want to try making something like that, buuut, Pinnacle already covers it, it goes really well with Pin Assistant as you can edit already existing pins. It also has different options for icons instead of being limited to the default 4 pins.

      So yeah, I don't think I'll create a filter x type pin, anytime soon as an existing mod that goes well with mine exists. I also made it compatible so there wouldn't be any issues with changing the pin name through the mod.

      for the regex filter or the multi filter ones. I'll see what I can do there. The regex solution should be very easy, would have to modify the simple search feature I made a tiny bit to work with regex.
    2. WxAaRoNxW
      WxAaRoNxW
      • member
      • 0 kudos
      Released a new update covering this! Can't do the multiple active filters at once as I thought RegEx would do the same thing and is much simpler and easier to code.

      As for guards, all I did was check if it's an invalid RegEx pattern, don't really know how to make a check for complex RegEx that could make it slow, if you give me an example of a pattern maybe I can work off it, not really super familiar with RegEx, only basic stuff.

      Although, Regex might not be too user friendly so I'll consider giving an option for most of the users for multi filters, but not anytime soon tho.
    3. arhmichal
      arhmichal
      • supporter
      • 0 kudos
      since regex is not something most ppl are familiar, i'd disable it by default in your config, this way ppl won't report bugs on expressions that fall into regex but they don't know it ;)

      for multi-filters you can consider a very simple workaround that will satisfy almost everyone...
      do you know of CSV files? or PATH console var? they have multiple values put into one line but separated with some "special" char.

      you can also introduce a char that in filter (non-regex version) would mean it separates two filters from each other.

      assume you want to see only berries, 3 filters would be "rb" and "bb" and "cb" for rasberrie, blueberries and cloudberries.
      assume you want to use this charracter for separating multiple filters "|" for compatibility with regex syntax and because near noone is using this in their pin names
      you just allow this filter "rb|bb|cb" into textbox.
      you can insta-transform it into regex (just need to escape some characters) and all is fine or you do string split("|") and apply all filters from returned array

      this way you skip dynamically gathering an array of filters, you skip entire GUI shenaningans to adjust for multi filters and you add this feature in very few lines of code ;)
    4. arhmichal
      arhmichal
      • supporter
      • 0 kudos
      as for a very slow regex ...
      to test it well you'll need 200 pins or more

      btw: all regex matches should be case-insensitive to avoid complicating regex for small or capital letters

      a slow regex is one with many "any-char" (* or +) or "multi-char" ( [ ]  groups like [a-z!@#$%^&*] or at least [rbcRBC] ) slots, some look-ahead( (?=qwe) ) and look-behinds ( (?<=qwe) ) and maybe some alts ( | )

      also there are over-complicated ways to write regexes, like take this simple regex "Blue Berry|cloud berries|raspberry" and instead you can write "([Bb]lue|[Cc]loud|[Rr]asp) ?[Bb]err(y|ies)"

      a bit over-complicated example - a negative filter to hide all ore except silver and all berries
      i assume pins have text like "blue berry" or "copper ore" and some other pins that are not berry or ore, like "base 1" "boat" "that dude's base where we all got drunk and owned by moskito suprise attack"
      (!) "(.*berry\b.*)|(.*(?<!silver )\b(?:ore)\b.*)"
      notice - both alts don't know what letter they start with, so they need to search entire string just to be sure - this is one of the most common issues with regex performance
      depending on regex implementation, this can be is quadratic complexity due to (.*) and additional burder due to (?<text) right after (.*)

      note:
      there's a difference in search() and match() methods
      match() will try to match entire string ONLY, if there is a first or last letter that goes beyond searched regex, it will return not-match, your regex needs to cover entire string for to return a match. if you want to find "ala" in "hula hala lala" you'll need regex ".*ala.*" but this way match() is faster
      search() will try to find a matching substring, so you don't need to try and cover all possible cases of prefixes and sufixes. if you want to find "ala" in "hula hala lala" you'll need regex "ala"
    5. WxAaRoNxW
      WxAaRoNxW
      • member
      • 0 kudos
      oh yeaaah good point, I forgot I could do it on that approach, that was actually my first approach with tracking objects, similar to locator, but deemed it as too messy as you'd be working on 1 line only. I was cranking up my brain coming up with a way to do multi filtering. Only caveat is it's pretty messy to handle in the tiny text box if you have a lot of filters. Will try working on it, and maybe make it even more user friendly.

      also I used Match for regex, should I be making an option for both Match and Search?
    6. arhmichal
      arhmichal
      • supporter
      • 0 kudos
      if you think about it, using match or search is a very advanced option just like using regex, so sure make an option, but default hidden along with regex. and for default value i'd use match

      and for long filters ... don't mind the long filter in short textbox. just make it 2x-3x longer (to help a bit) and don't mind it any more.
      if user enters a long multi filter that doesn't fit in textbox, that means he knows what he entered and what he's doing. so a textbox that shows like 30-50 chars should be enough.
      that's the lazy approach :P
      otherwise i can see a textbox growing with the filter up to the width of the map or a rich text box that allows multiple lines and each filter in next line therefore "\n" separator instead of "|" separator

      if you actually work on it more and let the UI scale somehow to pretty show multiple filters, you're living gold!!
      keep in mind that you can hide the filter textbox with TAB so don't worry with obstructing too much of the map, at most some transparency for the text box if it's too big