[Scummvm-git-logs] scummvm master -> 2f9b446c785d919090a60e3c346b104f63401c53
OMGPizzaGuy
48367439+OMGPizzaGuy at users.noreply.github.com
Mon Aug 10 01:57:02 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:
2f9b446c78 ULTIMA8: Alter Ultima8::Rect to track left, top, right, bottom similar to Common::Rect
Commit: 2f9b446c785d919090a60e3c346b104f63401c53
https://github.com/scummvm/scummvm/commit/2f9b446c785d919090a60e3c346b104f63401c53
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-08-09T20:54:18-05:00
Commit Message:
ULTIMA8: Alter Ultima8::Rect to track left, top, right, bottom similar to Common::Rect
Changed paths:
engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
engines/ultima/ultima8/graphics/fonts/font.cpp
engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp
engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
engines/ultima/ultima8/graphics/fonts/tt_font.cpp
engines/ultima/ultima8/graphics/soft_render_surface.inl
engines/ultima/ultima8/gumps/computer_gump.cpp
engines/ultima/ultima8/gumps/container_gump.cpp
engines/ultima/ultima8/gumps/game_map_gump.cpp
engines/ultima/ultima8/gumps/gump.cpp
engines/ultima/ultima8/gumps/inverter_gump.cpp
engines/ultima/ultima8/gumps/item_relative_gump.cpp
engines/ultima/ultima8/gumps/paperdoll_gump.cpp
engines/ultima/ultima8/gumps/remorse_menu_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/kernel/mouse.cpp
engines/ultima/ultima8/misc/rect.h
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 5b994dcaff..efc3885199 100644
--- a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
@@ -499,9 +499,9 @@ void BaseSoftRenderSurface::SetFlipped(bool wantFlipped) {
// What we 'need' to do is negate the pitches, and flip the clipping window
// We keep the 'origin' in the same position relative to the clipping window
- _oy -= _clipWindow.y;
- _clipWindow.setHeight(_height - _clipWindow.y + _clipWindow.height());
- _oy += _clipWindow.y;
+ _oy -= _clipWindow.top;
+ _clipWindow.setHeight(_height - _clipWindow.top + _clipWindow.height());
+ _oy += _clipWindow.top;
_pitch = -_pitch;
_zPitch = -_zPitch;
diff --git a/engines/ultima/ultima8/graphics/fonts/font.cpp b/engines/ultima/ultima8/graphics/fonts/font.cpp
index 919237239e..de2aa5df17 100644
--- a/engines/ultima/ultima8/graphics/fonts/font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/font.cpp
@@ -209,8 +209,8 @@ Std::list<PositionedText> typesetText(Font *font,
// break here
int32 stringwidth = 0, stringheight = 0;
font->getStringSize(curline, stringwidth, stringheight);
- line._dims.x = 0;
- line._dims.y = totalheight;
+ line._dims.left = 0;
+ line._dims.top = totalheight;
line._dims.setWidth(stringwidth);
line._dims.setHeight(stringheight);
line._text = curline;
@@ -345,10 +345,10 @@ Std::list<PositionedText> typesetText(Font *font,
case Font::TEXT_LEFT:
break;
case Font::TEXT_RIGHT:
- lineiter->_dims.x = totalwidth - lineiter->_dims.width();
+ lineiter->_dims.MoveAbs(totalwidth - lineiter->_dims.width(), lineiter->_dims.top);
break;
case Font::TEXT_CENTER:
- lineiter->_dims.x = (totalwidth - lineiter->_dims.width()) / 2;
+ lineiter->_dims.MoveAbs((totalwidth - lineiter->_dims.width()) / 2, lineiter->_dims.top);
break;
}
#if 0
diff --git a/engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp
index 687d1b7fa5..40fc1ddf51 100644
--- a/engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/jp_rendered_text.cpp
@@ -55,8 +55,8 @@ void JPRenderedText::draw(RenderSurface *surface, int x, int y, bool /*destmaske
Std::list<PositionedText>::const_iterator iter;
for (iter = _lines.begin(); iter != _lines.end(); ++iter) {
- int line_x = x + iter->_dims.x;
- int line_y = y + iter->_dims.y;
+ int line_x = x + iter->_dims.left;
+ int line_y = y + iter->_dims.top;
size_t textsize = iter->_text.size();
@@ -100,8 +100,8 @@ void JPRenderedText::drawBlended(RenderSurface *surface, int x, int y,
Std::list<PositionedText>::const_iterator iter;
for (iter = _lines.begin(); iter != _lines.end(); ++iter) {
- int line_x = x + iter->_dims.x;
- int line_y = y + iter->_dims.y;
+ int line_x = x + iter->_dims.left;
+ int line_y = y + iter->_dims.top;
size_t textsize = iter->_text.size();
diff --git a/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
index 0d1060b4d3..fa22ece209 100644
--- a/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
@@ -47,8 +47,8 @@ void ShapeRenderedText::draw(RenderSurface *surface, int x, int y, bool /*destma
Std::list<PositionedText>::const_iterator iter;
for (iter = _lines.begin(); iter != _lines.end(); ++iter) {
- int line_x = x + iter->_dims.x;
- int line_y = y + iter->_dims.y;
+ int line_x = x + iter->_dims.left;
+ int line_y = y + iter->_dims.top;
size_t textsize = iter->_text.size();
@@ -78,8 +78,8 @@ void ShapeRenderedText::drawBlended(RenderSurface *surface, int x, int y,
Std::list<PositionedText>::const_iterator iter;
for (iter = _lines.begin(); iter != _lines.end(); ++iter) {
- int line_x = x + iter->_dims.x;
- int line_y = y + iter->_dims.y;
+ int line_x = x + iter->_dims.left;
+ int line_y = y + iter->_dims.top;
size_t textsize = iter->_text.size();
diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
index 8e708f569f..f5acca558a 100644
--- a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
@@ -171,21 +171,21 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
byte *surfrow = (byte *)textSurf.getBasePtr(0, y);
// CHECKME: _borderSize!
- uint32 *bufrow = texBuf + (iter->_dims.y + y + _borderSize) * resultWidth;
+ uint32 *bufrow = texBuf + (iter->_dims.top + y + _borderSize) * resultWidth;
for (int x = 0; x < textSurf.w; x++) {
if (!_antiAliased && surfrow[x] == 1) {
- bufrow[iter->_dims.x + x + _borderSize] = _color | 0xFF000000;
+ bufrow[iter->_dims.left + x + _borderSize] = _color | 0xFF000000;
if (_borderSize <= 0) continue;
if (_borderSize == 1) {
// optimize common case
for (int dx = -1; dx <= 1; dx++) {
for (int dy = -1; dy <= 1; dy++) {
- if (x + 1 + iter->_dims.x + dx >= 0 &&
- x + 1 + iter->_dims.x + dx < resultWidth &&
+ if (x + 1 + iter->_dims.left + dx >= 0 &&
+ x + 1 + iter->_dims.left + dx < resultWidth &&
y + 1 + dy >= 0 && y + 1 + dy < resultHeight) {
- if (texBuf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] == 0) {
- texBuf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] = 0xFF000000;
+ if (texBuf[(y + iter->_dims.top + dy + 1)*resultWidth + x + 1 + iter->_dims.left + dx] == 0) {
+ texBuf[(y + iter->_dims.top + dy + 1)*resultWidth + x + 1 + iter->_dims.left + dx] = 0xFF000000;
}
}
}
@@ -194,11 +194,11 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
}
for (int dx = -_borderSize; dx <= _borderSize; dx++) {
for (int dy = -_borderSize; dy <= _borderSize; dy++) {
- if (x + _borderSize + iter->_dims.x + dx >= 0 &&
- x + _borderSize + iter->_dims.x + dx < resultWidth &&
+ if (x + _borderSize + iter->_dims.left + dx >= 0 &&
+ x + _borderSize + iter->_dims.left + dx < resultWidth &&
y + _borderSize + dy >= 0 && y + _borderSize + dy < resultHeight) {
- if (texBuf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] == 0) {
- texBuf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] = 0xFF000000;
+ if (texBuf[(y + iter->_dims.top + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.left + dx] == 0) {
+ texBuf[(y + iter->_dims.top + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.left + dx] = 0xFF000000;
}
}
}
@@ -213,33 +213,33 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
int idx = pixA;
if (_borderSize <= 0) {
- bufrow[iter->_dims.x + x + _borderSize] = TEX32_PACK_RGBA(pixR, pixG, pixB, pixA);
+ bufrow[iter->_dims.left + x + _borderSize] = TEX32_PACK_RGBA(pixR, pixG, pixB, pixA);
} else {
- bufrow[iter->_dims.x + x + _borderSize] = TEX32_PACK_RGBA(pixR, pixG, pixB, 0xFF);
+ bufrow[iter->_dims.left + x + _borderSize] = TEX32_PACK_RGBA(pixR, pixG, pixB, 0xFF);
// optimize common case
if (_borderSize == 1) for (int dx = -1; dx <= 1; dx++) {
for (int dy = -1; dy <= 1; dy++) {
- if (x + 1 + iter->_dims.x + dx >= 0 &&
- x + 1 + iter->_dims.x + dx < resultWidth &&
+ if (x + 1 + iter->_dims.left + dx >= 0 &&
+ x + 1 + iter->_dims.left + dx < resultWidth &&
y + 1 + dy >= 0 && y + 1 + dy < resultHeight) {
- uint32 alpha = TEX32_A(texBuf[(y + iter->_dims.y + dy + 1) * resultWidth + x + 1 + iter->_dims.x + dx]);
+ uint32 alpha = TEX32_A(texBuf[(y + iter->_dims.top + dy + 1) * resultWidth + x + 1 + iter->_dims.left + dx]);
if (alpha != 0xFF) {
alpha = 255 - (((255 - alpha) * (255 - idx)) >> 8);
- texBuf[(y + iter->_dims.y + dy + 1)*resultWidth + x + 1 + iter->_dims.x + dx] = alpha << TEX32_A_SHIFT;
+ texBuf[(y + iter->_dims.top + dy + 1)*resultWidth + x + 1 + iter->_dims.left + dx] = alpha << TEX32_A_SHIFT;
}
}
}
} else {
for (int dx = -_borderSize; dx <= _borderSize; dx++) {
for (int dy = -_borderSize; dy <= _borderSize; dy++) {
- if (x + _borderSize + iter->_dims.x + dx >= 0 &&
- x + _borderSize + iter->_dims.x + dx < resultWidth &&
+ if (x + _borderSize + iter->_dims.left + dx >= 0 &&
+ x + _borderSize + iter->_dims.left + dx < resultWidth &&
y + _borderSize + dy >= 0 && y + _borderSize + dy < resultHeight) {
- uint32 alpha = TEX32_A(texBuf[(y + iter->_dims.y + dy + _borderSize) * resultWidth + x + _borderSize + iter->_dims.x + dx]);
+ uint32 alpha = TEX32_A(texBuf[(y + iter->_dims.top + dy + _borderSize) * resultWidth + x + _borderSize + iter->_dims.left + dx]);
if (alpha != 0xFF) {
alpha = 255 - (((255 - alpha) * (255 - idx)) >> 8);
- texBuf[(y + iter->_dims.y + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.x + dx] = alpha << TEX32_A_SHIFT;
+ texBuf[(y + iter->_dims.top + dy + _borderSize)*resultWidth + x + _borderSize + iter->_dims.left + dx] = alpha << TEX32_A_SHIFT;
}
}
}
@@ -257,10 +257,10 @@ RenderedText *TTFont::renderText(const Std::string &text, unsigned int &remainin
int w = _ttfFont->getStringWidth(unicodeText);
for (int y = 0; y < iter->_dims.height(); y++) {
- uint32 *bufrow = texBuf + (iter->_dims.y + y) * resultWidth;
- bufrow[iter->_dims.x + w + _borderSize] = 0xFF000000;
+ uint32 *bufrow = texBuf + (iter->_dims.top + y) * resultWidth;
+ bufrow[iter->_dims.left + w + _borderSize] = 0xFF000000;
// if (_borderSize > 0)
-// bufrow[iter->_dims.x+w+_borderSize-1] = 0xFF000000;
+// bufrow[iter->_dims.left+w+_borderSize-1] = 0xFF000000;
}
}
}
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.inl b/engines/ultima/ultima8/graphics/soft_render_surface.inl
index 9c6cf90409..703f441e0a 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.inl
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.inl
@@ -121,9 +121,9 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
#define NOT_CLIPPED_Y (line >= 0 && line < scrn_height)
#define OFFSET_PIXELS (off_pixels)
- uint8 *off_pixels = _pixels + _clipWindow.x * sizeof(uintX) + _clipWindow.y * _pitch;
- x -= _clipWindow.x;
- y -= _clipWindow.y;
+ uint8 *off_pixels = _pixels + _clipWindow.left * sizeof(uintX) + _clipWindow.top * _pitch;
+ x -= _clipWindow.left;
+ y -= _clipWindow.top;
#endif
diff --git a/engines/ultima/ultima8/gumps/computer_gump.cpp b/engines/ultima/ultima8/gumps/computer_gump.cpp
index 27621ab709..b6c724de88 100644
--- a/engines/ultima/ultima8/gumps/computer_gump.cpp
+++ b/engines/ultima/ultima8/gumps/computer_gump.cpp
@@ -74,8 +74,8 @@ void ComputerGump::InitGump(Gump *newparent, bool take_focus) {
return;
}
- _dims.x = 0;
- _dims.y = 0;
+ _dims.left = 0;
+ _dims.top = 0;
_dims.setWidth(topFrame->_width);
_dims.setHeight(topFrame->_height + botFrame->_height);
diff --git a/engines/ultima/ultima8/gumps/container_gump.cpp b/engines/ultima/ultima8/gumps/container_gump.cpp
index b244051352..4feebf7301 100644
--- a/engines/ultima/ultima8/gumps/container_gump.cpp
+++ b/engines/ultima/ultima8/gumps/container_gump.cpp
@@ -99,8 +99,8 @@ void ContainerGump::getItemCoords(Item *item, int32 &itemx, int32 &itemy) {
item->setGumpLocation(itemx, itemy);
}
- itemx += _itemArea.x;
- itemy += _itemArea.y;
+ itemx += _itemArea.left;
+ itemy += _itemArea.top;
}
@@ -140,8 +140,8 @@ void ContainerGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
if (_displayDragging) {
int32 itemx, itemy;
- itemx = _draggingX + _itemArea.x;
- itemy = _draggingY + _itemArea.y;
+ itemx = _draggingX + _itemArea.left;
+ itemy = _draggingY + _itemArea.top;
Shape *s = GameData::get_instance()->getMainShapes()->
getShape(_draggingShape);
assert(s);
@@ -400,8 +400,8 @@ bool ContainerGump::DraggingItem(Item *item, int mx, int my) {
// determine target location and set dragging_x/y
- _draggingX = mx - _itemArea.x - dox;
- _draggingY = my - _itemArea.y - doy;
+ _draggingX = mx - _itemArea.left - dox;
+ _draggingY = my - _itemArea.top - doy;
const Shape *sh = item->getShapeObject();
assert(sh);
@@ -528,8 +528,8 @@ void ContainerGump::DropItem(Item *item, int mx, int my) {
int32 dox, doy;
Mouse::get_instance()->getDraggingOffset(dox, doy);
- _draggingX = mx - _itemArea.x - dox;
- _draggingY = my - _itemArea.y - doy;
+ _draggingX = mx - _itemArea.left - dox;
+ _draggingY = my - _itemArea.top - doy;
item->setGumpLocation(_draggingX, _draggingY);
}
}
@@ -537,8 +537,8 @@ void ContainerGump::DropItem(Item *item, int mx, int my) {
void ContainerGump::saveData(Common::WriteStream *ws) {
ItemRelativeGump::saveData(ws);
- ws->writeUint32LE(static_cast<uint32>(_itemArea.x));
- ws->writeUint32LE(static_cast<uint32>(_itemArea.y));
+ ws->writeUint32LE(static_cast<uint32>(_itemArea.left));
+ ws->writeUint32LE(static_cast<uint32>(_itemArea.top));
ws->writeUint32LE(static_cast<uint32>(_itemArea.width()));
ws->writeUint32LE(static_cast<uint32>(_itemArea.height()));
}
diff --git a/engines/ultima/ultima8/gumps/game_map_gump.cpp b/engines/ultima/ultima8/gumps/game_map_gump.cpp
index 028bc5efc8..3193eeb62f 100644
--- a/engines/ultima/ultima8/gumps/game_map_gump.cpp
+++ b/engines/ultima/ultima8/gumps/game_map_gump.cpp
@@ -69,8 +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.x -= _dims.width() / 2;
- _dims.y -= _dims.height() / 2;
+ _dims.MoveAbs(-_dims.width() / 2, -_dims.height() / 2);
pout << "Create _displayList ItemSorter object" << Std::endl;
_displayList = new ItemSorter();
@@ -567,17 +566,14 @@ void GameMapGump::DropItem(Item *item, int mx, int my) {
}
void GameMapGump::RenderSurfaceChanged() {
- _dims.x += _dims.width() / 2;
- _dims.y += _dims.height() / 2;
-
// Resize the desktop gump to match the parent
Rect new_dims;
_parent->GetDims(new_dims);
_dims.setWidth(new_dims.width());
_dims.setHeight(new_dims.height());
- _dims.x -= _dims.width() / 2;
- _dims.y -= _dims.height() / 2;
+ // Offset the gump. We want 0,0 to be the centre
+ _dims.MoveAbs(-_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 6e35da476b..4ec44ae0e0 100644
--- a/engines/ultima/ultima8/gumps/gump.cpp
+++ b/engines/ultima/ultima8/gumps/gump.cpp
@@ -90,8 +90,8 @@ void Gump::SetShape(FrameID frame, bool adjustsize) {
void Gump::UpdateDimsFromShape() {
const ShapeFrame *sf = _shape->getFrame(_frameNum);
assert(sf);
- _dims.x = -sf->_xoff;
- _dims.y = -sf->_yoff;
+ _dims.left = -sf->_xoff;
+ _dims.top = -sf->_yoff;
_dims.setWidth(sf->_width);
_dims.setHeight(sf->_height);
}
@@ -453,16 +453,16 @@ void Gump::GumpToScreenSpace(int32 &gx, int32 &gy, PointRoundDir r) {
// Convert a parent relative point to a gump point
void Gump::ParentToGump(int32 &px, int32 &py, PointRoundDir) {
px -= _x;
- px += _dims.x;
+ px += _dims.left;
py -= _y;
- py += _dims.y;
+ py += _dims.top;
}
// Convert a gump point to parent relative point
void Gump::GumpToParent(int32 &gx, int32 &gy, PointRoundDir) {
- gx -= _dims.x;
+ gx -= _dims.left;
gx += _x;
- gy -= _dims.y;
+ gy -= _dims.top;
gy += _y;
}
@@ -471,12 +471,12 @@ void Gump::GumpRectToScreenSpace(Rect &gr, RectRoundDir r) {
PointRoundDir tl = (r == ROUND_INSIDE ? ROUND_BOTTOMRIGHT : ROUND_TOPLEFT);
PointRoundDir br = (r == ROUND_OUTSIDE ? ROUND_BOTTOMRIGHT : ROUND_TOPLEFT);
- int32 x1 = gr.x, y1 = gr.y;
- int32 x2 = gr.x + gr.width(), y2 = gr.y + gr.height();
+ int32 x1 = gr.left, y1 = gr.top;
+ int32 x2 = gr.left + gr.width(), y2 = gr.top + gr.height();
GumpToScreenSpace(x1, y1, tl);
GumpToScreenSpace(x2, y2, br);
- gr.x = x1;
- gr.y = y1;
+ gr.left = x1;
+ gr.top = y1;
if (gr.width() != 0)
gr.setWidth(x2 - x1);
if (gr.height() != 0)
@@ -488,12 +488,12 @@ void Gump::ScreenSpaceToGumpRect(Rect &sr, RectRoundDir r) {
PointRoundDir tl = (r == ROUND_INSIDE ? ROUND_BOTTOMRIGHT : ROUND_TOPLEFT);
PointRoundDir br = (r == ROUND_OUTSIDE ? ROUND_BOTTOMRIGHT : ROUND_TOPLEFT);
- int32 x1 = sr.x, y1 = sr.y;
- int32 x2 = sr.x + sr.width(), y2 = sr.y + sr.height();
+ int32 x1 = sr.left, y1 = sr.top;
+ int32 x2 = sr.left + sr.width(), y2 = sr.top + sr.height();
ScreenSpaceToGump(x1, y1, tl);
ScreenSpaceToGump(x2, y2, br);
- sr.x = x1;
- sr.y = y1;
+ sr.left = x1;
+ sr.top = y1;
if (sr.width() != 0)
sr.setWidth(x2 - x1);
if (sr.height() != 0)
@@ -785,8 +785,8 @@ void Gump::saveData(Common::WriteStream *ws) {
ws->writeUint16LE(_owner);
ws->writeUint32LE(static_cast<uint32>(_x));
ws->writeUint32LE(static_cast<uint32>(_y));
- ws->writeUint32LE(static_cast<uint32>(_dims.x));
- ws->writeUint32LE(static_cast<uint32>(_dims.y));
+ ws->writeUint32LE(static_cast<uint32>(_dims.left));
+ ws->writeUint32LE(static_cast<uint32>(_dims.top));
ws->writeUint32LE(static_cast<uint32>(_dims.width()));
ws->writeUint32LE(static_cast<uint32>(_dims.height()));
ws->writeUint32LE(_flags);
diff --git a/engines/ultima/ultima8/gumps/inverter_gump.cpp b/engines/ultima/ultima8/gumps/inverter_gump.cpp
index 2c499b5a3d..c415dc14ed 100644
--- a/engines/ultima/ultima8/gumps/inverter_gump.cpp
+++ b/engines/ultima/ultima8/gumps/inverter_gump.cpp
@@ -115,17 +115,17 @@ void InverterGump::PaintChildren(RenderSurface *surf, int32 lerp_factor, bool sc
// Convert a parent relative point to a gump point
void InverterGump::ParentToGump(int32 &px, int32 &py, PointRoundDir) {
px -= _x;
- px += _dims.x;
+ px += _dims.left;
py -= _y;
if (Ultima8Engine::get_instance()->isInverted()) py = _dims.height() - py - 1;
- py += _dims.y;
+ py += _dims.top;
}
// Convert a gump point to parent relative point
void InverterGump::GumpToParent(int32 &gx, int32 &gy, PointRoundDir) {
- gx -= _dims.x;
+ gx -= _dims.left;
gx += _x;
- gy -= _dims.y;
+ gy -= _dims.top;
if (Ultima8Engine::get_instance()->isInverted()) gy = _dims.height() - gy - 1;
gy += _y;
}
diff --git a/engines/ultima/ultima8/gumps/item_relative_gump.cpp b/engines/ultima/ultima8/gumps/item_relative_gump.cpp
index 2c0ab1015d..44f66b05b3 100644
--- a/engines/ultima/ultima8/gumps/item_relative_gump.cpp
+++ b/engines/ultima/ultima8/gumps/item_relative_gump.cpp
@@ -64,24 +64,24 @@ void ItemRelativeGump::MoveOnScreen() {
// get rectangle that gump occupies in scalerGump's coordinate space
int32 left, right, top, bottom;
- left = -_dims.x;
+ left = -_dims.left;
right = left + _dims.width();
- top = -_dims.y;
+ top = -_dims.top;
bottom = top + _dims.height();
GumpToParent(left, top);
GumpToParent(right, bottom);
int32 movex = 0, movey = 0;
- if (left < -sd.x)
- movex = -sd.x - left;
- else if (right > -sd.x + sd.width())
- movex = -sd.x + sd.width() - right;
+ if (left < -sd.left)
+ movex = -sd.left - left;
+ else if (right > -sd.left + sd.width())
+ movex = -sd.left + sd.width() - right;
- if (top < -sd.y)
- movey = -sd.y - top;
- else if (bottom > -sd.y + sd.height())
- movey = -sd.y + sd.height() - bottom;
+ if (top < -sd.top)
+ movey = -sd.top - top;
+ else if (bottom > -sd.top + sd.height())
+ movey = -sd.top + sd.height() - bottom;
Move(left + movex, top + movey);
}
diff --git a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
index d148574525..54c9028ea3 100644
--- a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
+++ b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
@@ -201,8 +201,8 @@ void PaperdollGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
itemx = equipcoords[i].x;
itemy = equipcoords[i].y;
- itemx += _itemArea.x;
- itemy += _itemArea.y;
+ itemx += _itemArea.left;
+ itemy += _itemArea.top;
Shape *s = item->getShapeObject();
assert(s);
surf->Paint(s, frame, itemx, itemy);
@@ -210,8 +210,8 @@ void PaperdollGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
if (_displayDragging) {
int32 itemx, itemy;
- itemx = _draggingX + _itemArea.x;
- itemy = _draggingY + _itemArea.y;
+ itemx = _draggingX + _itemArea.left;
+ itemy = _draggingY + _itemArea.top;
Shape *s = GameData::get_instance()->getMainShapes()->
getShape(_draggingShape);
assert(s);
@@ -239,8 +239,8 @@ uint16 PaperdollGump::TraceObjId(int32 mx, int32 my) {
itemx = equipcoords[i].x;
itemy = equipcoords[i].y;
- itemx += _itemArea.x;
- itemy += _itemArea.y;
+ itemx += _itemArea.left;
+ itemy += _itemArea.top;
const Shape *s = item->getShapeObject();
assert(s);
const ShapeFrame *frame = s->getFrame(item->getFrame() + 1);
@@ -252,7 +252,7 @@ uint16 PaperdollGump::TraceObjId(int32 mx, int32 my) {
}
// try backpack
- if (_backpackRect.InRect(mx - _itemArea.x, my - _itemArea.y)) {
+ if (_backpackRect.InRect(mx - _itemArea.left, my - _itemArea.top)) {
if (a->getEquip(7)) // constants
return a->getEquip(7);
}
@@ -275,16 +275,16 @@ bool PaperdollGump::GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy,
//!!! need to use lerp_factor
if (item->getShape() == 529) { //!! constant
- gx = _backpackRect.x;
- gy = _backpackRect.y;
+ gx = _backpackRect.left;
+ gy = _backpackRect.top;
} else {
int equiptype = item->getZ();
assert(equiptype >= 0 && equiptype <= 6); //!! constants
gx = equipcoords[equiptype].x;
gy = equipcoords[equiptype].y;
}
- gx += _itemArea.x;
- gy += _itemArea.y;
+ gx += _itemArea.left;
+ gy += _itemArea.top;
return true;
}
@@ -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.x, my - _itemArea.y)) {
+ if (backpack && _backpackRect.InRect(mx - _itemArea.left, my - _itemArea.top)) {
over_backpack = true;
}
@@ -351,8 +351,8 @@ bool PaperdollGump::DraggingItem(Item *item, int mx, int my) {
return false;
}
- _draggingX = _backpackRect.x + _backpackRect.width() / 2;
- _draggingY = _backpackRect.y + _backpackRect.height() / 2;
+ _draggingX = _backpackRect.left + _backpackRect.width() / 2;
+ _draggingY = _backpackRect.top + _backpackRect.height() / 2;
}
return 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.x, my - _itemArea.y)) {
+ if (backpack && _backpackRect.InRect(mx - _itemArea.left, my - _itemArea.top)) {
over_backpack = true;
}
diff --git a/engines/ultima/ultima8/gumps/remorse_menu_gump.cpp b/engines/ultima/ultima8/gumps/remorse_menu_gump.cpp
index f665d06abb..e1110b1ef8 100644
--- a/engines/ultima/ultima8/gumps/remorse_menu_gump.cpp
+++ b/engines/ultima/ultima8/gumps/remorse_menu_gump.cpp
@@ -126,8 +126,8 @@ void RemorseMenuGump::InitGump(Gump *newparent, bool take_focus) {
return;
}
- _dims.x = 0;
- _dims.y = 0;
+ _dims.left = 0;
+ _dims.top = 0;
_dims.setWidth(tlFrame->_width + trFrame->_width);
_dims.setHeight(tlFrame->_height + brFrame->_height);
diff --git a/engines/ultima/ultima8/gumps/u8_save_gump.cpp b/engines/ultima/ultima8/gumps/u8_save_gump.cpp
index d8e8a4afd8..f1e9b82382 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.x += 6;
+ rect.MoveRel(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 45e9071632..bb77a36b56 100644
--- a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
@@ -74,7 +74,7 @@ void ButtonWidget::InitGump(Gump *newparent, bool take_focus) {
assert(widget);
widget->InitGump(this);
widget->GetDims(_dims); // transfer child dimension to self
- widget->Move(0, _dims.y); // move it to the correct height
+ widget->Move(0, _dims.top); // move it to the correct height
} else {
assert(_shapeUp != nullptr);
assert(_shapeDown != nullptr);
@@ -247,7 +247,7 @@ bool ButtonWidget::loadData(Common::ReadStream *rs, uint32 version) {
if (_textWidget != 0) {
Gump *widget = getGump(_textWidget);
widget->GetDims(_dims); // transfer child dimension to self
- widget->Move(0, _dims.y); // move it to the correct height
+ widget->Move(0, _dims.top); // move it to the correct height
}
return true;
diff --git a/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp b/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
index 4ef67b4847..e9591e9a48 100644
--- a/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
@@ -55,15 +55,12 @@ void EditWidget::InitGump(Gump *newparent, bool take_focus) {
Font *font = getFont();
// Y offset is always baseline
- _dims.y = -font->getBaseline();
-
- // No X offset
- _dims.x = 0;
+ _dims.MoveAbs(0 , -font->getBaseline());
if (_gameFont && getFont()->isHighRes()) {
- Rect rect(0, 0, 0, _dims.y);
+ Rect rect(0, 0, 0, _dims.top);
ScreenSpaceToGumpRect(rect, ROUND_OUTSIDE);
- _dims.y = rect.height();
+ _dims.MoveAbs(0, rect.height());
}
}
@@ -164,7 +161,7 @@ void EditWidget::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
renderText();
if (scaled && _gameFont && getFont()->isHighRes()) {
- surf->FillAlpha(0xFF, _dims.x, _dims.y, _dims.width(), _dims.height());
+ surf->FillAlpha(0xFF, _dims.left, _dims.top, _dims.width(), _dims.height());
return;
}
@@ -184,7 +181,7 @@ void EditWidget::PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 s
Rect rect(_dims);
GumpRectToScreenSpace(rect, ROUND_OUTSIDE);
- surf->FillAlpha(0x00, rect.x, rect.y, rect.width(), rect.height());
+ surf->FillAlpha(0x00, rect.left, rect.top, rect.width(), rect.height());
}
// don't handle any mouse motion events, so let parent handle them for us.
diff --git a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
index 01c202a539..e1347efcc8 100644
--- a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
@@ -59,15 +59,12 @@ void TextWidget::InitGump(Gump *newparent, bool take_focus) {
Font *font = getFont();
// Y offset is always baseline
- _dims.y = -font->getBaseline();
-
- // No X offset
- _dims.x = 0;
+ _dims.MoveAbs(0, -font->getBaseline());
if (_gameFont && getFont()->isHighRes()) {
- Rect rect(0, 0, 0, _dims.y);
+ Rect rect(0, 0, 0, _dims.top);
ScreenSpaceToGumpRect(rect, ROUND_OUTSIDE);
- _dims.y = rect.height();
+ _dims.MoveAbs(0 , rect.height());
// Note that GumpRectToScreenSpace is guaranteed to keep
// _targetWidth/_targetHeight zero if they already were.
@@ -120,8 +117,8 @@ bool TextWidget::setupNextText() {
_targetWidth, _targetHeight, _textAlign, true);
- _dims.y = -font->getBaseline();
- _dims.x = 0;
+ _dims.top = -font->getBaseline();
+ _dims.left = 0;
_dims.setWidth(_tx);
_dims.setHeight(_ty);
_currentEnd = _currentStart + remaining;
@@ -137,9 +134,9 @@ bool TextWidget::setupNextText() {
_dims.setWidth(sr.width());
_dims.setHeight(sr.height());
- sr.Set(0, 0, 0, _dims.y);
+ sr.Set(0, 0, 0, _dims.top);
ScreenSpaceToGumpRect(sr, ROUND_OUTSIDE);
- _dims.y = sr.height();
+ _dims.MoveAbs(_dims.left, sr.height());
}
}
@@ -171,7 +168,7 @@ void TextWidget::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
renderText();
if (scaled && _gameFont && getFont()->isHighRes()) {
- surf->FillAlpha(0xFF, _dims.x, _dims.y, _dims.width(), _dims.height());
+ surf->FillAlpha(0xFF, _dims.left, _dims.top, _dims.width(), _dims.height());
return;
}
@@ -203,7 +200,7 @@ void TextWidget::PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 s
Rect rect(_dims);
GumpRectToScreenSpace(rect, ROUND_OUTSIDE);
- surf->FillAlpha(0x00, rect.x, rect.y, rect.width(), rect.height());
+ surf->FillAlpha(0x00, rect.left, rect.top, rect.width(), rect.height());
}
// don't handle any mouse motion events, so let parent handle them for us.
@@ -260,7 +257,7 @@ bool TextWidget::loadData(Common::ReadStream *rs, uint32 version) {
_targetWidth, _targetHeight, _textAlign, true);
// Y offset is always baseline
- _dims.y = -font->getBaseline();
+ _dims.top = -font->getBaseline();
_dims.setWidth(tx_);
_dims.setHeight(ty_);
_currentEnd = _currentStart + remaining;
diff --git a/engines/ultima/ultima8/kernel/mouse.cpp b/engines/ultima/ultima8/kernel/mouse.cpp
index 572e3fa329..cd0ff7df30 100644
--- a/engines/ultima/ultima8/kernel/mouse.cpp
+++ b/engines/ultima/ultima8/kernel/mouse.cpp
@@ -277,13 +277,13 @@ void Mouse::setMouseCoords(int mx, int my) {
RenderSurface *screen = Ultima8Engine::get_instance()->getRenderScreen();
screen->GetSurfaceDims(dims);
- if (mx < dims.x)
- mx = dims.x;
+ if (mx < dims.left)
+ mx = dims.left;
else if (mx > dims.width())
mx = dims.width();
- if (my < dims.y)
- my = dims.y;
+ if (my < dims.top)
+ my = dims.top;
else if (my > dims.height())
my = dims.height();
diff --git a/engines/ultima/ultima8/misc/rect.h b/engines/ultima/ultima8/misc/rect.h
index ed6ba08384..526a2ceb1c 100644
--- a/engines/ultima/ultima8/misc/rect.h
+++ b/engines/ultima/ultima8/misc/rect.h
@@ -27,38 +27,38 @@ namespace Ultima {
namespace Ultima8 {
struct Rect {
- int32 x, y;
- int32 w, h;
+ int32 left, top;
+ int32 right, bottom;
- Rect() : x(0), y(0), w(0), h(0) {}
- Rect(int nx, int ny, int nw, int nh) : x(nx), y(ny), w(nw), h(nh) {}
+ 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) {}
bool operator==(const Rect &rhs) const { return equals(rhs); }
bool operator!=(const Rect &rhs) const { return !equals(rhs); }
- int32 width() const { return w; }
- int32 height() const { return h; }
+ int16 width() const { return right - left; }
+ int16 height() const { return bottom - top; }
- void setWidth(int32 aWidth) {
- w = aWidth;
+ void setWidth(int16 aWidth) {
+ right = left + aWidth;
}
- void setHeight(int32 aHeight) {
- h = aHeight;
+ void setHeight(int16 aHeight) {
+ bottom = top + aHeight;
}
void grow(int16 offset) {
- x -= offset;
- y -= offset;
- w += offset;
- h += offset;
+ left -= offset;
+ top -= offset;
+ right += offset;
+ bottom += offset;
}
void Set(int nx, int ny, int nw, int nh) {
- x = nx;
- y = ny;
- w = nw;
- h = nh;
+ left = nx;
+ top = ny;
+ right = nx + nw;
+ bottom = ny + nh;
}
void Set(Rect &o) {
*this = o;
@@ -66,76 +66,79 @@ struct Rect {
// Check to see if a Rectangle is 'valid'
bool IsValid() const {
- return w > 0 && h > 0;
+ return right > left && bottom > top;
}
// Check to see if a point is within the Rectangle
bool InRect(int px, int py) const {
- return px >= x && py >= y && px < (x + w) && py < (y + h);
+ return px >= left && py >= top && px < right && py < bottom;
}
// Move the Rect (Relative)
void MoveRel(int32 dx, int32 dy) {
- x = x + dx;
- y = y + dy;
+ left += dx;
+ top += dy;
+ right += dx;
+ bottom += dy;
}
// Move the Rect (Absolute)
void MoveAbs(int32 nx, int32 ny) {
- x = nx;
- y = ny;
+ right += nx - left;
+ bottom += ny - top;
+ left = nx;
+ top = ny;
}
// Resize the Rect (Relative)
void ResizeRel(int32 dw, int32 dh) {
- w = w + dw;
- h = h + dh;
+ right += dw;
+ bottom += dh;
}
// Resize the Rect (Absolute)
void ResizeAbs(int32 nw, int32 nh) {
- w = nw;
- h = nh;
+ right = left + nw;
+ bottom = top + nh;
}
// Intersect/Clip this rect with another
void Intersect(int ox, int oy, int ow, int oh) {
- int x2 = x + w, y2 = y + h;
+ int x2 = right, y2 = bottom;
int ox2 = ox + ow, oy2 = oy + oh;
- if (x < ox) x = ox;
- else if (x > ox2) x = ox2;
+ if (left < ox) left = ox;
+ else if (left > ox2) left = ox2;
if (x2 < ox) x2 = ox;
else if (x2 > ox2) x2 = ox2;
- if (y < oy) y = oy;
- else if (y > oy2) y = oy2;
+ if (top < oy) top = oy;
+ else if (top > oy2) top = oy2;
if (y2 < oy) y2 = oy;
else if (y2 > oy2) y2 = oy2;
- w = x2 - x;
- h = y2 - y;
-
+ right = x2;
+ bottom = y2;
}
// Intersect/Clip this another with this
template<typename T>
void IntersectOther(T &ox, T &oy, T &ow, T &oh) const {
- int x2 = x + w, y2 = y + h;
+ int x2 = right, y2 = bottom;
int ox2 = ox + ow, oy2 = oy + oh;
- if (ox < x) ox = x;
+ if (ox < left) ox = left;
else if (ox > x2) ox = x2;
- if (ox2 < x) ox2 = x;
+ if (ox2 < left) ox2 = left;
else if (ox2 > x2) ox2 = x2;
- if (oy < y) oy = y;
+ if (oy < top) oy = top;
else if (oy > y2) oy = y2;
- if (oy2 < y) oy2 = y;
+ if (oy2 < top) oy2 = top;
else if (oy2 > y2) oy2 = y2;
ow = ox2 - ox;
@@ -144,38 +147,38 @@ struct Rect {
// Intersect/Clip this rect with another
void Intersect(const Rect &o) {
- Intersect(o.x, o.y, o.w, o.h);
+ Intersect(o.left, o.top, o.width(), o.height());
}
// Union/Add this rect with another
void Union(int ox, int oy, int ow, int oh) {
- int x2 = x + w, y2 = y + h;
+ int x2 = right, y2 = bottom;
int ox2 = ox + ow, oy2 = oy + oh;
- if (ox < x) x = ox;
+ if (ox < left) left = ox;
else if (ox2 > x2) x2 = ox2;
- if (oy < y) y = ox;
+ if (oy < top) top = ox;
else if (oy2 > y2) y2 = ox2;
- w = x2 - x;
- h = y2 - y;
+ right = x2;
+ bottom = y2;
}
// Union/Add this rect with another
void Union(const Rect &o) {
- Union(o.x, o.y, o.w, o.h);
+ Union(o.left, o.top, o.width(), o.height());
}
bool Overlaps(const Rect &o) const {
- if (x + w <= o.x || o.x + o.w <= x) return false;
- if (y + h <= o.y || o.y + o.h <= y) return false;
+ if (right <= o.left || o.right <= left) return false;
+ if (bottom <= o.top || o.bottom <= top) return false;
return true;
}
// Operator +=
Rect &operator += (const Rect &o) {
- Union(o.x, o.y, o.w, o.h);
+ Union(o.left, o.top, o.width(), o.height());
return *(this);
}
@@ -186,7 +189,7 @@ struct Rect {
}
bool equals(const Rect &o) const {
- return x == o.x && y == o.y && w == o.w && h == o.h;
+ return left == o.left && top == o.top && right == o.right && bottom == o.bottom;
}
};
diff --git a/engines/ultima/ultima8/world/snap_process.cpp b/engines/ultima/ultima8/world/snap_process.cpp
index af83464138..f85c8ea372 100644
--- a/engines/ultima/ultima8/world/snap_process.cpp
+++ b/engines/ultima/ultima8/world/snap_process.cpp
@@ -136,8 +136,8 @@ void SnapProcess::getSnapEggRange(const Item *item, Rect &rect) const {
int32 x, y, z;
item->getLocation(x, y, z);
- rect.x = x - xrange + xoff;
- rect.y = y - yrange + yoff;
+ rect.left = x - xrange + xoff;
+ rect.top = y - yrange + yoff;
rect.setWidth(xrange * 2);
rect.setHeight(yrange * 2);
}
More information about the Scummvm-git-logs
mailing list