Repository navigation
Conversation
Reviewer's GuideThis PR introduces a TokenManager-backed token asset pipeline with normalized lookup, layered fallbacks, per-character overrides, filesystem-driven refresh, and GL texture caching; it then integrates tokens into both map rendering and Group Manager with independent visibility controls, configurable sizing, context-menu selection, persistence, and immediate UI/map updates. Sequence diagram for token rendering on the mapsequenceDiagram
participant MapCanvas
participant CharacterBatch
participant TokenManager
participant OpenGL
MapCanvas->>CharacterBatch: drawCharacter(coordinate, color, fill, dispName)
CharacterBatch->>TokenManager: overrideFor(dispName)
CharacterBatch->>CharacterBatch: canonicalTokenKey(dispName)
MapCanvas->>CharacterBatch: reallyDrawCharacters(OpenGL, textures)
CharacterBatch->>TokenManager: processPendingTextureChanges(OpenGL)
CharacterBatch->>TokenManager: textureIdFor(key)
alt texture is not cached
CharacterBatch->>TokenManager: getToken(key)
CharacterBatch->>TokenManager: uploadNow(key, pixmap)
end
CharacterBatch->>TokenManager: textureById(id)
CharacterBatch->>OpenGL: renderColoredTexturedQuads(token quad, texture)
Sequence diagram for token selection and immediate refreshsequenceDiagram
actor User
participant GroupWidget
participant Configuration
participant GroupModel
participant MapCanvas
User->>GroupWidget: Set Icon action
GroupWidget->>Configuration: update tokenOverrides
GroupWidget->>GroupModel: resetModel()
GroupWidget-->>MapCanvas: sig_characterUpdated
MapCanvas->>MapCanvas: slot_requestUpdate()
User->>GroupWidget: Use default icon action
GroupWidget->>Configuration: set kForceFallback override
GroupWidget->>GroupModel: resetModel()
GroupWidget-->>MapCanvas: sig_characterUpdated
MapCanvas->>MapCanvas: slot_requestUpdate()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/group/CGroupChar.h" line_range="158" />
<code_context>
m_server.maxmp = _maxmoves;
}
+
+ QString getDisplayName() const;
};
</code_context>
<issue_to_address>
**Application cannot build**
Calls to `CGroupChar::getDisplayName()` from the map and Group Manager have no definition, so linking fails and the application cannot be built.
Provide a definition for `CGroupChar::getDisplayName()`.
Also at `src/display/Characters.cpp:588-589`, `src/group/groupwidget.cpp:159`.
</issue_to_address>
### Comment 2
<location path="src/group/tokenmanager.cpp" line_range="76" />
<code_context>
+ : QObject(parent)
+{
+ g_tokenManager = this;
+ scanDirectories();
+
+ m_rescanTimer.setSingleShot(true);
</code_context>
<issue_to_address>
**New folder tokens stay missing**
When the user changes the resource directory while the application is running, `TokenManager::scanDirectories()` runs only at startup or for watched old paths, so `m_availableFiles` and the watchers stay pointed at the previous folder; tokens from the newly selected folder remain unavailable until a rescan or restart.
Rescan the token directory and retarget its watchers when the resource directory changes.
Also at `src/group/tokenmanager.cpp:119-121`, `src/group/tokenmanager.cpp:168-170`.
</issue_to_address>
### Comment 3
<location path="src/display/Characters.cpp" line_range="333-337" />
<code_context>
+ pushVert(sc, {1.f, 1.f});
+ pushVert(sd, {0.f, 1.f});
+
+ QString key = TokenManager::overrideFor(dispName);
+ if (key.isEmpty())
+ key = canonicalTokenKey(dispName);
+ else
+ key = canonicalTokenKey(key);
+
+ m_charTokenKeys.emplace_back(key);
</code_context>
<issue_to_address>
**Map shows the wrong character’s token**
When a canonical map key matches another character’s display name, and that character has an override, `drawBox` canonicalizes the display name or selected override, then `getToken` applies `overrideFor` again; the map shows the other character’s override, while the Group Manager resolves the original character once and shows a different icon.
Ensure canonical map keys are not treated as display names and have overrides applied a second time.
Also at `src/group/tokenmanager.cpp:189`.
</issue_to_address>
### Comment 4
<location path="src/display/Characters.cpp" line_range="301" />
<code_context>
addTransformed(c);
addTransformed(d);
+ if (!dispName.isEmpty() && getConfig().groupManager.showMapTokens && numAlreadyInRoom == 0) {
+ const Color tokenColor{1.f, 1.f, 1.f, 1.f};
+ const auto &mtx = m_stack.top().modelView;
</code_context>
<issue_to_address>
**Later room members lack tokens**
When multiple group characters occupy the same mapped room, `drawBox` skips token quads when `numAlreadyInRoom` is nonzero, even though it draws those characters’ offset squares; the map shows a token for at most one member.
Generate token quads for every group character, not only the first character drawn in a room.
</issue_to_address>
### Comment 5
<location path="src/display/Characters.cpp" line_range="301" />
<code_context>
addTransformed(c);
addTransformed(d);
+ if (!dispName.isEmpty() && getConfig().groupManager.showMapTokens && numAlreadyInRoom == 0) {
+ const Color tokenColor{1.f, 1.f, 1.f, 1.f};
+ const auto &mtx = m_stack.top().modelView;
</code_context>
<issue_to_address>
**Map tokens disappear when zoomed out**
When the map is zoomed out far enough for `isFar` to be true, `isFar` selects the other rendering branch before this token-generation block, so characters drawn at the far/beacon scale never get token quads. The configured map tokens therefore disappear at those zoom levels.
Generate and render token quads for the far-scale character path as well, or document and enforce a token visibility scale limit.
</issue_to_address>Sourcery assessment
Approval pending. 5 findings to address first.
Blocking findings: src/group/CGroupChar.h:158, src/group/tokenmanager.cpp:76, src/display/Characters.cpp:337, src/display/Characters.cpp:301, src/display/Characters.cpp:301
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #562 +/- ##
==========================================
- Coverage 27.91% 27.56% -0.36%
==========================================
Files 563 567 +4
Lines 46169 46836 +667
Branches 4884 5001 +117
==========================================
+ Hits 12889 12909 +20
- Misses 33280 33927 +647 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This PR adds configurable character token images to the map and Group Manager.
It includes token image lookup and fallback, per-character image overrides, adjustment of icon and row size in Group Manager, immediate updates when tokens or their size change, and rendering that keeps the map’s coloured character square from tinting the token.
It need not be set to default to be active in either Group manager or on the map.
Token images are square .png files and respect alpha channels. A "tokens" folder sits with the "areas" and "pixmaps" folders and is scanned on startup for files. It has a fallback from a modding folder to an internal tokens folder (this has not been added and need not be within Mmapper) to the regular char-select image.
A token picker will open a gallery of images n the modding folder. One can be selected, or you can navigate to an image elsewhere and both select and import it. Selected tokens will be remembered for characters and npcs matched against names.
It will also switch token images between human and bear for metamorph transformations.
I do have a set of tokens that covers most character types and npcs you may group with, though this isn't included. It could be if you want. Am working on an updated set that is cleaner and uses alphas.
Summary by Sourcery
Add configurable character tokens throughout the map and Group Manager with persistent overrides, fallback handling, and live updates.
New Features:
Bug Fixes:
Enhancements: