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/misc/hypertext.h"
26 #include "engines/nancy/renderobject.h"
27 
28 namespace Nancy {
29 
30 struct NancyInput;
31 struct TBOX;
32 struct UICO;
33 
34 namespace UI {
35 
36 // Nancy 10+ conversation popup. Replaces the legacy Textbox for dialogue
37 // display. The conversation action calls open(), addTextLine(), and close()
38 // to drive the popup lifecycle. Response hotspots and hover highlights
39 // mirror the Textbox behavior but render inside a UICO-driven overlay window.
41 public:
43  ~ConversationPopup() override = default;
44 
45  void init() override;
46  void registerGraphics() override;
47  void handleInput(NancyInput &input);
48 
49  // Called by ConversationSound::execute() at each new dialogue state.
50  // Always clears previous content, matching Textbox::clear() for Nancy 1-9.
51  void open();
52 
53  // Called once per text line after open() — NPC speech first, then
54  // each response option. Triggers a redraw after each addition.
55  void addTextLine(const Common::String &text);
56 
57  // Called at kActionTrigger just before finishExecution(). Hides the popup.
58  void close();
59 
60  // Called after NPC text lines have been added, before response lines.
61  // Records the hotspot offset so response clicks map to the correct index.
62  void setResponseStart() { _responseStartIdx = (uint)_hotspots.size(); }
63 
64 private:
65  void drawBackground();
66  void drawContent();
67  void drawScrollbar(uint state);
68  uint16 getInnerHeight() const;
69 
70  // Returns the popup-local bounding rect of the scrollbar thumb at
71  // the current scroll position.
72  Common::Rect computeThumbRect() const;
73 
74  // Convert a chunk-space rect into popup-local coordinates.
75  Common::Rect toPopupLocal(const Common::Rect &chunkRect, bool useGameFrame) const;
76  Common::Point popupLocalMouse(const Common::Point &screenMouse) const;
77 
78  const UICO *_uicoData;
79  const TBOX *_tboxData;
80 
81  Graphics::ManagedSurface _overlayImage;
82 
83  // Separate render object for drawing hovered response text,
84  // mirroring the Textbox::_highlightRObj approach.
85  RenderObject _highlightRObj;
86 
87  // Scrollbar state, driven by header.slider.
88  float _scrollPos = 0.0f;
89  bool _scrollbarDragging = false;
90  bool _scrollbarHovered = false;
91  int _scrollbarGrabOffset = 0;
92 
93  uint _responseStartIdx = 0;
94 };
95 
96 } // End of namespace UI
97 } // End of namespace Nancy
98 
99 #endif // NANCY_UI_CONVERSATIONPOPUP_H
Definition: managed_surface.h:51
Definition: conversationpopup.h:40
Definition: str.h:59
Definition: enginedata.h:695
Definition: rect.h:524
Definition: input.h:41
Definition: soundequalizerpuzzle.h:27
Definition: hypertext.h:32
Definition: renderobject.h:36
Definition: rect.h:144
size_type size() const
Definition: array.h:316
Definition: enginedata.h:155
Definition: actionmanager.h:32