Ticket #1767: 1767.3.diff
File 1767.3.diff, 5.0 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(" ") 260 if (text.length > 0) 261 text += " "; 262 263 text += wordAutoCompletion; 264 break; 265 } 266 } 267 return text; 268 } 269 270 //listPlayer parameter must be an array and every object with name property 271 function autoCompleteNick(guiName, listPlayer) 272 { 273 var input = Engine.GetGUIObjectByName(guiName); 274 var text = escapeText(input.caption); 275 if (!text.length) 276 return; 277 278 var autoCompleteList = []; 279 for (var player of listPlayer) 280 autoCompleteList.push(player.name); 281 282 input.caption = tryAutoComplete(text, autoCompleteList); 283 } 284 No newline at end of file -
binaries/data/mods/public/gui/lobby/lobby.js
749 749 } 750 750 } 751 751 752 function completeNick()753 {754 var input = Engine.GetGUIObjectByName("chatInput");755 var text = escapeText(input.caption);756 if (text.length)757 {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 }778 }779 }780 781 752 function isValidNick(nick) 782 753 { 783 754 var prohibitedNicks = ["system"]; -
binaries/data/mods/public/gui/lobby/lobby.xml
231 231 <object name="chatText" size="0 0 100% 94%" type="text" style="ChatPanel" font="sans-13"/> 232 232 <object name="chatInput" size="0 94% 100% 100%" type="input" style="ModernInput" font="sans-13"> 233 233 <action on="Press">submitChatInput();</action> 234 <action on="Tab"> completeNick();</action>234 <action on="Tab">autoCompleteNick("chatInput", Engine.GetPlayerList());</action> 235 235 </object> 236 236 </object> 237 237 </object> -
binaries/data/mods/public/gui/session/messages.js
612 612 msg.hide = true; 613 613 recurse = true; 614 614 break; 615 case "/allies": 616 var player = g_Players[Engine.GetPlayerID()]; 617 618 if (player && player.isAlly[sender]) 619 msg.context = translate("Ally"); 620 else 621 msg.hide = true; 622 623 recurse = true; 624 break; 615 625 case "/enemy": 616 626 // Check if we are in a team. 617 627 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("chatInput", g_Players);</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
841 841 GetScrollBar(0).SetScrollBarStyle(scrollbar_style); 842 842 } 843 843 844 if (Message.value == CStr("caption") && m_iBufferPos > 0) 845 { 846 CStrW caption; 847 GUI<CStrW>::GetSetting(this, "caption", caption); 848 m_iBufferPos = m_iBufferPos_Tail = (int)caption.size(); 849 } 850 844 851 if (Message.value == CStr("size") || 845 852 Message.value == CStr("z") || 846 853 Message.value == CStr("font") ||