Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
tome
Tales of MajEyal
Commits
2b5af11b
Commit
2b5af11b
authored
10 years ago
by
Alex Ksandra
Browse files
Options
Downloads
Patches
Plain Diff
Removed redunant functions.
parent
8f573890
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!104
Many a fix to colored string rendering.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game/engines/default/engine/utils.lua
+2
-71
2 additions, 71 deletions
game/engines/default/engine/utils.lua
with
2 additions
and
71 deletions
game/engines/default/engine/utils.lua
+
2
−
71
View file @
2b5af11b
...
...
@@ -824,77 +824,6 @@ function __get_uid_entity(uid)
end
local
tmps
=
core
.
display
.
newSurface
(
1
,
1
)
getmetatable
(
tmps
).
__index
.
drawColorString
=
function
(
s
,
font
,
str
,
x
,
y
,
r
,
g
,
b
,
alpha_from_texture
,
limit_w
)
local
list
=
str
:
split
(
"#"
*
(
Puid
+
Pcolorcodefull
+
Pcolorname
+
Pfontstyle
+
Pextra
)
*
"#"
,
true
)
r
=
r
or
255
g
=
g
or
255
b
=
b
or
255
limit_w
=
limit_w
or
99999999
local
oldr
,
oldg
,
oldb
=
r
,
g
,
b
local
max_h
=
0
local
sw
=
0
local
bx
,
by
=
x
,
y
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
)
local
extra
=
lpeg
.
match
(
"#"
*
lpeg
.
C
(
Pextra
)
*
"#"
,
v
)
if
nr
and
ng
and
nb
then
oldr
,
oldg
,
oldb
=
r
,
g
,
b
r
,
g
,
b
=
nr
:
parseHex
(),
ng
:
parseHex
(),
nb
:
parseHex
()
elseif
col
then
if
col
==
"LAST"
then
r
,
g
,
b
=
oldr
,
oldg
,
oldb
else
oldr
,
oldg
,
oldb
=
r
,
g
,
b
r
,
g
,
b
=
colors
[
col
].
r
,
colors
[
col
].
g
,
colors
[
col
].
b
end
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
()
if
sw
+
w
>
limit_w
then
break
end
s
:
merge
(
surf
,
x
,
y
)
if
h
>
max_h
then
max_h
=
h
end
x
=
x
+
(
w
or
0
)
sw
=
sw
+
(
w
or
0
)
end
end
elseif
fontstyle
then
font
:
setStyle
(
fontstyle
)
elseif
extra
then
--
else
local
w
,
h
=
font
:
size
(
v
)
local
stop
=
false
while
sw
+
w
>
limit_w
do
v
=
v
:
sub
(
1
,
#
v
-
1
)
if
#
v
==
0
then
break
end
w
,
h
=
font
:
size
(
v
)
stop
=
true
end
if
h
>
max_h
then
max_h
=
h
end
s
:
drawStringBlended
(
font
,
v
,
x
,
y
,
r
,
g
,
b
,
alpha_from_texture
)
x
=
x
+
w
sw
=
sw
+
w
if
stop
then
break
end
end
end
return
r
,
g
,
b
,
sw
,
max_h
,
bx
,
by
end
getmetatable
(
tmps
).
__index
.
drawColorStringCentered
=
function
(
s
,
font
,
str
,
dx
,
dy
,
dw
,
dh
,
r
,
g
,
b
,
alpha_from_texture
,
limit_w
)
local
w
,
h
=
font
:
size
(
str
)
local
x
,
y
=
dx
+
(
dw
-
w
)
/
2
,
dy
+
(
dh
-
h
)
/
2
s
:
drawColorString
(
font
,
str
,
x
,
y
,
r
,
g
,
b
,
alpha_from_texture
,
limit_w
)
end
getmetatable
(
tmps
).
__index
.
drawColorStringBlended
=
function
(
s
,
font
,
str
,
x
,
y
,
r
,
g
,
b
,
alpha_from_texture
,
limit_w
)
local
list
=
str
:
split
(
"#"
*
(
Puid
+
Pcolorcodefull
+
Pcolorname
+
Pfontstyle
+
Pextra
)
*
"#"
,
true
)
r
=
r
or
255
...
...
@@ -958,12 +887,14 @@ getmetatable(tmps).__index.drawColorStringBlended = function(s, font, str, x, y,
end
return
r
,
g
,
b
,
sw
,
max_h
,
bx
,
by
end
getmetatable
(
tmps
).
__index
.
drawColorString
=
getmetatable
(
tmps
).
__index
.
drawColorStringBlended
getmetatable
(
tmps
).
__index
.
drawColorStringBlendedCentered
=
function
(
s
,
font
,
str
,
dx
,
dy
,
dw
,
dh
,
r
,
g
,
b
,
alpha_from_texture
,
limit_w
)
local
w
,
h
=
font
:
size
(
str
)
local
x
,
y
=
dx
+
(
dw
-
w
)
/
2
,
dy
+
(
dh
-
h
)
/
2
s
:
drawColorStringBlended
(
font
,
str
,
x
,
y
,
r
,
g
,
b
,
alpha_from_texture
,
limit_w
)
end
getmetatable
(
tmps
).
__index
.
drawColorStringCentered
=
getmetatable
(
tmps
).
__index
.
drawColorStringBlendedCentered
local
font_cache
=
{}
local
oldNewFont
=
core
.
display
.
newFont
...
...
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