some window moving
This commit is contained in:
		
							parent
							
								
									08a88e3842
								
							
						
					
					
						commit
						46df3c7dbe
					
				
							
								
								
									
										4
									
								
								TODO
								
								
								
								
							
							
						
						
									
										4
									
								
								TODO
								
								
								
								
							|  | @ -3,7 +3,6 @@ High priority TODO in order (before first public disclose) | |||
| 
 | ||||
| restore map moving | ||||
| multiline text edit | ||||
| fix auto repeats events | ||||
| remove UIGame | ||||
| move windows, navigate in containers | ||||
| complete miniwindow (close, minimize, resize, move) | ||||
|  | @ -11,9 +10,7 @@ create and bind all game functions/events | |||
| let windows stay open while playing | ||||
| combat controls | ||||
| player status icons (poison, etc) | ||||
| modules managment interface | ||||
| load modules from zip files | ||||
| addons folder | ||||
| display exit box when exiting from game | ||||
| scrollbar and scrollable widgets | ||||
| 
 | ||||
|  | @ -25,6 +22,7 @@ review directories loading search | |||
| load modules from zip packages | ||||
| create a class for reading binary files | ||||
| rework lua/c++ logger | ||||
| replace autoload-antencedence with load-before/load-after | ||||
| 
 | ||||
| == Graphics | ||||
| use CoordsBuffer in font | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| You can plance any personal addons here. | ||||
| This folder work exactly as modules folder, however is intended to place only addons here. | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ end | |||
| function About.terminate() | ||||
|   aboutButton:destroy() | ||||
|   aboutButton = nil | ||||
|   About = nil | ||||
| end | ||||
| 
 | ||||
| function About.openWebpage() | ||||
|  |  | |||
|  | @ -15,4 +15,4 @@ Module | |||
|     About.init() | ||||
| 
 | ||||
|   onUnload: | | ||||
|     About.terminate() | ||||
|     About.terminate() | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ MainWindow | |||
|       text-align: center | ||||
|       text: |- | ||||
|         OTClient | ||||
|         Version 0.2.0 | ||||
|         Version 0.4.0 | ||||
|         Created by edubart | ||||
|       anchors.horizontalCenter: parent.horizontalCenter | ||||
|       anchors.top: parent.top | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ end | |||
| function Background.terminate() | ||||
|   background:destroy() | ||||
|   background = nil | ||||
|   Background = nil | ||||
| end | ||||
| 
 | ||||
| function Background.hide() | ||||
|  |  | |||
|  | @ -12,4 +12,3 @@ Module | |||
| 
 | ||||
|   onUnload: | | ||||
|     Background.terminate() | ||||
| 
 | ||||
|  |  | |||
|  | @ -9,4 +9,3 @@ Panel | |||
|   anchors.bottom: parent.bottom | ||||
|   margin-top: 1 | ||||
|   focusable: false | ||||
| 
 | ||||
|  |  | |||
|  | @ -63,6 +63,7 @@ function CharacterList.terminate() | |||
|     loadBox:destroy() | ||||
|     loadBox = nil | ||||
|   end | ||||
|   CharacterList = nil | ||||
| end | ||||
| 
 | ||||
| function CharacterList.create(characters, premDays) | ||||
|  |  | |||
|  | @ -66,4 +66,4 @@ MainWindow | |||
|     width: 64 | ||||
|     anchors.right: parent.right | ||||
|     anchors.bottom: parent.bottom | ||||
|     @onClick: CharacterList.destroy() | ||||
|     @onClick: CharacterList.destroy() | ||||
|  |  | |||
|  | @ -97,6 +97,7 @@ function EnterGame.terminate() | |||
|   enterGameButton = nil | ||||
|   motdButton:destroy() | ||||
|   motdButton = nil | ||||
|   EnterGame = nil | ||||
| end | ||||
| 
 | ||||
