[Super-tux-commit] supertux/src background.h,1.6,1.7 button.cpp,1.33,1.34 button.h,1.24,1.25 level.c
Brought to you by:
wkendrick
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19976/src Modified Files: background.h button.cpp button.h level.cpp leveleditor.cpp leveleditor.h menu.cpp sector.h title.cpp Log Message: Managed to update the level editor to the new drawing context code and stuff. But it has a lot of issues. Scrolling is not being respected, buttons are not working well, and lots of crashing. Time to rescue the level editor! :) Index: background.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/background.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- background.h 31 May 2004 02:40:29 -0000 1.6 +++ background.h 2 Jun 2004 23:33:34 -0000 1.7 @@ -40,6 +40,15 @@ void set_gradient(Color top, Color bottom); + std::string get_image() const + { return imagefile; } + float get_speed() const + { return speed; } + Color get_gradient_top() const + { return gradient_top; } + Color get_gradient_bottom() const + { return gradient_bottom; } + virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.129 retrieving revision 1.130 diff -u -d -r1.129 -r1.130 --- leveleditor.cpp 31 May 2004 22:13:15 -0000 1.129 +++ leveleditor.cpp 2 Jun 2004 23:33:35 -0000 1.130 @@ -37,17 +37,17 @@ #include "setup.h" #include "menu.h" #include "level.h" +#include "sector.h" +#include "tilemap.h" #include "gameloop.h" #include "badguy.h" +#include "player.h" #include "scene.h" #include "button.h" #include "tile.h" [...1015 lines suppressed...] - while(done_ == 0) - { - done_ = wait_for_event(event); - SDL_Delay(50); - } + while(done_ == 0) + { + done_ = wait_for_event(event); + SDL_Delay(50); + } + } show_selections = true; le_show_grid = tmp_show_grid; le_selection_mode = temp_le_selection_mode; le_help_shown = false; } - -#endif Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- menu.cpp 31 May 2004 23:47:05 -0000 1.76 +++ menu.cpp 2 Jun 2004 23:33:35 -0000 1.77 @@ -89,7 +89,10 @@ dialog->event(event); } - context.draw_surface(background, Vector(0,0), LAYER_BACKGROUND0); + if(background == NULL) + context.draw_gradient(Color(200, 100, 200), Color(100, 200, 100), LAYER_BACKGROUND0); + else + context.draw_surface(background, Vector(0,0), LAYER_BACKGROUND0); dialog->draw(context); dialog->action(); Index: sector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sector.h 31 May 2004 13:43:30 -0000 1.2 +++ sector.h 2 Jun 2004 23:33:35 -0000 1.3 @@ -119,11 +119,11 @@ std::string name; - std::string song_title; MusicRef level_song; MusicRef level_song_fast; public: + std::string song_title; float gravity; // some special objects, where we need direct access Index: button.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/button.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- button.h 30 May 2004 01:08:48 -0000 1.24 +++ button.h 2 Jun 2004 23:33:34 -0000 1.25 @@ -24,9 +24,6 @@ #include <vector> #include "screen/texture.h" -// TODO -#if 0 - enum ButtonState { BUTTON_NONE = -1, BUTTON_CLICKED, @@ -51,18 +48,18 @@ ~Button(); void event(SDL_Event& event); - void draw(); + void draw(DrawingContext& context); int get_state(); void set_active(bool active) { active ? state = BUTTON_NONE : state = BUTTON_DEACTIVE; }; void add_icon(const std::string& imagefile, int mw, int mh); SDL_Rect get_pos() { return rect; } int get_tag(){return tag; } - void set_drawable(Drawable* newdrawable) - { drawable = newdrawable; } +// void set_drawable(Drawable* newdrawable) +// { drawable = newdrawable; } private: static Timer popup_timer; - Drawable* drawable; +// Drawable* drawable; std::vector<Surface*> icon; std::string info; SDLKey shortcut; @@ -77,7 +74,7 @@ public: ButtonPanel(int x, int y, int w, int h); ~ButtonPanel(); - void draw(); + void draw(DrawingContext& context); Button* event(SDL_Event &event); void additem(Button* pbutton, int tag); Button* button_panel_event(SDL_Event& event); @@ -95,6 +92,5 @@ std::vector<Button*> item; std::vector<Button*>::iterator last_clicked; }; -#endif #endif /*SUPERTUX_BUTTON_H*/ Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -r1.89 -r1.90 --- level.cpp 31 May 2004 22:13:15 -0000 1.89 +++ level.cpp 2 Jun 2004 23:33:34 -0000 1.90 @@ -274,6 +274,45 @@ add_sector(sector); } +void +Level::save(const std::string& filename) +{ +#if 0 + LispReader* level = LispReader::load(filename, "supertux-level"); + + int version = 1; + level->read_int("version", version); + if(version == 1) { + load_old_format(*level); + return; + } + + for(lisp_object_t* cur = level->get_lisp(); !lisp_nil_p(cur); + cur = lisp_cdr(cur)) { + std::string token = lisp_symbol(lisp_car(lisp_car(cur))); + lisp_object_t* data = lisp_car(lisp_cdr(lisp_car(cur))); + LispReader reader(lisp_cdr(lisp_car(cur))); + + if(token == "name") { + name = lisp_string(data); + } else if(token == "author") { + author = lisp_string(data); + } else if(token == "time") { + time_left = lisp_integer(data); + } else if(token == "sector") { + Sector* sector = new Sector; + sector->parse(reader); + add_sector(sector); + } else { + std::cerr << "Unknown token '" << token << "' in level file.\n"; + continue; + } + } + + delete level; +#endif +} + Level::~Level() { for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) Index: button.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/button.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- button.cpp 30 May 2004 01:08:48 -0000 1.33 +++ button.cpp 2 Jun 2004 23:33:34 -0000 1.34 @@ -22,13 +22,11 @@ #include <stdlib.h> #include "setup.h" #include "screen/screen.h" +#include "screen/drawing_context.h" #include "globals.h" #include "button.h" #include "camera.h" -// TODO -#if 0 - Timer Button::popup_timer; Button::Button(Surface* button_image, const std::string& ninfo, @@ -50,7 +48,6 @@ tag = -1; state = BUTTON_NONE; show_info = false; - drawable = NULL; } Button::Button(const std::string& imagefilename, const std::string& ninfo, @@ -71,7 +68,6 @@ tag = -1; state = BUTTON_NONE; show_info = false; - drawable = NULL; } void Button::add_icon(const std::string& icon_file, int mw, int mh) @@ -99,7 +95,7 @@ } -void Button::draw() +void Button::draw(DrawingContext& context) { if(state == BUTTON_HOVER) if(!popup_timer.check()) @@ -109,14 +105,14 @@ fillrect(rect.x+1,rect.y+1,rect.w-2,rect.h-2,175,175,175,200); for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it) - (*it)->draw(rect.x,rect.y); + context.draw_surface(*it, Vector(rect.x,rect.y), LAYER_GUI); - if(drawable) +/* if(drawable) { Camera viewport; viewport.set_translation(Vector(rect.x, rect.y)); drawable->draw(viewport, 0); - } + }*/ if(show_info) { @@ -127,9 +123,9 @@ i = rect.w + strlen(info.c_str()) * white_small_text->w; if(!info.empty()) - white_small_text->draw(info.c_str(), i + rect.x - strlen(info.c_str()) * white_small_text->w, rect.y, 1); + context.draw_text(white_small_text, info.c_str(), Vector(i + rect.x - strlen(info.c_str()) * white_small_text->w, rect.y), LAYER_GUI); sprintf(str,"(%s)", SDL_GetKeyName(shortcut)); - white_small_text->draw(str, i + rect.x - strlen(str) * white_small_text->w, rect.y + white_small_text->h+2, 1); + context.draw_text(white_small_text, str, Vector(i + rect.x - strlen(str) * white_small_text->w, rect.y + white_small_text->h+2), LAYER_GUI); } if(state == BUTTON_PRESSED || state == BUTTON_DEACTIVE) fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200); @@ -272,7 +268,7 @@ item.clear(); } -void ButtonPanel::draw() +void ButtonPanel::draw(DrawingContext& context) { if(hidden == false) @@ -280,7 +276,7 @@ fillrect(rect.x,rect.y,rect.w,rect.h,100,100,100,200); for(std::vector<Button*>::iterator it = item.begin(); it != item.end(); ++it) { - (*it)->draw(); + (*it)->draw(context); if(hlast && it == last_clicked) { fillrect((*it)->get_pos().x,(*it)->get_pos().y,(*it)->get_pos().w,(*it)->get_pos().h,100,100,100,128); @@ -326,6 +322,3 @@ { hlast = b; } -#endif - - Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- title.cpp 31 May 2004 23:47:05 -0000 1.92 +++ title.cpp 2 Jun 2004 23:33:35 -0000 1.93 @@ -297,8 +297,7 @@ generate_contrib_menu(); break; case MNID_LEVELEDITOR: - // TODO - //leveleditor(); + leveleditor(); Menu::set_current(main_menu); break; case MNID_CREDITS: Index: leveleditor.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- leveleditor.h 30 May 2004 01:08:48 -0000 1.11 +++ leveleditor.h 2 Jun 2004 23:33:35 -0000 1.12 @@ -23,8 +23,6 @@ #ifndef SUPERTUX_LEVELEDITOR_H #define SUPERTUX_LEVELEDITOR_H -#if 0 // TODO - struct square { int x1, y1, x2, y2; @@ -42,6 +40,4 @@ int le_init(void); void le_checkevents(void); -#endif - #endif /*SUPERTUX_LEVELEDITOR_H*/ |