Commit 6668ba842737e8780d01e25d629ec36d5057de7f

Authored by DarkGod
1 parent 9cee03f6

Prodigies screen splits out evolutions from prodigies to better see them

... ... @@ -27,6 +27,8 @@ module(..., package.seeall, class.inherit(Base))
27 27 function _M:init(t)
28 28 self.dir = assert(t.dir, "no separator dir")
29 29 self.size = assert(t.size, "no separator size")
  30 + self.text = t.text
  31 + self.text_shadow = t.text_shadow or self.text_shadow
30 32
31 33 self.dest_area = {w = 1, h = 1}
32 34 Base.init(self, t)
... ... @@ -44,6 +46,10 @@ function _M:generate()
44 46 self.middle = self:getUITexture("ui/border_hor_middle.png")
45 47 self.right = self:getUITexture("ui/border_hor_right.png")
46 48 self.w, self.h = self.size, self.middle.h
  49 +
  50 + if self.text then
  51 + self.text_tex = self:drawFontLine(self.font, self.text)
  52 + end
47 53 end
48 54 self.dest_area.w = self.w
49 55 self.dest_area.h = self.h
... ... @@ -58,5 +64,10 @@ function _M:display(x, y, nb_keyframes)
58 64 self.left.t:toScreenFull(x, y, self.left.w, self.left.h, self.left.tw, self.left.th)
59 65 self.right.t:toScreenFull(x + self.w - self.right.w, y, self.right.w, self.right.h, self.right.tw, self.right.th)
60 66 self.middle.t:toScreenFull(x + self.left.w, y, self.w - self.left.w - self.right.w, self.middle.h, self.middle.tw, self.middle.th)
  67 +
  68 + if self.text_tex then
  69 + if self.text_shadow then self:textureToScreen(self.text_tex, x + (self.w - self.text_tex.w) / 2 + 1, y + (self.h - self.text_tex.h) / 2 + 1, 0, 0, 0, self.text_shadow) end
  70 + self:textureToScreen(self.text_tex, x + (self.w - self.text_tex.w) / 2, y + (self.h - self.text_tex.h) / 2)
  71 + end
61 72 end
62 73 end
... ...
... ... @@ -90,8 +90,8 @@ end
90 90 function _M:generateList()
91 91 -- Makes up the list
92 92 local max = 0
93   - local cols = {}
94   - local list = {}
  93 + local cols, evocols = {}, {}
  94 + local list, evolist = {}, {}
