New sexy 'move stackable item' window!

master
BeniS 12 years ago
parent a1a8d28f5c
commit 8d07f8eaf6

@ -473,7 +473,6 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
return true return true
else else
g_game.use(useThing) g_game.use(useThing)
return true
end end
return true return true
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then 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 autoWalkPos and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
if not player:autoWalk(autoWalkPos) then if not player:autoWalk(autoWalkPos) then
modules.game_textmessage.displayStatusMessage(tr('There is no way.')) modules.game_textmessage.displayStatusMessage(tr('There is no way.'))
return true
end end
return true
end end
return false return false
@ -542,24 +541,32 @@ function moveStackableItem(item, toPos)
g_game.move(item, toPos, 1) g_game.move(item, toPos, 1)
return return
end end
local count = item:getCount() local count = item:getCount()
countWindow = g_ui.createWidget('CountWindow', rootWidget) countWindow = g_ui.createWidget('CountWindow', rootWidget)
local spinbox = countWindow:getChildById('countSpinBox') local itembox = countWindow:getChildById('item')
local scrollbar = countWindow:getChildById('countScrollBar') local scrollbar = countWindow:getChildById('countScrollBar')
spinbox:setMaximum(count) itembox:setItemId(item:getId())
spinbox:setMinimum(1) itembox:setItemCount(count)
spinbox:setValue(count)
scrollbar:setMaximum(count) scrollbar:setMaximum(count)
scrollbar:setMinimum(1) scrollbar:setMinimum(1)
scrollbar:setValue(count) 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) local spinBoxValueChange = function(self, value)
scrollbar:setValue(value) scrollbar:setValue(value)
end end
spinbox.onValueChange = spinBoxValueChange spinbox.onValueChange = spinBoxValueChange
scrollbar.onValueChange = function(self, value) scrollbar.onValueChange = function(self, value)
item:setCount(count - value)
itembox:setItemCount(value)
spinbox.onValueChange = nil spinbox.onValueChange = nil
spinbox:setValue(value) spinbox:setValue(value)
spinbox.onValueChange = spinBoxValueChange spinbox.onValueChange = spinBoxValueChange
@ -567,7 +574,7 @@ function moveStackableItem(item, toPos)
local okButton = countWindow:getChildById('buttonOk') local okButton = countWindow:getChildById('buttonOk')
local moveFunc = function() local moveFunc = function()
g_game.move(item, toPos, spinbox:getValue()) g_game.move(item, toPos, itembox:getItemCount())
okButton:getParent():destroy() okButton:getParent():destroy()
countWindow = nil countWindow = nil
end end

@ -1,40 +1,52 @@
CountWindow < MainWindow CountWindow < MainWindow
id: countWindow id: countWindow
!text: tr('Move Stackable Item') !text: tr('Move Stackable Item')
size: 196 122 size: 196 80
Label SpinBox
!text: tr('Amount:') id: spinBox
text-auto-resize: true
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.bottom
margin-top: 2 width: 0
height: 0
phantom: true
padding-bottom: -40
SpinBox Item
id: countSpinBox id: item
margin-left: 5 anchors.left: parent.left
anchors.left: prev.right
anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
margin-top: 2
margin-left: -4
focusable: false
virtual: true
HorizontalScrollBar HorizontalScrollBar
id: countScrollBar id: countScrollBar
anchors.left: parent.left anchors.left: prev.right
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.top
margin-top: 8 margin-left: 10
margin-top: -2
focusable: false
Button Button
id: buttonOk id: buttonOk
!text: tr('Ok') !text: tr('Ok')
width: 64 height: 20
anchors.right: next.left anchors.left: countScrollBar.horizontalCenter
anchors.bottom: parent.bottom anchors.right: countScrollBar.right
margin-right: 5 anchors.top: countScrollBar.bottom
margin-top: 7
focusable: false
Button Button
id: buttonCancel id: buttonCancel
!text: tr('Cancel') !text: tr('Cancel')
width: 64 height: 20
anchors.right: parent.right anchors.right: countScrollBar.horizontalCenter
anchors.bottom: parent.bottom anchors.left: countScrollBar.left
anchors.top: countScrollBar.bottom
margin-top: 7
margin-right: 6
focusable: false

@ -386,8 +386,9 @@ function onMinimapMouseRelease(self, mousePosition, mouseButton)
if not player:autoWalk(pos) then if not player:autoWalk(pos) then
modules.game_textmessage.displayStatusMessage(tr('There is no way.')) modules.game_textmessage.displayStatusMessage(tr('There is no way.'))
return false return false
else
return true
end end
return true
end end
return false return false
end end

@ -278,9 +278,10 @@ bool Tile::hasThing(const ThingPtr& thing)
int Tile::getThingStackpos(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]) if(thing == m_things[stackpos])
return stackpos; return stackpos;
}
return -1; return -1;
} }

Loading…
Cancel
Save