mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 04:24:54 +02:00
restore old modules
* partially restore vip, battle, healthbar, skills and inventory modules * more fixes on UIWidgets * implement UIMiniWindow close/minimize functionality * allow drag and drop miniwindows beteween game panels
This commit is contained in:
@@ -53,7 +53,7 @@ TexturePtr TextureManager::getTexture(const std::string& textureFile)
|
||||
g_resources.loadFile(textureFile, fin);
|
||||
texture = loadPNG(fin);
|
||||
} catch(Exception& e) {
|
||||
Fw::throwException("unable to load texture '", textureFile, "': ", e.what());
|
||||
logError("unable to load texture '", textureFile, "': ", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -57,6 +57,11 @@ void UIAnchorLayout::removeAnchors(const UIWidgetPtr& anchoredWidget)
|
||||
update();
|
||||
}
|
||||
|
||||
bool UIAnchorLayout::hasAnchors(const UIWidgetPtr& anchoredWidget)
|
||||
{
|
||||
return m_anchorsGroups.find(anchoredWidget) != m_anchorsGroups.end();
|
||||
}
|
||||
|
||||
void UIAnchorLayout::centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId)
|
||||
{
|
||||
addAnchor(anchoredWidget, Fw::AnchorHorizontalCenter, hookedWidgetId, Fw::AnchorHorizontalCenter);
|
||||
|
@@ -66,6 +66,7 @@ public:
|
||||
void addAnchor(const UIWidgetPtr& anchoredWidget, Fw::AnchorEdge anchoredEdge,
|
||||
const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge);
|
||||
void removeAnchors(const UIWidgetPtr& anchoredWidget);
|
||||
bool hasAnchors(const UIWidgetPtr& anchoredWidget);
|
||||
void centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
||||
void fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
||||
|
||||
|
@@ -37,8 +37,10 @@ void UILayout::update()
|
||||
|
||||
m_updating = true;
|
||||
internalUpdate();
|
||||
if(UIWidgetPtr parentWidget = getParentWidget())
|
||||
if(UIWidgetPtr parentWidget = getParentWidget()) {
|
||||
if(!parentWidget->isDestroyed())
|
||||
parentWidget->onLayoutUpdate();
|
||||
}
|
||||
m_updating = false;
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,7 @@ void UIManager::inputEvent(const InputEvent& event)
|
||||
break;
|
||||
case Fw::MousePressInputEvent:
|
||||
if(event.mouseButton == Fw::MouseLeftButton && m_mouseReceiver->isVisible()) {
|
||||
UIWidgetPtr pressedWidget = m_mouseReceiver->recursiveGetChildByPos(event.mousePos);
|
||||
UIWidgetPtr pressedWidget = m_mouseReceiver->recursiveGetChildByPos(event.mousePos, false);
|
||||
if(pressedWidget && !pressedWidget->isEnabled())
|
||||
pressedWidget = nullptr;
|
||||
updatePressedWidget(pressedWidget, event.mousePos);
|
||||
@@ -219,7 +219,7 @@ void UIManager::updateHoveredWidget()
|
||||
return;
|
||||
|
||||
m_hoverUpdateScheduled = false;
|
||||
UIWidgetPtr hoveredWidget = m_rootWidget->recursiveGetChildByPos(g_window.getMousePosition());
|
||||
UIWidgetPtr hoveredWidget = m_rootWidget->recursiveGetChildByPos(g_window.getMousePosition(), false);
|
||||
if(hoveredWidget && !hoveredWidget->isEnabled())
|
||||
hoveredWidget = nullptr;
|
||||
|
||||
|
@@ -635,7 +635,7 @@ void UIWidget::bindRectToParent()
|
||||
Rect boundRect = m_rect;
|
||||
UIWidgetPtr parent = getParent();
|
||||
if(parent) {
|
||||
Rect parentRect = parent->getRect();
|
||||
Rect parentRect = parent->getClippingRect();
|
||||
boundRect.bind(parentRect);
|
||||
}
|
||||
|
||||
@@ -872,6 +872,14 @@ bool UIWidget::isVisible()
|
||||
return asUIWidget() == g_ui.getRootWidget();
|
||||
}
|
||||
|
||||
bool UIWidget::isAnchored()
|
||||
{
|
||||
if(UIWidgetPtr parent = getParent())
|
||||
if(UIAnchorLayoutPtr anchorLayout = parent->getAnchoredLayout())
|
||||
return anchorLayout->hasAnchors(asUIWidget());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UIWidget::isChildLocked(const UIWidgetPtr& child)
|
||||
{
|
||||
auto it = std::find(m_lockedChildren.begin(), m_lockedChildren.end(), child);
|
||||
@@ -1013,7 +1021,7 @@ UIWidgetPtr UIWidget::recursiveGetChildById(const std::string& id)
|
||||
return widget;
|
||||
}
|
||||
|
||||
UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
|
||||
UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos, bool wantsPhantom)
|
||||
{
|
||||
if(!containsChildPoint(childPos))
|
||||
return nullptr;
|
||||
@@ -1021,10 +1029,10 @@ UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos)
|
||||
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
|
||||
const UIWidgetPtr& child = (*it);
|
||||
if(child->isExplicitlyVisible() && child->containsPoint(childPos)) {
|
||||
UIWidgetPtr subChild = child->recursiveGetChildByPos(childPos);
|
||||
UIWidgetPtr subChild = child->recursiveGetChildByPos(childPos, wantsPhantom);
|
||||
if(subChild)
|
||||
return subChild;
|
||||
else if(!child->isPhantom())
|
||||
else if(wantsPhantom || !child->isPhantom())
|
||||
return child;
|
||||
}
|
||||
}
|
||||
@@ -1043,8 +1051,7 @@ UIWidgetList UIWidget::recursiveGetChildrenByPos(const Point& childPos)
|
||||
UIWidgetList subChildren = child->recursiveGetChildrenByPos(childPos);
|
||||
if(!subChildren.empty())
|
||||
children.insert(children.end(), subChildren.begin(), subChildren.end());
|
||||
else if(!child->isPhantom())
|
||||
children.push_back(child);
|
||||
children.push_back(child);
|
||||
}
|
||||
}
|
||||
return children;
|
||||
@@ -1279,6 +1286,12 @@ void UIWidget::onGeometryChange(const Rect& oldRect, const Rect& newRect)
|
||||
|
||||
if(m_textWrap && oldRect.size() != newRect.size())
|
||||
updateText();
|
||||
|
||||
// move children that is outside the parent rect to inside again
|
||||
for(const UIWidgetPtr& child : m_children) {
|
||||
if(!child->isAnchored())
|
||||
child->bindRectToParent();
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::onLayoutUpdate()
|
||||
|
@@ -130,6 +130,7 @@ public:
|
||||
void setVirtualOffset(const Point& offset);
|
||||
|
||||
bool isVisible();
|
||||
bool isAnchored();
|
||||
bool isChildLocked(const UIWidgetPtr& child);
|
||||
bool hasChild(const UIWidgetPtr& child);
|
||||
int getChildIndex(const UIWidgetPtr& child);
|
||||
@@ -144,7 +145,7 @@ public:
|
||||
UIWidgetPtr getChildByPos(const Point& childPos);
|
||||
UIWidgetPtr getChildByIndex(int index);
|
||||
UIWidgetPtr recursiveGetChildById(const std::string& id);
|
||||
UIWidgetPtr recursiveGetChildByPos(const Point& childPos);
|
||||
UIWidgetPtr recursiveGetChildByPos(const Point& childPos, bool wantsPhantom);
|
||||
UIWidgetList recursiveGetChildrenByPos(const Point& childPos);
|
||||
UIWidgetPtr backwardsGetWidgetById(const std::string& id);
|
||||
|
||||
|
Reference in New Issue
Block a user