|
|
@ -18,12 +18,14 @@ JobDetails.ATTRS {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function JobDetails:init(args)
|
|
|
|
function JobDetails:init(args)
|
|
|
|
|
|
|
|
self.building = dfhack.job.getHolder(self.job)
|
|
|
|
|
|
|
|
|
|
|
|
local status = { text = 'No worker', pen = COLOR_DARKGREY }
|
|
|
|
local status = { text = 'No worker', pen = COLOR_DARKGREY }
|
|
|
|
local worker = dfhack.job.getWorker(self.job)
|
|
|
|
local worker = dfhack.job.getWorker(self.job)
|
|
|
|
if self.job.flags.suspend then
|
|
|
|
if self.job.flags.suspend then
|
|
|
|
status = { text = 'Suspended', pen = COLOR_RED }
|
|
|
|
status = { text = 'Suspended', pen = COLOR_RED }
|
|
|
|
elseif worker then
|
|
|
|
elseif worker then
|
|
|
|
status = { text = dfhack.TranslateName(dfhack.unit.getVisibleName(worker)), pen = COLOR_GREEN }
|
|
|
|
status = { text = dfhack.TranslateName(dfhack.units.getVisibleName(worker)), pen = COLOR_GREEN }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
self:addviews{
|
|
|
|
self:addviews{
|
|
|
@ -63,6 +65,14 @@ function JobDetails:init(args)
|
|
|
|
self:initListChoices()
|
|
|
|
self:initListChoices()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function JobDetails:onGetSelectedBuilding()
|
|
|
|
|
|
|
|
return self.building
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function JobDetails:onGetSelectedJob()
|
|
|
|
|
|
|
|
return self.job
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function describe_item_type(iobj)
|
|
|
|
function describe_item_type(iobj)
|
|
|
|
local itemline = 'any item'
|
|
|
|
local itemline = 'any item'
|
|
|
|
if iobj.item_type >= 0 then
|
|
|
|
if iobj.item_type >= 0 then
|
|
|
@ -79,10 +89,7 @@ function describe_item_type(iobj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function is_caste_mat(iobj)
|
|
|
|
function is_caste_mat(iobj)
|
|
|
|
if iobj.item_type >= 0 then
|
|
|
|
return dfhack.items.isCasteMaterial(iobj.item_type)
|
|
|
|
return df.item_type.attrs[iobj.item_type].is_caste_mat
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function describe_material(iobj)
|
|
|
|
function describe_material(iobj)
|
|
|
@ -119,7 +126,7 @@ function JobDetails:initListChoices()
|
|
|
|
|
|
|
|
|
|
|
|
local choices = {}
|
|
|
|
local choices = {}
|
|
|
|
for i,iobj in ipairs(self.job.job_items) do
|
|
|
|
for i,iobj in ipairs(self.job.job_items) do
|
|
|
|
local head = 'Item '..(i+1)..': '..(items[idx] or 0)..' of '..iobj.quantity
|
|
|
|
local head = 'Item '..(i+1)..': '..(items[i] or 0)..' of '..iobj.quantity
|
|
|
|
if iobj.min_dimension > 0 then
|
|
|
|
if iobj.min_dimension > 0 then
|
|
|
|
head = head .. '(size '..iobj.min_dimension..')'
|
|
|
|
head = head .. '(size '..iobj.min_dimension..')'
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -175,16 +182,22 @@ function JobDetails:canChangeIType()
|
|
|
|
return obj ~= nil
|
|
|
|
return obj ~= nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function JobDetails:setItemType(obj, item_type, item_subtype)
|
|
|
|
|
|
|
|
obj.iobj.item_type = item_type
|
|
|
|
|
|
|
|
obj.iobj.item_subtype = item_subtype
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if is_caste_mat(obj.iobj) then
|
|
|
|
|
|
|
|
self:setMaterial(obj, -1, -1)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function JobDetails:onChangeIType()
|
|
|
|
function JobDetails:onChangeIType()
|
|
|
|
local idx, obj = self.subviews.list:getSelected()
|
|
|
|
local idx, obj = self.subviews.list:getSelected()
|
|
|
|
guimat.ItemTypeDialog{
|
|
|
|
guimat.ItemTypeDialog{
|
|
|
|
prompt = 'Please select a new item type for input '..idx,
|
|
|
|
prompt = 'Please select a new item type for input '..idx,
|
|
|
|
none_caption = 'any item',
|
|
|
|
none_caption = 'any item',
|
|
|
|
item_filter = curry(dfhack.job.isSuitableItem, obj.iobj),
|
|
|
|
item_filter = curry(dfhack.job.isSuitableItem, obj.iobj),
|
|
|
|
on_select = function(item_type, item_subtype)
|
|
|
|
on_select = self:callback('setItemType', obj)
|
|
|
|
obj.iobj.item_type = item_type
|
|
|
|
|
|
|
|
obj.iobj.item_subtype = item_subtype
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
}:show()
|
|
|
|
}:show()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -193,6 +206,20 @@ function JobDetails:canChangeMat()
|
|
|
|
return obj ~= nil and not is_caste_mat(obj.iobj)
|
|
|
|
return obj ~= nil and not is_caste_mat(obj.iobj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function JobDetails:setMaterial(obj, mat_type, mat_index)
|
|
|
|
|
|
|
|
if obj.index == 0
|
|
|
|
|
|
|
|
and self.job.mat_type == obj.iobj.mat_type
|
|
|
|
|
|
|
|
and self.job.mat_index == obj.iobj.mat_index
|
|
|
|
|
|
|
|
and self.job.job_type ~= df.job_type.PrepareMeal
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
self.job.mat_type = mat_type
|
|
|
|
|
|
|
|
self.job.mat_index = mat_index
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj.iobj.mat_type = mat_type
|
|
|
|
|
|
|
|
obj.iobj.mat_index = mat_index
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function JobDetails:onChangeMat()
|
|
|
|
function JobDetails:onChangeMat()
|
|
|
|
local idx, obj = self.subviews.list:getSelected()
|
|
|
|
local idx, obj = self.subviews.list:getSelected()
|
|
|
|
|
|
|
|
|
|
|
@ -213,20 +240,18 @@ function JobDetails:onChangeMat()
|
|
|
|
mat_filter = function(mat,parent,mat_type,mat_index)
|
|
|
|
mat_filter = function(mat,parent,mat_type,mat_index)
|
|
|
|
return dfhack.job.isSuitableMaterial(obj.iobj, mat_type, mat_index)
|
|
|
|
return dfhack.job.isSuitableMaterial(obj.iobj, mat_type, mat_index)
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
on_select = function(mat_type, mat_index)
|
|
|
|
on_select = self:callback('setMaterial', obj)
|
|
|
|
if idx == 1
|
|
|
|
}:show()
|
|
|
|
and self.job.mat_type == obj.iobj.mat_type
|
|
|
|
end
|
|
|
|
and self.job.mat_index == obj.iobj.mat_index
|
|
|
|
|
|
|
|
and self.job.job_type ~= df.job_type.PrepareMeal
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
self.job.mat_type = mat_type
|
|
|
|
|
|
|
|
self.job.mat_index = mat_index
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj.iobj.mat_type = mat_type
|
|
|
|
function JobDetails:onInput(keys)
|
|
|
|
obj.iobj.mat_index = mat_index
|
|
|
|
if self:propagateMoveKeys(keys) then
|
|
|
|
|
|
|
|
if df.global.world.selected_building ~= self.building then
|
|
|
|
|
|
|
|
self:dismiss()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}:show()
|
|
|
|
else
|
|
|
|
|
|
|
|
JobDetails.super.onInput(self, keys)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if not string.match(dfhack.gui.getCurFocus(), '^dwarfmode/QueryBuilding/Some/Workshop/Job') then
|
|
|
|
if not string.match(dfhack.gui.getCurFocus(), '^dwarfmode/QueryBuilding/Some/Workshop/Job') then
|
|
|
|