From 9a72799fafb2013484eac2bf1f7bf2cf2c971b01 Mon Sep 17 00:00:00 2001 From: florianf Date: Thu, 11 Feb 2010 14:55:39 +0000 Subject: [PATCH] Various objects: Use "reader_get_layer" to parse the "z-pos" and "layer" options. This should be a much more thorough fix for the bug described in #527 "Text and backgrounds can overlap the menu". References: #527. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6321 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/object/background.cpp | 7 +------ src/object/cloud_particle_system.cpp | 2 +- src/object/comet_particle_system.cpp | 2 +- src/object/comet_particle_system.hpp | 1 + src/object/decal.cpp | 2 +- src/object/ghost_particle_system.cpp | 2 +- src/object/gradient.cpp | 2 +- src/object/rain_particle_system.cpp | 2 +- src/object/scripted_object.cpp | 2 +- src/object/snow_particle_system.cpp | 2 +- src/object/thunderstorm.cpp | 2 +- src/object/tilemap.cpp | 11 ++--------- 12 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/object/background.cpp b/src/object/background.cpp index 422592b38..78aebf2fb 100644 --- a/src/object/background.cpp +++ b/src/object/background.cpp @@ -104,12 +104,7 @@ Background::Background(const Reader& reader) : reader.get("scroll-speed-x", scroll_speed.x); reader.get("scroll-speed-y", scroll_speed.y); - reader.get("layer", layer); - if (layer > (LAYER_GUI - 100)) { - log_warning << "Layer of background (" << layer << ") is too large. " - << "Clipping to " << (LAYER_GUI - 100) << "." << std::endl; - layer = LAYER_GUI - 100; - } + layer = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND0); if(!reader.get("image", imagefile) || !reader.get("speed", speed)) throw std::runtime_error("Must specify image and speed for background"); diff --git a/src/object/cloud_particle_system.cpp b/src/object/cloud_particle_system.cpp index ace29eeca..e1a7a5eb1 100644 --- a/src/object/cloud_particle_system.cpp +++ b/src/object/cloud_particle_system.cpp @@ -45,7 +45,7 @@ CloudParticleSystem::CloudParticleSystem() : void CloudParticleSystem::parse(const Reader& reader) { - reader.get("z-pos", z_pos); + z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1); } CloudParticleSystem::~CloudParticleSystem() diff --git a/src/object/comet_particle_system.cpp b/src/object/comet_particle_system.cpp index fb923f98f..a2fd295b5 100644 --- a/src/object/comet_particle_system.cpp +++ b/src/object/comet_particle_system.cpp @@ -48,7 +48,7 @@ CometParticleSystem::CometParticleSystem() void CometParticleSystem::parse(const Reader& reader) { - reader.get("z-pos", z_pos); + z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1); } CometParticleSystem::~CometParticleSystem() diff --git a/src/object/comet_particle_system.hpp b/src/object/comet_particle_system.hpp index c38e0b5ed..460ef0d95 100644 --- a/src/object/comet_particle_system.hpp +++ b/src/object/comet_particle_system.hpp @@ -21,6 +21,7 @@ #include "object/particlesystem_interactive.hpp" #include "video/surface_ptr.hpp" +#include "src/video/drawing_request.hpp" /* LAYER_BACKGROUND1 */ class CometParticleSystem : public ParticleSystem_Interactive { diff --git a/src/object/decal.cpp b/src/object/decal.cpp index af7a8f7ea..3a985a270 100644 --- a/src/object/decal.cpp +++ b/src/object/decal.cpp @@ -21,7 +21,7 @@ Decal::Decal(const Reader& reader) : MovingSprite(reader, LAYER_OBJECTS, COLGROUP_DISABLED) { - reader.get("layer", layer); + layer = reader_get_layer (reader, /* default = */ LAYER_OBJECTS); bool solid = false; reader.get("solid", solid); diff --git a/src/object/ghost_particle_system.cpp b/src/object/ghost_particle_system.cpp index 17ddcf418..b5373cbb4 100644 --- a/src/object/ghost_particle_system.cpp +++ b/src/object/ghost_particle_system.cpp @@ -47,7 +47,7 @@ GhostParticleSystem::GhostParticleSystem() void GhostParticleSystem::parse(const Reader& reader) { - reader.get("z-pos", z_pos); + z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1); } GhostParticleSystem::~GhostParticleSystem() diff --git a/src/object/gradient.cpp b/src/object/gradient.cpp index f259c08ad..9d1efeacb 100644 --- a/src/object/gradient.cpp +++ b/src/object/gradient.cpp @@ -32,7 +32,7 @@ Gradient::Gradient(const Reader& reader) : gradient_top(), gradient_bottom() { - reader.get("layer", layer); + layer = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND0); std::vector bkgd_top_color, bkgd_bottom_color; if(!reader.get("top_color", bkgd_top_color) || !reader.get("bottom_color", bkgd_bottom_color)) diff --git a/src/object/rain_particle_system.cpp b/src/object/rain_particle_system.cpp index 4a6500f03..bb9d7d8ce 100644 --- a/src/object/rain_particle_system.cpp +++ b/src/object/rain_particle_system.cpp @@ -48,7 +48,7 @@ RainParticleSystem::RainParticleSystem() void RainParticleSystem::parse(const Reader& reader) { - reader.get("z-pos", z_pos); + z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1); } RainParticleSystem::~RainParticleSystem() diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index 1a43a3a45..e64c62c09 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -47,7 +47,7 @@ ScriptedObject::ScriptedObject(const Reader& lisp) : lisp.get("solid", solid); lisp.get("physic-enabled", physic_enabled); lisp.get("visible", visible); - lisp.get("z-pos", layer); + layer = reader_get_layer (lisp, /* default = */ LAYER_OBJECTS); if( solid ){ set_group( COLGROUP_MOVING_STATIC ); } else { diff --git a/src/object/snow_particle_system.cpp b/src/object/snow_particle_system.cpp index a0efa3550..d2037c410 100644 --- a/src/object/snow_particle_system.cpp +++ b/src/object/snow_particle_system.cpp @@ -76,7 +76,7 @@ SnowParticleSystem::SnowParticleSystem() : void SnowParticleSystem::parse(const Reader& reader) { - reader.get("z-pos", z_pos); + z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1); } SnowParticleSystem::~SnowParticleSystem() diff --git a/src/object/thunderstorm.cpp b/src/object/thunderstorm.cpp index 253c82327..14830576d 100644 --- a/src/object/thunderstorm.cpp +++ b/src/object/thunderstorm.cpp @@ -44,7 +44,7 @@ Thunderstorm::Thunderstorm(const Reader& reader) : if(interval <= 0) { log_warning << "Running a thunderstorm with non-positive time interval is a bad idea" << std::endl; } - reader.get("layer", layer); + layer = reader_get_layer (reader, /* default = */ LAYER_BACKGROUNDTILES-1); sound_manager->preload("sounds/thunder.wav"); sound_manager->preload("sounds/lightning.wav"); diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index 6f2019588..9528a81d6 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -69,10 +69,11 @@ TileMap::TileMap(const Reader& reader) : assert(tileset != NULL); reader.get("name", name); - reader.get("z-pos", z_pos); reader.get("solid", solid); reader.get("speed", speed_x); reader.get("speed-y", speed_y); + + z_pos = reader_get_layer (reader, /* default = */ 0); if(solid && ((speed_x != 1) || (speed_y != 1))) { log_warning << "Speed of solid tilemap is not 1. fixing" << std::endl; @@ -80,14 +81,6 @@ TileMap::TileMap(const Reader& reader) : speed_y = 1; } - if (z_pos > (LAYER_GUI - 100)) { - log_warning << "z-pos of " - << ((name == "") ? "unnamed tilemap" : name) << " (" << z_pos << ") " - << "is too large. " - << "Clipping to " << (LAYER_GUI - 100) << "." << std::endl; - z_pos = LAYER_GUI - 100; - } - const lisp::Lisp* pathLisp = reader.get_lisp("path"); if (pathLisp) { path.reset(new Path()); -- 2.11.0