Turned a lot of other global objects into Currentons
authorIngo Ruhnke <grumbel@gmail.com>
Sun, 17 Aug 2014 18:20:35 +0000 (20:20 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Sun, 17 Aug 2014 20:34:30 +0000 (22:34 +0200)
126 files changed:
src/audio/sound_manager.hpp
src/audio/stream_sound_source.cpp
src/badguy/badguy.cpp
src/badguy/bomb.cpp
src/badguy/dart.cpp
src/badguy/darttrap.cpp
src/badguy/dispenser.cpp
src/badguy/flame.cpp
src/badguy/ghostflame.cpp
src/badguy/ghosttree.cpp
src/badguy/goldbomb.cpp
src/badguy/haywire.cpp
src/badguy/iceflame.cpp
src/badguy/jumpy.cpp
src/badguy/kamikazesnowball.cpp
src/badguy/kugelblitz.cpp
src/badguy/livefire.cpp
src/badguy/mole.cpp
src/badguy/mole_rock.cpp
src/badguy/mrbomb.cpp
src/badguy/mriceblock.cpp
src/badguy/mrtree.cpp
src/badguy/owl.cpp
src/badguy/root.cpp
src/badguy/short_fuse.cpp
src/badguy/skullyhop.cpp
src/badguy/snail.cpp
src/badguy/snowman.cpp
src/badguy/stalactite.cpp
src/badguy/stumpy.cpp
src/badguy/toad.cpp
src/badguy/totem.cpp
src/badguy/treewillowisp.cpp
src/badguy/willowisp.cpp
src/badguy/yeti.cpp
src/control/input_manager.hpp
src/gui/menu.cpp
src/gui/menu_manager.cpp
src/object/ambient_sound.cpp
src/object/block.cpp
src/object/bonus_block.cpp
src/object/bouncy_coin.cpp
src/object/brick.cpp
src/object/bullet.cpp
src/object/candle.cpp
src/object/coin.cpp
src/object/coin_rain.cpp
src/object/endsequence_fireworks.cpp
src/object/endsequence_walkleft.cpp
src/object/endsequence_walkright.cpp
src/object/explosion.cpp
src/object/falling_coin.cpp
src/object/firefly.cpp
src/object/fireworks.cpp
src/object/floating_image.cpp
src/object/flower.cpp
src/object/growup.cpp
src/object/icecrusher.cpp
src/object/infoblock.cpp
src/object/invisible_block.cpp
src/object/lantern.cpp
src/object/light.cpp
src/object/moving_sprite.cpp
src/object/player.cpp
src/object/powerup.cpp
src/object/pushbutton.cpp
src/object/rainsplash.cpp
src/object/rock.cpp
src/object/rusty_trampoline.cpp
src/object/smoke_cloud.cpp
src/object/spotlight.cpp
src/object/sprite_particle.cpp
src/object/star.cpp
src/object/thunderstorm.cpp
src/object/trampoline.cpp
src/object/weak_block.cpp
src/scripting/functions.cpp
src/sprite/sprite_manager.hpp
src/supertux/game_manager.cpp
src/supertux/game_session.cpp
src/supertux/gameconfig.cpp
src/supertux/globals.cpp
src/supertux/globals.hpp
src/supertux/level.cpp
src/supertux/levelintro.cpp
src/supertux/levelset_screen.cpp
src/supertux/main.cpp
src/supertux/main.hpp
src/supertux/menu/contrib_levelset_menu.cpp
src/supertux/menu/joystick_menu.cpp
src/supertux/menu/joystick_menu.hpp
src/supertux/menu/keyboard_menu.cpp
src/supertux/menu/keyboard_menu.hpp
src/supertux/menu/language_menu.cpp
src/supertux/menu/main_menu.cpp
src/supertux/menu/menu_storage.cpp
src/supertux/menu/options_menu.cpp
src/supertux/menu/worldmap_menu.cpp
src/supertux/player_status.cpp
src/supertux/resources.cpp
src/supertux/resources.hpp
src/supertux/screen_manager.cpp
src/supertux/screen_manager.hpp
src/supertux/sector.cpp
src/supertux/textscroller.cpp
src/supertux/tile_manager.hpp
src/supertux/title_screen.cpp
src/trigger/door.cpp
src/trigger/switch.cpp
src/util/gettext.hpp
src/video/gl/gl_lightmap.cpp
src/video/gl/gl_renderer.cpp
src/video/gl/gl_video_system.cpp
src/video/gl/gl_video_system.hpp
src/video/sdl/sdl_renderer.cpp
src/video/sdl/sdl_video_system.cpp
src/video/sdl/sdl_video_system.hpp
src/video/surface.cpp
src/video/texture.hpp
src/video/texture_manager.hpp
src/worldmap/level.cpp
src/worldmap/special_tile.cpp
src/worldmap/sprite_change.cpp
src/worldmap/teleporter.cpp
src/worldmap/tux.cpp
src/worldmap/worldmap.cpp

index da042c6..8c699d4 100644 (file)
 #include <alc.h>
 
 #include "math/vector.hpp"
+#include "util/currenton.hpp"
 
 class SoundFile;
 class SoundSource;
 class StreamSoundSource;
 class OpenALSoundSource;
 
-class SoundManager
+class SoundManager : public Currenton<SoundManager>
 {
 public:
   SoundManager();
index 2c06059..e813b7d 100644 (file)
@@ -30,13 +30,13 @@ StreamSoundSource::StreamSoundSource() :
   alGenBuffers(STREAMFRAGMENTS, buffers);
   SoundManager::check_al_error("Couldn't allocate audio buffers: ");
   //add me to update list
-  sound_manager->register_for_update( this );
+  SoundManager::current()->register_for_update( this );
 }
 
 StreamSoundSource::~StreamSoundSource()
 {
   //don't update me any longer
-  sound_manager->remove_from_update( this );
+  SoundManager::current()->remove_from_update( this );
   file.reset();
   stop();
   alDeleteBuffers(STREAMFRAGMENTS, buffers);
index b0ffd20..0b397c9 100644 (file)
@@ -53,8 +53,8 @@ BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name_, int layer_) :
 {
   start_position = bbox.p1;
 
-  sound_manager->preload("sounds/squish.wav");
-  sound_manager->preload("sounds/fall.wav");
+  SoundManager::current()->preload("sounds/squish.wav");
+  SoundManager::current()->preload("sounds/fall.wav");
 
   dir = (start_dir == AUTO) ? LEFT : start_dir;
 }
@@ -79,8 +79,8 @@ BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite
 {
   start_position = bbox.p1;
 
-  sound_manager->preload("sounds/squish.wav");
-  sound_manager->preload("sounds/fall.wav");
+  SoundManager::current()->preload("sounds/squish.wav");
+  SoundManager::current()->preload("sounds/fall.wav");
 
   dir = (start_dir == AUTO) ? LEFT : start_dir;
 }
@@ -112,8 +112,8 @@ BadGuy::BadGuy(const Reader& reader, const std::string& sprite_name_, int layer_
 
   reader.get("dead-script", dead_script);
 
-  sound_manager->preload("sounds/squish.wav");
-  sound_manager->preload("sounds/fall.wav");
+  SoundManager::current()->preload("sounds/squish.wav");
+  SoundManager::current()->preload("sounds/fall.wav");
 
   dir = (start_dir == AUTO) ? LEFT : start_dir;
 }
@@ -386,7 +386,7 @@ BadGuy::kill_squished(GameObject& object)
 {
   if (!is_active()) return;
 
-  sound_manager->play("sounds/squish.wav", get_pos());
+  SoundManager::current()->play("sounds/squish.wav", get_pos());
   physic.enable_gravity(true);
   physic.set_velocity_x(0);
   physic.set_velocity_y(0);
@@ -406,7 +406,7 @@ BadGuy::kill_fall()
 {
   if (!is_active()) return;
 
-  sound_manager->play("sounds/fall.wav", get_pos());
+  SoundManager::current()->play("sounds/fall.wav", get_pos());
   physic.set_velocity_y(0);
   physic.set_acceleration_y(0);
   physic.enable_gravity(true);
index a16a9f0..629b75b 100644 (file)
@@ -32,7 +32,7 @@ Bomb::Bomb(const Vector& pos, Direction dir_, std::string custom_sprite /*= "ima
   set_action(dir_ == LEFT ? "ticking-left" : "ticking-right", 1);
   countMe = false;
 
-  ticking = sound_manager->create_sound_source("sounds/fizz.wav");
+  ticking = SoundManager::current()->create_sound_source("sounds/fizz.wav");
   ticking->set_position(get_pos());
   ticking->set_looping(true);
   ticking->set_gain(2.0);
index c75bea1..37389fc 100644 (file)
@@ -34,9 +34,9 @@ Dart::Dart(const Reader& reader) :
 {
   physic.enable_gravity(false);
   countMe = false;
-  sound_manager->preload(DART_SOUND);
-  sound_manager->preload("sounds/darthit.wav");
-  sound_manager->preload("sounds/stomp.wav");
+  SoundManager::current()->preload(DART_SOUND);
+  SoundManager::current()->preload("sounds/darthit.wav");
+  SoundManager::current()->preload("sounds/stomp.wav");
 }
 
 Dart::Dart(const Vector& pos, Direction d, const BadGuy* parent_ = 0) :
@@ -46,9 +46,9 @@ Dart::Dart(const Vector& pos, Direction d, const BadGuy* parent_ = 0) :
 {
   physic.enable_gravity(false);
   countMe = false;
-  sound_manager->preload(DART_SOUND);
-  sound_manager->preload("sounds/darthit.wav");
-  sound_manager->preload("sounds/stomp.wav");
+  SoundManager::current()->preload(DART_SOUND);
+  SoundManager::current()->preload("sounds/darthit.wav");
+  SoundManager::current()->preload("sounds/stomp.wav");
 }
 
 Dart::~Dart()
@@ -75,7 +75,7 @@ Dart::initialize()
 void
 Dart::activate()
 {
-  sound_source = sound_manager->create_sound_source(DART_SOUND);
+  sound_source = SoundManager::current()->create_sound_source(DART_SOUND);
   sound_source->set_position(get_pos());
   sound_source->set_looping(true);
   sound_source->set_gain(1.0);
@@ -100,7 +100,7 @@ Dart::active_update(float elapsed_time)
 void
 Dart::collision_solid(const CollisionHit& )
 {
-  sound_manager->play("sounds/darthit.wav", get_pos());
+  SoundManager::current()->play("sounds/darthit.wav", get_pos());
   remove_me();
 }
 
@@ -111,7 +111,7 @@ Dart::collision_badguy(BadGuy& badguy, const CollisionHit& )
   if (&badguy == parent) {
     return FORCE_MOVE;
   }
-  sound_manager->play("sounds/stomp.wav", get_pos());
+  SoundManager::current()->play("sounds/stomp.wav", get_pos());
   remove_me();
   badguy.kill_fall();
   return ABORT_MOVE;
@@ -120,7 +120,7 @@ Dart::collision_badguy(BadGuy& badguy, const CollisionHit& )
 HitResponse
 Dart::collision_player(Player& player, const CollisionHit& hit)
 {
-  sound_manager->play("sounds/stomp.wav", get_pos());
+  SoundManager::current()->play("sounds/stomp.wav", get_pos());
   remove_me();
   return BadGuy::collision_player(player, hit);
 }
index c07d447..3885cb6 100644 (file)
@@ -39,7 +39,7 @@ DartTrap::DartTrap(const Reader& reader) :
   reader.get("fire-delay", fire_delay);
   reader.get("ammo", ammo);
   countMe = false;
-  sound_manager->preload("sounds/dartfire.wav");
+  SoundManager::current()->preload("sounds/dartfire.wav");
   if (start_dir == AUTO) { log_warning << "Setting a DartTrap's direction to AUTO is no good idea" << std::endl; }
   state = IDLE;
   set_colgroup_active(COLGROUP_DISABLED);
@@ -96,7 +96,7 @@ DartTrap::fire()
   float py = get_pos().y;
   py += MUZZLE_Y;
 
-  sound_manager->play("sounds/dartfire.wav", get_pos());
+  SoundManager::current()->play("sounds/dartfire.wav", get_pos());
   Sector::current()->add_object(new Dart(Vector(px, py), dir, this));
   state = IDLE;
   sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
index 542d0f5..e3deca0 100644 (file)
@@ -39,7 +39,7 @@ Dispenser::Dispenser(const Reader& reader) :
   type()
 {
   set_colgroup_active(COLGROUP_MOVING_STATIC);
-  sound_manager->preload("sounds/squish.wav");
+  SoundManager::current()->preload("sounds/squish.wav");
   reader.get("cycle", cycle);
   reader.get("badguy", badguys);
   random = false; // default
@@ -111,7 +111,7 @@ Dispenser::collision_squished(GameObject& object)
   if (player){
     player->bounce(*this);
   }
-  sound_manager->play("sounds/squish.wav", get_pos());
+  SoundManager::current()->play("sounds/squish.wav", get_pos());
   broken = true;
   return true;
 }
index 0539577..66ce6d3 100644 (file)
@@ -35,7 +35,7 @@ Flame::Flame(const Reader& reader) :
   radius(100),
   speed(2),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
   sound_source()
 {
   reader.get("radius", radius);
@@ -43,7 +43,7 @@ Flame::Flame(const Reader& reader) :
   bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
                       start_position.y + sin(angle) * radius));
   countMe = false;
-  sound_manager->preload(FLAME_SOUND);
+  SoundManager::current()->preload(FLAME_SOUND);
 
   set_colgroup_active(COLGROUP_TOUCHABLE);
 
@@ -85,7 +85,7 @@ Flame::draw(DrawingContext& context)
 void
 Flame::activate()
 {
-  sound_source = sound_manager->create_sound_source(FLAME_SOUND);
+  sound_source = SoundManager::current()->create_sound_source(FLAME_SOUND);
   sound_source->set_position(get_pos());
   sound_source->set_looping(true);
   sound_source->set_gain(2.0);
@@ -108,7 +108,7 @@ Flame::kill_fall()
 void
 Flame::freeze()
 {
-  sound_manager->play("sounds/sizzle.ogg", get_pos());
+  SoundManager::current()->play("sounds/sizzle.ogg", get_pos());
   sprite->set_action("fade", 1);
   Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", bbox.get_middle(), ANCHOR_MIDDLE, Vector(0, -150), Vector(0,0), LAYER_BACKGROUNDTILES+2));
   set_group(COLGROUP_DISABLED);
index 843f9d8..d5a7170 100644 (file)
@@ -33,7 +33,7 @@ Ghostflame::Ghostflame(const Reader& reader) :
   radius(100),
   speed(2),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   reader.get("radius", radius);
   reader.get("speed", speed);
@@ -41,7 +41,7 @@ Ghostflame::Ghostflame(const Reader& reader) :
                       start_position.y + sin(angle) * radius));
   countMe = false;
   //TODO: get unique death sound
-  sound_manager->preload("sounds/fizz.wav");
+  SoundManager::current()->preload("sounds/fizz.wav");
 
   set_colgroup_active(COLGROUP_TOUCHABLE);
 
index 8ae3259..4e8832b 100644 (file)
@@ -53,10 +53,10 @@ GhostTree::GhostTree(const Reader& lisp) :
   suck_lantern(0),
   willowisps()
 {
-  glow_sprite = sprite_manager->create("images/creatures/ghosttree/ghosttree-glow.sprite");
+  glow_sprite = SpriteManager::current()->create("images/creatures/ghosttree/ghosttree-glow.sprite");
   set_colgroup_active(COLGROUP_TOUCHABLE);
-  sound_manager->preload("sounds/tree_howling.ogg");
-  sound_manager->preload("sounds/tree_suck.ogg");
+  SoundManager::current()->preload("sounds/tree_howling.ogg");
+  SoundManager::current()->preload("sounds/tree_suck.ogg");
 }
 
 GhostTree::~GhostTree()
@@ -93,7 +93,7 @@ GhostTree::active_update(float elapsed_time)
 
   if (mystate == STATE_IDLE) {
     if(colorchange_timer.check()) {
-      sound_manager->play("sounds/tree_howling.ogg", get_pos());
+      SoundManager::current()->play("sounds/tree_howling.ogg", get_pos());
       suck_timer.start(3);
       treecolor = (treecolor + 1) % 3;
 
@@ -112,7 +112,7 @@ GhostTree::active_update(float elapsed_time)
 
     if(suck_timer.check()) {
       Color col = glow_sprite->get_color();
-      sound_manager->play("sounds/tree_suck.ogg", get_pos());
+      SoundManager::current()->play("sounds/tree_suck.ogg", get_pos());
       std::vector<TreeWillOWisp*>::iterator iter;
       for(iter = willowisps.begin(); iter != willowisps.end(); ++iter) {
         TreeWillOWisp *willo = *iter;
index 3569fe3..67c8002 100644 (file)
@@ -38,7 +38,7 @@ GoldBomb::GoldBomb(const Reader& reader) :
   max_drop_height = 16;
 
   //Prevent stutter when Tux jumps on Gold Bomb
-  sound_manager->preload("sounds/explosion.wav");
+  SoundManager::current()->preload("sounds/explosion.wav");
 
   //Check if we need another sprite
   if( !reader.get( "sprite", sprite_name ) ){
@@ -49,7 +49,7 @@ GoldBomb::GoldBomb(const Reader& reader) :
     return;
   }
   //Replace sprite
-  sprite = sprite_manager->create( sprite_name );
+  sprite = SpriteManager::current()->create( sprite_name );
 }
 
 void
@@ -114,7 +114,7 @@ GoldBomb::collision_squished(GameObject& object)
     if (player)
       player->bounce(*this);
 
-    ticking = sound_manager->create_sound_source("sounds/fizz.wav");
+    ticking = SoundManager::current()->create_sound_source("sounds/fizz.wav");
     ticking->set_position(get_pos());
     ticking->set_looping(true);
     ticking->set_gain(2.0);
index 9620b70..f3d7242 100644 (file)
@@ -42,7 +42,7 @@ Haywire::Haywire(const Reader& reader) :
   max_drop_height = 16;
 
   //Prevent stutter when Tux jumps on Mr Bomb
-  sound_manager->preload("sounds/explosion.wav");
+  SoundManager::current()->preload("sounds/explosion.wav");
 
   //Check if we need another sprite
   if( !reader.get( "sprite", sprite_name ) ){
@@ -53,7 +53,7 @@ Haywire::Haywire(const Reader& reader) :
     return;
   }
   //Replace sprite
-  sprite = sprite_manager->create( sprite_name );
+  sprite = SpriteManager::current()->create( sprite_name );
 }
 
 HitResponse
@@ -96,12 +96,12 @@ Haywire::collision_squished(GameObject& object)
     time_until_explosion = TIME_EXPLOSION;
     is_exploding = true;
 
-    ticking = sound_manager->create_sound_source("sounds/fizz.wav");
+    ticking = SoundManager::current()->create_sound_source("sounds/fizz.wav");
     ticking->set_position(get_pos());
     ticking->set_looping(true);
     ticking->set_reference_distance(32);
     ticking->play();
-    grunting = sound_manager->create_sound_source("sounds/grunts.ogg");
+    grunting = SoundManager::current()->create_sound_source("sounds/grunts.ogg");
     grunting->set_position(get_pos());
     grunting->set_looping(true);
     grunting->set_reference_distance(32);
index 46b5e85..630da0a 100644 (file)
@@ -33,14 +33,14 @@ Iceflame::Iceflame(const Reader& reader) :
   radius(100),
   speed(2),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   reader.get("radius", radius);
   reader.get("speed", speed);
   bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
                       start_position.y + sin(angle) * radius));
   countMe = false;
-  sound_manager->preload("sounds/sizzle.ogg");
+  SoundManager::current()->preload("sounds/sizzle.ogg");
 
   set_colgroup_active(COLGROUP_TOUCHABLE);
 
@@ -86,7 +86,7 @@ Iceflame::kill_fall()
 void
 Iceflame::ignite()
 {
-  sound_manager->play("sounds/sizzle.ogg", get_pos());
+  SoundManager::current()->play("sounds/sizzle.ogg", get_pos());
   sprite->set_action("fade", 1);
   Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", bbox.get_middle(), ANCHOR_MIDDLE, Vector(0, -150), Vector(0,0), LAYER_BACKGROUNDTILES+2));
   set_group(COLGROUP_DISABLED);
index 6b04ebb..7a6eaaa 100644 (file)
@@ -30,7 +30,7 @@ Jumpy::Jumpy(const Reader& reader) :
   groundhit_pos_set(false)
 {
   // TODO create a nice sound for this...
-  //sound_manager->preload("sounds/skid.wav");
+  //SoundManager::current()->preload("sounds/skid.wav");
 }
 
 void
@@ -57,7 +57,7 @@ Jumpy::hit(const CollisionHit& chit)
 
     physic.set_velocity_y((frozen || get_state() == STATE_FALLING) ? 0 : JUMPYSPEED);
     // TODO create a nice sound for this...
-    //sound_manager->play("sounds/skid.wav");
+    //SoundManager::current()->play("sounds/skid.wav");
   } else if(chit.top) {
     physic.set_velocity_y(0);
   }
index b82a533..49ae582 100644 (file)
@@ -32,14 +32,14 @@ namespace{
 KamikazeSnowball::KamikazeSnowball(const Reader& reader) :
   BadGuy(reader, "images/creatures/snowball/kamikaze-snowball.sprite")
 {
-  sound_manager->preload(SPLAT_SOUND);
+  SoundManager::current()->preload(SPLAT_SOUND);
   set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
 }
 
 KamikazeSnowball::KamikazeSnowball(const Vector& pos, Direction d)
   : BadGuy(pos, d, "images/creatures/snowball/kamikaze-snowball.sprite")
 {
-  sound_manager->preload(SPLAT_SOUND);
+  SoundManager::current()->preload(SPLAT_SOUND);
   set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
 }
 
@@ -74,7 +74,7 @@ void
 KamikazeSnowball::kill_collision()
 {
   sprite->set_action(dir == LEFT ? "collision-left" : "collision-right");
-  sound_manager->play(SPLAT_SOUND, get_pos());
+  SoundManager::current()->play(SPLAT_SOUND, get_pos());
   physic.set_velocity_x(0);
   physic.set_velocity_y(0);
   physic.enable_gravity(true);
index 7437ca3..da2c6e0 100644 (file)
@@ -42,7 +42,7 @@ Kugelblitz::Kugelblitz(const Reader& reader) :
   direction(),
   state(),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light.sprite"))
 {
   reader.get("x", start_position.x);
   sprite->set_action("falling");
index d62d036..55c91ad 100644 (file)
@@ -25,7 +25,7 @@
 
 LiveFire::LiveFire(const Reader& reader) :
   WalkingBadguy(reader, "images/creatures/livefire/livefire.sprite", "left", "right"),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-medium.sprite")),
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-medium.sprite")),
   death_sound("sounds/fall.wav"),
   state(STATE_WALKING)
 {
@@ -131,7 +131,7 @@ LiveFire::is_flammable() const
 void
 LiveFire::kill_fall()
 {
-  sound_manager->play(death_sound, get_pos());
+  SoundManager::current()->play(death_sound, get_pos());
   // throw a puff of smoke
   Vector ppos = bbox.get_middle();
   Vector pspeed = Vector(0, -150);
index 2921ddb..f6ab193 100644 (file)
@@ -36,9 +36,9 @@ Mole::Mole(const Reader& reader) :
   throw_timer()
 {
   physic.enable_gravity(false);
-  sound_manager->preload("sounds/fall.wav");
-  sound_manager->preload("sounds/squish.wav");
-  sound_manager->preload("sounds/dartfire.wav");
+  SoundManager::current()->preload("sounds/fall.wav");
+  SoundManager::current()->preload("sounds/squish.wav");
+  SoundManager::current()->preload("sounds/dartfire.wav");
 }
 
 Mole::Mole(const Vector& pos) :
@@ -48,9 +48,9 @@ Mole::Mole(const Vector& pos) :
   throw_timer()
 {
   physic.enable_gravity(false);
-  sound_manager->preload("sounds/fall.wav");
-  sound_manager->preload("sounds/squish.wav");
-  sound_manager->preload("sounds/dartfire.wav");
+  SoundManager::current()->preload("sounds/fall.wav");
+  SoundManager::current()->preload("sounds/squish.wav");
+  SoundManager::current()->preload("sounds/dartfire.wav");
 }
 
 void
@@ -63,7 +63,7 @@ void
 Mole::kill_fall()
 {
   set_state(DEAD);
-  sound_manager->play("sounds/fall.wav", get_pos());
+  SoundManager::current()->play("sounds/fall.wav", get_pos());
   run_dead_script();
 }
 
@@ -80,7 +80,7 @@ Mole::collision_squished(GameObject& )
     return true;
 
   set_state(DEAD);
-  sound_manager->play("sounds/squish.wav", get_pos());
+  SoundManager::current()->play("sounds/squish.wav", get_pos());
   run_dead_script();
   return true;
 }
@@ -95,7 +95,7 @@ Mole::throw_rock()
   float vx = cos(angle) * THROW_VELOCITY;
   float vy = -sin(angle) * THROW_VELOCITY;
 
-  sound_manager->play("sounds/dartfire.wav", get_pos());
+  SoundManager::current()->play("sounds/dartfire.wav", get_pos());
   Sector::current()->add_object(new MoleRock(Vector(px, py), Vector(vx, vy), this));
 }
 
index 6b25970..b4ef0bf 100644 (file)
@@ -27,8 +27,8 @@ MoleRock::MoleRock(const Reader& reader) :
 {
   physic.enable_gravity(true);
   countMe = false;
-  sound_manager->preload("sounds/darthit.wav");
-  sound_manager->preload("sounds/stomp.wav");
+  SoundManager::current()->preload("sounds/darthit.wav");
+  SoundManager::current()->preload("sounds/stomp.wav");
 }
 
 MoleRock::MoleRock(const Vector& pos, const Vector& velocity, const BadGuy* parent_ = 0) :
@@ -38,8 +38,8 @@ MoleRock::MoleRock(const Vector& pos, const Vector& velocity, const BadGuy* pare
 {
   physic.enable_gravity(true);
   countMe = false;
-  sound_manager->preload("sounds/darthit.wav");
-  sound_manager->preload("sounds/stomp.wav");
+  SoundManager::current()->preload("sounds/darthit.wav");
+  SoundManager::current()->preload("sounds/stomp.wav");
 }
 
 MoleRock::~MoleRock()
@@ -78,7 +78,7 @@ MoleRock::active_update(float elapsed_time)
 void
 MoleRock::collision_solid(const CollisionHit& )
 {
-  sound_manager->play("sounds/darthit.wav", get_pos());
+  SoundManager::current()->play("sounds/darthit.wav", get_pos());
   remove_me();
 }
 
@@ -89,7 +89,7 @@ MoleRock::collision_badguy(BadGuy& badguy, const CollisionHit& )
   if (&badguy == parent) {
     return FORCE_MOVE;
   }
-  sound_manager->play("sounds/stomp.wav", get_pos());
+  SoundManager::current()->play("sounds/stomp.wav", get_pos());
   remove_me();
   badguy.kill_fall();
   return ABORT_MOVE;
@@ -98,7 +98,7 @@ MoleRock::collision_badguy(BadGuy& badguy, const CollisionHit& )
 HitResponse
 MoleRock::collision_player(Player& player, const CollisionHit& hit)
 {
-  sound_manager->play("sounds/stomp.wav", get_pos());
+  SoundManager::current()->play("sounds/stomp.wav", get_pos());
   remove_me();
   return BadGuy::collision_player(player, hit);
 }
index 4acf898..d9688dd 100644 (file)
@@ -34,7 +34,7 @@ MrBomb::MrBomb(const Reader& reader) :
   grabbed = false;
 
   //Prevent stutter when Tux jumps on Mr Bomb
-  sound_manager->preload("sounds/explosion.wav");
+  SoundManager::current()->preload("sounds/explosion.wav");
 
   //Check if we need another sprite
   if( !reader.get( "sprite", sprite_name ) ){
@@ -45,7 +45,7 @@ MrBomb::MrBomb(const Reader& reader) :
     return;
   }
   //Replace sprite
-  sprite = sprite_manager->create( sprite_name );
+  sprite = SpriteManager::current()->create( sprite_name );
 }
 
 /* MrBomb created by a dispenser always gets default sprite atm.*/
@@ -56,7 +56,7 @@ MrBomb::MrBomb(const Vector& pos, Direction d) :
   walk_speed = 80;
   max_drop_height = 16;
   grabbed = false;
-  sound_manager->preload("sounds/explosion.wav");
+  SoundManager::current()->preload("sounds/explosion.wav");
 }
 
 HitResponse
index c46e925..f87539b 100644 (file)
@@ -39,9 +39,9 @@ MrIceBlock::MrIceBlock(const Reader& reader) :
 {
   walk_speed = 80;
   max_drop_height = 600;
-  sound_manager->preload("sounds/iceblock_bump.wav");
-  sound_manager->preload("sounds/stomp.wav");
-  sound_manager->preload("sounds/kick.wav");
+  SoundManager::current()->preload("sounds/iceblock_bump.wav");
+  SoundManager::current()->preload("sounds/stomp.wav");
+  SoundManager::current()->preload("sounds/kick.wav");
 }
 
 MrIceBlock::MrIceBlock(const Vector& pos, Direction d) :
@@ -53,9 +53,9 @@ MrIceBlock::MrIceBlock(const Vector& pos, Direction d) :
 {
   walk_speed = 80;
   max_drop_height = 600;
-  sound_manager->preload("sounds/iceblock_bump.wav");
-  sound_manager->preload("sounds/stomp.wav");
-  sound_manager->preload("sounds/kick.wav");
+  SoundManager::current()->preload("sounds/iceblock_bump.wav");
+  SoundManager::current()->preload("sounds/stomp.wav");
+  SoundManager::current()->preload("sounds/kick.wav");
 }
 
 void
@@ -106,7 +106,7 @@ MrIceBlock::collision_solid(const CollisionHit& hit)
     case ICESTATE_KICKED: {
       if((hit.right && dir == RIGHT) || (hit.left && dir == LEFT)) {
         dir = (dir == LEFT) ? RIGHT : LEFT;
-        sound_manager->play("sounds/iceblock_bump.wav", get_pos());
+        SoundManager::current()->play("sounds/iceblock_bump.wav", get_pos());
         physic.set_velocity_x(-physic.get_velocity_x()*.975);
       }
       this->set_action(dir == LEFT ? "flat-left" : "flat-right", /* loops = */ -1);
@@ -238,7 +238,7 @@ MrIceBlock::set_state(IceState state_, bool up)
       if(up) {
         physic.set_velocity_y(-KICKSPEED);
       } else {
-        sound_manager->play("sounds/stomp.wav", get_pos());
+        SoundManager::current()->play("sounds/stomp.wav", get_pos());
         physic.set_velocity_x(0);
         physic.set_velocity_y(0);
       }
@@ -246,7 +246,7 @@ MrIceBlock::set_state(IceState state_, bool up)
       flat_timer.start(4);
       break;
     case ICESTATE_KICKED:
-      sound_manager->play("sounds/kick.wav", get_pos());
+      SoundManager::current()->play("sounds/kick.wav", get_pos());
 
       physic.set_velocity_x(dir == LEFT ? -KICKSPEED : KICKSPEED);
       this->set_action(dir == LEFT ? "flat-left" : "flat-right", /* loops = */ -1);
@@ -294,7 +294,7 @@ SmartBlock::SmartBlock(const Reader& reader) :
   MrIceBlock(reader)
 {
   max_drop_height = 16;
-  sprite = sprite_manager->create("images/creatures/mr_iceblock/smart_block/smart_block.sprite");
+  sprite = SpriteManager::current()->create("images/creatures/mr_iceblock/smart_block/smart_block.sprite");
 }
 
 /* EOF */
index cc8feb8..74c46a5 100644 (file)
@@ -38,7 +38,7 @@ MrTree::MrTree(const Reader& reader)
 {
   walk_speed = TREE_SPEED;
   max_drop_height = 16;
-  sound_manager->preload("sounds/mr_tree.ogg");
+  SoundManager::current()->preload("sounds/mr_tree.ogg");
 }
 
 bool
@@ -59,7 +59,7 @@ MrTree::collision_squished(GameObject& object)
   Sector::current()->add_object(stumpy);
 
   // give Feedback
-  sound_manager->play("sounds/mr_tree.ogg", get_pos());
+  SoundManager::current()->play("sounds/mr_tree.ogg", get_pos());
   Player* player = dynamic_cast<Player*>(&object);
   if (player) player->bounce(*this);
 
index f31fe9c..54c9433 100644 (file)
@@ -143,7 +143,7 @@ Owl::collision_squished(GameObject&)
 void
 Owl::kill_fall()
 {
-  sound_manager->play("sounds/fall.wav", get_pos());
+  SoundManager::current()->play("sounds/fall.wav", get_pos());
   physic.set_velocity_y(0);
   physic.set_acceleration_y(0);
   physic.enable_gravity(true);
index 58ecfa5..8e5423d 100644 (file)
@@ -29,7 +29,7 @@ Root::Root(const Vector& pos) :
   offset_y(0),
   hatch_timer()
 {
-  base_sprite = sprite_manager->create("images/creatures/ghosttree/root-base.sprite");
+  base_sprite = SpriteManager::current()->create("images/creatures/ghosttree/root-base.sprite");
   base_sprite->set_action("appearing", 1);
   base_sprite->set_animation_loops(1); // TODO: necessary because set_action ignores loops for default action
   physic.enable_gravity(false);
index 8b07a3e..0bd6472 100644 (file)
@@ -44,7 +44,7 @@ ShortFuse::ShortFuse(const Reader& reader) :
     return;
   }
   //Replace sprite
-  sprite = sprite_manager->create( sprite_name );
+  sprite = SpriteManager::current()->create( sprite_name );
 }
 
 void
index 2d2fc89..7f1d7be 100644 (file)
@@ -32,7 +32,7 @@ SkullyHop::SkullyHop(const Reader& reader) :
   recover_timer(),
   state()
 {
-  sound_manager->preload( SKULLYHOP_SOUND );
+  SoundManager::current()->preload( SKULLYHOP_SOUND );
 }
 
 SkullyHop::SkullyHop(const Vector& pos, Direction d) :
@@ -40,7 +40,7 @@ SkullyHop::SkullyHop(const Vector& pos, Direction d) :
   recover_timer(),
   state()
 {
-  sound_manager->preload( SKULLYHOP_SOUND );
+  SoundManager::current()->preload( SKULLYHOP_SOUND );
 }
 
 void
@@ -71,7 +71,7 @@ const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */
         physic.set_velocity_x(dir == LEFT ? -HORIZONTAL_SPEED : HORIZONTAL_SPEED);
 const float VERTICAL_SPEED = -450;   /**< y-speed when jumping */
         physic.set_velocity_y(VERTICAL_SPEED);
-        sound_manager->play( SKULLYHOP_SOUND, get_pos());
+        SoundManager::current()->play( SKULLYHOP_SOUND, get_pos());
       }
 
   state = newState;
index 7592c15..f0f62f2 100644 (file)
@@ -37,9 +37,9 @@ Snail::Snail(const Reader& reader) :
 {
   walk_speed = 80;
   max_drop_height = 600;
-  sound_manager->preload("sounds/iceblock_bump.wav");
-  sound_manager->preload("sounds/stomp.wav");
-  sound_manager->preload("sounds/kick.wav");
+  SoundManager::current()->preload("sounds/iceblock_bump.wav");
+  SoundManager::current()->preload("sounds/stomp.wav");
+  SoundManager::current()->preload("sounds/kick.wav");
 }
 
 Snail::Snail(const Vector& pos, Direction d) :
@@ -50,9 +50,9 @@ Snail::Snail(const Vector& pos, Direction d) :
 {
   walk_speed = 80;
   max_drop_height = 600;
-  sound_manager->preload("sounds/iceblock_bump.wav");
-  sound_manager->preload("sounds/stomp.wav");
-  sound_manager->preload("sounds/kick.wav");
+  SoundManager::current()->preload("sounds/iceblock_bump.wav");
+  SoundManager::current()->preload("sounds/stomp.wav");
+  SoundManager::current()->preload("sounds/kick.wav");
 }
 
 void
@@ -159,7 +159,7 @@ Snail::collision_solid(const CollisionHit& hit)
       return;
     case STATE_KICKED:
       if(hit.left || hit.right) {
-        sound_manager->play("sounds/iceblock_bump.wav", get_pos());
+        SoundManager::current()->play("sounds/iceblock_bump.wav", get_pos());
 
         if( ( dir == LEFT && hit.left ) || ( dir == RIGHT && hit.right) ){
           dir = (dir == LEFT) ? RIGHT : LEFT;
@@ -251,12 +251,12 @@ Snail::collision_squished(GameObject& object)
         kill_fall();
         return true;
       }
-      sound_manager->play("sounds/stomp.wav", get_pos());
+      SoundManager::current()->play("sounds/stomp.wav", get_pos());
       be_flat();
       break;
 
     case STATE_FLAT:
-      sound_manager->play("sounds/kick.wav", get_pos());
+      SoundManager::current()->play("sounds/kick.wav", get_pos());
       {
         MovingObject* movingobject = dynamic_cast<MovingObject*>(&object);
         if (movingobject && (movingobject->get_pos().x < get_pos().x)) {
index c6b9747..7edc1c1 100644 (file)
@@ -26,7 +26,7 @@ Snowman::Snowman(const Reader& reader) :
   WalkingBadguy(reader, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
 {
   walk_speed = 40;
-  sound_manager->preload("sounds/pop.ogg");
+  SoundManager::current()->preload("sounds/pop.ogg");
 }
 
 void
@@ -58,7 +58,7 @@ Snowman::collision_bullet(Bullet& bullet, const CollisionHit& hit)
     // fire bullets destroy snowman's body
     loose_head();
 
-    sound_manager->play("sounds/pop.ogg", get_pos()); // this could be a different sound
+    SoundManager::current()->play("sounds/pop.ogg", get_pos()); // this could be a different sound
     bullet.remove_me();
 
     return ABORT_MOVE;
@@ -78,7 +78,7 @@ Snowman::collision_squished(GameObject& object)
   if (player)
     player->bounce(*this);
 
-  sound_manager->play("sounds/pop.ogg", get_pos());
+  SoundManager::current()->play("sounds/pop.ogg", get_pos());
 
   loose_head();
 
index 5e6e837..84febae 100644 (file)
@@ -35,9 +35,9 @@ Stalactite::Stalactite(const Reader& lisp) :
 {
   countMe = false;
   set_colgroup_active(COLGROUP_TOUCHABLE);
-  sound_manager->preload("sounds/cracking.wav");
-  sound_manager->preload("sounds/sizzle.ogg");
-  sound_manager->preload("sounds/icecrash.ogg");
+  SoundManager::current()->preload("sounds/cracking.wav");
+  SoundManager::current()->preload("sounds/sizzle.ogg");
+  SoundManager::current()->preload("sounds/icecrash.ogg");
 }
 
 void
@@ -52,7 +52,7 @@ Stalactite::active_update(float elapsed_time)
          && player->get_bbox().p1.y < bbox.p2.y + SHAKE_RANGE_Y) {
         timer.start(SHAKE_TIME);
         state = STALACTITE_SHAKING;
-        sound_manager->play("sounds/cracking.wav", get_pos());
+        SoundManager::current()->play("sounds/cracking.wav", get_pos());
       }
     }
   } else if(state == STALACTITE_SHAKING) {
@@ -76,7 +76,7 @@ Stalactite::squish()
   physic.set_velocity_y(0);
   set_state(STATE_SQUISHED);
   sprite->set_action("squished");
-  sound_manager->play("sounds/icecrash.ogg", get_pos());
+  SoundManager::current()->play("sounds/icecrash.ogg", get_pos());
   set_group(COLGROUP_MOVING_ONLY_STATIC);
   run_dead_script();
 }
@@ -129,8 +129,8 @@ Stalactite::collision_bullet(Bullet& bullet, const CollisionHit& )
     state = STALACTITE_SHAKING;
     bullet.remove_me();
     if(bullet.get_type() == FIRE_BONUS)
-      sound_manager->play("sounds/sizzle.ogg", get_pos());
-    sound_manager->play("sounds/cracking.wav", get_pos());
+      SoundManager::current()->play("sounds/sizzle.ogg", get_pos());
+    SoundManager::current()->play("sounds/cracking.wav", get_pos());
   }
 
   return FORCE_MOVE;
index 5a61070..7eb6c4e 100644 (file)
@@ -35,7 +35,7 @@ Stumpy::Stumpy(const Reader& reader) :
 {
   walk_speed = STUMPY_SPEED;
   max_drop_height = 16;
-  sound_manager->preload("sounds/mr_treehit.ogg");
+  SoundManager::current()->preload("sounds/mr_treehit.ogg");
 }
 
 Stumpy::Stumpy(const Vector& pos, Direction d) :
@@ -45,7 +45,7 @@ Stumpy::Stumpy(const Vector& pos, Direction d) :
 {
   walk_speed = STUMPY_SPEED;
   max_drop_height = 16;
-  sound_manager->preload("sounds/mr_treehit.ogg");
+  SoundManager::current()->preload("sounds/mr_treehit.ogg");
   invincible_timer.start(INVINCIBLE_TIME);
 }
 
@@ -87,7 +87,7 @@ Stumpy::collision_squished(GameObject& object)
 
   // if we're still invincible, we ignore the hit
   if (mystate == STATE_INVINCIBLE) {
-    sound_manager->play("sounds/mr_treehit.ogg", get_pos());
+    SoundManager::current()->play("sounds/mr_treehit.ogg", get_pos());
     Player* player = dynamic_cast<Player*>(&object);
     if (player) player->bounce(*this);
     return true;
index f70f87a..2314e10 100644 (file)
@@ -33,7 +33,7 @@ Toad::Toad(const Reader& reader) :
   recover_timer(),
   state()
 {
-  sound_manager->preload(HOP_SOUND);
+  SoundManager::current()->preload(HOP_SOUND);
 }
 
 Toad::Toad(const Vector& pos, Direction d) :
@@ -41,7 +41,7 @@ Toad::Toad(const Vector& pos, Direction d) :
   recover_timer(),
   state()
 {
-  sound_manager->preload(HOP_SOUND);
+  SoundManager::current()->preload(HOP_SOUND);
 }
 
 void
@@ -68,7 +68,7 @@ Toad::set_state(ToadState newState)
       sprite->set_action(dir == LEFT ? "jumping-left" : "jumping-right");
       physic.set_velocity_x(dir == LEFT ? -HORIZONTAL_SPEED : HORIZONTAL_SPEED);
       physic.set_velocity_y(VERTICAL_SPEED);
-      sound_manager->play( HOP_SOUND, get_pos());
+      SoundManager::current()->play( HOP_SOUND, get_pos());
     } else
       if (newState == FALLING) {
         Player* player = get_nearest_player();
index 70bd850..5941a1b 100644 (file)
@@ -33,7 +33,7 @@ Totem::Totem(const Reader& reader) :
   carrying(0),
   carried_by(0)
 {
-  sound_manager->preload( LAND_ON_TOTEM_SOUND );
+  SoundManager::current()->preload( LAND_ON_TOTEM_SOUND );
 }
 
 Totem::~Totem()
@@ -222,7 +222,7 @@ Totem::jump_on(Totem* target)
   this->initialize();
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
 
-  sound_manager->play( LAND_ON_TOTEM_SOUND , get_pos());
+  SoundManager::current()->play( LAND_ON_TOTEM_SOUND , get_pos());
 
   this->synchronize_with(target);
 }
index 5ca187e..3de20e0 100644 (file)
@@ -42,7 +42,7 @@ TreeWillOWisp::TreeWillOWisp(GhostTree* tree_, const Vector& pos,
   tree(tree_),
   suck_target()
 {
-  sound_manager->preload(TREEWILLOSOUND);
+  SoundManager::current()->preload(TREEWILLOSOUND);
 
   this->radius = radius_;
   this->angle  = 0;
@@ -58,7 +58,7 @@ TreeWillOWisp::~TreeWillOWisp()
 void
 TreeWillOWisp::activate()
 {
-  sound_source = sound_manager->create_sound_source(TREEWILLOSOUND);
+  sound_source = SoundManager::current()->create_sound_source(TREEWILLOSOUND);
   sound_source->set_position(get_pos());
   sound_source->set_looping(true);
   sound_source->set_gain(2.0);
index 7cc348a..282595e 100644 (file)
@@ -46,7 +46,7 @@ WillOWisp::WillOWisp(const Reader& reader) :
   flyspeed(),
   track_range(),
   vanish_range(),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   bool running = false;
   flyspeed     = FLYSPEED;
@@ -72,8 +72,8 @@ WillOWisp::WillOWisp(const Reader& reader) :
   }
 
   countMe = false;
-  sound_manager->preload(SOUNDFILE);
-  sound_manager->preload("sounds/warp.wav");
+  SoundManager::current()->preload(SOUNDFILE);
+  SoundManager::current()->preload("sounds/warp.wav");
 
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   lightsprite->set_color(Color(0.0f, 0.2f, 0.0f));
@@ -159,7 +159,7 @@ WillOWisp::active_update(float elapsed_time)
 void
 WillOWisp::activate()
 {
-  sound_source = sound_manager->create_sound_source(SOUNDFILE);
+  sound_source = SoundManager::current()->create_sound_source(SOUNDFILE);
   sound_source->set_position(get_pos());
   sound_source->set_looping(true);
   sound_source->set_gain(2.0);
@@ -226,7 +226,7 @@ WillOWisp::collision_player(Player& player, const CollisionHit& ) {
   } else {
     GameSession::current()->respawn(target_sector, target_spawnpoint);
   }
-  sound_manager->play("sounds/warp.wav");
+  SoundManager::current()->play("sounds/warp.wav");
 
   return CONTINUE;
 }
index f7f8a4d..e958d53 100644 (file)
@@ -62,8 +62,8 @@ Yeti::Yeti(const Reader& reader) :
 {
   hit_points = INITIAL_HITPOINTS;
   countMe = false;
-  sound_manager->preload("sounds/yeti_gna.wav");
-  sound_manager->preload("sounds/yeti_roar.wav");
+  SoundManager::current()->preload("sounds/yeti_gna.wav");
+  SoundManager::current()->preload("sounds/yeti_roar.wav");
   hud_head = Surface::create("images/creatures/yeti/hudlife.png");
 }
 
@@ -126,7 +126,7 @@ Yeti::active_update(float elapsed_time)
       break;
     case BE_ANGRY:
       if(state_timer.check()) {
-        sound_manager->play("sounds/yeti_gna.wav");
+        SoundManager::current()->play("sounds/yeti_gna.wav");
         physic.set_velocity_y(STOMP_VY);
         sprite->set_action((dir==RIGHT)?"stomp-right":"stomp-left");
       }
@@ -205,7 +205,7 @@ void Yeti::take_hit(Player& )
   if(safe_timer.started())
     return;
 
-  sound_manager->play("sounds/yeti_roar.wav");
+  SoundManager::current()->play("sounds/yeti_roar.wav");
   hit_points--;
 
   if(hit_points <= 0) {
index 1a0736c..8b7ec19 100644 (file)
@@ -25,6 +25,7 @@
 #include <vector>
 #include <memory>
 
+#include "util/currenton.hpp"
 #include "util/reader_fwd.hpp"
 #include "util/writer_fwd.hpp"
 
@@ -36,7 +37,7 @@ class KeyboardManager;
 class KeyboardMenu;
 class Menu;
 
-class InputManager final
+class InputManager final : public Currenton<InputManager>
 {
 private:
   friend class KeyboardMenu;
index be3b208..a329e25 100644 (file)
@@ -180,7 +180,7 @@ Menu::process_input()
   }
 
   MenuAction menuaction = MENU_ACTION_NONE;
-  Controller* controller = g_input_manager->get_controller();
+  Controller* controller = InputManager::current()->get_controller();
   /** check main input controller... */
   if(controller->pressed(Controller::UP)) {
     menuaction = MENU_ACTION_UP;
index 89087b1..9a34c98 100644 (file)
@@ -258,7 +258,7 @@ MenuManager::set_menu(std::unique_ptr<Menu> menu)
   }
 
   // just to be sure...
-  g_input_manager->reset();
+  InputManager::current()->reset();
 }
 
 void
index c2e9f55..14539e6 100644 (file)
@@ -89,7 +89,7 @@ AmbientSound::AmbientSound(const Reader& lisp) :
   lisp.get("silence_distance",silence_distance);
 
   sound_source.reset(); // not playing at the beginning
-  sound_manager->preload(sample);
+  SoundManager::current()->preload(sample);
   latency=0;
 }
 
@@ -127,7 +127,7 @@ AmbientSound::AmbientSound(Vector pos, float factor, float bias, float vol, std:
     silence_distance = 1/distance_factor;
 
   sound_source = 0; // not playing at the beginning
-  sound_manager->preload(sample);
+  SoundManager::current()->preload(sample);
   latency=0;
 }
 
@@ -151,7 +151,7 @@ void
 AmbientSound::start_playing()
 {
   try {
-    sound_source = sound_manager->create_sound_source(sample);
+    sound_source = SoundManager::current()->create_sound_source(sample);
     if(!sound_source)
       throw std::runtime_error("file not found");
 
index dd1272f..1e24271 100644 (file)
@@ -42,8 +42,8 @@ Block::Block(SpritePtr newsprite) :
 {
   bbox.set_size(32, 32.1f);
   set_group(COLGROUP_STATIC);
-  sound_manager->preload("sounds/upgrade.wav");
-  sound_manager->preload("sounds/brick.wav");
+  SoundManager::current()->preload("sounds/upgrade.wav");
+  SoundManager::current()->preload("sounds/brick.wav");
 }
 
 Block::~Block()
index b3f80ba..dbcc20c 100644 (file)
@@ -40,7 +40,7 @@
 #include <stdexcept>
 
 BonusBlock::BonusBlock(const Vector& pos, int data) :
-  Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")),
+  Block(SpriteManager::current()->create("images/objects/bonus_block/bonusblock.sprite")),
   contents(),
   object(0),
   hit_counter(1),
@@ -57,7 +57,7 @@ BonusBlock::BonusBlock(const Vector& pos, int data) :
     case 4: contents = CONTENT_1UP; break;
     case 5: contents = CONTENT_ICEGROW; break;
     case 6: contents = CONTENT_LIGHT;
-      sound_manager->preload("sounds/switch.ogg");
+      SoundManager::current()->preload("sounds/switch.ogg");
       lightsprite=Surface::create("/images/objects/lightmap_light/bonusblock_light.png");
       break;
     case 7: contents = CONTENT_TRAMPOLINE;
@@ -82,7 +82,7 @@ BonusBlock::BonusBlock(const Vector& pos, int data) :
 }
 
 BonusBlock::BonusBlock(const Reader& lisp) :
-  Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")),
+  Block(SpriteManager::current()->create("images/objects/bonus_block/bonusblock.sprite")),
   contents(),
   object(0),
   hit_counter(1),
@@ -102,7 +102,7 @@ BonusBlock::BonusBlock(const Reader& lisp) :
       iter.value()->get(pos.y);
     } else if(token == "sprite") {
       iter.value()->get(sprite_name);
-      sprite = sprite_manager->create(sprite_name);
+      sprite = SpriteManager::current()->create(sprite_name);
     } else if(token == "count") {
       iter.value()->get(hit_counter);
     } else if(token == "script") {
@@ -126,7 +126,7 @@ BonusBlock::BonusBlock(const Reader& lisp) :
         contents = CONTENT_SCRIPT;
       } else if(contentstring == "light") {
         contents = CONTENT_LIGHT;
-        sound_manager->preload("sounds/switch.ogg");
+        SoundManager::current()->preload("sounds/switch.ogg");
       } else if(contentstring == "trampoline") {
         contents = CONTENT_TRAMPOLINE;
       } else if(contentstring == "rain") {
@@ -200,7 +200,7 @@ void
 BonusBlock::try_open(Player *player)
 {
   if(sprite->get_action() == "empty") {
-    sound_manager->play("sounds/brick.wav");
+    SoundManager::current()->play("sounds/brick.wav");
     return;
   }
 
@@ -235,7 +235,7 @@ BonusBlock::try_open(Player *player)
           get_pos(), new Flower(FIRE_BONUS));
         sector->add_object(riser);
       }
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       break;
     }
 
@@ -249,21 +249,21 @@ BonusBlock::try_open(Player *player)
           get_pos(), new Flower(ICE_BONUS));
         sector->add_object(riser);
       }
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       break;
     }
 
     case CONTENT_STAR:
     {
       sector->add_object(new Star(get_pos() + Vector(0, -32), direction));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       break;
     }
 
     case CONTENT_1UP:
     {
       sector->add_object(new OneUp(get_pos(), direction));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       break;
     }
 
