Skip to content

Commit

Permalink
more customizable item previews
Browse files Browse the repository at this point in the history
  • Loading branch information
parameterized committed Mar 2, 2019
1 parent b49e52e commit 780c083
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 17 deletions.
Binary file modified gfx/fonts/stat_font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/icons/atk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/icons/def.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/icons/reg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/icons/spd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/icons/vit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/icons/wis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/item_info/base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/item_info/special_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gfx/ui/item_info/tier_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 19 additions & 2 deletions hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,22 @@ function hud.draw()
love.graphics.setShader(_shader)
love.graphics.push()
love.graphics.translate(x, y)
love.graphics.draw(gfx.ui.itemInfo, 0, 0)
font = fonts.stats
love.graphics.draw(gfx.ui.itemInfo.base, 0, 0)
love.graphics.setColor(200/255, 88/255, 9/255)
love.graphics.draw(gfx.ui.itemInfo.tierColor, 5, 6)
love.graphics.setColor(1, 1, 1)
love.graphics.draw(gfx.items[item.imageId], 7, 8)
love.graphics.draw(gfx.ui.icons.atk, 14, 29)
love.graphics.draw(gfx.ui.icons.wis, 57, 29)
love.graphics.draw(gfx.ui.icons.spd, 14, 51)
love.graphics.draw(gfx.ui.icons.reg, 57, 51)
local font = fonts.stats
love.graphics.setFont(font)
love.graphics.setColor(193/255, 193/255, 193/255)
text.print('"TOOLTIP WOULD GO\nHERE"', 26, 9)
love.graphics.setColor(1, 1, 1)
love.graphics.draw(gfx.ui.itemInfo.specialIcon, 9, 74)
text.print('25% CHANCE TO BURN', 16, 74)
local playerWeapon = items.client.getItem(p.inventory.items[2])
if isSword[item.imageId] and item.atk then
if playerWeapon and playerWeapon.atk then
Expand All @@ -354,6 +367,10 @@ function hud.draw()
else
text.print('100', 35, 34)
end
love.graphics.setColor(1, 1, 1)
text.print('100', 78, 34)
text.print('100', 35, 56)
text.print('100', 78, 56)
love.graphics.pop()
end

Expand Down
24 changes: 11 additions & 13 deletions items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ items = {
}
}

local imageId2Type = {
armor0Helmet = 'helmet', armor1Helmet = 'helmet',
armor0Chest = 'chest', armor1Chest = 'chest',
armor0Pants = 'pants', armor1Pants = 'pants'
}
for _, v in ipairs{'sword0', 'sword1', 'sword2', 'sword3', 'sword4'} do
imageId2Type[v] = 'sword'
end

function items.server.newItem(data)
if not data.id then
data.id = lume.uuid()
Expand All @@ -17,19 +26,8 @@ function items.server.newItem(data)
data.imageId = 'apple'
end
if not data.type then
data.type = data.imageId
if isSword[data.imageId] then
data.type = 'sword'
end
if data.imageId == 'armor0Helmet' or data.imageId == 'armor1Helmet' then
data.type = 'helmet'
end
if data.imageId == 'armor0Chest' or data.imageId == 'armor1Chest' then
data.type = 'chest'
end
if data.imageId == 'armor0Pants' or data.imageId == 'armor1Pants' then
data.type = 'pants'
end
data.type = imageId2Type[data.imageId]
data.type = data.type or data.imageId
end
items.server.container[data.id] = data
return data.id
Expand Down
16 changes: 14 additions & 2 deletions loadassets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@ gfx = {
logo = love.graphics.newImage('gfx/logo.png'),
logoAnim = love.graphics.newImage('gfx/logo_anim.png'),
ui = {
icons = {
vit = love.graphics.newImage('gfx/ui/icons/vit.png'),
atk = love.graphics.newImage('gfx/ui/icons/atk.png'),
spd = love.graphics.newImage('gfx/ui/icons/spd.png'),
wis = love.graphics.newImage('gfx/ui/icons/wis.png'),
def = love.graphics.newImage('gfx/ui/icons/def.png'),
reg = love.graphics.newImage('gfx/ui/icons/reg.png')
},
buttons = {
up = love.graphics.newImage('gfx/ui/buttons/up.png'),
down = love.graphics.newImage('gfx/ui/buttons/down.png'),
left = love.graphics.newImage('gfx/ui/buttons/left.png'),
right = love.graphics.newImage('gfx/ui/buttons/right.png')
},
bag = love.graphics.newImage('gfx/ui/bagui.png'),
itemInfo = love.graphics.newImage('gfx/ui/item_info.png'),
itemInfo = {
base = love.graphics.newImage('gfx/ui/item_info/base.png'),
tierColor = love.graphics.newImage('gfx/ui/item_info/tier_color.png'),
specialIcon = love.graphics.newImage('gfx/ui/item_info/special_icon.png')
},
quest = love.graphics.newImage('gfx/ui/questui.png')
},
hud = {
Expand Down Expand Up @@ -296,7 +308,7 @@ fonts = {

c13 = love.graphics.newImageFont('gfx/fonts/small_font.png', ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`\'*#=[]"|~@$^_{}<>'),
c17 = love.graphics.newImageFont('gfx/fonts/big_font.png', ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`\'*#=[]"|~@$^_{}<>'),
stats = love.graphics.newImageFont('gfx/fonts/stat_font.png', ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/')
stats = love.graphics.newImageFont('gfx/fonts/stat_font.png', ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/\'"%')
}
-- todo: test
-- love.graphics.newFont([filename, ] size, "mono")
Expand Down

0 comments on commit 780c083

Please sign in to comment.