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
6b156fb8
Commit
6b156fb8
authored
11 years ago
by
DarkGod
Browse files
Options
Downloads
Patches
Plain Diff
Pressing tab when typing a player name as the first word of a sentence will try to autocomplete it
parent
7a3ee623
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game/engines/default/engine/dialogs/Talkbox.lua
+31
-0
31 additions, 0 deletions
game/engines/default/engine/dialogs/Talkbox.lua
with
31 additions
and
0 deletions
game/engines/default/engine/dialogs/Talkbox.lua
+
31
−
0
View file @
6b156fb8
...
...
@@ -78,6 +78,8 @@ function _M:init(chat, on_end)
self
.
chat
:
setCurrentTarget
(
false
,
self
.
chat
.
last_whispers
[
found
])
self
:
updateTitle
(
self
:
getTitle
())
end
else
self
:
autoComplete
()
end
end
)
end
...
...
@@ -136,6 +138,35 @@ function _M:checkTarget(text)
end
end
function
_M
:
autoComplete
()
local
text
,
text_len
=
self
.
c_box
.
text
,
self
.
c_box
.
text
:
len
()
local
matches
=
{}
for
k
,
v
in
pairs
(
self
.
chat
.
channels
[
self
.
chat
.
cur_channel
].
users
)
do
if
k
:
sub
(
1
,
text_len
)
==
text
then
matches
[
#
matches
+
1
]
=
k
end
end
if
#
matches
==
1
then
self
.
c_box
:
setText
(
matches
[
1
])
elseif
#
matches
>
1
then
-- Find the longest common substring and complete it
local
substring
=
matches
[
1
]:
sub
(
#
text
+
1
)
for
i
=
2
,
#
matches
do
local
min_len
=
math.min
(
#
matches
[
i
]
-#
text
,
#
substring
)
for
j
=
1
,
min_len
do
if
substring
:
sub
(
j
,
j
)
~=
matches
[
i
]:
sub
(
#
text
+
j
,
#
text
+
j
)
then
substring
=
substring
:
sub
(
1
,
util
.
bound
(
j
-
1
,
0
))
break
end
end
if
#
substring
>
0
then
self
.
c_box
:
setText
(
text
..
substring
)
end
end
end
end
function
_M
:
okclick
()
local
text
=
self
.
c_box
.
text
...
...
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