@@ -272,7 +272,7 @@ BonusBlock::try_open(Player *player)
       SpecialRiser* riser = new SpecialRiser(get_pos(), object);
       object = 0;
       sector->add_object(riser);
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       break;
     }
 
@@ -285,28 +285,28 @@ BonusBlock::try_open(Player *player)
         sprite->set_action("off");
       else
         sprite->set_action("on");
-      sound_manager->play("sounds/switch.ogg");
+      SoundManager::current()->play("sounds/switch.ogg");
       break;
     }
     case CONTENT_TRAMPOLINE:
     {
       SpecialRiser* riser = new SpecialRiser(get_pos(), new Trampoline(get_pos(), false));
       sector->add_object(riser);
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       break;
     }
     case CONTENT_RAIN:
     {
       hit_counter = 1; // multiple hits of coin rain is not allowed
       Sector::current()->add_object(new CoinRain(get_pos(), true));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       break;
     }
     case CONTENT_EXPLODE:
     {
       hit_counter = 1; // multiple hits of coin explode is not allowed
       Sector::current()->add_object(new CoinExplode(get_pos() + Vector (0, -40)));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       break;
     }
   }
@@ -329,7 +329,7 @@ void
 BonusBlock::try_drop(Player *player)
 {
   if(sprite->get_action() == "empty") {
-    sound_manager->play("sounds/brick.wav");
+    SoundManager::current()->play("sounds/brick.wav");
     return;
   }
 
@@ -367,7 +367,7 @@ BonusBlock::try_drop(Player *player)
     case CONTENT_FIREGROW:
     {
       sector->add_object(new PowerUp(get_pos() + Vector(0, 32), "images/powerups/fireflower/fireflower.sprite"));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       countdown = true;
       break;
     }
@@ -375,7 +375,7 @@ BonusBlock::try_drop(Player *player)
     case CONTENT_ICEGROW:
     {
       sector->add_object(new PowerUp(get_pos() + Vector(0, 32), "images/powerups/iceflower/iceflower.sprite"));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       countdown = true;
       break;
     }
@@ -383,7 +383,7 @@ BonusBlock::try_drop(Player *player)
     case CONTENT_STAR:
     {
       sector->add_object(new Star(get_pos() + Vector(0, 32), direction));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       countdown = true;
       break;
     }
@@ -391,7 +391,7 @@ BonusBlock::try_drop(Player *player)
     case CONTENT_1UP:
     {
       sector->add_object(new OneUp(get_pos(), DOWN));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       countdown = true;
       break;
     }
@@ -402,7 +402,7 @@ BonusBlock::try_drop(Player *player)
       object->set_pos(get_pos() +  Vector(0, 32));
       sector->add_object(object);
       object = 0;
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       countdown = true;
       break;
     }
