From: Ricardo Cruz Date: Tue, 29 Jun 2004 13:00:43 +0000 (+0000) Subject: Changes: X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=dfeeeb45adc66a590a9684daa58958e1dd75bf11;p=supertux.git Changes: - Font now supports drawing effect; - Level saving now works. Still has flaws: o Spawn points are not saved; o Tilemaps do not know differ foreground/background. Matze, Can you have a look at this? - Other minor stuff. SVN-Revision: 1520 --- diff --git a/src/badguy.h b/src/badguy.h index 6e53ec98b..99dcc3f60 100644 --- a/src/badguy.h +++ b/src/badguy.h @@ -136,6 +136,9 @@ public: */ void kill_me(int score); + /** initializes the badguy (when he appears on screen) */ + void activate(Direction direction); // should only be used by BadGuy's objects + private: void init(); @@ -153,9 +156,6 @@ private: void action_wingling(double frame_ratio); void action_walkingtree(double frame_ratio); - /** initializes the badguy (when he appears on screen) */ - void activate(Direction direction); - /** handles falling down. disables gravity calculation when we're back on * ground */ void fall(); diff --git a/src/level.cpp b/src/level.cpp index a3d5a44d5..f004fd2dc 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -115,7 +115,11 @@ Level::save(const std::string& filename) writer->write_int("time", time_left); for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) + { + writer->start_list("sector"); i->second->write(*writer); + writer->end_list("sector"); + } writer->end_list("supertux-level"); diff --git a/src/screen/drawing_context.cpp b/src/screen/drawing_context.cpp index 135d9a128..569fac2cb 100644 --- a/src/screen/drawing_context.cpp +++ b/src/screen/drawing_context.cpp @@ -76,13 +76,14 @@ DrawingContext::draw_surface_part(const Surface* surface, const Vector& source, void DrawingContext::draw_text(Font* font, const std::string& text, - const Vector& position, int layer) + const Vector& position, int layer, Uint32 drawing_effect) { DrawingRequest request; request.type = TEXT; request.layer = layer; request.pos = transform.apply(position); + request.drawing_effect = drawing_effect; TextRequest* textrequest = new TextRequest; textrequest->font = font; @@ -94,7 +95,7 @@ DrawingContext::draw_text(Font* font, const std::string& text, void DrawingContext::draw_text_center(Font* font, const std::string& text, - const Vector& position, int layer) + const Vector& position, int layer, Uint32 drawing_effect) { DrawingRequest request; @@ -102,6 +103,7 @@ DrawingContext::draw_text_center(Font* font, const std::string& text, request.layer = layer; request.pos = transform.apply(position) + Vector(screen->w/2 - font->get_text_width(text)/2, 0); + request.drawing_effect = drawing_effect; TextRequest* textrequest = new TextRequest; textrequest->font = font; @@ -212,7 +214,7 @@ DrawingContext::draw_text(DrawingRequest& request) { TextRequest* textrequest = (TextRequest*) request.request_data; - textrequest->font->draw(textrequest->text, request.pos); + textrequest->font->draw(textrequest->text, request.pos, request.drawing_effect); delete textrequest; } @@ -226,6 +228,7 @@ DrawingContext::draw_filled_rect(DrawingRequest& request) float y = request.pos.y; float w = fillrectrequest->size.x; float h = fillrectrequest->size.y; + #ifndef NOOPENGL if(use_gl) { diff --git a/src/screen/drawing_context.h b/src/screen/drawing_context.h index ceb9ea2bc..48bd54d91 100644 --- a/src/screen/drawing_context.h +++ b/src/screen/drawing_context.h @@ -62,10 +62,10 @@ public: Uint32 drawing_effect = NONE_EFFECT); /** draws a text */ void draw_text(Font* font, const std::string& text, const Vector& position, - int layer); + int layer, Uint32 drawing_effect = NONE_EFFECT); /** draws aligned text */ void draw_text_center(Font* font, const std::string& text, - const Vector& position, int layer); + const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT); /** draws a color gradient onto the whole screen */ void draw_gradient(Color from, Color to, int layer); /** fills a rectangle */ diff --git a/src/screen/font.cpp b/src/screen/font.cpp index af159b929..4ea0469f5 100644 --- a/src/screen/font.cpp +++ b/src/screen/font.cpp @@ -81,16 +81,18 @@ Font::get_text_width(const std::string& text) const } void -Font::draw(const std::string& text, const Vector& pos) +Font::draw(const std::string& text, const Vector& pos, Uint32 drawing_effect) { if(shadowsize > 0) - draw_chars(shadow_chars, text, pos + Vector(shadowsize, shadowsize)); + draw_chars(shadow_chars, text, pos + Vector(shadowsize, shadowsize), + drawing_effect); - draw_chars(chars, text, pos); + draw_chars(chars, text, pos, drawing_effect); } void -Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos) +Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos, + Uint32 drawing_effect) { SurfaceImpl* impl = pchars->impl; @@ -115,7 +117,7 @@ Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos) int source_x = (index % 16) * w; int source_y = (index / 16) * h; - impl->draw_part(source_x, source_y, p.x, p.y, w, h, 255); + impl->draw_part(source_x, source_y, p.x, p.y, w, h, 255, drawing_effect); p.x += w; } } diff --git a/src/screen/font.h b/src/screen/font.h index f3f31cde0..369410b60 100644 --- a/src/screen/font.h +++ b/src/screen/font.h @@ -53,9 +53,10 @@ public: private: friend class DrawingContext; - void draw(const std::string& text, const Vector& pos); + void draw(const std::string& text, const Vector& pos, + Uint32 drawing_effect = NONE_EFFECT); void draw_chars(Surface* pchars, const std::string& text, - const Vector& position); + const Vector& position, Uint32 drawing_effect); Surface* chars; Surface* shadow_chars; diff --git a/src/sector.cpp b/src/sector.cpp index 5752860c2..78c45bd50 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -265,6 +265,7 @@ Sector::write(LispWriter& writer) { writer.write_string("name", name); writer.write_float("gravity", gravity); + writer.write_string("music", song_title); for(GameObjects::iterator i = gameobjects.begin(); i != gameobjects.end(); ++i) { diff --git a/src/tilemap.cpp b/src/tilemap.cpp index 222fdd5e5..42abf7b4c 100644 --- a/src/tilemap.cpp +++ b/src/tilemap.cpp @@ -52,7 +52,7 @@ TileMap::TileMap(LispReader& reader) else if(layer == "foreground") layer = LAYER_FOREGROUNDTILES; else - std::cout << "Unknown layer '" << layer << "' in tilemap.\n"; + std::cerr << "Unknown layer '" << layer << "' in tilemap.\n"; } reader.read_bool("solid", solid); @@ -99,7 +99,8 @@ TileMap::write(LispWriter& writer) else if(layer == LAYER_FOREGROUNDTILES) writer.write_string("layer", "foreground"); else { - std::cout << "Warning unknown layer in tilemap.\n"; + writer.write_string("layer", "unknown"); + std::cerr << "Warning unknown layer in tilemap.\n"; } writer.write_bool("solid", solid);