hedgewars/uChat.pas
branchwebgl
changeset 9950 2759212a27de
parent 9521 8054d9d775fd
parent 9680 50a001b1964e
child 9954 bf51bc7e2808
equal deleted inserted replaced
9521:8054d9d775fd 9950:2759212a27de
    27 procedure ReloadLines;
    27 procedure ReloadLines;
    28 procedure CleanupInput;
    28 procedure CleanupInput;
    29 procedure AddChatString(s: shortstring);
    29 procedure AddChatString(s: shortstring);
    30 procedure DrawChat;
    30 procedure DrawChat;
    31 procedure KeyPressChat(Key, Sym: Longword);
    31 procedure KeyPressChat(Key, Sym: Longword);
       
    32 procedure SendHogSpeech(s: shortstring);
    32 
    33 
    33 implementation
    34 implementation
    34 uses SDLh, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO;
    35 uses SDLh, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO;
    35 
    36 
    36 const MaxStrIndex = 27;
    37 const MaxStrIndex = 27;
    39     Tex: PTexture;
    40     Tex: PTexture;
    40     Time: Longword;
    41     Time: Longword;
    41     Width: LongInt;
    42     Width: LongInt;
    42     s: shortstring;
    43     s: shortstring;
    43     end;
    44     end;
    44     TChatCmd = (quitCmd, pauseCmd, finishCmd, fullscreenCmd);
    45     TChatCmd = (quit, pause, finish, showhistory, fullscreen);
    45 
    46 
    46 var Strs: array[0 .. MaxStrIndex] of TChatLine;
    47 var Strs: array[0 .. MaxStrIndex] of TChatLine;
    47     MStrs: array[0 .. MaxStrIndex] of shortstring;
    48     MStrs: array[0 .. MaxStrIndex] of shortstring;
    48     LocalStrs: array[0 .. MaxStrIndex] of shortstring;
    49     LocalStrs: array[0 .. MaxStrIndex] of shortstring;
    49     missedCount: LongWord;
    50     missedCount: LongWord;
    71             ProcedureCallChatCmd: string[31];
    72             ProcedureCallChatCmd: string[31];
    72             end = (
    73             end = (
    73             (ChatCmd: '/quit'; ProcedureCallChatCmd: 'halt'),
    74             (ChatCmd: '/quit'; ProcedureCallChatCmd: 'halt'),
    74             (ChatCmd: '/pause'; ProcedureCallChatCmd: 'pause'),
    75             (ChatCmd: '/pause'; ProcedureCallChatCmd: 'pause'),
    75             (ChatCmd: '/finish'; ProcedureCallChatCmd: 'finish'),
    76             (ChatCmd: '/finish'; ProcedureCallChatCmd: 'finish'),
       
    77             (ChatCmd: '/history'; ProcedureCallChatCmd: 'history'),
    76             (ChatCmd: '/fullscreen'; ProcedureCallChatCmd: 'fullscr')
    78             (ChatCmd: '/fullscreen'; ProcedureCallChatCmd: 'fullscr')
    77             );
    79             );
    78 
    80 
    79 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
    81 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
    80 var strSurface, resSurface: PSDL_Surface;
    82 var strSurface, resSurface: PSDL_Surface;
   172     begin
   174     begin
   173     r.w:= InputStr.Width;
   175     r.w:= InputStr.Width;
   174     DrawFillRect(r);
   176     DrawFillRect(r);
   175     Tint($00, $00, $00, $80);
   177     Tint($00, $00, $00, $80);
   176     DrawTexture(9 - cScreenWidth div 2, visibleCount * 16 + 11, InputStr.Tex);
   178     DrawTexture(9 - cScreenWidth div 2, visibleCount * 16 + 11, InputStr.Tex);
   177     Tint($FF, $FF, $FF, $FF);
   179     untint;
   178     DrawTexture(8 - cScreenWidth div 2, visibleCount * 16 + 10, InputStr.Tex);
   180     DrawTexture(8 - cScreenWidth div 2, visibleCount * 16 + 10, InputStr.Tex);
   179     end;
   181     end;
   180 
   182 
   181 dec(r.y, 16);
   183 dec(r.y, 16);
   182 
   184 
   185     begin
   187     begin
   186     r.w:= Strs[i].Width;
   188     r.w:= Strs[i].Width;
   187     DrawFillRect(r);
   189     DrawFillRect(r);
   188     Tint($00, $00, $00, $80);
   190     Tint($00, $00, $00, $80);
   189     DrawTexture(9 - cScreenWidth div 2, (visibleCount - t) * 16 - 5, Strs[i].Tex);
   191     DrawTexture(9 - cScreenWidth div 2, (visibleCount - t) * 16 - 5, Strs[i].Tex);
   190     Tint($FF, $FF, $FF, $FF);
   192     untint;
   191     DrawTexture(8 - cScreenWidth div 2, (visibleCount - t) * 16 - 6, Strs[i].Tex);
   193     DrawTexture(8 - cScreenWidth div 2, (visibleCount - t) * 16 - 6, Strs[i].Tex);
   192     dec(r.y, 16);
   194     dec(r.y, 16);
   193 
   195 
   194     if i = 0 then
   196     if i = 0 then
   195         i:= MaxStrIndex
   197         i:= MaxStrIndex
   238     else
   240     else
   239         SendHogSpeech(char(x) + char(t) + copy(s, 2, Length(s)-2));
   241         SendHogSpeech(char(x) + char(t) + copy(s, 2, Length(s)-2));
   240     exit
   242     exit
   241     end;
   243     end;
   242 
   244 
   243 // These 3 are same as above, only are to make the hedgehog say it on next attack
   245 if (s[1] = '/') then
   244 if (s[1] = '/') and (copy(s, 1, 5) = '/hsa ') then
   246     begin
   245     begin
   247     // These 3 are same as above, only are to make the hedgehog say it on next attack
   246     if CurrentTeam^.ExtDriven then
   248     if (copy(s, 1, 5) = '/hsa ') then
   247         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   249         begin
   248     else
   250         if CurrentTeam^.ExtDriven then
   249         SendHogSpeech(#4 + copy(s, 6, Length(s)-5));
   251             ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   250     exit
   252         else
   251     end;
   253             SendHogSpeech(#4 + copy(s, 6, Length(s)-5));
   252 if (s[1] = '/') and (copy(s, 1, 5) = '/hta ') then
   254         exit
   253     begin
   255         end;
   254     if CurrentTeam^.ExtDriven then
   256 
   255         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   257     if (copy(s, 1, 5) = '/hta ') then
   256     else
   258         begin
   257         SendHogSpeech(#5 + copy(s, 6, Length(s)-5));
   259         if CurrentTeam^.ExtDriven then
   258     exit
   260             ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   259     end;
   261         else
   260 if (s[1] = '/') and (copy(s, 1, 5) = '/hya ') then
   262             SendHogSpeech(#5 + copy(s, 6, Length(s)-5));
   261     begin
   263         exit
   262     if CurrentTeam^.ExtDriven then
   264         end;
   263         ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   265 
   264     else
   266     if (copy(s, 1, 5) = '/hya ') then
   265         SendHogSpeech(#6 + copy(s, 6, Length(s)-5));
   267         begin
   266     exit
   268         if CurrentTeam^.ExtDriven then
   267     end;
   269             ParseCommand('/say ' + copy(s, 6, Length(s)-5), true)
   268 
   270         else
   269 if (copy(s, 1, 6) = '/team ') and (length(s) > 6) then
   271             SendHogSpeech(#6 + copy(s, 6, Length(s)-5));
   270     begin
   272         exit
   271     ParseCommand(s, true);
   273         end;
   272     exit
   274 
   273     end;
   275     if (copy(s, 1, 6) = '/team ') and (length(s) > 6) then
   274 if (s[1] = '/') and (copy(s, 1, 4) <> '/me ') then
   276         begin
   275     begin
   277         ParseCommand(s, true);
   276     if CurrentTeam^.ExtDriven or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then
   278         exit
   277         exit;
   279         end;
   278 
   280 
   279     for i:= Low(TWave) to High(TWave) do
   281     if (copy(s, 1, 4) = '/me ') then
   280         if (s = Wavez[i].cmd) then
   282         begin
   281             begin
   283         ParseCommand('/say ' + s, true);
   282             ParseCommand('/taunt ' + char(i), true);
   284         exit
   283             exit
   285         end;
   284             end;
   286 
   285 
   287     if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then
   286     for j:= Low(TChatCmd) to High(TChatCmd) do
   288         begin
   287         if (s = ChatCommandz[j].ChatCmd) then
   289         for i:= Low(TWave) to High(TWave) do
   288             begin
   290             if (s = Wavez[i].cmd) then
   289             ParseCommand(ChatCommandz[j].ProcedureCallChatCmd, true);
   291                 begin
   290             exit
   292                 ParseCommand('/taunt ' + char(i), true);
   291             end;
   293                 exit
       
   294                 end;
       
   295 
       
   296         for j:= Low(TChatCmd) to High(TChatCmd) do
       
   297             if (s = ChatCommandz[j].ChatCmd) then
       
   298                 begin
       
   299                 ParseCommand(ChatCommandz[j].ProcedureCallChatCmd, true);
       
   300                 exit
       
   301                 end;
       
   302         end
   292     end
   303     end
   293     else
   304     else
   294         ParseCommand('/say ' + s, true);
   305         ParseCommand('/say ' + s, true);
   295 end;
   306 end;
   296 
   307