@@ -429,7 +429,7 @@ BonusBlock::try_drop(Player *player)
     {
       hit_counter = 1; // multiple hits of coin explode is not allowed
       Sector::current()->add_object(new CoinExplode(get_pos() + Vector (0, 40)));
-      sound_manager->play("sounds/upgrade.wav");
+      SoundManager::current()->play("sounds/upgrade.wav");
       countdown = true;
       break;
     }
index 12b3148..6e95673 100644 (file)
@@ -31,7 +31,7 @@ BouncyCoin::BouncyCoin(const Vector& pos, bool emerge) :
   emerge_distance(0)
 {
   timer.start(LIFE_TIME);
-  sprite = sprite_manager->create("images/objects/coin/coin.sprite");
+  sprite = SpriteManager::current()->create("images/objects/coin/coin.sprite");
 
   if(emerge) {
     emerge_distance = sprite->get_height();
index 8e85da7..4b2b90c 100644 (file)
@@ -28,7 +28,7 @@
 #include "supertux/sector.hpp"
 
 Brick::Brick(const Vector& pos, int data, const std::string& spriteName)
-  : Block(sprite_manager->create(spriteName)), breakable(false),
+  : Block(SpriteManager::current()->create(spriteName)), breakable(false),
     coin_counter(0)
 {
   bbox.set_pos(pos);
@@ -84,7 +84,7 @@ Brick::try_break(Player* player)
   if(sprite->get_action() == "empty")
     return;
 
-  sound_manager->play("sounds/brick.wav");
+  SoundManager::current()->play("sounds/brick.wav");
   Sector* sector = Sector::current();
   Player& player_one = *(sector->player);
   if(coin_counter > 0) {
index c6a4867..46c5260 100644 (file)
@@ -32,23 +32,23 @@ Bullet::Bullet(const Vector& pos, float xm, int dir, BonusType type_) :
   life_count(3),
   sprite(),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
   type(type_)
 {
   float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM;
   physic.set_velocity_x(speed + xm);
 
   if(type == FIRE_BONUS) {
-    sprite = sprite_manager->create("images/objects/bullets/firebullet.sprite");
+    sprite = SpriteManager::current()->create("images/objects/bullets/firebullet.sprite");
     lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
     lightsprite->set_color(Color(0.3f, 0.1f, 0.0f));
  } else if(type == ICE_BONUS) {
     life_count = 10;
-    sprite = sprite_manager->create("images/objects/bullets/icebullet.sprite");
+    sprite = SpriteManager::current()->create("images/objects/bullets/icebullet.sprite");
   } else {
     log_warning << "Bullet::Bullet called with unknown BonusType" << std::endl;
     life_count = 10;
-    sprite = sprite_manager->create("images/objects/bullets/firebullet.sprite");
+    sprite = SpriteManager::current()->create("images/objects/bullets/firebullet.sprite");
   }
 
   bbox.set_pos(pos);
index a3b8f15..84535f6 100644 (file)
@@ -28,8 +28,8 @@ Candle::Candle(const Reader& lisp)
     burning(true),
     flicker(true),
     lightcolor(1.0f, 1.0f, 1.0f),
-    candle_light_1(sprite_manager->create("images/objects/candle/candle-light-1.sprite")),
-    candle_light_2(sprite_manager->create("images/objects/candle/candle-light-2.sprite"))
+    candle_light_1(SpriteManager::current()->create("images/objects/candle/candle-light-1.sprite")),
+    candle_light_2(SpriteManager::current()->create("images/objects/candle/candle-light-2.sprite"))
 {
   lisp.get("name", name);
   lisp.get("burning", burning);
index d3cc163..cf82ff3 100644 (file)
@@ -33,7 +33,7 @@ Coin::Coin(const Vector& pos)
     from_tilemap(false),
     physic()
 {
-  sound_manager->preload("sounds/coin.wav");
+  SoundManager::current()->preload("sounds/coin.wav");
 }
 
 Coin::Coin(const Vector& pos, TileMap* tilemap)
@@ -49,7 +49,7 @@ Coin::Coin(const Vector& pos, TileMap* tilemap)
     offset = pos - v;
   }
 
-  sound_manager->preload("sounds/coin.wav");
+  SoundManager::current()->preload("sounds/coin.wav");
 }
 
 Coin::Coin(const Reader& reader)
@@ -69,7 +69,7 @@ Coin::Coin(const Reader& reader)
     set_pos(v);
   }
 
-  sound_manager->preload("sounds/coin.wav");
+  SoundManager::current()->preload("sounds/coin.wav");
 }
 
 void
@@ -149,11 +149,11 @@ Coin::collect()
     }
     sound_timer.start(1);
 
-    SoundSource* soundSource = sound_manager->create_sound_source("sounds/coin.wav");
+    SoundSource* soundSource = SoundManager::current()->create_sound_source("sounds/coin.wav");
     soundSource->set_position(get_pos());
     soundSource->set_pitch(pitch);
     soundSource->play();
-    sound_manager->manage_source(soundSource);
+    SoundManager::current()->manage_source(soundSource);
   */
   Sector::current()->player->get_status()->add_coins(1);
   Sector::current()->add_object(new BouncyCoin(get_pos()));
@@ -178,7 +178,7 @@ HeavyCoin::HeavyCoin(const Vector& pos, const Vector& init_velocity)
   physic()
 {
   physic.enable_gravity(true);
-  sound_manager->preload("sounds/coin2.ogg");
+  SoundManager::current()->preload("sounds/coin2.ogg");
   set_group(COLGROUP_MOVING);
   physic.set_velocity(init_velocity);
 }
@@ -188,7 +188,7 @@ HeavyCoin::HeavyCoin(const Reader& reader)
   physic()
 {
   physic.enable_gravity(true);
-  sound_manager->preload("sounds/coin2.ogg");
+  SoundManager::current()->preload("sounds/coin2.ogg");
   set_group(COLGROUP_MOVING);
 }
 
@@ -207,7 +207,7 @@ HeavyCoin::collision_solid(const CollisionHit& hit)
 
   if(hit.bottom) {
     if(physic.get_velocity_y() > clink_threshold)
-      sound_manager->play("sounds/coin2.ogg");
+      SoundManager::current()->play("sounds/coin2.ogg");
     if(physic.get_velocity_y() > 200) {// lets some coins bounce
       physic.set_velocity_y(-99);
     }else{
@@ -217,12 +217,12 @@ HeavyCoin::collision_solid(const CollisionHit& hit)
   }
   if(hit.right || hit.left) {
     if(physic.get_velocity_x() > clink_threshold || physic.get_velocity_x() < clink_threshold)
-      sound_manager->play("sounds/coin2.ogg");
+      SoundManager::current()->play("sounds/coin2.ogg");
     physic.set_velocity_x(-physic.get_velocity_x());
   }
   if(hit.top) {
     if(physic.get_velocity_y() < clink_threshold)
-      sound_manager->play("sounds/coin2.ogg");
+      SoundManager::current()->play("sounds/coin2.ogg");
     physic.set_velocity_y(-physic.get_velocity_y());
   }
 }
index 05426e6..c3b10e5 100644 (file)
@@ -32,7 +32,7 @@ CoinRain::CoinRain(const Vector& pos, bool emerge) :
   counter(0),
   drop(0)
 {
-  sprite = sprite_manager->create("images/objects/coin/coin.sprite");
+  sprite = SpriteManager::current()->create("images/objects/coin/coin.sprite");
 
   if(emerge) {
     emerge_distance = sprite->get_height();
index 2e4f830..f2f0ba4 100644 (file)
@@ -40,7 +40,7 @@ void
 EndSequenceFireworks::starting()
 {
   EndSequence::starting();
-  endsequence_timer.start(7.3f * g_screen_manager->get_speed());
+  endsequence_timer.start(7.3f * ScreenManager::current()->get_speed());
   Sector::current()->add_object(new Fireworks());
 }
 
index 19e2041..268db70 100644 (file)
@@ -41,7 +41,7 @@ EndSequenceWalkLeft::starting()
 {
   EndSequence::starting();
   last_x_pos = -1;
-  endsequence_timer.start(7.3f * g_screen_manager->get_speed());
+  endsequence_timer.start(7.3f * ScreenManager::current()->get_speed());
 }
 
 void
index 1631c16..6a52ddd 100644 (file)
@@ -41,7 +41,7 @@ EndSequenceWalkRight::starting()
 {
   EndSequence::starting();
   last_x_pos = -1;
-  endsequence_timer.start(7.3f * g_screen_manager->get_speed());
+  endsequence_timer.start(7.3f * ScreenManager::current()->get_speed());
 }
 
 void
index 12d164e..828f02b 100644 (file)
@@ -35,10 +35,10 @@ Explosion::Explosion(const Vector& pos) :
   push(false),
   state(STATE_WAITING),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-large.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-large.sprite"))
 {
-  sound_manager->preload("sounds/explosion.wav");
-  sound_manager->preload("sounds/firecracker.ogg");
+  SoundManager::current()->preload("sounds/explosion.wav");
+  SoundManager::current()->preload("sounds/firecracker.ogg");
   set_pos(get_pos() - (get_bbox().get_middle() - get_pos()));
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   lightsprite->set_color(Color(0.6f, 0.6f, 0.6f));
@@ -50,10 +50,10 @@ Explosion::Explosion(const Reader& reader) :
   push(false),
   state(STATE_WAITING),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-large.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-large.sprite"))
 {
-  sound_manager->preload("sounds/explosion.wav");
-  sound_manager->preload("sounds/firecracker.ogg");
+  SoundManager::current()->preload("sounds/explosion.wav");
+  SoundManager::current()->preload("sounds/firecracker.ogg");
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   lightsprite->set_color(Color(0.6f, 0.6f, 0.6f));
 }
@@ -68,7 +68,7 @@ Explosion::explode()
   set_action(hurt ? "default" : "pop", 1);
   sprite->set_animation_loops(1); //TODO: this is necessary because set_action will not set "loops" when "action" is the default action
   sprite->set_angle(graphicsRandom.randf(0, 360)); // a random rotation on the sprite to make explosions appear more random
-  sound_manager->play(hurt ? "sounds/explosion.wav" : "sounds/firecracker.ogg", get_pos());
+  SoundManager::current()->play(hurt ? "sounds/explosion.wav" : "sounds/firecracker.ogg", get_pos());
 
 #if 0
   // spawn some particles
index 66b2c2e..ffa221c 100644 (file)
@@ -25,7 +25,7 @@ FallingCoin::FallingCoin(const Vector& start_position, const int vel_x) :
   sprite()
 {
   pos = start_position;
-  sprite = sprite_manager->create("images/objects/coin/coin.sprite");
+  sprite = SpriteManager::current()->create("images/objects/coin/coin.sprite");
   physic.set_velocity_y(-800);
   physic.set_velocity_x(vel_x);
 }
index 44e60c5..a7198ec 100644 (file)
@@ -43,16 +43,16 @@ Firefly::Firefly(const Reader& lisp) :
     return;
   }
   //Replace sprite
-  sprite = sprite_manager->create( sprite_name );
+  sprite = SpriteManager::current()->create( sprite_name );
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
   reactivate();
 
   //Load sound
     if( sprite_name.find("vbell", 0) == std::string::npos ) {
-      sound_manager->preload("sounds/savebell_low.wav");
+      SoundManager::current()->preload("sounds/savebell_low.wav");
     }
     else {
-      sound_manager->preload("sounds/savebell2.wav");
+      SoundManager::current()->preload("sounds/savebell2.wav");
     }
 }
 
@@ -93,10 +93,10 @@ Firefly::collision(GameObject& other, const CollisionHit& )
     }
 
     if( sprite_name.find("vbell", 0) == std::string::npos ) {
-      sound_manager->play("sounds/savebell2.wav");
+      SoundManager::current()->play("sounds/savebell2.wav");
     }
     else {
-      sound_manager->play("sounds/savebell_low.wav");
+      SoundManager::current()->play("sounds/savebell_low.wav");
     }
 
     sprite->set_action("ringing");
index c5ec447..bd1814e 100644 (file)
@@ -27,7 +27,7 @@ Fireworks::Fireworks() :
   timer()
 {
   timer.start(.2f);
-  sound_manager->preload("sounds/fireworks.wav");
+  SoundManager::current()->preload("sounds/fireworks.wav");
 }
 
 Fireworks::~Fireworks()
@@ -52,7 +52,7 @@ Fireworks::update(float )
     sector->add_object(new Particles(pos, 0, 360, Vector(140, 140),
                                      Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f,
                                      LAYER_FOREGROUND1+1));
-    sound_manager->play("sounds/fireworks.wav");
+    SoundManager::current()->play("sounds/fireworks.wav");
     timer.start(graphicsRandom.randf(1.0, 1.5));
   }
 }
