X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsprite%2Fsprite_data.cpp;h=6d2d2a558df4618291634184e637dfb4d2bd7a40;hb=c1277f5b7db9f55d1d28f658b4e804f32b76f0ce;hp=599e4e1d8c81e7af7bbd3b81bf1a6da21fdd423a;hpb=93a74f493825b4a4c76774f190b2fc39b2488d8f;p=supertux.git diff --git a/src/sprite/sprite_data.cpp b/src/sprite/sprite_data.cpp index 599e4e1d8..6d2d2a558 100644 --- a/src/sprite/sprite_data.cpp +++ b/src/sprite/sprite_data.cpp @@ -1,12 +1,10 @@ -// $Id$ -// // SuperTux // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,29 +12,31 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// along with this program. If not, see . -#include +#include "sprite/sprite_data.hpp" -#include -#include -#include #include +#include -#include "sprite_data.hpp" -#include "resources.hpp" -#include "video/drawing_context.hpp" #include "lisp/list_iterator.hpp" -#include "log.hpp" +#include "util/log.hpp" -SpriteData::Action::Action() +SpriteData::Action::Action() : + name(), + x_offset(), + y_offset(), + hitbox_w(), + hitbox_h(), + z_order(), + fps(), + surfaces() { x_offset = 0; y_offset = 0; hitbox_w = 0; hitbox_h = 0; - z_order = 0; + z_order = 0; fps = 10; } @@ -47,7 +47,9 @@ SpriteData::Action::~Action() delete *i; } -SpriteData::SpriteData(const lisp::Lisp* lisp, const std::string& basedir) +SpriteData::SpriteData(const lisp::Lisp* lisp, const std::string& basedir) : + actions(), + name() { lisp::ListIterator iter(lisp); while(iter.next()) { @@ -60,7 +62,7 @@ SpriteData::SpriteData(const lisp::Lisp* lisp, const std::string& basedir) } } if(actions.empty()) - throw std::runtime_error("Error: Sprite wihtout actions."); + throw std::runtime_error("Error: Sprite without actions."); } SpriteData::~SpriteData() @@ -77,10 +79,10 @@ SpriteData::parse_action(const lisp::Lisp* lisp, const std::string& basedir) if(!lisp->get("name", action->name)) { if(!actions.empty()) throw std::runtime_error( - "If there are more than one action, they need names!"); + "If there are more than one action, they need names!"); } std::vector hitbox; - if (lisp->get_vector("hitbox", hitbox)) { + if (lisp->get("hitbox", hitbox)) { if (hitbox.size() != 4) throw std::runtime_error("hitbox must specify exactly 4 coordinates"); action->x_offset = hitbox[0]; action->y_offset = hitbox[1]; @@ -96,16 +98,15 @@ SpriteData::parse_action(const lisp::Lisp* lisp, const std::string& basedir) Action* act_tmp = get_action(mirror_action); if(act_tmp == NULL) { throw std::runtime_error("Could not mirror action. Action not found\n" - "Mirror actions must be defined after the real one!"); + "Mirror actions must be defined after the real one!"); } else { float max_w = 0; float max_h = 0; - for(int i = 0; static_cast(i) < act_tmp->surfaces.size(); - i++) { + for(int i = 0; static_cast(i) < act_tmp->surfaces.size(); i++) { Surface* surface = new Surface(*(act_tmp->surfaces[i])); surface->hflip(); - max_w = std::max(max_w, surface->get_width()); - max_h = std::max(max_h, surface->get_height()); + max_w = std::max(max_w, (float) surface->get_width()); + max_h = std::max(max_h, (float) surface->get_height()); action->surfaces.push_back(surface); } if (action->hitbox_w < 1) action->hitbox_w = max_w; @@ -113,7 +114,7 @@ SpriteData::parse_action(const lisp::Lisp* lisp, const std::string& basedir) } } else { // Load images std::vector images; - if(!lisp->get_vector("images", images)) { + if(!lisp->get("images", images)) { std::stringstream msg; msg << "Sprite '" << name << "' contains no images in action '" << action->name << "'."; @@ -124,8 +125,8 @@ SpriteData::parse_action(const lisp::Lisp* lisp, const std::string& basedir) float max_h = 0; for(std::vector::size_type i = 0; i < images.size(); i++) { Surface* surface = new Surface(basedir + images[i]); - max_w = std::max(max_w, surface->get_width()); - max_h = std::max(max_h, surface->get_height()); + max_w = std::max(max_w, (float) surface->get_width()); + max_h = std::max(max_h, (float) surface->get_height()); action->surfaces.push_back(surface); } if (action->hitbox_w < 1) action->hitbox_w = max_w; @@ -144,3 +145,4 @@ SpriteData::get_action(std::string act) return i->second; } +/* EOF */