hedgewars/uStore.pas
author unc0rr
Thu, 12 Jan 2006 16:33:26 +0000
changeset 47 8daf1ee0b9a3
parent 43 e297fea1a2f3
child 49 3afe33c1cf06
permissions -rw-r--r--
Show team health bars, without sorting yet
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     1
(*
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     2
 * Hedgewars, a worms-like game
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
     3
 * Copyright (c) 2004, 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     4
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     5
 * Distributed under the terms of the BSD-modified licence:
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     6
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     8
 * of this software and associated documentation files (the "Software"), to deal
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     9
 * with the Software without restriction, including without limitation the
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    10
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    11
 * sell copies of the Software, and to permit persons to whom the Software is
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    12
 * furnished to do so, subject to the following conditions:
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    13
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    14
 * 1. Redistributions of source code must retain the above copyright notice,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    15
 *    this list of conditions and the following disclaimer.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    16
 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    17
 *    this list of conditions and the following disclaimer in the documentation
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    18
 *    and/or other materials provided with the distribution.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    19
 * 3. The name of the author may not be used to endorse or promote products
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    20
 *    derived from this software without specific prior written permission.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    21
 *
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    23
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    24
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    25
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    26
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    28
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    29
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    30
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    31
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    32
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    33
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    34
unit uStore;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    35
interface
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    36
uses uConsts, uTeams, SDLh;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    37
{$INCLUDE options.inc}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    38
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    39
type PRangeArray = ^TRangeArray;
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 38
diff changeset
    40
     TRangeArray = array[0..31] of record
72ffe21f027c - Fixed console behavior
unc0rr
parents: 38
diff changeset
    41
                                   Left, Right: integer;
72ffe21f027c - Fixed console behavior
unc0rr
parents: 38
diff changeset
    42
                                   end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    43
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    44
procedure StoreInit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    45
procedure StoreLoad;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    46
procedure StoreRelease;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    47
procedure DrawGear(Stuff : TStuff; X, Y: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    48
procedure DrawSpriteFromRect(r: TSDL_Rect; X, Y, Height, Position: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    49
procedure DrawSprite (Sprite: TSprite; X, Y, Position: integer; Surface: PSDL_Surface);
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
    50
procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: integer; Surface: PSDL_Surface);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    51
procedure DrawLand (X, Y: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    52
procedure DXOutText(X, Y: Integer; Font: THWFont; s: string; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    53
procedure DrawCaption(X, Y: integer; Rect: TSDL_Rect; Surface: PSDL_Surface; const fromTempSurf: boolean = false);
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
    54
procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    55
procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    56
procedure DrawExplosion(X, Y, Radius: integer);
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 38
diff changeset
    57
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
    58
procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    59
procedure RenderHealth(var Hedgehog: THedgehog);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    60
function  RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    61
procedure AddProgress;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
    62
function  LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    63
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    64
var PixelFormat: PSDL_PixelFormat;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    65
 SDLPrimSurface: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    66
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    67
implementation
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    68
uses uMisc, uIO, uConsole, uLand;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    69
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    70
var StoreSurface,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    71
     TempSurface,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    72
       HHSurface: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    73
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    74
procedure DrawExplosion(X, Y, Radius: integer);
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
    75
var ty, tx, p: integer;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    76
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    77
for ty:= max(-Radius, -y) to min(radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    78
    for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    79
        Land[ty + y, tx]:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    80
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    81
if SDL_MustLock(LandSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    82
   SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    83
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
    84
p:= integer(LandSurface.pixels);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    85
case LandSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    86
     1: ;// not supported
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    87
     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    88
            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    89
                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    90
     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    91
            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    92
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    93
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    94
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    95
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    96
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    97
     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    98
            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    99
                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   100
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   101
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   102
inc(Radius, 4);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   103
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   104
case LandSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   105
     1: ;// not supported
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   106
     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   107
            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   108
               if Land[y + ty, tx] <> 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   109
                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   110
     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   111
            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   112
               if Land[y + ty, tx] <> 0 then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   113
                begin
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   114
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   115
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= (cExplosionBorderColor shr 8) and $FF;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   116
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   117
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   118
     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   119
            for tx:= max(0, round(x-radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(x+radius*sqrt(1-sqr(ty/radius)))) do
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   120
               if Land[y + ty, tx] <> 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   121
                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   122
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   123
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   124
if SDL_MustLock(LandSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   125
   SDL_UnlockSurface(LandSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   126
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   127
SDL_UpdateRect(LandSurface, X - Radius, Y - Radius, Radius * 2, Radius * 2)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   128
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   129
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 38
diff changeset
   130
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   131
var tx, ty, i, p: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   132
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   133
if SDL_MustLock(LandSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   134
   SDL_LockSurface(LandSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   135
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   136
p:= integer(LandSurface.pixels);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   137
for i:= 0 to Pred(Count) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   138
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   139
    case LandSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   140
     1: ;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   141
     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   142
            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   143
                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   144
     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   145
            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   146
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   147
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   148
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   149
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   150
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   151
     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   152
            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   153
                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   154
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   155
    inc(y, dY)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   156
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   157
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   158
inc(Radius, 4);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   159
dec(y, Count*dY);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   160
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   161
for i:= 0 to Pred(Count) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   162
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   163
    case LandSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   164
     1: ;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   165
     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   166
            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   167
               if Land[y + ty, tx] <> 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   168
                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   169
     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   170
            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   171
               if Land[y + ty, tx] <> 0 then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   172
                begin
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   173
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   174
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= (cExplosionBorderColor shr 8) and $FF;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   175
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   176
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   177
     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   178
            for tx:= max(0, round(ar[i].Left - radius*sqrt(1-sqr(ty/radius)))) to min(2047, round(ar[i].Right + radius*sqrt(1-sqr(ty/radius)))) do
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   179
               if Land[y + ty, tx] <> 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   180
                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   181
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   182
    inc(y, dY)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   183
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   184
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   185
if SDL_MustLock(LandSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   186
   SDL_UnlockSurface(LandSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   187
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   188
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   189
//
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   190
//  - (dX, dY) - direction, vector of length = 0.5
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   191
//
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   192
procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   193
var nx, ny: real;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   194
    i, t, tx, ty, p: integer;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   195
begin  // (-dY, dX) is (dX, dY) turned by PI/2
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   196
if SDL_MustLock(LandSurface) then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   197
   SDL_LockSurface(LandSurface);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   198
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   199
nx:= X + dY * (HalfWidth + 8);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   200
ny:= Y - dX * (HalfWidth + 8);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   201
p:= integer(LandSurface.pixels);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   202
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   203
for i:= 0 to 7 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   204
    begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   205
    X:= nx - 8 * dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   206
    Y:= ny - 8 * dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   207
    for t:= -8 to ticks + 8 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   208
        {$include tunsetborder.inc}
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   209
    nx:= nx - dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   210
    ny:= ny + dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   211
    end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   212
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   213
for i:= -HalfWidth to HalfWidth do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   214
    begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   215
    X:= nx - dX * 8;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   216
    Y:= ny - dY * 8;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   217
    for t:= 0 to 7 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   218
        {$include tunsetborder.inc}
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   219
    X:= nx;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   220
    Y:= ny;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   221
    for t:= 0 to ticks do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   222
        begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   223
        X:= X + dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   224
        Y:= Y + dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   225
        tx:= round(X);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   226
        ty:= round(Y);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   227
        if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   228
           begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   229
           Land[ty, tx]:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   230
           case LandSurface.format.BytesPerPixel of
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   231
                1: ;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   232
                2: PWord(p + LandSurface.pitch * ty + tx * 2)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   233
                3: begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   234
                   PByte(p + LandSurface.pitch * ty + tx * 3 + 0)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   235
                   PByte(p + LandSurface.pitch * ty + tx * 3 + 1)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   236
                   PByte(p + LandSurface.pitch * ty + tx * 3 + 2)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   237
                   end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   238
                4: PLongword(p + LandSurface.pitch * ty + tx * 4)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   239
                end
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   240
           end
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   241
        end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   242
    for t:= 0 to 7 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   243
        {$include tunsetborder.inc}
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   244
    nx:= nx - dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   245
    ny:= ny + dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   246
    end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   247
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   248
for i:= 0 to 7 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   249
    begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   250
    X:= nx - 8 * dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   251
    Y:= ny - 8 * dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   252
    for t:= -8 to ticks + 8 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   253
        {$include tunsetborder.inc}
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   254
    nx:= nx - dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   255
    ny:= ny + dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   256
    end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   257
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   258
if SDL_MustLock(LandSurface) then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   259
   SDL_UnlockSurface(LandSurface)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   260
end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   261
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   262
procedure StoreInit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   263
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   264
StoreSurface  := SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   265
TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true);
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 35
diff changeset
   266
SDL_FillRect(StoreSurface, nil, 0);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   267
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   268
TempSurface   := SDL_CreateRGBSurface(SDL_HWSURFACE, 724, 320, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   269
TryDo(  TempSurface <> nil, errmsgCreateSurface + ': temp'  , true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   270
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   271
TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   272
//TryDo(SDL_SetColorKey(SpriteSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   273
TryDo(SDL_SetColorKey(  TempSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   274
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   275
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   276
procedure LoadToSurface(Filename: String; Surface: PSDL_Surface; X, Y: integer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   277
var tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   278
    rr: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   279
begin
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   280
  tmpsurf:= LoadImage(Filename, false);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   281
  rr.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   282
  rr.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   283
  SDL_UpperBlit(tmpsurf, nil, Surface, @rr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   284
  SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   285
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   286
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   287
procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   288
var r: TSDL_Rect;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   289
begin
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   290
r:= rect^;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   291
SDL_FillRect(Surface, @r, 0);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   292
r.y:= rect.y + 1;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   293
r.h:= rect.h - 2;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   294
SDL_FillRect(Surface, @r, BorderColor);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   295
r.x:= rect.x + 1;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   296
r.w:= rect.w - 2;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   297
r.y:= rect.y;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   298
r.h:= rect.h;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   299
SDL_FillRect(Surface, @r, BorderColor);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   300
r.x:= rect.x + 2;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   301
r.y:= rect.y + 1;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   302
r.w:= rect.w - 4;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   303
r.h:= rect.h - 2;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   304
SDL_FillRect(Surface, @r, FillColor);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   305
r.x:= rect.x + 1;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   306
r.y:= rect.y + 2;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   307
r.w:= rect.w - 2;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   308
r.h:= rect.h - 4;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   309
SDL_FillRect(Surface, @r, FillColor)
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   310
end;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   311
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   312
function WriteInRoundRect(Surface: PSDL_Surface; X, Y: integer; Color: LongWord; Font: THWFont; s: string): TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   313
var w, h: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   314
    tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   315
    clr: TSDL_Color;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   316
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   317
TTF_SizeText(Fontz[Font].Handle, PChar(s), w, h);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   318
Result.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   319
Result.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   320
Result.w:= w + 6;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   321
Result.h:= h + 6;
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   322
DrawRoundRect(@Result, cWhiteColor, cColorNearBlack, Surface);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   323
SDL_GetRGB(Color, Surface.format, @clr.r, @clr.g, @clr.b);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   324
tmpsurf:= TTF_RenderText_Blended(Fontz[Font].Handle, PChar(s), clr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   325
Result.x:= X + 3;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   326
Result.y:= Y + 3;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   327
SDL_UpperBlit(tmpsurf, nil, Surface, @Result);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   328
SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   329
Result.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   330
Result.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   331
Result.w:= w + 6;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   332
Result.h:= h + 6
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   333
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   334
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   335
procedure StoreLoad;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   336
var i: TStuff;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   337
    ii: TSprite;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   338
    fi: THWFont;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   339
    s: string;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   340
    tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   341
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   342
    procedure WriteNames(Font: THWFont);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   343
    var Team: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   344
        i: integer;
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   345
        r, rr: TSDL_Rect;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   346
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   347
    r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   348
    r.y:= 272;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   349
    Team:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   350
    while Team<>nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   351
      begin
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   352
      r.w:= 104;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   353
      r:= WriteInRoundRect(StoreSurface, r.x, r.y, Team.Color, Font, Team.TeamName);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   354
      Team.NameRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   355
      inc(r.y, r.h);
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   356
      r.w:= cTeamHealthWidth + 5;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   357
      DrawRoundRect(@r, cWhiteColor, cColorNearBlack, StoreSurface);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   358
      Team.HealthRect:= r;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   359
      rr:= r;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   360
      inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   361
      DrawRoundRect(@rr, Team.Color, Team.Color, StoreSurface);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   362
      inc(r.y, r.h);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   363
      for i:= 0 to 7 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   364
          if Team.Hedgehogs[i].Gear<>nil then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   365
             begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   366
             r:= WriteInRoundRect(StoreSurface, r.x, r.y, Team.Color, Font, Team.Hedgehogs[i].Name);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   367
             Team.Hedgehogs[i].NameRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   368
             inc(r.y, r.h)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   369
             end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   370
      Team:= Team.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   371
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   372
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   373
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   374
    procedure MakeCrossHairs;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   375
    var Team: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   376
        r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   377
        tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   378
        s: string;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   379
        TransColor: Longword;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   380
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   381
    r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   382
    r.y:= 256;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   383
    r.w:= 16;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   384
    r.h:= 16;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   385
    s:= Pathz[ptGraphics] + cCHFileName;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   386
    WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   387
    tmpsurf:= IMG_Load(PChar(s));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   388
    TryDo(tmpsurf <> nil, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   389
    WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   390
    TransColor:= SDL_MapRGB(tmpsurf.format, $FF, $FF, $FF);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   391
    TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, TransColor) = 0, errmsgTransparentSet, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   392
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   393
    Team:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   394
    while Team<>nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   395
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   396
      SDL_FillRect(StoreSurface, @r, Team.Color);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   397
      SDL_UpperBlit(tmpsurf, nil, StoreSurface, @r);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   398
      Team.CrossHairRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   399
      inc(r.x, 16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   400
      Team:= Team.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   401
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   402
      
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   403
    SDL_FreeSurface(tmpsurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   404
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   405
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   406
    procedure InitHealth;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   407
    var p: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   408
        i, t: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   409
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   410
    p:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   411
    t:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   412
    while p <> nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   413
          begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   414
          for i:= 0 to cMaxHHIndex do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   415
              if p.Hedgehogs[i].Gear <> nil then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   416
                 begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   417
                 p.Hedgehogs[i].HealthRect.y:= t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   418
                 RenderHealth(p.Hedgehogs[i]);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   419
                 inc(t, p.Hedgehogs[i].HealthRect.h)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   420
                 end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   421
          p:= p.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   422
          end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   423
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   424
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   425
    procedure LoadGraves;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   426
    var p: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   427
        l: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   428
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   429
    p:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   430
    l:= 512;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   431
    while p <> nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   432
          begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   433
          dec(l, 32);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   434
          if p.GraveName = '' then p.GraveName:= 'Simple';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   435
          LoadToSurface(Pathz[ptGraves] + p.GraveName + '.png', StoreSurface, l, 512);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   436
          p.GraveRect.x:= l;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   437
          p.GraveRect.y:= 512;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   438
          p.GraveRect.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   439
          p.GraveRect.h:= 256;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   440
          p:= p.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   441
          end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   442
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   443
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   444
    procedure GetSkyColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   445
    var p: Longword;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   446
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   447
    if SDL_MustLock(StoreSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   448
       SDLTry(SDL_LockSurface(StoreSurface) >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   449
    p:= Longword(StoreSurface.pixels) + Word(StuffPoz[sSky].x) * StoreSurface.format.BytesPerPixel;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   450
    case StoreSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   451
         1: cSkyColor:= PByte(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   452
         2: cSkyColor:= PWord(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   453
         3: cSkyColor:= (PByte(p)^) or (PByte(p + 1)^ shl 8) or (PByte(p + 2)^ shl 16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   454
         4: cSkyColor:= PLongword(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   455
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   456
    if SDL_MustLock(StoreSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   457
       SDL_UnlockSurface(StoreSurface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   458
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   459
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   460
    procedure GetExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   461
    var f: textfile;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   462
        c: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   463
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   464
    s:= Pathz[ptThemeCurrent] + cThemeCFGFilename;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   465
    WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   466
    AssignFile(f, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   467
    {$I-}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   468
    Reset(f);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   469
    Readln(f, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   470
    Closefile(f);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   471
    {$I+}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   472
    TryDo(IOResult = 0, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   473
    WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   474
    val(s, cExplosionBorderColor, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   475
    if cFullScreen then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   476
    cExplosionBorderColor:= SDL_MapRGB(PixelFormat, (cExplosionBorderColor shr 16) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   477
                                                    (cExplosionBorderColor shr 8) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   478
                                                     cExplosionBorderColor and $FF)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   479
    else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   480
    cExplosionBorderColor:= SDL_MapRGB(LandSurface.format, (cExplosionBorderColor shr 16) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   481
                                                           (cExplosionBorderColor shr 8) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   482
                                                            cExplosionBorderColor and $FF)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   483
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   484
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   485
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   486
for fi:= Low(THWFont) to High(THWFont) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   487
    with Fontz[fi] do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   488
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   489
         s:= Pathz[ptFonts] + Name;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   490
         WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   491
         Handle:= TTF_OpenFont(PChar(s), Height);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   492
         TryDo(Handle <> nil, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   493
         WriteLnToConsole(msgOK)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   494
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   495
AddProgress;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   496
//s:= Pathz[ptMapCurrent] + cLandFileName;
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   497
//WriteToConsole(msgLoading + s + ' ');         
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   498
//tmpsurf:= IMG_Load(PChar(s));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   499
tmpsurf:= LandSurface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   500
TryDo(tmpsurf <> nil, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   501
if cFullScreen then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   502
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   503
   LandSurface:= SDL_DisplayFormat(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   504
   SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   505
   end else LandSurface:= tmpsurf;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   506
TryDo(SDL_SetColorKey(LandSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   507
WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   508
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   509
GetExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   510
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   511
AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   512
for i:= Low(TStuff) to High(TStuff) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   513
    LoadToSurface(Pathz[StuffLoadData[i].Path] + StuffLoadData[i].FileName, StoreSurface, StuffPoz[i].x, StuffPoz[i].y);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   514
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   515
AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   516
WriteNames(fnt16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   517
MakeCrosshairs;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   518
LoadGraves;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   519
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   520
GetSkyColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   521
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   522
AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   523
for ii:= Low(TSprite) to High(TSprite) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   524
    with SpritesData[ii] do
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   525
         Surface:= LoadImage(Pathz[Path] + FileName, hasAlpha);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   526
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   527
AddProgress;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   528
tmpsurf:= LoadImage(Pathz[ptGraphics] + cHHFileName, false);
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   529
TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   530
HHSurface:= SDL_DisplayFormat(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   531
SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   532
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   533
InitHealth;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   534
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   535
{$IFDEF DUMP}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   536
SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   537
SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   538
SDL_SaveBMP_RW(TempSurface, SDL_RWFromFile('TempSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   539
{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   540
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   541
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   542
procedure DrawFromRect(X, Y: integer; r: PSDL_Rect; SourceSurface, DestSurface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   543
var rr: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   544
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   545
rr.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   546
rr.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   547
rr.w:= r.w;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   548
rr.h:= r.h;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   549
if SDL_UpperBlit(SourceSurface, r, DestSurface, @rr) < 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   550
   begin
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   551
   OutError('Blit: ' + SDL_GetError, true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   552
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   553
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   554
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   555
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   556
procedure DrawGear(Stuff: TStuff; X, Y: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   557
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   558
DrawFromRect(X, Y, @StuffPoz[Stuff], StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   559
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   560
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   561
procedure DrawSpriteFromRect(r: TSDL_Rect; X, Y, Height, Position: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   562
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   563
r.y:= r.y + Height * Position;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   564
r.h:= Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   565
DrawFromRect(X, Y, @r, StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   566
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   567
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   568
procedure DrawSprite(Sprite: TSprite; X, Y, Position: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   569
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   570
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   571
r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   572
r.w:= SpritesData[Sprite].Width;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   573
r.y:= Position * SpritesData[Sprite].Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   574
r.h:= SpritesData[Sprite].Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   575
DrawFromRect(X, Y, @r, SpritesData[Sprite].Surface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   576
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   577
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   578
procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: integer; Surface: PSDL_Surface);
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   579
var r: TSDL_Rect;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   580
begin
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   581
r.x:= FrameX * SpritesData[Sprite].Width;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   582
r.w:= SpritesData[Sprite].Width;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   583
r.y:= FrameY * SpritesData[Sprite].Height;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   584
r.h:= SpritesData[Sprite].Height;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   585
DrawFromRect(X, Y, @r, SpritesData[Sprite].Surface, Surface)
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   586
end;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   587
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   588
procedure DXOutText(X, Y: Integer; Font: THWFont; s: string; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   589
var clr: TSDL_Color;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   590
    tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   591
    r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   592
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   593
r.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   594
r.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   595
SDL_GetRGB(cWhiteColor, PixelFormat, @clr.r, @clr.g, @clr.b);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   596
tmpsurf:= TTF_RenderText_Solid(Fontz[Font].Handle, PChar(s), clr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   597
SDL_UpperBlit(tmpsurf, nil, Surface, @r);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   598
SDL_FreeSurface(tmpsurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   599
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   600
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   601
procedure DrawLand(X, Y: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   602
const r: TSDL_Rect = (x: 0; y: 0; w: 2048; h: 1024);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   603
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   604
DrawFromRect(X, Y, @r, LandSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   605
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   606
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   607
procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   608
begin
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   609
DrawFromRect(X, Y, Rect, StoreSurface, Surface)
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   610
end;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   611
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   612
procedure DrawCaption(X, Y: integer; Rect: TSDL_Rect; Surface: PSDL_Surface; const fromTempSurf: boolean = false);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   613
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   614
if fromTempSurf then DrawFromRect(X - (Rect.w) div 2, Y, @Rect, TempSurface,  Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   615
                else DrawFromRect(X - (Rect.w) div 2, Y, @Rect, StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   616
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   617
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   618
procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   619
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   620
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   621
r.x:= Step * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   622
r.y:= Pos * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   623
if Dir = -1 then r.x:= cHHSurfaceWidth - 32 - r.x;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   624
r.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   625
r.h:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   626
DrawFromRect(X, Y, @r, HHSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   627
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   628
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   629
procedure StoreRelease;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   630
var ii: TSprite;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   631
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   632
for ii:= Low(TSprite) to High(TSprite) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   633
    SDL_FreeSurface(SpritesData[ii].Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   634
SDL_FreeSurface(  HHSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   635
SDL_FreeSurface(TempSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   636
SDL_FreeSurface(LandSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   637
SDL_FreeSurface(StoreSurface )
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   638
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   639
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   640
procedure RenderHealth(var Hedgehog: THedgehog);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   641
var s: string[15];
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   642
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   643
str(Hedgehog.Gear.Health, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   644
Hedgehog.HealthRect:= WriteInRoundRect(TempSurface, Hedgehog.HealthRect.x, Hedgehog.HealthRect.y, Hedgehog.Team.Color, fnt16, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   645
if Hedgehog.Gear.Damage > 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   646
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   647
   str(Hedgehog.Gear.Damage, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   648
   Hedgehog.HealthTagRect:= WriteInRoundRect(TempSurface, Hedgehog.HealthRect.x + Hedgehog.HealthRect.w, Hedgehog.HealthRect.y, Hedgehog.Team.Color, fnt16, s)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   649
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   650
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   651
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   652
function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   653
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   654
Result:= WriteInRoundRect(TempSurface, 64, Pos * Fontz[fntBig].Height, Color, fntBig, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   655
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   656
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   657
procedure AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   658
const Step: Longword = 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   659
      ProgrSurf: PSDL_Surface = nil;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   660
      MaxCalls = 10; // MaxCalls should be the count of calls to AddProgress to prevent memory leakage
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   661
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   662
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   663
if Step = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   664
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   665
   WriteToConsole(msgLoading + 'progress sprite... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   666
   ProgrSurf:= IMG_Load(PChar(string('Data/Graphics/BigDigits.png')));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   667
   SDLTry(ProgrSurf <> nil, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   668
   WriteLnToConsole(msgOK)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   669
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   670
SDL_FillRect(SDLPrimSurface, nil, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   671
r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   672
r.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   673
r.h:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   674
r.y:= Step * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   675
DrawFromRect(cScreenWidth div 2 - 16, cScreenHeight div 2 - 16, @r, ProgrSurf, SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   676
SDL_Flip(SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   677
inc(Step);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   678
if Step = MaxCalls then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   679
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   680
   WriteLnToConsole('Freeing progress surface... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   681
   SDL_FreeSurface(ProgrSurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   682
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   683
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   684
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   685
function  LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface;
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   686
var tmpsurf: PSDL_Surface;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   687
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   688
WriteToConsole(msgLoading + filename + '... ');
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   689
tmpsurf:= IMG_Load(PChar(filename));
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   690
TryDo(tmpsurf <> nil, msgFailed, true);
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   691
TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   692
if cFullScreen then
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   693
   begin
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   694
   if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf)
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   695
               else Result:= SDL_DisplayFormat(tmpsurf);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   696
   SDL_FreeSurface(tmpsurf);
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   697
   end else Result:= tmpsurf;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   698
WriteLnToConsole(msgOK)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   699
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   700
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   701
end.