index 40d3740..1bb0fe2 100644 (file)
@@ -20,7 +20,7 @@
 #include "supertux/globals.hpp"
 
 FloatingImage::FloatingImage(const std::string& spritefile) :
-  sprite(sprite_manager->create(spritefile)),
+  sprite(SpriteManager::current()->create(spritefile)),
   layer(LAYER_FOREGROUND1 + 1),
   visible(false),
   anchor(ANCHOR_MIDDLE),
index 3f18845..d823ed7 100644 (file)
@@ -25,19 +25,19 @@ Flower::Flower(BonusType _type) :
   sprite(),
   drawing_effect(NO_EFFECT),
   light(1.0f,1.0f,1.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   bbox.set_size(32, 32);
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
 
   if(type == FIRE_BONUS) {
-    sprite = sprite_manager->create("images/powerups/fireflower/fireflower.sprite");
-    sound_manager->preload("sounds/fire-flower.wav");
+    sprite = SpriteManager::current()->create("images/powerups/fireflower/fireflower.sprite");
+    SoundManager::current()->preload("sounds/fire-flower.wav");
     lightsprite->set_color(Color(0.3f, 0.0f, 0.0f));
   }
   else if(type == ICE_BONUS) {
-    sprite = sprite_manager->create("images/powerups/iceflower/iceflower.sprite");
-    sound_manager->preload("sounds/fire-flower.wav");
+    sprite = SpriteManager::current()->create("images/powerups/iceflower/iceflower.sprite");
+    SoundManager::current()->preload("sounds/fire-flower.wav");
     lightsprite->set_color(Color(0.0f, 0.1f, 0.2f));
   } else {
     assert(false);
@@ -80,7 +80,7 @@ Flower::collision(GameObject& other, const CollisionHit& )
   if(!player->add_bonus(type, true))
     return FORCE_MOVE;
 
-  sound_manager->play("sounds/fire-flower.wav");
+  SoundManager::current()->play("sounds/fire-flower.wav");
   remove_me();
   return ABORT_MOVE;
 }
index 4e49494..50d16ea 100644 (file)
@@ -26,12 +26,12 @@ GrowUp::GrowUp(Direction direction) :
   MovingSprite(Vector(0,0), "images/powerups/egg/egg.sprite", LAYER_OBJECTS, COLGROUP_MOVING),
   physic(),
   light(0.0f,0.0f,0.0f),
-  shadesprite(sprite_manager->create("images/powerups/egg/egg.sprite")),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  shadesprite(SpriteManager::current()->create("images/powerups/egg/egg.sprite")),
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   physic.enable_gravity(true);
   physic.set_velocity_x((direction == LEFT)?-100:100);
-  sound_manager->preload("sounds/grow.ogg");
+  SoundManager::current()->preload("sounds/grow.ogg");
   //shadow to remain in place as egg rolls
   shadesprite->set_action("shadow");
   //set light for glow effect
@@ -89,7 +89,7 @@ GrowUp::collision(GameObject& other, const CollisionHit& hit )
       return ABORT_MOVE;
     }
 
-    sound_manager->play("sounds/grow.ogg");
+    SoundManager::current()->play("sounds/grow.ogg");
     remove_me();
 
     return ABORT_MOVE;
index e8374ff..d2fcf5c 100644 (file)
@@ -52,7 +52,7 @@ IceCrusher::IceCrusher(const Reader& reader) :
 {
   // TODO: icecrusher hitting deserves its own sounds-
   // one for hitting the ground, one for hitting Tux
-  sound_manager->preload("sounds/brick.wav");
+  SoundManager::current()->preload("sounds/brick.wav");
 
   start_position = get_bbox().p1;
   set_state(state, true);
@@ -61,11 +61,11 @@ IceCrusher::IceCrusher(const Reader& reader) :
   if (sprite_width >= 128.0)
     ic_size = LARGE;
 
-  lefteye = sprite_manager->create(sprite_name);
+  lefteye = SpriteManager::current()->create(sprite_name);
   lefteye->set_action("lefteye");
-  righteye = sprite_manager->create(sprite_name);
+  righteye = SpriteManager::current()->create(sprite_name);
   righteye->set_action("righteye");
-  whites = sprite_manager->create(sprite_name);
+  whites = SpriteManager::current()->create(sprite_name);
   whites->set_action("whites");
 }
 
