~ubuntu-branches/ubuntu/wily/hedgewars/wily

« back to all changes in this revision

Viewing changes to hedgewars/uChat.pas

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-09-23 10:16:55 UTC
  • mfrom: (1.2.11 upstream)
  • Revision ID: package-import@ubuntu.com-20110923101655-3977th2gc5n0a3pv
Tags: 0.9.16-1
* New upstream version.
 + Downloadable content! Simply click to install any content.
   New voices, hats, maps, themes, translations, music, scripts...
   Hedgewars is now more customisable than ever before! As time goes
   by we will be soliciting community content to feature on this page,
   so remember to check it from time to time. If you decide you want
   to go back to standard Hedgewars, just remove the Data directory
   from your Hedgewars config directory.
 + 3-D rendering! Diorama-like rendering of the game in a variety
   of 3D modes. Let us know which ones work best for you, we didn't
   really have the equipment to test them all.
 + Resizable game window.
 + New utilities! The Time Box will remove one of your hedgehogs
   from the game for a while, protecting from attack until it returns,
   somewhere else on the map. Land spray will allow you to build bridges,
   seal up holes, or just make life unpleasant for your enemies.
 + New single player: Bamboo Thicket, That Sinking Feeling, Newton and
   the Tree and multi-player: The Specialists, Space Invaders,
   Racer - scripts! And a ton more script hooks for scripters
 + New twists on old weapons. Drill strike, seduction and fire have
   been adjusted. Defective mines have been added, rope can attach to
   hogs/crates/barrels again, grenades now have variable bounce (use
   precise key + 1-5). Portal gun is now more usable in flight and
   all game actions are a lot faster.
 + New theme - Golf, dozens of new community hats and a new
   localised Default voice, Ukranian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
(*
2
2
 * Hedgewars, a free turn based strategy game
3
 
 * Copyright (c) 2008 Andrey Korotaev <unC0Rr@gmail.com>
 
3
 * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License as published by
29
29
procedure DrawChat;
30
30
procedure KeyPressChat(Key: Longword);
31
31
 
32
 
var UserNick: shortstring = '';
33
 
    ChatReady: boolean;
34
 
    showAll: boolean;
35
 
 
36
32
implementation
37
33
uses SDLh, uKeys, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO;
38
34
 
52
48
    visibleCount: LongWord;
53
49
    InputStr: TChatLine;
54
50
    InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char
 
51
    ChatReady: boolean;
 
52
    showAll: boolean;
55
53
 
56
 
const colors: array[#1..#5] of TSDL_Color = (
 
54
const colors: array[#1..#6] of TSDL_Color = (
57
55
    (r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White]
58
56
    (r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple]
59
57
    (r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime]
60
58
    (r:$FF; g:$FF; b:$A0; unused:$FF), // team message [Light Yellow]
61
 
    (r:$FF; g:$00; b:$00; unused:$ff)  // error messages [Red]
 
59
    (r:$FF; g:$00; b:$00; unused:$FF), // error messages [Red]
 
60
    (r:$00; g:$FF; b:$FF; unused:$FF)  // input line [Light Blue]
62
61
    );
63
62
 
64
63
procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
70
69
if cl.Tex <> nil then
71
70
    FreeTexture(cl.Tex);
72
71
 
73
 
 
74
72
cl.s:= str;
75
73
 
76
74
if isInput then
77
75
begin
78
 
    // [Light Blue]
79
 
    color.r:= $00;
80
 
    color.g:= $FF;
81
 
    color.b:= $FF;
82
 
    color.unused:= $FF;
 
76
    color:= colors[#6];
83
77
    str:= UserNick + '> ' + str + '_'
84
78
end
85
79
else
156
150
 
157
151
dec(r.y, 16);
158
152
 
159
 
while
160
 
    (
161
 
            ((t < 7) and (Strs[i].Time > RealTicks))
162
 
        or
163
 
            ((t < MaxStrIndex) and showAll)
164
 
    )
165
 
    and
166
 
        (Strs[i].Tex <> nil) do
 
153
while (((t < 7) and (Strs[i].Time > RealTicks)) or
 
154
       ((t < MaxStrIndex) and showAll)) and
 
155
      (Strs[i].Tex <> nil) do
167
156
    begin
168
157
    r.w:= Strs[i].Width;
169
158
    DrawFillRect(r);
272
261
                SetLine(InputStr, InputStr.s, true)
273
262
                end;
274
263
        {Esc}
275
 
        27: SetLine(InputStr, '', true);
 
264
        27: if Length(InputStr.s) > 0 then SetLine(InputStr, '', true)
 
265
            else
 
266
                begin
 
267
                FreezeEnterKey;
 
268
                SDL_EnableKeyRepeat(0,0);
 
269
                GameState:= gsGame;
 
270
                end;
276
271
        {Return}
277
272
        3, 13, 271: begin
278
273
            if Length(InputStr.s) > 0 then
281
276
                SetLine(InputStr, '', false)
282
277
                end;
283
278
            FreezeEnterKey;
284
 
            GameState:= gsGame
 
279
            SDL_EnableKeyRepeat(0,0);
 
280
            GameState:= gsGame;
285
281
            end;
286
282
    else
287
283
    if (Key < $80) then btw:= 1
342
338
begin
343
339
    s:= s; // avoid compiler hint
344
340
    GameState:= gsChat;
 
341
    SDL_EnableKeyRepeat(200,45);
345
342
    if length(s) = 0 then
346
 
        KeyPressChat(27)
 
343
        SetLine(InputStr, '', true)
347
344
    else
348
345
        begin
 
346
        // err, does anyone have any documentation on this sequence?
349
347
        KeyPressChat(27);
350
348
        KeyPressChat(47);
351
349
        KeyPressChat(116);
357
355
end;
358
356
 
359
357
procedure initModule;
 
358
var i: ShortInt;
360
359
begin
361
360
    RegisterVariable('chatmsg', vtCommand, @chChatMessage, true);
362
361
    RegisterVariable('say', vtCommand, @chSay, true);
369
368
    showAll:= false;
370
369
    ChatReady:= false;
371
370
    missedCount:= 0;
 
371
 
 
372
    inputStr.Tex := nil;
 
373
    for i:= 0 to MaxStrIndex do
 
374
    begin
 
375
        Strs[i].Tex := nil;
 
376
    end;
372
377
end;
373
378
 
374
379
procedure freeModule;
 
380
var i: ShortInt;
375
381
begin
376
 
    UserNick:= '';
 
382
    FreeTexture(InputStr.Tex);
 
383
    for i:= 0 to MaxStrIndex do
 
384
    begin
 
385
        FreeTexture(Strs[i].Tex);
 
386
    end;
377
387
end;
378
388
 
379
389
end.