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

Bring back unique light sources (no new macro functions) #5067

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Nov 22, 2024

Identify the Bug or Feature request

Resolves #3087

Description of the Change

This adds unique light sources, originally from #4356. Unlike before, this change focuses primarily on UI changes and does not include any macro functions for manipulating unique light sources.

UI changes

The only way to define unique light sources for now is through the Edit Token dialog's Config tab. It has a textbox for entering light source definitions, following the same syntax as lights in the Campaign Properties dialog, minus the support for groups.

The token context menu's "Light Sources" sub-menu now shows a "Unique" group containing the token's unique light sources. If the token has none, this group will not be shown. Attaching and detaching unique lights works exactly the same as for campaign lights.

UVTT importer

The UVTT importer now defines and attaches a unique light source on the light tokens it produces. The range of the light source is taken from the light's "range" field. The color is taken from the "color" field, but only if the imported map does not have baked lighting. Clear lights are produced if lighting is baked since the light color is already present on the map.

The light's properties are still written to the token's GM notes as JSON, but now all properties are written rather than a hand-picked subset.

There are two limitations on this part of the importer:

  • The "intensity" field goes unused as we don't have a equivalent concept.
  • The UVTT format includes no shape information for lights, so the shape will always be set to "circle".

Macro function changes

The only change to macro functions is to add the "$token" type to getLights(), setLight(), and hasLightSource. The "*" wildcard type will also include any unique light sources on the token in addition to those in the campaign.

Possible Drawbacks

Existing macros may fail if they try to match up the results of getLights("*") with the lighting info in getInfo("campaign"), without validating that the keys exist. This would not immediately impact existing campaigns since it is only an issue if run against tokens with unique light sources added to them.

Documentation Notes

How the Edit Token dialog looks for defining unique light sources:
defining via Edit Token dialog

How the token context menu looks for turning unique light sources on and off:
attaching via token context menu

For getLights() type parameter:

  • If set to "$token", unique light sources on the token are returned.
  • If set to "*", all light sources - including unique light sources on the token - are returned.

For setLight() type parameter:

  • If set to "$token", name refers to a unique light source on the token.

For hasLightSource() type parameter:

  • If set to "$token", only unique light sources on the token are checked.
  • If set to "*", all light sources - including unique light source on the token - are returned

Release Notes

  • Added unique lights to tokens, with support in UVTT importer for creating them on imported lights.

This change is Reviewable

- Methods on `Token` to add or delete unique light sources and look them up.
- Support in `AttachedLightSource` to resolve against a `Token` in addition to a `Campaign`.
- Support in `TokenDto` to transfer unique light sources.

Attaching (turning on) a unique light source works exactly as for a campaign light source: the ID is added to the
list. The only difference in behaviour between unique and campaign light sources is where the definition lives.
The new version is not an overload of `updateTokenProperty()` but has a more descriptive name. It also does not rely on
the caller deciding which `Token.Update` value to use. Instead, a `boolean` is accepted to toggle the light source on or
off, and the method will pick one of the two valid `Token.Update` value based on that.
This only adds the ability to write a `"$token"` category in `getLights()`, `setLight()`, and `hasLightSource()` to
restrict the operation to unique light sources on the given token, rather than restricting it to a campaign category. It
also extends the wildcard (`"*"`) support in these functions to also look for unique light sources on the token.
The Edit Token dialog now sports a textbox where unique light sources can be defined. The syntax is identical to the light
syntax in the Campaign Properties dialog except that categories are not supported.

If a token has unique light sources, its context menu will display them under "Light Sources". They will be in their own
"Unique" category, separated from the campaign categories. The functionality is identical to that for campaign lights.
The importer will synthesize unique lights for each light in the UVTT file. The range will be taken from the light's
`"range"` field, and the lumens will be set to 100. The colour will be set to the light's `"color"` field, unless the
map image has baked lighting in - in that case, the unique light source will be clear. The `IGNORES-VBL` flag will be
set if the light's `"shadow"` flag is `false`.

All light properties are now written to the GM notes. Previously we wrote a hand-picked subset, but now everything is
there. This avoids any chance of missing some in the future if the UVTT format adds additional properties.

There are a few limitations with the import:
1. UVTT does not include the shape or texture of the light, so imported lights are always treated as circles.
2. We have no equivalent to "intensity" so that remains unused.
@kwvanderlinde kwvanderlinde self-assigned this Nov 22, 2024
@github-actions github-actions bot added the feature Adding functionality that adds value label Nov 22, 2024
@kwvanderlinde kwvanderlinde marked this pull request as ready for review November 22, 2024 22:03
@FullBleed
Copy link

FullBleed commented Nov 23, 2024

That was quick. Looks like a good implementation.

Quick question...

If a token has a light source and is saved. Then imported into a campaign without that light source, will it convert to a "unique" light source on the token?

@kwvanderlinde kwvanderlinde changed the title Bring back unique light sources (no new macros) Bring back unique light sources (no new macro functions) Nov 23, 2024
@kwvanderlinde
Copy link
Collaborator Author

If a token has a light source and is saved. Then imported into a campaign without that light source, will it convert to a "unique" light source on the token?

No. Tokens don't actually store campaign lights, they just make a note saying that a certain light is activated. So at import time there's nothing available to convert. This PR doesn't change that.

@cwisniew cwisniew added this pull request to the merge queue Nov 26, 2024
Merged via the queue into RPTools:develop with commit 5024111 Nov 26, 2024
5 checks passed
@kwvanderlinde kwvanderlinde deleted the feature/3087-resurrect-unique-lights branch November 26, 2024 23:11
@bubblobill
Copy link
Collaborator

Damn you. I had just redesigned the whole config tab. *sigh*

@kwvanderlinde kwvanderlinde restored the feature/3087-resurrect-unique-lights branch November 27, 2024 21:43
@kwvanderlinde kwvanderlinde deleted the feature/3087-resurrect-unique-lights branch November 27, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding functionality that adds value
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

Add 'Implicit Lights'
4 participants