MADS: Implementing UserInterface loading
This commit is contained in:
parent
ca6cf0eaf2
commit
c4ed42e6d5
3 changed files with 123 additions and 7 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include "mads/events.h"
|
#include "mads/events.h"
|
||||||
#include "mads/game_data.h"
|
#include "mads/game_data.h"
|
||||||
#include "mads/messages.h"
|
#include "mads/messages.h"
|
||||||
|
#include "mads/user_interface.h"
|
||||||
|
|
||||||
namespace MADS {
|
namespace MADS {
|
||||||
|
|
||||||
|
@ -50,12 +51,6 @@ class SpriteSlot;
|
||||||
#define TEXT_DISPLAY_MAX_SIZE 40
|
#define TEXT_DISPLAY_MAX_SIZE 40
|
||||||
#define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE)
|
#define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE)
|
||||||
|
|
||||||
enum ScrCategory {
|
|
||||||
CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
|
|
||||||
CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_6 = 6, CAT_INV_SCROLLER = 7,
|
|
||||||
CAT_12 = 12
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Layer {
|
enum Layer {
|
||||||
LAYER_GUI = 19
|
LAYER_GUI = 19
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,8 @@ void SceneNode::load(Common::SeekableReadStream *f) {
|
||||||
UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
|
UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
|
||||||
_category = CAT_NONE;
|
_category = CAT_NONE;
|
||||||
_screenObjectsCount = 0;
|
_screenObjectsCount = 0;
|
||||||
|
_inventoryTopIndex = 0;
|
||||||
|
_objectY = 0;
|
||||||
|
|
||||||
byte *pData = _vm->_screen.getBasePtr(0, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
|
byte *pData = _vm->_screen.getBasePtr(0, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
|
||||||
setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
|
setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
|
||||||
|
@ -123,7 +125,105 @@ void UserInterface::setBounds(const Common::Rect &r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserInterface::loadElements() {
|
void UserInterface::loadElements() {
|
||||||
warning("TODO: UserInterface::loadElements");
|
Scene &scene = _vm->_game->_scene;
|
||||||
|
Common::Rect bounds;
|
||||||
|
scene._screenObjects.clear();
|
||||||
|
|
||||||
|
if (!scene._screenObjects._v832EC) {
|
||||||
|
for (int idx = 1; idx <= 3; ++idx) {
|
||||||
|
getBounds(CAT_INV_SCROLLER, idx, bounds);
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds) {
|
||||||
|
Common::Rect result;
|
||||||
|
int heightMultiplier, widthMultiplier;
|
||||||
|
int leftStart, yOffset, widthAmt;
|
||||||
|
|
||||||
|
switch (category) {
|
||||||
|
case CAT_ACTION:
|
||||||
|
heightMultiplier = v / 5;
|
||||||
|
widthMultiplier = v / 5;
|
||||||
|
leftStart = 2;
|
||||||
|
yOffset = 3;
|
||||||
|
widthAmt = 32;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAT_INV_LIST:
|
||||||
|
if (v < _inventoryTopIndex || v > (_inventoryTopIndex + 5))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
heightMultiplier = v - _inventoryTopIndex;
|
||||||
|
widthMultiplier = 0;
|
||||||
|
leftStart = 90;
|
||||||
|
yOffset = 3;
|
||||||
|
widthAmt = 69;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAT_6:
|
||||||
|
heightMultiplier = v;
|
||||||
|
widthMultiplier = 0;
|
||||||
|
leftStart = 2;
|
||||||
|
yOffset = 3;
|
||||||
|
widthAmt = 310;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAT_INV_SCROLLER:
|
||||||
|
heightMultiplier = 0;
|
||||||
|
widthMultiplier = 73;
|
||||||
|
yOffset = 0;
|
||||||
|
widthAmt = 9;
|
||||||
|
leftStart = (v != 73) ? 73 : 75;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
heightMultiplier = v;
|
||||||
|
widthMultiplier = 0;
|
||||||
|
leftStart = 240;
|
||||||
|
yOffset = 3;
|
||||||
|
widthAmt = 80;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.left = (widthMultiplier > 0) ? widthMultiplier * widthAmt + leftStart : leftStart;
|
||||||
|
result.setWidth(widthAmt);
|
||||||
|
result.top = heightMultiplier * 3 + yOffset;
|
||||||
|
result.setHeight(8);
|
||||||
|
|
||||||
|
if (category == CAT_INV_SCROLLER) {
|
||||||
|
switch (v) {
|
||||||
|
case 1:
|
||||||
|
// Arrow up
|
||||||
|
result.top = 4;
|
||||||
|
result.setHeight(7);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
// Arrow down
|
||||||
|
result.top = 35;
|
||||||
|
result.setHeight(7);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
// Scroller
|
||||||
|
result.top = 12;
|
||||||
|
result.setHeight(22);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
// Thumb
|
||||||
|
result.top = _objectY + 14;
|
||||||
|
result.setHeight(1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserInterface::extendRect(Common::Rect &bounds) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace MADS
|
} // End of namespace MADS
|
||||||
|
|
|
@ -30,17 +30,38 @@
|
||||||
|
|
||||||
namespace MADS {
|
namespace MADS {
|
||||||
|
|
||||||
|
enum ScrCategory {
|
||||||
|
CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
|
||||||
|
CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_6 = 6, CAT_INV_SCROLLER = 7,
|
||||||
|
CAT_12 = 12
|
||||||
|
};
|
||||||
|
|
||||||
class UserInterface : public MSurface {
|
class UserInterface : public MSurface {
|
||||||
private:
|
private:
|
||||||
MADSEngine *_vm;
|
MADSEngine *_vm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the elements of the user interface
|
||||||
|
*/
|
||||||
void loadElements();
|
void loadElements();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the area within the user interface a given element falls
|
||||||
|
*/
|
||||||
|
bool getBounds(ScrCategory category, int invIndex, Common::Rect &bounds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reposition a bounding rectangle to physical co-ordinates
|
||||||
|
*/
|
||||||
|
void extendRect(Common::Rect &bounds);
|
||||||
public:
|
public:
|
||||||
ScrCategory _category;
|
ScrCategory _category;
|
||||||
int _screenObjectsCount;
|
int _screenObjectsCount;
|
||||||
Common::Rect _bounds;
|
Common::Rect _bounds;
|
||||||
Common::Rect *_rectP;
|
Common::Rect *_rectP;
|
||||||
MSurface _surface;
|
MSurface _surface;
|
||||||
|
int _inventoryTopIndex;
|
||||||
|
int _objectY;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue