hedgewars/uStore.pas
author unc0rr
Sun, 15 Jan 2006 14:14:12 +0000
changeset 49 3afe33c1cf06
parent 47 8daf1ee0b9a3
child 53 0e27949850e3
permissions -rw-r--r--
- Teams health bars sorting - Fixed slow walking on hedgehog - Fixed accidently disabled bots' ammo - Fixed exception when runnig engine without command line parameters - One more template
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;
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 47
diff changeset
   346
        drY: integer;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   347
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   348
    r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   349
    r.y:= 272;
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 47
diff changeset
   350
    drY:= cSCreenHeight - 4;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   351
    Team:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   352
    while Team<>nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   353
      begin
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   354
      r.w:= 104;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   355
      r:= WriteInRoundRect(StoreSurface, r.x, r.y, Team.Color, Font, Team.TeamName);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   356
      Team.NameRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   357
      inc(r.y, r.h);
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   358
      r.w:= cTeamHealthWidth + 5;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   359
      DrawRoundRect(@r, cWhiteColor, cColorNearBlack, StoreSurface);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   360
      Team.HealthRect:= r;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   361
      rr:= r;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   362
      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
   363
      DrawRoundRect(@rr, Team.Color, Team.Color, StoreSurface);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   364
      inc(r.y, r.h);
49
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 47
diff changeset
   365
      dec(drY, r.h + 2);