| function EnterGame.show() | ||||
|  | @ -144,4 +145,3 @@ end | |||
| function EnterGame.displayMotd() | ||||
|   displayInfoBox('Message of the day', motdMessage) | ||||
| end | ||||
| 
 | ||||
|  |  | |||
|  | @ -14,5 +14,3 @@ Module | |||
|   onUnload: | | ||||
|     EnterGame.terminate() | ||||
|     CharacterList.terminate() | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -34,4 +34,5 @@ function Client.terminate() | |||
|   Settings.set('window-size', g_window.getUnmaximizedSize()) | ||||
|   Settings.set('window-pos', g_window.getUnmaximizedPos()) | ||||
|   Settings.set('window-maximized', g_window.isMaximized()) | ||||
|   Client = nil | ||||
| end | ||||
|  |  | |||
|  | @ -27,6 +27,7 @@ function ModuleManager.terminate() | |||
|   moduleManagerButton:destroy() | ||||
|   moduleManagerButton = nil | ||||
|   moduleList = nil | ||||
|   ModuleManager = nil | ||||
| end | ||||
| 
 | ||||
| function ModuleManager.hide() | ||||
|  | @ -37,7 +38,6 @@ function ModuleManager.show() | |||
|   moduleManagerWindow:show() | ||||
|   moduleManagerWindow:focus() | ||||
|   moduleManagerWindow:raise() | ||||
| 
 | ||||
| end | ||||
| 
 | ||||
| function ModuleManager.toggle() | ||||
|  |  | |||
|  | @ -34,6 +34,7 @@ function Options.terminate() | |||
|   optionsWindow = nil | ||||
|   optionsButton:destroy() | ||||
|   optionsButton = nil | ||||
|   Options = nil | ||||
| end | ||||
| 
 | ||||
| function Options.toggle() | ||||
|  |  | |||
|  | @ -137,6 +137,7 @@ function Terminal.terminate() | |||
|   terminalWidget:destroy() | ||||
|   terminalWidget = nil | ||||
|   commandEnv = nil | ||||
|   Terminal = nil | ||||
| end | ||||
| 
 | ||||
| function Terminal.toggle() | ||||
|  |  | |||
|  | @ -39,6 +39,8 @@ function TopMenu.terminate() | |||
| 
 | ||||
|   disconnect(Game, { onLogin = TopMenu.showGameButtons, | ||||
|                      onLogout = TopMenu.hideGameButtons }) | ||||
| 
 | ||||
|   TopMenu = nil | ||||
| end | ||||
| 
 | ||||
| function TopMenu.addButton(id, description, icon, callback, right) | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| function scheduleEvent(func, delay) | ||||
| function scheduleEvent(callback, delay) | ||||
|   local event = g_dispatcher.scheduleEvent(callback, delay) | ||||
| 
 | ||||
|   -- must hold a reference to the callback, otherwise it would be collected | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| Color = {} | ||||
| Color = {} | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| Point = {} | ||||
| Point = {} | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| Rect = {} | ||||
| Rect = {} | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| Size = {} | ||||
| Size = {} | ||||
|  |  | |||
|  | @ -2,4 +2,4 @@ Item < UIItem | |||
|   size: 34 34 | ||||
|   image-source: /core_styles/images/item.png | ||||
|   font: verdana-11px-rounded | ||||
|   border-color: white | ||||
|   border-color: white | ||||
|  |  | |||
|  | @ -10,8 +10,7 @@ TopPanel < Panel | |||
|   image-source: /core_styles/images/top_panel.png | ||||
|   image-repeated: true | ||||
| 
 | ||||
| InterfacePanel < Panel | ||||
|   focusable: false | ||||
| InterfacePanel < UIMiniWindowContainer | ||||
|   image-source: /core_styles/images/interface_panel.png | ||||
|   image-border: 4 | ||||
| 
 | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ Window < UIWindow | |||