@@ -114,7 +114,7 @@ IceCrusher::collision(GameObject& other, const CollisionHit& hit)
   /* If the other object is the player, and the collision is at the bottom of
    * the ice crusher, hurt the player. */
   if (player && hit.bottom) {
-    sound_manager->play("sounds/brick.wav");
+    SoundManager::current()->play("sounds/brick.wav");
     if(player->is_invincible()) {
       if (state == CRUSHING)
         set_state(RECOVERING);
@@ -143,7 +143,7 @@ IceCrusher::collision_solid(const CollisionHit& hit)
         if (ic_size == LARGE) {
           cooldown_timer = PAUSE_TIME_LARGE;
           Sector::current()->camera->shake (/* frequency = */ .125f, /* x = */ 0.0, /* y = */ 16.0);
-          sound_manager->play("sounds/brick.wav");
+          SoundManager::current()->play("sounds/brick.wav");
           // throw some particles, bigger and more for large icecrusher
           for(int j = 0; j < 9; j++)
           {
@@ -160,7 +160,7 @@ IceCrusher::collision_solid(const CollisionHit& hit)
         else {
           cooldown_timer = PAUSE_TIME_NORMAL;
           Sector::current()->camera->shake (/* frequency = */ .1f, /* x = */ 0.0, /* y = */ 8.0);
-          sound_manager->play("sounds/brick.wav");
+          SoundManager::current()->play("sounds/brick.wav");
           // throw some particles
           for(int j = 0; j < 5; j++)
           {
index c8ef306..2bbb42f 100644 (file)
@@ -33,7 +33,7 @@ const float HEIGHT = 200;
 }
 
 InfoBlock::InfoBlock(const Reader& lisp) :
-  Block(sprite_manager->create("images/objects/bonus_block/infoblock.sprite")),
+  Block(SpriteManager::current()->create("images/objects/bonus_block/infoblock.sprite")),
   message(),
   shown_pct(0),
   dest_pct(0),
index 6fc64ea..3f4a8c5 100644 (file)
 #include "supertux/constants.hpp"
 
 InvisibleBlock::InvisibleBlock(const Vector& pos) :
-   Block(sprite_manager->create("images/objects/bonus_block/invisibleblock.sprite")),
+   Block(SpriteManager::current()->create("images/objects/bonus_block/invisibleblock.sprite")),
    visible(false)
 {
   bbox.set_pos(pos);
-  sound_manager->preload("sounds/brick.wav");
+  SoundManager::current()->preload("sounds/brick.wav");
 }
 
 void
@@ -62,7 +62,7 @@ InvisibleBlock::collision(GameObject& other, const CollisionHit& hit_)
 void
 InvisibleBlock::hit(Player& player)
 {
-  sound_manager->play("sounds/brick.wav");
+  SoundManager::current()->play("sounds/brick.wav");
 
   if(visible)
     return;
index bde4171..798ccb4 100644 (file)
@@ -33,10 +33,10 @@ Lantern::Lantern(const Reader& reader) :
   std::vector<float> vColor;
   reader.get("color", vColor);
   lightcolor = Color(vColor);
-  lightsprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite");
+  lightsprite = SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light.sprite");
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   updateColor();
-  sound_manager->preload("sounds/willocatch.wav");
+  SoundManager::current()->preload("sounds/willocatch.wav");
 }
 
 Lantern::Lantern(const Vector& pos) :
@@ -44,10 +44,10 @@ Lantern::Lantern(const Vector& pos) :
   lightcolor(0.0f, 0.0f, 0.0f),
   lightsprite()
 {
-  lightsprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite");
+  lightsprite = SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light.sprite");
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   updateColor();
-  sound_manager->preload("sounds/willocatch.wav");
+  SoundManager::current()->preload("sounds/willocatch.wav");
 }
 
 Lantern::~Lantern()
@@ -84,7 +84,7 @@ HitResponse Lantern::collision(GameObject& other, const CollisionHit& hit) {
     WillOWisp* wow = dynamic_cast<WillOWisp*>(&other);
     if (wow) {
       // collided with WillOWisp while grabbed and unlit
-      sound_manager->play("sounds/willocatch.wav");
+      SoundManager::current()->play("sounds/willocatch.wav");
       lightcolor = Color(0,1,0);
       updateColor();
       wow->vanish();
@@ -92,7 +92,7 @@ HitResponse Lantern::collision(GameObject& other, const CollisionHit& hit) {
     TreeWillOWisp* twow = dynamic_cast<TreeWillOWisp*>(&other);
     if (twow) {
       // collided with TreeWillOWisp while grabbed and unlit
-      sound_manager->play("sounds/willocatch.wav");
+      SoundManager::current()->play("sounds/willocatch.wav");
       lightcolor = twow->get_color();
       updateColor();
       twow->vanish();
index 92a1934..34ebea8 100644 (file)
@@ -23,7 +23,7 @@ Light::Light(const Vector& center, const Color& color_) :
   color(color_),
   sprite()
 {
-  sprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite");
+  sprite = SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light.sprite");
 }
 
 Light::~Light()
index a9d877a..7d4f708 100644 (file)
@@ -28,7 +28,7 @@ MovingSprite::MovingSprite(const Vector& pos, const std::string& sprite_name_,
   layer(layer_)
 {
   bbox.set_pos(pos);
-  sprite = sprite_manager->create(sprite_name);
+  sprite = SpriteManager::current()->create(sprite_name);
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
   set_group(collision_group);
 }
@@ -42,7 +42,7 @@ MovingSprite::MovingSprite(const Reader& reader, const Vector& pos, int layer_,
   if (!reader.get("sprite", sprite_name))
     throw std::runtime_error("no sprite name set");
 
-  sprite = sprite_manager->create(sprite_name);
+  sprite = SpriteManager::current()->create(sprite_name);
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
   set_group(collision_group);
 }
@@ -56,7 +56,7 @@ MovingSprite::MovingSprite(const Reader& reader, const std::string& sprite_name_
   reader.get("y", bbox.p1.y);
   reader.get("sprite", this->sprite_name);
 
-  sprite = sprite_manager->create(this->sprite_name);
+  sprite = SpriteManager::current()->create(this->sprite_name);
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
   set_group(collision_group);
 }
@@ -71,7 +71,7 @@ MovingSprite::MovingSprite(const Reader& reader, int layer_, CollisionGroup coll
   if (!reader.get("sprite", sprite_name))
     throw std::runtime_error("no sprite name set");
 
-  sprite = sprite_manager->create(sprite_name);
+  sprite = SpriteManager::current()->create(sprite_name);
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
   set_group(collision_group);
 }
index 8a09076..ab375d7 100644 (file)
@@ -160,23 +160,23 @@ Player::Player(PlayerStatus* _player_status, const std::string& name_) :
   climbing(0)
 {
   this->name = name_;
-  controller = g_input_manager->get_controller();
+  controller = InputManager::current()->get_controller();
   scripting_controller.reset(new CodeController());
   // if/when we have complete penny gfx, we can
   // load those instead of Tux's sprite in the
   // constructor
-  sprite = sprite_manager->create("images/creatures/tux/tux.sprite");
+  sprite = SpriteManager::current()->create("images/creatures/tux/tux.sprite");
   airarrow = Surface::create("images/engine/hud/airarrow.png");
   idle_timer.start(IDLE_TIME[0]/1000.0f);
 
-  sound_manager->preload("sounds/bigjump.wav");
-  sound_manager->preload("sounds/jump.wav");
-  sound_manager->preload("sounds/hurt.wav");
-  sound_manager->preload("sounds/kill.wav");
-  sound_manager->preload("sounds/skid.wav");
-  sound_manager->preload("sounds/flip.wav");
-  sound_manager->preload("sounds/invincible_start.ogg");
-  sound_manager->preload("sounds/splash.ogg");
+  SoundManager::current()->preload("sounds/bigjump.wav");
+  SoundManager::current()->preload("sounds/jump.wav");
+  SoundManager::current()->preload("sounds/hurt.wav");
+  SoundManager::current()->preload("sounds/kill.wav");
+  SoundManager::current()->preload("sounds/skid.wav");
+  SoundManager::current()->preload("sounds/flip.wav");
+  SoundManager::current()->preload("sounds/invincible_start.ogg");
+  SoundManager::current()->preload("sounds/splash.ogg");
 
   init();
 }
@@ -550,7 +550,7 @@ Player::handle_horizontal_input()
     // let's skid!
     if(fabs(vx)>SKID_XM && !skidding_timer.started()) {
       skidding_timer.start(SKID_TIME);
-      sound_manager->play("sounds/skid.wav");
+      SoundManager::current()->play("sounds/skid.wav");
       // dust some particles
       Sector::current()->add_object(
         new Particles(
@@ -644,7 +644,7 @@ Player::do_backflip() {
   backflip_direction = (dir == LEFT)?(+1):(-1);
   backflipping = true;
   do_jump(-580);
-  sound_manager->play("sounds/flip.wav");
+  SoundManager::current()->play("sounds/flip.wav");
   backflip_timer.start(TUX_BACKFLIP_TIME);
 }
 
@@ -661,9 +661,9 @@ Player::do_jump(float yspeed) {
 
   // play sound
   if (is_big()) {
-    sound_manager->play("sounds/bigjump.wav");
+    SoundManager::current()->play("sounds/bigjump.wav");
   } else {
-    sound_manager->play("sounds/jump.wav");
+    SoundManager::current()->play("sounds/jump.wav");
   }
 }
 
@@ -1185,7 +1185,7 @@ Player::collision_tile(uint32_t tile_attributes)
     if( tile_attributes & Tile::WATER ){
       swimming = true;
       no_water = false;
-      sound_manager->play( "sounds/splash.ogg" );
+      SoundManager::current()->play( "sounds/splash.ogg" );
     }
   }
 #endif
@@ -1285,7 +1285,7 @@ Player::collision(GameObject& other, const CollisionHit& hit)
 void
 Player::make_invincible()
 {
-  sound_manager->play("sounds/invincible_start.ogg");
+  SoundManager::current()->play("sounds/invincible_start.ogg");
   invincible_timer.start(TUX_INVINCIBLE_TIME);
   Sector::current()->play_music(HERRING_MUSIC);
 }
@@ -1307,7 +1307,7 @@ Player::kill(bool completely)
   physic.set_velocity_x(0);
 
   if(!completely && is_big()) {
-    sound_manager->play("sounds/hurt.wav");
+    SoundManager::current()->play("sounds/hurt.wav");
 
     if(player_status->bonus == FIRE_BONUS
        || player_status->bonus == ICE_BONUS) {
@@ -1326,7 +1326,7 @@ Player::kill(bool completely)
       duck = false;
     }
   } else {
-    sound_manager->play("sounds/kill.wav");
+    SoundManager::current()->play("sounds/kill.wav");
 
     // do not die when in edit mode
     if (edit_mode) {
@@ -1362,7 +1362,7 @@ Player::kill(bool completely)
 
     // TODO: need nice way to handle players dying in co-op mode
     Sector::current()->effect->fade_out(3.0);
-    sound_manager->stop_music(3.0);
+    SoundManager::current()->stop_music(3.0);
   }
 }
 
index 09feaaf..686b407 100644 (file)
@@ -34,14 +34,14 @@ PowerUp::PowerUp(const Reader& lisp) :
   script(),
   no_physics(),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   lisp.get("script", script);
   no_physics = false;
   lisp.get("disable-physics", no_physics);
   physic.enable_gravity(true);
-  sound_manager->preload("sounds/grow.ogg");
-  sound_manager->preload("sounds/fire-flower.wav");
+  SoundManager::current()->preload("sounds/grow.ogg");
+  SoundManager::current()->preload("sounds/fire-flower.wav");
   //set default light for glow effect for standard sprites
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   lightsprite->set_color(Color(0.0f, 0.0f, 0.0f));
@@ -63,11 +63,11 @@ PowerUp::PowerUp(const Vector& pos, const std::string& sprite_name_) :
   script(),
   no_physics(false),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   physic.enable_gravity(true);
-  sound_manager->preload("sounds/grow.ogg");
-  sound_manager->preload("sounds/fire-flower.wav");
+  SoundManager::current()->preload("sounds/grow.ogg");
+  SoundManager::current()->preload("sounds/fire-flower.wav");
   //set default light for glow effect for standard sprites
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   lightsprite->set_color(Color(0.0f, 0.0f, 0.0f));
@@ -111,15 +111,15 @@ PowerUp::collision(GameObject& other, const CollisionHit&)
   if (sprite_name == "images/powerups/egg/egg.sprite") {
     if(!player->add_bonus(GROWUP_BONUS, true))
       return FORCE_MOVE;
-    sound_manager->play("sounds/grow.ogg");
+    SoundManager::current()->play("sounds/grow.ogg");
   } else if (sprite_name == "images/powerups/fireflower/fireflower.sprite") {
     if(!player->add_bonus(FIRE_BONUS, true))
       return FORCE_MOVE;
-    sound_manager->play("sounds/fire-flower.wav");
+    SoundManager::current()->play("sounds/fire-flower.wav");
   } else if (sprite_name == "images/powerups/iceflower/iceflower.sprite") {
     if(!player->add_bonus(ICE_BONUS, true))
       return FORCE_MOVE;
-    sound_manager->play("sounds/fire-flower.wav");
+    SoundManager::current()->play("sounds/fire-flower.wav");
   } else if (sprite_name == "images/powerups/star/star.sprite") {
     player->make_invincible();
   } else if (sprite_name == "images/powerups/1up/1up.sprite") {
index 19cc9f9..e5b7175 100644 (file)
@@ -35,7 +35,7 @@ PushButton::PushButton(const Reader& lisp) :
   script(),
   state(OFF)
 {
-  sound_manager->preload(BUTTON_SOUND);
+  SoundManager::current()->preload(BUTTON_SOUND);
   set_action("off", -1);
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
 
@@ -69,7 +69,7 @@ PushButton::collision(GameObject& other, const CollisionHit& hit)
   set_pos(get_pos() + Vector(0, old_bbox_height - new_bbox_height));
 
   // play sound
-  sound_manager->play(BUTTON_SOUND);
+  SoundManager::current()->play(BUTTON_SOUND);
 
   // run script
   std::istringstream stream(script);
index d03b014..dcb6b4f 100644 (file)
@@ -23,8 +23,8 @@ RainSplash::RainSplash(Vector pos, bool vertical) :
 {
   frame = 0;
   position = pos;
-  if (vertical) sprite = sprite_manager->create("images/objects/particles/rainsplash-vertical.sprite");
-  else sprite = sprite_manager->create("images/objects/particles/rainsplash.sprite");
+  if (vertical) sprite = SpriteManager::current()->create("images/objects/particles/rainsplash-vertical.sprite");
+  else sprite = SpriteManager::current()->create("images/objects/particles/rainsplash.sprite");
 }
 
 RainSplash::~RainSplash() {
index 48dee00..8f60e66 100644 (file)
@@ -30,7 +30,7 @@ Rock::Rock(const Vector& pos, std::string spritename) :
   grabbed(),
   last_movement()
 {
-  sound_manager->preload(ROCK_SOUND);
+  SoundManager::current()->preload(ROCK_SOUND);
   on_ground = false;
   grabbed = false;
   set_group(COLGROUP_MOVING_STATIC);
@@ -43,7 +43,7 @@ Rock::Rock(const Reader& reader) :
   grabbed(),
   last_movement()
 {
-  sound_manager->preload(ROCK_SOUND);
+  SoundManager::current()->preload(ROCK_SOUND);
   on_ground = false;
   grabbed = false;
   set_group(COLGROUP_MOVING_STATIC);
@@ -56,7 +56,7 @@ Rock::Rock(const Reader& reader, std::string spritename) :
   grabbed(),
   last_movement()
 {
-  sound_manager->preload(ROCK_SOUND);
+  SoundManager::current()->preload(ROCK_SOUND);
   on_ground = false;
   grabbed = false;
   set_group(COLGROUP_MOVING_STATIC);
@@ -87,7 +87,7 @@ Rock::collision_solid(const CollisionHit& hit)
     physic.set_velocity(0, 0);
 
   if(hit.bottom  && !on_ground && !grabbed) {
-    sound_manager->play(ROCK_SOUND, get_pos());
+    SoundManager::current()->play(ROCK_SOUND, get_pos());
     on_ground = true;
   }
 }
index 002af24..f378d0d 100644 (file)
@@ -37,7 +37,7 @@ RustyTrampoline::RustyTrampoline(const Reader& lisp) :
   Rock(lisp, "images/objects/rusty-trampoline/rusty-trampoline.sprite"),
   portable(true), counter(3)
 {
-  sound_manager->preload(BOUNCE_SOUND);
+  SoundManager::current()->preload(BOUNCE_SOUND);
 
   lisp.get("counter", counter);
   lisp.get("portable", portable); //do we really need this?
@@ -76,7 +76,7 @@ RustyTrampoline::collision(GameObject& other, const CollisionHit& hit)
           vy = VY_BOUNCE;
         }
         player->get_physic().set_velocity_y(vy);
-        sound_manager->play(BOUNCE_SOUND);
+        SoundManager::current()->play(BOUNCE_SOUND);
         counter--;
         if (counter > 0) {
           sprite->set_action("swinging", 1);
@@ -95,7 +95,7 @@ RustyTrampoline::collision(GameObject& other, const CollisionHit& hit)
       if(hit.top && vy >= 0) {
         vy = VY_BOUNCE;
         walking_badguy->set_velocity_y(vy);
-        sound_manager->play(BOUNCE_SOUND);
+        SoundManager::current()->play(BOUNCE_SOUND);
         counter--;
         if (counter > 0) {
           sprite->set_action("swinging", 1);
index 734a029..ef7fc20 100644 (file)
@@ -25,7 +25,7 @@ SmokeCloud::SmokeCloud(const Vector& pos) :
   position(pos)
 {
   timer.start(.3f);
-  sprite = sprite_manager->create("images/objects/particles/stomp.sprite");
+  sprite = SpriteManager::current()->create("images/objects/particles/stomp.sprite");
 }
 
 SmokeCloud::~SmokeCloud()
index 429c800..2055b0e 100644 (file)
@@ -40,11 +40,11 @@ Spotlight::Spotlight(const Reader& lisp) :
     color = Color( vColor );
   }
 
-  center    = sprite_manager->create("images/objects/spotlight/spotlight_center.sprite");
-  base      = sprite_manager->create("images/objects/spotlight/spotlight_base.sprite");
-  lights    = sprite_manager->create("images/objects/spotlight/spotlight_lights.sprite");
-  lightcone = sprite_manager->create("images/objects/spotlight/lightcone.sprite");
-  light     = sprite_manager->create("images/objects/spotlight/light.sprite");
+  center    = SpriteManager::current()->create("images/objects/spotlight/spotlight_center.sprite");
+  base      = SpriteManager::current()->create("images/objects/spotlight/spotlight_base.sprite");
+  lights    = SpriteManager::current()->create("images/objects/spotlight/spotlight_lights.sprite");
+  lightcone = SpriteManager::current()->create("images/objects/spotlight/lightcone.sprite");
+  light     = SpriteManager::current()->create("images/objects/spotlight/light.sprite");
 
 }
 
index 82e70fa..0285207 100644 (file)
@@ -33,10 +33,10 @@ SpriteParticle::SpriteParticle(std::string sprite_name, std::string action,
   acceleration(acceleration_),
   drawing_layer(drawing_layer_),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-tiny.sprite")),
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-tiny.sprite")),
   glow(false)
 {
-  sprite = sprite_manager->create(sprite_name);
+  sprite = SpriteManager::current()->create(sprite_name);
   if (!sprite.get()) throw std::runtime_error("Could not load sprite "+sprite_name);
   sprite->set_action(action, 1);
   sprite->set_animation_loops(1); //TODO: this is necessary because set_action will not set "loops" when "action" is the default action
index 36a2b20..66f8211 100644 (file)
@@ -31,7 +31,7 @@ Star::Star(const Vector& pos, Direction direction) :
   MovingSprite(pos, "images/powerups/star/star.sprite", LAYER_OBJECTS, COLGROUP_MOVING),
   physic(),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   physic.set_velocity((direction == LEFT) ? -STAR_SPEED : STAR_SPEED, INITIALJUMP);
   //set light for glow effect
index 793d6ab..187a4c3 100644 (file)
@@ -46,8 +46,8 @@ Thunderstorm::Thunderstorm(const Reader& reader) :
   }
   layer = reader_get_layer (reader, /* default = */ LAYER_BACKGROUNDTILES-1);
 
-  sound_manager->preload("sounds/thunder.wav");
-  sound_manager->preload("sounds/lightning.wav");
+  SoundManager::current()->preload("sounds/thunder.wav");
+  SoundManager::current()->preload("sounds/lightning.wav");
 
   if (running) {
     running = false; // else start() is ignored
@@ -118,7 +118,7 @@ Thunderstorm::stop()
 void
 Thunderstorm::thunder()
 {
-  sound_manager->play("sounds/thunder.wav");
+  SoundManager::current()->play("sounds/thunder.wav");
 }
 
 void
@@ -131,7 +131,7 @@ Thunderstorm::lightning()
 void
 Thunderstorm::flash()
 {
-  sound_manager->play("sounds/lightning.wav");
+  SoundManager::current()->play("sounds/lightning.wav");
   flash_display_timer.start(FLASH_DISPLAY_TIME);
 }
 
index 9d4e12a..b1c2fbc 100644 (file)
@@ -36,14 +36,14 @@ Trampoline::Trampoline(const Reader& lisp) :
   Rock(lisp, "images/objects/trampoline/trampoline.sprite"),
   portable(true)
 {
-  sound_manager->preload(TRAMPOLINE_SOUND);
+  SoundManager::current()->preload(TRAMPOLINE_SOUND);
 
   //Check if this trampoline is not portable
   if(lisp.get("portable", portable)) {
     if(!portable) {
       //we need another sprite
       sprite_name = "images/objects/trampoline/trampoline_fix.sprite";
-      sprite = sprite_manager->create(sprite_name);
+      sprite = SpriteManager::current()->create(sprite_name);
       sprite->set_action("normal");
     }
   }
@@ -53,10 +53,10 @@ Trampoline::Trampoline(const Vector& pos, bool port) :
   Rock(pos, "images/objects/trampoline/trampoline.sprite"),
   portable(port)
 {
-  sound_manager->preload(TRAMPOLINE_SOUND);
+  SoundManager::current()->preload(TRAMPOLINE_SOUND);
   if(!port) {
     sprite_name = "images/objects/trampoline/trampoline_fix.sprite";
-    sprite = sprite_manager->create(sprite_name);
+    sprite = SpriteManager::current()->create(sprite_name);
     sprite->set_action("normal");
   }
 }
@@ -89,7 +89,7 @@ Trampoline::collision(GameObject& other, const CollisionHit& hit)
           vy = VY_INITIAL;
         }
         player->get_physic().set_velocity_y(vy);
-        sound_manager->play(TRAMPOLINE_SOUND);
+        SoundManager::current()->play(TRAMPOLINE_SOUND);
         sprite->set_action("swinging", 1);
         return FORCE_MOVE;
       }
@@ -102,7 +102,7 @@ Trampoline::collision(GameObject& other, const CollisionHit& hit)
       if(hit.top && vy >= 0) {
         vy = VY_INITIAL;
         walking_badguy->set_velocity_y(vy);
-        sound_manager->play(TRAMPOLINE_SOUND);
+        SoundManager::current()->play(TRAMPOLINE_SOUND);
         sprite->set_action("swinging", 1);
         return FORCE_MOVE;
       }
index 3a3f07e..834dc5f 100644 (file)
@@ -33,14 +33,14 @@ WeakBlock::WeakBlock(const Reader& lisp)
 : MovingSprite(lisp, "images/objects/weak_block/strawbox.sprite", LAYER_TILES, COLGROUP_STATIC), state(STATE_NORMAL),
   linked(true),
   light(0.0f,0.0f,0.0f),
-  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
+  lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
 {
   sprite->set_action("normal");
   //Check if this weakblock destroys adjacent weakblocks
   if(lisp.get("linked", linked)){
     if(! linked){
       sprite_name = "images/objects/weak_block/meltbox.sprite";
-      sprite = sprite_manager->create(sprite_name);
+      sprite = SpriteManager::current()->create(sprite_name);
       sprite->set_action("normal");
     }
   }
@@ -48,7 +48,7 @@ WeakBlock::WeakBlock(const Reader& lisp)
     lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
     lightsprite->set_color(Color(0.3f, 0.2f, 0.1f));
   } else if(sprite_name == "images/objects/weak_block/meltbox.sprite")
-    sound_manager->preload("sounds/sizzle.ogg");
+    SoundManager::current()->preload("sounds/sizzle.ogg");
 }
 
 HitResponse
@@ -129,7 +129,7 @@ WeakBlock::update(float )
           sprite->set_action("disintegrating", 1);
           spreadHit();
           set_group(COLGROUP_DISABLED);
-          lightsprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light-tiny.sprite");
+          lightsprite = SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-tiny.sprite");
           lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
           lightsprite->set_color(Color(0.3f, 0.2f, 0.1f));
         }
@@ -170,7 +170,7 @@ WeakBlock::startBurning()
   state = STATE_BURNING;
   sprite->set_action("burning", 1);
   if(sprite_name == "images/objects/weak_block/meltbox.sprite")
-    sound_manager->play("sounds/sizzle.ogg");
+    SoundManager::current()->play("sounds/sizzle.ogg");
 }
 
 void
index af907e3..216aeb6 100644 (file)
@@ -66,37 +66,37 @@ void wait(HSQUIRRELVM vm, float seconds)
 
 void wait_for_screenswitch(HSQUIRRELVM vm)
 {
-  g_screen_manager->m_waiting_threads.add(vm);
+  ScreenManager::current()->m_waiting_threads.add(vm);
 }
 
 void exit_screen()
 {
-  g_screen_manager->pop_screen();
+  ScreenManager::current()->pop_screen();
 }
 
 void fadeout_screen(float seconds)
 {
-  g_screen_manager->set_screen_fade(std::unique_ptr<ScreenFade>(new FadeOut(seconds)));
+  ScreenManager::current()->set_screen_fade(std::unique_ptr<ScreenFade>(new FadeOut(seconds)));
 }
 
 void shrink_screen(float dest_x, float dest_y, float seconds)
 {
-  g_screen_manager->set_screen_fade(std::unique_ptr<ScreenFade>(new ShrinkFade(Vector(dest_x, dest_y), seconds)));
+  ScreenManager::current()->set_screen_fade(std::unique_ptr<ScreenFade>(new ShrinkFade(Vector(dest_x, dest_y), seconds)));
 }
 
 void abort_screenfade()
 {
-  g_screen_manager->set_screen_fade(std::unique_ptr<ScreenFade>());
+  ScreenManager::current()->set_screen_fade(std::unique_ptr<ScreenFade>());
 }
 
 std::string translate(const std::string& text)
 {
-  return dictionary_manager->get_dictionary().translate(text);
+  return g_dictionary_manager->get_dictionary().translate(text);
 }
 
 void display_text_file(const std::string& filename)
 {
-  g_screen_manager->push_screen(std::unique_ptr<Screen>(new TextScroller(filename)));
+  ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new TextScroller(filename)));
 }
 
 void load_worldmap(const std::string& filename)
@@ -109,7 +109,7 @@ void load_worldmap(const std::string& filename)
   }
   else
   {
-    g_screen_manager->push_screen(std::unique_ptr<Screen>(new WorldMap(filename, WorldMap::current()->get_savegame())));
+    ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new WorldMap(filename, WorldMap::current()->get_savegame())));
   }
 }
 
@@ -121,7 +121,7 @@ void load_level(const std::string& filename)
   }
   else
   {
-    g_screen_manager->push_screen(std::unique_ptr<Screen>(new GameSession(filename, GameSession::current()->get_savegame())));
+    ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new GameSession(filename, GameSession::current()->get_savegame())));
   }
 }
 
@@ -205,12 +205,12 @@ bool validate_sector_player()
 
 void play_music(const std::string& filename)
 {
-  sound_manager->play_music(filename);
+  SoundManager::current()->play_music(filename);
 }
 
 void play_sound(const std::string& filename)
 {
-  sound_manager->play(filename);
+  SoundManager::current()->play(filename);
 }
 
 void grease()
@@ -282,7 +282,7 @@ void set_gamma(float gamma)
 
 void quit()
 {
-  g_screen_manager->quit();
+  ScreenManager::current()->quit();
 }
 
 int rand()
index d769f1d..070a294 100644 (file)
 #include <string>
 
 #include "sprite/sprite_ptr.hpp"
+#include "util/currenton.hpp"
 
 class SpriteData;
 
-class SpriteManager
+class SpriteManager : public Currenton<SpriteManager>
 {
 private:
   typedef std::map<std::string, SpriteData*> Sprites;
index 45215d3..1692a84 100644 (file)
@@ -54,7 +54,7 @@ GameManager::start_level(std::unique_ptr<World> world, const std::string& level_
   std::unique_ptr<Screen> screen(new LevelsetScreen(m_world->get_basedir(),
                                                     level_filename,
                                                     *m_savegame));
-  g_screen_manager->push_screen(std::move(screen));
+  ScreenManager::current()->push_screen(std::move(screen));
 }
 
 void
@@ -66,7 +66,7 @@ GameManager::start_worldmap(std::unique_ptr<World> world)
     m_savegame.reset(new Savegame(m_world->get_savegame_filename()));
     m_savegame->load();
 
-    g_screen_manager->push_screen(std::unique_ptr<Screen>(
+    ScreenManager::current()->push_screen(std::unique_ptr<Screen>(
                                     new worldmap::WorldMap(m_world->get_worldmap_filename(),
                                                            *m_savegame)));
   }
index 0e621bd..8b0794c 100644 (file)
@@ -55,7 +55,7 @@ GameSession::GameSession(const std::string& levelfile_, Savegame& savegame, Stat
   pause_menu_frame(),
   end_sequence(0),
   game_pause(false),
-  speed_before_pause(g_screen_manager->get_speed()),
+  speed_before_pause(ScreenManager::current()->get_speed()),
   levelfile(levelfile_),
   reset_sector(),
   reset_pos(),
@@ -96,7 +96,7 @@ GameSession::restart_level()
   game_pause   = false;
   end_sequence = 0;
 
-  g_input_manager->reset();
+  InputManager::current()->reset();
 
   currentsector = 0;
 
@@ -125,11 +125,11 @@ GameSession::restart_level()
     }
   } catch(std::exception& e) {
     log_fatal << "Couldn't start level: " << e.what() << std::endl;
-    g_screen_manager->pop_screen();
+    ScreenManager::current()->pop_screen();
     return (-1);
   }
 
-  sound_manager->stop_music();
+  SoundManager::current()->stop_music();
   currentsector->play_music(LEVEL_MUSIC);
 
   if(capture_file != "") {
@@ -244,8 +244,8 @@ GameSession::toggle_pause()
   // pause
   if (!game_pause && !MenuManager::instance().is_active())
   {
-    speed_before_pause = g_screen_manager->get_speed();
-    g_screen_manager->set_speed(0);
+    speed_before_pause = ScreenManager::current()->get_speed();
+    ScreenManager::current()->set_speed(0);
     MenuManager::instance().set_menu(MenuStorage::GAME_MENU);
     game_pause = true;
   }
@@ -257,7 +257,7 @@ void
 GameSession::abort_level()
 {
   MenuManager::instance().clear_menu_stack();
-  g_screen_manager->pop_screen();
+  ScreenManager::current()->pop_screen();
   currentsector->player->set_bonus(bonus_at_start);
   PlayerStatus *currentStatus = m_savegame.get_player_status();
   currentStatus->coins = coins_at_start;
@@ -349,7 +349,7 @@ GameSession::process_events()
 
   // save input for demo?
   if(capture_demo_stream != 0) {
-    Controller *controller = g_input_manager->get_controller();
+    Controller *controller = InputManager::current()->get_controller();
     capture_demo_stream ->put(controller->hold(Controller::LEFT));
     capture_demo_stream ->put(controller->hold(Controller::RIGHT));
     capture_demo_stream ->put(controller->hold(Controller::UP));
@@ -404,7 +404,7 @@ GameSession::setup()
   int total_stats_to_be_collected = level->stats.total_coins + level->stats.total_badguys + level->stats.total_secrets;
   if ((!levelintro_shown) && (total_stats_to_be_collected > 0)) {
     levelintro_shown = true;
-    g_screen_manager->push_screen(std::unique_ptr<Screen>(new LevelIntro(level.get(), best_level_statistics)));
+    ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new LevelIntro(level.get(), best_level_statistics)));
   }
 }
 
@@ -417,12 +417,12 @@ void
 GameSession::update(float elapsed_time)
 {
   // handle controller
-  if(g_input_manager->get_controller()->pressed(Controller::PAUSE_MENU))
+  if(InputManager::current()->get_controller()->pressed(Controller::PAUSE_MENU))
   {
     on_escape_press();
   }
 
-  if(g_input_manager->get_controller()->pressed(Controller::CHEAT_MENU))
+  if(InputManager::current()->get_controller()->pressed(Controller::CHEAT_MENU))
   {
     if (!MenuManager::instance().is_active())
     {
@@ -435,7 +435,7 @@ GameSession::update(float elapsed_time)
 
   // Unpause the game if the menu has been closed
   if (game_pause && !MenuManager::instance().is_active()) {
-    g_screen_manager->set_speed(speed_before_pause);
+    ScreenManager::current()->set_speed(speed_before_pause);
     game_pause = false;
   }
 
@@ -475,7 +475,7 @@ GameSession::update(float elapsed_time)
   }
 
   // update sounds
-  if (currentsector && currentsector->camera) sound_manager->set_listener_position(currentsector->camera->get_center());
+  if (currentsector && currentsector->camera) SoundManager::current()->set_listener_position(currentsector->camera->get_center());
 
   /* Handle music: */
   if (end_sequence)
@@ -515,7 +515,7 @@ GameSession::finish(bool win)
     }
   }
 
-  g_screen_manager->pop_screen();
+  ScreenManager::current()->pop_screen();
 }
 
 void
@@ -575,12 +575,12 @@ GameSession::start_sequence(const std::string& sequencename)
   }
 
   /* slow down the game for end-sequence */
-  g_screen_manager->set_speed(0.5f);
+  ScreenManager::current()->set_speed(0.5f);
 
   currentsector->add_object(end_sequence);
   end_sequence->start();
 
-  sound_manager->play_music("music/leveldone.ogg", false);
+  SoundManager::current()->play_music("music/leveldone.ogg", false);
   currentsector->player->set_winning();
 
   // Stop all clocks.
index 2ddadb8..f7fa917 100644 (file)
@@ -95,8 +95,8 @@ Config::load()
   }
 
   const lisp::Lisp* config_control_lisp = config_lisp->get_lisp("control");
-  if(config_control_lisp && g_input_manager) {
-    g_input_manager->read(*config_control_lisp);
+  if(config_control_lisp && InputManager::current()) {
+    InputManager::current()->read(*config_control_lisp);
   }
 
   const lisp::Lisp* config_addons_lisp = config_lisp->get_lisp("addons");
@@ -141,9 +141,9 @@ Config::save()
   writer.write("music_enabled", music_enabled);
   writer.end_list("audio");
 
-  if(g_input_manager) {
+  if(InputManager::current()) {
     writer.start_list("control");
-    g_input_manager->write(writer);
+    InputManager::current()->write(writer);
     writer.end_list("control");
   }
 
index 7f1a9f8..d6d4d75 100644 (file)
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "supertux/globals.hpp"
+
 #include <tinygettext/tinygettext.hpp>
 
-InputManager* g_input_manager = 0;
-tinygettext::DictionaryManager* dictionary_manager = 0;
+#include "supertux/gameconfig.hpp"
 
 int SCREEN_WIDTH;
 int SCREEN_HEIGHT;
 
-ScreenManager* g_screen_manager = 0;
-
-TextureManager* texture_manager = 0;
-
-SoundManager* sound_manager = 0;
-
-Config* g_config = 0;
+std::unique_ptr<Config> g_config;
 
 float game_time = 0;
 float real_time = 0;
 
-TileManager* tile_manager    = NULL;
-TileSet*     current_tileset = NULL;
-
-SpriteManager* sprite_manager = NULL;
+TileSet* current_tileset = NULL;
 
 float g_game_speed = 1.0f;
 
index 6aca5eb..f1894ef 100644 (file)
 #ifndef HEADER_SUPERTUX_SUPERTUX_GLOBALS_HPP
 #define HEADER_SUPERTUX_SUPERTUX_GLOBALS_HPP
 
+#include <memory>
+
 typedef struct SDL_Surface SDL_Surface;
 namespace tinygettext { class DictionaryManager; }
 class Config;
-class InputManager;
-class PlayerStatus;
-class ScreenManager;
-class SoundManager;
-class SpriteManager;
-class TextureManager;
-class TileManager;
 class TileSet;
 
 /** The width of the display (this is a logical value, not the
@@ -39,28 +34,13 @@ extern int SCREEN_WIDTH;
     shrink or scale things) */
 extern int SCREEN_HEIGHT;
 
-// global variables
-extern InputManager* g_input_manager;
-
-extern ScreenManager* g_screen_manager;
-
-extern TextureManager* texture_manager;
-
-extern SoundManager* sound_manager;
-
-extern Config* g_config;
-
-extern tinygettext::DictionaryManager* dictionary_manager;
+extern std::unique_ptr<Config> g_config;
 
 extern float game_time;
 extern float real_time;
 
-extern TileManager *tile_manager;
-
 /** this is only set while loading a map */
-extern TileSet     *current_tileset;
-
-extern SpriteManager* sprite_manager;
+extern TileSet* current_tileset;
 
 extern float g_game_speed;
 
index 73f3a6f..2a3674e 100644 (file)
@@ -70,14 +70,14 @@ Level::load(const std::string& filepath)
     level->get("version", version);
     if(version == 1) {
       log_info << "[" <<  filepath << "] level uses old format: version 1" << std::endl;
-      tileset = tile_manager->get_tileset("images/tiles.strf");
+      tileset = TileManager::current()->get_tileset("images/tiles.strf");
       load_old_format(*level);
       return;
     }
 
     const lisp::Lisp* tilesets_lisp = level->get_lisp("tilesets");
     if(tilesets_lisp != NULL) {
-      tileset      = tile_manager->parse_tileset_definition(*tilesets_lisp).release();
+      tileset      = TileManager::current()->parse_tileset_definition(*tilesets_lisp).release();
       free_tileset = true;
     }
     std::string tileset_name;
@@ -85,12 +85,12 @@ Level::load(const std::string& filepath)
       if(tileset != NULL) {
         log_warning << "[" <<  filepath << "] multiple tilesets specified in level" << std::endl;
       } else {
-        tileset = tile_manager->get_tileset(tileset_name);
+        tileset = TileManager::current()->get_tileset(tileset_name);
       }
     }
     /* load default tileset */
     if(tileset == NULL) {
-      tileset = tile_manager->get_tileset("images/tiles.strf");
+      tileset = TileManager::current()->get_tileset("images/tiles.strf");
     }
     current_tileset = tileset;
 
index d20a4a7..82b9651 100644 (file)
@@ -36,7 +36,7 @@ LevelIntro::LevelIntro(const Level* level_, const Statistics* best_level_statist
   player_sprite_vy(0),
   player_sprite_jump_timer()
 {
-  player_sprite = sprite_manager->create("images/creatures/tux/tux.sprite");
+  player_sprite = SpriteManager::current()->create("images/creatures/tux/tux.sprite");
   player_sprite->set_action("small-walk-right");
   player_sprite_jump_timer.start(graphicsRandom.randf(5,10));
 }
@@ -53,14 +53,14 @@ LevelIntro::setup()
 void
 LevelIntro::update(float elapsed_time)
 {
-  Controller *controller = g_input_manager->get_controller();
+  Controller *controller = InputManager::current()->get_controller();
 
   // Check if it's time to exit the screen
   if(controller->pressed(Controller::JUMP)
      || controller->pressed(Controller::ACTION)
      || controller->pressed(Controller::MENU_SELECT)
      || controller->pressed(Controller::PAUSE_MENU)) {
-    g_screen_manager->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.1)));
+    ScreenManager::current()->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.1)));
   }
 
   player_sprite_py += player_sprite_vy * elapsed_time;
index 9ce906c..dde3cd2 100644 (file)
@@ -73,7 +73,7 @@ LevelsetScreen::setup()
     // this gets called when the GameSession is done and we return back to the
     m_savegame.set_levelset_state(m_basedir, m_level_filename, m_solved);
     m_savegame.save();
-    g_screen_manager->pop_screen();
+    ScreenManager::current()->pop_screen();
   }
   else
   {
@@ -81,7 +81,7 @@ LevelsetScreen::setup()
 
     std::unique_ptr<Screen> screen(new GameSession(FileSystem::join(m_basedir, m_level_filename),
                                                    m_savegame));
-    g_screen_manager->push_screen(std::move(screen));
+    ScreenManager::current()->push_screen(std::move(screen));
   }
 }
 