3afe33c1cf06 - Teams health bars sorting
unc0rr
parents: 47
diff changeset
   366
      Team.DrawHealthY:= drY;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   367
      for i:= 0 to 7 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   368
          if Team.Hedgehogs[i].Gear<>nil then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   369
             begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   370
             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
   371
             Team.Hedgehogs[i].NameRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   372
             inc(r.y, r.h)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   373
             end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   374
      Team:= Team.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   375
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   376
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   377
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   378
    procedure MakeCrossHairs;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   379
    var Team: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   380
        r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   381
        tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   382
        s: string;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   383
        TransColor: Longword;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   384
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   385
    r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   386
    r.y:= 256;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   387
    r.w:= 16;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   388
    r.h:= 16;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   389
    s:= Pathz[ptGraphics] + cCHFileName;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   390
    WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   391
    tmpsurf:= IMG_Load(PChar(s));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   392
    TryDo(tmpsurf <> nil, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   393
    WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   394
    TransColor:= SDL_MapRGB(tmpsurf.format, $FF, $FF, $FF);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   395
    TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, TransColor) = 0, errmsgTransparentSet, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   396
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   397
    Team:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   398
    while Team<>nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   399
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   400
      SDL_FillRect(StoreSurface, @r, Team.Color);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   401
      SDL_UpperBlit(tmpsurf, nil, StoreSurface, @r);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   402
      Team.CrossHairRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   403
      inc(r.x, 16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   404
      Team:= Team.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   405
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   406
      
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   407
    SDL_FreeSurface(tmpsurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   408
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   409
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   410
    procedure InitHealth;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   411
    var p: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   412
        i, t: integer;
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
    p:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   415
    t:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   416
    while p <> nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   417
          begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   418
          for i:= 0 to cMaxHHIndex do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   419
              if p.Hedgehogs[i].Gear <> nil then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   420
                 begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   421
                 p.Hedgehogs[i].HealthRect.y:= t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   422
                 RenderHealth(p.Hedgehogs[i]);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   423
                 inc(t, p.Hedgehogs[i].HealthRect.h)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   424
                 end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   425
          p:= p.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   426
          end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   427
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   428
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   429
    procedure LoadGraves;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   430
    var p: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   431
        l: integer;
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
    p:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   434
    l:= 512;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   435
    while p <> nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   436
          begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   437
          dec(l, 32);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   438
          if p.GraveName = '' then p.GraveName:= 'Simple';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   439
          LoadToSurface(Pathz[ptGraves] + p.GraveName + '.png', StoreSurface, l, 512);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   440
          p.GraveRect.x:= l;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   441
          p.GraveRect.y:= 512;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   442
          p.GraveRect.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   443
          p.GraveRect.h:= 256;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   444
          p:= p.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   445
          end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   446
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   447
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   448
    procedure GetSkyColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   449
    var p: Longword;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   450
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   451
    if SDL_MustLock(StoreSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   452
       SDLTry(SDL_LockSurface(StoreSurface) >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   453
    p:= Longword(StoreSurface.pixels) + Word(StuffPoz[sSky].x) * StoreSurface.format.BytesPerPixel;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   454
    case StoreSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   455
         1: cSkyColor:= PByte(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   456
         2: cSkyColor:= PWord(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   457
         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
   458
         4: cSkyColor:= PLongword(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   459
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   460
    if SDL_MustLock(StoreSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   461
       SDL_UnlockSurface(StoreSurface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   462
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   463
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   464
    procedure GetExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   465
    var f: textfile;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   466
        c: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   467
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   468
    s:= Pathz[ptThemeCurrent] + cThemeCFGFilename;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   469
    WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   470
    AssignFile(f, s);
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
    Reset(f);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   473
    Readln(f, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   474
    Closefile(f);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   475
    {$I+}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   476
    TryDo(IOResult = 0, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   477
    WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   478
    val(s, cExplosionBorderColor, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   479
    if cFullScreen then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   480
    cExplosionBorderColor:= SDL_MapRGB(PixelFormat, (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
    else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   484
    cExplosionBorderColor:= SDL_MapRGB(LandSurface.format, (cExplosionBorderColor shr 16) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   485
                                                           (cExplosionBorderColor shr 8) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   486
                                                            cExplosionBorderColor and $FF)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   487
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   488
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   489
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   490
for fi:= Low(THWFont) to High(THWFont) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   491
    with Fontz[fi] do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   492
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   493
         s:= Pathz[ptFonts] + Name;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   494
         WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   495
         Handle:= TTF_OpenFont(PChar(s), Height);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   496
         TryDo(Handle <> nil, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   497
         WriteLnToConsole(msgOK)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   498
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   499
AddProgress;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   500
//s:= Pathz[ptMapCurrent] + cLandFileName;
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   501
//WriteToConsole(msgLoading + s + ' ');         
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   502
//tmpsurf:= IMG_Load(PChar(s));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   503
tmpsurf:= LandSurface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   504
TryDo(tmpsurf <> nil, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   505
if cFullScreen then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   506
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   507
   LandSurface:= SDL_DisplayFormat(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   508
   SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   509
   end else LandSurface:= tmpsurf;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   510
TryDo(SDL_SetColorKey(LandSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   511
WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   512
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   513
GetExplosionBorderColor;
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
for i:= Low(TStuff) to High(TStuff) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   517
    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
   518
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   519
AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   520
WriteNames(fnt16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   521
MakeCrosshairs;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   522
LoadGraves;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   523
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   524
GetSkyColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   525
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   526
AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   527
for ii:= Low(TSprite) to High(TSprite) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   528
    with SpritesData[ii] do
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   529
         Surface:= LoadImage(Pathz[Path] + FileName, hasAlpha);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   530
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   531
AddProgress;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   532
tmpsurf:= LoadImage(Pathz[ptGraphics] + cHHFileName, false);
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   533
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
   534
HHSurface:= SDL_DisplayFormat(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   535
SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   536
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   537
InitHealth;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   538
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   539
{$IFDEF DUMP}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   540
SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   541
SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   542
SDL_SaveBMP_RW(TempSurface, SDL_RWFromFile('TempSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   543
{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   544
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   545
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   546
procedure DrawFromRect(X, Y: integer; r: PSDL_Rect; SourceSurface, DestSurface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   547
var rr: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   548
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   549
rr.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   550
rr.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   551
rr.w:= r.w;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   552
rr.h:= r.h;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   553
if SDL_UpperBlit(SourceSurface, r, DestSurface, @rr) < 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   554
   begin
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   555
   OutError('Blit: ' + SDL_GetError, true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   556
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   557
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   558
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   559
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   560
procedure DrawGear(Stuff: TStuff; X, Y: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   561
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   562
DrawFromRect(X, Y, @StuffPoz[Stuff], StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   563
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   564
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   565
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
   566
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   567
r.y:= r.y + Height * Position;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   568
r.h:= Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   569
DrawFromRect(X, Y, @r, StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   570
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   571
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   572
procedure DrawSprite(Sprite: TSprite; X, Y, Position: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   573
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   574
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   575
r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   576
r.w:= SpritesData[Sprite].Width;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   577
r.y:= Position * SpritesData[Sprite].Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   578
r.h:= SpritesData[Sprite].Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   579
DrawFromRect(X, Y, @r, SpritesData[Sprite].Surface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   580
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   581
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   582
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
   583
var r: TSDL_Rect;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   584
begin
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   585
r.x:= FrameX * SpritesData[Sprite].Width;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   586
r.w:= SpritesData[Sprite].Width;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   587
r.y:= FrameY * SpritesData[Sprite].Height;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   588
r.h:= SpritesData[Sprite].Height;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   589
DrawFromRect(X, Y, @r, SpritesData[Sprite].Surface, Surface)
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   590
end;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   591
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   592
procedure DXOutText(X, Y: Integer; Font: THWFont; s: string; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   593
var clr: TSDL_Color;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   594
    tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   595
    r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   596
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   597
r.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   598
r.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   599
SDL_GetRGB(cWhiteColor, PixelFormat, @clr.r, @clr.g, @clr.b);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   600
tmpsurf:= TTF_RenderText_Solid(Fontz[Font].Handle, PChar(s), clr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   601
SDL_UpperBlit(tmpsurf, nil, Surface, @r);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   602
SDL_FreeSurface(tmpsurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   603
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   604
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   605
procedure DrawLand(X, Y: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   606
const r: TSDL_Rect = (x: 0; y: 0; w: 2048; h: 1024);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   607
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   608
DrawFromRect(X, Y, @r, LandSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   609
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   610
47
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   611
procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface);
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   612
begin
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   613
DrawFromRect(X, Y, Rect, StoreSurface, Surface)
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   614
end;
8daf1ee0b9a3 Show team health bars, without sorting yet
unc0rr
parents: 43
diff changeset
   615
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   616
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
   617
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   618
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
   619
                else DrawFromRect(X - (Rect.w) div 2, Y, @Rect, StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   620
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   621
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   622
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
   623
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   624
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   625
r.x:= Step * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   626
r.y:= Pos * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   627
if Dir = -1 then r.x:= cHHSurfaceWidth - 32 - r.x;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   628
r.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   629
r.h:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   630
DrawFromRect(X, Y, @r, HHSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   631
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   632
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   633
procedure StoreRelease;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   634
var ii: TSprite;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   635
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   636
for ii:= Low(TSprite) to High(TSprite) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   637
    SDL_FreeSurface(SpritesData[ii].Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   638
SDL_FreeSurface(  HHSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   639
SDL_FreeSurface(TempSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   640
SDL_FreeSurface(LandSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   641
SDL_FreeSurface(StoreSurface )
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   642
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   643
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   644
procedure RenderHealth(var Hedgehog: THedgehog);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   645
var s: string[15];
4
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.Health, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   648
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
   649
if Hedgehog.Gear.Damage > 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   650
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   651
   str(Hedgehog.Gear.Damage, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   652
   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
   653
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   654
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   655
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   656
function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   657
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   658
Result:= WriteInRoundRect(TempSurface, 64, Pos * Fontz[fntBig].Height, Color, fntBig, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   659
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   660
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   661
procedure AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   662
const Step: Longword = 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   663
      ProgrSurf: PSDL_Surface = nil;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   664
      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
   665
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   666
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   667
if Step = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   668
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   669
   WriteToConsole(msgLoading + 'progress sprite... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   670
   ProgrSurf:= IMG_Load(PChar(string('Data/Graphics/BigDigits.png')));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   671
   SDLTry(ProgrSurf <> nil, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   672
   WriteLnToConsole(msgOK)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   673
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   674
SDL_FillRect(SDLPrimSurface, nil, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   675
r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   676
r.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   677
r.h:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   678
r.y:= Step * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   679
DrawFromRect(cScreenWidth div 2 - 16, cScreenHeight div 2 - 16, @r, ProgrSurf, SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   680
SDL_Flip(SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   681
inc(Step);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   682
if Step = MaxCalls then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   683
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   684
   WriteLnToConsole('Freeing progress surface... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   685
   SDL_FreeSurface(ProgrSurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   686
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   687
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   688
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   689
function  LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface;
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   690
var tmpsurf: PSDL_Surface;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   691
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   692
WriteToConsole(msgLoading + filename + '... ');
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   693
tmpsurf:= IMG_Load(PChar(filename));
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   694
TryDo(tmpsurf <> nil, msgFailed, true);
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   695
TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   696
if cFullScreen then
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   697
   begin
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   698
   if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf)
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   699
               else Result:= SDL_DisplayFormat(tmpsurf);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   700
   SDL_FreeSurface(tmpsurf);
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   701
   end else Result:= tmpsurf;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   702
WriteLnToConsole(msgOK)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   703
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   704
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   705
end.