Commit graph

12 commits

Author SHA1 Message Date
383f66e297 v0.3.0 2025-06-02 00:05:32 +01:00
9bc73100f3 Borders: Move main call in init hook
The main function is called at script invocation, which is nice and early
but everything we do is done in hooks.
This makes it not really useful, and harder to properly disable the module
with the settings.

So, register our `init` hook at script invocation and call the main function
from within.
This makes handling the disabling via the setting trivial, and ensures that
*everything* is properly disabled.

However, the `socketlib.ready` hook fires earlier than the `init` one, so
register the socket at invocation as well, but only register the remote
methods in the main function.
2025-06-02 00:00:42 +01:00
95bb1c3445 Borders: Clean up debug prints
A lot of console logs where left for debugging the scene switch issues.
Those issues being fixed now, they are not useful anymore : remove them.
2025-06-01 23:51:26 +01:00
77ae01a7b3 Borders: Don't rely on .inCombat to check combat status
When changing scenes, *a lot* of data is either empty or points to
the previous scene, preventing us from knowing whether a token is in
combat or not directly from the token.

To work around that, go through the list of combats directly and try
to match them with the scene and token we are drawing instead of using
`.inCombat`.
We cannot rely on `game.combats.active` either as it points to the
active combat in the previous scene.

This is far more work, but it is the only working solution I found.
It depends quite a bit on Fabula Ultima's system combat type which
lists combatants.

This leaves a more minor issue that the borders are not updated when
switching between encounters on the same scene, but this is a rarer
scenario.

Remove the issue from the README and mention the encounter switch issue.
2025-06-01 23:49:35 +01:00
73d2a08b88 Borders: Make clients check combat updates
In the Fabula Ultima system, the clients cannot
use the combat hooks, only the GM.
So the GM orchestrates the token visiblity changes
for all clients.

Currently, the GM checks the status of tokens when
they run the combat hook.
However, this doesn't work when the GM is on another
scene, as the tokens *do not exist* for their client
in this case, as only those in the current scene do.

To fix this, we need to do the token status check
on all clients, and verify that we are on the proper
scene : otherwise there won't be a token to update.

Change the method called on the clients by the GM
to be a wrapper around token_set_border_visibility()
which checks the scene and the token locally.

Introduce another method to manually set the border
status on clients via SocketLib, used for the end of
combat.

Remove the mentions of this issue in the README and
comments as this commit fixes it.
2025-06-01 22:17:36 +01:00
7cd85468c7 module: Add compendium folder
We currently only have a macro compendium, but
we might have more in the future (items, powers...).
All the Fabula Ultima compendium are also in folders.

Add a compendium folder and move the macro compendium within.
2025-06-01 20:26:08 +01:00
22dc500801 Implement Token UI adjustments
Implement the sub-module moving the attribute bars and nameplate
to work well with our dynamic borders.

The attribute bars are moved below the token, one on
top of the other, and the nameplate is moved above.

This is done by monkey patching the `_drawBar()` and
`_refreshNameplate()` functions from the Token class.
This is vulnerable to compatibility issues with other
modules, but is the only way I found for the changes
to be shown without further input.

Indeed, those functions are called after the `drawToken`
hook, which makes it impossible to move those UI elements
there.
We can do it in the `refreshToken` hook, which works *but*
requires the canvas view to be moved at least once for
the position change to be reflected, which looks a bit
broken.

So we monkey patch the functions, but bind them
beforehand to be able to call them within our custom
function as we don't want to duplicate what they do.

Update README and translations for the added setting.
2025-06-01 18:37:22 +01:00
ab02dd139a README: Fix feature sub-section levels
Each main feature should have its own sub-sections
for settings, limitations, etc.
This was not the case for the combat borders :
lower the title level for its subsections
2025-06-01 18:22:00 +01:00
fe9b56acaa Introduce token UI adjustment script
Most of the token UI like tracking bars go over
the token in its own square.
However, the dynamic borders do the same and
conflict with them.

This script will handle moving the already existing
UI elements to free up the view of the token.
2025-05-30 21:38:02 +01:00
3f0f81ee54 Start work on v0.3.0 2025-05-30 21:35:48 +01:00
f617b26fe1 v0.2.0: Add setting to disable dynamic borders
The point of the module is to allow multiple functionalities
to support our campaign.
They might not be suited all the time or to all of them.
They might be buggy !

Add a toggle setting to the dynamic borders functionality,
so that we can keep the compendium while it is fixed.
2025-05-28 18:55:08 +01:00
6c3ce53101 Initial commit - v0.1.0
This initial version adds a custom compendium with a
macro for the tinkerer, and a dynamic token border
to track player turn status.

It has a couple of known major bugs but is needed for
an upcoming game, with fixes hopefully later.

It is only compatible with Foundry v12 at this time.
2025-05-12 22:55:13 +01:00