Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Implement proposed fixes for MapData [skip ci] #2375

Closed
wants to merge 9 commits into from

Conversation

kristofbolyai
Copy link
Collaborator

@kristofbolyai kristofbolyai commented Mar 16, 2024

This PR expects that #2373 is merged, and we agreed upon using zoom steps for our zooming value.

Quoting #2158 (comment):

feat: Make map features have a range of level, add foundation for custom (dynamic only) and json-parsed map visibility

  • Label should treat the int value of level better
  • We need to decide how to handle unknown/suitable-for-all on level in map attributes
  • Visibility for zoom levels is missing; either fix here or as a follow-up

feat: add base versioning for forward-compatibility in JsonProvider (and also add a missing local-file provider loading method)

  • JSON files should have a version field

I expect this PR to be controversial, at least partially. I am okay with that, in fact, I hope we can agree on something even better, in the end.

…tom (dynamic only) and json-parsed map visibility
…and also add a missing local-file provider loading method)
@kristofbolyai kristofbolyai marked this pull request as ready for review March 16, 2024 15:16
@magicus
Copy link
Member

magicus commented Mar 16, 2024

In a first quick glance, this looks good. But I need to take a better look when I'm more sharp and concentrated.

My main worry is if we are going to be able to retrofit the existing "zoom levels" into the new format. Have you experimented anything with that? Things like town names that does not show when zoomed in very much, but neither when zoomed out very much. Some discrepancy wrt to the current situation is okay, but overall "feel" of zoom visibility must be able to be expressed.

@kristofbolyai
Copy link
Collaborator Author

In a first quick glance, this looks good. But I need to take a better look when I'm more sharp and concentrated.

My main worry is if we are going to be able to retrofit the existing "zoom levels" into the new format. Have you experimented anything with that? Things like town names that does not show when zoomed in very much, but neither when zoomed out very much. Some discrepancy wrt to the current situation is okay, but overall "feel" of zoom visibility must be able to be expressed.

It's really easy to port it, you can count the steps with a scroll keybind, so you don't even need to code/debug anything.

@kristofbolyai kristofbolyai changed the title refactor: Implement proposed fixes for MapData refactor: Implement proposed fixes for MapData [skip ci] Mar 17, 2024
@magicus
Copy link
Member

magicus commented Mar 18, 2024

Interesting approach. I'd still like to see both the old and the new on-screen at the same time to double-check that they fade in/out at about the same time.

@magicus
Copy link
Member

magicus commented Mar 18, 2024

Also, my weekend was a bit hectic. I thought I would have time to review this and the other map PR, but I had not. I'll try to do it as soon as I can, but it might take a few days.

@kristofbolyai
Copy link
Collaborator Author

Also, my weekend was a bit hectic. I thought I would have time to review this and the other map PR, but I had not. I'll try to do it as soon as I can, but it might take a few days.

Start with the other PR first. This is only changes that have no effect yet, since we have no data supplying to MapData yet (so there is also nothing to test..)

@magicus
Copy link
Member

magicus commented Apr 22, 2024

Let's get #2373 sorted out first, then I will come back and look at this. (Basically, it is just the zoom levels that still worry me.)

@kristofbolyai
Copy link
Collaborator Author

Let's get #2373 sorted out first, then I will come back and look at this. (Basically, it is just the zoom levels that still worry me.)

And @magicus, whenever you have time, here is the next step.

@kristofbolyai
Copy link
Collaborator Author

@magicus Hi. I've sent this ping to you on both Github and Discord. Please respond to the first one you see, and ignore the second one.

I've been approached by some people from our community, working on the same project. Coincidentally, both would benefit from the new mapdata system. Also considering that the 1.2.0 release is now done, I'd like to finish up map data too.

The reason why I am pinging is you to ask about the development process for this feature. I have a 3 options in mind, so please pick whichever suits you the best.
1, You still want to manage the map data refactor. I still write the code. Only downside is that the review cycle will get really long.
2, I take over management of the refactor. I won't wait for explicit review from you, but I'll label every map-data PR or tag you, whichever you prefer, so you can do any post-review suggestions. Before the "final" release, I'll try to get your overall opinion on the change, if it's possible.
3, You'll have time to work on the feature in the upcoming time-period. If so, I'll take up another big project.