95 95 for tid, t in pairs(self.actor.talents_def) do
96 96 if t.uber and not t.not_listed then
97 97 if
... ... @@ -107,25 +107,22 @@ function _M:generateList()
107 107 ) and
108 108 (not t.requires_unlock or profile.mod.allow_build[t.requires_unlock] or self:ignoreUnlocks())
109 109 then
110   - cols[t.type[1]] = cols[t.type[1]] or {}
111   - local c = cols[t.type[1]]
112   - c[#c+1] = t
  110 + if not t.is_race_evolution and not t.is_class_evolution then
  111 + cols[t.type[1]] = cols[t.type[1]] or {}
  112 + local c = cols[t.type[1]]
  113 + c[#c+1] = t
  114 + else
  115 + evocols[#evocols+1] = t
  116 + end
113 117 end
114 118 end
115 119 end
116   - max = math.max(#cols["uber/strength"], #cols["uber/dexterity"], #cols["uber/constitution"], #cols["uber/magic"], #cols["uber/willpower"], #cols["uber/cunning"])
117 120
  121 + -- Handle prodigies
  122 + max = math.max(#cols["uber/strength"], #cols["uber/dexterity"], #cols["uber/constitution"], #cols["uber/magic"], #cols["uber/willpower"], #cols["uber/cunning"])
118 123 for _, s in ipairs{"uber/strength", "uber/dexterity", "uber/constitution", "uber/magic", "uber/willpower", "uber/cunning"} do
119 124 local n = {}
120   - table.sort(cols[s], function(a,b)
121   - if a.is_class_evolution ~= b.is_class_evolution then
122   - return b.is_class_evolution and true or false
123   - elseif a.is_race_evolution ~= b.is_race_evolution then
124   - return b.is_race_evolution and true or false
125   - else
126   - return a.name < b.name
127   - end
128   - end)
  125 + table.sort(cols[s], function(a,b) return a.name < b.name end)
129 126
130 127 for i = 1, max do
131 128 if not cols[s][i] then
... ... @@ -155,27 +152,82 @@ function _M:generateList()
155 152 list[#list+1] = n
156 153 end
157 154 list.max = max
  155 +
  156 + -- Hande evos
  157 + table.sort(evocols, function(a,b) return a.name < b.name end)
  158 + evolist = {{}, {}, {}, {}, {}, {}}
  159 + evolist.max = 1
  160 + self.has_evos = false
  161 + for i, t in ipairs(evocols) do
  162 + if t.display_entity then t.display_entity:getMapObjects(game.uiset.hotkeys_display_icons.tiles, {}, 1) end
  163 +
  164 + self.has_evos = true
  165 + local n = evolist[(i-1) % 6 + 1]
  166 + n[#n+1] = {
  167 + rawname = t.name,
  168 + talent = t.id,
  169 + entity=t.display_entity,
  170 + do_shadow = function(item) if not self.actor:canLearnTalent(t) then return true else return false end end,
  171 + color=function(item)
  172 + if self.actor:knowTalent(t) or self.levelup_end_prodigies[t.id] then return {0,255,0}
  173 + elseif not self.actor:canLearnTalent(t) then return {75,75,75}
  174 + else return {175,175,175}
  175 + end
  176 + end,
  177 + status = function(item)
  178 + return tstring{}
  179 + end,
  180 + }
  181 + evolist.max = math.max(evolist.max, #n)
  182 + end
  183 +
158 184 self.list = list
  185 + self.evolist = evolist
159 186 end
160 187
161 188 -----------------------------------------------------------------
162 189 -- UI Stuff
163 190 -----------------------------------------------------------------
164 191
165   -_M.tuttext = _t[[Prodigies are special talents that only the most powerful of characters can attain.
166   -All of them require at least 50 in a core stat and many also have more special demands. You can learn a new prodigy at level 25 and 42.
167   -#LIGHT_GREEN#Prodigies available: %d]]
  192 +_M.tuttext = _t[[#LIGHT_GREEN#Number available: %d#LAST#
  193 +Prodigies are special talents that only the most powerful of characters can attain.%s
  194 +All of them require at least 50 in a core stat and many also have more special demands. You can learn a new prodigy at level 25 and 42.]]
  195 +_M.evotext = _t"\nEvolutions are special prodigies specific to a class or race. Only one evolution can be choosen, if any are available at all."
168 196
169 197 function _M:createDisplay()
170   - self.c_tut = Textzone.new{ width=self.iw, auto_height = true, text=self.tuttext:format(self.actor.unused_prodigies or 0)}
  198 + self.c_tut = Textzone.new{ width=self.iw, auto_height = true, text=self.tuttext:format(self.actor.unused_prodigies or 0, self.has_evos and self.evotext or "")}
171 199
172 200 local vsep = Separator.new{dir="horizontal", size=self.ih - 20 - self.c_tut.h}
  201 + local listsep = Separator.new{dir="vertical", size=370, text="#{bold}##GOLD#Prodigies#{normal}#", text_shadow=1}
  202 + local evosep
  203 +
173 204 self.c_desc = TextzoneList.new{ focus_check = true, scrollbar = true, pingpong = 20, width=self.iw - 370 - vsep.w - 20, height = self.ih - self.c_tut.h, dest_area = { h = self.ih - self.c_tut.h } }
  205 +
  206 + if self.has_evos then
  207 + evosep = Separator.new{dir="vertical", size=370, text="#{bold}##LIGHT_STEEL_BLUE#Evolutions#{normal}#", text_shadow=1}
  208 + self.c_evo = TalentGrid.new{
  209 + font = core.display.newFont("/data/font/DroidSans.ttf", 14),
  210 + tiles=game.uiset.hotkeys_display_icons,
  211 + grid=self.evolist,
  212 + width=370, height="auto",
  213 + tooltip=function(item)
  214 + local x = self.display_x + self.uis[2].x + self.uis[2].ui.w
  215 + if self.display_x + self.w + game.tooltip.max <= game.w then x = self.display_x + self.w end
  216 + local ret = self:getTalentDesc(item), x, nil
  217 + self.c_desc:erase()
  218 + self.c_desc:switchItem(ret, ret)
  219 + return ret
  220 + end,
  221 + on_use = function(item, inc) self:use(item) end,
  222 + no_tooltip = true,
  223 + }
  224 + end
174 225 self.c_list = TalentGrid.new{
175 226 font = core.display.newFont("/data/font/DroidSans.ttf", 14),
176 227 tiles=game.uiset.hotkeys_display_icons,
177 228 grid=self.list,
178   - width=370, height=self.ih - self.c_tut.h,
  229 + width=370, height=self.ih - self.c_tut.h - (self.has_evos and (self.c_evo.h + evosep.h) or 0),
  230 + auto_shrink = true,
179 231 scrollbar = true,
180 232 tooltip=function(item)
181 233 local x = self.display_x + self.uis[2].x + self.uis[2].ui.w
... ... @@ -191,11 +243,15 @@ function _M:createDisplay()
191 243
192 244 local ret = {
193 245 {left=0, top=0, ui=self.c_tut},
194   - {left=0, top=self.c_tut.h, ui=self.c_list},
  246 + {left=0, top=self.c_tut.h, ui=listsep},
  247 + {left=0, top=self.c_tut.h+listsep.h, ui=self.c_list},
195 248 {left=self.c_list, top=self.c_tut.h, ui=vsep},
196 249 {right=0, top=self.c_tut.h, ui=self.c_desc},
197 250 }
198   -
  251 + if self.has_evos then
  252 + table.insert(ret, 3, {left=0, top=self.c_tut.h+listsep.h+self.c_list.h, ui=evosep})
  253 + table.insert(ret, 4, {left=0, top=self.c_tut.h+listsep.h+self.c_list.h+evosep.h, ui=self.c_evo})
  254 + end
199 255
200 256 return ret
201 257 end
... ...
... ... @@ -30,6 +30,7 @@ function _M:init(t)
30 30 self.grid = t.grid or {}
31 31 self.w = assert(t.width, "no width")
32 32 self.h = assert(t.height, "no height")
  33 + self.auto_shrink = t.auto_shrink
33 34 self.tooltip = assert(t.tooltip, "no tooltip")
34 35 self.on_use = assert(t.on_use, "no on_use")
35 36 self.on_expand = t.on_expand
... ... @@ -53,14 +54,18 @@ function _M:generate()
53 54 self.mouse:reset()
54 55 self.key:reset()
55 56
56   - -- generate the scrollbar
57   - if self.scrollbar then self.scrollbar = Slider.new{size=self.h, max=1} end
58   -
59 57 self.sel_i = 1
60 58 self.sel_j = 1
61 59 self.max_h = self.grid.max * (self.frame_size + self.frame_offset)
  60 + if self.h == "auto" then self.h = self.max_h end
  61 +
  62 + -- generate the scrollbar
  63 + if self.scrollbar then
  64 + self.scrollbar = Slider.new{size=self.h, max=1}
  65 + self.scrollbar.max = self.max_h - self.h
  66 + end
62 67
63   - if self.scrollbar then self.scrollbar.max = self.max_h - self.h end
  68 + if self.auto_shrink and self.h > self.max_h then self.h = self.max_h end
64 69
65 70 self.mousezones = {}
66 71 self:redrawAllItems()
... ... @@ -210,7 +215,7 @@ function _M:display(x, y, nb_keyframes, screen_x, screen_y, offset_x, offset_y,
210 215
211 216 local mz = {}
212 217 self.mousezones = mz
213   - local dx, dy = 3, -self.scrollbar.pos + 3
  218 + local dx, dy = 3, (self.scrollbar and -self.scrollbar.pos or 0) + 3
214 219
215 220 core.display.glScissor(true, screen_x, screen_y, self.w, self.h)
216 221
... ... @@ -243,7 +248,7 @@ function _M:display(x, y, nb_keyframes, screen_x, screen_y, offset_x, offset_y,
243 248
244 249 addw = addw + self.frame_size
245 250
246   - dy = -self.scrollbar.pos + 3
  251 + dy = (self.scrollbar and -self.scrollbar.pos or 0) + 3
247 252 dx = dx + addw + 12
248 253 end
249 254 core.display.glScissor(false)
... ...