| MainWindow < Window | ||||
|   anchors.centerIn: parent | ||||
| 
 | ||||
| MiniWindow < UIWindow | ||||
| MiniWindow < UIMiniWindow | ||||
|   font: verdana-11px-antialised | ||||
|   //icon: /core_styles/icons/login.png | ||||
|   icon-rect: 4 4 16 16 | ||||
|  |  | |||
|  | @ -19,12 +19,12 @@ Module | |||
|     dofile 'uitabbar' | ||||
|     dofile 'uipopupmenu' | ||||
|     dofile 'uiwindow' | ||||
|     dofile 'uiminiwindow' | ||||
|     dofile 'uiminiwindowcontainer' | ||||
|     dofile 'uiitem' | ||||
|     dofile 'uimessagebox' | ||||
| 
 | ||||
|     dofile 'tooltip' | ||||
|     --dofile 'messagebox/messagebox' | ||||
| 
 | ||||
|     ToolTip.init() | ||||
| 
 | ||||
|   onUnload: | | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ function UIItem:onDragEnter(mousePos) | |||
|   return true | ||||
| end | ||||
| 
 | ||||
| function UIItem:onDragLeave(widget, mousePos) | ||||
| function UIItem:onDragLeave(droppedWidget, mousePos) | ||||
|   if self:isVirtual() then return false end | ||||
| 
 | ||||
|   if not self.parsed then | ||||
|  | @ -53,8 +53,9 @@ end | |||
| function UIItem:onHoverChange(hovered) | ||||
|   if self:isVirtual() then return end | ||||
| 
 | ||||
|   if g_ui.getDraggingWidget() and self ~= g_ui.getDraggingWidget() then | ||||
|     if hovered then | ||||
|   local dragginWidget = g_ui.getDraggingWidget() | ||||
|   if dragginWidget and self ~= dragginWidget then | ||||
|     if dragginWidget:getClassName() == 'UIItem' and not dragginWidget:isVirtual() and hovered then | ||||
|       self:setBorderWidth(1) | ||||
|     else | ||||
|       self:setBorderWidth(0) | ||||
|  |  | |||
|  | @ -0,0 +1,30 @@ | |||
| UIMiniWindow = extends(UIWindow) | ||||
| 
 | ||||
| function UIMiniWindow.create() | ||||
|   local miniwindow = UIMiniWindow.internalCreate() | ||||
|   return miniwindow | ||||
| end | ||||
| 
 | ||||
| function UIMiniWindow:onMousePress(mousePos, mouseButton) | ||||
|   local parent = self:getParent() | ||||
|   if parent:getClassName() ~= 'UIMiniWindowContainer' then | ||||
|     self:raise() | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| function UIMiniWindow:onDragEnter(mousePos) | ||||
|   local parent = self:getParent() | ||||
|   if parent:getClassName() == 'UIMiniWindowContainer' then | ||||
|     local containerParent = parent:getParent() | ||||
|     parent:removeChild(self) | ||||
|     containerParent:addChild(self) | ||||
|   end | ||||
| 
 | ||||
|   local oldPos = self:getPosition() | ||||
|   self.movingReference = { x = mousePos.x - oldPos.x, y = mousePos.y - oldPos.y } | ||||
|   self:setPosition(oldPos) | ||||
| end | ||||
| 
 | ||||
| function UIMiniWindow:onDragLeave(droppedWidget, mousePos) | ||||
|   -- TODO: drop on other interfaces | ||||
| end | ||||
|  | @ -0,0 +1,12 @@ | |||
| UIMiniWindowContainer = extends(UIWidget) | ||||
| 
 | ||||
| function UIMiniWindowContainer.create() | ||||
|   local container = UIMiniWindowContainer.internalCreate() | ||||
|   container:setFocusable(false) | ||||
|   container:setPhantom(true) | ||||
|   return container | ||||
| end | ||||
| 
 | ||||
