mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 19:32:11 +00:00
TINSEL: Implement pointer handling for Notebook
This commit is contained in:
parent
5c873a17b2
commit
1f1f97c745
@ -2202,6 +2202,10 @@ void Dialogs::InvLabels(bool InBody, int aniX, int aniY) {
|
||||
}
|
||||
}
|
||||
|
||||
void Dialogs::InvPointEvent(const InventoryObject *invObj, int index) {
|
||||
InvTinselEvent(invObj, POINTED, PLR_NOEVENT, index);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/***/
|
||||
/**************************************************************************/
|
||||
|
@ -355,6 +355,7 @@ public:
|
||||
void InvCursor(InvCursorFN fn, int CurX, int CurY);
|
||||
const InventoryObject *GetInvObject(int id);
|
||||
const InventoryObjectT3 *GetInvObjectT3(int id);
|
||||
void InvPointEvent(const InventoryObject *invObj, int index);
|
||||
bool UpdateString(const Common::KeyState &kbd);
|
||||
bool InventoryIsActive() { return _inventoryState == ACTIVE_INV; }
|
||||
bool IsMixingDeskControl() { return _invDragging == ID_MDCONT; }
|
||||
|
@ -243,11 +243,23 @@ void Notebook::StepAnimScripts() {
|
||||
}
|
||||
}
|
||||
|
||||
int Notebook::GetPointedClue(const Common::Point &point) const {
|
||||
if (_currentPage == 0 || _currentPage > _numPages) {
|
||||
return 0;
|
||||
}
|
||||
return _pages[_currentPage].GetClueForLine(_polygons->lineHit(point));
|
||||
}
|
||||
|
||||
bool Notebook::HandlePointer(const Common::Point &point) {
|
||||
if (!IsOpen()) {
|
||||
return 0;
|
||||
}
|
||||
warning("TODO: Implement pointer handling");
|
||||
auto inside = _polygons->isInsideNotebook(point);
|
||||
if (inside) {
|
||||
auto hit = _polygons->lineHit(point);
|
||||
_pages[_currentPage].HandlePointAtLine(hit);
|
||||
return true; // We handled the pointer
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -255,7 +267,36 @@ bool Notebook::HandleEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
|
||||
if (!IsOpen()) { // TODO: Clicking outside should close the notebook
|
||||
return false;
|
||||
}
|
||||
auto inside = _polygons->isInsideNotebook(coOrds);
|
||||
switch(pEvent) {
|
||||
case PLR_ACTION:
|
||||
if (inside) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case PLR_LOOK:
|
||||
if (inside) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case PLR_WALKTO: {
|
||||
// Handle clue-clicks
|
||||
auto poly = _polygons->mostSpecificHit(coOrds);
|
||||
switch (poly) {
|
||||
case NoteBookPoly::NEXT:
|
||||
HandleEvent(PLR_PGUP, coOrds);
|
||||
return true;
|
||||
case NoteBookPoly::PREV:
|
||||
HandleEvent(PLR_PGDN, coOrds);
|
||||
return true;
|
||||
case NoteBookPoly::NONE:
|
||||
HandleEvent(PLR_ESCAPE, coOrds);
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
case PLR_ESCAPE:
|
||||
Close();
|
||||
return true;
|
||||
|
@ -87,6 +87,8 @@ private:
|
||||
|
||||
void PageFlip(bool up);
|
||||
|
||||
int32 GetPointedClue(const Common::Point &point) const;
|
||||
|
||||
void ClearNotebookPage();
|
||||
|
||||
void SetNextPage(int pageIndex);
|
||||
|
@ -93,6 +93,15 @@ void NotebookLine::CrossOut() {
|
||||
_crossedOut = true;
|
||||
}
|
||||
|
||||
void NotebookPage::HandlePointAtLine(int line) {
|
||||
auto objId = GetClueForLine(line);
|
||||
if (objId != 0 && objId != _pointedClue) {
|
||||
auto obj = _vm->_dialogs->GetInvObject(objId);
|
||||
_vm->_dialogs->InvPointEvent(obj, -1);
|
||||
_pointedClue = objId;
|
||||
}
|
||||
}
|
||||
|
||||
int NotebookPage::IndexOfClue(int id) const {
|
||||
for (int i = 0; i < _numLines; i++) {
|
||||
if (_lines[i]._id == id) {
|
||||
@ -140,6 +149,14 @@ void NotebookPage::Clear() {
|
||||
for (int i = 0; i < _numLines; i++) {
|
||||
_lines[i].Clear();
|
||||
}
|
||||
_pointedClue = -1;
|
||||
}
|
||||
|
||||
int NotebookPage::GetClueForLine(int line) const {
|
||||
if (line >= _numLines) {
|
||||
return 0;
|
||||
}
|
||||
return _lines[line]._id;
|
||||
}
|
||||
|
||||
} // End of namespace Tinsel
|
||||
|
@ -52,8 +52,13 @@ public:
|
||||
int32 GetTitle() const;
|
||||
void FillIn();
|
||||
void Clear();
|
||||
int GetPointedClue(const Common::Point &point) const;
|
||||
int GetClueForLine(int line) const;
|
||||
void HandlePointAtLine(int line);
|
||||
private:
|
||||
int IndexOfClue(int id) const;
|
||||
|
||||
int _pointedClue = -1;
|
||||
const static uint32 MAX_ENTRIES_PER_PAGE = 8;
|
||||
NotebookLine _lines[MAX_ENTRIES_PER_PAGE] = {};
|
||||
uint32 _numLines = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user