Working on phone messages

This commit is contained in:
Vladislav Khorev committed 2026-05-30 21:27:25 +03:00
1 parent cdab525858
commit 9425f9b19a
20 files changed
+591 -28

No files matched your search

+56
View File
@@ -26,6 +26,7 @@ These properties are available on every node type.
| `height` | float \| `"match_parent"` | `0` | Height in virtual pixels |
| `horizontal_gravity` | `"left"` \| `"center"` \| `"right"` | `"left"` | Positions the node horizontally inside a **FrameLayout** parent |
| `vertical_gravity` | `"bottom"` \| `"center"` \| `"top"` | `"bottom"` | Positions the node vertically inside a **FrameLayout** parent |
| `visible` | bool | `true` | Whether the node (and all its children) are rendered and interactive. Can be toggled at runtime via `setNodeVisible` |
---
@@ -343,6 +344,12 @@ A non-interactive image. Supports optional fade-in and pulse-scale animations.
| `pulse.maxScale` | float | `1.1` | Maximum scale during the pulse cycle |
| `pulse.periodMs` | float | `1000` | Duration of one full pulse cycle in milliseconds |
**C++ pop-in animation** (scales the node from 0 → 1, ease-out quad):
```cpp
uiManager.startPopIn("background", 300.0f); // duration in milliseconds
```
Typically called immediately after making a node visible. The node is automatically removed from the animation list when the scale reaches 1.
---
## Animations
@@ -433,9 +440,58 @@ uiManager.setNodeVisible("hint5", false);
bool visible = uiManager.getNodeVisible("hint5");
```
### Pop-in animation
Scales a node from 0 to 1 using an ease-out curve. Useful for chat bubble reveals and similar "appear" effects.
```cpp
uiManager.startPopIn("messageBubble", 300.0f); // node name, duration ms
```
Set the node's `scaleX`/`scaleY` to `0` and call `setNodeVisible` before calling `startPopIn` to avoid a one-frame flash at full size.
### Dynamic node repositioning
`node->localY` (and `localX`) can be modified directly on a node pointer, then a layout recalculation applied:
```cpp
auto node = uiManager.findNode("messageBubble");
node->localY = 350.0f; // new bottom-Y (for vertical_gravity: bottom nodes)
uiManager.updateAllLayouts(); // recomputes screenRect and rebuilds meshes
```
This is how the phone chat manager repositions bubbles as new messages arrive.
### Per-frame update
```cpp
uiManager.update(deltaMs); // advance animations and fade-ins
uiManager.draw(renderer); // render everything
```
---
## Dialogue → UI integration (phone chat bubbles)
Dialogue nodes in JSON can carry a `"bubbleSlot"` field naming a `StaticImage` UI node. When the dialogue runtime presents that line, it fires the `onBubbleSlotReady` callback with the slot name, which the game uses to reveal the corresponding bubble image.
```json
{
"id": "line_1",
"type": "Line",
"speaker": "Айпери",
"text": "...",
"next": "line_2",
"bubbleSlot": "message01in"
}
```
Lines without `"bubbleSlot"` (or with an empty value) do not trigger any UI change — useful for internal monologue lines that have no corresponding chat image.
**C++ wiring:**
```cpp
dialogueSystem.setOnBubbleSlotReady([](const std::string& slotName) {
// slotName == "message01in" etc.
menuManager.revealPhoneChatBubble(slotName);
});
```