| function UIMiniWindowContainer:getClassName() | ||||
|   return 'UIMiniWindowContainer' | ||||
| end | ||||
|  | @ -3,6 +3,7 @@ UIWindow = extends(UIWidget) | |||
| function UIWindow.create() | ||||
|   local window = UIWindow.internalCreate() | ||||
|   window:setTextAlign(AlignTopCenter) | ||||
|   window:setDragable(true) | ||||
|   return window | ||||
| end | ||||
| 
 | ||||
|  | @ -20,6 +21,17 @@ function UIWindow:onMousePress(mousePos, mouseButton) | |||
| 
 | ||||
| end | ||||
| 
 | ||||
| function UIWindow:onGeometryChange(oldRect, newRect) | ||||
| 
 | ||||
| function UIWindow:onDragEnter(mousePos) | ||||
|   self:breakAnchors() | ||||
|   self.movingReference = { x = mousePos.x - self:getX(), y = mousePos.y - self:getY() } | ||||
| end | ||||
| 
 | ||||
| function UIWindow:onDragLeave(droppedWidget, mousePos) | ||||
|   -- TODO: auto detect and reconnect anchors | ||||
| end | ||||
| 
 | ||||
| function UIWindow:onDragMove(mousePos, mouseMoved) | ||||
|   local pos = { x = mousePos.x - self.movingReference.x, y = mousePos.y - self.movingReference.y } | ||||
|   self:setPosition(pos) | ||||
|   self:bindRectToParent() | ||||
| end | ||||
|  |  | |||
|  | @ -1,6 +0,0 @@ | |||
| Module | ||||
|   name: game_miniwindow | ||||
|   description: Manage game miniwindow | ||||
|   author: OTClient team | ||||
|   website: https://github.com/edubart/otclient | ||||
|   onLoad: | ||||
|  | @ -103,6 +103,8 @@ void Application::registerLuaFunctions() | |||
|     g_lua.bindClassMemberFunction<UIWidget>("setChecked", &UIWidget::setChecked); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setFocusable", &UIWidget::setFocusable); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setPhantom", &UIWidget::setPhantom); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setDragging", &UIWidget::setDragging); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setDragable", &UIWidget::setDragable); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setFixedSize", &UIWidget::setFixedSize); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setLastFocusReason", &UIWidget::setLastFocusReason); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setAutoRepeatDelay", &UIWidget::setAutoRepeatDelay); | ||||
|  | @ -120,6 +122,7 @@ void Application::registerLuaFunctions() | |||
|     g_lua.bindClassMemberFunction<UIWidget>("getChildByIndex", &UIWidget::getChildByIndex); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildById", &UIWidget::recursiveGetChildById); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildByPos", &UIWidget::recursiveGetChildByPos); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildrenByPos", &UIWidget::recursiveGetChildrenByPos); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("backwardsGetWidgetById", &UIWidget::backwardsGetWidgetById); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("asUIWidget", &UIWidget::asUIWidget); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("resize", &UIWidget::resize); | ||||
|  | @ -145,6 +148,8 @@ void Application::registerLuaFunctions() | |||
|     g_lua.bindClassMemberFunction<UIWidget>("isExplicitlyVisible", &UIWidget::isExplicitlyVisible); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("isFocusable", &UIWidget::isFocusable); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("isPhantom", &UIWidget::isPhantom); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("isDragable", &UIWidget::isDragable); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("isDragging", &UIWidget::isDragging); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("isFixedSize", &UIWidget::isFixedSize); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("isDestroyed", &UIWidget::isDestroyed); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("hasChildren", &UIWidget::hasChildren); | ||||
|  | @ -186,7 +191,15 @@ void Application::registerLuaFunctions() | |||
|     g_lua.bindClassMemberFunction<UIWidget>("setIconSize", &UIWidget::setIconSize); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setIconRect", &UIWidget::setIconRect); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderWidth", &UIWidget::setBorderWidth); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderWidthTop", &UIWidget::setBorderWidthTop); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderWidthRight", &UIWidget::setBorderWidthRight); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderWidthBottom", &UIWidget::setBorderWidthBottom); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderWidthLeft", &UIWidget::setBorderWidthLeft); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderColor", &UIWidget::setBorderColor); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderColorTop", &UIWidget::setBorderColorTop); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderColorRight", &UIWidget::setBorderColorRight); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderColorBottom", &UIWidget::setBorderColorBottom); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setBorderColorLeft", &UIWidget::setBorderColorLeft); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setMargin", &UIWidget::setMargin); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setMarginHorizontal", &UIWidget::setMarginHorizontal); | ||||
|     g_lua.bindClassMemberFunction<UIWidget>("setMarginVertical", &UIWidget::setMarginVertical); | ||||
|  |  | |||
|  | @ -50,6 +50,12 @@ void LuaInterface::init() | |||
|     registerClass<LuaObject>(); | ||||
|     bindClassMemberFunction<LuaObject>("getUseCount", &LuaObject::getUseCount); | ||||
|     bindClassMemberFunction<LuaObject>("getClassName", &LuaObject::getClassName); | ||||
| 
 | ||||
