#include "supertux/sector.hpp"
#include "supertux/shrinkfade.hpp"
#include "supertux/textscroller.hpp"
+#include "supertux/tile.hpp"
#include "supertux/world.hpp"
#include "util/gettext.hpp"
#include "worldmap/tux.hpp"
Sector::draw_solids_only = enable;
}
+void debug_draw_editor_images(bool enable)
+{
+ Tile::draw_editor_images = enable;
+}
+
void debug_worldmap_ghost(bool enable)
{
using namespace worldmap;
void debug_draw_solids_only(bool enable);
/**
+ * enable/disable drawing of editor images
+ */
+void debug_draw_editor_images(bool enable);
+
+/**
* enable/disable worldmap ghost mode
*/
void debug_worldmap_ghost(bool enable);
}
+static SQInteger debug_draw_editor_images_wrapper(HSQUIRRELVM vm)
+{
+ SQBool arg0;
+ if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) {
+ sq_throwerror(vm, _SC("Argument 1 not a bool"));
+ return SQ_ERROR;
+ }
+
+ try {
+ scripting::debug_draw_editor_images(arg0 == SQTrue);
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'debug_draw_editor_images'"));
+ return SQ_ERROR;
+ }
+
+}
+
static SQInteger debug_worldmap_ghost_wrapper(HSQUIRRELVM vm)
{
SQBool arg0;
throw SquirrelError(v, "Couldn't register function 'debug_draw_solids_only'");
}
+ sq_pushstring(v, "debug_draw_editor_images", -1);
+ sq_newclosure(v, &debug_draw_editor_images_wrapper, 0);
+ sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tb");
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'debug_draw_editor_images'");
+ }
+
sq_pushstring(v, "debug_worldmap_ghost", -1);
sq_newclosure(v, &debug_worldmap_ghost_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tb");
lines.pop_back();
// increase console height if necessary
- if (height < 64) {
+ if ((stayOpen > 0) && (height < 64)) {
if(height < 4)
height = 4;
height += fontheight * line_count;
// reset console to full opacity
alpha = 1.0;
-
- // increase time that console stays open
- if(stayOpen < 6)
- stayOpen += 1.5;
}
void
}
void
+Console::open()
+{
+ if(stayOpen < 2)
+ stayOpen += 1.5;
+}
+
+void
Console::hide()
{
focused = false;
void update(float elapsed_time);
void show(); /**< display the console */
+ void open(); /**< open the console for viewing for 6 seconds */
void hide(); /**< hide the console */
void toggle(); /**< display the console if hidden, hide otherwise */
}
catch(std::exception& e)
{
- log_warning << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl;
+ log_info << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl;
}
}
#include "supertux/tile_set.hpp"
#include "video/drawing_context.hpp"
+bool Tile::draw_editor_images = false;
+
Tile::Tile(const TileSet& new_tileset) :
tileset(new_tileset),
imagespecs(),
images(),
+ editor_imagespecs(),
+ editor_images(),
attributes(0),
data(0),
fps(1)
{
}
-Tile::Tile(const TileSet& new_tileset, const std::vector<ImageSpec>& imagespecs_,
+Tile::Tile(const TileSet& new_tileset, const std::vector<ImageSpec>& imagespecs_, const std::vector<ImageSpec>& editor_imagespecs_,
uint32_t attributes, uint32_t data, float fps) :
tileset(new_tileset),
imagespecs(imagespecs_),
images(),
+ editor_imagespecs(editor_imagespecs_),
+ editor_images(),
attributes(attributes),
data(data),
fps(fps)
images.push_back(surface);
}
}
+
+ if(editor_images.size() == 0 && editor_imagespecs.size() != 0)
+ {
+ assert(editor_images.size() == 0);
+ for(std::vector<ImageSpec>::iterator i = editor_imagespecs.begin(); i != editor_imagespecs.end(); ++i)
+ {
+ const ImageSpec& spec = *i;
+
+ SurfacePtr surface;
+ if(spec.rect.get_width() <= 0)
+ {
+ surface = Surface::create(spec.file);
+ }
+ else
+ {
+ surface = Surface::create(spec.file,
+ Rect((int) spec.rect.p1.x,
+ (int) spec.rect.p1.y,
+ Size((int) spec.rect.get_width(),
+ (int) spec.rect.get_height())));
+ }
+ editor_images.push_back(surface);
+ }
+ }
}
void
Tile::draw(DrawingContext& context, const Vector& pos, int z_pos) const
{
+ if(draw_editor_images) {
+ if(editor_images.size() > 1) {
+ size_t frame = size_t(game_time * fps) % editor_images.size();
+ context.draw_surface(editor_images[frame], pos, z_pos);
+ return;
+ } else if (editor_images.size() == 1) {
+ context.draw_surface(editor_images[0], pos, z_pos);
+ return;
+ }
+ }
+
if(images.size() > 1) {
size_t frame = size_t(game_time * fps) % images.size();
context.draw_surface(images[frame], pos, z_pos);
Tile::print_debug(int id) const
{
log_debug << " Tile: id " << id << ", data " << getData() << ", attributes " << getAttributes() << ":" << std::endl;
+ for(std::vector<Tile::ImageSpec>::const_iterator im = editor_imagespecs.begin(); im != editor_imagespecs.end(); ++im)
+ log_debug << " Editor Imagespec: file " << im->file << "; rect " << im->rect << std::endl;
for(std::vector<Tile::ImageSpec>::const_iterator im = imagespecs.begin(); im != imagespecs.end(); ++im)
- {
- log_debug << " Imagespec: file " << im->file << "; rect " << im->rect << std::endl;
- }
+ log_debug << " Imagespec: file " << im->file << "; rect " << im->rect << std::endl;
}
/* EOF */
class Tile
{
public:
+ static bool draw_editor_images;
/// bitset for tile attributes
enum {
/** solid tile that is indestructible by Tux */
const TileSet& tileset;
std::vector<ImageSpec> imagespecs;
std::vector<SurfacePtr> images;
+ std::vector<ImageSpec> editor_imagespecs;
+ std::vector<SurfacePtr> editor_images;
/// tile attributes
uint32_t attributes;
public:
Tile(const TileSet& tileset);
- Tile(const TileSet& tileset, const std::vector<ImageSpec>& images,
+ Tile(const TileSet& tileset, const std::vector<ImageSpec>& images, const std::vector<ImageSpec>& editor_images,
uint32_t attributes, uint32_t data, float fps);
~Tile();
}
uint32_t attributes = 0;
- uint32_t data = 0;
- std::vector<Tile::ImageSpec> imagespecs;
-
- float fps = 10;
bool value = false;
if(reader.get("solid", value) && value)
if(reader.get("goal", value) && value)
attributes |= Tile::GOAL;
+ uint32_t data = 0;
+
if(reader.get("north", value) && value)
data |= Tile::WORLDMAP_NORTH;
if(reader.get("south", value) && value)
data |= Tile::WORLDMAP_STOP;
reader.get("data", data);
+
+ float fps = 10;
reader.get("fps", fps);
if(reader.get("slope-type", data))
attributes |= Tile::SOLID | Tile::SLOPE;
}
+ std::vector<Tile::ImageSpec> editor_imagespecs;
+ const lisp::Lisp* editor_images;
+ editor_images = reader.get_lisp("editor-images");
+ if(editor_images)
+ editor_imagespecs = parse_tile_images(*editor_images);
+
+ std::vector<Tile::ImageSpec> imagespecs;
const lisp::Lisp* images;
-#ifndef NDEBUG
- images = reader.get_lisp("editor-images");
+ images = reader.get_lisp("images");
if(images)
- imagespecs = parse_tile_images(*images);
- else {
-#endif
- images = reader.get_lisp("images");
- if(images)
imagespecs = parse_tile_images(*images);
-#ifndef NDEBUG
- }
-#endif
- std::auto_ptr<Tile> tile(new Tile(m_tileset, imagespecs, attributes, data, fps));
+ std::auto_ptr<Tile> tile(new Tile(m_tileset, imagespecs, editor_imagespecs, attributes, data, fps));
if (id >= m_tileset.tiles.size())
m_tileset.tiles.resize(id+1, 0);
std::vector<uint32_t> datas;
//List of frames that the tiles come in
std::vector<std::string> images;
+ //List of frames that the editor tiles come in
+ std::vector<std::string> editor_images;
// width and height of the image in tile units, this is used for two
// purposes:
bool has_datas = reader.get("datas", datas);
reader.get("image", images) || reader.get("images", images);
+ reader.get("editor-images", editor_images);
reader.get("width", width);
reader.get("height", height);
imagespecs.push_back(Tile::ImageSpec(m_tiles_path + *j, Rectf(x, y, x + 32, y + 32)));
}
- std::auto_ptr<Tile> tile(new Tile(m_tileset, imagespecs,
+ std::vector<Tile::ImageSpec> editor_imagespecs;
+ for(std::vector<std::string>::const_iterator j = editor_images.begin(); j != editor_images.end(); ++j)
+ {
+ editor_imagespecs.push_back(Tile::ImageSpec(m_tiles_path + *j, Rectf(x, y, x + 32, y + 32)));
+ }
+
+ std::auto_ptr<Tile> tile(new Tile(m_tileset, imagespecs, editor_imagespecs,
(has_attributes ? attributes[i] : 0), (has_datas ? datas[i] : 0), fps));
if (m_tileset.tiles[ids[i]] == 0) {
m_tileset.tiles[ids[i]] = tile.release();
#include "math/rectf.hpp"
#include "supertux/console.hpp"
-#ifndef NDEBUG
-
std::ostream& log_debug_f(const char* file, int line)
{
Console::output << "[DEBUG] " << file << ":" << line << " ";
std::ostream& log_warning_f(const char* file, int line)
{
+ Console::instance->open();
Console::output << "[WARNING] " << file << ":" << line << " ";
return Console::output;
}
-#endif
-
std::ostream& log_fatal_f(const char* file, int line)
{
+ Console::instance->open();
Console::output << "[FATAL] " << file << ":" << line << " ";
return Console::output;
}
#include <config.h>
#include <ostream>
-#ifndef NDEBUG
-
std::ostream& log_debug_f(const char* file, int line);
#define log_debug log_debug_f(__FILE__, __LINE__)
std::ostream& log_warning_f(const char* file, int line);
#define log_warning log_warning_f(__FILE__, __LINE__)
-#else
-
-#include <iostream>
-
-#define log_debug std::cout
-#define log_info std::cout
-#define log_warning std::cerr
-
-#endif
-
std::ostream& log_fatal_f(const char* file, int line);
-
#define log_fatal log_fatal_f(__FILE__, __LINE__)
class Vector;