index 7054f37..1be3a0a 100644 (file)
@@ -38,10 +38,11 @@ extern "C" {
 #include "physfs/physfs_file_system.hpp"
 #include "physfs/physfs_sdl.hpp"
 #include "scripting/squirrel_util.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "supertux/command_line_arguments.hpp"
 #include "supertux/game_manager.hpp"
 #include "supertux/gameconfig.hpp"
 #include "supertux/globals.hpp"
-#include "supertux/command_line_arguments.hpp"
 #include "supertux/player_status.hpp"
 #include "supertux/resources.hpp"
 #include "supertux/screen_fade.hpp"
@@ -54,15 +55,13 @@ extern "C" {
 #include "video/renderer.hpp"
 #include "worldmap/worldmap.hpp"
 
-namespace { DrawingContext *context_pointer; }
-
 void
 Main::init_config()
 {
-  g_config = new Config();
+  g_config.reset(new Config);
   try {
     g_config->load();
-  } catch(std::exception& e) {
+  } catch(const std::exception& e) {
     log_info << "Couldn't load config file: " << e.what() << ", using default settings" << std::endl;
   }
 }
@@ -70,23 +69,23 @@ Main::init_config()
 void
 Main::init_tinygettext()
 {
-  dictionary_manager = new tinygettext::DictionaryManager();
+  g_dictionary_manager.reset(new tinygettext::DictionaryManager);
   tinygettext::Log::set_log_info_callback(0);
-  dictionary_manager->set_filesystem(std::unique_ptr<tinygettext::FileSystem>(new PhysFSFileSystem));
+  g_dictionary_manager->set_filesystem(std::unique_ptr<tinygettext::FileSystem>(new PhysFSFileSystem));
 
-  dictionary_manager->add_directory("locale");
-  dictionary_manager->set_charset("UTF-8");
+  g_dictionary_manager->add_directory("locale");
+  g_dictionary_manager->set_charset("UTF-8");
 
   // Config setting "locale" overrides language detection
   if (g_config->locale != "")
   {
-    dictionary_manager->set_language(tinygettext::Language::from_name(g_config->locale));
+    g_dictionary_manager->set_language(tinygettext::Language::from_name(g_config->locale));
   } else {
     FL_Locale *locale;
     FL_FindLocale(&locale);
     tinygettext::Language language = tinygettext::Language::from_spec( locale->lang?locale->lang:"", locale->country?locale->country:"", locale->variant?locale->variant:"");
     FL_FreeLocale(&locale);
-    dictionary_manager->set_language(language);
+    g_dictionary_manager->set_language(language);
   }
 }
 
@@ -233,24 +232,6 @@ Main::init_video()
            << " Area: "       << g_config->aspect_size << std::endl;
 }
 
-void
-Main::init_audio()
-{
-  sound_manager = new SoundManager();
-
-  sound_manager->enable_sound(g_config->sound_enabled);
-  sound_manager->enable_music(g_config->music_enabled);
-}
-
-void
-Main::quit_audio()
-{
-  if(sound_manager != NULL) {
-    delete sound_manager;
-    sound_manager = NULL;
-  }
-}
-
 static Uint32 last_timelog_ticks = 0;
 static const char* last_timelog_component = 0;
 
@@ -331,7 +312,7 @@ Main::run(int argc, char** argv)
     Console console;
 
     timelog("controller");
-    g_input_manager = new InputManager();
+    InputManager input_manager;
 
     timelog("commandline");
 
@@ -339,11 +320,12 @@ Main::run(int argc, char** argv)
     std::unique_ptr<VideoSystem> video_system = VideoSystem::create(g_config->video);
     DrawingContext context(video_system->get_renderer(),
                            video_system->get_lightmap());
-    context_pointer = &context;
     init_video();
 
     timelog("audio");
-    init_audio();
+    SoundManager sound_manager;
+    sound_manager.enable_sound(g_config->sound_enabled);
+    sound_manager.enable_music(g_config->music_enabled);
 
     Console::current()->init_graphics();
 
@@ -351,7 +333,9 @@ Main::run(int argc, char** argv)
     scripting::init_squirrel(g_config->enable_script_debugger);
 
     timelog("resources");
-    Resources::load_shared();
+    TileManager tile_manager;
+    SpriteManager sprite_manager;
+    Resources resources;
 
     timelog("addons");
     AddonManager::get_instance().load_addons();
@@ -361,7 +345,7 @@ Main::run(int argc, char** argv)
     const std::unique_ptr<Savegame> default_savegame(new Savegame(std::string()));
 
     GameManager game_manager;
-    g_screen_manager = new ScreenManager();
+    ScreenManager screen_manager;
 
     init_rand();
 
@@ -379,7 +363,7 @@ Main::run(int argc, char** argv)
 
       if(g_config->start_level.size() > 4 &&
          g_config->start_level.compare(g_config->start_level.size() - 5, 5, ".stwm") == 0) {
-        g_screen_manager->push_screen(std::unique_ptr<Screen>(
+        ScreenManager::current()->push_screen(std::unique_ptr<Screen>(
                                         new worldmap::WorldMap(
                                           FileSystem::basename(g_config->start_level), *default_savegame)));
       } else {
@@ -394,13 +378,13 @@ Main::run(int argc, char** argv)
 
         if(g_config->record_demo != "")
           session->record_demo(g_config->record_demo);
-        g_screen_manager->push_screen(std::move(session));
+        ScreenManager::current()->push_screen(std::move(session));
       }
     } else {
-      g_screen_manager->push_screen(std::unique_ptr<Screen>(new TitleScreen(*default_savegame)));
+      ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new TitleScreen(*default_savegame)));
     }
 
