hedgewars/uChat.pas
changeset 10866 c1f75780c56f
parent 10863 9d3e1123bd43
child 10868 acb03a9712c3
equal deleted inserted replaced
10865:a587145ced34 10866:c1f75780c56f
    96 
    96 
    97 
    97 
    98 const Padding  = 2;
    98 const Padding  = 2;
    99       ClHeight = 2 * Padding + 16; // font height
    99       ClHeight = 2 * Padding + 16; // font height
   100 
   100 
       
   101 function charIsForHogSpeech(c: char): boolean;
       
   102 begin
       
   103 exit((c = '"') or (c = '''') or (c = '-'));
       
   104 end;
       
   105 
   101 procedure ResetSelection();
   106 procedure ResetSelection();
   102 begin
   107 begin
   103     selectedPos:= -1;
   108     selectedPos:= -1;
   104 end;
   109 end;
   105 
   110 
   277 end;
   282 end;
   278 
   283 
   279 procedure DrawChat;
   284 procedure DrawChat;
   280 var i, t, left, top, cnt: LongInt;
   285 var i, t, left, top, cnt: LongInt;
   281     selRect: TSDL_Rect;
   286     selRect: TSDL_Rect;
       
   287     c: char;
   282 begin
   288 begin
   283 ChatReady:= true; // maybe move to somewhere else?
   289 ChatReady:= true; // maybe move to somewhere else?
   284 
   290 
   285 if ChatHidden and (not showAll) then
   291 if ChatHidden and (not showAll) then
   286     visibleCount:= 0;
   292     visibleCount:= 0;
   330 
   336 
   331         DrawRect(selRect, $FF, $FF, $FF, $40, true);
   337         DrawRect(selRect, $FF, $FF, $FF, $40, true);
   332         end;
   338         end;
   333 
   339 
   334     dec(left, InputLinePrefix.Width);
   340     dec(left, InputLinePrefix.Width);
   335     end;
   341 
       
   342 
       
   343     if (Length(InputStr.s) > 0) and ((CursorPos = 1) or (CursorPos = 2)) then
       
   344         begin
       
   345         c:= InputStr.s[1];
       
   346         if charIsForHogSpeech(c) then
       
   347             begin
       
   348             SpeechHogNumber:= 1;
       
   349             if Length(InputStr.s) > 1 then
       
   350                 begin
       
   351                 c:= InputStr.s[2];
       
   352                 if (c > '0') and (c < '9') then
       
   353                     SpeechHogNumber:= byte(c) - 48;
       
   354                 end;
       
   355             end;
       
   356         end
       
   357     else
       
   358         SpeechHogNumber:= 0;
       
   359     end
       
   360 else
       
   361     SpeechHogNumber:= 0;
   336 
   362 
   337 // draw chat lines
   363 // draw chat lines
   338 if ((not ChatHidden) or showAll) and (UIDisplay <> uiNone) then
   364 if ((not ChatHidden) or showAll) and (UIDisplay <> uiNone) then
   339     begin
   365     begin
   340     if MissedCount <> 0 then // there are chat strings we missed, so print them now
   366     if MissedCount <> 0 then // there are chat strings we missed, so print them now
  1026         utf8:= char(Key or firstByteMark[Pred(btw)]) + utf8;
  1052         utf8:= char(Key or firstByteMark[Pred(btw)]) + utf8;
  1027 
  1053 
  1028         if Length(InputStr.s) + btw > MaxInputStrLen then
  1054         if Length(InputStr.s) + btw > MaxInputStrLen then
  1029             exit;
  1055             exit;
  1030 
  1056 
  1031         InsertIntoInputStr(utf8);
  1057         if (Length(InputStr.s) = 0) and (Length(utf8) = 1) and (charIsForHogSpeech(utf8[1])) then
       
  1058             begin
       
  1059             InsertIntoInputStr(utf8);
       
  1060             InsertIntoInputStr(utf8);
       
  1061             cursorPos:= 1;
       
  1062             UpdateCursorCoords();
       
  1063             end
       
  1064         else
       
  1065             InsertIntoInputStr(utf8);
  1032         end
  1066         end
  1033 end;
  1067 end;
  1034 
  1068 
  1035 procedure chChatMessage(var s: shortstring);
  1069 procedure chChatMessage(var s: shortstring);
  1036 begin
  1070 begin