MADS: Fix refresh of inventory list after scrolling

This commit is contained in:
Paul Gilbert 2014-04-19 17:43:44 -04:00
parent 34d0bc72b5
commit c4669dd2f2
3 changed files with 7 additions and 16 deletions

View file

@ -54,8 +54,6 @@ void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
right = maxWidth; right = maxWidth;
_bounds.right = right; _bounds.right = right;
_bounds2.left = _bounds.width() / 2;
_bounds2.right = _bounds.left + (_bounds.width() + 1) / 2 - 1;
if (_bounds.top < 0) if (_bounds.top < 0)
_bounds.top = 0; _bounds.top = 0;
@ -68,9 +66,6 @@ void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
bottom = maxHeight; bottom = maxHeight;
_bounds.bottom = bottom; _bounds.bottom = bottom;
_bounds2.top = _bounds.height() / 2;
_bounds2.bottom = _bounds.top + (_bounds.height() + 1) / 2 - 1;
_active = true; _active = true;
} }
@ -193,7 +188,7 @@ void DirtyAreas::merge(int startIndex, int count) {
* Returns true if two dirty areas intersect * Returns true if two dirty areas intersect
*/ */
bool DirtyAreas::intersects(int idx1, int idx2) { bool DirtyAreas::intersects(int idx1, int idx2) {
return (*this)[idx1]._bounds2.intersects((*this)[idx2]._bounds2); return (*this)[idx1]._bounds.intersects((*this)[idx2]._bounds);
} }
void DirtyAreas::mergeAreas(int idx1, int idx2) { void DirtyAreas::mergeAreas(int idx1, int idx2) {
@ -202,11 +197,6 @@ void DirtyAreas::mergeAreas(int idx1, int idx2) {
da1._bounds.extend(da2._bounds); da1._bounds.extend(da2._bounds);
da1._bounds2.left = da1._bounds.width() / 2;
da1._bounds2.right = da1._bounds.left + (da1._bounds.width() + 1) / 2 - 1;
da1._bounds2.top = da1._bounds.height() / 2;
da1._bounds2.bottom = da1._bounds.top + (da1._bounds.height() + 1) / 2 - 1;
da2._active = false; da2._active = false;
da2._mergedArea = &da1; da2._mergedArea = &da1;
da1._textActive = true; da1._textActive = true;

View file

@ -66,7 +66,6 @@ private:
friend class DirtyAreas; friend class DirtyAreas;
public: public:
Common::Rect _bounds; Common::Rect _bounds;
Common::Rect _bounds2;
bool _textActive; bool _textActive;
bool _active; bool _active;
DirtyArea *_mergedArea; DirtyArea *_mergedArea;

View file

@ -98,7 +98,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
if (dirtyAreaPtr) if (dirtyAreaPtr)
dirtyAreaPtr->_active = true; dirtyAreaPtr->_active = true;
// Copy parts of the user interface background that are going to have sprites drawn // Copy parts of the user interface background that need to be erased
for (uint idx = 0; idx < size(); ++idx) { for (uint idx = 0; idx < size(); ++idx) {
DirtyArea &dirtyArea = userInterface._dirtyAreas[idx]; DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
UISlot &slot = (*this)[idx]; UISlot &slot = (*this)[idx];
@ -106,11 +106,13 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
if (dirtyArea._active && dirtyArea._bounds.width() > 0 if (dirtyArea._active && dirtyArea._bounds.width() > 0
&& dirtyArea._bounds.height() > 0 && slot._flags >= -20) { && dirtyArea._bounds.height() > 0 && slot._flags >= -20) {
// TODO: Figure out the difference between two copy methods used
if (slot._flags >= IMG_ERASE) { if (slot._flags >= IMG_ERASE) {
// Merge area
error("TODO: Create a sprite merge method");
userInterface._surface.copyTo(&userInterface, dirtyArea._bounds, userInterface._surface.copyTo(&userInterface, dirtyArea._bounds,
Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top)); Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
} else { } else {
// Copy area
userInterface._surface.copyTo(&userInterface, dirtyArea._bounds, userInterface._surface.copyTo(&userInterface, dirtyArea._bounds,
Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top)); Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
} }
@ -183,7 +185,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
if (slot._flags < IMG_STATIC) { if (slot._flags < IMG_STATIC) {
if (delFlag || updateFlag) if (delFlag || updateFlag)
remove_at(idx); remove_at(idx);
else if (slot._flags >= -20) else if (slot._flags > -20)
slot._flags -= 20; slot._flags -= 20;
} else { } else {
if (updateFlag) if (updateFlag)
@ -721,7 +723,7 @@ void UserInterface::inventoryAnim() {
// Loop through the slots list for inventory animation entry // Loop through the slots list for inventory animation entry
for (uint i = 0; i < _uiSlots.size(); ++i) { for (uint i = 0; i < _uiSlots.size(); ++i) {
if (_uiSlots[i]._segmentId == IMG_SPINNING_OBJECT) if (_uiSlots[i]._segmentId == IMG_SPINNING_OBJECT)
_uiSlots[i]._flags = -5; _uiSlots[i]._flags = IMG_UPDATE_ONLY;
} }
// Add a new slot entry for the inventory animation // Add a new slot entry for the inventory animation