[Scummvm-git-logs] scummvm master -> 2e38da497ac251799ccba41b330dae058fa0d13b
OMGPizzaGuy
48367439+OMGPizzaGuy at users.noreply.github.com
Mon Aug 10 23:16:32 UTC 2020
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:
2e38da497a ULTIMA8: Alter Ultima8::Rect constructors and some methods to match Common::Rect
Commit: 2e38da497ac251799ccba41b330dae058fa0d13b
https://github.com/scummvm/scummvm/commit/2e38da497ac251799ccba41b330dae058fa0d13b
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-08-10T18:15:37-05:00
Commit Message:
ULTIMA8: Alter Ultima8::Rect constructors and some methods to match Common::Rect
Changed paths:
engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
engines/ultima/ultima8/graphics/fonts/font.cpp
engines/ultima/ultima8/graphics/gump_shape_archive.cpp
engines/ultima/ultima8/gumps/game_map_gump.cpp
engines/ultima/ultima8/gumps/gump.cpp
engines/ultima/ultima8/gumps/paperdoll_gump.cpp
engines/ultima/ultima8/gumps/u8_save_gump.cpp
engines/ultima/ultima8/gumps/widgets/button_widget.cpp
engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
engines/ultima/ultima8/gumps/widgets/text_widget.cpp
engines/ultima/ultima8/misc/rect.h
engines/ultima/ultima8/world/current_map.cpp
engines/ultima/ultima8/world/item.cpp
engines/ultima/ultima8/world/item_sorter.cpp
engines/ultima/ultima8/world/snap_process.cpp
diff --git a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
index efc3885199..796d14b38b 100644
--- a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
@@ -421,7 +421,7 @@ void BaseSoftRenderSurface::GetSurfaceDims(Rect &r) const {
//
void BaseSoftRenderSurface::SetOrigin(int32 x, int32 y) {
// Adjust the clipping window
- _clipWindow.MoveRel(_ox - x, _oy - y);
+ _clipWindow.translate(_ox - x, _oy - y);
// Set the origin
_ox = x;
diff --git a/engines/ultima/ultima8/graphics/fonts/font.cpp b/engines/ultima/ultima8/graphics/fonts/font.cpp
index de2aa5df17..f3413dc225 100644
--- a/engines/ultima/ultima8/graphics/fonts/font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/font.cpp
@@ -345,10 +345,10 @@ Std::list<PositionedText> typesetText(Font *font,
case Font::TEXT_LEFT:
break;
case Font::TEXT_RIGHT:
- lineiter->_dims.MoveAbs(totalwidth - lineiter->_dims.width(), lineiter->_dims.top);
+ lineiter->_dims.moveTo(totalwidth - lineiter->_dims.width(), lineiter->_dims.top);
break;
case Font::TEXT_CENTER:
- lineiter->_dims.MoveAbs((totalwidth - lineiter->_dims.width()) / 2, lineiter->_dims.top);
+ lineiter->_dims.moveTo((totalwidth - lineiter->_dims.width()) / 2, lineiter->_dims.top);
break;
}
#if 0
diff --git a/engines/ultima/ultima8/graphics/gump_shape_archive.cpp b/engines/ultima/ultima8/graphics/gump_shape_archive.cpp
index 57bab98f3f..2a7948302f 100644
--- a/engines/ultima/ultima8/graphics/gump_shape_archive.cpp
+++ b/engines/ultima/ultima8/graphics/gump_shape_archive.cpp
@@ -38,12 +38,12 @@ void GumpShapeArchive::loadGumpage(Common::SeekableReadStream *rs) {
unsigned int total = rs->size() / 8;
_gumpItemArea.resize(total + 1);
for (unsigned int i = 1; i <= total; ++i) {
- int x, y, w, h;
- x = static_cast<int16>(rs->readUint16LE());
- y = static_cast<int16>(rs->readUint16LE());
- w = static_cast<int16>(rs->readUint16LE()) - x;
- h = static_cast<int16>(rs->readUint16LE()) - y;
- _gumpItemArea[i] = new Rect(x, y, w, h);
+ int x1, y1, x2, y2;
+ x1 = static_cast<int16>(rs->readUint16LE());
+ y1 = static_cast<int16>(rs->readUint16LE());
+ x2 = static_cast<int16>(rs->readUint16LE());
+ y2 = static_cast<int16>(rs->readUint16LE());
+ _gumpItemArea[i] = new Rect(x1, y1, x2, y2);
}
}
diff --git a/engines/ultima/ultima8/gumps/game_map_gump.cpp b/engines/ultima/ultima8/gumps/game_map_gump.cpp
index 3193eeb62f..ded60fbcd2 100644
--- a/engines/ultima/ultima8/gumps/game_map_gump.cpp
+++ b/engines/ultima/ultima8/gumps/game_map_gump.cpp
@@ -69,7 +69,7 @@ GameMapGump::GameMapGump(int x, int y, int width, int height) :
_displayList(0), _displayDragging(false), _draggingShape(0), _draggingFrame(0),
_draggingFlags(0) {
// Offset the gump. We want 0,0 to be the centre
- _dims.MoveAbs(-_dims.width() / 2, -_dims.height() / 2);
+ _dims.moveTo(-_dims.width() / 2, -_dims.height() / 2);
pout << "Create _displayList ItemSorter object" << Std::endl;
_displayList = new ItemSorter();
@@ -573,7 +573,7 @@ void GameMapGump::RenderSurfaceChanged() {
_dims.setHeight(new_dims.height());
// Offset the gump. We want 0,0 to be the centre
- _dims.MoveAbs(-_dims.width() / 2, -_dims.height() / 2);
+ _dims.moveTo(-_dims.width() / 2, -_dims.height() / 2);
Gump::RenderSurfaceChanged();
}
diff --git a/engines/ultima/ultima8/gumps/gump.cpp b/engines/ultima/ultima8/gumps/gump.cpp
index 4ec44ae0e0..b8a10795d0 100644
--- a/engines/ultima/ultima8/gumps/gump.cpp
+++ b/engines/ultima/ultima8/gumps/gump.cpp
@@ -403,7 +403,7 @@ bool Gump::PointOnGump(int mx, int my) {
ParentToGump(gx, gy);
// First check again rectangle
- if (!_dims.InRect(gx, gy)) {
+ if (!_dims.contains(gx, gy)) {
return false;
}
diff --git a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
index 54c9028ea3..eae4c79fe2 100644
--- a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
+++ b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
@@ -82,7 +82,7 @@ static const int statbuttony = 84;
PaperdollGump::PaperdollGump() : ContainerGump(), _statButtonId(0),
- _backpackRect(49, 25, 10, 25) {
+ _backpackRect(49, 25, 59, 50) {
Common::fill(_cachedText, _cachedText + 14, (RenderedText *)nullptr);
Common::fill(_cachedVal, _cachedVal + 7, 0);
}
@@ -90,7 +90,7 @@ PaperdollGump::PaperdollGump() : ContainerGump(), _statButtonId(0),
PaperdollGump::PaperdollGump(Shape *shape_, uint32 frameNum, uint16 owner,
uint32 Flags, int32 layer)
: ContainerGump(shape_, frameNum, owner, Flags, layer),
- _statButtonId(0), _backpackRect(49, 25, 10, 25) {
+ _statButtonId(0), _backpackRect(49, 25, 59, 50) {
_statButtonId = 0;
Common::fill(_cachedText, _cachedText + 14, (RenderedText *)nullptr);
@@ -252,7 +252,7 @@ uint16 PaperdollGump::TraceObjId(int32 mx, int32 my) {
}
// try backpack
- if (_backpackRect.InRect(mx - _itemArea.left, my - _itemArea.top)) {
+ if (_backpackRect.contains(mx - _itemArea.left, my - _itemArea.top)) {
if (a->getEquip(7)) // constants
return a->getEquip(7);
}
@@ -311,7 +311,7 @@ bool PaperdollGump::StartDraggingItem(Item *item, int mx, int my) {
bool PaperdollGump::DraggingItem(Item *item, int mx, int my) {
- if (!_itemArea.InRect(mx, my)) {
+ if (!_itemArea.contains(mx, my)) {
_displayDragging = false;
return false;
}
@@ -322,7 +322,7 @@ bool PaperdollGump::DraggingItem(Item *item, int mx, int my) {
bool over_backpack = false;
Container *backpack = getContainer(a->getEquip(7)); // constant!
- if (backpack && _backpackRect.InRect(mx - _itemArea.left, my - _itemArea.top)) {
+ if (backpack && _backpackRect.contains(mx - _itemArea.left, my - _itemArea.top)) {
over_backpack = true;
}
@@ -367,7 +367,7 @@ void PaperdollGump::DropItem(Item *item, int mx, int my) {
bool over_backpack = false;
Container *backpack = getContainer(a->getEquip(7)); // constant!
- if (backpack && _backpackRect.InRect(mx - _itemArea.left, my - _itemArea.top)) {
+ if (backpack && _backpackRect.contains(mx - _itemArea.left, my - _itemArea.top)) {
over_backpack = true;
}
diff --git a/engines/ultima/ultima8/gumps/u8_save_gump.cpp b/engines/ultima/ultima8/gumps/u8_save_gump.cpp
index f1e9b82382..f97201e93e 100644
--- a/engines/ultima/ultima8/gumps/u8_save_gump.cpp
+++ b/engines/ultima/ultima8/gumps/u8_save_gump.cpp
@@ -115,7 +115,7 @@ void U8SaveGump::InitGump(Gump *newparent, bool take_focus) {
// frame for '10', cutting off the first 6 pixels.
Rect rect;
gump->GetDims(rect);
- rect.MoveRel(6, 0);
+ rect.translate(6, 0);
gump->SetDims(rect);
}
gump->InitGump(this, false);
diff --git a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
index bb77a36b56..8b00510595 100644
--- a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
@@ -105,7 +105,7 @@ bool ButtonWidget::PointOnGump(int mx, int my) {
int32 gx = mx, gy = my;
ParentToGump(gx, gy);
- return _dims.InRect(gx, gy);
+ return _dims.contains(gx, gy);
}
Gump *ButtonWidget::onMouseDown(int button, int32 mx, int32 my) {
diff --git a/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp b/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
index e9591e9a48..4ef9ec0e85 100644
--- a/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
@@ -55,12 +55,12 @@ void EditWidget::InitGump(Gump *newparent, bool take_focus) {
Font *font = getFont();
// Y offset is always baseline
- _dims.MoveAbs(0 , -font->getBaseline());
+ _dims.moveTo(0, -font->getBaseline());
if (_gameFont && getFont()->isHighRes()) {
Rect rect(0, 0, 0, _dims.top);
ScreenSpaceToGumpRect(rect, ROUND_OUTSIDE);
- _dims.MoveAbs(0, rect.height());
+ _dims.moveTo(0, rect.height());
}
}
diff --git a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
index e1347efcc8..b7c5363694 100644
--- a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
@@ -59,12 +59,12 @@ void TextWidget::InitGump(Gump *newparent, bool take_focus) {
Font *font = getFont();
// Y offset is always baseline
- _dims.MoveAbs(0, -font->getBaseline());
+ _dims.moveTo(0, -font->getBaseline());
if (_gameFont && getFont()->isHighRes()) {
Rect rect(0, 0, 0, _dims.top);
ScreenSpaceToGumpRect(rect, ROUND_OUTSIDE);
- _dims.MoveAbs(0 , rect.height());
+ _dims.moveTo(0, rect.height());
// Note that GumpRectToScreenSpace is guaranteed to keep
// _targetWidth/_targetHeight zero if they already were.
@@ -136,7 +136,7 @@ bool TextWidget::setupNextText() {
sr.Set(0, 0, 0, _dims.top);
ScreenSpaceToGumpRect(sr, ROUND_OUTSIDE);
- _dims.MoveAbs(_dims.left, sr.height());
+ _dims.moveTo(_dims.left, sr.height());
}
}
diff --git a/engines/ultima/ultima8/misc/rect.h b/engines/ultima/ultima8/misc/rect.h
index 526a2ceb1c..1b7db07014 100644
--- a/engines/ultima/ultima8/misc/rect.h
+++ b/engines/ultima/ultima8/misc/rect.h
@@ -30,8 +30,8 @@ struct Rect {
int32 left, top;
int32 right, bottom;
- Rect() : left(0), top(0), right(0), bottom(0) {}
- Rect(int nx, int ny, int nw, int nh) : left(nx), top(ny), right(nx + nw), bottom(ny + nh) {}
+ Rect() : top(0), left(0), bottom(0), right(0) {}
+ Rect(int x1, int y1, int x2, int y2) : top(y1), left(x1), bottom(y2), right(x2) {}
bool operator==(const Rect &rhs) const { return equals(rhs); }
bool operator!=(const Rect &rhs) const { return !equals(rhs); }
@@ -60,9 +60,6 @@ struct Rect {
right = nx + nw;
bottom = ny + nh;
}
- void Set(Rect &o) {
- *this = o;
- }
// Check to see if a Rectangle is 'valid'
bool IsValid() const {
@@ -70,30 +67,24 @@ struct Rect {
}
// Check to see if a point is within the Rectangle
- bool InRect(int px, int py) const {
- return px >= left && py >= top && px < right && py < bottom;
+ bool contains(int16 x, int16 y) const {
+ return (left <= x) && (x < right) && (top <= y) && (y < bottom);
}
// Move the Rect (Relative)
- void MoveRel(int32 dx, int32 dy) {
+ void translate(int32 dx, int32 dy) {
left += dx;
- top += dy;
right += dx;
+ top += dy;
bottom += dy;
}
// Move the Rect (Absolute)
- void MoveAbs(int32 nx, int32 ny) {
- right += nx - left;
- bottom += ny - top;
- left = nx;
- top = ny;
- }
-
- // Resize the Rect (Relative)
- void ResizeRel(int32 dw, int32 dh) {
- right += dw;
- bottom += dh;
+ void moveTo(int32 x, int32 y) {
+ bottom += y - top;
+ right += x - left;
+ top = y;
+ left = x;
}
// Resize the Rect (Absolute)
@@ -176,18 +167,6 @@ struct Rect {
return true;
}
- // Operator +=
- Rect &operator += (const Rect &o) {
- Union(o.left, o.top, o.width(), o.height());
- return *(this);
- }
-
- // Operator +
- Rect &operator + (const Rect &o) const {
- Rect result(*this);
- return (result += o);
- }
-
bool equals(const Rect &o) const {
return left == o.left && top == o.top && right == o.right && bottom == o.bottom;
}
diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 22aa88ff88..e8817298bb 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -523,7 +523,7 @@ void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript,
check->getFootpadWorld(xd, yd, zd);
}
- const Rect searchrange(x - xd - range, y - yd - range, 2 * range + xd, 2 * range + yd);
+ const Rect searchrange(x - xd - range, y - yd - range, x + range, y + range);
int minx = ((x - xd - range) / _mapChunkSize) - 1;
int maxx = ((x + range) / _mapChunkSize) + 1;
@@ -549,7 +549,7 @@ void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript,
int32 ixd, iyd, izd;
item->getFootpadWorld(ixd, iyd, izd);
- const Rect itemrect(ix - ixd, iy - iyd, ixd, iyd);
+ const Rect itemrect(ix - ixd, iy - iyd, ix, iy);
if (!itemrect.Overlaps(searchrange))
continue;
@@ -592,7 +592,7 @@ void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript,
int32 origin[3], int32 dims[3],
bool above, bool below, bool recurse) const {
const Rect searchrange(origin[0] - dims[0], origin[1] - dims[1],
- dims[0], dims[1]);
+ origin[0], origin[1]);
int minx = ((origin[0] - dims[0]) / _mapChunkSize) - 1;
int maxx = ((origin[0]) / _mapChunkSize) + 1;
@@ -619,7 +619,7 @@ void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript,
int32 ixd, iyd, izd;
item->getFootpadWorld(ixd, iyd, izd);
- const Rect itemrect(ix - ixd, iy - iyd, ixd, iyd);
+ const Rect itemrect(ix - ixd, iy - iyd, ix, iy);
if (!itemrect.Overlaps(searchrange))
continue;
diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index 003175b4bb..2cd989faca 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -606,8 +606,8 @@ bool Item::isOnScreen() const {
int32 xd, yd, zd;
getFootpadWorld(xd, yd, zd);
- if (game_map_dims.InRect(screenx, screeny) &&
- game_map_dims.InRect(screenx + xd, screeny + yd)) {
+ if (game_map_dims.contains(screenx, screeny) &&
+ game_map_dims.contains(screenx + xd, screeny + yd)) {
return true;
}
diff --git a/engines/ultima/ultima8/world/item_sorter.cpp b/engines/ultima/ultima8/world/item_sorter.cpp
index 126e8f2573..de83050bdb 100644
--- a/engines/ultima/ultima8/world/item_sorter.cpp
+++ b/engines/ultima/ultima8/world/item_sorter.cpp
@@ -684,7 +684,7 @@ void ItemSorter::AddItem(int32 x, int32 y, int32 z, uint32 shapeNum, uint32 fram
si->_sy2 = si->_sy + _frame->_height; // Bottom
// Do Clipping here
- si->_clipped = _surf->CheckClipped(Rect(si->_sx, si->_sy, _frame->_width, _frame->_height));
+ si->_clipped = _surf->CheckClipped(Rect(si->_sx, si->_sy, si->_sx + _frame->_width, si->_sy + _frame->_height));
if (si->_clipped < 0)
// Clipped away entirely - don't add to the list.
return;
diff --git a/engines/ultima/ultima8/world/snap_process.cpp b/engines/ultima/ultima8/world/snap_process.cpp
index f85c8ea372..83b1a3e258 100644
--- a/engines/ultima/ultima8/world/snap_process.cpp
+++ b/engines/ultima/ultima8/world/snap_process.cpp
@@ -66,7 +66,7 @@ void SnapProcess::updateCurrentEgg() {
int32 ax, ay, az, axd, ayd, azd, x, y, z;
a->getLocation(ax, ay, az);
a->getFootpadWorld(axd, ayd, azd);
- Rect arect(ax, ay, axd, ayd);
+ Rect arect(ax, ay, ax + axd, ay + ayd);
for (Std::list<ObjId>::const_iterator iter = _snapEggs.begin();
iter != _snapEggs.end(); iter++) {
@@ -114,7 +114,7 @@ bool SnapProcess::isNpcInRangeOfCurrentEgg() const {
a->getFootpadWorld(axd, ayd, azd);
currentegg->getLocation(x, y, z);
- Rect arect(ax, ay, axd, ayd);
+ Rect arect(ax, ay, ax + axd, ay + ayd);
if (!_currentSnapEggRange.Overlaps(arect))
return false;
More information about the Scummvm-git-logs
mailing list