aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorlukaslw2014-06-09 00:57:08 +0200
committerlukaslw2014-06-22 20:08:50 +0200
commit98525c1145f8b62c1e12d463754ff3777bcc7db7 (patch)
tree121d4fb44f2950fd8443e358b5d2d01de1c1907b /engines
parent3bf8d86a57ef54ba3f87fbbd12ee5e41ec254bf8 (diff)
downloadscummvm-rg350-98525c1145f8b62c1e12d463754ff3777bcc7db7.tar.gz
scummvm-rg350-98525c1145f8b62c1e12d463754ff3777bcc7db7.tar.bz2
scummvm-rg350-98525c1145f8b62c1e12d463754ff3777bcc7db7.zip
PRINCE: Inventory - left mouse button handling
Diffstat (limited to 'engines')
-rw-r--r--engines/prince/mob.h4
-rw-r--r--engines/prince/prince.cpp146
-rw-r--r--engines/prince/prince.h12
-rw-r--r--engines/prince/script.cpp21
-rw-r--r--engines/prince/script.h2
5 files changed, 135 insertions, 50 deletions
diff --git a/engines/prince/mob.h b/engines/prince/mob.h
index 1c095c2fc4..36630eb6eb 100644
--- a/engines/prince/mob.h
+++ b/engines/prince/mob.h
@@ -66,10 +66,6 @@ public:
bool _visible;
uint16 _type;
- uint16 _x1; // initialize this?
- uint16 _y1;
- uint16 _x2;
- uint16 _y2;
uint16 _mask;
Common::Rect _rect;
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 261ba70b26..ae7530997a 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -82,7 +82,8 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc)
_invLineX(134), _invLineY(176), _invLine(5), _invLines(3), _invLineW(70), _invLineH(76), _maxInvW(72), _maxInvH(76),
_invLineSkipX(2), _invLineSkipY(3), _showInventoryFlag(false), _inventoryBackgroundRemember(false),
_mst_shadow(0), _mst_shadow2(0), _candleCounter(0), _invX1(53), _invY1(18), _invWidth(536), _invHeight(438),
- _invCurInside(false) {
+ _invCurInside(false), _optionsFlag(false), _currentMob(0), _optionEnabled(0), _invOptionsNumber(5),
+ _invExamY(120) {
// Debug/console setup
DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
@@ -685,7 +686,7 @@ void PrinceEngine::keyHandler(Common::Event event) {
}
}
-void PrinceEngine::hotspot(Graphics::Surface *screen, Common::Array<Mob> &mobList) {
+int PrinceEngine::hotspot(Graphics::Surface *screen, Common::Array<Mob> &mobList) {
Common::Point mousepos = _system->getEventManager()->getMousePos();
Common::Point mousePosCamera(mousepos.x + _picWindowX, mousepos.y);
@@ -700,7 +701,7 @@ void PrinceEngine::hotspot(Graphics::Surface *screen, Common::Array<Mob> &mobLis
textW += _font->getCharWidth(mob._name[i]);
}
- uint16 x = mousepos.x - textW/2;
+ uint16 x = mousepos.x - textW / 2;
if (x > screen->w) {
x = 0;
}
@@ -715,9 +716,10 @@ void PrinceEngine::hotspot(Graphics::Surface *screen, Common::Array<Mob> &mobLis
}
_font->drawString(screen, mob._name, x, y, screen->w, 216);
- break;
+ return mob._mask;
}
}
+ return 0;
}
void PrinceEngine::printAt(uint32 slot, uint8 color, const char *s, uint16 x, uint16 y) {
@@ -740,7 +742,7 @@ uint32 PrinceEngine::getTextWidth(const char *s) {
return textW;
}
-void PrinceEngine::showTexts() {
+void PrinceEngine::showTexts(Graphics::Surface *screen) {
for (uint32 slot = 0; slot < MAXTEXTS; ++slot) {
Text& text = _textSlots[slot];
if (!text._str && !text._time)
@@ -751,11 +753,11 @@ void PrinceEngine::showTexts() {
for (uint8 i = 0; i < lines.size(); ++i) {
_font->drawString(
- _graph->_frontScreen,
+ screen,
lines[i],
text._x - getTextWidth(lines[i].c_str())/2,
text._y - (lines.size() - i) * (_font->getFontHeight()),
- _graph->_frontScreen->w,
+ screen->w,
text._color
);
}
@@ -1249,8 +1251,8 @@ void PrinceEngine::drawScreen() {
playNextFrame();
if (!_inventoryBackgroundRemember) {
- hotspot(_graph->_frontScreen, _mobList);
- showTexts();
+ _currentMob = hotspot(_graph->_frontScreen, _mobList);
+ showTexts(_graph->_frontScreen);
} else {
_inventoryBackgroundRemember = false;
}
@@ -1372,18 +1374,13 @@ void PrinceEngine::prepareInventoryToView() {
for (int j = 0; j < _invLine; j++) {
Mob tempMobItem;
if (item < _mainHero->_inventory.size()) {
- int itemNr = _mainHero->_inventory[item];
+ int itemNr = _mainHero->_inventory[item];
tempMobItem._visible = 0;
tempMobItem._mask = itemNr; // itemNr - 1??
- tempMobItem._x1 = currInvX + _picWindowX; //picWindowX2 ?
- tempMobItem._x2 = currInvX + _picWindowX + _invLineW - 1; // picWindowX2 ?
- tempMobItem._y1 = currInvY;
- tempMobItem._y2 = currInvY + _invLineH - 1;
-
- tempMobItem._rect.left = tempMobItem._x1;
- tempMobItem._rect.right = tempMobItem._x2;
- tempMobItem._rect.top = tempMobItem._y1;
- tempMobItem._rect.bottom = tempMobItem._y2;
+ tempMobItem._rect.left = currInvX + _picWindowX; //picWindowX2 ?
+ tempMobItem._rect.right = currInvX + _picWindowX + _invLineW - 1; // picWindowX2 ?
+ tempMobItem._rect.top = currInvY;
+ tempMobItem._rect.bottom = currInvY + _invLineH - 1;
tempMobItem._name = "";
tempMobItem._examText = "";
@@ -1466,6 +1463,59 @@ void PrinceEngine::drawInvItems() {
}
}
+void PrinceEngine::inventoryLeftButton() {
+ if (_optionsFlag == 1) {
+ //check_opt
+ if (_currentMob != 0) {
+ if (_optionEnabled < _invOptionsNumber) {
+ _optionsFlag = 0;
+ // ebp = _currentMob;
+ } else {
+ return;
+ }
+ } else {
+ // test bx, RMBMask 7996 ?
+ }
+ } else {
+ if (_currentMob != 0) {
+ //if (_currentPointerNumber != 2) {
+ if (_currentMob != 29) {
+ _optionEnabled = 0;
+ } else {
+ _optionEnabled = 1;
+ }
+ //do_option
+ //} else {
+ //use_item_on_item
+ //}
+ }
+ }
+ //do_option
+ int selectedMob = _currentMob; // no _currentMob just selectedMob as global for _currentMob.mask ?
+ if (_optionEnabled == 0) {
+ int invObjExamEvent = _script->scanInvObjExamEvents(selectedMob); // test this
+ if (invObjExamEvent == -1) {
+ // do_standard
+ printAt(0, 216, _invMobList[selectedMob]._examText.c_str(), kNormalWidth / 2, _invExamY);
+ showTexts(_graph->_screenForInventory); // here?
+ // setSpecVoice();
+ } else {
+ //store_new_pc
+ // storeNewPC();
+ _flags->setFlagValue(Flags::CURRMOB, selectedMob);
+ _currentMob = 0;
+ //_optionsMob = 0;
+ }
+ } else {
+ // not_examine
+
+ }
+}
+
+void PrinceEngine::inventoryRightButton() {
+
+}
+
void PrinceEngine::displayInventory() {
// temp:
_mainHero->_inventory.clear();
@@ -1475,10 +1525,41 @@ void PrinceEngine::displayInventory() {
_mainHero->_inventory.push_back(4);
_mainHero->_inventory.push_back(68);
+ _mainHero->_inventory.push_back(29);
+ _mainHero->_inventory.push_back(13);
+ _mainHero->_inventory.push_back(44);
+ _mainHero->_inventory.push_back(67);
+
prepareInventoryToView();
while (!shouldQuit()) {
+ rememberScreenInv();
+
+ Graphics::Surface *suitcase = _suitcaseBmp->getSurface();
+ _graph->drawTransparentSurface(_graph->_screenForInventory, 0, 0, suitcase, 0);
+
+ drawInvItems();
+
+ Common::Rect _inventoryRect;
+ _inventoryRect.left = _invX1;
+ _inventoryRect.top = _invY1;
+ _inventoryRect.right = _invX1 + _invWidth;
+ _inventoryRect.bottom = _invY1 + _invHeight;
+ Common::Point mousePos = _system->getEventManager()->getMousePos();
+
+ if (!_invCurInside && _inventoryRect.contains(mousePos)) {
+ _invCurInside = true;
+ }
+
+ if (_invCurInside && !_inventoryRect.contains(mousePos)) {
+ inventoryFlagChange(false);
+ _invCurInside = false;
+ break;
+ }
+
+ _currentMob = hotspot(_graph->_screenForInventory, _invMobList);
+
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
@@ -1491,6 +1572,8 @@ void PrinceEngine::displayInventory() {
case Common::EVENT_MOUSEMOVE:
break;
case Common::EVENT_LBUTTONDOWN:
+ inventoryLeftButton();
+ break;
case Common::EVENT_RBUTTONDOWN:
break;
case Common::EVENT_LBUTTONUP:
@@ -1506,31 +1589,6 @@ void PrinceEngine::displayInventory() {
if (shouldQuit())
return;
- rememberScreenInv();
-
- Graphics::Surface *suitcase = _suitcaseBmp->getSurface();
- _graph->drawTransparentSurface(_graph->_screenForInventory, 0, 0, suitcase, 0);
-
- drawInvItems();
-
- Common::Rect _inventoryRect;
- _inventoryRect.left = _invX1;
- _inventoryRect.top = _invY1;
- _inventoryRect.right = _invX1 + _invWidth;
- _inventoryRect.bottom = _invY1 + _invHeight;
- Common::Point mousePos = _system->getEventManager()->getMousePos();
-
- if (!_invCurInside && _inventoryRect.contains(mousePos)) {
- _invCurInside = true;
- }
-
- if (_invCurInside && !_inventoryRect.contains(mousePos)) {
- inventoryFlagChange(false);
- _invCurInside = false;
- break;
- }
-
- hotspot(_graph->_screenForInventory, _invMobList);
getDebugger()->onFrame();
_graph->update(_graph->_screenForInventory);
pause();
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index b85a1610c8..46c573b0a6 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -273,12 +273,18 @@ public:
void showMask(int maskNr, Graphics::Surface *originalRoomSurface);
void clsMasks();
+ int _currentMob; // number of selected Mob / inventory item
+
static const int16 kMaxInv = 90; // max amount of inventory items in whole game
uint32 _invTxtSize;
byte *_invTxt;
bool _showInventoryFlag;
+ bool _optionsFlag;
+ int _optionEnabled;
+ int _invOptionsNumber;
+ int _invExamY;
bool _inventoryBackgroundRemember;
int _invLineX;
int _invLineY;
@@ -307,6 +313,8 @@ public:
void displayInventory();
void addInvObj();
void makeInvCursor();
+ void inventoryLeftButton();
+ void inventoryRightButton();
int testAnimNr;
int testAnimFrame;
@@ -314,9 +322,9 @@ public:
private:
bool playNextFrame();
void keyHandler(Common::Event event);
- void hotspot(Graphics::Surface *screen, Common::Array<Mob> &mobList);
+ int hotspot(Graphics::Surface *screen, Common::Array<Mob> &mobList);
void drawScreen();
- void showTexts();
+ void showTexts(Graphics::Surface *screen);
void init();
void showLogo();
void showBackAnims();
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 331e425a42..4eed60d7e5 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -205,6 +205,27 @@ uint8 *Script::getRoomOffset(int locationNr) {
return &_data[_scriptInfo.rooms + locationNr * 64];
}
+struct RE {
+ int16 _mob; // number of Mob, -1 for end of list
+ int32 _code; // offset of code in script
+};
+
+int Script::scanInvObjExamEvents(int mobMask) {
+ RE tempRE;
+ int i = 0;
+ do {
+ tempRE._mob = (int)READ_UINT16(&_data[_scriptInfo.invObjExam + i * 6]);
+ debug("mob: %d", tempRE._mob);
+ tempRE._code = (int)READ_UINT32(&_data[_scriptInfo.invObjExam + i * 6 + 2]);
+ debug("code: %d", tempRE._code);
+ if (tempRE._mob == mobMask) {
+ return tempRE._code;
+ }
+ i++;
+ } while (tempRE._mob != -1); //?? || i <= 1 or without this (no items there)
+ return -1; // or sth else?
+}
+
void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, int offset) {
BackgroundAnim newBackgroundAnim;
diff --git a/engines/prince/script.h b/engines/prince/script.h
index 4b9f85a61e..06b09b94c4 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -137,6 +137,8 @@ public:
void installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, int offset);
bool loadAllMasks(Common::Array<Mask> &maskList, int offset);
+ int scanInvObjExamEvents(int mobMask);
+
const char *getString(uint32 offset) {
return (const char *)(&_data[offset]);
}