2 Copyright © 2004 Parallel Realities
3 Copyright © 2007-2008 Kővágó Zoltán <DirtY.iCE.hu@gmail.com>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "CGraphics.h"
25 #include "font/fontengine.hpp"
26 #include "gettext.hpp"
27 #include "resources.h"
29 extern FontEngine::Manager font_manager
;
31 void loadSound(int index
, const char *filename
)
33 if (!audio
.loadSound(index
, filename
))
34 graphics
.showErrorAndExit(ERR_FILE
, filename
);
36 graphics
.showLoading(1, 30);
39 void loadSprite(char *token
)
44 char filename
[8][100];
50 sscanf(token
, "%s %d %d %d %s %d %s %d %s %d %s %d %s %d %s %d %s %d %s %d", name
, &hue
, &sat
, &val
, filename
[0], &frameTime
[0], filename
[1], &frameTime
[1], filename
[2], &frameTime
[2], filename
[3], &frameTime
[3], filename
[4], &frameTime
[4], filename
[5], &frameTime
[5], filename
[6], &frameTime
[6], filename
[7], &frameTime
[7]);
52 sprite
= graphics
.addSprite(name
);
58 if (strcmp(filename
[i
], "@none@") == 0)
61 sprite
->setFrame(i
, graphics
.loadImage(filename
[i
], hue
, sat
, val
), frameTime
[i
]);
72 graphics
.resetLoading();
78 graphics
.quickSprite("cheatHeader", graphics
.loadImage("gfx/main/cheats.png"));
80 graphics
.quickSprite("optionsHeader", graphics
.loadImage("gfx/main/options.png"));
81 graphics
.quickSprite("joystickHeader", graphics
.loadImage("gfx/main/joystickConfig.png"));
82 graphics
.quickSprite("keyHeader", graphics
.loadImage("gfx/main/keyConfig.png"));
83 graphics
.quickSprite("optionsBackground", graphics
.loadImage("gfx/main/optionsBackground.png"));
85 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
86 /*Video::Surface screen(graphics.screen);
87 Video::PointSurface text(FontEngine::Renderer::RenderLine(font_manager.GetFont("default"), _("Loading..."), font_manager.GetOldSize(0)));
88 screen.BlitInto(Video::Point(graphics.width/2, graphics.height - 30), text, text["center_base"]);*/
89 FontEngine::DrawLine("default", _("Loading..."), font_manager
.GetOldSize(0), graphics
.width
/ 2, graphics
.height
- 30, "center_base", graphics
.screen
);
90 graphics
.showLoading(0, 0);
91 graphics
.updateScreen();
93 if (!engine
.loadDefines())
94 graphics
.showErrorAndExit(_("Could not load map define list '%s'"), "data/defines.h");
96 if (!engine
.loadData("data/mainSprites"))
97 graphics
.showErrorAndExit(ERR_FILE
, "data/mainSprites");
99 char *token
= strtok((char*)engine
.dataBuffer
, "\n");
103 if (strcmp(token
, "@EOF@") == 0)
110 token
= strtok(NULL
, "\n");
112 graphics
.showLoading(1, 20);
115 loadSound(SND_WATERIN
, "sound/waterIn.wav");
116 loadSound(SND_WATEROUT
, "sound/waterOut.wav");
117 loadSound(SND_ITEM
, "sound/item.wav");
118 loadSound(SND_PISTOL
, "sound/pistol.wav");
119 loadSound(SND_RICO1
, "sound/rico1.wav");
120 loadSound(SND_RICO2
, "sound/rico2.wav");
121 loadSound(SND_MACHINEGUN
, "sound/machinegun.wav");
122 loadSound(SND_DEATH1
, "sound/death1.wav");
123 loadSound(SND_DEATH2
, "sound/death2.wav");
124 loadSound(SND_DEATH3
, "sound/death3.wav");
125 loadSound(SND_GRENADE
, "sound/grenade.wav");
126 loadSound(SND_ROCKET
, "sound/rocket.wav");
127 loadSound(SND_FIREBALL
, "sound/fireball.wav");
128 loadSound(SND_HIT
, "sound/punch.wav");
129 loadSound(SND_SPLAT
, "sound/splat.wav");
130 loadSound(SND_POP
, "sound/pop1.wav");
131 loadSound(SND_TELEPORT1
, "sound/teleport1.wav");
132 loadSound(SND_TELEPORT2
, "sound/teleport2.wav");
133 loadSound(SND_TELEPORT3
, "sound/teleport3.wav");
134 loadSound(SND_GETWEAPON
, "sound/weaponPickup.wav");
135 loadSound(SND_LASER
, "sound/laser.wav");
136 loadSound(SND_ELECDEATH1
, "sound/elecDeath1.wav");
137 loadSound(SND_ELECDEATH2
, "sound/elecDeath2.wav");
138 loadSound(SND_ELECDEATH3
, "sound/elecDeath3.wav");
139 loadSound(SND_LOCKEDDOOR
, "sound/doorLocked.wav");
140 loadSound(SND_OPENDOOR
, "sound/doorOpen.wav");
141 loadSound(SND_DOOROPENED
, "sound/doorOpened.wav");
142 loadSound(SND_SWITCH1
, "sound/switch.wav");
143 loadSound(SND_SWITCH2
, "sound/switch.wav");
144 loadSound(SND_DROWNING
, "sound/drowning.wav");
145 loadSound(SND_GULP
, "sound/gulp.wav");
146 loadSound(SND_EAT
, "sound/eat.wav");
147 loadSound(SND_THROW
, "sound/throw.wav");
148 loadSound(SND_GRBOUNCE
, "sound/grenadeBounce.wav");
149 loadSound(SND_SPREADGUN
, "sound/plasma.wav");
150 loadSound(SND_STONEBREAK
, "sound/stoneBreak.wav");
151 loadSound(SND_ELECTRICITY1
, "sound/electricity1.wav");
152 loadSound(SND_ELECTRICITY2
, "sound/electricity2.wav");
153 loadSound(SND_ELECTRICITY3
, "sound/electricity3.wav");
154 loadSound(SND_CLANG
, "sound/clang.wav");
155 loadSound(SND_FIRECRACKLE
, "sound/fireCrackle.wav");
156 loadSound(SND_CLOCK
, "sound/clock.wav");
160 graphics
.showLoading(35, 35);
164 graphics
.showLoading(40, 40);
168 graphics
.showLoading(45, 45);
170 graphics
.loadMapTiles("gfx/common");
172 player
.setSprites(graphics
.getSprite("BobRight", true), graphics
.getSprite("BobLeft", true), graphics
.getSprite("BobSpin", true));
174 graphics
.showLoading(50, 50);
176 loadMapData(game
.mapName
);
178 graphics
.showLoading(100, 100);
180 //graphics.showLoading(100, 100);
181 //graphics.delay(100);
183 createBoss(game
.stageName
);
185 game
.canContinue
= 0;
187 // We don't need this anymore. Remove it to free up some memory...
188 engine
.defineList
.clear();