Skip to content

Commit

Permalink
Fix eject typing effect for multibyte characters (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
BytewaveMLP authored Dec 15, 2020
1 parent 8a6ece2 commit a7d44c3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gamemodes/amongus/gamemode/vgui/vgui_eject.moon
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,20 @@ eject.WriteText = (text, subtext) =>
draw.SimpleText subtext, "NMW AU Eject Subtext", w/2, h/2, color,
TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 2, COLOR_OUTLINE

textLen = utf8.len(text)
i = 0
callback = ->
i += 1

@ejectTextLabel.Text ..= text[i]
char = utf8.GetChar(text, i)

if text[i] ~= "" and text[i] ~= " "
@ejectTextLabel.Text ..= char

if char ~= "" and char ~= " "
surface.PlaySound "au/eject_text.ogg"

if i ~= #text
@ejectTextLabel\NewAnimation 1.5/#text, 0, 0, callback
if i ~= textLen
@ejectTextLabel\NewAnimation 1.5/textLen, 0, 0, callback
elseif @ejectTextSubLabel
@ejectTextSubLabel\AlphaTo 255, 0.25, 1

Expand Down

0 comments on commit a7d44c3

Please sign in to comment.