2014-05-11 18:29:59 -06:00
|
|
|
-- dfstatus 1.5 - a quick access status screen.
|
2015-04-18 17:19:43 -06:00
|
|
|
-- originally written by enjia2000@gmail.com
|
2014-05-06 20:26:18 -06:00
|
|
|
|
|
|
|
local gui = require 'gui'
|
|
|
|
|
2015-04-18 17:19:43 -06:00
|
|
|
dfstatus = defclass(dfstatus, gui.FramedScreen)
|
|
|
|
dfstatus.ATTRS = {
|
|
|
|
frame_style = gui.GREY_LINE_FRAME,
|
|
|
|
frame_title = 'dfstatus',
|
|
|
|
frame_width = 16,
|
|
|
|
frame_height = 17,
|
|
|
|
frame_inset = 1,
|
|
|
|
focus_path = 'dfstatus',
|
|
|
|
}
|
2014-05-06 20:26:18 -06:00
|
|
|
|
2015-04-18 17:19:43 -06:00
|
|
|
function dfstatus:onRenderBody(dc)
|
2014-05-11 18:32:46 -06:00
|
|
|
local drink = 0
|
|
|
|
local wood = 0
|
|
|
|
--local meat = 0
|
|
|
|
--local raw_fish = 0
|
|
|
|
--local plants = 0
|
|
|
|
local prepared_meals = 0
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2014-05-11 18:32:46 -06:00
|
|
|
local fuel = 0
|
|
|
|
local pigiron = 0
|
|
|
|
local iron = 0
|
|
|
|
local steel = 0
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2014-05-11 18:32:46 -06:00
|
|
|
local silver = 0
|
|
|
|
local copper = 0
|
|
|
|
local gold = 0
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2014-05-11 18:32:46 -06:00
|
|
|
local tannedhides = 0
|
|
|
|
local cloth = 0
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2015-04-18 17:19:43 -06:00
|
|
|
for _, item in ipairs(df.global.world.items.all) do
|
|
|
|
if not item.flags.rotten and not item.flags.dump and not item.flags.forbid then
|
|
|
|
if (item:getType() == df.item_type.WOOD) then wood = wood + item:getStackSize()
|
|
|
|
elseif (item:getType() == df.item_type.DRINK) then drink = drink + item:getStackSize()
|
|
|
|
elseif (item:getType() == df.item_type.SKIN_TANNED) then tannedhides = tannedhides + item:getStackSize()
|
|
|
|
elseif (item:getType() == df.item_type.CLOTH) then cloth = cloth + item:getStackSize()
|
|
|
|
--elseif (item:getType() == df.item_type.MEAT) then meat = meat + item:getStackSize()
|
|
|
|
--elseif (item:getType() == df.item_type.FISH_RAW) then raw_fish = raw_fish + item:getStackSize()
|
|
|
|
--elseif (item:getType() == df.item_type.PLANT) then plants = plants + item:getStackSize()
|
|
|
|
elseif (item:getType() == df.item_type.FOOD) then prepared_meals = prepared_meals + item:getStackSize()
|
|
|
|
elseif (item:getType() == df.item_type.BAR) then
|
|
|
|
for token in string.gmatch(dfhack.items.getDescription(item,0),"[^%s]+") do
|
|
|
|
if (token == "silver") then silver = silver + item:getStackSize()
|
|
|
|
elseif (token == "charcoal" or token == "coke") then fuel = fuel + item:getStackSize()
|
|
|
|
elseif (token == "iron") then iron = iron + item:getStackSize()
|
|
|
|
elseif (token == "pig") then pigiron = pigiron + item:getStackSize()
|
|
|
|
elseif (token == "copper") then copper = copper + item:getStackSize()
|
|
|
|
elseif (token == "gold") then gold = gold + item:getStackSize()
|
|
|
|
elseif (token == "steel") then steel = steel + item:getStackSize()
|
|
|
|
end
|
|
|
|
break -- only need to look at the 1st token of each item.
|
2014-05-11 18:29:59 -06:00
|
|
|
end
|
2014-05-11 18:32:46 -06:00
|
|
|
end
|
2014-05-11 18:29:59 -06:00
|
|
|
end
|
2014-05-11 18:32:46 -06:00
|
|
|
end
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:pen(COLOR_LIGHTGREEN)
|
|
|
|
dc:string("Drinks: " .. drink)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(0)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Meals: " .. prepared_meals)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(0)
|
|
|
|
dc:newline(0)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Wood: " .. wood)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(0)
|
|
|
|
dc:newline(0)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Hides: " .. tannedhides)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(0)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Cloth: " .. cloth)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(0)
|
2015-04-18 17:19:43 -06:00
|
|
|
-- dc:string("Raw Fish: ".. raw_fish)
|
2014-05-11 18:32:46 -06:00
|
|
|
-- dc:newline(0)
|
2015-04-18 17:19:43 -06:00
|
|
|
-- dc:string("Plants: ".. plants)
|
2014-05-11 18:32:46 -06:00
|
|
|
-- dc:newline(0)
|
|
|
|
dc:newline(0)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Bars:")
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(1)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Fuel: " .. fuel)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(1)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Pig Iron: " .. pigiron)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(1)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Steel: " .. steel)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(1)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Iron: " .. iron)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(1)
|
|
|
|
dc:newline(1)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Copper: " .. copper)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(1)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Silver: " .. silver)
|
2014-05-11 18:32:46 -06:00
|
|
|
dc:newline(1)
|
2015-04-18 17:19:43 -06:00
|
|
|
dc:string("Gold: " .. gold)
|
2014-05-06 20:26:18 -06:00
|
|
|
end
|
|
|
|
|
2015-04-18 17:19:43 -06:00
|
|
|
function dfstatus:onInput(keys)
|
2014-05-11 18:32:46 -06:00
|
|
|
if keys.LEAVESCREEN or keys.SELECT then
|
|
|
|
self:dismiss()
|
2015-04-18 17:19:43 -06:00
|
|
|
scr = nil
|
2014-05-11 18:32:46 -06:00
|
|
|
end
|
2014-05-06 20:26:18 -06:00
|
|
|
end
|
|
|
|
|
2015-04-18 17:19:43 -06:00
|
|
|
if not scr then
|
|
|
|
scr = dfstatus()
|
|
|
|
scr:show()
|
|
|
|
else
|
|
|
|
scr:dismiss()
|
|
|
|
scr = nil
|
|
|
|
end
|
|
|
|
|