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

moooaarr

Textzone now correctly cuts text based on font style


git-svn-id: http://svn.net-core.org/repos/t-engine4@2378 51575b47-30f0-44d4-a5cc-537603b46e54
parent 4068b5d3
No related branches found
No related tags found
No related merge requests found
Showing
with 24 additions and 32 deletions
......@@ -42,20 +42,18 @@ function _M:generate()
self.mouse:reset()
self.key:reset()
local list
if not self.auto_width then
list = self.text:splitLines(self.w, self.font)
else
list = {self.text}
self.w = self.font:size(self.text)
local text, max_w = self.text:toTString():splitLines(self.w, self.font)
local max_lines = text:countLines()
if self.auto_width then
self.w = max_w
end
self.scroll = 1
self.max = #list
self.max = max_lines
local fw, fh = self.w, self.font_h
self.fw, self.fh = fw, fh
if self.auto_height then self.h = self.fh * #list end
if self.auto_height then self.h = self.fh * max_lines end
self.max_display = math.floor(self.h / self.fh)
self.can_focus = false
......@@ -64,19 +62,7 @@ function _M:generate()
end
-- Draw the list items
local old_style = self.font:getStyle()
self.list = {}
local r, g, b = 255, 255, 255
local s = core.display.newSurface(fw, fh)
for i, l in ipairs(list) do
s:erase()
r, g, b = s:drawColorStringBlended(self.font, l, 0, 0, r, g, b, true)
if self.no_color_bleed then r, g, b = 255, 255, 255 end
local item = {}
item._tex, item._tex_w, item._tex_h = s:glTexture()
self.list[#self.list+1] = item
end
self.list = tstring.makeLineTextures(text, self.fw, self.font)
-- Draw the scrollbar
if self.scrollbar then
......@@ -91,8 +77,6 @@ function _M:generate()
self.scrollbar.bar.w, self.scrollbar.bar.h, self.scrollbar.bar.tex, self.scrollbar.bar.texw, self.scrollbar.bar.texh = ssb_w, self.h - fh, s:glTexture()
end
self.font:setStyle(old_style)
-- Add UI controls
self.mouse:registerZone(0, 0, self.w, self.h, function(button, x, y, xrel, yrel, bx, by, event)
if button == "wheelup" and event == "button" then self.key:triggerVirtual("MOVE_UP")
......
......@@ -30,7 +30,7 @@ function _M:init(t, no_default)
ActorAI.init(self, t)
-- Grab default image name if none is set
if not self.image then self.image = "npc/"..(self.type or "unknown").."_"..(self.subtype or "unknown").."_"..(self.name or "unknown"):lower():gsub("[^a-z0-9]", "_")..".png" end
if not self.image and self.name ~= "unknown actor" then self.image = "npc/"..(self.type or "unknown").."_"..(self.subtype or "unknown").."_"..(self.name or "unknown"):lower():gsub("[^a-z0-9]", "_")..".png" end
end
function _M:act()
......@@ -207,9 +207,10 @@ function _M:tooltip(x, y, seen_by)
str:add(
true,
("Killed by you: "):format(killed), true,
"Target: ", self.ai_target.actor and self.ai_target.actor.name or "none", true,
"UID: "..self.uid
"Target: ", self.ai_target.actor and self.ai_target.actor.name or "none"
)
if config.settings.cheat then str:add(true, "UID: "..self.uid, true, self.image) end
return str
end
......
......@@ -90,8 +90,8 @@ newBirthDescriptor{
selection_default = not profile.mod.allow_build.tutorial_done,
desc =
{
"#GOLD##{bold}#Tutorial mode#WHITE# start with a simplified character and discover the game in a simple quest.#{normal}#",
"You will be guided by a helpful spirit while learning.",
"#GOLD##{bold}#Tutorial mode",
"#WHITE#Starts with a simplified character and discover the game in a simple quest.#{normal}#",
"All damage done to the player reduced by 20%",
"All healing for the player increased by 10%",
"No main game achievements possible.",
......@@ -116,7 +116,9 @@ newBirthDescriptor{
display_name = "Discovery",
desc =
{
"#GOLD##{bold}#Discovery mode#WHITE# provides an easier game experience.\nUse it if you feel uneasy tackling the harder modes.#{normal}#",
"#GOLD##{bold}#Discovery mode#WHITE#",
"Provides an easier game experience.",
"Use it if you feel uneasy tackling the harder modes.#{normal}#",
"All damage done to the player decreased by 30%",
"All healing for the player increased by 30%",
"At level 1,2,3,5,7,10,14,18,24,30,40 get one more 'life' that allows to resurrect at the start of the level.",
......@@ -139,7 +141,9 @@ newBirthDescriptor{
selection_default = profile.mod.allow_build.tutorial_done,
desc =
{
"#GOLD##{bold}#Adventure mode#WHITE# provides the normal game experience but with limited extra lifes.\nUse it if you want a normal playing conditions but do not feel ready for just one life.#{normal}#",
"#GOLD##{bold}#Adventure mode#WHITE#",
"Provides the normal game experience but with limited extra lifes.",
"Use it if you want a normal playing conditions but do not feel ready for just one life.#{normal}#",
"At level 1,2,3,5,7,10,14,18,24,30,40 get one more 'life' that allows to resurrect at the start of the level.",
},
descriptor_choices =
......@@ -157,7 +161,9 @@ newBirthDescriptor{
name = "Roguelike",
desc =
{
"#GOLD##{bold}#Roguelike mode provides the closer experience to 'classic' roguelike games. You will only have one life, you *ARE* your character.#WHITE##{normal}#",
"#GOLD##{bold}#Roguelike mode#WHITE#",
"Provides the closer experience to 'classic' roguelike games.",
"You will only have one life, you *ARE* your character.#{normal}#",
"Only one life, unless ways to self-resurrect are found in-game.",
},
descriptor_choices =
......@@ -172,7 +178,8 @@ newBirthDescriptor{
name = "Insane",
desc =
{
"#GOLD##{bold}#Insane mode#WHITE# the basic roguelike mode rules with add unfairness!#{normal}#",
"#GOLD##{bold}#Insane mode#WHITE#",
"The basic roguelike mode rules with added unfairness!#{normal}#",
"Absolutely unfair game setting",
"Only one life, unless ways to self-resurrect are found in-game.",
"All zone levels increased by 100% + 10",
......
game/modules/tome/data/gfx/shockbolt/npc/army_ant.png

8.62 KiB

game/modules/tome/data/gfx/shockbolt/npc/carpenter_ant.png

7.47 KiB

game/modules/tome/data/gfx/shockbolt/npc/ice_ant.png

7.7 KiB | W: | H:

game/modules/tome/data/gfx/shockbolt/npc/ice_ant.png

7.91 KiB | W: | H:

game/modules/tome/data/gfx/shockbolt/npc/ice_ant.png
game/modules/tome/data/gfx/shockbolt/npc/ice_ant.png
game/modules/tome/data/gfx/shockbolt/npc/ice_ant.png
game/modules/tome/data/gfx/shockbolt/npc/ice_ant.png
  • 2-up
  • Swipe
  • Onion skin
game/modules/tome/data/gfx/shockbolt/npc/vermin_sandworm_gigantic_sandworm_tunneler.png

13.7 KiB

game/modules/tome/data/gfx/shockbolt/npc/vermin_sandworm_sandworm.png

8.41 KiB

game/modules/tome/data/gfx/shockbolt/npc/vermin_sandworm_sandworm_destroyer.png

14 KiB

game/modules/tome/data/gfx/shockbolt/object/lite_brass.png

7.35 KiB

game/modules/tome/data/gfx/shockbolt/object/scroll-lore.png

4.87 KiB

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