Ticket #1767: 1767.diff
File 1767.diff, 4.4 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/common/functions_utility.js
240 240 // Limit the length to 20 characters 241 241 return sanitizedName.substr(0,20); 242 242 } 243 244 function tryAutoComplete(text, autoCompleteList) 245 { 246 if (text.length == 0) 247 return text; 248 249 var wordSplit = text.split(/\s+/g); 250 251 if(!wordSplit.length) 252 return text; 253 254 var lastWord = wordSplit.pop(); 255 for (var wordAutoCompletion of autoCompleteList) 256 { 257 if (wordAutoCompletion.toLowerCase().indexOf(lastWord.toLowerCase()) == 0) 258 { 259 text = wordSplit.join(" ") + " " + wordAutoCompletion; 260 break; 261 } 262 } 263 return text; 264 } 265 No newline at end of file -
binaries/data/mods/public/gui/lobby/lobby.js
753 753 { 754 754 var input = Engine.GetGUIObjectByName("chatInput"); 755 755 var text = escapeText(input.caption); 756 if (text.length) 756 if (!text.length) 757 return; 758 759 var autoCompletionList = []; 760 for each (var playerObj in Engine.GetPlayerList()) 757 761 { 758 var matched = false; 759 for each (var playerObj in Engine.GetPlayerList()) 760 { 761 var player = playerObj.name; 762 var breaks = text.match(/(\s+)/g) || []; 763 text.split(/\s+/g).reduceRight(function (wordsSoFar, word, index) 764 { 765 if (matched) 766 return null; 767 var matchCandidate = word + (breaks[index - 1] || "") + wordsSoFar; 768 if (player.toUpperCase().indexOf(matchCandidate.toUpperCase().trim()) == 0) 769 { 770 input.caption = text.replace(matchCandidate.trim(), player); 771 matched = true; 772 } 773 return matchCandidate; 774 }, ""); 775 if (matched) 776 break; 777 } 762 autoCompletionList.push(playerObj.name); 778 763 } 764 765 input.caption = tryAutoComplete(text, autoCompletionList); 779 766 } 780 767 781 768 function isValidNick(nick) -
binaries/data/mods/public/gui/session/messages.js
308 308 } 309 309 } 310 310 311 function autoCompleteNick() 312 { 313 var input = Engine.GetGUIObjectByName("chatInput"); 314 var text = input.caption; 315 316 if (!text.length) 317 return; 318 319 var autoCompletionList = []; 320 for (var player of g_Players) 321 { 322 autoCompletionList.push(player.name); 323 } 324 325 input.caption = tryAutoComplete(text, autoCompletionList); 326 } 327 311 328 function submitChatInput() 312 329 { 313 330 var input = Engine.GetGUIObjectByName("chatInput"); … … 612 629 msg.hide = true; 613 630 recurse = true; 614 631 break; 632 case "/allies": 633 var player = g_Players[Engine.GetPlayerID()]; 634 635 if (player && player.isAlly[sender]) 636 msg.context = translate("Ally"); 637 else 638 msg.hide = true; 639 640 recurse = true; 641 break; 615 642 case "/enemy": 616 643 // Check if we are in a team. 617 644 if (g_Players[Engine.GetPlayerID()] && g_Players[Engine.GetPlayerID()].team != -1) -
binaries/data/mods/public/gui/session/session.xml
195 195 <object name="chatDialogPanel" size="50%-180 50%-48 50%+180 50%+36" type="image" hidden="true" sprite="genericPanel"> 196 196 <object name="chatInput" size="16 12 100%-16 36" type="input" style="ModernInput" max_length="80"> 197 197 <action on="Press">submitChatInput();</action> 198 <action on="Tab">autoCompleteNick();</action> 198 199 </object> 199 200 200 201 <object size="16 100%-40 30%+16 100%-12" type="button" style="StoneButton"> -
source/gui/CInput.cpp
840 840 841 841 GetScrollBar(0).SetScrollBarStyle(scrollbar_style); 842 842 } 843 844 if (Message.value == CStr("caption")) 845 { 846 if (m_iBufferPos > 0) 847 { 848 CStrW caption; 849 GUI<CStrW>::GetSetting(this, "caption", caption); 850 m_iBufferPos = m_iBufferPos_Tail = (int)caption.size(); 851 } 852 } 843 853 844 854 if (Message.value == CStr("size") || 845 855 Message.value == CStr("z") ||