|     registerClassMemberFunction<LuaObject>("getFieldsTable", (LuaCppFunction) ([](LuaInterface* lua) { | ||||
|         LuaObjectPtr obj = g_lua.popObject(); | ||||
|         obj->luaGetFieldsTable(); | ||||
|         return 1; | ||||
|     })); | ||||
| } | ||||
| 
 | ||||
| void LuaInterface::terminate() | ||||
|  |  | |||
|  | @ -65,6 +65,14 @@ void LuaObject::luaGetField(const std::string& key) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void LuaObject::luaGetFieldsTable() | ||||
| { | ||||
|     if(m_fieldsTableRef != -1) | ||||
|         g_lua.getRef(m_fieldsTableRef); | ||||
|     else | ||||
|         g_lua.pushNil(); | ||||
| } | ||||
| 
 | ||||
| int LuaObject::getUseCount() | ||||
| { | ||||
|     return shared_from_this().use_count() - 1; | ||||
|  |  | |||
|  | @ -57,6 +57,9 @@ public: | |||
|     /// Gets a field from this lua object, the result is pushed onto the stack
 | ||||
|     void luaGetField(const std::string& key); | ||||
| 
 | ||||
|     /// Gets the table containing all stored fields of this lua object, the result is pushed onto the stack
 | ||||
|     void luaGetFieldsTable(); | ||||
| 
 | ||||
|     /// Returns the number of references of this object
 | ||||
|     /// @note each userdata of this object on lua counts as a reference
 | ||||
|     int getUseCount(); | ||||
|  |  | |||
|  | @ -79,6 +79,22 @@ void UIManager::inputEvent(const InputEvent& event) | |||
|             break; | ||||
|         case Fw::MouseReleaseInputEvent: | ||||
|             m_mouseReceiver->propagateOnMouseRelease(event.mousePos, event.mouseButton); | ||||
|             if(m_draggingWidget && event.mouseButton == Fw::MouseLeftButton) { | ||||
|                 auto clickedChildren = m_rootWidget->recursiveGetChildrenByPos(event.mousePos); | ||||
|                 UIWidgetPtr droppedWidget; | ||||
|                 for(const UIWidgetPtr& child : clickedChildren) { | ||||
|                     if(child != m_draggingWidget) { | ||||
|                         droppedWidget = child; | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|                 if(droppedWidget) | ||||
|                     droppedWidget->onDrop(m_draggingWidget, event.mousePos); | ||||
| 
 | ||||
|                 m_draggingWidget->onDragLeave(droppedWidget, event.mousePos); | ||||
|                 m_draggingWidget->setDragging(false); | ||||
|                 m_draggingWidget = nullptr; | ||||
|             } | ||||
|             break; | ||||
|         case Fw::MouseMoveInputEvent: | ||||
|             m_mouseReceiver->updateState(Fw::HoverState); | ||||
|  |  | |||
|  | @ -743,12 +743,6 @@ void UIWidget::setPhantom(bool phantom) | |||
| 
 | ||||
| void UIWidget::setDragging(bool dragging) | ||||
| { | ||||
|     if(dragging) { | ||||
|         g_ui.setDraggingWidget(asUIWidget()); | ||||
|     } else { | ||||
|         if(g_ui.getDraggingWidget() == asUIWidget()) | ||||
|             g_ui.setDraggingWidget(nullptr); | ||||
|     } | ||||
|     m_dragging = dragging; | ||||
| } | ||||
| 
 | ||||
|  | @ -898,6 +892,22 @@ UIWidgetPtr UIWidget::recursiveGetChildByPos(const Point& childPos) | |||
|     return nullptr; | ||||
| } | ||||
| 
 | ||||
| UIWidgetList UIWidget::recursiveGetChildrenByPos(const Point& childPos) | ||||
| { | ||||
|     UIWidgetList children; | ||||
|     for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) { | ||||
|         const UIWidgetPtr& child = (*it); | ||||
|         if(child->isExplicitlyVisible() && child->containsPoint(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); | ||||
|         } | ||||
|     } | ||||
|     return children; | ||||
| } | ||||
| 
 | ||||
| UIWidgetPtr UIWidget::backwardsGetWidgetById(const std::string& id) | ||||
| { | ||||
|     UIWidgetPtr widget = getChildById(id); | ||||
|  | @ -1141,6 +1151,11 @@ void UIWidget::onDragLeave(UIWidgetPtr droppedWidget, const Point& mousePos) | |||
|     callLuaField("onDragLeave", droppedWidget, mousePos); | ||||
| } | ||||
| 
 | ||||
| bool UIWidget::onDragMove(const Point& mousePos, const Point& mouseMoved) | ||||
| { | ||||
|     return callLuaField("onDragMove", mousePos, mouseMoved); | ||||
| } | ||||
| 
 | ||||
| void UIWidget::onDrop(UIWidgetPtr draggedWidget, const Point& mousePos) | ||||
| { | ||||
|     callLuaField("onDrop", draggedWidget, mousePos); | ||||
|  | @ -1184,13 +1199,6 @@ bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button) | |||
|     if(isPressed() && getRect().contains(mousePos)) | ||||
|         onClick(mousePos); | ||||
| 
 | ||||
|     UIWidgetPtr draggedWidget = g_ui.getDraggingWidget(); | ||||
|     if(draggedWidget && button == Fw::MouseLeftButton && (containsPoint(mousePos) || asUIWidget() == g_ui.getRootWidget())) { | ||||
|         onDrop(draggedWidget, mousePos); | ||||
|         draggedWidget->onDragLeave(asUIWidget(), mousePos); | ||||
|         draggedWidget->setDragging(false); | ||||
|     } | ||||
| 
 | ||||
|     return callLuaField<bool>("onMouseRelease", mousePos, button); | ||||
| } | ||||
| 
 | ||||
