[Scummvm-git-logs] scummvm master -> f5712907d1581303f55770de7fe65bd578ff1207
mduggan
mgithub at guarana.org
Sun Mar 29 04:00:05 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:
f5712907d1 ULTIMA8: Refactor gump pattern of setting dims from shape
Commit: f5712907d1581303f55770de7fe65bd578ff1207
https://github.com/scummvm/scummvm/commit/f5712907d1581303f55770de7fe65bd578ff1207
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-03-29T12:59:06+09:00
Commit Message:
ULTIMA8: Refactor gump pattern of setting dims from shape
Changed paths:
engines/ultima/ultima8/gumps/book_gump.cpp
engines/ultima/ultima8/gumps/container_gump.cpp
engines/ultima/ultima8/gumps/gump.cpp
engines/ultima/ultima8/gumps/gump.h
engines/ultima/ultima8/gumps/menu_gump.cpp
engines/ultima/ultima8/gumps/mini_stats_gump.cpp
engines/ultima/ultima8/gumps/paged_gump.cpp
engines/ultima/ultima8/gumps/quit_gump.cpp
engines/ultima/ultima8/gumps/readable_gump.cpp
engines/ultima/ultima8/gumps/scroll_gump.cpp
engines/ultima/ultima8/gumps/slider_gump.cpp
engines/ultima/ultima8/gumps/widgets/button_widget.cpp
engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
diff --git a/engines/ultima/ultima8/gumps/book_gump.cpp b/engines/ultima/ultima8/gumps/book_gump.cpp
index fa6afea5b6..6e6fc5e266 100644
--- a/engines/ultima/ultima8/gumps/book_gump.cpp
+++ b/engines/ultima/ultima8/gumps/book_gump.cpp
@@ -73,12 +73,7 @@ void BookGump::InitGump(Gump *newparent, bool take_focus) {
Shape *shapeP = GameData::get_instance()->getGumps()->getShape(6);
SetShape(shapeP, 0);
-
- const ShapeFrame *sf = shapeP->getFrame(0);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
}
void BookGump::NextText() {
diff --git a/engines/ultima/ultima8/gumps/container_gump.cpp b/engines/ultima/ultima8/gumps/container_gump.cpp
index 2172fc24cd..fc80e8a9c6 100644
--- a/engines/ultima/ultima8/gumps/container_gump.cpp
+++ b/engines/ultima/ultima8/gumps/container_gump.cpp
@@ -66,11 +66,7 @@ ContainerGump::~ContainerGump() {
}
void ContainerGump::InitGump(Gump *newparent, bool take_focus) {
- const ShapeFrame *sf = _shape->getFrame(_frameNum);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
// Wait with ItemRelativeGump initialization until we calculated our size.
ItemRelativeGump::InitGump(newparent, take_focus);
diff --git a/engines/ultima/ultima8/gumps/gump.cpp b/engines/ultima/ultima8/gumps/gump.cpp
index a75bc42264..6d9351b602 100644
--- a/engines/ultima/ultima8/gumps/gump.cpp
+++ b/engines/ultima/ultima8/gumps/gump.cpp
@@ -82,12 +82,16 @@ void Gump::SetShape(FrameID frame, bool adjustsize) {
_frameNum = frame._frameNum;
if (adjustsize && _shape) {
- const ShapeFrame *sf = _shape->getFrame(_frameNum);
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
}
}
+void Gump::UpdateDimsFromShape() {
+ const ShapeFrame *sf = _shape->getFrame(_frameNum);
+ assert(sf);
+ _dims.w = sf->_width;
+ _dims.h = sf->_height;
+}
void Gump::CreateNotifier() {
assert(_notifier == 0);
diff --git a/engines/ultima/ultima8/gumps/gump.h b/engines/ultima/ultima8/gumps/gump.h
index 169c1281b1..59fd92ba0a 100644
--- a/engines/ultima/ultima8/gumps/gump.h
+++ b/engines/ultima/ultima8/gumps/gump.h
@@ -94,6 +94,9 @@ public:
void SetShape(FrameID frame, bool adjustsize = false);
+ //! Update the width/height to match the gump's current shape frame
+ void UpdateDimsFromShape();
+
//! Set the Gump's frame
inline void Set_frameNum(uint32 frameNum) {
_frameNum = frameNum;
diff --git a/engines/ultima/ultima8/gumps/menu_gump.cpp b/engines/ultima/ultima8/gumps/menu_gump.cpp
index e18899dd8d..d78e926142 100644
--- a/engines/ultima/ultima8/gumps/menu_gump.cpp
+++ b/engines/ultima/ultima8/gumps/menu_gump.cpp
@@ -108,15 +108,11 @@ void MenuGump::InitGump(Gump *newparent, bool take_focus) {
ModalGump::InitGump(newparent, take_focus);
_shape = GameData::get_instance()->getGumps()->getShape(gumpShape);
- const ShapeFrame *sf = _shape->getFrame(0);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
Shape *logoShape;
logoShape = GameData::get_instance()->getGumps()->getShape(paganShape);
- sf = logoShape->getFrame(0);
+ const ShapeFrame *sf = logoShape->getFrame(0);
assert(sf);
Gump *logo = new Gump(42, 10, sf->_width, sf->_height);
diff --git a/engines/ultima/ultima8/gumps/mini_stats_gump.cpp b/engines/ultima/ultima8/gumps/mini_stats_gump.cpp
index 7fee623ba4..52893a1d80 100644
--- a/engines/ultima/ultima8/gumps/mini_stats_gump.cpp
+++ b/engines/ultima/ultima8/gumps/mini_stats_gump.cpp
@@ -66,11 +66,7 @@ void MiniStatsGump::InitGump(Gump *newparent, bool take_focus) {
Gump::InitGump(newparent, take_focus);
_shape = GameData::get_instance()->getGumps()->getShape(gumpshape);
- const ShapeFrame *sf = _shape->getFrame(0);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
}
void MiniStatsGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
diff --git a/engines/ultima/ultima8/gumps/paged_gump.cpp b/engines/ultima/ultima8/gumps/paged_gump.cpp
index d0e6bd5373..70bf894d8d 100644
--- a/engines/ultima/ultima8/gumps/paged_gump.cpp
+++ b/engines/ultima/ultima8/gumps/paged_gump.cpp
@@ -60,11 +60,7 @@ void PagedGump::InitGump(Gump *newparent, bool take_focus) {
ModalGump::InitGump(newparent, take_focus);
_shape = GameData::get_instance()->getGumps()->getShape(_gumpShape);
- const ShapeFrame *sf = _shape->getFrame(0);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
FrameID buttonleft(GameData::GUMPS, pageOverShape, 0);
FrameID buttonright(GameData::GUMPS, pageOverShape, 1);
diff --git a/engines/ultima/ultima8/gumps/quit_gump.cpp b/engines/ultima/ultima8/gumps/quit_gump.cpp
index 2eee406550..c518c7cb5c 100644
--- a/engines/ultima/ultima8/gumps/quit_gump.cpp
+++ b/engines/ultima/ultima8/gumps/quit_gump.cpp
@@ -57,17 +57,13 @@ void QuitGump::InitGump(Gump *newparent, bool take_focus) {
ModalGump::InitGump(newparent, take_focus);
_shape = GameData::get_instance()->getGumps()->getShape(gumpShape);
- const ShapeFrame *sf = _shape->getFrame(0);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
FrameID askshape(GameData::GUMPS, askShapeId, 0);
askshape = _TL_SHP_(askshape);
Shape *askShape = GameData::get_instance()->getShape(askshape);
- sf = askShape->getFrame(askshape._frameNum);
+ const ShapeFrame *sf = askShape->getFrame(askshape._frameNum);
assert(sf);
Gump *ask = new Gump(0, 0, sf->_width, sf->_height);
diff --git a/engines/ultima/ultima8/gumps/readable_gump.cpp b/engines/ultima/ultima8/gumps/readable_gump.cpp
index 3a0ed1b7ea..ba11a79c36 100644
--- a/engines/ultima/ultima8/gumps/readable_gump.cpp
+++ b/engines/ultima/ultima8/gumps/readable_gump.cpp
@@ -63,11 +63,7 @@ void ReadableGump::InitGump(Gump *newparent, bool take_focus) {
SetShape(shape_, 0);
- const ShapeFrame *sf = shape_->getFrame(0);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
if (CoreApp::get_instance()->getGameInfo()->_language ==
GameInfo::GAMELANG_JAPANESE) {
diff --git a/engines/ultima/ultima8/gumps/scroll_gump.cpp b/engines/ultima/ultima8/gumps/scroll_gump.cpp
index d6e9267b9a..151cbae502 100644
--- a/engines/ultima/ultima8/gumps/scroll_gump.cpp
+++ b/engines/ultima/ultima8/gumps/scroll_gump.cpp
@@ -66,12 +66,7 @@ void ScrollGump::InitGump(Gump *newparent, bool take_focus) {
Shape *shape_ = GameData::get_instance()->getGumps()->getShape(19);
SetShape(shape_, 0);
-
- const ShapeFrame *sf = shape_->getFrame(0);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
}
void ScrollGump::NextText() {
diff --git a/engines/ultima/ultima8/gumps/slider_gump.cpp b/engines/ultima/ultima8/gumps/slider_gump.cpp
index 2d8d960f50..16b7c6504b 100644
--- a/engines/ultima/ultima8/gumps/slider_gump.cpp
+++ b/engines/ultima/ultima8/gumps/slider_gump.cpp
@@ -125,11 +125,7 @@ void SliderGump::InitGump(Gump *newparent, bool take_focus) {
ModalGump::InitGump(newparent, take_focus);
_shape = GameData::get_instance()->getGumps()->getShape(gumpshape);
- const ShapeFrame *sf = _shape->getFrame(0);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
Shape *childshape = GameData::get_instance()->
getGumps()->getShape(slidershape);
diff --git a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
index 8b9deb99ea..955b6d924b 100644
--- a/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/button_widget.cpp
@@ -79,13 +79,8 @@ void ButtonWidget::InitGump(Gump *newparent, bool take_focus) {
assert(_shapeUp != nullptr);
assert(_shapeDown != nullptr);
- _shape = _shapeUp;
- _frameNum = _frameNumUp;
-
- const ShapeFrame *sf = _shape->getFrame(_frameNum);
- assert(sf);
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ SetShape(_shapeUp, _frameNumUp);
+ UpdateDimsFromShape();
}
}
diff --git a/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp b/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
index 48b6cdc385..686688b005 100644
--- a/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
+++ b/engines/ultima/ultima8/gumps/widgets/sliding_widget.cpp
@@ -49,11 +49,7 @@ SlidingWidget::~SlidingWidget() {
void SlidingWidget::InitGump(Gump *newparent, bool take_focus) {
Gump::InitGump(newparent, take_focus);
- const ShapeFrame *sf = _shape->getFrame(_frameNum);
- assert(sf);
-
- _dims.w = sf->_width;
- _dims.h = sf->_height;
+ UpdateDimsFromShape();
}
uint16 SlidingWidget::TraceObjId(int32 mx, int32 my) {
More information about the Scummvm-git-logs
mailing list