[Scummvm-git-logs] scummvm master -> b0a56a0378974e6b4a321d2b607b022e6815e40b
OMGPizzaGuy
48367439+OMGPizzaGuy at users.noreply.github.com
Sun Aug 9 21:47:25 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
db189b17fd ULTIMA8: Update gump / screen space transformations to use rect struct
af35c258d9 ULTIMA8: Update font to use rect width and height accessor methods
b0a56a0378 ULTIMA8: Change offset for first entry in save gump to match other entries
Commit: db189b17fd6d468fa446b446e84987a1f367238e
https://github.com/scummvm/scummvm/commit/db189b17fd6d468fa446b446e84987a1f367238e
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-08-09T16:40:46-05:00
Commit Message:
ULTIMA8: Update gump / screen space transformations to use rect struct
Changed paths:
engines/ultima/ultima8/gumps/gump.cpp
engines/ultima/ultima8/gumps/gump.h
engines/ultima/ultima8/gumps/paperdoll_gump.cpp
engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
engines/ultima/ultima8/gumps/widgets/text_widget.cpp
engines/ultima/ultima8/misc/rect.h
diff --git a/engines/ultima/ultima8/gumps/gump.cpp b/engines/ultima/ultima8/gumps/gump.cpp
index 4d4239500f..6e35da476b 100644
--- a/engines/ultima/ultima8/gumps/gump.cpp
+++ b/engines/ultima/ultima8/gumps/gump.cpp
@@ -307,9 +307,8 @@ void Gump::PaintCompositing(RenderSurface *surf, int32 lerp_factor,
surf->GetClippingRect(old_rect);
// Set new clipping rect
- int32 cx = _dims.x, cy = _dims.y, cw = _dims.width(), ch = _dims.height();
- GumpRectToScreenSpace(cx, cy, cw, ch, ROUND_OUTSIDE);
- Rect new_rect(cx, cy, cw, ch);
+ Rect new_rect(_dims);
+ GumpRectToScreenSpace(new_rect, ROUND_OUTSIDE);
new_rect.Intersect(old_rect);
surf->SetClippingRect(new_rect);
@@ -468,35 +467,37 @@ void Gump::GumpToParent(int32 &gx, int32 &gy, PointRoundDir) {
}
// Transform a rectangle to screenspace from gumpspace
-void Gump::GumpRectToScreenSpace(int32 &gx, int32 &gy, int32 &gw, int32 &gh,
- RectRoundDir r) {
+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 = gx, y1 = gy;
- int32 x2 = gx + gw, y2 = gy + gh;
+ int32 x1 = gr.x, y1 = gr.y;
+ int32 x2 = gr.x + gr.width(), y2 = gr.y + gr.height();
GumpToScreenSpace(x1, y1, tl);
GumpToScreenSpace(x2, y2, br);
- gx = x1;
- gy = y1;
- if (gw != 0) gw = x2 - x1;
- if (gh != 0) gh = y2 - y1;
+ gr.x = x1;
+ gr.y = y1;
+ if (gr.width() != 0)
+ gr.setWidth(x2 - x1);
+ if (gr.height() != 0)
+ gr.setHeight(y2 - y1);
}
// Transform a rectangle to gumpspace from screenspace
-void Gump::ScreenSpaceToGumpRect(int32 &sx, int32 &sy, int32 &sw, int32 &sh,
- RectRoundDir r) {
+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 = sx, y1 = sy;
- int32 x2 = sx + sw, y2 = sy + sh;
+ int32 x1 = sr.x, y1 = sr.y;
+ int32 x2 = sr.x + sr.width(), y2 = sr.y + sr.height();
ScreenSpaceToGump(x1, y1, tl);
ScreenSpaceToGump(x2, y2, br);
- sx = x1;
- sy = y1;
- if (sw != 0) sw = x2 - x1;
- if (sh != 0) sh = y2 - y1;
+ sr.x = x1;
+ sr.y = y1;
+ if (sr.width() != 0)
+ sr.setWidth(x2 - x1);
+ if (sr.height() != 0)
+ sr.setHeight(y2 - y1);
}
uint16 Gump::TraceObjId(int32 mx, int32 my) {
diff --git a/engines/ultima/ultima8/gumps/gump.h b/engines/ultima/ultima8/gumps/gump.h
index 57213093cc..f6df969002 100644
--- a/engines/ultima/ultima8/gumps/gump.h
+++ b/engines/ultima/ultima8/gumps/gump.h
@@ -275,12 +275,10 @@ public:
PointRoundDir r = ROUND_TOPLEFT);
//! Transform a rectangle to screenspace from gumpspace
- virtual void GumpRectToScreenSpace(int32 &gx, int32 &gy,
- int32 &gw, int32 &gh, RectRoundDir r = ROUND_OUTSIDE);
+ virtual void GumpRectToScreenSpace(Rect &gr, RectRoundDir r = ROUND_OUTSIDE);
//! Transform a rectangle to gumpspace from screenspace
- virtual void ScreenSpaceToGumpRect(int32 &sx, int32 &sy,
- int32 &sw, int32 &sh, RectRoundDir r = ROUND_OUTSIDE);
+ virtual void ScreenSpaceToGumpRect(Rect &sr, RectRoundDir r = ROUND_OUTSIDE);
//! Trace a click, and return ObjId
virtual uint16 TraceObjId(int32 mx, int32 my);
diff --git a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
index 163541d0df..d148574525 100644
--- a/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
+++ b/engines/ultima/ultima8/gumps/paperdoll_gump.cpp
@@ -397,11 +397,8 @@ void PaperdollGump::ChildNotify(Gump *child, uint32 message) {
desktop->GetDims(rect);
Rect sr;
statsgump->GetDims(sr);
- sr.x += 2;
- sr.w -= 4;
- sr.y += 2;
- sr.h -= 4;
- statsgump->GumpRectToScreenSpace(sr.x, sr.y, sr.w, sr.h);
+ sr.grow(-2);
+ statsgump->GumpRectToScreenSpace(sr);
if (!sr.Overlaps(rect))
statsgump->setRelativePosition(BOTTOM_RIGHT, -5, -5);
}
diff --git a/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp b/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
index f8e0a1581f..4ef67b4847 100644
--- a/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/edit_widget.cpp
@@ -61,8 +61,9 @@ void EditWidget::InitGump(Gump *newparent, bool take_focus) {
_dims.x = 0;
if (_gameFont && getFont()->isHighRes()) {
- int32 x_ = 0, y_ = 0, w = 0;
- ScreenSpaceToGumpRect(x_, y_, w, _dims.y, ROUND_OUTSIDE);
+ Rect rect(0, 0, 0, _dims.y);
+ ScreenSpaceToGumpRect(rect, ROUND_OUTSIDE);
+ _dims.y = rect.height();
}
}
@@ -93,8 +94,11 @@ bool EditWidget::textFits(Std::string &t) {
int32 max_width = _multiLine ? _dims.width() : 0;
int32 max_height = _dims.height();
if (_gameFont && font->isHighRes()) {
- int32 x_ = 0, y_ = 0;
- GumpRectToScreenSpace(x_, y_, max_width, max_height, ROUND_INSIDE);
+ Rect rect(0, 0, max_width, max_height);
+ GumpRectToScreenSpace(rect, ROUND_INSIDE);
+
+ max_width = rect.width();
+ max_height = rect.height();
}
font->getTextSize(t, width, height, remaining,
@@ -102,8 +106,11 @@ bool EditWidget::textFits(Std::string &t) {
Font::TEXT_LEFT, false);
if (_gameFont && font->isHighRes()) {
- int32 x_ = 0, y_ = 0;
- ScreenSpaceToGumpRect(x_, y_, width, height, ROUND_OUTSIDE);
+ Rect rect(0, 0, width, height);
+ ScreenSpaceToGumpRect(rect, ROUND_OUTSIDE);
+
+ width = rect.width();
+ height = rect.height();
}
if (_multiLine)
@@ -135,8 +142,11 @@ void EditWidget::renderText() {
int32 max_width = _multiLine ? _dims.width() : 0;
int32 max_height = _dims.height();
if (_gameFont && font->isHighRes()) {
- int32 x_ = 0, y_ = 0;
- GumpRectToScreenSpace(x_, y_, max_width, max_height, ROUND_INSIDE);
+ Rect rect(0, 0, max_width, max_height);
+ GumpRectToScreenSpace(rect, ROUND_INSIDE);
+
+ max_width = rect.width();
+ max_height = rect.height();
}
unsigned int remaining;
@@ -172,11 +182,9 @@ void EditWidget::PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 s
_cachedText->draw(surf, x_, y_, true);
- x_ = _dims.x;
- y_ = _dims.y;
- int32 w = _dims.width(), h = _dims.height();
- GumpRectToScreenSpace(x_, y_, w, h, ROUND_OUTSIDE);
- surf->FillAlpha(0x00, x_, y_, w, h);
+ Rect rect(_dims);
+ GumpRectToScreenSpace(rect, ROUND_OUTSIDE);
+ surf->FillAlpha(0x00, rect.x, rect.y, 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 2ca9b08899..01c202a539 100644
--- a/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/text_widget.cpp
@@ -65,22 +65,22 @@ void TextWidget::InitGump(Gump *newparent, bool take_focus) {
_dims.x = 0;
if (_gameFont && getFont()->isHighRes()) {
- int32 w = 0;
- int32 x_ = 0, y_ = 0;
- ScreenSpaceToGumpRect(x_, y_, w, _dims.y, ROUND_OUTSIDE);
-
- int32 tx_ = _dims.x;
- int32 ty_ = _dims.y;
+ Rect rect(0, 0, 0, _dims.y);
+ ScreenSpaceToGumpRect(rect, ROUND_OUTSIDE);
+ _dims.y = rect.height();
// Note that GumpRectToScreenSpace is guaranteed to keep
// _targetWidth/_targetHeight zero if they already were.
- GumpRectToScreenSpace(tx_, ty_, _targetWidth, _targetHeight, ROUND_OUTSIDE);
+ Rect target(_dims);
+ GumpRectToScreenSpace(target, ROUND_OUTSIDE);
+
+ _targetWidth = target.width();
+ _targetHeight = target.height();
- _dims.setWidth(_targetWidth);
- _dims.setHeight(_targetHeight);
- x_ = 0;
- y_ = 0;
- ScreenSpaceToGumpRect(x_, y_, _dims.w, _dims.h, ROUND_OUTSIDE);
+ Rect sr(0, 0, _targetWidth, _targetHeight);
+ ScreenSpaceToGumpRect(sr, ROUND_OUTSIDE);
+ _dims.setWidth(sr.width());
+ _dims.setHeight(sr.height());
}
setupNextText();
@@ -93,8 +93,9 @@ int TextWidget::getVlead() {
int32 vlead = _cachedText->getVlead();
if (_gameFont && getFont()->isHighRes()) {
- int32 xv = 0, yv = 0, w = 0;
- ScreenSpaceToGumpRect(xv, yv, w, vlead, ROUND_OUTSIDE);
+ Rect rect(0, 0, 0, vlead);
+ ScreenSpaceToGumpRect(rect, ROUND_OUTSIDE);
+ vlead = rect.height();
}
return vlead;
@@ -131,13 +132,14 @@ bool TextWidget::setupNextText() {
if (_gameFont) {
Font *fontP = getFont();
if (fontP->isHighRes()) {
- int32 x_ = 0, y_ = 0;
- ScreenSpaceToGumpRect(x_, y_, _dims.w, _dims.h, ROUND_OUTSIDE);
-
- int32 w = 0;
- x_ = 0;
- y_ = 0;
- ScreenSpaceToGumpRect(x_, y_, w, _dims.y, ROUND_OUTSIDE);
+ Rect sr(0, 0, _dims.width(), _dims.height());
+ ScreenSpaceToGumpRect(sr, ROUND_OUTSIDE);
+ _dims.setWidth(sr.width());
+ _dims.setHeight(sr.height());
+
+ sr.Set(0, 0, 0, _dims.y);
+ ScreenSpaceToGumpRect(sr, ROUND_OUTSIDE);
+ _dims.y = sr.height();
}
}
@@ -199,11 +201,9 @@ void TextWidget::PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 s
if (dynamic_cast<ButtonWidget *>(_parent) && dynamic_cast<AskGump *>(_parent->GetParent()))
return;
- x = _dims.x;
- y = _dims.y;
- int32 w = _dims.width(), h = _dims.height();
- GumpRectToScreenSpace(x, y, w, h, ROUND_OUTSIDE);
- surf->FillAlpha(0x00, x, y, w, h);
+ Rect rect(_dims);
+ GumpRectToScreenSpace(rect, ROUND_OUTSIDE);
+ surf->FillAlpha(0x00, rect.x, rect.y, rect.width(), rect.height());
}
// don't handle any mouse motion events, so let parent handle them for us.
diff --git a/engines/ultima/ultima8/misc/rect.h b/engines/ultima/ultima8/misc/rect.h
index 96d9009f1b..ed6ba08384 100644
--- a/engines/ultima/ultima8/misc/rect.h
+++ b/engines/ultima/ultima8/misc/rect.h
@@ -27,8 +27,8 @@ namespace Ultima {
namespace Ultima8 {
struct Rect {
- int32 x, y;
- int32 w, h;
+ int32 x, y;
+ int32 w, h;
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) {}
@@ -47,6 +47,13 @@ struct Rect {
h = aHeight;
}
+ void grow(int16 offset) {
+ x -= offset;
+ y -= offset;
+ w += offset;
+ h += offset;
+ }
+
void Set(int nx, int ny, int nw, int nh) {
x = nx;
y = ny;
Commit: af35c258d9e58791f1a1f4294522f2d618d28a6f
https://github.com/scummvm/scummvm/commit/af35c258d9e58791f1a1f4294522f2d618d28a6f
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-08-09T16:43:16-05:00
Commit Message:
ULTIMA8: Update font to use rect width and height accessor methods
Changed paths:
engines/ultima/ultima8/graphics/fonts/font.cpp
diff --git a/engines/ultima/ultima8/graphics/fonts/font.cpp b/engines/ultima/ultima8/graphics/fonts/font.cpp
index 625091dcbc..919237239e 100644
--- a/engines/ultima/ultima8/graphics/fonts/font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/font.cpp
@@ -211,15 +211,16 @@ Std::list<PositionedText> typesetText(Font *font,
font->getStringSize(curline, stringwidth, stringheight);
line._dims.x = 0;
line._dims.y = totalheight;
- line._dims.w = stringwidth;
- line._dims.h = stringheight;
+ line._dims.setWidth(stringwidth);
+ line._dims.setHeight(stringheight);
line._text = curline;
line._cursor = Std::string::npos;
if (cursor != Std::string::npos && cursoriter >= curlinestart &&
(cursoriter < iter || (!breakhere && cursoriter == iter))) {
line._cursor = cursoriter - curlinestart;
- if (line._dims.w == 0) {
- stringwidth = line._dims.w = 2;
+ if (line._dims.width() == 0) {
+ stringwidth = 2;
+ line._dims.setWidth(stringwidth);
}
}
lines.push_back(line);
@@ -344,15 +345,15 @@ Std::list<PositionedText> typesetText(Font *font,
case Font::TEXT_LEFT:
break;
case Font::TEXT_RIGHT:
- lineiter->_dims.x = totalwidth - lineiter->_dims.w;
+ lineiter->_dims.x = totalwidth - lineiter->_dims.width();
break;
case Font::TEXT_CENTER:
- lineiter->_dims.x = (totalwidth - lineiter->_dims.w) / 2;
+ lineiter->_dims.x = (totalwidth - lineiter->_dims.width()) / 2;
break;
}
#if 0
pout << lineiter->_dims.x << "," << lineiter->_dims.y << " "
- << lineiter->_dims.w << "," << lineiter->_dims.h << ": "
+ << lineiter->_dims.width() << "," << lineiter->_dims.height() << ": "
<< lineiter->text << Std::endl;
#endif
}
Commit: b0a56a0378974e6b4a321d2b607b022e6815e40b
https://github.com/scummvm/scummvm/commit/b0a56a0378974e6b4a321d2b607b022e6815e40b
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-08-09T16:45:12-05:00
Commit Message:
ULTIMA8: Change offset for first entry in save gump to match other entries
Changed paths:
engines/ultima/ultima8/gumps/u8_save_gump.cpp
diff --git a/engines/ultima/ultima8/gumps/u8_save_gump.cpp b/engines/ultima/ultima8/gumps/u8_save_gump.cpp
index 0d8d1d4b73..d8e8a4afd8 100644
--- a/engines/ultima/ultima8/gumps/u8_save_gump.cpp
+++ b/engines/ultima/ultima8/gumps/u8_save_gump.cpp
@@ -122,7 +122,7 @@ void U8SaveGump::InitGump(Gump *newparent, bool take_focus) {
if (index_ == 0) {
// special case for 'The Beginning...' _save
- Gump *widget = new TextWidget(xbase, 12 + entryheight,
+ Gump *widget = new TextWidget(xbase, entryheight + 4 + 40 * yi,
_TL_("The Beginning..."),
true, entryfont, 95);
widget->InitGump(this, false);
More information about the Scummvm-git-logs
mailing list