|  | @ -1202,6 +1210,11 @@ bool UIWidget::onMouseMove(const Point& mousePos, const Point& mouseMoved) | |||
|         onDragEnter(mousePos - mouseMoved); | ||||
|     } | ||||
| 
 | ||||
|     if(m_dragging) { | ||||
|         if(onDragMove(mousePos, mouseMoved)) | ||||
|             return true; | ||||
|     } | ||||
| 
 | ||||
|     return callLuaField<bool>("onMouseMove", mousePos, mouseMoved); | ||||
| } | ||||
| 
 | ||||
|  | @ -1354,7 +1367,7 @@ bool UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton bu | |||
|     UIWidgetList children; | ||||
|     for(const UIWidgetPtr& child : m_children) { | ||||
|         // events on hidden or disabled widgets are discarded
 | ||||
|         if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible()) | ||||
|         if((!child->isExplicitlyEnabled() || !child->isExplicitlyVisible()) && (!child->isPressed() && button == Fw::MouseLeftButton)) | ||||
|             continue; | ||||
| 
 | ||||
|         // mouse release events go to all children
 | ||||
|  |  | |||
|  | @ -140,6 +140,7 @@ public: | |||
|     UIWidgetPtr getChildByIndex(int index); | ||||
|     UIWidgetPtr recursiveGetChildById(const std::string& id); | ||||
|     UIWidgetPtr recursiveGetChildByPos(const Point& childPos); | ||||
|     UIWidgetList recursiveGetChildrenByPos(const Point& childPos); | ||||
|     UIWidgetPtr backwardsGetWidgetById(const std::string& id); | ||||
| 
 | ||||
