improve transferring items between left and right
This commit is contained in:
parent
fb214842b8
commit
56a6fb85bf
@ -321,6 +321,7 @@ end
|
||||
function main_view:on_key(key)
|
||||
local left_selected = self.left_store.filtered_names[self.left_store.selected_idx]
|
||||
local right_selected = self.right_store.filtered_names[self.right_store.selected_idx]
|
||||
local selected_item = self.is_left_active and left_selected or right_selected
|
||||
|
||||
if key == keys.rightCtrl or key == keys.leftCtrl then
|
||||
self.ctrl_down = true
|
||||
@ -357,26 +358,27 @@ function main_view:on_key(key)
|
||||
self:deposit_items()
|
||||
end
|
||||
|
||||
if self.is_left_active then
|
||||
if key == keys.l and left_selected then
|
||||
local item = left_selected
|
||||
local stack_size = self.item_details[item].stack_size
|
||||
local transferred = math.min(self.left_store.all_items[item], stack_size)
|
||||
self.left_store.all_items[item] = self.left_store.all_items[item] - transferred
|
||||
self.right_store.all_items[item] = (self.right_store.all_items[item] or 0) + transferred
|
||||
self:refresh_filtered_names(self.left_store, self.left_area)
|
||||
self:refresh_filtered_names(self.right_store, self.right_area)
|
||||
self:select_item(self.left_store, self.left_area, item)
|
||||
if selected_item and (key == keys.l or key == keys.h) then
|
||||
local item = selected_item
|
||||
local stack_size = self.item_details[item].stack_size
|
||||
local right_items = self.right_store.all_items
|
||||
local left_items = self.left_store.all_items
|
||||
|
||||
if key == keys.l then
|
||||
local transferred = math.min(left_items[item], stack_size)
|
||||
left_items[item] = left_items[item] - transferred
|
||||
right_items[item] = (right_items[item] or 0) + transferred
|
||||
elseif key == keys.h then
|
||||
local transferred = math.min(right_items[item] or 0, stack_size)
|
||||
left_items[item] = left_items[item] + transferred
|
||||
right_items[item] = (right_items[item] or 0) - transferred
|
||||
end
|
||||
else
|
||||
if key == keys.h and right_selected then
|
||||
local item = right_selected
|
||||
local stack_size = self.item_details[item].stack_size
|
||||
local transferred = math.min(self.right_store.all_items[item], stack_size)
|
||||
self.left_store.all_items[item] = self.left_store.all_items[item] + transferred
|
||||
self.right_store.all_items[item] = self.right_store.all_items[item] - transferred
|
||||
self:refresh_filtered_names(self.left_store, self.left_area)
|
||||
self:refresh_filtered_names(self.right_store, self.right_area)
|
||||
|
||||
self:refresh_filtered_names(self.left_store, self.left_area)
|
||||
self:refresh_filtered_names(self.right_store, self.right_area)
|
||||
if self.is_left_active then
|
||||
self:select_item(self.left_store, self.left_area, item)
|
||||
else
|
||||
self:select_item(self.right_store, self.right_area, item)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user