// $Id$
//
-// SuperTux - A Jump'n Run
+// SuperTux
// Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
#include <config.h>
-#include "app/globals.h"
-#include "special/sprite_manager.h"
-#include "app/setup.h"
-#include "gui/menu.h"
-#include "gui/button.h"
-#include "resources.h"
-#include "tile_manager.h"
-#include "object/gameobjs.h"
-#include "object/player.h"
-
-Menu* main_menu = 0;
-Menu* game_menu = 0;
-Menu* options_menu = 0;
-Menu* options_keys_menu = 0;
-Menu* options_joystick_menu = 0;
-Menu* highscore_menu = 0;
-Menu* load_game_menu = 0;
-Menu* save_game_menu = 0;
-Menu* contrib_menu = 0;
-Menu* contrib_subset_menu = 0;
-
-MusicRef herring_song;
-MusicRef level_end_song;
-MusicRef credits_song;
-
-SpriteManager* sprite_manager = 0;
-TileManager* tile_manager = 0;
-
-char * soundfilenames[NUM_SOUNDS] = {
- "/sounds/jump.wav",
- "/sounds/bigjump.wav",
- "/sounds/skid.wav",
- "/sounds/coin.wav",
- "/sounds/invincible.wav",
- "/sounds/brick.wav",
- "/sounds/hurt.wav",
- "/sounds/squish.wav",
- "/sounds/fall.wav",
- "/sounds/ricochet.wav",
- "/sounds/bump-upgrade.wav",
- "/sounds/upgrade.wav",
- "/sounds/grow.wav",
- "/sounds/fire-flower.wav",
- "/sounds/shoot.wav",
- "/sounds/lifeup.wav",
- "/sounds/stomp.wav",
- "/sounds/kick.wav",
- "/sounds/explosion.wav",
- "/sounds/warp.wav",
- "/sounds/fireworks.wav"
- };
-
-
-Font* gold_text;
-Font* blue_text;
-Font* gray_text;
-Font* yellow_nums;
-Font* white_text;
-Font* white_small_text;
-Font* white_big_text;
-
+#include "sprite/sprite_manager.hpp"
+#include "gui/menu.hpp"
+#include "gui/button.hpp"
+#include "resources.hpp"
+#include "file_system.hpp"
+#include "tile_manager.hpp"
+#include "object/gameobjs.hpp"
+#include "object/player.hpp"
+
+MouseCursor* mouse_cursor = NULL;
+
+Font* gold_text = NULL;
+Font* gold_fixed_text = NULL;
+Font* blue_text = NULL;
+Font* gray_text = NULL;
+Font* white_text = NULL;
+Font* white_small_text = NULL;
+Font* white_big_text = NULL;
+
/* Load graphics/sounds shared between all levels: */
-void loadshared()
+void load_shared()
{
+ /* Load the mouse-cursor */
+ mouse_cursor = new MouseCursor("images/engine/menu/mousecursor.png");
+ MouseCursor::set_current(mouse_cursor);
+
/* Load global images: */
- gold_text = new Font(datadir + "/images/fonts/gold.png", Font::TEXT, 16,18);
- blue_text = new Font(datadir + "/images/fonts/blue.png", Font::TEXT, 16,18,3);
- white_text = new Font(datadir + "/images/fonts/white.png",
- Font::TEXT, 16,18);
- gray_text = new Font(datadir + "/images/fonts/gray.png",
- Font::TEXT, 16,18);
- white_small_text = new Font(datadir + "/images/fonts/white-small.png",
- Font::TEXT, 8,9, 1);
- white_big_text = new Font(datadir + "/images/fonts/white-big.png",
- Font::TEXT, 20,22, 3);
- yellow_nums = new Font(datadir + "/images/fonts/numbers.png",
- Font::NUM, 32,32);
-
- Menu::default_font = white_text;
- Menu::active_font = blue_text;
+ gold_text = new Font(Font::VARIABLE,
+ "images/engine/fonts/gold.png",
+ "images/engine/fonts/shadow.png", 16, 18);
+ gold_fixed_text = new Font(Font::FIXED,
+ "images/engine/fonts/gold.png",
+ "images/engine/fonts/shadow.png", 16, 18);
+ blue_text = new Font(Font::VARIABLE,
+ "images/engine/fonts/blue.png",
+ "images/engine/fonts/shadow.png", 16, 18, 3);
+ white_text = new Font(Font::VARIABLE,
+ "images/engine/fonts/white.png",
+ "images/engine/fonts/shadow.png", 16, 18);
+ gray_text = new Font(Font::VARIABLE,
+ "images/engine/fonts/gray.png",
+ "images/engine/fonts/shadow.png", 16, 18);
+ white_small_text = new Font(Font::VARIABLE,
+ "images/engine/fonts/white-small.png",
+ "images/engine/fonts/shadow-small.png", 8, 9, 1);
+ white_big_text = new Font(Font::VARIABLE,
+ "images/engine/fonts/white-big.png",
+ "images/engine/fonts/shadow-big.png", 20, 22, 3);
+
+ Menu::default_font = white_text;
+ Menu::active_font = blue_text;
Menu::deactive_font = gray_text;
- Menu::label_font = white_big_text;
- Menu::field_font = gold_text;
-
- Button::info_font = white_small_text;
+ Menu::label_font = white_big_text;
+ Menu::field_font = gold_text;
- int i;
+ Button::info_font = white_small_text;
- sprite_manager = new SpriteManager(
- get_resource_filename("/images/supertux.strf"));
- tile_manager = new TileManager("/images/tilesets/supertux.stgt");
+ sprite_manager = new SpriteManager();
+ tile_manager = new TileManager("images/tiles.strf");
/* Tuxes: */
char img_name[1024];
for (int i = 0; i < GROWING_FRAMES; i++)
{
- sprintf(img_name, "%s/images/shared/tux-grow-left-%i.png", datadir.c_str(), i+1);
- growingtux_left[i] = new Surface(img_name, true);
+ snprintf(img_name, sizeof(img_name), "images/creatures/tux_grow/left-%i.png", i+1);
+ growingtux_left[i] = new Surface(img_name);
- sprintf(img_name, "%s/images/shared/tux-grow-right-%i.png", datadir.c_str(), i+1);
- growingtux_right[i] = new Surface(img_name, true);
+ snprintf(img_name, sizeof(img_name), "images/creatures/tux_grow/right-%i.png", i+1);
+ growingtux_right[i] = new Surface(img_name);
}
small_tux = new TuxBodyParts();
small_tux->head = 0;
- small_tux->body = sprite_manager->create("small-tux-body");
- small_tux->arms = sprite_manager->create("small-tux-arms");
+ small_tux->body = sprite_manager->create("images/creatures/tux_small/small-tux-body.sprite");
+ small_tux->arms = sprite_manager->create("images/creatures/tux_small/small-tux-arms.sprite");
small_tux->feet = 0;
big_tux = new TuxBodyParts();
- big_tux->head = sprite_manager->create("big-tux-head");
- big_tux->body = sprite_manager->create("big-tux-body");
- big_tux->arms = sprite_manager->create("big-tux-arms");
- big_tux->feet = sprite_manager->create("big-tux-feet");
+ big_tux->head = sprite_manager->create("images/creatures/tux_big/big-tux-head.sprite");
+ big_tux->body = sprite_manager->create("images/creatures/tux_big/big-tux-body.sprite");
+ big_tux->arms = sprite_manager->create("images/creatures/tux_big/big-tux-arms.sprite");
+ big_tux->feet = sprite_manager->create("images/creatures/tux_big/big-tux-feet.sprite");
fire_tux = new TuxBodyParts();
- fire_tux->head = sprite_manager->create("big-fire-tux-head");
- fire_tux->body = sprite_manager->create("big-tux-body");
- fire_tux->arms = sprite_manager->create("big-tux-arms");
- fire_tux->feet = sprite_manager->create("big-tux-feet");
+ fire_tux->head = sprite_manager->create("images/creatures/tux_big/big-fire-tux-head.sprite");
+ fire_tux->body = sprite_manager->create("images/creatures/tux_big/big-tux-body.sprite");
+ fire_tux->arms = sprite_manager->create("images/creatures/tux_big/big-tux-arms.sprite");
+ fire_tux->feet = sprite_manager->create("images/creatures/tux_big/big-tux-feet.sprite");
ice_tux = new TuxBodyParts();
- ice_tux->head = sprite_manager->create("big-tux-head");
- ice_tux->body = sprite_manager->create("big-tux-body");
- ice_tux->arms = sprite_manager->create("big-tux-arms");
- ice_tux->feet = sprite_manager->create("big-tux-feet");
-
- /* Objects */
- load_object_gfx();
-
- /* Tux life: */
- tux_life = new Surface(datadir + "/images/shared/tux-life.png",
- true);
-
- /* Sound effects: */
- for (i = 0; i < NUM_SOUNDS; i++)
- SoundManager::get()->add_sound(SoundManager::get
- ()->load_sound(datadir + soundfilenames[i]),i);
-
- /* Herring song */
- herring_song = SoundManager::get
- ()->load_music(datadir + "/music/salcon.mod");
- level_end_song = SoundManager::get
- ()->load_music(datadir + "/music/leveldone.mod");
+ ice_tux->head = sprite_manager->create("images/creatures/tux_big/big-ice-tux-head.sprite");
+ ice_tux->body = sprite_manager->create("images/creatures/tux_big/big-tux-body.sprite");
+ ice_tux->arms = sprite_manager->create("images/creatures/tux_big/big-tux-arms.sprite");
+ ice_tux->feet = sprite_manager->create("images/creatures/tux_big/big-tux-feet.sprite");
+
+ player_status = new PlayerStatus();
}
/* Free shared data: */
-void unloadshared(void)
+void unload_shared()
{
/* Free global images: */
delete gold_text;
delete gray_text;
delete white_small_text;
delete white_big_text;
- delete yellow_nums;
-
- free_object_gfx();
-
- delete tux_life;
delete small_tux;
delete big_tux;
}
delete sprite_manager;
- sprite_manager = 0;
+ sprite_manager = NULL;
delete tile_manager;
- tile_manager = 0;
-}
+ tile_manager = NULL;
-std::string get_resource_filename(const std::string& resource)
-{
- std::string filepath = st_dir + resource;
- if(FileSystem::faccessible(filepath))
- return filepath;
-
- filepath = datadir + resource;
- if(FileSystem::faccessible(filepath))
- return filepath;
-
- std::cerr << "Couldn't find resource: '" << resource << "'." << std::endl;
- return "";
+ /* Free mouse-cursor */
+ delete mouse_cursor;
}