Skip to content
Snippets Groups Projects
Commit 91f80729 authored by dg's avatar dg
Browse files

Fixed cutoff texts in dialogs

git-svn-id: http://svn.net-core.org/repos/t-engine4@1456 51575b47-30f0-44d4-a5cc-537603b46e54
parent 1e7e383a
No related branches found
No related tags found
No related merge requests found
......@@ -200,7 +200,7 @@ function _M:display()
end
self.font:setStyle("bold")
local tw, th = self.font:size(self.title:removeColorCodes())
local tw, th = self.font:size(self.title)
s:drawColorStringBlended(self.font, self.title, (self.w - tw) / 2, 4, 255,255,255)
self.font:setStyle("normal")
......
......@@ -45,7 +45,7 @@ function _M:generate()
-- Draw UI
self.font:setStyle("bold")
local w, h = self.font:size(self.text:removeColorCodes())
local w, h = self.font:size(self.text)
if self.force_w then w = self.force_w end
local fw, fh = w + ls_w + rs_w, ls_h
local ss = core.display.newSurface(fw, fh)
......
......@@ -26,8 +26,8 @@ module(..., package.seeall, class.inherit(Base))
--- Requests a simple, press any key, dialog
function _M:simplePopup(title, text, fct, no_leave)
local w, h = self.font:size(text:removeColorCodes())
local tw, th = self.font_bold:size(title:removeColorCodes())
local w, h = self.font:size(text)
local tw, th = self.font_bold:size(title)
local d = new(title, math.max(w, tw) + 20, h + 75)
d:loadUI{{left = 3, top = 3, ui=require("engine.ui.Textzone").new{width=w+10, height=h+5, text=text}}}
if not no_leave then
......@@ -59,8 +59,8 @@ end
--- Requests a simple yes-no dialog
function _M:yesnoPopup(title, text, fct, yes_text, no_text)
local w, h = self.font:size(text:removeColorCodes())
local tw, th = self.font_bold:size(title:removeColorCodes())
local w, h = self.font:size(text)
local tw, th = self.font_bold:size(title)
local d = new(title, math.max(w, tw) + 35, h + 75)
-- d.key:addBind("EXIT", function() game:unregisterDialog(d) fct(false) end)
......@@ -160,7 +160,7 @@ function _M:generate()
end
self.font:setStyle("bold")
local tw, th = self.font:size(self.title:removeColorCodes())
local tw, th = self.font:size(self.title)
s:drawColorStringBlended(self.font, self.title, (self.w - tw) / 2, 4, 255,255,255)
self.font:setStyle("normal")
......
......@@ -57,7 +57,7 @@ function _M:generate()
self.h = r_h
-- Draw UI
local title_w = self.font:size(self.title:removeColorCodes())
local title_w = self.font:size(self.title)
self.w = title_w + self.chars * self.font_mono_w + ls_w + rs_w
local w, h = self.w, r_h
local fw, fh = w - title_w - ls_w - rs_w, self.font_h
......
......@@ -55,7 +55,7 @@ function _M:generate()
self.h = r_h
-- Draw UI
local title_w = self.font:size(self.title:removeColorCodes())
local title_w = self.font:size(self.title)
self.w = title_w + self.chars * self.font_mono_w + ls_w + rs_w
local w, h = self.w, r_h
local fw, fh = w - title_w - ls_w - rs_w, self.font_h
......
......@@ -47,7 +47,7 @@ function _M:generate()
list = self.text:splitLines(self.w, self.font)
else
list = {self.text}
self.w = self.font:size(self.text:removeColorCodes())
self.w = self.font:size(self.text)
end
self.scroll = 1
self.max = #list
......
......@@ -383,6 +383,33 @@ getmetatable(tmps).__index.drawColorStringBlendedCentered = function(s, font, st
s:drawColorStringBlended(font, str, x, y, r, g, b, alpha_from_texture, limit_w)
end
local tmps = core.display.newFont("/data/font/Vera.ttf", 12)
local fontoldsize = getmetatable(tmps).__index.size
getmetatable(tmps).__index.size = function(font, str)
local list = str:split("#" * (Puid + Pcolorcodefull + Pcolorname + Pfontstyle) * "#", true)
local mw, mh = 0, 0
for i, v in ipairs(list) do
local nr, ng, nb = lpeg.match("#" * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * lpeg.C(Pcolorcode) * "#", v)
local col = lpeg.match("#" * lpeg.C(Pcolorname) * "#", v)
local uid, mo = lpeg.match("#" * Puid_cap * "#", v)
local fontstyle = lpeg.match("#" * Pfontstyle_cap * "#", v)
if nr and ng and nb then
-- Ignore
elseif col then
-- Ignore
elseif uid and mo and game.level then
-- Ignore
elseif fontstyle then
font:setStyle(fontstyle)
else
local w, h = fontoldsize(font, v)
if h > mh then mh = h end
mw = mw + w
end
end
return mw, mh
end
dir_to_coord = {
[1] = {-1, 1},
[2] = { 0, 1},
......
......@@ -151,21 +151,6 @@ Now go and have some fun!]]
end
end
function _M:checkLogged()
if profile.auth then
self.logged_url = "http://te4.org/players/"..profile.auth.page
local str = "Online Profile: "..profile.auth.name.."[#LIGHT_BLUE##{underline}#"..self.logged_url.."#LAST##{normal}#]"
local plain = str:removeColorCodes()
local w, h = self.profile_font:size(plain)
self.s_log = core.display.newSurface(w, h)
self.s_log:erase(0, 0, 0)
self.s_log:drawColorStringBlended(self.profile_font, str, 0, 0, 255, 255, 0)
else
self.logged_url = nil
self.s_log = nil
end
end
function _M:newGame()
self.player = Player.new{name=self.player_name, game_ender=true}
Map:setViewerActor(self.player)
......@@ -452,7 +437,7 @@ function _M:createProfile(loginItem)
end
profile:newProfile(loginItem.login, loginItem.name, loginItem.pass, loginItem.email)
if (profile.auth) then
Dialog:simplePopup("Profile created!", "Your online profile is active now...", function() self:checkLogged() end )
Dialog:simplePopup("Profile created!", "Your online profile is active now...", function() end )
else
Dialog:simplePopup("Profile Failed to authenticate!", "Try logging in in a few moments", function() end )
end
......
......@@ -47,7 +47,7 @@ function _M:init()
}
self.c_background = Button.new{text=game.stopped and "Enable background" or "Disable background", width=150, fct=function() self:switchBackground() end}
self.c_version = Textzone.new{font=self.font_bold, auto_width=true, auto_height=true, text=("#B9E100#T-Engine4 version: %d.%d.%d"):format(engine.version[1], engine.version[2], engine.version[3])}
self.c_version = Textzone.new{auto_width=true, auto_height=true, text=("#{bold}##B9E100#T-Engine4 version: %d.%d.%d"):format(engine.version[1], engine.version[2], engine.version[3])}
if profile.auth then
self.logged_url = "http://te4.org/players/"..profile.auth.page
......
......@@ -37,7 +37,6 @@ function _M:init()
Dialog:yesnoPopup("You are logged in", "Do you want to log out?", function(ret)
if ret then
profile:logOut()
game:checkLogged()
end
end, "Log out", "Cancel")
end}
......
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