From: mathnerd314 Date: Mon, 25 Jan 2010 02:01:14 +0000 (+0000) Subject: Console logging is now identical in all builds; warning and error show the console... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=cc2848ea41e57f729a5eec79e9b2670b448b97b9;p=supertux.git Console logging is now identical in all builds; warning and error show the console for 1.5-3 seconds. Tile editor images are now scripted by debug_draw_editor_images Change contrib_menu level subset warning to info. Ignore "release" directory that holds release builds. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6271 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 6c84d3002..4fb1a6aa1 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -29,6 +29,7 @@ #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" @@ -144,6 +145,11 @@ void debug_draw_solids_only(bool enable) 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; diff --git a/src/scripting/functions.hpp b/src/scripting/functions.hpp index 6eb807444..e1828c2bf 100644 --- a/src/scripting/functions.hpp +++ b/src/scripting/functions.hpp @@ -128,6 +128,11 @@ void debug_show_fps(bool enable); 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); diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index 08d04ef6c..0f4ae0650 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -3366,6 +3366,29 @@ static SQInteger debug_draw_solids_only_wrapper(HSQUIRRELVM vm) } +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; @@ -4411,6 +4434,13 @@ void register_supertux_wrapper(HSQUIRRELVM v) 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"); diff --git a/src/supertux/console.cpp b/src/supertux/console.cpp index e4f246c21..883ec09d6 100644 --- a/src/supertux/console.cpp +++ b/src/supertux/console.cpp @@ -363,7 +363,7 @@ Console::addLine(std::string s) 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; @@ -371,10 +371,6 @@ Console::addLine(std::string s) // reset console to full opacity alpha = 1.0; - - // increase time that console stays open - if(stayOpen < 6) - stayOpen += 1.5; } void @@ -439,6 +435,13 @@ Console::show() } void +Console::open() +{ + if(stayOpen < 2) + stayOpen += 1.5; +} + +void Console::hide() { focused = false; diff --git a/src/supertux/console.hpp b/src/supertux/console.hpp index 64b6c8dee..d81bbf38f 100644 --- a/src/supertux/console.hpp +++ b/src/supertux/console.hpp @@ -56,6 +56,7 @@ public: 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 */ diff --git a/src/supertux/menu/contrib_menu.cpp b/src/supertux/menu/contrib_menu.cpp index 5b6ee413d..34895b73d 100644 --- a/src/supertux/menu/contrib_menu.cpp +++ b/src/supertux/menu/contrib_menu.cpp @@ -56,7 +56,7 @@ ContribMenu::ContribMenu() : } 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; } } diff --git a/src/supertux/tile.cpp b/src/supertux/tile.cpp index 3d5ec4df7..a0b73e149 100644 --- a/src/supertux/tile.cpp +++ b/src/supertux/tile.cpp @@ -20,21 +20,27 @@ #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& imagespecs_, +Tile::Tile(const TileSet& new_tileset, const std::vector& imagespecs_, const std::vector& 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) @@ -72,11 +78,46 @@ Tile::load_images() images.push_back(surface); } } + + if(editor_images.size() == 0 && editor_imagespecs.size() != 0) + { + assert(editor_images.size() == 0); + for(std::vector::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); @@ -100,10 +141,10 @@ void Tile::print_debug(int id) const { log_debug << " Tile: id " << id << ", data " << getData() << ", attributes " << getAttributes() << ":" << std::endl; + for(std::vector::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::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 */ diff --git a/src/supertux/tile.hpp b/src/supertux/tile.hpp index b2d2ae238..60b3991fb 100644 --- a/src/supertux/tile.hpp +++ b/src/supertux/tile.hpp @@ -31,6 +31,7 @@ class DrawingContext; class Tile { public: + static bool draw_editor_images; /// bitset for tile attributes enum { /** solid tile that is indestructible by Tux */ @@ -95,6 +96,8 @@ private: const TileSet& tileset; std::vector imagespecs; std::vector images; + std::vector editor_imagespecs; + std::vector editor_images; /// tile attributes uint32_t attributes; @@ -106,7 +109,7 @@ private: public: Tile(const TileSet& tileset); - Tile(const TileSet& tileset, const std::vector& images, + Tile(const TileSet& tileset, const std::vector& images, const std::vector& editor_images, uint32_t attributes, uint32_t data, float fps); ~Tile(); diff --git a/src/supertux/tile_set_parser.cpp b/src/supertux/tile_set_parser.cpp index 484c7a275..a4cbd3d3f 100644 --- a/src/supertux/tile_set_parser.cpp +++ b/src/supertux/tile_set_parser.cpp @@ -79,10 +79,6 @@ TileSetParser::parse_tile(const Reader& reader) } uint32_t attributes = 0; - uint32_t data = 0; - std::vector imagespecs; - - float fps = 10; bool value = false; if(reader.get("solid", value) && value) @@ -106,6 +102,8 @@ TileSetParser::parse_tile(const Reader& reader) 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) @@ -118,6 +116,8 @@ TileSetParser::parse_tile(const Reader& reader) data |= Tile::WORLDMAP_STOP; reader.get("data", data); + + float fps = 10; reader.get("fps", fps); if(reader.get("slope-type", data)) @@ -125,21 +125,19 @@ TileSetParser::parse_tile(const Reader& reader) attributes |= Tile::SOLID | Tile::SLOPE; } + std::vector 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 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(new Tile(m_tileset, imagespecs, attributes, data, fps)); + std::auto_ptr tile(new Tile(m_tileset, imagespecs, editor_imagespecs, attributes, data, fps)); if (id >= m_tileset.tiles.size()) m_tileset.tiles.resize(id+1, 0); @@ -210,6 +208,8 @@ TileSetParser::parse_tiles(const Reader& reader) std::vector datas; //List of frames that the tiles come in std::vector images; + //List of frames that the editor tiles come in + std::vector editor_images; // width and height of the image in tile units, this is used for two // purposes: @@ -226,6 +226,7 @@ TileSetParser::parse_tiles(const Reader& reader) 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); @@ -280,7 +281,13 @@ TileSetParser::parse_tiles(const Reader& reader) imagespecs.push_back(Tile::ImageSpec(m_tiles_path + *j, Rectf(x, y, x + 32, y + 32))); } - std::auto_ptr tile(new Tile(m_tileset, imagespecs, + std::vector editor_imagespecs; + for(std::vector::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(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(); diff --git a/src/util/log.cpp b/src/util/log.cpp index 7b0107b9d..036ada58c 100644 --- a/src/util/log.cpp +++ b/src/util/log.cpp @@ -19,8 +19,6 @@ #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 << " "; @@ -35,14 +33,14 @@ std::ostream& log_info_f(const char* file, int 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; } diff --git a/src/util/log.hpp b/src/util/log.hpp index b5219b292..7882eac8e 100644 --- a/src/util/log.hpp +++ b/src/util/log.hpp @@ -20,8 +20,6 @@ #include #include -#ifndef NDEBUG - std::ostream& log_debug_f(const char* file, int line); #define log_debug log_debug_f(__FILE__, __LINE__) @@ -31,18 +29,7 @@ std::ostream& log_info_f(const char* file, int line); std::ostream& log_warning_f(const char* file, int line); #define log_warning log_warning_f(__FILE__, __LINE__) -#else - -#include - -#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;