-    g_screen_manager->run(context);
+    ScreenManager::current()->run(context);
   } catch(std::exception& e) {
     log_fatal << "Unexpected exception: " << e.what() << std::endl;
     result = 1;
@@ -409,26 +393,16 @@ Main::run(int argc, char** argv)
     result = 1;
   }
 
-  delete g_screen_manager;
-  g_screen_manager = NULL;
-
-  Resources::unload_shared();
-  quit_audio();
-
   if(g_config)
     g_config->save();
-  delete g_config;
-  g_config = NULL;
-  delete g_input_manager;
-  g_input_manager = NULL;
+  g_config.reset();
+
   scripting::exit_squirrel();
-  delete texture_manager;
-  texture_manager = NULL;
+
   SDL_Quit();
   PHYSFS_deinit();
 
-  delete dictionary_manager;
-  dictionary_manager = nullptr;
+  g_dictionary_manager.reset();
 
   return result;
 }
index dc91929..c8b321e 100644 (file)
 class Main
 {
 private:
-  void init_audio();
   void init_config();
   void init_physfs(const char* argv0);
   void init_rand();
   void init_sdl();
   void init_tinygettext();
   void init_video();
-  void quit_audio();
 
 public:
   /** We call it run() instead of main() as main collides with
index b0197d4..f7e0373 100644 (file)
@@ -73,7 +73,7 @@ ContribLevelsetMenu::menu_action(MenuItem* item)
 {
   if (item->kind == MN_ACTION)
   {
-    sound_manager->stop_music();
+    SoundManager::current()->stop_music();
 
     // reload the World so that we have something that we can safely
     // std::move() around without wreaking the ContribMenu
index 352e83b..48678fa 100644 (file)
@@ -32,7 +32,7 @@ enum {
 
 } // namespace
 
-JoystickMenu::JoystickMenu(InputManager* input_manager) :
+JoystickMenu::JoystickMenu(InputManager& input_manager) :
   m_input_manager(input_manager),
   m_joysticks_available(false)
 {
@@ -50,16 +50,16 @@ JoystickMenu::recreate_menu()
   add_hl();
 
   add_toggle(MNID_AUTO_JOYSTICK_CFG, _("Manual Configuration"),
-             !m_input_manager->use_game_controller())
+             !m_input_manager.use_game_controller())
     ->set_help(_("Use manual configuration instead of SDL2's automatic GameController support"));
 
-  if (m_input_manager->use_game_controller())
+  if (m_input_manager.use_game_controller())
   {
     m_joysticks_available = false;
   }
   else
   {
-    if (m_input_manager->joystick_manager->joysticks.size() > 0)
+    if (m_input_manager.joystick_manager->joysticks.size() > 0)
     {
       m_joysticks_available = true;
 
@@ -75,7 +75,7 @@ JoystickMenu::recreate_menu()
       add_controlfield(Controller::PEEK_UP,     _("Peek Up"));
       add_controlfield(Controller::PEEK_DOWN,   _("Peek Down"));
 
-      add_toggle(MNID_JUMP_WITH_UP, _("Jump with Up"), m_input_manager->joystick_manager->jump_with_up_joy);
+      add_toggle(MNID_JUMP_WITH_UP, _("Jump with Up"), m_input_manager.joystick_manager->jump_with_up_joy);
     }
     else
     {
@@ -112,21 +112,21 @@ JoystickMenu::menu_action(MenuItem* item)
   if (0 <= item->id && item->id < Controller::CONTROLCOUNT)
   {
     item->change_input(_("Press Button"));
-    m_input_manager->joystick_manager->wait_for_joystick = item->id;
+    m_input_manager.joystick_manager->wait_for_joystick = item->id;
   }
   else if (item->id == MNID_JUMP_WITH_UP)
   {
-    m_input_manager->joystick_manager->jump_with_up_joy = item->toggled;
+    m_input_manager.joystick_manager->jump_with_up_joy = item->toggled;
   }
   else if (item->id == MNID_AUTO_JOYSTICK_CFG)
   {
-    m_input_manager->use_game_controller(!item->toggled);
-    m_input_manager->reset();
+    m_input_manager.use_game_controller(!item->toggled);
+    m_input_manager.reset();
     recreate_menu();
   }
   else if(item->id == MNID_SCAN_JOYSTICKS)
   {
-    m_input_manager->reset();
+    m_input_manager.reset();
     recreate_menu();
   }
 }
@@ -134,9 +134,9 @@ JoystickMenu::menu_action(MenuItem* item)
 void
 JoystickMenu::refresh_menu_item(Controller::Control id)
 {
-  int button  = m_input_manager->joystick_manager->reversemap_joybutton(id);
-  int axis    = m_input_manager->joystick_manager->reversemap_joyaxis(id);
-  int hat_dir = m_input_manager->joystick_manager->reversemap_joyhat(id);
+  int button  = m_input_manager.joystick_manager->reversemap_joybutton(id);
+  int axis    = m_input_manager.joystick_manager->reversemap_joyaxis(id);
+  int hat_dir = m_input_manager.joystick_manager->reversemap_joyhat(id);
 
   if (button != -1)
   {
index 469ed0d..196abe6 100644 (file)
@@ -24,7 +24,7 @@
 class JoystickMenu : public Menu
 {
 public:
-  JoystickMenu(InputManager* input_manager);
+  JoystickMenu(InputManager& input_manager);
   virtual ~JoystickMenu();
 
   void refresh();
@@ -37,7 +37,7 @@ private:
   void recreate_menu();
 
 private:
-  InputManager* m_input_manager;
+  InputManager& m_input_manager;
   bool m_joysticks_available;
 
 private:
index 052ed3d..e1c4d28 100644 (file)
@@ -22,8 +22,8 @@
 #include "supertux/globals.hpp"
 #include "util/gettext.hpp"
 
-KeyboardMenu::KeyboardMenu(InputManager* _controller) :
-  controller(_controller)
+KeyboardMenu::KeyboardMenu(InputManager& input_manager) :
+  m_input_manager(input_manager)
 {
   add_label(_("Setup Keyboard"));
   add_hl();
@@ -40,7 +40,7 @@ KeyboardMenu::KeyboardMenu(InputManager* _controller) :
   if (g_config->console_enabled) {
     add_controlfield(Controller::CONSOLE, _("Console"));
   }
-  add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), controller->keyboard_manager->jump_with_up_kbd);
+  add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), m_input_manager.keyboard_manager->jump_with_up_kbd);
   add_hl();
   add_back(_("Back"));
   refresh();
@@ -89,16 +89,16 @@ KeyboardMenu::menu_action(MenuItem* item)
 {
   if(item->id >= 0 && item->id < Controller::CONTROLCOUNT){
     item->change_input(_("Press Key"));
-    controller->keyboard_manager->wait_for_key = item->id;
+    m_input_manager.keyboard_manager->wait_for_key = item->id;
   } else if( item->id == Controller::CONTROLCOUNT) {
-    controller->keyboard_manager->jump_with_up_kbd = item->toggled;
+    m_input_manager.keyboard_manager->jump_with_up_kbd = item->toggled;
   }
 }
 
 void
 KeyboardMenu::refresh()
 {
-  auto& kbd_mgr = controller->keyboard_manager;
+  auto& kbd_mgr = m_input_manager.keyboard_manager;
 
   get_item_by_id((int) Controller::UP).change_input(get_key_name(
                                                       kbd_mgr->reversemap_key(Controller::UP)));
index 83f8f59..3230f34 100644 (file)
 
 class KeyboardMenu : public Menu
 {
+private:
+  InputManager& m_input_manager;
+
 public:
-  KeyboardMenu(InputManager* controller);
+  KeyboardMenu(InputManager& input_manager);
   ~KeyboardMenu();
 
   void refresh();
   std::string get_key_name(SDL_Keycode key);
   void menu_action(MenuItem* item) override;
-  InputManager* controller;
 
 private:
   KeyboardMenu(const KeyboardMenu&);
index 373b8fc..e7ff524 100644 (file)
@@ -39,7 +39,7 @@ LanguageMenu::LanguageMenu()
   add_entry(MNID_LANGUAGE_ENGLISH, "English");
 
   int mnid = MNID_LANGUAGE_NEXT;
-  std::set<tinygettext::Language> languages = dictionary_manager->get_languages();
+  std::set<tinygettext::Language> languages = g_dictionary_manager->get_languages();
   for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
   {
     add_entry(mnid++, i->get_name());
@@ -59,7 +59,7 @@ LanguageMenu::menu_action(MenuItem* item)
     tinygettext::Language language = tinygettext::Language::from_spec( locale->lang?locale->lang:"", locale->country?locale->country:"", locale->variant?locale->variant:"");
     FL_FreeLocale(&locale);
 
-    dictionary_manager->set_language(language); // set currently detected language
+    g_dictionary_manager->set_language(language); // set currently detected language
     g_config->locale = ""; // do auto detect every time on startup
     g_config->save();
     MenuManager::instance().clear_menu_stack();
@@ -67,21 +67,21 @@ LanguageMenu::menu_action(MenuItem* item)
   else if (item->id == MNID_LANGUAGE_ENGLISH) // english
   {
     g_config->locale = "en";
-    dictionary_manager->set_language(tinygettext::Language::from_name(g_config->locale));
+    g_dictionary_manager->set_language(tinygettext::Language::from_name(g_config->locale));
     g_config->save();
     MenuManager::instance().clear_menu_stack();
   }
   else
   {
     int mnid = MNID_LANGUAGE_NEXT;
-    std::set<tinygettext::Language> languages = dictionary_manager->get_languages();
+    std::set<tinygettext::Language> languages = g_dictionary_manager->get_languages();
 
     for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
     {
       if (item->id == mnid++)
       {
         g_config->locale = i->str();
-        dictionary_manager->set_language(*i);
+        g_dictionary_manager->set_language(*i);
         g_config->save();
         MenuManager::instance().clear_menu_stack();
         break;
index acd9b29..8eb4d7a 100644 (file)
@@ -75,13 +75,13 @@ MainMenu::menu_action(MenuItem* item)
 
     case MNID_CREDITS:
       MenuManager::instance().clear_menu_stack();
-      g_screen_manager->push_screen(std::unique_ptr<Screen>(new TextScroller("credits.txt")),
+      ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new TextScroller("credits.txt")),
                                     std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
       break;
 
     case MNID_QUITMAINMENU:
-      g_screen_manager->quit(std::unique_ptr<ScreenFade>(new FadeOut(0.25)));
-      sound_manager->stop_music(0.25);
+      ScreenManager::current()->quit(std::unique_ptr<ScreenFade>(new FadeOut(0.25)));
+      SoundManager::current()->stop_music(0.25);
       break;
   }
 }
index daf0474..67b76da 100644 (file)
@@ -71,10 +71,10 @@ MenuStorage::create(MenuId menu_id)
       return std::unique_ptr<Menu>(new ProfileMenu);
 
     case KEYBOARD_MENU:
-      return std::unique_ptr<Menu>(new KeyboardMenu(g_input_manager));
+      return std::unique_ptr<Menu>(new KeyboardMenu(*InputManager::current()));
 
     case JOYSTICK_MENU:
-      return std::unique_ptr<Menu>(new JoystickMenu(g_input_manager));
+      return std::unique_ptr<Menu>(new JoystickMenu(*InputManager::current()));
 
     case WORLDMAP_MENU:
       return std::unique_ptr<Menu>(new WorldmapMenu);
index dfa6f61..a3db0eb 100644 (file)
@@ -185,7 +185,7 @@ OptionsMenu::OptionsMenu(bool complete)
     }
   }
 
-  if (sound_manager->is_audio_enabled()) {
+  if (SoundManager::current()->is_audio_enabled()) {
     add_toggle(MNID_SOUND, _("Sound"), g_config->sound_enabled)
       ->set_help(_("Disable all sound effects"));
     add_toggle(MNID_MUSIC, _("Music"), g_config->music_enabled)
@@ -280,7 +280,7 @@ OptionsMenu::menu_action(MenuItem* item)
     case MNID_SOUND:
       if(g_config->sound_enabled != is_toggled(MNID_SOUND)) {
         g_config->sound_enabled = !g_config->sound_enabled;
-        sound_manager->enable_sound(g_config->sound_enabled);
+        SoundManager::current()->enable_sound(g_config->sound_enabled);
         g_config->save();
       }
       break;
@@ -288,7 +288,7 @@ OptionsMenu::menu_action(MenuItem* item)
     case MNID_MUSIC:
       if(g_config->music_enabled != is_toggled(MNID_MUSIC)) {
         g_config->music_enabled = !g_config->music_enabled;
-        sound_manager->enable_music(g_config->music_enabled);
+        SoundManager::current()->enable_music(g_config->music_enabled);
         g_config->save();
       }
       break;
index f252325..7210a29 100644 (file)
@@ -45,7 +45,7 @@ WorldmapMenu::menu_action(MenuItem* item)
 
     case MNID_QUITWORLDMAP:
       MenuManager::instance().clear_menu_stack();
-      g_screen_manager->pop_screen();
+      ScreenManager::current()->pop_screen();
       break;
   }
 }
index 2a59925..e2d1155 100644 (file)
@@ -47,8 +47,8 @@ PlayerStatus::PlayerStatus() :
   reset();
 
   coin_surface = Surface::create("images/engine/hud/coins-0.png");
-  sound_manager->preload("sounds/coin.wav");
-  sound_manager->preload("sounds/lifeup.wav");
+  SoundManager::current()->preload("sounds/coin.wav");
+  SoundManager::current()->preload("sounds/lifeup.wav");
 }
 
 PlayerStatus::~PlayerStatus()
@@ -69,9 +69,9 @@ PlayerStatus::add_coins(int count, bool play_sound)
   coins = std::min(coins + count, MAX_COINS);
   if(play_sound) {
     if(count >= 100)
-      sound_manager->play("sounds/lifeup.wav");
+      SoundManager::current()->play("sounds/lifeup.wav");
     else if (real_time > sound_played_time + 0.010) {
-      sound_manager->play("sounds/coin.wav");
+      SoundManager::current()->play("sounds/coin.wav");
       sound_played_time = real_time;
     }
   }
index aed7571..012e313 100644 (file)
@@ -20,7 +20,6 @@
 #include "gui/mousecursor.hpp"
 #include "sprite/sprite_manager.hpp"
 #include "supertux/player_status.hpp"
-#include "supertux/tile_manager.hpp"
 #include "video/font.hpp"
 
 MouseCursor* Resources::mouse_cursor = NULL;
@@ -36,17 +35,15 @@ SurfacePtr Resources::back;
 SurfacePtr Resources::arrow_left;
 SurfacePtr Resources::arrow_right;
 
-/* Load graphics/sounds shared between all levels: */
-void
-Resources::load_shared()
+Resources::Resources()
 {
-  /* Load the mouse-cursor */
+  // Load the mouse-cursor
   mouse_cursor = new MouseCursor("images/engine/menu/mousecursor.png",
                                  "images/engine/menu/mousecursor-click.png",
                                  "images/engine/menu/mousecursor-link.png");
   MouseCursor::set_current(mouse_cursor);
 
-  /* Load global images: */
+  // Load global images:
   fixed_font.reset(new Font(Font::FIXED, "fonts/white.stf"));
   normal_font.reset(new Font(Font::VARIABLE, "fonts/white.stf"));
   small_font.reset(new Font(Font::VARIABLE, "fonts/white-small.stf", 1));
@@ -58,46 +55,22 @@ Resources::load_shared()
   back = Surface::create("images/engine/menu/arrow-back.png");
   arrow_left = Surface::create("images/engine/menu/arrow-left.png");
   arrow_right = Surface::create("images/engine/menu/arrow-right.png");
-
-  tile_manager   = new TileManager();
-  sprite_manager = new SpriteManager();
 }
 
-/* Free shared data: */
-void
-Resources::unload_shared()
+Resources::~Resources()
 {
-  /* Free menu images */
-  if(checkbox != NULL)
-    checkbox.reset();
-  if(checkbox_checked != NULL)
-    checkbox_checked.reset();
-  if(back != NULL)
-    back.reset();
-  if(arrow_left != NULL)
-    arrow_left.reset();
-  if(arrow_right != NULL)
-    arrow_right.reset();
-
-  /* Free global images: */
-  if(fixed_font != NULL)
-    fixed_font.reset();
-  if(normal_font != NULL)
-    normal_font.reset();
-  if(small_font != NULL)
-    small_font.reset();
-  if(big_font != NULL)
-    big_font.reset();
-
-  /* Free tilesets */
-  delete tile_manager;
-  tile_manager = 0;
+  // Free menu images
+  checkbox.reset();
+  checkbox_checked.reset();
+  back.reset();
+  arrow_left.reset();
+  arrow_right.reset();
 
-  if(sprite_manager != NULL)
-  {
-    delete sprite_manager;
-    sprite_manager = NULL;
-  }
+  // Free global images:
+  fixed_font.reset();
+  normal_font.reset();
+  small_font.reset();
+  big_font.reset();
 
   /* Free mouse-cursor */
   if(mouse_cursor != NULL)
index 243947b..dcd9dcb 100644 (file)
@@ -41,8 +41,8 @@ public:
   static SurfacePtr arrow_right;
 
 public:
-  static void load_shared();
-  static void unload_shared();
+  Resources();
+  ~Resources();
 };
 
 #endif
index f680e7a..8453cbc 100644 (file)
@@ -190,11 +190,11 @@ ScreenManager::update_gamelogic(float elapsed_time)
 void
 ScreenManager::process_events()
 {
-  g_input_manager->update();
+  InputManager::current()->update();
   SDL_Event event;
   while (SDL_PollEvent(&event))
   {
-    g_input_manager->process_event(event);
+    InputManager::current()->process_event(event);
 
     m_menu_manager->event(event);
 
@@ -365,7 +365,7 @@ ScreenManager::run(DrawingContext &context)
       draw(context);
     }
 
-    sound_manager->update();
+    SoundManager::current()->update();
 
     handle_screen_switch();
   }
index 53d02b1..59599c8 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "scripting/thread_queue.hpp"
 #include "supertux/screen.hpp"
+#include "util/currenton.hpp"
 
 class Console;
 class DrawingContext;
@@ -34,7 +35,7 @@ class ScreenFade;
 /**
  * Manages, updates and draws all Screens, Controllers, Menus and the Console.
  */
-class ScreenManager
+class ScreenManager : public Currenton<ScreenManager>
 {
 public:
   ScreenManager();
index 86491e1..a87b900 100644 (file)
@@ -90,7 +90,7 @@ Sector::Sector(Level* parent) :
   add_object(new DisplayEffect("Effect"));
   add_object(new TextObject("Text"));
 
-  sound_manager->preload("sounds/shoot.wav");
+  SoundManager::current()->preload("sounds/shoot.wav");
 
   // create a new squirrel table for the sector
   using namespace scripting;
@@ -1468,7 +1468,7 @@ Sector::add_bullet(const Vector& pos, const PlayerStatus* player_status, float x
   new_bullet = new Bullet(pos, xm, dir, player_status->bonus);
   add_object(new_bullet);
 
-  sound_manager->play("sounds/shoot.wav");
+  SoundManager::current()->play("sounds/shoot.wav");
 
   return true;
 }
@@ -1486,16 +1486,16 @@ Sector::play_music(MusicType type)
   currentmusic = type;
   switch(currentmusic) {
     case LEVEL_MUSIC:
-      sound_manager->play_music(music);
+      SoundManager::current()->play_music(music);
       break;
     case HERRING_MUSIC:
-      sound_manager->play_music("music/invincible.ogg");
+      SoundManager::current()->play_music("music/invincible.ogg");
       break;
     case HERRING_WARNING_MUSIC:
-      sound_manager->stop_music(TUX_INVINCIBLE_TIME_WARNING);
+      SoundManager::current()->stop_music(TUX_INVINCIBLE_TIME_WARNING);
       break;
     default:
-      sound_manager->play_music("");
+      SoundManager::current()->play_music("");
       break;
   }
 }
index 17b848e..d09e32e 100644 (file)
@@ -87,13 +87,13 @@ TextScroller::~TextScroller()
 void
 TextScroller::setup()
 {
-  sound_manager->play_music(music);
+  SoundManager::current()->play_music(music);
 }
 
 void
 TextScroller::update(float elapsed_time)
 {
-  Controller *controller = g_input_manager->get_controller();
+  Controller* controller = InputManager::current()->get_controller();
   if(controller->hold(Controller::UP)) {
     speed = -defaultspeed*5;
   } else if(controller->hold(Controller::DOWN)) {
@@ -107,7 +107,7 @@ TextScroller::update(float elapsed_time)
      )&& !(controller->pressed(Controller::UP))) // prevent skipping if jump with up is enabled
     scroll += SCROLL;
   if(controller->pressed(Controller::PAUSE_MENU)) {
-    g_screen_manager->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
+    ScreenManager::current()->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
   }
 
   scroll += speed * elapsed_time;
@@ -136,7 +136,7 @@ TextScroller::draw(DrawingContext& context)
 
   if(y < 0 && !fading ) {
     fading = true;
-    g_screen_manager->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
+    ScreenManager::current()->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
   }
 }
 
