Skip to content
Snippets Groups Projects
Commit 70b9240e authored by dg's avatar dg
Browse files

New levelup screen, merges both stats and talents and adds way more nice stuff. Thanks graziel!

git-svn-id: http://svn.net-core.org/repos/t-engine4@3508 51575b47-30f0-44d4-a5cc-537603b46e54
parent 48d314c1
No related branches found
No related tags found
No related merge requests found
......@@ -62,9 +62,10 @@ end
--- Requests a simple, press any key, dialog
function _M:simpleLongPopup(title, text, w, fct, no_leave, force_height)
local list = text:splitLines(w - 10, self.font)
local _, th = self.font:size(title)
local d = new(title, 1, 1)
local h = math.min(force_height and (force_height * game.h) or 999999999, self.font_h * #list)
d:loadUI{{left = 3, top = 3, ui=require("engine.ui.Textzone").new{width=w+10, height=h, scrollbar=(h < self.font_h * #list) and true or false, text=text}}}
local h = math.min(force_height and (force_height * game.h) or 999999999, self.font_h * #list + th )
d:loadUI{{left = 3, top = 3, ui=require("engine.ui.Textzone").new{width=w+10, height=h + 10, scrollbar=(h < self.font_h * #list) and true or false, text=text}}}
if not no_leave then
d.key:addBind("EXIT", function() game:unregisterDialog(d) if fct then fct() end end)
local close = require("engine.ui.Button").new{text="Close", fct=function() d.key:triggerVirtual("EXIT") end}
......@@ -118,6 +119,30 @@ function _M:yesnoLongPopup(title, text, w, fct, yes_text, no_text, no_leave, esc
return d
end
--- Requests a simple yes-no dialog
function _M:yesnocancelLongPopup(title, text, fct, yes_text, no_text, cancel_text, no_leave, escape)
local w, h = self.font:size(text)
local d = new(title, 1, 1)
-- d.key:addBind("EXIT", function() game:unregisterDialog(d) fct(false) end)
local ok = require("engine.ui.Button").new{text=yes_text or "Yes", fct=function() game:unregisterDialog(d) fct(true, false) end}
local no = require("engine.ui.Button").new{text=no_text or "No", fct=function() game:unregisterDialog(d) fct(false, false) end}
local cancel = require("engine.ui.Button").new{text=cancel_text or "Cancel", fct=function() game:unregisterDialog(d) fct(false, true) end}
if not no_leave then d.key:addBind("EXIT", function() game:unregisterDialog(d) game:unregisterDialog(d) fct(false,not escape) end) end
d:loadUI{
{left = 3, top = 3, ui=require("engine.ui.Textzone").new{width=w+20, height=h + 5, text=text}},
{left = 3, bottom = 3, ui=ok},
{left = 3 + ok.w, bottom = 3, ui=no},
{right = 3, bottom = 3, ui=cancel},
}
d:setFocus(ok)
d:setupUI(true, true)
game:registerDialog(d)
return d
end
title_shadow = true
function _M:init(title, w, h, x, y, alpha, font, showup)
......@@ -275,10 +300,12 @@ function _M:setupUI(resizex, resizey, on_resize, addmw, addmh)
end
-- print("===", mw, addw)
mw = mw + addw + 5 * 2 + (addmw or 0)
mh = mh + addh + 5 + 22 + 3 + (addmh or 0)
-- print("===", mw, addw)
local tw, th = self.font_bold:size(self.title)
mw = math.max(tw + 6, mw)
mh = mh + addh + 5 + 22 + 3 + (addmh or 0) + th
if on_resize then on_resize(resizex and mw or self.w, resizey and mh or self.h) end
self:resize(resizex and mw or self.w, resizey and mh or self.h)
......@@ -341,6 +368,31 @@ function _M:setFocus(id)
ui.ui:setFocus(true)
end
function _M:moveUIElement(id, left, right, top, bottom)
if type(id) == "table" then
for i = 1, #self.uis do
if self.uis[i].ui == id then id = i break end
end
if type(id) == "table" then return end
end
self.uis[id].left = left or self.uis[id].left
self.uis[id].right = right or self.uis[id].right
self.uis[id].top = top or self.uis[id].top
self.uis[id].bottom = bottom or self.uis[id].bottom
end
function _M:getUIElement(id)
if type(id) == "table" then
for i = 1, #self.uis do
if self.uis[i].ui == id then id = i break end
end
if type(id) == "table" then return end
end
return self.uis[id]
end
function _M:moveFocus(v)
local id = self.focus_ui_id
local start = id or 1
......
......@@ -89,6 +89,11 @@ function _M:drawItem(item, nb_keyframes)
if type(text) ~= "table" then text = tstring.from(tostring(text)) end
end
local color = item.color or {255,255,255}
if item.color and type(item.color[1]) == "table" then
color = item.color[j]
end
local s = col.surface
s:erase(0, 0, 0, 0)
......@@ -231,11 +236,12 @@ function _M:setList(list)
for i, item in ipairs(self.list) do self:drawItem(item) end
end
function _M:onSelect()
function _M:onSelect(force_refresh)
local item = self.list[self.sel]
if not item then return end
if not item or not force_refresh and self.previtem and self.previtem==item then return end
if rawget(self, "select") then self.select(item, self.sel) end
-- self.previtem = item
end
function _M:onUse(...)
......
......@@ -31,8 +31,7 @@ require "mod.class.interface.PartyDeath"
local Map = require "engine.Map"
local Dialog = require "engine.ui.Dialog"
local ActorTalents = require "engine.interface.ActorTalents"
local LevelupStatsDialog = require "mod.dialogs.LevelupStatsDialog"
local LevelupTalentsDialog = require "mod.dialogs.LevelupTalentsDialog"
local LevelupDialog = require "mod.dialogs.LevelupDialog"
--- Defines the player for ToME
-- It is a normal actor, with some redefined methods to handle user interaction.<br/>
......@@ -865,13 +864,8 @@ function _M:quickSwitchWeapons()
end
function _M:playerLevelup(on_finish)
if self.unused_stats > 0 then
local ds = LevelupStatsDialog.new(self, on_finish)
game:registerDialog(ds)
else
local dt = LevelupTalentsDialog.new(self, on_finish)
game:registerDialog(dt)
end
local ds = LevelupDialog.new(self, on_finish)
game:registerDialog(ds)
end
--- Use a portal with the orb of many ways
......
......@@ -49,6 +49,11 @@ newBirthDescriptor{
"#LIGHT_BLUE# * +0 Strength, +1 Dexterity, +0 Constitution",
"#LIGHT_BLUE# * +0 Magic, +5 Willpower, +3 Cunning",
},
getStatDesc = function(stat, actor)
if stat == actor.STAT_CUN then
return "Max summons: "..math.floor(actor:getCun()/10)
end
end,
stats = { wil=5, cun=3, dex=1, },
talents_types = {
["wild-gift/call"]={true, 0.2},
......
This diff is collapsed.
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