Commit da18b9452e0b6ec97c5811f538ed265bcd69e403

Authored by DarkGod
1 parent 76e3a596

Class icons for all classes!

Showing 72 changed files with 39 additions and 7 deletions
... ... @@ -123,6 +123,9 @@ function _M:drawItem(item, nb_keyframes)
123 123 item.cols[i] = {}
124 124
125 125 s:erase(0, 0, 0, 0)
  126 +
  127 + if self.on_drawitem then startx = self.on_drawitem(item, s, startx, self.fh) end
  128 +
126 129 local test_text = text:toString()
127 130 local font_w, _ = self.font:size(test_text)
128 131 font_w = font_w + startx
... ... @@ -156,7 +159,6 @@ function _M:drawItem(item, nb_keyframes)
156 159 item.cols[i]._tex, item.cols[i]._tex_w, item.cols[i]._tex_h = s:glTexture()
157 160 end
158 161 end
159   - if self.on_drawitem then self.on_drawitem(item) end
160 162 end
161 163
162 164 function _M:drawTree()
... ...
... ... @@ -886,8 +886,11 @@ end
886 886 function __get_uid_surface(uid, w, h)
887 887 uid = tonumber(uid)
888 888 local e = uid and __uids[uid]
889   - if e and game.level then
890   - return e:getEntityFinalSurface(game.level.map.tiles, w, h)
  889 + local tiles
  890 + if game.level then tiles = game.level.map.tiles
  891 + else tiles = require("engine.Map").tiles end
  892 + if e and tiles then
  893 + return e:getEntityFinalSurface(tiles, w, h)
891 894 end
892 895 return nil
893 896 end
... ... @@ -895,7 +898,7 @@ end
895 898 function __get_uid_entity(uid)
896 899 uid = tonumber(uid)
897 900 local e = uid and __uids[uid]
898   - if e and game.level then
  901 + if e then
899 902 return e
900 903 end
901 904 return nil
... ... @@ -963,7 +966,10 @@ getmetatable(tmps).__index.size = function(font, str)
963 966 local uid = v[2]
964 967 local e = __uids[uid]
965 968 if e then
966   - local surf = e:getEntityFinalSurface(game.level.map.tiles, font:lineSkip(), font:lineSkip())
  969 + local tiles
  970 + if game.level then tiles = game.level.map.tiles
  971 + else tiles = require("engine.Map").tiles end
  972 + local surf = e:getEntityFinalSurface(tiles, font:lineSkip(), font:lineSkip())
967 973 if surf then
968 974 local w, h = surf:getSize()
969 975 mw = mw + w
... ...
... ... @@ -39,9 +39,22 @@ local Particles = require "engine.Particles"
39 39 local CharacterVaultSave = require "engine.CharacterVaultSave"
40 40 local Object = require "mod.class.Object"
41 41 local OptionTree = require "mod.dialogs.OptionTree"
  42 +local Entity = require "engine.Entity"
42 43
43 44 module(..., package.seeall, class.inherit(Birther))
44 45
  46 +function _M:setSubclassIcon(t)
  47 + t.image32 = "class-icons/"..(t.name:lower():gsub("[^a-z0-9]", "_")).."_32_bg.png"
  48 + t.image128 = "class-icons/"..(t.name:lower():gsub("[^a-z0-9]", "_")).."_128_bg.png"
  49 + if not fs.exists(Tiles.baseImageFile(t.image32)) then
  50 + t.image32 = "class-icons/unknown_32_bg.png"
  51 + t.image128 = "class-icons/unknown_128_bg.png"
  52 + end
  53 + t.display_entity32 = Entity.new{image=t.image32}
  54 + t.display_entity128 = Entity.new{image=t.image128}
  55 +end
  56 +for _, t in pairs(_M.birth_descriptor_def.subclass) do _M:setSubclassIcon(t) end
  57 +
45 58 --- Instanciates a birther for the given actor
46 59 function _M:init(title, actor, order, at_end, quickbirth, w, h)
47 60 self.quickbirth = quickbirth
... ... @@ -112,7 +125,6 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h)
112 125 fct=function(item, sel, v) self:raceUse(item, sel, v) end,
113 126 select=function(item, sel) self:updateDesc(item) end,
114 127 on_expand=function(item) end,
115   - on_drawitem=function(item) end,
116 128 }
117 129
118 130 self:generateClasses()
... ... @@ -122,7 +134,12 @@ function _M:init(title, actor, order, at_end, quickbirth, w, h)
122 134 fct=function(item, sel, v) self:classUse(item, sel, v) end,
123 135 select=function(item, sel) self:updateDesc(item) end,
124 136 on_expand=function(item) end,
125   - on_drawitem=function(item) end,
  137 + on_drawitem=function(item, s, startx, h)
  138 + if not item.def or not item.def.display_entity32 then return startx end
  139 + local sc = item.def.display_entity32:getEntityFinalSurface(self.tiles, h, h)
  140 + s:merge(sc, startx, 0)
  141 + return startx + h
  142 + end,
126 143 }
127 144
128 145 self.cur_order = 1
... ... @@ -1012,6 +1029,13 @@ function _M:innerDisplay(x, y, nb_keyframes)
1012 1029 elseif self.actor.image and self.actor.add_mos then
1013 1030 self.actor:toScreen(self.tiles, x + self.iw - 64, y - 64, 128, 64)
1014 1031 end
  1032 +
  1033 + if self.descriptors_by_type.subclass then
  1034 + local sc = self.birth_descriptor_def.subclass[self.descriptors_by_type.subclass]
  1035 + if sc.display_entity128 then
  1036 + sc.display_entity128:toScreen(self.tiles, x + self.iw - self.c_desc.w, y + 16, 64, 64)
  1037 + end
  1038 + end
1015 1039 end
1016 1040
1017 1041 --- Fake a body & starting equipment
... ...