|     UIWidgetPtr asUIWidget() { return std::static_pointer_cast<UIWidget>(shared_from_this()); } | ||||
|  | @ -175,6 +176,7 @@ protected: | |||
|     virtual void onHoverChange(bool hovered); | ||||
|     virtual void onDragEnter(const Point& mousePos); | ||||
|     virtual void onDragLeave(UIWidgetPtr droppedWidget, const Point& mousePos); | ||||
|     virtual bool onDragMove(const Point& mousePos, const Point& mouseMoved); | ||||
|     virtual void onDrop(UIWidgetPtr draggedWidget, const Point& mousePos); | ||||
|     virtual bool onKeyText(const std::string& keyText); | ||||
|     virtual bool onKeyDown(uchar keyCode, int keyboardModifiers); | ||||
|  |  | |||
|  | @ -229,14 +229,16 @@ void OTClient::registerLuaFunctions() | |||
|     g_lua.bindClassStaticFunction<UIItem>("create", []{ return UIItemPtr(new UIItem); }); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("setItemId", &UIItem::setItemId); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("setItemCount", &UIItem::setItemCount); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("setItemSubType", &UIItem::setItemSubType); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("setItem", &UIItem::setItem); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("setVirtual", &UIItem::setVirtual); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("clearItem", &UIItem::clearItem); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("getItemId", &UIItem::getItemId); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("getItemCount", &UIItem::getItemCount); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("getItemSubType", &UIItem::getItemSubType); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("getItem", &UIItem::getItem); | ||||
|     g_lua.bindClassMemberFunction<UIItem>("isVirtual", &UIItem::isVirtual); | ||||
| 
 | ||||
| 
 | ||||
|     g_lua.registerClass<UICreature, UIWidget>(); | ||||
|     g_lua.bindClassStaticFunction<UICreature>("create", []{ return UICreaturePtr(new UICreature); } ); | ||||
|     g_lua.bindClassMemberFunction<UICreature>("getCreature", &UICreature::getCreature); | ||||
|  |  | |||
|  | @ -44,6 +44,7 @@ void OTClient::init(const std::vector<std::string>& args) | |||
|     // client modules 100-499
 | ||||
|     g_modules.autoLoadModules(499); | ||||
|     g_modules.ensureModuleLoaded("client_main"); | ||||
|     g_modules.ensureModuleLoaded("client_tibiafiles"); | ||||
|     // game modules 500-999
 | ||||
|     g_modules.autoLoadModules(999); | ||||
|     g_modules.ensureModuleLoaded("game"); | ||||
|  |  | |||
|  | @ -54,7 +54,7 @@ void UIItem::draw() | |||
| 
 | ||||
| void UIItem::setItemId(int id) | ||||
| { | ||||
|     if(!m_item) | ||||
|     if(!m_item && id != 0) | ||||
|         m_item = Item::create(id); | ||||
|     else { | ||||
|         // remove item
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Eduardo Bart
						Eduardo Bart