MACVENTURE: Fix click-through and refactor
This commit is contained in:
parent
fdd949bb00
commit
b6acfe868c
2 changed files with 19 additions and 16 deletions
|
@ -906,13 +906,20 @@ WindowReference Gui::findObjWindow(ObjID objID) {
|
||||||
return kNoWindow;
|
return kNoWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::checkSelect(ObjID obj, const Common::Event &event, const Common::Rect & clickRect, WindowReference ref) {
|
bool Gui::canBeSelected(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
|
||||||
if (_engine->isObjVisible(obj) &&
|
return (_engine->isObjVisible(obj) &&
|
||||||
_engine->isObjClickable(obj) &&
|
_engine->isObjClickable(obj) &&
|
||||||
isRectInsideObject(clickRect, obj))
|
isRectInsideObject(clickRect, obj));
|
||||||
{
|
|
||||||
selectDraggable(obj, ref, event.mouse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Gui::checkSelect(const WindowData &data, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
|
||||||
|
ObjID child;
|
||||||
|
for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
|
||||||
|
if (canBeSelected((*it).obj, event, clickRect, ref)) {
|
||||||
|
child = (*it).obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (child != 0) selectDraggable(child, ref, event.mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) {
|
bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) {
|
||||||
|
@ -1182,14 +1189,11 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e
|
||||||
|
|
||||||
if (click == kBorderInner && event.type == Common::EVENT_LBUTTONDOWN) {
|
if (click == kBorderInner && event.type == Common::EVENT_LBUTTONDOWN) {
|
||||||
WindowData &data = findWindowData(kMainGameWindow);
|
WindowData &data = findWindowData(kMainGameWindow);
|
||||||
ObjID child;
|
ObjID child = 0;
|
||||||
Common::Point pos;
|
Common::Point pos;
|
||||||
// Click rect to local coordinates. We assume the click is inside the window ^
|
// Click rect to local coordinates. We assume the click is inside the window ^
|
||||||
Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions());
|
Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions());
|
||||||
for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
|
checkSelect(data, event, clickRect, kMainGameWindow);
|
||||||
child = (*it).obj;
|
|
||||||
checkSelect(child, event, clickRect, kMainGameWindow);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1262,10 +1266,8 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) {
|
||||||
Common::Point pos;
|
Common::Point pos;
|
||||||
// Click rect to local coordinates. We assume the click is inside the window ^
|
// Click rect to local coordinates. We assume the click is inside the window ^
|
||||||
Common::Rect clickRect = calculateClickRect(event.mouse, win->getDimensions());
|
Common::Rect clickRect = calculateClickRect(event.mouse, win->getDimensions());
|
||||||
for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
|
checkSelect(data, event, clickRect, (WindowReference)ref);
|
||||||
child = (*it).obj;
|
|
||||||
checkSelect(child, event, clickRect, (WindowReference)ref);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,8 @@ private: // Methods
|
||||||
Graphics::MacWindow *findWindow(WindowReference reference);
|
Graphics::MacWindow *findWindow(WindowReference reference);
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
void checkSelect(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref);
|
bool canBeSelected(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref);
|
||||||
|
void checkSelect(const WindowData &data, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref);
|
||||||
bool isRectInsideObject(Common::Rect target, ObjID obj);
|
bool isRectInsideObject(Common::Rect target, ObjID obj);
|
||||||
void selectDraggable(ObjID child, WindowReference origin, Common::Point startPos);
|
void selectDraggable(ObjID child, WindowReference origin, Common::Point startPos);
|
||||||
void handleDragRelease(Common::Point pos, bool shiftPressed, bool isDoubleClick);
|
void handleDragRelease(Common::Point pos, bool shiftPressed, bool isDoubleClick);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue