New sexy 'move stackable item' window!
This commit is contained in:
parent
a1a8d28f5c
commit
8d07f8eaf6
|
@ -473,7 +473,6 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
|
|||
return true
|
||||
else
|
||||
g_game.use(useThing)
|
||||
return true
|
||||
end
|
||||
return true
|
||||
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
|
@ -524,8 +523,8 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
|
|||
if autoWalkPos and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
||||
if not player:autoWalk(autoWalkPos) then
|
||||
modules.game_textmessage.displayStatusMessage(tr('There is no way.'))
|
||||
return true
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
|
@ -542,24 +541,32 @@ function moveStackableItem(item, toPos)
|
|||
g_game.move(item, toPos, 1)
|
||||
return
|
||||
end
|
||||
|
||||
local count = item:getCount()
|
||||
|
||||
countWindow = g_ui.createWidget('CountWindow', rootWidget)
|
||||
local spinbox = countWindow:getChildById('countSpinBox')
|
||||
local itembox = countWindow:getChildById('item')
|
||||
local scrollbar = countWindow:getChildById('countScrollBar')
|
||||
spinbox:setMaximum(count)
|
||||
spinbox:setMinimum(1)
|
||||
spinbox:setValue(count)
|
||||
itembox:setItemId(item:getId())
|
||||
itembox:setItemCount(count)
|
||||
scrollbar:setMaximum(count)
|
||||
scrollbar:setMinimum(1)
|
||||
scrollbar:setValue(count)
|
||||
|
||||
local spinbox = countWindow:getChildById('spinBox')
|
||||
spinbox:setMaximum(count)
|
||||
spinbox:setMinimum(0)
|
||||
spinbox:setValue(0)
|
||||
spinbox:hideButtons()
|
||||
spinbox:focus()
|
||||
|
||||
local spinBoxValueChange = function(self, value)
|
||||
scrollbar:setValue(value)
|
||||
end
|
||||
spinbox.onValueChange = spinBoxValueChange
|
||||
|
||||
scrollbar.onValueChange = function(self, value)
|
||||
item:setCount(count - value)
|
||||
itembox:setItemCount(value)
|
||||
spinbox.onValueChange = nil
|
||||
spinbox:setValue(value)
|
||||
spinbox.onValueChange = spinBoxValueChange
|
||||
|
@ -567,7 +574,7 @@ function moveStackableItem(item, toPos)
|
|||
|
||||
local okButton = countWindow:getChildById('buttonOk')
|
||||
local moveFunc = function()
|
||||
g_game.move(item, toPos, spinbox:getValue())
|
||||
g_game.move(item, toPos, itembox:getItemCount())
|
||||
okButton:getParent():destroy()
|
||||
countWindow = nil
|
||||
end
|
||||
|
|
|
@ -1,40 +1,52 @@
|
|||
CountWindow < MainWindow
|
||||
id: countWindow
|
||||
!text: tr('Move Stackable Item')
|
||||
size: 196 122
|
||||
size: 196 80
|
||||
|
||||
Label
|
||||
!text: tr('Amount:')
|
||||
text-auto-resize: true
|
||||
SpinBox
|
||||
id: spinBox
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.bottom
|
||||
width: 0
|
||||
height: 0
|
||||
phantom: true
|
||||
padding-bottom: -40
|
||||
|
||||
Item
|
||||
id: item
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin-top: 2
|
||||
|
||||
SpinBox
|
||||
id: countSpinBox
|
||||
margin-left: 5
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
margin-left: -4
|
||||
focusable: false
|
||||
virtual: true
|
||||
|
||||
HorizontalScrollBar
|
||||
id: countScrollBar
|
||||
anchors.left: parent.left
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 8
|
||||
anchors.top: prev.top
|
||||
margin-left: 10
|
||||
margin-top: -2
|
||||
focusable: false
|
||||
|
||||
Button
|
||||
id: buttonOk
|
||||
!text: tr('Ok')
|
||||
width: 64
|
||||
anchors.right: next.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin-right: 5
|
||||
height: 20
|
||||
anchors.left: countScrollBar.horizontalCenter
|
||||
anchors.right: countScrollBar.right
|
||||
anchors.top: countScrollBar.bottom
|
||||
margin-top: 7
|
||||
focusable: false
|
||||
|
||||
Button
|
||||
id: buttonCancel
|
||||
!text: tr('Cancel')
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
height: 20
|
||||
anchors.right: countScrollBar.horizontalCenter
|
||||
anchors.left: countScrollBar.left
|
||||
anchors.top: countScrollBar.bottom
|
||||
margin-top: 7
|
||||
margin-right: 6
|
||||
focusable: false
|
||||
|
|
|
@ -386,9 +386,10 @@ function onMinimapMouseRelease(self, mousePosition, mouseButton)
|
|||
if not player:autoWalk(pos) then
|
||||
modules.game_textmessage.displayStatusMessage(tr('There is no way.'))
|
||||
return false
|
||||
end
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
@ -278,9 +278,10 @@ bool Tile::hasThing(const ThingPtr& thing)
|
|||
|
||||
int Tile::getThingStackpos(const ThingPtr& thing)
|
||||
{
|
||||
for(uint stackpos = 0; stackpos < m_things.size(); ++stackpos)
|
||||
for(uint stackpos = 0; stackpos < m_things.size(); ++stackpos) {
|
||||
if(thing == m_things[stackpos])
|
||||
return stackpos;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue