Skip to content
Snippets Groups Projects
Commit 179732bb authored by dg's avatar dg
Browse files

Inventory title bar (in Metal UI) fills up with a special color to represent encumberance

git-svn-id: http://svn.net-core.org/repos/t-engine4@4429 51575b47-30f0-44d4-a5cc-537603b46e54
parent ad4d091e
No related branches found
No related tags found
No related merge requests found
......@@ -33,13 +33,13 @@ defineAction{
defineAction{
default = { "sym:=g:false:false:false:false" },
type = "PICKUP_FLOOR",
group = "actions",
group = "inventory",
name = "Pickup items",
}
defineAction{
default = { "sym:=d:false:false:false:false" },
type = "DROP_FLOOR",
group = "actions",
group = "inventory",
name = "Drop items",
}
......
......@@ -434,13 +434,13 @@ function _M:instanciate(mod, name, new_game, no_reboot)
if config.settings.cheat then
hash_valid, hash_err = false, "cheat mode skipping validation"
else
fp("/mod")
fp("/data")
fp("/engine")
table.sort(md5s)
local fmd5 = md5.sumhexa(table.concat(md5s))
print("[MODULE LOADER] module MD5", fmd5, "computed in ", core.game.getTime() - t)
if mod.short_name ~= "boot" then
fp("/mod")
fp("/data")
fp("/engine")
table.sort(md5s)
local fmd5 = md5.sumhexa(table.concat(md5s))
print("[MODULE LOADER] module MD5", fmd5, "computed in ", core.game.getTime() - t)
hash_valid, hash_err = profile:checkModuleHash(mod.version_name, fmd5)
end
end
......
......@@ -53,7 +53,7 @@ _M.ui_conf = {
frame_ox2 = 42,
frame_oy1 = -42,
frame_oy2 = 42,
title_bar = {x=0, y=-19},
title_bar = {x=0, y=-21, w=4, h=25},
},
stone = {
frame_shadow = {x=15, y=15, a=0.5},
......
......@@ -225,6 +225,8 @@ function _M:init(title, w, h, x, y, alpha, font, showup, skin)
if conf.title_bar then
self.frame.title_x = conf.title_bar.x
self.frame.title_y = conf.title_bar.y
self.frame.title_w = conf.title_bar.w
self.frame.title_h = conf.title_bar.h
self.frame.b7 = self.frame.b7:gsub("dialogframe", "title_dialogframe")
self.frame.b8 = self.frame.b8:gsub("dialogframe", "title_dialogframe")
self.frame.b9 = self.frame.b9:gsub("dialogframe", "title_dialogframe")
......@@ -316,10 +318,12 @@ function _M:updateTitle(title)
if not title then return end
local title = title
if type(title)=="function" then title = title() end
self.font_bold:setStyle("bold")
local tw, th = self.font_bold:size(title)
local s = core.display.newSurface(tw, th)
s:erase(0, 0, 0, 0)
s:drawColorStringBlended(self.font_bold, title, 0, 0, self.color.r, self.color.g, self.color.b, true)
self.font_bold:setStyle("normal")
self.title_tex = {s:glTexture()}
self.title_tex.w = tw
self.title_tex.h = th
......
......@@ -1208,6 +1208,10 @@ function util.showMainMenu(no_reboot, reboot_engine, reboot_engine_version, rebo
end
end
function util.lerp(a, b, x)
return a + x * (b - a)
end
function util.factorial(n)
if n == 0 then
return 1
......
......@@ -66,3 +66,28 @@ function _M:generateList()
self.c_inven:setList(self.inven_list)
self.c_equip:setList(self.equip_list)
end
function _M:updateTitle(title)
Base.updateTitle(self, title)
local green = colors.LIGHT_GREEN
local red = colors.LIGHT_RED
local enc, max = self.actor:getEncumbrance(), self.actor:getMaxEncumbrance()
local v = math.min(enc, max) / max
self.title_fill = self.iw * v
self.title_fill_color = {
r = util.lerp(green.r, red.r, v),
g = util.lerp(green.g, red.g, v),
b = util.lerp(green.b, red.b, v),
}
end
function _M:drawFrame(x, y, r, g, b, a)
Base.drawFrame(self, x, y, r, g, b, a)
if r == 0 then return end -- Drawing the shadow
if self.ui ~= "metal" then return end
if not self.title_fill then return end
core.display.drawQuad(x + self.frame.title_x, y + self.frame.title_y, self.title_fill, self.frame.title_h, self.title_fill_color.r, self.title_fill_color.g, self.title_fill_color.b, 60)
end
......@@ -46,3 +46,28 @@ function _M:select(item)
self.c_desc:switchItem(item, item.desc)
end
end
function _M:updateTitle(title)
Base.updateTitle(self, title)
local green = colors.LIGHT_GREEN
local red = colors.LIGHT_RED
local enc, max = self.actor:getEncumbrance(), self.actor:getMaxEncumbrance()
local v = math.min(enc, max) / max
self.title_fill = self.iw * v
self.title_fill_color = {
r = util.lerp(green.r, red.r, v),
g = util.lerp(green.g, red.g, v),
b = util.lerp(green.b, red.b, v),
}
end
function _M:drawFrame(x, y, r, g, b, a)
Base.drawFrame(self, x, y, r, g, b, a)
if r == 0 then return end -- Drawing the shadow
if self.ui ~= "metal" then return end
if not self.title_fill then return end
core.display.drawQuad(x + self.frame.title_x, y + self.frame.title_y, self.title_fill, self.frame.title_h, self.title_fill_color.r, self.title_fill_color.g, self.title_fill_color.b, 60)
end
......@@ -46,3 +46,28 @@ function _M:select(item)
self.c_desc:switchItem(item, item.desc)
end
end
function _M:updateTitle(title)
Base.updateTitle(self, title)
local green = colors.LIGHT_GREEN
local red = colors.LIGHT_RED
local enc, max = self.actor:getEncumbrance(), self.actor:getMaxEncumbrance()
local v = math.min(enc, max) / max
self.title_fill = self.iw * v
self.title_fill_color = {
r = util.lerp(green.r, red.r, v),
g = util.lerp(green.g, red.g, v),
b = util.lerp(green.b, red.b, v),
}
end
function _M:drawFrame(x, y, r, g, b, a)
Base.drawFrame(self, x, y, r, g, b, a)
if r == 0 then return end -- Drawing the shadow
if self.ui ~= "metal" then return end
if not self.title_fill then return end
core.display.drawQuad(x + self.frame.title_x, y + self.frame.title_y, self.title_fill, self.frame.title_h, self.title_fill_color.r, self.title_fill_color.g, self.title_fill_color.b, 60)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment