[Scummvm-git-logs] scummvm master -> 61c94379cda64d3d5119edb905d65b4d92ce1778
somaen
noreply at scummvm.org
Thu May 26 20:10:01 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
61c94379cd TINSEL: Add initial event support to Notebook.
Commit: 61c94379cda64d3d5119edb905d65b4d92ce1778
https://github.com/scummvm/scummvm/commit/61c94379cda64d3d5119edb905d65b4d92ce1778
Author: Einar Johan Trøan SømaÌen (einarjohants at gmail.com)
Date: 2022-05-26T22:09:31+02:00
Commit Message:
TINSEL: Add initial event support to Notebook.
For now this should be enough to flip pages.
Changed paths:
engines/tinsel/dialogs.cpp
engines/tinsel/noir/notebook.cpp
engines/tinsel/noir/notebook.h
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 1f251867399..ffd11801a83 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -1797,6 +1797,14 @@ enum { I_NOTIN,
* to rework all this.
*/
int Dialogs::InvArea(int x, int y) {
+ if (TinselVersion == 3) {
+ if (_vm->_notebook->IsOpen()) {
+ if (_vm->_notebook->HandlePointer(Common::Point(x, y)) != 0) {
+ return I_ENDCHANGE;
+ }
+ return I_NOTIN;
+ }
+ }
if (TinselVersion >= 2) {
int RightX = MultiRightmost(_rectObject) - NM_BG_SIZ_X - NM_BG_POS_X - NM_RS_R_INSET;
int BottomY = MultiLowest(_rectObject) - NM_BG_SIZ_Y - NM_BG_POS_Y - NM_RS_B_INSET;
@@ -5005,6 +5013,13 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
if (_InventoryHidden)
return;
+ if (TinselVersion == 3) {
+ // If the Notebook handles the event, it has been consumed.
+ if (_vm->_notebook->HandleEvent(pEvent, coOrds)) {
+ return;
+ }
+ }
+
switch (pEvent) {
case PLR_PROV_WALKTO:
if (MenuActive()) {
@@ -5031,7 +5046,8 @@ void Dialogs::EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
break;
case PLR_DRAG1_START: // Left drag start
- InvDragStart();
+ if (TinselVersion < 3 || _inventoryState == ACTIVE_INV) // InventoryActive, but not Notebook
+ InvDragStart();
break;
case PLR_DRAG1_END: // Left drag end
diff --git a/engines/tinsel/noir/notebook.cpp b/engines/tinsel/noir/notebook.cpp
index d138be5b373..43af61c59bb 100644
--- a/engines/tinsel/noir/notebook.cpp
+++ b/engines/tinsel/noir/notebook.cpp
@@ -171,6 +171,25 @@ void Notebook::SetNextPage(int pageIndex) {
_currentPage = pageIndex;
}
+void Notebook::PageFlip(bool up) {
+ int nextPage = _currentPage + (up ? -1 : 1);
+ if (nextPage <= 0) {
+ SetNextPage(0);
+ Refresh();
+ return;
+ } else if (nextPage == 1) {
+ // TODO: Should possibly just call whatever function we use to open.
+ InitNotebookAnim(&_object, _anim, SysReel::NOTEPAD_OPENING, Z_INV_RFRAME);
+ _state = BOOKSTATE::OPEN_ANIMATING;
+ SetNextPage(nextPage);
+ return;
+ }
+ SetNextPage(nextPage);
+ SysReel reel = (up ? SysReel::NOTEPAD_FLIPUP : SysReel::NOTEPAD_FLIPDOWN);
+ InitNotebookAnim(&_pageObject, _pageAnim, reel, 19);
+ _state = BOOKSTATE::PAGEFLIP;
+}
+
void Notebook::Show(bool isOpen) {
auto reel = (isOpen ? SysReel::NOTEPAD_OPEN : SysReel::NOTEPAD_OPENING);
InitNotebookAnim(&_object, _anim, reel, Z_INV_MFRAME);
@@ -205,6 +224,44 @@ void Notebook::StepAnimScripts() {
Refresh();
}
}
+ if (_state == BOOKSTATE::PAGEFLIP) {
+ auto state = StepAnimScript(&_pageAnim);
+ if (state == ScriptFinished) {
+ MultiDeleteObjectIfExists(FIELD_STATUS, &_pageObject);
+ _state = BOOKSTATE::OPENED;
+ Refresh();
+ }
+ }
+}
+
+bool Notebook::HandlePointer(const Common::Point &point) {
+ if (!IsOpen()) {
+ return 0;
+ }
+ warning("TODO: Implement pointer handling");
+ return false;
+}
+
+bool Notebook::HandleEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
+ if (!IsOpen()) { // TODO: Clicking outside should close the notebook
+ return false;
+ }
+ switch(pEvent) {
+ case PLR_ESCAPE:
+ Close();
+ return true;
+ case PLR_PGUP:
+ PageFlip(true);
+ return true;
+ case PLR_PGDN:
+ PageFlip(false);
+ return true;
+ case PLR_HOME:
+ case PLR_END:
+ default:
+ return false;
+ }
+ return false;
}
} // End of namespace Tinsel
diff --git a/engines/tinsel/noir/notebook.h b/engines/tinsel/noir/notebook.h
index 58beda8da7c..6797ffad712 100644
--- a/engines/tinsel/noir/notebook.h
+++ b/engines/tinsel/noir/notebook.h
@@ -50,7 +50,8 @@ enum class BOOKSTATE {
CLOSED = 0,
OPEN_UNKNOWN = 1,
OPEN_ANIMATING = 2,
- OPENED = 3
+ OPENED = 3,
+ PAGEFLIP = 4
};
class InventoryObjectT3;
@@ -70,7 +71,9 @@ public:
void Show(bool isOpen);
bool IsOpen() const;
void Close();
-
+
+ bool HandlePointer(const Common::Point &point);
+ bool HandleEvent(PLR_EVENT pEvent, const Common::Point &coOrds);
void StepAnimScripts();
void Refresh();
private:
@@ -78,6 +81,8 @@ private:
void AddClue(const InventoryObjectT3 &invObject);
int GetPageWithTitle(int id);
+ void PageFlip(bool up);
+
void ClearNotebookPage();
void SetNextPage(int pageIndex);
More information about the Scummvm-git-logs
mailing list