mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
@@ -138,6 +138,24 @@ function UIMiniWindow:onDragEnter(mousePos)
|
||||
return true
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
|
||||
if self.movedWidget then
|
||||
self.setMovedChildMargin(0)
|
||||
self.movedWidget = nil
|
||||
self.setMovedChildMargin = nil
|
||||
self.movedIndex = nil
|
||||
end
|
||||
|
||||
local parent = self:getParent()
|
||||
if parent then
|
||||
if parent:getClassName() == 'UIMiniWindowContainer' then
|
||||
parent:saveChildren()
|
||||
else
|
||||
self:saveParentPosition(parent:getId(), self:getPosition())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragMove(mousePos, mouseMoved)
|
||||
local oldMousePosY = mousePos.y - mouseMoved.y
|
||||
local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos)
|
||||
@@ -188,24 +206,6 @@ function UIMiniWindow:onMousePress()
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
|
||||
if self.movedWidget then
|
||||
self.setMovedChildMargin(0)
|
||||
self.movedWidget = nil
|
||||
self.setMovedChildMargin = nil
|
||||
self.movedIndex = nil
|
||||
end
|
||||
|
||||
local parent = self:getParent()
|
||||
if parent then
|
||||
if parent:getClassName() == 'UIMiniWindowContainer' then
|
||||
parent:saveChildren()
|
||||
else
|
||||
self:saveParentPosition(parent:getId(), self:getPosition())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onFocusChange(focused)
|
||||
-- miniwindows only raises when its outside MiniWindowContainers
|
||||
if not focused then return end
|
||||
@@ -253,3 +253,13 @@ end
|
||||
function UIMiniWindow:disableResize()
|
||||
self:getChildById('bottomResizeBorder'):disable()
|
||||
end
|
||||
|
||||
function UIMiniWindow:setMinimumHeight(height)
|
||||
local resizeBorder = self:getChildById('bottomResizeBorder')
|
||||
resizeBorder:setMinimum(height)
|
||||
end
|
||||
|
||||
function UIMiniWindow:setMaximumHeight(height)
|
||||
local resizeBorder = self:getChildById('bottomResizeBorder')
|
||||
resizeBorder:setMaximum(height)
|
||||
end
|
||||
|
@@ -8,6 +8,10 @@ function UIWindow.create()
|
||||
return window
|
||||
end
|
||||
|
||||
function UIWindow:getClassName()
|
||||
return 'UIWindow'
|
||||
end
|
||||
|
||||
function UIWindow:onKeyDown(keyCode, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
if keyCode == KeyEnter then
|
||||
|
@@ -41,7 +41,7 @@ MiniWindow
|
||||
!text: tr('Battle')
|
||||
height: 166
|
||||
icon: battle.png
|
||||
@onClose: onMiniWindowClose()
|
||||
@onClose: modules.game_battle.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
|
@@ -28,7 +28,7 @@ MiniWindow
|
||||
icon: combatcontrols.png
|
||||
height: 48
|
||||
&save: true
|
||||
@onClose: onMiniWindowClose()
|
||||
@onClose: modules.game_combatcontrols.onMiniWindowClose()
|
||||
|
||||
MiniWindowContents
|
||||
FightOffensiveBox
|
||||
|
@@ -65,7 +65,7 @@ MiniWindow
|
||||
id: healthInfoWindow
|
||||
!text: tr('Health Info')
|
||||
height: 102
|
||||
@onClose: onMiniWindowClose()
|
||||
@onClose: modules.game_healthinfo.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
|
@@ -179,9 +179,9 @@ function onUseWith(clickedWidget, mousePosition)
|
||||
local tile = clickedWidget:getTile(mousePosition)
|
||||
if tile then
|
||||
g_game.useWith(selectedThing, tile:getTopMultiUseThing())
|
||||
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||
g_game.useWith(selectedThing, clickedWidget:getItem())
|
||||
end
|
||||
elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
|
||||
g_game.useWith(selectedThing, clickedWidget:getItem())
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -7,7 +7,6 @@ function UIGameMap.create()
|
||||
return gameMap
|
||||
end
|
||||
|
||||
|
||||
function UIGameMap:onDragEnter(mousePos)
|
||||
local tile = self:getTile(mousePos)
|
||||
if not tile then return false end
|
||||
@@ -28,7 +27,7 @@ function UIGameMap:onDragLeave(droppedWidget, mousePos)
|
||||
end
|
||||
|
||||
function UIGameMap:onDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
if not self:canAcceptDrop(widget, mousePos) then return false end
|
||||
|
||||
local tile = self:getTile(mousePos)
|
||||
if not tile then return false end
|
||||
@@ -82,3 +81,20 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton)
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
function UIGameMap:canAcceptDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local children = rootWidget:recursiveGetChildrenByPos(mousePos)
|
||||
for i=1,#children do
|
||||
local child = children[i]
|
||||
if child == self then
|
||||
return true
|
||||
elseif not child:isPhantom() then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
error('Widget ' .. self:getId() .. ' not in drop list.')
|
||||
return false
|
||||
end
|
||||
|
@@ -20,9 +20,7 @@ function UIItem:onDragLeave(droppedWidget, mousePos)
|
||||
end
|
||||
|
||||
function UIItem:onDrop(widget, mousePos)
|
||||
if self:isVirtual() then return false end
|
||||
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
if not self:canAcceptDrop(widget, mousePos) then return false end
|
||||
|
||||
local item = widget.currentDragThing
|
||||
if not item:isItem() then return false end
|
||||
@@ -94,3 +92,20 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
|
||||
return false
|
||||
end
|
||||
|
||||
function UIItem:canAcceptDrop(widget, mousePos)
|
||||
if self:isVirtual() then return false end
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local children = rootWidget:recursiveGetChildrenByPos(mousePos)
|
||||
for i=1,#children do
|
||||
local child = children[i]
|
||||
if child == self then
|
||||
return true
|
||||
elseif not child:isPhantom() then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
error('Widget ' .. self:getId() .. ' not in drop list.')
|
||||
return false
|
||||
end
|
||||
|
@@ -56,7 +56,7 @@ MiniWindow
|
||||
!text: tr('Inventory')
|
||||
icon: inventory.png
|
||||
height: 95
|
||||
@onClose: onMiniWindowClose()
|
||||
@onClose: modules.game_inventory.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
|
@@ -25,7 +25,7 @@ MiniWindow
|
||||
!text: tr('Minimap')
|
||||
height: 150
|
||||
icon: minimap.png
|
||||
@onClose: onMiniWindowClose()
|
||||
@onClose: modules.game_minimap.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
Label
|
||||
|
@@ -35,7 +35,7 @@ MiniWindow
|
||||
!text: tr('Skills')
|
||||
height: 150
|
||||
icon: skills.png
|
||||
@onClose: onMiniWindowClose()
|
||||
@onClose: modules.game_skills.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
@@ -149,4 +149,3 @@ MiniWindow
|
||||
!text: tr('Fishing')
|
||||
SkillValueLabel
|
||||
SkillPercentPanel
|
||||
|
||||
|
@@ -11,7 +11,6 @@ function init()
|
||||
g_keyboard.bindKeyDown('Ctrl+P', toggle)
|
||||
|
||||
vipWindow = g_ui.loadUI('viplist.otui', modules.game_interface.getRightPanel())
|
||||
vipWindow.onClose = onMiniWindowClose
|
||||
vipButton = TopMenu.addRightGameToggleButton('vipListButton', tr('VIP list') .. ' (Ctrl+P)', 'viplist.png', toggle)
|
||||
vipButton:setOn(true)
|
||||
|
||||
|
@@ -7,6 +7,7 @@ MiniWindow
|
||||
!text: tr('VIP List')
|
||||
height: 100
|
||||
icon: viplist.png
|
||||
@onClose: modules.game_viplist.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
|
Reference in New Issue
Block a user