Some details about the "project" I've mentioned above:
This part was asked to not be public, and is only shared in the discord message.

@kristofbolyai kristofbolyai requested a review from magicus May 9, 2024 16:00
@kristofbolyai
Copy link
Collaborator Author

@magicus I think I did everything we've discussed.


@Override
public float getVisibility(float zoomLevel) {
// A feature stats fading in at min - fade, is fully visible at min,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see this somewhat different. The change I would like to see is that the fading should be "centered" around min and max, instead of extending the visibility. That is, if you change the fade it should still feel like the icon is shown for roughly the same interval. With this code, increasing the fade will make the icon visibile for a much longer period, and that will likely make people set a shorter visible interval to get the desired effect.

So basically what I am saying is that the max/min specifies the interval where the icon is shown with at least 50% visibility.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that desirable behavior, though? Personally, I would expect min max values a point where they either start or stop fading. Now, it's a mix of both, which I agree can be a bit confusing, but overall, I thought this makes the most sense, without having to read "documentation" for the user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is desirable, yes. Here are my two arguments:

  1. This decouples fading from the actual max/min point. Otherwise you will probably need to adjust max/min at the same time you adjusts fading, to get your desired effect.

  2. If you don't select the midpoint of the fading range, then what do you select? When the point starts to fade or stops to fade? It is kind of impossible to know.

My idea is to think of this as without fading. Then there is a single instance at which the visibility kicks in (or out). But the fade argument makes this a little less abrupt. But if you slide the fading up or down, it should still center around the actual value.

// the minimum combat level for which this feature is suitable for
// 1 means suitable for all levels (players start at level 1)
// 0 means inherit
// -1 means no information is available, or the feature is suitable for all levels
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So can we set -1 as the combat level at the "root"? So if someone adds a data point and leaves out the level, the default value will be "no info".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every other method here specified their default as inherit. I think this method should do the same, and we'll specify the real default value somewhere else (which will be called when the root is "inherit".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I've apparently forgotten like everything about this. :) Where do we specify the root? Can we make sure this is set to -1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit lost in that regard still. Here is what I've found. It seems that FullFeatureAttributes and FullCategoryAttributes expect inherit values to be null, or 0. I would assume these classes would provide/get the default values. Somewhere, sometime. I think i'll have to figure this out, when I am working on porting to map data.

(For reference, here is a code snippet from FullFeatureAttributes:

    protected <T> T getAttribute(Function<MapAttributes, T> getter) {
        // Check if the feature has overridden this attribute
        if (attributes != null) {
            T attribute = getter.apply(attributes);
            if (attribute != null && !(attribute instanceof Integer i && i == 0)) {
                return attribute;
            }
        }

        // Otherwise get it from the category
        MapAttributes categoryAttributes = Services.MapData.getFullCategoryAttributes(feature.getCategoryId());
        if (categoryAttributes == null) return null;

        return getter.apply(categoryAttributes);
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one point that is still worrying me. I think we need to get to the bottom on how this is supposed to work, so we get this part right.

Maybe it is bad that we use 0 for inheritance on the other integer values as well. Perhaps we need a way to say if an integer value is present or not, basically having nullable Integers instead of int. That is harder to match to a json format, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do you have any idea on how to handle this? Nullable ints are not so bad to handle in GSON, afaik.

@@ -1,5 +1,5 @@
/*
* Copyright © Wynntils 2023.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you can revert this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only by force pushing. Do you want me to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it is okay to force-push to a PR branch to get rid of a thing like this. A bit annoying that this is the only way to fix this, but in this case I think it's fine. I assume you'll make an interactive rebase and remove all edits to this file?

@magicus
Copy link
Member

magicus commented May 13, 2024

This has been superseded by #2489.

@magicus magicus closed this May 13, 2024
@kristofbolyai kristofbolyai deleted the mapdata-fixes branch May 13, 2024 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants