Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
K'van
Tales of MajEyal
Commits
dc1d03e1
Commit
dc1d03e1
authored
10 years ago
by
Alex Ksandra
Browse files
Options
Downloads
Patches
Plain Diff
Font.size now uses tstrings too
parent
9cdf3bd0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game/engines/default/engine/utils.lua
+23
-32
23 additions, 32 deletions
game/engines/default/engine/utils.lua
with
23 additions
and
32 deletions
game/engines/default/engine/utils.lua
+
23
−
32
View file @
dc1d03e1
...
...
@@ -860,42 +860,33 @@ local word_size_cache = {}
local
fontoldsize
=
getmetatable
(
tmps
).
__index
.
size
getmetatable
(
tmps
).
__index
.
simplesize
=
fontoldsize
getmetatable
(
tmps
).
__index
.
size
=
function
(
font
,
str
)
local
li
st
=
str
:
split
(
"#"
*
(
Puid
+
Pcolorcodefull
+
Pcolorname
+
Pfontstyle
+
Pextra
)
*
"#"
,
true
)
local
t
st
r
=
str
:
toTString
(
)
local
mw
,
mh
=
0
,
0
local
fstyle
=
font
:
getStyle
()
word_size_cache
[
font
]
=
word_size_cache
[
font
]
or
{}
word_size_cache
[
font
][
fstyle
]
=
word_size_cache
[
font
][
fstyle
]
or
{}
local
v
for
i
=
1
,
#
list
do
v
=
list
[
i
]
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
)
local
extra
=
lpeg
.
match
(
"#"
*
lpeg
.
C
(
Pextra
)
*
"#"
,
v
)
if
nr
and
ng
and
nb
then
-- Ignore
elseif
col
then
-- Ignore
elseif
uid
and
mo
and
game
.
level
then
uid
=
tonumber
(
uid
)
mo
=
tonumber
(
mo
)
local
e
=
__uids
[
uid
]
if
e
then
local
surf
=
e
:
getEntityFinalSurface
(
game
.
level
.
map
.
tiles
,
font
:
lineSkip
(),
font
:
lineSkip
())
if
surf
then
local
w
,
h
=
surf
:
getSize
()
mw
=
mw
+
w
if
h
>
mh
then
mh
=
h
end
for
i
=
1
,
#
tstr
do
v
=
tstr
[
i
]
if
type
(
v
)
==
"table"
then
if
v
[
1
]
==
"font"
then
local
fontstyle
=
v
[
2
]
font
:
setStyle
(
fontstyle
)
fstyle
=
fontstyle
word_size_cache
[
font
][
fstyle
]
=
word_size_cache
[
font
][
fstyle
]
or
{}
elseif
v
[
1
]
==
"uid"
then
local
uid
=
v
[
2
]
local
e
=
__uids
[
uid
]
if
e
then
local
surf
=
e
:
getEntityFinalSurface
(
game
.
level
.
map
.
tiles
,
font
:
lineSkip
(),
font
:
lineSkip
())
if
surf
then
local
w
,
h
=
surf
:
getSize
()
mw
=
mw
+
w
if
h
>
mh
then
mh
=
h
end
end
end
end
elseif
fontstyle
then
font
:
setStyle
(
fontstyle
)
fstyle
=
fontstyle
word_size_cache
[
font
][
fstyle
]
=
word_size_cache
[
font
][
fstyle
]
or
{}
elseif
extra
then
--
else
end
-- ignore colors and all that
elseif
type
(
v
)
==
"string"
then
local
w
,
h
if
word_size_cache
[
font
][
fstyle
][
v
]
then
w
,
h
=
word_size_cache
[
font
][
fstyle
][
v
][
1
],
word_size_cache
[
font
][
fstyle
][
v
][
2
]
...
...
@@ -905,7 +896,7 @@ getmetatable(tmps).__index.size = function(font, str)
end
if
h
>
mh
then
mh
=
h
end
mw
=
mw
+
w
end
end
-- ignore the rest
end
return
mw
,
mh
end
...
...
@@ -1028,7 +1019,7 @@ function string.toTString(str)
elseif
col
then
tstr
:
add
({
"color"
,
col
})
elseif
uid
and
mo
then
tstr
:
add
({
"uid"
,
tonumber
(
uid
)})
tstr
:
add
({
"uid"
,
tonumber
(
uid
)
,
tonumber
(
mo
)
})
elseif
fontstyle
then
tstr
:
add
({
"font"
,
fontstyle
})
elseif
extra
then
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment