ScummVM API documentation
conversationpopup.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
#ifndef NANCY_UI_CONVERSATIONPOPUP_H
23
#define NANCY_UI_CONVERSATIONPOPUP_H
24
25
#include "engines/nancy/commontypes.h"
26
#include "engines/nancy/misc/hypertext.h"
27
#include "engines/nancy/renderobject.h"
28
29
namespace
Nancy
{
30
31
struct
NancyInput;
32
struct
TBOX;
33
struct
UICO;
34
35
namespace
UI
{
36
37
// Nancy 10+ conversation popup. Replaces the legacy Textbox for dialogue
38
// display. The conversation action calls open(), addTextLine(), and close()
39
// to drive the popup lifecycle. Response hotspots and hover highlights
40
// mirror the Textbox behavior but render inside a UICO-driven overlay window.
41
class
ConversationPopup
:
public
RenderObject
,
public
Misc::HypertextParser
{
42
public
:
43
ConversationPopup
();
44
~
ConversationPopup
()
override
=
default
;
45
46
void
init()
override
;
47
void
registerGraphics()
override
;
48
void
handleInput(
NancyInput
&input);
49
50
// Called by ConversationSound::execute() at each new dialogue state.
51
// Always clears previous content, matching Textbox::clear() for Nancy 1-9.
52
void
open();
53
54
// Called once per text line after open() — NPC speech first, then
55
// each response option. Triggers a redraw after each addition.
56
void
addTextLine(
const
Common::String
&text);
57
58
// Called at kActionTrigger just before finishExecution(). Hides the popup.
59
void
close();
60
61
// Called after NPC text lines have been added, before response lines.
62
// Records the hotspot offset so response clicks map to the correct index.
63
void
setResponseStart() { _responseStartIdx = (uint)_hotspots.
size
(); }
64
65
private
:
66
void
drawBackground();
67
// Full content rebuild: lay the text out into _fullSurface (expensive), then
68
// paint the visible slice. Only needed when the text itself changes.
69
void
drawContent();
70
// Lay the response text out into _fullSurface (the expensive step).
71
void
layoutText();
72
// Blit the currently-visible vertical slice of _fullSurface into the popup.
73
// Cheap; safe to call every scroll step.
74
void
paintVisibleText();
75
// Re-composite the popup at the current scroll position without re-laying out
76
// the text. Used while dragging the scrollbar.
77
void
redrawScroll();
78
void
drawScrollbar(UIButtonState state);
79
uint16 getInnerHeight()
const
;
80
81
// Returns the popup-local bounding rect of the scrollbar thumb at
82
// the current scroll position.
83
Common::Rect
computeThumbRect()
const
;
84
85
// The text area in popup-local coordinates. Pre-Nancy13 stores textRect in
86
// chunk/screen space and needs the popup origin subtracted; Nancy13 already
87
// stores it image-local.
88
Common::Rect
getLocalTextRect()
const
;
89
90
// Convert a chunk-space rect into popup-local coordinates.
91
Common::Rect
toPopupLocal(
const
Common::Rect
&chunkRect,
bool
useGameFrame)
const
;
92
Common::Point
popupLocalMouse(
const
Common::Point
&screenMouse)
const
;
93
94
const
UICO
*_uicoData;
95
const
TBOX
*_tboxData;
96
97
Graphics::ManagedSurface
_overlayImage;
98
99
// Separate render object for drawing hovered response text,
100
// mirroring the Textbox::_highlightRObj approach.
101
RenderObject
_highlightRObj;
102
103
// Scrollbar state, driven by header.slider.
104
float
_scrollPos = 0.0f;
105
bool
_scrollbarDragging =
false
;
106
bool
_scrollbarHovered =
false
;
107
int
_scrollbarGrabOffset = 0;
108
109
uint _responseStartIdx = 0;
110
};
111
112
}
// End of namespace UI
113
}
// End of namespace Nancy
114
115
#endif // NANCY_UI_CONVERSATIONPOPUP_H
Graphics::ManagedSurface
Definition:
managed_surface.h:51
Nancy::UI::ConversationPopup
Definition:
conversationpopup.h:41
Common::String
Definition:
str.h:59
Nancy::UICO
Definition:
enginedata.h:760
Common::Rect
Definition:
rect.h:536
Nancy::NancyInput
Definition:
input.h:41
UI
Definition:
soundequalizerpuzzle.h:27
Nancy::Misc::HypertextParser
Definition:
hypertext.h:32
Nancy::RenderObject
Definition:
renderobject.h:36
Common::Point
Definition:
rect.h:144
Common::Array::size
size_type size() const
Definition:
array.h:316
Nancy::TBOX
Definition:
enginedata.h:156
Nancy
Definition:
actionmanager.h:32
engines
nancy
ui
conversationpopup.h
Generated on Sun Aug 23 2026 09:15:38 for ScummVM API documentation by
1.8.13