index 6a5fcee..5e2ffd7 100644 (file)
 #include <memory>
 #include <string>
 
+#include "util/currenton.hpp"
 #include "util/reader_fwd.hpp"
 
 class TileSet;
 
-class TileManager
+class TileManager : public Currenton<TileManager>
 {
 private:
   typedef std::map<std::string, std::unique_ptr<TileSet> > TileSets;
index 052c9d9..27db44b 100644 (file)
@@ -133,7 +133,7 @@ TitleScreen::draw(DrawingContext& context)
 void
 TitleScreen::update(float elapsed_time)
 {
-  g_screen_manager->set_speed(0.6f);
+  ScreenManager::current()->set_speed(0.6f);
   Sector* sector  = titlesession->get_current_sector();
   sector->update(elapsed_time);
 
@@ -141,7 +141,7 @@ TitleScreen::update(float elapsed_time)
 
   // reopen menu if user closed it (so that the app doesn't close when user
   // accidently hit ESC)
-  if(!MenuManager::instance().is_active() && !g_screen_manager->has_pending_fadeout())
+  if(!MenuManager::instance().is_active() && !ScreenManager::current()->has_pending_fadeout())
   {
     MenuManager::instance().set_menu(MenuStorage::MAIN_MENU);
   }
index 2bb4f71..4423511 100644 (file)
@@ -41,11 +41,11 @@ Door::Door(const Reader& reader) :
 
   reader.get("script", script);
 
-  sprite = sprite_manager->create("images/objects/door/door.sprite");
+  sprite = SpriteManager::current()->create("images/objects/door/door.sprite");
   sprite->set_action("closed");
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
 
-  sound_manager->preload("sounds/door.wav");
+  SoundManager::current()->preload("sounds/door.wav");
 }
 
 Door::Door(int x, int y, std::string sector, std::string spawnpoint) :
@@ -60,11 +60,11 @@ Door::Door(int x, int y, std::string sector, std::string spawnpoint) :
   target_sector = sector;
   target_spawnpoint = spawnpoint;
 
-  sprite = sprite_manager->create("images/objects/door/door.sprite");
+  sprite = SpriteManager::current()->create("images/objects/door/door.sprite");
   sprite->set_action("closed");
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
 
-  sound_manager->preload("sounds/door.wav");
+  SoundManager::current()->preload("sounds/door.wav");
 }
 
 Door::~Door()
@@ -116,7 +116,7 @@ Door::event(Player& , EventType type)
       // if door was activated, start opening it
       if (type == EVENT_ACTIVATE) {
         state = OPENING;
-        sound_manager->play("sounds/door.wav");
+        SoundManager::current()->play("sounds/door.wav");
         sprite->set_action("opening", 1);
       }
       break;
index 53662c7..df29242 100644 (file)
@@ -39,11 +39,11 @@ Switch::Switch(const Reader& reader) :
   if (!reader.get("x", bbox.p1.x)) throw std::runtime_error("no x position set");
   if (!reader.get("y", bbox.p1.y)) throw std::runtime_error("no y position set");
   if (!reader.get("sprite", sprite_name)) throw std::runtime_error("no sprite name set");
-  sprite = sprite_manager->create(sprite_name);
+  sprite = SpriteManager::current()->create(sprite_name);
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
 
   if (!reader.get("script", script)) throw std::runtime_error("no script set");
-  sound_manager->preload( SWITCH_SOUND );
+  SoundManager::current()->preload( SWITCH_SOUND );
 }
 
 Switch::~Switch()
@@ -96,7 +96,7 @@ Switch::event(Player& , EventType type)
   switch (state) {
     case OFF:
       sprite->set_action("turnon", 1);
-      sound_manager->play( SWITCH_SOUND );
+      SoundManager::current()->play( SWITCH_SOUND );
       state = TURN_ON;
       break;
     case TURN_ON:
index f418695..d67c93b 100644 (file)
 
 #include <tinygettext/tinygettext.hpp>
 #include <assert.h>
+#include <memory>
 
 #include "supertux/globals.hpp"
 
+extern std::unique_ptr<tinygettext::DictionaryManager> g_dictionary_manager;
+
 /*
  * If you need to do a nontrivial substitution of values into a pattern, use
  * boost::format rather than an ad-hoc concatenation.  That way, translators can
@@ -43,9 +46,9 @@
 
 static inline std::string _(const std::string& message)
 {
-  if (dictionary_manager)
+  if (g_dictionary_manager)
   {
-    return dictionary_manager->get_dictionary().translate(message);
+    return g_dictionary_manager->get_dictionary().translate(message);
   }
   else
   {
index 8df70db..b5251e0 100644 (file)
@@ -67,7 +67,7 @@ GLLightmap::GLLightmap() :
 
   m_lightmap_uv_right = static_cast<float>(m_lightmap_width) / static_cast<float>(width);
   m_lightmap_uv_bottom = static_cast<float>(m_lightmap_height) / static_cast<float>(height);
-  texture_manager->register_texture(m_lightmap.get());
+  TextureManager::current()->register_texture(m_lightmap.get());
 }
 
 GLLightmap::~GLLightmap()
index 734895f..213c94a 100644 (file)
@@ -47,9 +47,6 @@ GLRenderer::GLRenderer() :
   SDL_GetCurrentDisplayMode(0, &mode);
   m_desktop_size = Size(mode.w, mode.h);
 
-  if(texture_manager != 0)
-    texture_manager->save_textures();
-
   if(g_config->try_vsync) {
     /* we want vsync for smooth scrolling */
     if (SDL_GL_SetSwapInterval(-1) != 0)
@@ -82,11 +79,6 @@ GLRenderer::GLRenderer() :
   // Init the projection matrix, viewport and stuff
   apply_config();
 
-  if(texture_manager == 0)
-    texture_manager = new TextureManager();
-  else
-    texture_manager->reload_textures();
-
 #ifndef GL_VERSION_ES_CM_1_0
   GLenum err = glewInit();
   if (GLEW_OK != err)
index 935be65..b19c9d9 100644 (file)
 #include "video/gl/gl_renderer.hpp"
 #include "video/gl/gl_surface_data.hpp"
 #include "video/gl/gl_texture.hpp"
+#include "video/texture_manager.hpp"
 
 GLVideoSystem::GLVideoSystem() :
   m_renderer(new GLRenderer),
-  m_lightmap(new GLLightmap)
+  m_lightmap(new GLLightmap),
+  m_texture_manager(new TextureManager)
 {
 }
 
index eab8a08..34fbb8f 100644 (file)
 
 #include "video/video_system.hpp"
 
+class TextureManager;
+
 class GLVideoSystem : public VideoSystem
 {
 private:
   std::unique_ptr<Renderer> m_renderer;
   std::unique_ptr<Lightmap> m_lightmap;
+  std::unique_ptr<TextureManager> m_texture_manager;
 
 public:
   GLVideoSystem();
index c95ee46..2ed479e 100644 (file)
@@ -112,9 +112,6 @@ SDLRenderer::SDLRenderer() :
     log_info << "Max Texture Height: " << info.max_texture_height << std::endl;
   }
 
-  if(texture_manager == 0)
-    texture_manager = new TextureManager();
-
   g_config->window_size = Size(width, height);
   apply_config();
 }
index f0aae38..4bb6cef 100644 (file)
@@ -28,7 +28,8 @@
 
 SDLVideoSystem::SDLVideoSystem() :
   m_renderer(new SDLRenderer),
-  m_lightmap(new SDLLightmap)
+  m_lightmap(new SDLLightmap),
+  m_texture_manager(new TextureManager)
 {
 }
 
index 2445f45..ecd2297 100644 (file)
 
 #include "video/video_system.hpp"
 
+class TextureManager;
+
 class SDLVideoSystem : public VideoSystem
 {
 private:
   std::unique_ptr<Renderer> m_renderer;
   std::unique_ptr<Lightmap> m_lightmap;
+  std::unique_ptr<TextureManager> m_texture_manager;
 
 public:
   SDLVideoSystem();
index 2236f62..2214293 100644 (file)
@@ -36,7 +36,7 @@ Surface::create(const std::string& file, const Rect& rect)
 }
 
 Surface::Surface(const std::string& file) :
-  texture(texture_manager->get(file)),
+  texture(TextureManager::current()->get(file)),
   surface_data(),
   rect(0, 0,
       Size(texture->get_image_width(),
@@ -47,7 +47,7 @@ Surface::Surface(const std::string& file) :
 }
 
 Surface::Surface(const std::string& file, const Rect& rect_) :
-  texture(texture_manager->get(file, rect_)),
+  texture(TextureManager::current()->get(file, rect_)),
   surface_data(),
   rect(0, 0, Size(rect_.get_width(), rect_.get_height())),
   flipx(false)
index 0a316cf..76964a9 100644 (file)
@@ -55,10 +55,10 @@ public:
   Texture() : cache_filename() {}
   virtual ~Texture()
   {
-    if (texture_manager && cache_filename != "")
+    if (TextureManager::current() && cache_filename != "")
       /* The cache entry is now useless: its weak pointer to us has been
        * cleared.  Remove the entry altogether to save memory. */
-      texture_manager->reap_cache_entry(cache_filename);
+      TextureManager::current()->reap_cache_entry(cache_filename);
   }
 
   virtual unsigned int get_texture_width() const = 0;
index 52074ca..8124928 100644 (file)
@@ -27,6 +27,7 @@
 #include <vector>
 #include <boost/weak_ptr.hpp>
 
+#include "util/currenton.hpp"
 #include "video/glutil.hpp"
 #include "video/texture_ptr.hpp"
 
@@ -34,7 +35,7 @@ class Texture;
 class GLTexture;
 class Rect;
 
-class TextureManager
+class TextureManager : public Currenton<TextureManager>
 {
 public:
   TextureManager();
index ead77e2..85e987f 100644 (file)
@@ -50,7 +50,7 @@ LevelTile::LevelTile(const std::string& basedir_, const Reader& lisp) :
 
   std::string spritefile = "images/worldmap/common/leveldot.sprite";
   lisp.get("sprite", spritefile);
-  sprite = sprite_manager->create(spritefile);
+  sprite = SpriteManager::current()->create(spritefile);
 
   lisp.get("extro-script", extro_script);
 
index b51766b..ccd3ea3 100644 (file)
@@ -43,7 +43,7 @@ SpecialTile::SpecialTile(const Reader& lisp) :
   if(!invisible) {
     std::string spritefile = "";
     lisp.get("sprite", spritefile);
-    sprite = sprite_manager->create(spritefile);
+    sprite = SpriteManager::current()->create(spritefile);
   }
 
   lisp.get("map-message", map_message);
index 705d5b4..6952559 100644 (file)
@@ -37,7 +37,7 @@ SpriteChange::SpriteChange(const Reader& lisp) :
 
   std::string spritefile = "";
   lisp.get("sprite", spritefile);
-  sprite = sprite_manager->create(spritefile);
+  sprite = SpriteManager::current()->create(spritefile);
 
   lisp.get("stay-action", stay_action);
   lisp.get("initial-stay-action", in_stay_action);
index ab709d4..41be7b0 100644 (file)
@@ -36,7 +36,7 @@ Teleporter::Teleporter(const Reader& lisp) :
 
   std::string spritefile = "";
   if (lisp.get("sprite", spritefile)) {
-    sprite = sprite_manager->create(spritefile);
+    sprite = SpriteManager::current()->create(spritefile);
   }
 
   lisp.get("worldmap", worldmap);
index 95c1c3d..561be82 100644 (file)
@@ -43,7 +43,7 @@ Tux::Tux(WorldMap* worldmap_) :
   moving(),
   ghost_mode()
 {
-  sprite = sprite_manager->create("images/worldmap/common/tux.sprite");
+  sprite = SpriteManager::current()->create("images/worldmap/common/tux.sprite");
 
   offset = 0;
   moving = false;
@@ -291,7 +291,7 @@ Tux::tryContinueWalking(float elapsed_time)
 void
 Tux::updateInputDirection()
 {
-  Controller* controller_ = g_input_manager->get_controller();
+  Controller* controller_ = InputManager::current()->get_controller();
   if(controller_->hold(Controller::UP))
     input_direction = D_NORTH;
   else if(controller_->hold(Controller::DOWN))
index 90b5055..9f71f16 100644 (file)
@@ -133,7 +133,7 @@ WorldMap::WorldMap(const std::string& filename, Savegame& savegame, const std::s
   sq_addref(global_vm, &worldmap_table);
   sq_pop(global_vm, 1);
 
-  sound_manager->preload("sounds/warp.wav");
+  SoundManager::current()->preload("sounds/warp.wav");
 
   // load worldmap objects
   load(filename);
@@ -239,8 +239,8 @@ WorldMap::move_to_spawnpoint(const std::string& spawnpoint, bool pan)
 void
 WorldMap::change(const std::string& filename, const std::string& force_spawnpoint_)
 {
-  g_screen_manager->pop_screen();
-  g_screen_manager->push_screen(std::unique_ptr<Screen>(new WorldMap(filename, m_savegame, force_spawnpoint_)));
+  ScreenManager::current()->pop_screen();
+  ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new WorldMap(filename, m_savegame, force_spawnpoint_)));
 }
 
 void
@@ -265,7 +265,7 @@ WorldMap::load(const std::string& filename)
 
     const lisp::Lisp* tilesets_lisp = level_->get_lisp("tilesets");
     if(tilesets_lisp != NULL) {
-      tileset      = tile_manager->parse_tileset_definition(*tilesets_lisp).release();
+      tileset      = TileManager::current()->parse_tileset_definition(*tilesets_lisp).release();
       free_tileset = true;
     }
     std::string tileset_name;
@@ -273,12 +273,12 @@ WorldMap::load(const std::string& filename)
       if(tileset != NULL) {
         log_warning << "multiple tilesets specified in level_" << std::endl;
       } else {
-        tileset = tile_manager->get_tileset(tileset_name);
+        tileset = TileManager::current()->get_tileset(tileset_name);
       }
     }
     /* load default tileset */
     if(tileset == NULL) {
-      tileset = tile_manager->get_tileset("images/worldmap.strf");
+      tileset = TileManager::current()->get_tileset("images/worldmap.strf");
     }
     current_tileset = tileset;
 
@@ -632,7 +632,7 @@ WorldMap::update(float delta)
     }
 
     // handle input
-    Controller *controller = g_input_manager->get_controller();
+    Controller *controller = InputManager::current()->get_controller();
     bool enter_level = false;
     if(controller->pressed(Controller::ACTION)
        || controller->pressed(Controller::JUMP)
@@ -659,7 +659,7 @@ WorldMap::update(float delta)
         change(teleporter->worldmap, teleporter->spawnpoint);
       } else {
         // TODO: an animation, camera scrolling or a fading would be a nice touch
-        sound_manager->play("sounds/warp.wav");
+        SoundManager::current()->play("sounds/warp.wav");
         tux->back_direction = D_NONE;
         move_to_spawnpoint(teleporter->spawnpoint, true);
       }
@@ -698,7 +698,7 @@ WorldMap::update(float delta)
           // update state and savegame
           save_state();
 
-          g_screen_manager->push_screen(std::unique_ptr<Screen>(new GameSession(levelfile, m_savegame, &level_->statistics)),
+          ScreenManager::current()->push_screen(std::unique_ptr<Screen>(new GameSession(levelfile, m_savegame, &level_->statistics)),
                                         std::unique_ptr<ScreenFade>(new ShrinkFade(shrinkpos, 1.0f)));
           in_level = true;
         } catch(std::exception& e) {
@@ -904,7 +904,7 @@ WorldMap::draw_status(DrawingContext& context)
 void
 WorldMap::setup()
 {
-  sound_manager->play_music(music);
+  SoundManager::current()->play_music(music);
   MenuManager::instance().clear_menu_stack();
 
   current_ = this;