Skip to content
Snippets Groups Projects
Commit 2e808f8f authored by dg's avatar dg
Browse files

Points buttons have description in the levelup screen

git-svn-id: http://svn.net-core.org/repos/t-engine4@5517 51575b47-30f0-44d4-a5cc-537603b46e54
parent 05ecd4cb
No related branches found
No related tags found
No related merge requests found
......@@ -32,9 +32,11 @@ frame_oy2 = 5
function _M:init(t)
self.text = assert(t.text, "no button text")
self.fct = assert(t.fct, "no button fct")
self.on_select = t.on_select
self.force_w = t.width
if t.can_focus ~= nil then self.can_focus = t.can_focus end
if t.can_focus_mouse ~= nil then self.can_focus_mouse = t.can_focus_mouse end
Base.init(self, t)
end
......@@ -54,7 +56,10 @@ function _M:generate()
self.font:setStyle("normal")
-- Add UI controls
self.mouse:registerZone(0, 0, self.w+6, self.h+6, function(button, x, y, xrel, yrel, bx, by, event) if button == "left" and event == "button" then self:sound("button") self.fct() end end)
self.mouse:registerZone(0, 0, self.w+6, self.h+6, function(button, x, y, xrel, yrel, bx, by, event)
if self.on_select then self.on_select() end
if button == "left" and event == "button" then self:sound("button") self.fct() end
end)
self.key:addBind("ACCEPT", function() self:sound("button") self.fct() end)
self.rw, self.rh = w, h
......@@ -67,6 +72,8 @@ function _M:generate()
end
function _M:display(x, y, nb_keyframes, ox, oy)
self.last_display_x = ox
self.last_display_y = oy
x = x + 3
y = y + 3
ox = ox + 3
......
......@@ -439,7 +439,7 @@ function _M:setupUI(resizex, resizey, on_resize, addmw, addmh)
self.setuped = true
end
function _M:setFocus(id)
function _M:setFocus(id, how)
if type(id) == "table" then
for i = 1, #self.uis do
if self.uis[i].ui == id then id = i break end
......@@ -449,7 +449,7 @@ function _M:setFocus(id)
local ui = self.uis[id]
if self.focus_ui == ui then return end
if self.focus_ui and self.focus_ui.ui.can_focus then self.focus_ui.ui:setFocus(false) end
if self.focus_ui and (self.focus_ui.ui.can_focus or (self.focus_ui.ui.can_focus_mouse and how=="mouse")) then self.focus_ui.ui:setFocus(false) end
if not ui.ui.can_focus then self:no_focus() return end
self.focus_ui = ui
self.focus_ui_id = id
......@@ -511,8 +511,8 @@ function _M:mouseEvent(button, x, y, xrel, yrel, bx, by, event)
-- Look for focus
for i = 1, #self.uis do
local ui = self.uis[i]
if ui.ui.can_focus and bx >= ui.x and bx <= ui.x + ui.ui.w and by >= ui.y and by <= ui.y + ui.ui.h then
self:setFocus(i)
if (ui.ui.can_focus or ui.ui.can_focus_mouse) and bx >= ui.x and bx <= ui.x + ui.ui.w and by >= ui.y and by <= ui.y + ui.ui.h then
self:setFocus(i, "mouse")
-- Pass the event
ui.ui.mouse:delegate(button, bx, by, xrel, yrel, bx, by, event)
......
......@@ -35,11 +35,11 @@ function _M:init(t)
self.scrollbar = t.scrollbar
self.focus_check = t.focus_check
self.variable_height = t.variable_height
self.dest_area = t.dest_area and t.dest_area or { h = self.h }
self.max_h = 0
self.scroll_inertia = 0
if t.can_focus ~= nil then self.can_focus = t.can_focus end
Base.init(self, t)
......@@ -82,13 +82,13 @@ function _M:generate()
self.scroll_drag = false
end
end
self.mouse:registerZone(0, 0, self.w, self.h, on_mousewheel)
self.key:addBinds{
MOVE_UP = function() if self.scrollbar then self.scroll_inertia = math.min(self.scroll_inertia, 0) - 10 end end,
MOVE_DOWN = function() if self.scrollbar then self.scroll_inertia = math.max(self.scroll_inertia, 0) + 10 end end
}
self.key:addCommands{
_HOME = function() if self.scrollbar then self.scrollbar.pos = 0 end end,
_END = function() if self.scrollbar then self.scrollbar.pos = self.scrollbar.max end end,
......@@ -120,9 +120,9 @@ function _M:createItem(item, text)
end
end
end
if gen[i].is_separator then
if gen[i].is_separator then
self.max_h = self.max_h + (self.fh - self.sep.h)
else
else
self.max_h = self.max_h + gen[i].h
end
end
......@@ -140,7 +140,7 @@ function _M:switchItem(item, create_if_needed, force)
if (create_if_needed and not self.items[item]) or force then self:createItem(item, create_if_needed) end
if not item or not self.items[item] then self.list = nil return false end
local d = self.items[item]
self.max_h = d.max_h
if self.scrollbar then
self.scrollbar.max = self.max_h - self.h
......@@ -173,7 +173,7 @@ function _M:display(x, y, nb_keyframes, ox, oy, offset_x, offset_y, local_x, loc
offset_y = offset_y and offset_y or (self.scrollbar and self.scrollbar.pos or 0)
local_x = local_x and local_x or 0
local_y = local_y and local_y or 0
if self.scrollbar then
self.scrollbar.pos = util.minBound(self.scrollbar.pos + self.scroll_inertia, 0, self.scrollbar.max)
if self.scroll_inertia > 0 then self.scroll_inertia = math.max(self.scroll_inertia - 1, 0)
......@@ -181,7 +181,7 @@ function _M:display(x, y, nb_keyframes, ox, oy, offset_x, offset_y, local_x, loc
end
if self.scrollbar.pos == 0 or self.scrollbar.pos == self.scrollbar.max then self.scroll_inertia = 0 end
end
local loffset_y = offset_y - local_y
local current_y = 0
local current_x = 0
......@@ -192,16 +192,16 @@ function _M:display(x, y, nb_keyframes, ox, oy, offset_x, offset_y, local_x, loc
local item = self.list[i]
clip_y_start = 0
clip_y_end = 0
local item_h = item.is_separator and (self.fh - self.sep.h) or item.h
-- if item is within visible area bounds
if total_h + item_h > loffset_y and total_h < loffset_y + self.dest_area.h then
-- if it started before visible area then compute its top clip
if total_h < loffset_y then
clip_y_start = loffset_y - total_h
if total_h < loffset_y then
clip_y_start = loffset_y - total_h
end
-- if it ended after visible area then compute its bottom clip
if total_h + item_h > loffset_y + self.dest_area.h then
if total_h + item_h > loffset_y + self.dest_area.h then
clip_y_end = total_h + item_h - (loffset_y + self.dest_area.h)
end
if item.background then
......
......@@ -171,7 +171,7 @@ newTalent{
local range = self:getTalentRadius(t)
local en = t.getLeech(self, t)
local dam = damDesc(self, DamageType.LIGHTNING, t.getDam(self, t))
return ([[You pull electric potential from all targets around you in a radius of %d, gaining %d energy for each one affected and giving them a nasty shock in the process. Deals between %d and %d damage nad has a chance to daze.]]):format(range, en, dam / 3, dam)
return ([[You pull electric potential from all targets around you in a radius of %d, gaining %d energy for each one affected and giving them a nasty shock in the process. Deals between %d and %d damage and has a chance to daze.]]):format(range, en, dam / 3, dam)
end,
}
newTalent{
......
......@@ -554,6 +554,33 @@ Category points left: #00FF00#%d#LAST#
Class talent points left: #00FF00#%d#LAST#
Generic talent points left: #00FF00#%d#LAST#]]
local desc_stats = ([[Stat points allow you to increase your core stats.
Each level you gain 3 new stat points to use.
You may only increase stats to a natural maximum of 60 or lower (relative to your level).]]):toTString()
local desc_class = ([[Class talent points alow you to learn new class talents or improve them.
Class talents are core to your class and can not be learnt by training.
Each level you gain 1 new class points to use.
Each five levels you gain one more.
]]):toTString()
local desc_generic = ([[Generic talent points alow you to learn new generic talents or improve them.
Generic talents comes from your class, your race or various outside training you can get during your adventures.
Each level you gain 1 new class points to use.
Each five levels you gain one less.
]]):toTString()
local desc_types = ([[Talent category points allow you to either:
- learn a new talent (class or generic) category
- improve a known talent category efficiency by 0.2
- learn a new inscription slot (up to a maximum of 5, learning it is automatic when using an inscription)
You gain a new point at level 10, 20 and 30.
Some races or items may increase them as well.]]):toTString()
function _M:createDisplay()
self.c_ctree = TalentTrees.new{
font = core.display.newFont("/data/font/DroidSans.ttf", 14),
......@@ -619,10 +646,42 @@ function _M:createDisplay()
local vsep2 = Separator.new{dir="horizontal", size=self.ih - 20}
local hsep = Separator.new{dir="vertical", size=180}
self.b_stat = Button.new{can_focus = false, text="Stats: "..self.actor.unused_stats, fct=function() end}
self.b_class = Button.new{can_focus = false, text="Class points: "..self.actor.unused_talents, fct=function() end}
self.b_generic = Button.new{can_focus = false, text="Generic points: "..self.actor.unused_generics, fct=function() end}
self.b_types = Button.new{can_focus = false, text="Category points: "..self.actor.unused_talents_types, fct=function() end}
self.b_stat = Button.new{can_focus = false, can_focus_mouse=true, text="Stats: "..self.actor.unused_stats, fct=function() end, on_select=function()
local str = desc_stats
if self.no_tooltip then
self.c_desc:erase()
self.c_desc:switchItem(str, str, true)
else
game:tooltipDisplayAtMap(self.b_stat.last_display_x + self.b_stat.w, self.b_stat.last_display_y, str)
end
end}
self.b_class = Button.new{can_focus = false, can_focus_mouse=true, text="Class points: "..self.actor.unused_talents, fct=function() end, on_select=function()
local str = desc_class
if self.no_tooltip then
self.c_desc:erase()
self.c_desc:switchItem(str, str, true)
else
game:tooltipDisplayAtMap(self.b_stat.last_display_x + self.b_stat.w, self.b_stat.last_display_y, str)
end
end}
self.b_generic = Button.new{can_focus = false, can_focus_mouse=true, text="Generic points: "..self.actor.unused_generics, fct=function() end, on_select=function()
local str = desc_generic
if self.no_tooltip then
self.c_desc:erase()
self.c_desc:switchItem(str, str, true)
else
game:tooltipDisplayAtMap(self.b_stat.last_display_x + self.b_stat.w, self.b_stat.last_display_y, str)
end
end}
self.b_types = Button.new{can_focus = false, can_focus_mouse=true, text="Category points: "..self.actor.unused_talents_types, fct=function() end, on_select=function()
local str = desc_types
if self.no_tooltip then
self.c_desc:erase()
self.c_desc:switchItem(str, str, true)
else
game:tooltipDisplayAtMap(self.b_stat.last_display_x + self.b_stat.w, self.b_stat.last_display_y, str)
end
end}
local ret = {
{left=-10, top=0, ui=self.b_stat},
......
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