hedgewars/uStore.pas
author unc0rr
Tue, 10 Jan 2006 19:53:18 +0000
changeset 43 e297fea1a2f3
parent 42 72ffe21f027c
child 47 8daf1ee0b9a3
permissions -rw-r--r--
- Removed dark pixels on the corners of health case - Cleaned up dynamite code - Dynamite sprite - Frontend shows error messages from engine (except IPC-related :) ) - changed IPC-related stuff in frontend
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
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     3
 * Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com>
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);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    54
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
    55
procedure DrawExplosion(X, Y, Radius: integer);
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 38
diff changeset
    56
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
    57
procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    58
procedure RenderHealth(var Hedgehog: THedgehog);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    59
function  RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    60
procedure AddProgress;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
    61
function  LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    62
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    63
var PixelFormat: PSDL_PixelFormat;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    64
 SDLPrimSurface: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    65
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    66
implementation
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    67
uses uMisc, uIO, uConsole, uLand;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    68
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    69
var StoreSurface,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    70
     TempSurface,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    71
       HHSurface: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    72
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    73
procedure DrawExplosion(X, Y, Radius: integer);
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
    74
var ty, tx, p: integer;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    75
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    76
for ty:= max(-Radius, -y) to min(radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    77
    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
    78
        Land[ty + y, tx]:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    79
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    80
if SDL_MustLock(LandSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    81
   SDLTry(SDL_LockSurface(LandSurface) >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    82
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
    83
p:= integer(LandSurface.pixels);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    84
case LandSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    85
     1: ;// not supported
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    86
     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    87
            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
    88
                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    89
     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    90
            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
    91
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    92
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    93
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    94
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    95
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    96
     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    97
            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
    98
                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    99
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   100
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   101
inc(Radius, 4);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   102
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   103
case LandSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   104
     1: ;// not supported
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   105
     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   106
            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
   107
               if Land[y + ty, tx] <> 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   108
                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   109
     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   110
            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
   111
               if Land[y + ty, tx] <> 0 then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   112
                begin
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   113
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   114
                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
   115
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   116
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   117
     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   118
            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
   119
               if Land[y + ty, tx] <> 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   120
                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   121
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   122
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   123
if SDL_MustLock(LandSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   124
   SDL_UnlockSurface(LandSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   125
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   126
SDL_UpdateRect(LandSurface, X - Radius, Y - Radius, Radius * 2, Radius * 2)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   127
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   128
42
72ffe21f027c - Fixed console behavior
unc0rr
parents: 38
diff changeset
   129
procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   130
var tx, ty, i, p: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   131
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   132
if SDL_MustLock(LandSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   133
   SDL_LockSurface(LandSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   134
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   135
p:= integer(LandSurface.pixels);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   136
for i:= 0 to Pred(Count) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   137
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   138
    case LandSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   139
     1: ;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   140
     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   141
            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
   142
                PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   143
     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   144
            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
   145
                begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   146
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   147
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 1)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   148
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   149
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   150
     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   151
            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
   152
                PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   153
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   154
    inc(y, dY)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   155
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   156
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   157
inc(Radius, 4);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   158
dec(y, Count*dY);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   159
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   160
for i:= 0 to Pred(Count) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   161
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   162
    case LandSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   163
     1: ;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   164
     2: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   165
            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
   166
               if Land[y + ty, tx] <> 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   167
                  PWord(p + LandSurface.pitch*(y + ty) + tx * 2)^:= cExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   168
     3: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   169
            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
   170
               if Land[y + ty, tx] <> 0 then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   171
                begin
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   172
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 0)^:= cExplosionBorderColor and $FF;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   173
                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
   174
                PByte(p + LandSurface.pitch*(y + ty) + tx * 3 + 2)^:= (cExplosionBorderColor shr 16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   175
                end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   176
     4: for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   177
            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
   178
               if Land[y + ty, tx] <> 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   179
                   PLongword(p + LandSurface.pitch*(y + ty) + tx * 4)^:= cExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   180
     end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   181
    inc(y, dY)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   182
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   183
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   184
if SDL_MustLock(LandSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   185
   SDL_UnlockSurface(LandSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   186
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   187
38
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   188
//
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   189
//  - (dX, dY) - direction, vector of length = 0.5
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   190
//
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   191
procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   192
var nx, ny: real;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   193
    i, t, tx, ty, p: integer;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   194
begin  // (-dY, dX) is (dX, dY) turned by PI/2
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   195
if SDL_MustLock(LandSurface) then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   196
   SDL_LockSurface(LandSurface);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   197
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   198
nx:= X + dY * (HalfWidth + 8);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   199
ny:= Y - dX * (HalfWidth + 8);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   200
p:= integer(LandSurface.pixels);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   201
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   202
for i:= 0 to 7 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   203
    begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   204
    X:= nx - 8 * dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   205
    Y:= ny - 8 * dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   206
    for t:= -8 to ticks + 8 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   207
        {$include tunsetborder.inc}
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   208
    nx:= nx - dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   209
    ny:= ny + dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   210
    end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   211
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   212
for i:= -HalfWidth to HalfWidth do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   213
    begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   214
    X:= nx - dX * 8;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   215
    Y:= ny - dY * 8;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   216
    for t:= 0 to 7 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   217
        {$include tunsetborder.inc}
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   218
    X:= nx;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   219
    Y:= ny;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   220
    for t:= 0 to ticks do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   221
        begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   222
        X:= X + dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   223
        Y:= Y + dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   224
        tx:= round(X);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   225
        ty:= round(Y);
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   226
        if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   227
           begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   228
           Land[ty, tx]:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   229
           case LandSurface.format.BytesPerPixel of
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   230
                1: ;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   231
                2: PWord(p + LandSurface.pitch * ty + tx * 2)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   232
                3: begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   233
                   PByte(p + LandSurface.pitch * ty + tx * 3 + 0)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   234
                   PByte(p + LandSurface.pitch * ty + tx * 3 + 1)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   235
                   PByte(p + LandSurface.pitch * ty + tx * 3 + 2)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   236
                   end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   237
                4: PLongword(p + LandSurface.pitch * ty + tx * 4)^:= 0;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   238
                end
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
    for t:= 0 to 7 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   242
        {$include tunsetborder.inc}
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   243
    nx:= nx - dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   244
    ny:= ny + dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   245
    end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   246
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   247
for i:= 0 to 7 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   248
    begin
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   249
    X:= nx - 8 * dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   250
    Y:= ny - 8 * dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   251
    for t:= -8 to ticks + 8 do
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   252
        {$include tunsetborder.inc}
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   253
    nx:= nx - dY;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   254
    ny:= ny + dX;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   255
    end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   256
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   257
if SDL_MustLock(LandSurface) then
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   258
   SDL_UnlockSurface(LandSurface)
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   259
end;
c1ec4b15d70e Better Desert Eagle and Shotgun
unc0rr
parents: 37
diff changeset
   260
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   261
procedure StoreInit;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   262
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   263
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
   264
TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true);
37
2b7f2a43b999 - Properly get seed in net game
unc0rr
parents: 35
diff changeset
   265
SDL_FillRect(StoreSurface, nil, 0);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   266
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   267
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
   268
TryDo(  TempSurface <> nil, errmsgCreateSurface + ': temp'  , true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   269
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   270
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
   271
//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
   272
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
   273
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   274
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   275
procedure LoadToSurface(Filename: String; Surface: PSDL_Surface; X, Y: integer);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   276
var tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   277
    rr: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   278
begin
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   279
  tmpsurf:= LoadImage(Filename, false);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   280
  rr.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   281
  rr.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   282
  SDL_UpperBlit(tmpsurf, nil, Surface, @rr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   283
  SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   284
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   285
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   286
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
   287
var w, h: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   288
    tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   289
    clr: TSDL_Color;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   290
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   291
TTF_SizeText(Fontz[Font].Handle, PChar(s), w, h);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   292
Result.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   293
Result.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   294
Result.w:= w + 6;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   295
Result.h:= h + 6;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   296
SDL_FillRect(Surface, @Result, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   297
Result.w:= 1;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   298
Result.y:= Y + 1;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   299
Result.h:= h + 4;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   300
SDL_FillRect(Surface, @Result, cWhiteColor);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   301
Result.x:= X + w + 5;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   302
SDL_FillRect(Surface, @Result, cWhiteColor);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   303
Result.x:= X + 1;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   304
Result.w:= w + 4;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   305
Result.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   306
Result.h:= 1;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   307
SDL_FillRect(Surface, @Result, cWhiteColor);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   308
Result.y:= Y + h + 5;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   309
SDL_FillRect(Surface, @Result, cWhiteColor);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   310
Result.x:= X + 1;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   311
Result.y:= Y + 1;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   312
Result.h:= h + 4;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   313
SDL_FillRect(Surface, @Result, cColorNearBlack);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   314
SDL_GetRGB(Color, Surface.format, @clr.r, @clr.g, @clr.b);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   315
tmpsurf:= TTF_RenderText_Blended(Fontz[Font].Handle, PChar(s), clr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   316
Result.x:= X + 3;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   317
Result.y:= Y + 3;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   318
SDL_UpperBlit(tmpsurf, nil, Surface, @Result);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   319
SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   320
Result.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   321
Result.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   322
Result.w:= w + 6;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   323
Result.h:= h + 6
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   324
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   325
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   326
procedure StoreLoad;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   327
var i: TStuff;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   328
    ii: TSprite;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   329
    fi: THWFont;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   330
    s: string;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   331
    tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   332
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   333
    procedure WriteNames(Font: THWFont);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   334
    var Team: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   335
        i: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   336
        r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   337
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   338
    r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   339
    r.y:= 272;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   340
    Team:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   341
    while Team<>nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   342
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   343
      r.w:= 1968;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   344
      r:= WriteInRoundRect(StoreSurface, r.x, r.y, Team.Color, Font, Team.TeamName);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   345
      Team.NameRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   346
      inc(r.y, r.h);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   347
      for i:= 0 to 7 do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   348
          if Team.Hedgehogs[i].Gear<>nil then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   349
             begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   350
             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
   351
             Team.Hedgehogs[i].NameRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   352
             inc(r.y, r.h)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   353
             end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   354
      Team:= Team.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   355
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   356
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   357
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   358
    procedure MakeCrossHairs;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   359
    var Team: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   360
        r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   361
        tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   362
        s: string;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   363
        TransColor: Longword;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   364
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   365
    r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   366
    r.y:= 256;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   367
    r.w:= 16;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   368
    r.h:= 16;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   369
    s:= Pathz[ptGraphics] + cCHFileName;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   370
    WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   371
    tmpsurf:= IMG_Load(PChar(s));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   372
    TryDo(tmpsurf <> nil, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   373
    WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   374
    TransColor:= SDL_MapRGB(tmpsurf.format, $FF, $FF, $FF);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   375
    TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, TransColor) = 0, errmsgTransparentSet, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   376
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   377
    Team:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   378
    while Team<>nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   379
      begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   380
      SDL_FillRect(StoreSurface, @r, Team.Color);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   381
      SDL_UpperBlit(tmpsurf, nil, StoreSurface, @r);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   382
      Team.CrossHairRect:= r;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   383
      inc(r.x, 16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   384
      Team:= Team.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   385
      end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   386
      
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   387
    SDL_FreeSurface(tmpsurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   388
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   389
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   390
    procedure InitHealth;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   391
    var p: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   392
        i, t: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   393
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   394
    p:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   395
    t:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   396
    while p <> nil do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   397
          begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   398
          for i:= 0 to cMaxHHIndex do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   399
              if p.Hedgehogs[i].Gear <> nil then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   400
                 begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   401
                 p.Hedgehogs[i].HealthRect.y:= t;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   402
                 RenderHealth(p.Hedgehogs[i]);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   403
                 inc(t, p.Hedgehogs[i].HealthRect.h)
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
          p:= p.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   406
          end
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   407
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   408
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   409
    procedure LoadGraves;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   410
    var p: PTeam;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   411
        l: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   412
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   413
    p:= TeamsList;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   414
    l:= 512;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   415
    while p <> nil do
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
          dec(l, 32);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   418
          if p.GraveName = '' then p.GraveName:= 'Simple';
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   419
          LoadToSurface(Pathz[ptGraves] + p.GraveName + '.png', StoreSurface, l, 512);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   420
          p.GraveRect.x:= l;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   421
          p.GraveRect.y:= 512;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   422
          p.GraveRect.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   423
          p.GraveRect.h:= 256;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   424
          p:= p.Next
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   425
          end
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
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   428
    procedure GetSkyColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   429
    var p: Longword;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   430
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   431
    if SDL_MustLock(StoreSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   432
       SDLTry(SDL_LockSurface(StoreSurface) >= 0, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   433
    p:= Longword(StoreSurface.pixels) + Word(StuffPoz[sSky].x) * StoreSurface.format.BytesPerPixel;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   434
    case StoreSurface.format.BytesPerPixel of
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   435
         1: cSkyColor:= PByte(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   436
         2: cSkyColor:= PWord(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   437
         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
   438
         4: cSkyColor:= PLongword(p)^;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   439
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   440
    if SDL_MustLock(StoreSurface) then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   441
       SDL_UnlockSurface(StoreSurface)
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 GetExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   445
    var f: textfile;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   446
        c: integer;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   447
    begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   448
    s:= Pathz[ptThemeCurrent] + cThemeCFGFilename;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   449
    WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   450
    AssignFile(f, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   451
    {$I-}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   452
    Reset(f);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   453
    Readln(f, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   454
    Closefile(f);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   455
    {$I+}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   456
    TryDo(IOResult = 0, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   457
    WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   458
    val(s, cExplosionBorderColor, c);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   459
    if cFullScreen then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   460
    cExplosionBorderColor:= SDL_MapRGB(PixelFormat, (cExplosionBorderColor shr 16) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   461
                                                    (cExplosionBorderColor shr 8) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   462
                                                     cExplosionBorderColor and $FF)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   463
    else
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   464
    cExplosionBorderColor:= SDL_MapRGB(LandSurface.format, (cExplosionBorderColor shr 16) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   465
                                                           (cExplosionBorderColor shr 8) and $FF,
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   466
                                                            cExplosionBorderColor and $FF)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   467
    end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   468
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   469
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   470
for fi:= Low(THWFont) to High(THWFont) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   471
    with Fontz[fi] do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   472
         begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   473
         s:= Pathz[ptFonts] + Name;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   474
         WriteToConsole(msgLoading + s + ' ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   475
         Handle:= TTF_OpenFont(PChar(s), Height);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   476
         TryDo(Handle <> nil, 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
         end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   479
AddProgress;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   480
//s:= Pathz[ptMapCurrent] + cLandFileName;
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   481
//WriteToConsole(msgLoading + s + ' ');         
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   482
//tmpsurf:= IMG_Load(PChar(s));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   483
tmpsurf:= LandSurface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   484
TryDo(tmpsurf <> nil, msgFailed, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   485
if cFullScreen then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   486
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   487
   LandSurface:= SDL_DisplayFormat(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   488
   SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   489
   end else LandSurface:= tmpsurf;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   490
TryDo(SDL_SetColorKey(LandSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   491
WriteLnToConsole(msgOK);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   492
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   493
GetExplosionBorderColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   494
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   495
AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   496
for i:= Low(TStuff) to High(TStuff) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   497
    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
   498
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   499
AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   500
WriteNames(fnt16);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   501
MakeCrosshairs;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   502
LoadGraves;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   503
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   504
GetSkyColor;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   505
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   506
AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   507
for ii:= Low(TSprite) to High(TSprite) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   508
    with SpritesData[ii] do
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   509
         Surface:= LoadImage(Pathz[Path] + FileName, hasAlpha);
4
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;
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   512
tmpsurf:= LoadImage(Pathz[ptGraphics] + cHHFileName, false);
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   513
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
   514
HHSurface:= SDL_DisplayFormat(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   515
SDL_FreeSurface(tmpsurf);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   516
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   517
InitHealth;
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
{$IFDEF DUMP}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   520
SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   521
SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   522
SDL_SaveBMP_RW(TempSurface, SDL_RWFromFile('TempSurface.bmp', 'wb'), 1);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   523
{$ENDIF}
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   524
end;
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
procedure DrawFromRect(X, Y: integer; r: PSDL_Rect; SourceSurface, DestSurface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   527
var rr: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   528
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   529
rr.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   530
rr.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   531
rr.w:= r.w;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   532
rr.h:= r.h;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   533
if SDL_UpperBlit(SourceSurface, r, DestSurface, @rr) < 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   534
   begin
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   535
   OutError('Blit: ' + SDL_GetError, true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   536
   exit
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   537
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   538
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   539
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   540
procedure DrawGear(Stuff: TStuff; X, Y: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   541
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   542
DrawFromRect(X, Y, @StuffPoz[Stuff], StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   543
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   544
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   545
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
   546
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   547
r.y:= r.y + Height * Position;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   548
r.h:= Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   549
DrawFromRect(X, Y, @r, StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   550
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   551
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   552
procedure DrawSprite(Sprite: TSprite; X, Y, Position: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   553
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   554
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   555
r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   556
r.w:= SpritesData[Sprite].Width;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   557
r.y:= Position * SpritesData[Sprite].Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   558
r.h:= SpritesData[Sprite].Height;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   559
DrawFromRect(X, Y, @r, SpritesData[Sprite].Surface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   560
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   561
43
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   562
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
   563
var r: TSDL_Rect;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   564
begin
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   565
r.x:= FrameX * SpritesData[Sprite].Width;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   566
r.w:= SpritesData[Sprite].Width;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   567
r.y:= FrameY * SpritesData[Sprite].Height;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   568
r.h:= SpritesData[Sprite].Height;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   569
DrawFromRect(X, Y, @r, SpritesData[Sprite].Surface, Surface)
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   570
end;
e297fea1a2f3 - Removed dark pixels on the corners of health case
unc0rr
parents: 42
diff changeset
   571
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   572
procedure DXOutText(X, Y: Integer; Font: THWFont; s: string; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   573
var clr: TSDL_Color;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   574
    tmpsurf: PSDL_Surface;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   575
    r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   576
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   577
r.x:= X;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   578
r.y:= Y;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   579
SDL_GetRGB(cWhiteColor, PixelFormat, @clr.r, @clr.g, @clr.b);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   580
tmpsurf:= TTF_RenderText_Solid(Fontz[Font].Handle, PChar(s), clr);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   581
SDL_UpperBlit(tmpsurf, nil, Surface, @r);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   582
SDL_FreeSurface(tmpsurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   583
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   584
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   585
procedure DrawLand(X, Y: integer; Surface: PSDL_Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   586
const r: TSDL_Rect = (x: 0; y: 0; w: 2048; h: 1024);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   587
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   588
DrawFromRect(X, Y, @r, LandSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   589
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   590
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   591
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
   592
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   593
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
   594
                else DrawFromRect(X - (Rect.w) div 2, Y, @Rect, StoreSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   595
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   596
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   597
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
   598
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   599
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   600
r.x:= Step * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   601
r.y:= Pos * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   602
if Dir = -1 then r.x:= cHHSurfaceWidth - 32 - r.x;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   603
r.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   604
r.h:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   605
DrawFromRect(X, Y, @r, HHSurface, Surface)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   606
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   607
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   608
procedure StoreRelease;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   609
var ii: TSprite;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   610
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   611
for ii:= Low(TSprite) to High(TSprite) do
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   612
    SDL_FreeSurface(SpritesData[ii].Surface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   613
SDL_FreeSurface(  HHSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   614
SDL_FreeSurface(TempSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   615
SDL_FreeSurface(LandSurface  );
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   616
SDL_FreeSurface(StoreSurface )
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   617
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   618
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   619
procedure RenderHealth(var Hedgehog: THedgehog);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   620
var s: string[15];
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   621
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   622
str(Hedgehog.Gear.Health, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   623
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
   624
if Hedgehog.Gear.Damage > 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   625
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   626
   str(Hedgehog.Gear.Damage, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   627
   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
   628
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   629
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   630
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   631
function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   632
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   633
Result:= WriteInRoundRect(TempSurface, 64, Pos * Fontz[fntBig].Height, Color, fntBig, s);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   634
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   635
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   636
procedure AddProgress;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   637
const Step: Longword = 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   638
      ProgrSurf: PSDL_Surface = nil;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   639
      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
   640
var r: TSDL_Rect;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   641
begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   642
if Step = 0 then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   643
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   644
   WriteToConsole(msgLoading + 'progress sprite... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   645
   ProgrSurf:= IMG_Load(PChar(string('Data/Graphics/BigDigits.png')));
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   646
   SDLTry(ProgrSurf <> nil, true);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   647
   WriteLnToConsole(msgOK)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   648
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   649
SDL_FillRect(SDLPrimSurface, nil, 0);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   650
r.x:= 0;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   651
r.w:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   652
r.h:= 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   653
r.y:= Step * 32;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   654
DrawFromRect(cScreenWidth div 2 - 16, cScreenHeight div 2 - 16, @r, ProgrSurf, SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   655
SDL_Flip(SDLPrimSurface);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   656
inc(Step);
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   657
if Step = MaxCalls then
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   658
   begin
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   659
   WriteLnToConsole('Freeing progress surface... ');
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   660
   SDL_FreeSurface(ProgrSurf)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   661
   end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   662
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   663
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   664
function  LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface;
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   665
var tmpsurf: PSDL_Surface;
4
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
WriteToConsole(msgLoading + filename + '... ');
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   668
tmpsurf:= IMG_Load(PChar(filename));
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   669
TryDo(tmpsurf <> nil, msgFailed, true);
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   670
TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   671
if cFullScreen then
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   672
   begin
35
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   673
   if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf)
9367f246fb5f - New rope
unc0rr
parents: 30
diff changeset
   674
               else Result:= SDL_DisplayFormat(tmpsurf);
30
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   675
   SDL_FreeSurface(tmpsurf);
794e98e11b66 - Fixed slow sprite blt
unc0rr
parents: 4
diff changeset
   676
   end else Result:= tmpsurf;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   677
WriteLnToConsole(msgOK)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   678
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   679
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   680
end.