diff --git a/modules/core_lib/widgets/uisplitter.lua b/modules/core_lib/widgets/uisplitter.lua index 459ad772..2be622a3 100644 --- a/modules/core_lib/widgets/uisplitter.lua +++ b/modules/core_lib/widgets/uisplitter.lua @@ -3,8 +3,6 @@ UISplitter = extends(UIWidget) function UISplitter.create() local splitter = UISplitter.internalCreate() splitter:setFocusable(false) - splitter.canGrow = true - splitter.canShrink = true return splitter end @@ -22,27 +20,23 @@ function UISplitter:onHoverChange(hovered) end end -function UISplitter:getAttachedTo() - local parent = self:getParent() - if parent and self.attachedTo then - return parent:getChildById(self.attachedTo) - end -end function UISplitter:onMouseMove(mousePos, mouseMoved) if self:isPressed() then - local deltay = mousePos.y - (self:getPosition().y + self:getHeight()/2) - local deltax = mousePos.x - (self:getPosition().x + self:getWidth()/2) - local attachedToWidget = self:getAttachedTo() - if not attachedToWidget then return end if self.vertical then - if deltay == 0 then return end - if not self.canGrow and deltay > 0 then return end - if not self.canShrink and deltay < 0 then return end - attachedToWidget:setHeight(attachedToWidget:getHeight() - deltay) + local delta = mousePos.y - self:getY() + local currentMargin = self:getMarginBottom() + local newMargin = self:canUpdateMargin(self:getMarginBottom() - delta) + if newMargin ~= currentMargin then + self.newMargin = newMargin + if not self.event or self.event:isExecuted() then + self.event = addEvent(function() + self:setMarginBottom(self.newMargin) + end) + end + end else - if deltax == 0 then return end - attachedToWidget:setWidth(attachedToWidget:getWidth() - deltax) + --TODO end return true end @@ -56,15 +50,11 @@ function UISplitter:onMouseRelease(mousePos, mouseButton) end function UISplitter:onStyleApply(styleName, styleNode) - if styleNode['attached-to'] then - self.attachedTo = styleNode['attached-to'] + if styleNode['relative-margin'] then + self.relativeMargin = styleNode['relative-margin'] end end -function UISplitter:setGrow(enabled) - self.canGrow = enabled -end - -function UISplitter:setShrink(enabled) - self.canShrink = enabled +function UISplitter:canUpdateMargin(newMargin) + return newMargin end diff --git a/modules/game/gameinterface.otui b/modules/game/gameinterface.otui index cdbcaed3..5e44e293 100644 --- a/modules/game/gameinterface.otui +++ b/modules/game/gameinterface.otui @@ -16,6 +16,33 @@ UIWidget anchors.fill: parent anchors.top: topMenu.bottom + GameMapPanel + id: gameMapPanel + anchors.left: gameLeftPanel.right + anchors.right: gameRightPanel.left + anchors.top: parent.top + anchors.bottom: gameBottomPanel.top + focusable: false + + UISplitter + id: mapSplitter + anchors.left: gameLeftPanel.right + anchors.right: gameRightPanel.left + anchors.bottom: parent.bottom + relative-margin: bottom + margin-bottom: 172 + height: 4 + margin-top: -2 + background: red + @canUpdateMargin: function(self, newMargin) return math.min(math.max(newMargin, 100), self:getParent():getHeight() - 300) end + + GameBottomPanel + id: gameBottomPanel + anchors.left: gameLeftPanel.right + anchors.right: gameRightPanel.left + anchors.top: mapSplitter.top + anchors.bottom: parent.bottom + GameSidePanel id: gameRightPanel width: 190 @@ -32,32 +59,6 @@ UIWidget anchors.top: parent.top anchors.bottom: parent.bottom - GameBottomPanel - id: gameBottomPanel - height: 170 - anchors.left: gameLeftPanel.right - anchors.right: gameRightPanel.left - anchors.bottom: parent.bottom - @onGeometryChange: self:getParent():getChildById('mapSplitter'):setGrow(self:getHeight() > 100) - - GameMapPanel - id: gameMapPanel - anchors.left: gameLeftPanel.right - anchors.right: gameRightPanel.left - anchors.top: parent.top - anchors.bottom: gameBottomPanel.top - focusable: false - @onGeometryChange: self:getParent():getChildById('mapSplitter'):setShrink(self:getHeight() > 300) - - UISplitter - id: mapSplitter - anchors.left: gameBottomPanel.left - anchors.right: gameBottomPanel.right - anchors.top: gameBottomPanel.top - attached-to: gameBottomPanel - height: 4 - margin-top: -2 - UIWidget id: mouseGrabber focusable: false diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index 8aff05bb..6a35b327 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -714,6 +714,10 @@ void UIWidget::setLayout(const UILayoutPtr& layout) void UIWidget::setRect(const Rect& rect) { + if(rect.width() > 8192 || rect.height() > 8192) { + logError("attempt to set huge rect size (", rect,") for ", m_id); + return; + } // only update if the rect really changed Rect oldRect = m_rect; if(rect == oldRect) diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/net/protocolcodes.h index 3b8f6d42..fc378d6d 100644 --- a/src/otclient/net/protocolcodes.h +++ b/src/otclient/net/protocolcodes.h @@ -49,7 +49,7 @@ namespace Proto { #if PROTOCOL>=861 constexpr int NumViolationReasons = 19; -#elif PROTOCOL==860 +#elif PROTOCOL>=860 constexpr int NumViolationReasons = 20; #endif @@ -246,7 +246,7 @@ namespace Proto { ServerSpeakRVRAnswer, ServerSpeakRVRContinue, ServerSpeakChannelRed2 -#elif PROTOCOL==860 +#elif PROTOCOL>=860 ServerSpeakSay = 1, ServerSpeakWhisper, ServerSpeakYell, @@ -269,7 +269,7 @@ namespace Proto { }; enum MessageTypes { -#if PROTOCOL>=862 +#if PROTOCOL>=861 MessageConsoleOrange = 13, MessageConsoleOrange2, MessageWarning, @@ -280,7 +280,7 @@ namespace Proto { MessageStatusSmall, MessageConsoleBlue, MessageConsoleRed -#elif PROTOCOL==860 +#elif PROTOCOL>=860 MessageConsoleRed = 18, MessageConsoleOrange, MessageConsoleOrange2,