mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-12 12:40:58 +00:00
ULTIMA8: Refactor gump pattern of setting dims from shape
This commit is contained in:
parent
241d4e761d
commit
f5712907d1
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user