super-tux-commit Mailing List for Super Tux (Page 47)
Brought to you by:
wkendrick
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(94) |
Apr
(500) |
May
(531) |
Jun
(196) |
Jul
(224) |
Aug
(193) |
Sep
(117) |
Oct
(115) |
Nov
(319) |
Dec
(97) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(19) |
Feb
|
Mar
(105) |
Apr
(41) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2007 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
(7) |
Oct
(12) |
Nov
(26) |
Dec
(39) |
2009 |
Jan
(6) |
Feb
(15) |
Mar
(10) |
Apr
(25) |
May
(29) |
Jun
(21) |
Jul
(26) |
Aug
(8) |
Sep
(3) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
|
From: Tobias G. <to...@us...> - 2004-07-21 16:52:04
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32238/lib/special Modified Files: base.h game_object.cpp game_object.h moving_object.cpp moving_object.h sprite.cpp sprite.h sprite_manager.cpp sprite_manager.h stringlist.cpp stringlist.h timer.cpp timer.h Log Message: The SuperTux library features a SuperTux namespace now. + minor Bugfixes and cleanups Index: moving_object.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/moving_object.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- moving_object.cpp 20 Jul 2004 17:51:37 -0000 1.1 +++ moving_object.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -19,6 +19,8 @@ #include "special/moving_object.h" +using namespace SuperTux; + MovingObject::MovingObject() { base.x = base.y = base.width = base.height = 0; Index: timer.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/timer.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- timer.h 20 Jul 2004 20:05:34 -0000 1.2 +++ timer.h 21 Jul 2004 16:51:52 -0000 1.3 @@ -21,63 +21,68 @@ #ifndef SUPERTUX_TIMER_H #define SUPERTUX_TIMER_H -extern unsigned int st_pause_ticks, st_pause_count; +namespace SuperTux + { -/// Time a game is running. (Non-pause mode, etc.) -unsigned int st_get_ticks(void); + extern unsigned int st_pause_ticks, st_pause_count; -void st_pause_ticks_init(void); -void st_pause_ticks_start(void); -void st_pause_ticks_stop(void); -bool st_pause_ticks_started(void); + /// Time a game is running. (Non-pause mode, etc.) + unsigned int st_get_ticks(void); -/// Timer -/** This class can be used as stop watch - for example. It's also possible to calculate - frames per seconds and things like that with it. - It's a general timing class, but it - can esspecially be used together with st_get_ticks(). */ -class Timer -{ - public: - unsigned int period; - unsigned int time; - unsigned int (*get_ticks) (void); + void st_pause_ticks_init(void); + void st_pause_ticks_start(void); + void st_pause_ticks_stop(void); + bool st_pause_ticks_started(void); - public: - Timer(); - - /// Initialize the timer. - /** @Param st_ticks: If true internally st_get_ticks() is used, else SDL_GetTicks() is used. */ - void init(bool st_ticks); - - /// Start the timer with the given period (in ms). - void start(unsigned int period); - - /// Stop the timer. - void stop(); + /// Timer + /** This class can be used as stop watch + for example. It's also possible to calculate + frames per seconds and things like that with it. + It's a general timing class, but it + can esspecially be used together with st_get_ticks(). */ + class Timer + { + public: + unsigned int period; + unsigned int time; + unsigned int (*get_ticks) (void); - /// Check if the timer is started and within its period. - /** If one of these requirements isn't the case the timer - is automatically reseted. */ - int check(); - - /// Is the timer started? - int started(); + public: + Timer(); - /// Get time left until the last timing period is finished. - /** The returned value can be negative. */ - int get_left(); + /// Initialize the timer. + /** @param st_ticks: If true internally st_get_ticks() is used, else SDL_GetTicks() is used. */ + void init(bool st_ticks); - /// Get the gone time, since last timer start. - /** The returned value can be negative. */ - int get_gone(); - - /// Write the timer value to a file (For save games in example). - void fwrite(FILE* fi); - /// Read a timer value from a file (From save games in example). - void fread(FILE* fi); -}; + /// Start the timer with the given period (in ms). + void start(unsigned int period); + + /// Stop the timer. + void stop(); + + /// Check if the timer is started and within its period. + /** If one of these requirements isn't the case the timer + is automatically reseted. */ + int check(); + + /// Is the timer started? + int started(); + + /// Get time left until the last timing period is finished. + /** The returned value can be negative. */ + int get_left(); + + /// Get the gone time, since last timer start. + /** The returned value can be negative. */ + int get_gone(); + + /// Write the timer value to a file (For save games in example). + void fwrite(FILE* fi); + /// Read a timer value from a file (From save games in example). + void fread(FILE* fi); + }; + +} //namespace SuperTux #endif /*SUPERTUX_TIMER_H*/ Index: sprite_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite_manager.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sprite_manager.cpp 20 Jul 2004 17:51:37 -0000 1.1 +++ sprite_manager.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -22,6 +22,8 @@ #include "utils/lispreader.h" #include "special/sprite_manager.h" +using namespace SuperTux; + SpriteManager::SpriteManager(const std::string& filename) { load_resfile(filename); Index: stringlist.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/stringlist.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- stringlist.h 20 Jul 2004 17:51:37 -0000 1.1 +++ stringlist.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -21,22 +21,25 @@ #ifndef SUPERTUX_STRINGLIST_H #define SUPERTUX_STRINGLIST_H -struct string_list_type -{ - int num_items; - int active_item; - char **item; -}; +namespace SuperTux + { -void string_list_init(string_list_type* pstring_list); -char* string_list_active(string_list_type* pstring_list); -void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig); -int string_list_find(string_list_type* pstring_list, const char* str); -void string_list_sort(string_list_type* pstring_list); -void string_list_add_item(string_list_type* pstring_list, const char* str); -void string_list_free(string_list_type* pstring_list); + struct string_list_type + { + int num_items; + int active_item; + char **item; + }; + void string_list_init(string_list_type* pstring_list); + char* string_list_active(string_list_type* pstring_list); + void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig); + int string_list_find(string_list_type* pstring_list, const char* str); + void string_list_sort(string_list_type* pstring_list); + void string_list_add_item(string_list_type* pstring_list, const char* str); + void string_list_free(string_list_type* pstring_list); +} //namespace SuperTux #endif /*SUPERTUX_STRINGLIST_H*/ Index: game_object.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/game_object.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- game_object.cpp 20 Jul 2004 17:51:37 -0000 1.1 +++ game_object.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -19,6 +19,8 @@ #include "special/game_object.h" +using namespace SuperTux; + GameObject::GameObject() : wants_to_die(false) { Index: sprite.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sprite.cpp 20 Jul 2004 17:51:37 -0000 1.1 +++ sprite.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -25,6 +25,8 @@ #include "special/sprite.h" #include "video/drawing_context.h" +using namespace SuperTux; + Sprite::Sprite(lisp_object_t* cur) { init_defaults(); Index: moving_object.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/moving_object.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- moving_object.h 20 Jul 2004 17:51:37 -0000 1.1 +++ moving_object.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -25,37 +25,44 @@ #include "math/vector.h" //#include "rectangle.h" -/** - * Base class for all dynamic/moving game objects. This class contains things - * for handling the bounding boxes and collision feedback. - */ -class MovingObject : public GameObject -{ -public: - MovingObject(); - virtual ~MovingObject(); +namespace SuperTux + { - /** this function is called when the object collided with any other object + /** + * Base class for all dynamic/moving game objects. This class contains things + * for handling the bounding boxes and collision feedback. */ - virtual void collision(const MovingObject& other_object, - int collision_type) = 0; + class MovingObject : public GameObject + { + public: + MovingObject(); + virtual ~MovingObject(); - Vector get_pos() const - { return Vector(base.x, base.y); } + /** this function is called when the object collided with any other object + */ + virtual void collision(const MovingObject& other_object, + int collision_type) = 0; - base_type base; - base_type old_base; + Vector get_pos() const + { + return Vector(base.x, base.y); + } -protected: + base_type base; + base_type old_base; + + protected: #if 0 // this will be used in my collision detection rewrite later - /// the current position of the object - Vector pos; - /// the position we want to move until next frame - Vector new_pos; - /// the bounding box relative to the current position - Rectangle bounding_box; + /// the current position of the object + Vector pos; + /// the position we want to move until next frame + Vector new_pos; + /// the bounding box relative to the current position + Rectangle bounding_box; #endif -}; + }; + +} //namespace SuperTux #endif /*SUPERTUX_MOVING_OBJECT_H*/ Index: base.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/base.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- base.h 20 Jul 2004 20:24:47 -0000 1.2 +++ base.h 21 Jul 2004 16:51:52 -0000 1.3 @@ -18,25 +18,29 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. -#ifndef SUPERTUX_TYPE_H -#define SUPERTUX_TYPE_H +#ifndef SUPERTUX_BASE_H +#define SUPERTUX_BASE_H #include <string> #include "SDL.h" -/// 'Base' type for game objects. -/** Mainly for layered use in game objects. - Containts upper left X and Y coordinates of an - object along with its width and height. */ -struct base_type -{ - float x; - float y; - float width; - float height; -}; +namespace SuperTux + { + + /// 'Base' type for game objects. + /** Mainly for layered use in game objects. + Containts upper left X and Y coordinates of an + object along with its width and height. */ + struct base_type + { + float x; + float y; + float width; + float height; + }; +} -#endif /*SUPERTUX_TYPE_H*/ +#endif /*SUPERTUX_BASE_H*/ Index: sprite.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sprite.h 20 Jul 2004 17:51:37 -0000 1.1 +++ sprite.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -27,51 +27,69 @@ #include "video/surface.h" #include "math/vector.h" -class Sprite -{ - private: - std::string name; +namespace SuperTux + { - int x_hotspot; - int y_hotspot; + class Sprite + { + private: + std::string name; - /** Frames per second */ - float fps; + int x_hotspot; + int y_hotspot; - /** Number of seconds that a frame is displayed until it is switched - to the next frame */ - float frame_delay; + /** Frames per second */ + float fps; - float time; + /** Number of seconds that a frame is displayed until it is switched + to the next frame */ + float frame_delay; - std::vector<Surface*> surfaces; + float time; - void init_defaults(); - public: - /** cur has to be a pointer to data in the form of ((x-hotspot 5) - (y-hotspot 10) ...) */ - Sprite(lisp_object_t* cur); - ~Sprite(); - - void reset(); + std::vector<Surface*> surfaces; - /** Update the sprite and process to the next frame */ - void update(float delta); - void draw(DrawingContext& context, const Vector& pos, int layer, - Uint32 drawing_effect = NONE_EFFECT); - int get_current_frame() const; + void init_defaults(); + public: + /** cur has to be a pointer to data in the form of ((x-hotspot 5) + (y-hotspot 10) ...) */ + Sprite(lisp_object_t* cur); + ~Sprite(); - float get_fps() { return fps; } ; - int get_frames() { return surfaces.size(); } ; + void reset(); - std::string get_name() const { return name; } - int get_width() const; - int get_height() const; + /** Update the sprite and process to the next frame */ + void update(float delta); + void draw(DrawingContext& context, const Vector& pos, int layer, + Uint32 drawing_effect = NONE_EFFECT); + int get_current_frame() const; - Surface* get_frame(unsigned int frame) - { if(frame < surfaces.size()) return surfaces[frame]; - else return surfaces[0]; } -}; + float get_fps() + { + return fps; + } ; + int get_frames() + { + return surfaces.size(); + } ; + + std::string get_name() const + { + return name; + } + int get_width() const; + int get_height() const; + + Surface* get_frame(unsigned int frame) + { + if(frame < surfaces.size()) + return surfaces[frame]; + else + return surfaces[0]; + } + }; + +} //namespace SuperTux #endif /*SUPERTUX_SPRITE_H*/ Index: timer.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/timer.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- timer.cpp 20 Jul 2004 17:51:37 -0000 1.1 +++ timer.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -21,9 +21,11 @@ #include "SDL.h" #include "special/timer.h" -unsigned int st_pause_ticks, st_pause_count; +using namespace SuperTux; -unsigned int st_get_ticks(void) +unsigned int SuperTux::st_pause_ticks, SuperTux::st_pause_count; + +unsigned int SuperTux::st_get_ticks(void) { if(st_pause_count != 0) return /*SDL_GetTicks()*/ - st_pause_ticks /*- SDL_GetTicks()*/ + st_pause_count; @@ -31,19 +33,19 @@ return SDL_GetTicks() - st_pause_ticks; } -void st_pause_ticks_init(void) +void SuperTux::st_pause_ticks_init(void) { st_pause_ticks = 0; st_pause_count = 0; } -void st_pause_ticks_start(void) +void SuperTux::st_pause_ticks_start(void) { if(st_pause_count == 0) st_pause_count = SDL_GetTicks(); } -void st_pause_ticks_stop(void) +void SuperTux::st_pause_ticks_stop(void) { if(st_pause_count == 0) return; @@ -52,7 +54,7 @@ st_pause_count = 0; } -bool st_pause_ticks_started(void) +bool SuperTux::st_pause_ticks_started(void) { if(st_pause_count == 0) return false; Index: game_object.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/game_object.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- game_object.h 20 Jul 2004 17:51:37 -0000 1.1 +++ game_object.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -22,50 +22,58 @@ #include <string> -class DrawingContext; +namespace SuperTux + { -/** - * Base class for all game objects. This contains functions for: - * -querying the actual type of the object - * -a flag that indicates if the object wants to be removed. Objects with this - * flag will be removed at the end of each frame. This is alot safer than - * having some uncontrollable "delete this" in the code. - * -an action function that is called once per frame and allows the object to - * update it's state. - * - * Most GameObjects will also implement the DrawableObject interface so that - * they can actually be drawn on screen. - */ -class GameObject // TODO rename this once the game has been converted -{ -public: - GameObject(); - virtual ~GameObject(); + class DrawingContext; - /** This function is called once per frame and allows the object to update - * it's state. The elapsed_time is the time since the last frame and should be - * the base for all timed things. + /** + * Base class for all game objects. This contains functions for: + * -querying the actual type of the object + * -a flag that indicates if the object wants to be removed. Objects with this + * flag will be removed at the end of each frame. This is alot safer than + * having some uncontrollable "delete this" in the code. + * -an action function that is called once per frame and allows the object to + * update it's state. + * + * Most GameObjects will also implement the DrawableObject interface so that + * they can actually be drawn on screen. */ - virtual void action(float elapsed_time) = 0; + class GameObject // TODO rename this once the game has been converted + { + public: + GameObject(); + virtual ~GameObject(); - /** The GameObject should draw itself onto the provided DrawingContext if this - * function is called. - */ - virtual void draw(DrawingContext& context) = 0; + /** This function is called once per frame and allows the object to update + * it's state. The elapsed_time is the time since the last frame and should be + * the base for all timed things. + */ + virtual void action(float elapsed_time) = 0; - /** returns true if the object is not scheduled to be removed yet */ - bool is_valid() const - { return !wants_to_die; } - /** schedules this object to be removed at the end of the frame */ - void remove_me() - { wants_to_die = true; } - -private: - /** this flag indicates if the object should be removed at the end of the - * frame - */ - bool wants_to_die; -}; + /** The GameObject should draw itself onto the provided DrawingContext if this + * function is called. + */ + virtual void draw(DrawingContext& context) = 0; + /** returns true if the object is not scheduled to be removed yet */ + bool is_valid() const + { + return !wants_to_die; + } + /** schedules this object to be removed at the end of the frame */ + void remove_me() + { + wants_to_die = true; + } + + private: + /** this flag indicates if the object should be removed at the end of the + * frame + */ + bool wants_to_die; + }; + +} #endif /*SUPERTUX_GAMEOBJECT_H*/ Index: stringlist.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/stringlist.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- stringlist.cpp 20 Jul 2004 17:51:37 -0000 1.1 +++ stringlist.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -22,14 +22,16 @@ #include "stdlib.h" #include "special/stringlist.h" -void string_list_init(string_list_type* pstring_list) +using namespace SuperTux; + +void SuperTux::string_list_init(string_list_type* pstring_list) { pstring_list->num_items = 0; pstring_list->active_item = -1; pstring_list->item = NULL; } -char* string_list_active(string_list_type* pstring_list) +char* SuperTux::string_list_active(string_list_type* pstring_list) { if(pstring_list == NULL) return ""; @@ -40,7 +42,7 @@ return ""; } -void string_list_add_item(string_list_type* pstring_list,const char* str) +void SuperTux::string_list_add_item(string_list_type* pstring_list,const char* str) { char *pnew_string; pnew_string = (char*) malloc(sizeof(char)*(strlen(str)+1)); @@ -52,7 +54,7 @@ pstring_list->active_item = 0; } -void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig) +void SuperTux::string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig) { int i; string_list_free(pstring_list); @@ -60,7 +62,7 @@ string_list_add_item(pstring_list,pstring_list_orig.item[i]); } -int string_list_find(string_list_type* pstring_list,const char* str) +int SuperTux::string_list_find(string_list_type* pstring_list,const char* str) { int i; for(i = 0; i < pstring_list->num_items; ++i) @@ -73,7 +75,7 @@ return -1; } -void string_list_sort(string_list_type* pstring_list) +void SuperTux::string_list_sort(string_list_type* pstring_list) { int i,j,y; @@ -103,7 +105,7 @@ } -void string_list_free(string_list_type* pstring_list) +void SuperTux::string_list_free(string_list_type* pstring_list) { if(pstring_list != NULL) { Index: sprite_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite_manager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sprite_manager.h 20 Jul 2004 17:51:37 -0000 1.1 +++ sprite_manager.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -24,21 +24,26 @@ #include "special/sprite.h" -class SpriteManager -{ - private: - typedef std::map<std::string, Sprite*> Sprites; - Sprites sprites; - public: - SpriteManager(const std::string& filename); - ~SpriteManager(); - - void load_resfile(const std::string& filename); - /** loads a sprite. - * WARNING: You must not delete the returned object. - */ - Sprite* load(const std::string& name); -}; +namespace SuperTux + { + + class SpriteManager + { + private: + typedef std::map<std::string, Sprite*> Sprites; + Sprites sprites; + public: + SpriteManager(const std::string& filename); + ~SpriteManager(); + + void load_resfile(const std::string& filename); + /** loads a sprite. + * WARNING: You must not delete the returned object. + */ + Sprite* load(const std::string& name); + }; + +} //namespace SuperTux #endif /*SUPERTUX_SPRITE_MANAGER_H*/ |
From: Tobias G. <to...@us...> - 2004-07-21 16:52:04
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32238/lib/utils Modified Files: configfile.cpp configfile.h exceptions.h lispreader.cpp lispreader.h lispwriter.cpp lispwriter.h Log Message: The SuperTux library features a SuperTux namespace now. + minor Bugfixes and cleanups Index: lispwriter.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispwriter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lispwriter.h 20 Jul 2004 17:51:38 -0000 1.1 +++ lispwriter.h 21 Jul 2004 16:51:53 -0000 1.2 @@ -24,33 +24,38 @@ #include <string> #include <vector> -class LispWriter -{ -public: - LispWriter(std::ostream& out); - ~LispWriter(); +namespace SuperTux + { - void write_comment(const std::string& comment); - - void start_list(const std::string& listname); + class LispWriter + { + public: + LispWriter(std::ostream& out); + ~LispWriter(); - void write_int(const std::string& name, int value); - void write_float(const std::string& name, float value); - void write_string(const std::string& name, const std::string& value); - void write_bool(const std::string& name, bool value); - void write_int_vector(const std::string& name, const std::vector<int>& value); - void write_int_vector(const std::string& name, const std::vector<unsigned int>& value); - // add more write-functions when needed... - - void end_list(const std::string& listname); + void write_comment(const std::string& comment); -private: - void indent(); - - std::ostream& out; - int indent_depth; - std::vector<std::string> lists; -}; + void start_list(const std::string& listname); -#endif + void write_int(const std::string& name, int value); + void write_float(const std::string& name, float value); + void write_string(const std::string& name, const std::string& value); + void write_bool(const std::string& name, bool value); + void write_int_vector(const std::string& name, const std::vector<int>& value); + void write_int_vector(const std::string& name, const std::vector<unsigned int>& value); + // add more write-functions when needed... + + void end_list(const std::string& listname); + + private: + void indent(); + + std::ostream& out; + int indent_depth; + std::vector<std::string> lists; + }; + +} //namespace SuperTux + +#endif //SUPERTUX_LISPWRITER_H Index: configfile.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- configfile.h 20 Jul 2004 17:51:37 -0000 1.1 +++ configfile.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -22,6 +22,8 @@ #include "utils/lispreader.h" +namespace SuperTux { + class Config { public: void load (); @@ -32,6 +34,7 @@ extern Config* config; +} //namespace SuperTux #endif Index: lispreader.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lispreader.h 20 Jul 2004 17:51:38 -0000 1.1 +++ lispreader.h 21 Jul 2004 16:51:53 -0000 1.2 @@ -33,6 +33,8 @@ #include "utils/exceptions.h" +namespace SuperTux { + #define LISP_STREAM_FILE 1 #define LISP_STREAM_STRING 2 #define LISP_STREAM_ANY 3 @@ -200,5 +202,7 @@ lisp_object_t* get_lisp(); }; +} //namespace SuperTux + #endif /*SUPERTUX_LISPREADER_H*/ Index: lispwriter.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispwriter.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lispwriter.cpp 20 Jul 2004 17:51:38 -0000 1.1 +++ lispwriter.cpp 21 Jul 2004 16:51:53 -0000 1.2 @@ -21,6 +21,8 @@ #include "utils/lispwriter.h" +using namespace SuperTux; + LispWriter::LispWriter(std::ostream& newout) : out(newout), indent_depth(0) { Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- configfile.cpp 20 Jul 2004 17:51:37 -0000 1.1 +++ configfile.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -24,13 +24,15 @@ #include "app/setup.h" #include "app/globals.h" +using namespace SuperTux; + #ifdef WIN32 const char * config_filename = "/st_config.dat"; #else const char * config_filename = "/config"; #endif -Config* config = 0; +Config* SuperTux::config = 0; static void defaults () { Index: exceptions.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/exceptions.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- exceptions.h 20 Jul 2004 17:51:38 -0000 1.1 +++ exceptions.h 21 Jul 2004 16:51:52 -0000 1.2 @@ -24,21 +24,26 @@ #include <exception> #include <string> -class SuperTuxException : public std::exception -{ - public: - SuperTuxException(const char* _message, const char* _file = "", const unsigned int _line = 0) - : message(_message), file(_file), line(_line) { }; - virtual ~SuperTuxException() throw() { }; +namespace SuperTux + { - const char* what() const throw() { return message; }; - const char* what_file() const throw() { return file; }; - const unsigned int what_line() const throw() { return line; }; - - private: - const char* message; - const char* file; - const unsigned int line; -}; + class SuperTuxException : public std::exception + { + public: + SuperTuxException(const char* _message, const char* _file = "", const unsigned int _line = 0) + : message(_message), file(_file), line(_line) { }; + virtual ~SuperTuxException() throw() { }; + + const char* what() const throw() { return message; }; + const char* what_file() const throw() { return file; }; + const unsigned int what_line() const throw() { return line; }; + + private: + const char* message; + const char* file; + const unsigned int line; + }; + +} #endif /*SUPERTUX_EXCEPTIONS_H*/ Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- lispreader.cpp 20 Jul 2004 17:51:38 -0000 1.1 +++ lispreader.cpp 21 Jul 2004 16:51:53 -0000 1.2 @@ -31,6 +31,8 @@ #include "app/setup.h" #include "utils/lispreader.h" +using namespace SuperTux; + #define TOKEN_ERROR -1 #define TOKEN_EOF 0 #define TOKEN_OPEN_PAREN 1 @@ -285,7 +287,7 @@ } lisp_stream_t* -lisp_stream_init_file (lisp_stream_t *stream, FILE *file) +SuperTux::lisp_stream_init_file (lisp_stream_t *stream, FILE *file) { stream->type = LISP_STREAM_FILE; stream->v.file = file; @@ -294,7 +296,7 @@ } lisp_stream_t* -lisp_stream_init_string (lisp_stream_t *stream, char *buf) +SuperTux::lisp_stream_init_string (lisp_stream_t *stream, char *buf) { stream->type = LISP_STREAM_STRING; stream->v.string.buf = buf; @@ -304,7 +306,7 @@ } lisp_stream_t* -lisp_stream_init_any (lisp_stream_t *stream, void *data, +SuperTux::lisp_stream_init_any (lisp_stream_t *stream, void *data, int (*next_char) (void *data), void (*unget_char) (char c, void *data)) { @@ -320,7 +322,7 @@ } lisp_object_t* -lisp_make_integer (int value) +SuperTux::lisp_make_integer (int value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_INTEGER); @@ -330,7 +332,7 @@ } lisp_object_t* -lisp_make_real (float value) +SuperTux::lisp_make_real (float value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_REAL); @@ -340,7 +342,7 @@ } lisp_object_t* -lisp_make_symbol (const char *value) +SuperTux::lisp_make_symbol (const char *value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_SYMBOL); @@ -350,7 +352,7 @@ } lisp_object_t* -lisp_make_string (const char *value) +SuperTux::lisp_make_string (const char *value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_STRING); @@ -360,7 +362,7 @@ } lisp_object_t* -lisp_make_cons (lisp_object_t *car, lisp_object_t *cdr) +SuperTux::lisp_make_cons (lisp_object_t *car, lisp_object_t *cdr) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_CONS); @@ -371,7 +373,7 @@ } lisp_object_t* -lisp_make_boolean (int value) +SuperTux::lisp_make_boolean (int value) { lisp_object_t *obj = lisp_object_alloc(LISP_TYPE_BOOLEAN); @@ -404,7 +406,7 @@ } lisp_object_t* -lisp_read (lisp_stream_t *in) +SuperTux::lisp_read (lisp_stream_t *in) { int token = _scan(in); lisp_object_t *obj = lisp_nil(); @@ -502,7 +504,7 @@ } void -lisp_free (lisp_object_t *obj) +SuperTux::lisp_free (lisp_object_t *obj) { if (obj == 0) return; @@ -547,7 +549,7 @@ } lisp_object_t* -lisp_read_from_string (const char *buf) +SuperTux::lisp_read_from_string (const char *buf) { lisp_stream_t stream; @@ -642,7 +644,7 @@ } int -lisp_compile_pattern (lisp_object_t **obj, int *num_subs) +SuperTux::lisp_compile_pattern (lisp_object_t **obj, int *num_subs) { int index = 0; int result; @@ -775,7 +777,7 @@ } int -lisp_match_pattern (lisp_object_t *pattern, lisp_object_t *obj, lisp_object_t **vars, int num_subs) +SuperTux::lisp_match_pattern (lisp_object_t *pattern, lisp_object_t *obj, lisp_object_t **vars, int num_subs) { int i; @@ -787,7 +789,7 @@ } int -lisp_match_string (const char *pattern_string, lisp_object_t *obj, lisp_object_t **vars) +SuperTux::lisp_match_string (const char *pattern_string, lisp_object_t *obj, lisp_object_t **vars) { lisp_object_t *pattern; int result; @@ -813,7 +815,7 @@ } int -lisp_type (lisp_object_t *obj) +SuperTux::lisp_type (lisp_object_t *obj) { if (obj == 0) return LISP_TYPE_NIL; @@ -821,7 +823,7 @@ } int -lisp_integer (lisp_object_t *obj) +SuperTux::lisp_integer (lisp_object_t *obj) { if (obj->type != LISP_TYPE_INTEGER) throw LispReaderException("lisp_integer()", __FILE__, __LINE__); @@ -830,7 +832,7 @@ } char* -lisp_symbol (lisp_object_t *obj) +SuperTux::lisp_symbol (lisp_object_t *obj) { if (obj->type != LISP_TYPE_SYMBOL) throw LispReaderException("lisp_symbol()", __FILE__, __LINE__); @@ -839,7 +841,7 @@ } char* -lisp_string (lisp_object_t *obj) +SuperTux::lisp_string (lisp_object_t *obj) { if (obj->type != LISP_TYPE_STRING) throw LispReaderException("lisp_string()", __FILE__, __LINE__); @@ -848,7 +850,7 @@ } int -lisp_boolean (lisp_object_t *obj) +SuperTux::lisp_boolean (lisp_object_t *obj) { if (obj->type != LISP_TYPE_BOOLEAN) throw LispReaderException("lisp_boolean()", __FILE__, __LINE__); @@ -857,7 +859,7 @@ } float -lisp_real (lisp_object_t *obj) +SuperTux::lisp_real (lisp_object_t *obj) { if (obj->type != LISP_TYPE_REAL && obj->type != LISP_TYPE_INTEGER) throw LispReaderException("lisp_real()", __FILE__, __LINE__); @@ -868,7 +870,7 @@ } lisp_object_t* -lisp_car (lisp_object_t *obj) +SuperTux::lisp_car (lisp_object_t *obj) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) throw LispReaderException("lisp_car()", __FILE__, __LINE__); @@ -877,7 +879,7 @@ } lisp_object_t* -lisp_cdr (lisp_object_t *obj) +SuperTux::lisp_cdr (lisp_object_t *obj) { if (obj->type != LISP_TYPE_CONS && obj->type != LISP_TYPE_PATTERN_CONS) throw LispReaderException("lisp_cdr()", __FILE__, __LINE__); @@ -886,7 +888,7 @@ } lisp_object_t* -lisp_cxr (lisp_object_t *obj, const char *x) +SuperTux::lisp_cxr (lisp_object_t *obj, const char *x) { int i; @@ -902,7 +904,7 @@ } int -lisp_list_length (lisp_object_t *obj) +SuperTux::lisp_list_length (lisp_object_t *obj) { int length = 0; @@ -919,7 +921,7 @@ } lisp_object_t* -lisp_list_nth_cdr (lisp_object_t *obj, int index) +SuperTux::lisp_list_nth_cdr (lisp_object_t *obj, int index) { while (index > 0) { @@ -936,7 +938,7 @@ } lisp_object_t* -lisp_list_nth (lisp_object_t *obj, int index) +SuperTux::lisp_list_nth (lisp_object_t *obj, int index) { obj = lisp_list_nth_cdr(obj, index); @@ -947,7 +949,7 @@ } void -lisp_dump (lisp_object_t *obj, FILE *out) +SuperTux::lisp_dump (lisp_object_t *obj, FILE *out) { if (obj == 0) { @@ -1275,7 +1277,7 @@ return lst; } -lisp_object_t* lisp_read_from_file(const std::string& filename) +lisp_object_t* SuperTux::lisp_read_from_file(const std::string& filename) { FILE* in = fopen(filename.c_str(), "r"); |
From: Tobias G. <to...@us...> - 2004-07-21 16:52:01
|
Update of /cvsroot/super-tux/supertux/lib/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32238/lib/math Modified Files: physic.cpp physic.h vector.cpp vector.h Log Message: The SuperTux library features a SuperTux namespace now. + minor Bugfixes and cleanups Index: vector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/vector.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- vector.cpp 20 Jul 2004 17:51:36 -0000 1.1 +++ vector.cpp 21 Jul 2004 16:51:52 -0000 1.2 @@ -21,6 +21,8 @@ #include "math/vector.h" +using namespace SuperTux; + Vector Vector::unit() const { return *this / norm(); Index: vector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/vector.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- vector.h 20 Jul 2004 20:21:16 -0000 1.2 +++ vector.h 21 Jul 2004 16:51:52 -0000 1.3 @@ -20,79 +20,84 @@ #ifndef SUPERTUX_VECTOR_H #define SUPERTUX_VECTOR_H -/// 2D Vector. -/** Simple two dimensional vector. */ -class Vector -{ -public: - Vector(float nx, float ny) - : x(nx), y(ny) - { } - Vector(const Vector& other) - : x(other.x), y(other.y) - { } - Vector() - : x(0), y(0) - { } - - bool operator ==(const Vector& other) const +namespace SuperTux { - return x == other.x && y == other.y; - } - const Vector& operator=(const Vector& other) - { - x = other.x; - y = other.y; - return *this; - } + /// 2D Vector. + /** Simple two dimensional vector. */ + class Vector + { + public: + Vector(float nx, float ny) + : x(nx), y(ny) + { } + Vector(const Vector& other) + : x(other.x), y(other.y) + { } + Vector() + : x(0), y(0) + { } - Vector operator+(const Vector& other) const - { - return Vector(x + other.x, y + other.y); - } + bool operator ==(const Vector& other) const + { + return x == other.x && y == other.y; + } - Vector operator-(const Vector& other) const - { - return Vector(x - other.x, y - other.y); - } + const Vector& operator=(const Vector& other) + { + x = other.x; + y = other.y; + return *this; + } - Vector operator*(float s) const - { - return Vector(x * s, y * s); - } + Vector operator+(const Vector& other) const + { + return Vector(x + other.x, y + other.y); + } - Vector operator/(float s) const - { - return Vector(x / s, y / s); - } + Vector operator-(const Vector& other) const + { + return Vector(x - other.x, y - other.y); + } - Vector operator-() const - { - return Vector(-x, -y); - } + Vector operator*(float s) const + { + return Vector(x * s, y * s); + } - const Vector& operator +=(const Vector& other) - { - x += other.x; - y += other.y; - return *this; - } + Vector operator/(float s) const + { + return Vector(x / s, y / s); + } - /// Scalar product of 2 vectors - float operator*(const Vector& other) const - { - return x*other.x + y*other.y; - } + Vector operator-() const + { + return Vector(-x, -y); + } - float norm() const; - Vector unit() const; + const Vector& operator +=(const Vector& other) + { + x += other.x; + y += other.y; + return *this; + } - // ... add the other operators as needed, I'm too lazy now ... + /// Scalar product of 2 vectors + float operator*(const Vector& other) const + { + return x*other.x + y*other.y; + } - float x, y; // leave this public, get/set methods just give me headaches - // for such simple stuff :) -}; + float norm() const; + Vector unit() const; + + // ... add the other operators as needed, I'm too lazy now ... + + float x, y; // leave this public, get/set methods just give me headaches + // for such simple stuff :) + }; + +} //namespace SuperTux #endif /*SUPERTUX_VECTOR_H*/ Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/physic.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- physic.cpp 20 Jul 2004 22:55:50 -0000 1.2 +++ physic.cpp 21 Jul 2004 16:51:51 -0000 1.3 @@ -23,6 +23,8 @@ #include "math/physic.h" #include "special/timer.h" +using namespace SuperTux; + Physic::Physic() : ax(0), ay(0), vx(0), vy(0), gravity_enabled(true) { Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/physic.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- physic.h 20 Jul 2004 22:55:50 -0000 1.3 +++ physic.h 21 Jul 2004 16:51:52 -0000 1.4 @@ -23,60 +23,65 @@ #include "math/vector.h" -/// Physics engine. -/** This is a very simplistic physics engine handling accelerated and constant - * movement along with gravity. - */ -class Physic -{ -public: - Physic(); - ~Physic(); +namespace SuperTux + { - /// Resets all velocities and accelerations to 0. - void reset(); + /// Physics engine. + /** This is a very simplistic physics engine handling accelerated and constant + * movement along with gravity. + */ + class Physic + { + public: + Physic(); + ~Physic(); - /// Sets velocity to a fixed value. - void set_velocity(float vx, float vy); + /// Resets all velocities and accelerations to 0. + void reset(); - void set_velocity_x(float vx); - void set_velocity_y(float vy); + /// Sets velocity to a fixed value. + void set_velocity(float vx, float vy); - /// Velocities invertion. - void inverse_velocity_x(); - void inverse_velocity_y(); + void set_velocity_x(float vx); + void set_velocity_y(float vy); - float get_velocity_x(); - float get_velocity_y(); - - /// Set acceleration. - /** Sets acceleration applied to the object. (Note that gravity is - * eventually added to the vertical acceleration) - */ - void set_acceleration(float ax, float ay); + /// Velocities invertion. + void inverse_velocity_x(); + void inverse_velocity_y(); - void set_acceleration_x(float ax); - void set_acceleration_y(float ay); + float get_velocity_x(); + float get_velocity_y(); - float get_acceleration_x(); - float get_acceleration_y(); + /// Set acceleration. + /** Sets acceleration applied to the object. (Note that gravity is + * eventually added to the vertical acceleration) + */ + void set_acceleration(float ax, float ay); - /// Enables or disables handling of gravity. - void enable_gravity(bool gravity_enabled); + void set_acceleration_x(float ax); + void set_acceleration_y(float ay); - /// Applies the physical simulation to given x and y coordinates. - void apply(float frame_ratio, float &x, float &y, float gravity = 10.0f); + float get_acceleration_x(); + float get_acceleration_y(); - /// applies the physical simulation to given x and y coordinates. - void apply(Vector& vector, float frame_ratio, float gravity = 10.0f); + /// Enables or disables handling of gravity. + void enable_gravity(bool gravity_enabled); -private: - /// horizontal and vertical acceleration - float ax, ay; - /// horizontal and vertical velocity - float vx, vy; - /// should we respect gravity in out calculations? - bool gravity_enabled; -}; + /// Applies the physical simulation to given x and y coordinates. + void apply(float frame_ratio, float &x, float &y, float gravity = 10.0f); + + /// applies the physical simulation to given x and y coordinates. + void apply(Vector& vector, float frame_ratio, float gravity = 10.0f); + + private: + /// horizontal and vertical acceleration + float ax, ay; + /// horizontal and vertical velocity + float vx, vy; + /// should we respect gravity in out calculations? + bool gravity_enabled; + }; + +} //namespace SuperTux #endif /*SUPERTUX_PHYSIC_H*/ |
From: Tobias G. <to...@us...> - 2004-07-21 16:52:01
|
Update of /cvsroot/super-tux/supertux/lib/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32238/lib/gui Modified Files: button.h menu.cpp menu.h mousecursor.cpp mousecursor.h Log Message: The SuperTux library features a SuperTux namespace now. + minor Bugfixes and cleanups Index: mousecursor.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/mousecursor.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mousecursor.h 20 Jul 2004 19:41:29 -0000 1.2 +++ mousecursor.h 21 Jul 2004 16:51:51 -0000 1.3 @@ -25,54 +25,62 @@ #include "special/timer.h" #include "video/surface.h" -#define MC_FRAME_PERIOD 800 // in ms +namespace SuperTux + { -#define MC_STATES_NB 3 -enum { - MC_NORMAL, - MC_CLICK, - MC_LINK, - MC_HIDE -}; + #define MC_FRAME_PERIOD 800 // in ms -/// Mouse cursor. -/** Used to create mouse cursors. - The mouse cursors can be animated - and can be used in four different states. - (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ -class MouseCursor -{ -public: - /// Constructor of MouseCursor. - /** Expects an imagefile for the cursor and the number of animation frames it contains. */ - MouseCursor(std::string cursor_file, int frames); - ~MouseCursor(); - /// Get MouseCursor state. - /** (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ - int state(); - /// Set MouseCursor state. - /** (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ - void set_state(int nstate); - /// Define the middle of a MouseCursor. - /** Useful for cross mouse cursor images in example. */ - void set_mid(int x, int y); - - /// Draw MouseCursor on screen. - void draw(DrawingContext& context); - - /// Return the current cursor. - static MouseCursor* current() { return current_; }; - /// Set current cursor. - static void set_current(MouseCursor* pcursor) { current_ = pcursor; }; - -private: - int mid_x, mid_y; - static MouseCursor* current_; - int state_before_click; - int cur_state; - int cur_frame, tot_frames; - Surface* cursor; - Timer timer; -}; + #define MC_STATES_NB 3 + + enum { + MC_NORMAL, + MC_CLICK, + MC_LINK, + MC_HIDE + }; + + /// Mouse cursor. + /** Used to create mouse cursors. + The mouse cursors can be animated + and can be used in four different states. + (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ + class MouseCursor + { + public: + /// Constructor of MouseCursor. + /** Expects an imagefile for the cursor and the number of animation frames it contains. */ + MouseCursor(std::string cursor_file, int frames); + ~MouseCursor(); + /// Get MouseCursor state. + /** (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ + int state(); + /// Set MouseCursor state. + /** (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ + void set_state(int nstate); + /// Define the middle of a MouseCursor. + /** Useful for cross mouse cursor images in example. */ + void set_mid(int x, int y); + + /// Draw MouseCursor on screen. + void draw(DrawingContext& context); + + /// Return the current cursor. + static MouseCursor* current() + { return current_; }; + /// Set current cursor. + static void set_current(MouseCursor* pcursor) + { current_ = pcursor; }; + + private: + int mid_x, mid_y; + static MouseCursor* current_; + int state_before_click; + int cur_state; + int cur_frame, tot_frames; + Surface* cursor; + Timer timer; + }; + +} // namespace SuperTux #endif /*SUPERTUX_MOUSECURSOR_H*/ Index: mousecursor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/mousecursor.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mousecursor.cpp 20 Jul 2004 17:51:35 -0000 1.1 +++ mousecursor.cpp 21 Jul 2004 16:51:51 -0000 1.2 @@ -20,6 +20,8 @@ #include "video/drawing_context.h" #include "gui/mousecursor.h" +using namespace SuperTux; + MouseCursor* MouseCursor::current_ = 0; MouseCursor::MouseCursor(std::string cursor_file, int frames) : mid_x(0), mid_y(0) Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/menu.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- menu.cpp 20 Jul 2004 17:51:35 -0000 1.1 +++ menu.cpp 21 Jul 2004 16:51:51 -0000 1.2 @@ -37,31 +37,23 @@ #include "audio/sound.h" #include "special/timer.h" #include "app/gettext.h" +#include "math/vector.h" -#define FLICK_CURSOR_TIME 500 +using namespace SuperTux; -Surface* checkbox; -Surface* checkbox_checked; -Surface* back; -Surface* arrow_left; -Surface* arrow_right; +#define FLICK_CURSOR_TIME 500 -Menu* main_menu = 0; -Menu* game_menu = 0; -Menu* options_menu = 0; -Menu* options_keys_menu = 0; -Menu* options_joystick_menu = 0; -Menu* highscore_menu = 0; -Menu* load_game_menu = 0; -Menu* save_game_menu = 0; -Menu* contrib_menu = 0; -Menu* contrib_subset_menu = 0; +Surface* SuperTux::checkbox; +Surface* SuperTux::checkbox_checked; +Surface* SuperTux::back; +Surface* SuperTux::arrow_left; +Surface* SuperTux::arrow_right; std::vector<Menu*> Menu::last_menus; Menu* Menu::current_ = 0; /* just displays a Yes/No text that can be used to confirm stuff */ -bool confirm_dialog(Surface *background, std::string text) +bool SuperTux::confirm_dialog(Surface *background, std::string text) { //Surface* cap_screen = Surface::CaptureScreen(); Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/menu.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- menu.h 20 Jul 2004 17:51:35 -0000 1.1 +++ menu.h 21 Jul 2004 16:51:51 -0000 1.2 @@ -30,162 +30,161 @@ #include "special/stringlist.h" #include "gui/mousecursor.h" +namespace SuperTux + { -/* Joystick menu delay */ + /* Joystick menu delay */ #define JOYSTICK_MENU_DELAY 500 -/* IDs for menus */ + /* IDs for menus */ -bool confirm_dialog(Surface* background, std::string text); + bool confirm_dialog(Surface* background, std::string text); -/* Kinds of menu items */ -enum MenuItemKind { - MN_ACTION, - MN_GOTO, - MN_TOGGLE, - MN_BACK, - MN_DEACTIVE, - MN_TEXTFIELD, - MN_NUMFIELD, - MN_CONTROLFIELD_KB, - MN_CONTROLFIELD_JS, - MN_STRINGSELECT, - MN_LABEL, - MN_HL, /* horizontal line */ -}; + /* Kinds of menu items */ + enum MenuItemKind { + MN_ACTION, + MN_GOTO, + MN_TOGGLE, + MN_BACK, + MN_DEACTIVE, + MN_TEXTFIELD, + MN_NUMFIELD, + MN_CONTROLFIELD_KB, + MN_CONTROLFIELD_JS, + MN_STRINGSELECT, + MN_LABEL, + MN_HL, /* horizontal line */ + }; -class Menu; + class Menu; -class MenuItem -{ -public: - MenuItemKind kind; - int toggled; - char *text; - char *input; - int *int_p; // used for setting keys (can be used for more stuff...) - int id; // item id - string_list_type* list; - Menu* target_menu; + class MenuItem + { + public: + MenuItemKind kind; + int toggled; + char *text; + char *input; + int *int_p; // used for setting keys (can be used for more stuff...) + int id; // item id + string_list_type* list; + Menu* target_menu; - void change_text (const char *text); - void change_input(const char *text); + void change_text (const char *text); + void change_input(const char *text); - static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int id, int* int_p); + static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int id, int* int_p); - std::string get_input_with_symbol(bool active_item); // returns the text with an input symbol -private: - bool input_flickering; - Timer input_flickering_timer; -}; + std::string get_input_with_symbol(bool active_item); // returns the text with an input symbol + private: + bool input_flickering; + Timer input_flickering_timer; + }; -class Menu -{ -private: - static std::vector<Menu*> last_menus; - static Menu* current_; + class Menu + { + private: + static std::vector<Menu*> last_menus; + static Menu* current_; - static void push_current(Menu* pmenu); - static void pop_current(); + static void push_current(Menu* pmenu); + static void pop_current(); -public: - /** Set the current menu, if pmenu is NULL, hide the current menu */ - static void set_current(Menu* pmenu); + public: + /** Set the current menu, if pmenu is NULL, hide the current menu */ + static void set_current(Menu* pmenu); - /** Return the current active menu or NULL if none is active */ - static Menu* current() { return current_; } + /** Return the current active menu or NULL if none is active */ + static Menu* current() + { + return current_; + } -private: - /* Action done on the menu */ - enum MenuAction { - MENU_ACTION_NONE = -1, - MENU_ACTION_UP, - MENU_ACTION_DOWN, - MENU_ACTION_LEFT, - MENU_ACTION_RIGHT, - MENU_ACTION_HIT, - MENU_ACTION_INPUT, - MENU_ACTION_REMOVE - }; + private: + /* Action done on the menu */ + enum MenuAction { + MENU_ACTION_NONE = -1, + MENU_ACTION_UP, + MENU_ACTION_DOWN, + MENU_ACTION_LEFT, + MENU_ACTION_RIGHT, + MENU_ACTION_HIT, + MENU_ACTION_INPUT, + MENU_ACTION_REMOVE + }; - /** Number of the item that got 'hit' (ie. pressed) in the last - event()/action() call, -1 if none */ - int hit_item; + /** Number of the item that got 'hit' (ie. pressed) in the last + event()/action() call, -1 if none */ + int hit_item; - // position of the menu (ie. center of the menu, not top/left) - int pos_x; - int pos_y; + // position of the menu (ie. center of the menu, not top/left) + int pos_x; + int pos_y; - /** input event for the menu (up, down, left, right, etc.) */ - MenuAction menuaction; + /** input event for the menu (up, down, left, right, etc.) */ + MenuAction menuaction; - /* input implementation variables */ - int delete_character; - char mn_input_char; - Timer joystick_timer; - -public: - Timer effect; - int arrange_left; - int active_item; + /* input implementation variables */ + int delete_character; + char mn_input_char; + Timer joystick_timer; - std::vector<MenuItem> item; + public: + Timer effect; + int arrange_left; + int active_item; - Menu(); - ~Menu(); + std::vector<MenuItem> item; - void additem(MenuItem* pmenu_item); - void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int id = -1, int *int_p = NULL); - - void action (); - - /** Remove all entries from the menu */ - void clear(); + Menu(); + ~Menu(); - /** Return the index of the menu item that was 'hit' (ie. the user - clicked on it) in the last event() call */ - int check (); + void additem(MenuItem* pmenu_item); + void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int id = -1, int *int_p = NULL); - MenuItem& get_item(int index) { return item[index]; } - MenuItem& get_item_by_id(int id); + void action (); - int get_active_item_id(); + /** Remove all entries from the menu */ + void clear(); - bool isToggled(int id); + /** Return the index of the menu item that was 'hit' (ie. the user + clicked on it) in the last event() call */ + int check (); - void Menu::get_controlfield_key_into_input(MenuItem *item); - void Menu::get_controlfield_js_into_input(MenuItem *item); + MenuItem& get_item(int index) + { + return item[index]; + } + MenuItem& get_item_by_id(int id); - void draw(DrawingContext& context); - void draw_item(DrawingContext& context, - int index, int menu_width, int menu_height); - void set_pos(int x, int y, float rw = 0, float rh = 0); + int get_active_item_id(); - /** translate a SDL_Event into a menu_action */ - void event(SDL_Event& event); + bool isToggled(int id); - int get_width() const; - int get_height() const; + void Menu::get_controlfield_key_into_input(MenuItem *item); + void Menu::get_controlfield_js_into_input(MenuItem *item); - bool is_toggled(int id) const; -}; + void draw(DrawingContext& context); + void draw_item(DrawingContext& context, + int index, int menu_width, int menu_height); + void set_pos(int x, int y, float rw = 0, float rh = 0); -extern Surface* checkbox; -extern Surface* checkbox_checked; -extern Surface* back; -extern Surface* arrow_left; -extern Surface* arrow_right; + /** translate a SDL_Event into a menu_action */ + void event(SDL_Event& event); -extern Menu* contrib_menu; -extern Menu* contrib_subset_menu; -extern Menu* main_menu; -extern Menu* game_menu; -extern Menu* options_menu; -extern Menu* options_keys_menu; -extern Menu* options_joystick_menu; -extern Menu* highscore_menu; -extern Menu* load_game_menu; -extern Menu* save_game_menu; + int get_width() const; + int get_height() const; + + bool is_toggled(int id) const; + }; + + extern Surface* checkbox; + extern Surface* checkbox_checked; + extern Surface* back; + extern Surface* arrow_left; + extern Surface* arrow_right; + +} //namespace SuperTux #endif /*SUPERTUX_MENU_H*/ Index: button.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/button.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- button.h 21 Jul 2004 11:56:48 -0000 1.2 +++ button.h 21 Jul 2004 16:51:51 -0000 1.3 @@ -114,7 +114,7 @@ /// Dispatch button events. Button* event(SDL_Event &event); /// Add a button to the panel. - /** @Param tag: Can be used to identify a button. */ + /** @param tag: Can be used to identify a button. */ void additem(Button* pbutton, int tag); /// Set the default size of contained buttons. void set_button_size(int w, int h); |
From: Tobias G. <to...@us...> - 2004-07-21 11:56:59
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8601/src Modified Files: leveleditor.h Log Message: Introduction of SuperTux namespace. Added comments to Button and ButtonPanel classes. Index: leveleditor.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- leveleditor.h 20 Jul 2004 18:04:48 -0000 1.16 +++ leveleditor.h 21 Jul 2004 11:56:48 -0000 1.17 @@ -32,6 +32,8 @@ #include "gui/button.h" #include "gui/menu.h" +using namespace SuperTux; + enum LevelEditorMainMenuIDs { MNID_RETURNLEVELEDITOR, MNID_SUBSETSETTINGS, |
From: Tobias G. <to...@us...> - 2004-07-21 11:56:59
|
Update of /cvsroot/super-tux/supertux/lib/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8601/lib/gui Modified Files: button.cpp button.h Log Message: Introduction of SuperTux namespace. Added comments to Button and ButtonPanel classes. Index: button.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/button.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- button.h 20 Jul 2004 17:51:35 -0000 1.1 +++ button.h 21 Jul 2004 11:56:48 -0000 1.2 @@ -26,73 +26,117 @@ #include "video/surface.h" #include "special/timer.h" -enum ButtonState { - BUTTON_NONE = -1, - BUTTON_CLICKED, - BUTTON_PRESSED, - BUTTON_HOVER, - BUTTON_WHEELUP, - BUTTON_WHEELDOWN, - BUTTON_DEACTIVE -}; +namespace SuperTux + { -class ButtonPanel; + /// Possible states of a button. + enum ButtonState { + BUTTON_NONE = -1, + BUTTON_CLICKED, + BUTTON_PRESSED, + BUTTON_HOVER, + BUTTON_WHEELUP, + BUTTON_WHEELDOWN, + BUTTON_DEACTIVE + }; -class Button -{ - friend class ButtonPanel; + class ButtonPanel; -public: - Button(Surface* icon_file, const std::string& info, SDLKey shortcut, - int x, int y, int mw = -1, int h = -1); - Button(const std::string& icon_name, const std::string& info, SDLKey shortcut, - int x, int y, int mw = -1, int h = -1); - - ~Button(); - void event(SDL_Event& event); - 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; } + /// Button + /** Buttons can be placed on the screen and used like any other + simple button known from desktop applications. */ + class Button + { + friend class ButtonPanel; -private: - static Timer popup_timer; -// Drawable* drawable; - std::vector<Surface*> icon; - std::string info; - SDLKey shortcut; - SDL_Rect rect; - bool show_info; - ButtonState state; - int tag; -}; + public: + /// Constructor + Button(Surface* button_image, const std::string& ninfo, + SDLKey nshortcut, int x, int y, int mw = -1, int mh = -1); + Button(const std::string& imagefilename, const std::string& ninfo, + SDLKey nshortcut, int x, int y, int mw = -1, int mh = -1); -class ButtonPanel -{ -public: - ButtonPanel(int x, int y, int w, int h); - ~ButtonPanel(); - void draw(DrawingContext& context); - Button* event(SDL_Event &event); - void additem(Button* pbutton, int tag); - Button* button_panel_event(SDL_Event& event); - void set_button_size(int w, int h); - Button* manipulate_button(int i); - void highlight_last(bool b); - void set_last_clicked(unsigned int last) - { if(hlast) { if(item.size() >= last) { last_clicked = item.begin() + last; } } }; + ~Button(); -private: - int bw, bh; - bool hlast; - bool hidden; - SDL_Rect rect; - std::vector<Button*> item; - std::vector<Button*>::iterator last_clicked; -}; + /// Apply SDL_Event on button. + void event(SDL_Event& event); + /// Draw button. + void draw(DrawingContext& context); + /// Get button state. + int get_state(); + /// Activate/Deactivate button. + void set_active(bool active) + { active ? state = BUTTON_NONE : state = BUTTON_DEACTIVE; }; + /// Add an icon + /** The last added icon is the last one, which gets drawn. */ + void add_icon(const std::string& imagefile, int mw, int mh); + /// Get position of the button on screen. + /** Returns a SDL_Rect. */ + SDL_Rect get_pos() + { return rect; } + /// Get tag of the button + /** Useable for button identification etc. */ + int get_tag() + { return tag; } + // void set_drawable(Drawable* newdrawable) + // { drawable = newdrawable; } + + private: + static Timer popup_timer; + // Drawable* drawable; + std::vector<Surface*> icon; + std::string info; + SDLKey shortcut; + SDL_Rect rect; + bool show_info; + ButtonState state; + int tag; + }; + + /// Panel of buttons + /** A ButtonPanel manages buttons inside + its scope. It also dispatches events + and draws the buttons it contains. */ + class ButtonPanel + { + public: + /// Constructor. + /** Expects X,Y coordinates and the width and height values + of the ButtonPanel. */ + ButtonPanel(int x, int y, int w, int h); + /// Constructor. + /** SDL_Rect version of above. */ + ButtonPanel(const SDL_Rect& rect); + + ~ButtonPanel(); + /// Draw the panel and its buttons. + void draw(DrawingContext& context); + /// Dispatch button events. + Button* event(SDL_Event &event); + /// Add a button to the panel. + /** @Param tag: Can be used to identify a button. */ + void additem(Button* pbutton, int tag); + /// Set the default size of contained buttons. + void set_button_size(int w, int h); + /// Manipulate a button. + Button* manipulate_button(int i); + /// Set if the last clicked/used item, should be drawn highlighted. + void highlight_last(bool b); + /// Set the last clicked/used button. + /** Set which button is internally the last clicked/used and + therefore drawn highlighted in case button highlighting + is enabled for the ButtonPanel. */ + void set_last_clicked(unsigned int last); + + private: + int bw, bh; + bool hlast; + bool hidden; + SDL_Rect rect; + std::vector<Button*> item; + std::vector<Button*>::iterator last_clicked; + }; + +} // namespace SuperTux #endif /*SUPERTUX_BUTTON_H*/ Index: button.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/button.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- button.cpp 20 Jul 2004 17:51:35 -0000 1.1 +++ button.cpp 21 Jul 2004 11:56:48 -0000 1.2 @@ -27,10 +27,12 @@ #include "app/globals.h" #include "gui/button.h" +using namespace SuperTux; + Timer Button::popup_timer; Button::Button(Surface* button_image, const std::string& ninfo, - SDLKey nshortcut, int x, int y, int mw, int mh) + SDLKey nshortcut, int x, int y, int mw, int mh) { popup_timer.init(false); @@ -51,12 +53,12 @@ } Button::Button(const std::string& imagefilename, const std::string& ninfo, - SDLKey nshortcut, int x, int y, int mw, int mh) + SDLKey nshortcut, int x, int y, int mw, int mh) { popup_timer.init(false); add_icon(imagefilename, mw, mh); - + info = ninfo; shortcut = nshortcut; @@ -75,21 +77,21 @@ char filename[1024]; if(!icon_file.empty()) - { - snprintf(filename, 1024, "%s/%s", datadir.c_str(), icon_file.c_str()); - if(!faccessible(filename)) - snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str()); - } + { + snprintf(filename, 1024, "%s/%s", datadir.c_str(), icon_file.c_str()); + if(!faccessible(filename)) + snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str()); + } else - { - snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str()); - } + { + snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str()); + } if(mw != -1 || mh != -1) - { - icon.push_back(new Surface(filename,true)); - icon.back()->resize(mw,mh); - } + { + icon.push_back(new Surface(filename,true)); + icon.back()->resize(mw,mh); + } else icon.push_back(new Surface(filename,true)); @@ -107,26 +109,26 @@ for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it) context.draw_surface(*it, Vector(rect.x,rect.y), LAYER_GUI); -/* if(drawable) - { - Camera viewport; - viewport.set_translation(Vector(rect.x, rect.y)); - drawable->draw(viewport, 0); - }*/ + /* if(drawable) + { + Camera viewport; + viewport.set_translation(Vector(rect.x, rect.y)); + drawable->draw(viewport, 0); + }*/ if(show_info) - { - char str[80]; - int i = -32; + { + char str[80]; + int i = -32; - if(0 > rect.x - white_small_text->get_text_width(info)) - i = rect.w + (int)white_small_text->get_text_width(info); + if(0 > rect.x - white_small_text->get_text_width(info)) + i = rect.w + (int)white_small_text->get_text_width(info); - if(!info.empty()) - context.draw_text(white_small_text, info, Vector(i + rect.x - white_small_text->get_text_width(info), rect.y), LAYER_GUI); - sprintf(str,"(%s)", SDL_GetKeyName(shortcut)); - context.draw_text(white_small_text, str, Vector(i + rect.x - white_small_text->get_text_width(str), rect.y + white_small_text->get_height()+2), LAYER_GUI); - } + if(!info.empty()) + context.draw_text(white_small_text, info, Vector(i + rect.x - white_small_text->get_text_width(info), rect.y), LAYER_GUI); + sprintf(str,"(%s)", SDL_GetKeyName(shortcut)); + context.draw_text(white_small_text, str, Vector(i + rect.x - white_small_text->get_text_width(str), rect.y + white_small_text->get_height()+2), LAYER_GUI); + } if(state == BUTTON_PRESSED || state == BUTTON_DEACTIVE) fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200); else if(state == BUTTON_HOVER) @@ -151,77 +153,82 @@ SDLKey key = event.key.keysym.sym; if(event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) - { - if(event.button.x < rect.x || event.button.x >= rect.x + rect.w || - event.button.y < rect.y || event.button.y >= rect.y + rect.h) - return; - - if(event.button.button == SDL_BUTTON_RIGHT) { - show_info = true; - return; - } - else if(event.type == SDL_MOUSEBUTTONUP && event.button.button == 4) /* Mouse wheel up. */ - { - state = BUTTON_WHEELUP; - return; - } - else if(event.type == SDL_MOUSEBUTTONUP && event.button.button == 5) /* Mouse wheel down. */ - { - state = BUTTON_WHEELDOWN; - return; - } + if(event.button.x < rect.x || event.button.x >= rect.x + rect.w || + event.button.y < rect.y || event.button.y >= rect.y + rect.h) + return; - if(event.button.button == SDL_BUTTON_LEFT) - if(event.type == SDL_MOUSEBUTTONDOWN) - state = BUTTON_PRESSED; - else - state = BUTTON_CLICKED; - } + if(event.button.button == SDL_BUTTON_RIGHT) + { + show_info = true; + return; + } + else if(event.type == SDL_MOUSEBUTTONUP && event.button.button == 4) /* Mouse wheel up. */ + { + state = BUTTON_WHEELUP; + return; + } + else if(event.type == SDL_MOUSEBUTTONUP && event.button.button == 5) /* Mouse wheel down. */ + { + state = BUTTON_WHEELDOWN; + return; + } + + if(event.button.button == SDL_BUTTON_LEFT) + if(event.type == SDL_MOUSEBUTTONDOWN) + state = BUTTON_PRESSED; + else + state = BUTTON_CLICKED; + } else if(event.type == SDL_MOUSEMOTION) - { - if(event.motion.x < rect.x || event.motion.x >= rect.x + rect.w || - event.motion.y < rect.y || event.motion.y >= rect.y + rect.h) { - state = BUTTON_NONE; + if(event.motion.x < rect.x || event.motion.x >= rect.x + rect.w || + event.motion.y < rect.y || event.motion.y >= rect.y + rect.h) + { + state = BUTTON_NONE; + } + else + { + state = BUTTON_HOVER; + popup_timer.start(1500); + } + + if(show_info) + { + show_info = false; + } } - else + else if(event.type == SDL_KEYDOWN) { - state = BUTTON_HOVER; - popup_timer.start(1500); + if(key == shortcut) + state = BUTTON_PRESSED; } - - if(show_info) + else if(event.type == SDL_KEYUP) { - show_info = false; + if(state == BUTTON_PRESSED && key == shortcut) + state = BUTTON_CLICKED; } - } - else if(event.type == SDL_KEYDOWN) - { - if(key == shortcut) - state = BUTTON_PRESSED; - } - else if(event.type == SDL_KEYUP) - { - if(state == BUTTON_PRESSED && key == shortcut) - state = BUTTON_CLICKED; - } } int Button::get_state() { int rstate; switch(state) - { - case BUTTON_CLICKED: - case BUTTON_WHEELUP: - case BUTTON_WHEELDOWN: - rstate = state; - state = BUTTON_NONE; - return rstate; - default: - return state; - } + { + case BUTTON_CLICKED: + case BUTTON_WHEELUP: + case BUTTON_WHEELDOWN: + rstate = state; + state = BUTTON_NONE; + return rstate; + default: + return state; + } +} + +ButtonPanel::ButtonPanel(const SDL_Rect& rect) +{ + ButtonPanel(rect.x, rect.y, rect.w, rect.h); } ButtonPanel::ButtonPanel(int x, int y, int w, int h) @@ -239,32 +246,32 @@ Button* ButtonPanel::event(SDL_Event& event) { if(!hidden) - { - Button* ret = NULL; - for(std::vector<Button*>::iterator it = item.begin(); it != item.end(); ++it) { - (*it)->event(event); - if((*it)->state != BUTTON_NONE) - { - if(hlast && (*it)->state == BUTTON_CLICKED) - last_clicked = it; - ret = (*it); - } + Button* ret = NULL; + for(std::vector<Button*>::iterator it = item.begin(); it != item.end(); ++it) + { + (*it)->event(event); + if((*it)->state != BUTTON_NONE) + { + if(hlast && (*it)->state == BUTTON_CLICKED) + last_clicked = it; + ret = (*it); + } + } + return ret; } - return ret; - } else - { - return NULL; - } + { + return NULL; + } } ButtonPanel::~ButtonPanel() { for(std::vector<Button*>::iterator it = item.begin(); it != item.end(); ++it) - { - delete (*it); - } + { + delete (*it); + } item.clear(); } @@ -272,17 +279,17 @@ { if(hidden == false) - { - 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(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); - } + 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(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); + } + } } - } } void ButtonPanel::additem(Button* pbutton, int tag) @@ -322,3 +329,14 @@ { hlast = b; } + +void ButtonPanel::set_last_clicked(unsigned int last) +{ + if(hlast) + { + if(item.size() >= last) + { + last_clicked = item.begin() + last; + } + } +} |
From: Ryan F. <sik...@us...> - 2004-07-20 22:56:05
|
Update of /cvsroot/super-tux/supertux/lib/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23297/lib/math Modified Files: physic.h physic.cpp Log Message: - fixed compile error Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/physic.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- physic.h 20 Jul 2004 20:28:28 -0000 1.2 +++ physic.h 20 Jul 2004 22:55:50 -0000 1.3 @@ -65,10 +65,10 @@ void enable_gravity(bool gravity_enabled); /// Applies the physical simulation to given x and y coordinates. - void apply(float frame_ratio, float &x, float &y, float& gravity = 10); + void apply(float frame_ratio, float &x, float &y, float gravity = 10.0f); /// applies the physical simulation to given x and y coordinates. - void apply(Vector& vector, float frame_ratio, float& gravity = 10); + void apply(Vector& vector, float frame_ratio, float gravity = 10.0f); private: /// horizontal and vertical acceleration Index: physic.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/physic.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- physic.cpp 20 Jul 2004 17:51:36 -0000 1.1 +++ physic.cpp 20 Jul 2004 22:55:50 -0000 1.2 @@ -118,7 +118,7 @@ } void -Physic::apply(float elapsed_time, float &x, float &y, float& gravity) +Physic::apply(float elapsed_time, float &x, float &y, float gravity) { float grav; if(gravity_enabled) @@ -133,7 +133,7 @@ } void -Physic::apply(Vector& vector, float elapsed_time, float& gravity) +Physic::apply(Vector& vector, float elapsed_time, float gravity) { apply(elapsed_time, vector.x, vector.y, gravity); } |
From: Tobias G. <to...@us...> - 2004-07-20 20:33:22
|
Update of /cvsroot/super-tux/supertux/lib/audio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23997/lib/audio Modified Files: sound_manager.h Log Message: fixed type :) yeah, the really important commit today! :) Index: sound_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/sound_manager.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sound_manager.h 20 Jul 2004 20:18:18 -0000 1.2 +++ sound_manager.h 20 Jul 2004 20:33:14 -0000 1.3 @@ -67,7 +67,7 @@ /// Resource for music. /** Contains the raw music data and - informations for music reference + information for music reference counting. */ class MusicResource { |
From: Tobias G. <to...@us...> - 2004-07-20 20:28:42
|
Update of /cvsroot/super-tux/supertux/lib/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22933/lib/math Modified Files: physic.h Log Message: Improved comments. Index: physic.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/physic.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- physic.h 20 Jul 2004 17:51:36 -0000 1.1 +++ physic.h 20 Jul 2004 20:28:28 -0000 1.2 @@ -23,6 +23,7 @@ #include "math/vector.h" +/// Physics engine. /** This is a very simplistic physics engine handling accelerated and constant * movement along with gravity. */ @@ -32,23 +33,24 @@ Physic(); ~Physic(); - /** resets all velocities and accelerations to 0 */ + /// Resets all velocities and accelerations to 0. void reset(); - /** sets velocity to a fixed value */ + /// Sets velocity to a fixed value. void set_velocity(float vx, float vy); void set_velocity_x(float vx); void set_velocity_y(float vy); - /** velocities invertion */ + /// Velocities invertion. void inverse_velocity_x(); void inverse_velocity_y(); float get_velocity_x(); float get_velocity_y(); - /** sets acceleration applied to the object. (Note that gravity is + /// Set acceleration. + /** Sets acceleration applied to the object. (Note that gravity is * eventually added to the vertical acceleration) */ void set_acceleration(float ax, float ay); @@ -59,13 +61,13 @@ float get_acceleration_x(); float get_acceleration_y(); - /** enables or disables handling of gravity */ + /// Enables or disables handling of gravity. void enable_gravity(bool gravity_enabled); - /** applies the physical simulation to given x and y coordinates */ + /// Applies the physical simulation to given x and y coordinates. void apply(float frame_ratio, float &x, float &y, float& gravity = 10); - /** applies the physical simulation to given x and y coordinates */ + /// applies the physical simulation to given x and y coordinates. void apply(Vector& vector, float frame_ratio, float& gravity = 10); private: |
From: Tobias G. <to...@us...> - 2004-07-20 20:24:59
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22087/lib/special Modified Files: base.h Log Message: Added comment. Index: base.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/base.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- base.h 20 Jul 2004 17:51:37 -0000 1.1 +++ base.h 20 Jul 2004 20:24:47 -0000 1.2 @@ -25,8 +25,10 @@ #include "SDL.h" -/* 'Base' type for game objects */ - +/// 'Base' type for game objects. +/** Mainly for layered use in game objects. + Containts upper left X and Y coordinates of an + object along with its width and height. */ struct base_type { float x; |
From: Tobias G. <to...@us...> - 2004-07-20 20:21:24
|
Update of /cvsroot/super-tux/supertux/lib/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21383/lib/math Modified Files: vector.h Log Message: little comments improvements Index: vector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/math/vector.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- vector.h 20 Jul 2004 17:51:36 -0000 1.1 +++ vector.h 20 Jul 2004 20:21:16 -0000 1.2 @@ -20,6 +20,8 @@ #ifndef SUPERTUX_VECTOR_H #define SUPERTUX_VECTOR_H +/// 2D Vector. +/** Simple two dimensional vector. */ class Vector { public: @@ -77,7 +79,7 @@ return *this; } - // scalar product of 2 vectors + /// Scalar product of 2 vectors float operator*(const Vector& other) const { return x*other.x + y*other.y; |
From: Tobias G. <to...@us...> - 2004-07-20 20:18:27
|
Update of /cvsroot/super-tux/supertux/lib/audio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20820/lib/audio Modified Files: sound_manager.h Log Message: added comments Index: sound_manager.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/audio/sound_manager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sound_manager.h 20 Jul 2004 17:51:35 -0000 1.1 +++ sound_manager.h 20 Jul 2004 20:18:18 -0000 1.2 @@ -24,12 +24,12 @@ #include <map> #include "SDL_mixer.h" - #include "math/vector.h" class MusicRef; class MovingObject; +/// Sound manager /** This class handles all sounds that are played */ class SoundManager @@ -38,21 +38,37 @@ SoundManager(); ~SoundManager(); + /// Play sound. void play_sound(Mix_Chunk* sound); + /// Play sound relative to two Vectors. void play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2); + /// Play sound relative to a MovingObject and a Vector. void play_sound(Mix_Chunk* sound, const MovingObject* object, const Vector& pos); + /// Load music. + /** Is used to load the music for a MusicRef. */ MusicRef load_music(const std::string& file); + /// Test if a certain music file exists. bool exists_music(const std::string& filename); + /// Play music. + /** @Param loops: Defaults to -1, which means endless loops. */ void play_music(const MusicRef& music, int loops = -1); + + /// Halt music. void halt_music(); + /// Enable/Disable music. void enable_music(bool enable); private: // music part friend class MusicRef; + + /// Resource for music. + /** Contains the raw music data and + informations for music reference + counting. */ class MusicResource { public: |
From: Tobias G. <to...@us...> - 2004-07-20 20:05:42
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18214/lib/special Modified Files: timer.h Log Message: added comments Index: timer.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/timer.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- timer.h 20 Jul 2004 17:51:37 -0000 1.1 +++ timer.h 20 Jul 2004 20:05:34 -0000 1.2 @@ -23,12 +23,20 @@ extern unsigned int st_pause_ticks, st_pause_count; +/// Time a game is running. (Non-pause mode, etc.) unsigned int st_get_ticks(void); + void st_pause_ticks_init(void); void st_pause_ticks_start(void); void st_pause_ticks_stop(void); bool st_pause_ticks_started(void); +/// Timer +/** This class can be used as stop watch + for example. It's also possible to calculate + frames per seconds and things like that with it. + It's a general timing class, but it + can esspecially be used together with st_get_ticks(). */ class Timer { public: @@ -39,26 +47,35 @@ public: Timer(); + /// Initialize the timer. + /** @Param st_ticks: If true internally st_get_ticks() is used, else SDL_GetTicks() is used. */ void init(bool st_ticks); + + /// Start the timer with the given period (in ms). void start(unsigned int period); + + /// Stop the timer. void stop(); - /*====================================================================== - return: NO = the timer is not started - or it is over - YES = otherwise - ======================================================================*/ + /// Check if the timer is started and within its period. + /** If one of these requirements isn't the case the timer + is automatically reseted. */ int check(); + + /// Is the timer started? int started(); - /*====================================================================== - return: the time left (in millisecond) - note : the returned value can be negative - ======================================================================*/ + /// Get time left until the last timing period is finished. + /** The returned value can be negative. */ int get_left(); + /// Get the gone time, since last timer start. + /** The returned value can be negative. */ int get_gone(); + + /// Write the timer value to a file (For save games in example). void fwrite(FILE* fi); + /// Read a timer value from a file (From save games in example). void fread(FILE* fi); }; |
From: Tobias G. <to...@us...> - 2004-07-20 19:41:42
|
Update of /cvsroot/super-tux/supertux/lib/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12525/lib/gui Modified Files: mousecursor.h Log Message: added comments Index: mousecursor.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/mousecursor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mousecursor.h 20 Jul 2004 17:51:35 -0000 1.1 +++ mousecursor.h 20 Jul 2004 19:41:29 -0000 1.2 @@ -35,17 +35,34 @@ MC_HIDE }; +/// Mouse cursor. +/** Used to create mouse cursors. + The mouse cursors can be animated + and can be used in four different states. + (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ class MouseCursor { public: + /// Constructor of MouseCursor. + /** Expects an imagefile for the cursor and the number of animation frames it contains. */ MouseCursor(std::string cursor_file, int frames); ~MouseCursor(); + /// Get MouseCursor state. + /** (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ int state(); + /// Set MouseCursor state. + /** (MC_NORMAL, MC_CLICK, MC_LINK or MC_HIDE) */ void set_state(int nstate); + /// Define the middle of a MouseCursor. + /** Useful for cross mouse cursor images in example. */ void set_mid(int x, int y); + + /// Draw MouseCursor on screen. void draw(DrawingContext& context); + /// Return the current cursor. static MouseCursor* current() { return current_; }; + /// Set current cursor. static void set_current(MouseCursor* pcursor) { current_ = pcursor; }; private: |
From: Tobias G. <to...@us...> - 2004-07-20 18:07:39
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23278/src Modified Files: Makefile.am Log Message: and here comes the shrinked ;) Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/src/Makefile.am,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- Makefile.am 16 Jun 2004 00:40:41 -0000 1.37 +++ Makefile.am 20 Jul 2004 18:07:30 -0000 1.38 @@ -2,109 +2,18 @@ bin_PROGRAMS = supertux supertux_CXXFLAGS = -DLOCALEDIR=\"$(localedir)\" -supertux_LDADD = @LIBINTL@ +supertux_LDADD = $(top_builddir)/lib/libsupertux.la @LIBINTL@ -supertux_SOURCES = \ -screen/drawing_context.h \ -screen/drawing_context.cpp \ -screen/font.h \ -screen/font.cpp \ -screen/screen.h \ -screen/screen.cpp \ -screen/surface.cpp \ -screen/surface.h \ -lispwriter.h \ -lispwriter.cpp \ -badguy.cpp \ -badguy.h \ -bitmask.cpp \ -bitmask.h \ -button.cpp \ -button.h \ -camera.cpp \ -camera.h \ -collision.cpp \ -collision.h \ -configfile.cpp \ -configfile.h \ -door.cpp \ -door.h \ -intro.cpp \ -intro.h \ -defines.h \ -exceptions.h \ -gameloop.cpp \ -gameloop.h \ -gettext.h \ -globals.cpp \ -globals.h \ -high_scores.cpp \ -high_scores.h \ -interactive_object.cpp \ -interactive_object.h \ -level.cpp \ -level.h \ -level_subset.cpp \ -level_subset.h \ -leveleditor.cpp \ -leveleditor.h \ -lispreader.cpp \ -lispreader.h \ -menu.cpp \ -menu.h \ -mousecursor.cpp \ -mousecursor.h \ -musicref.cpp \ -musicref.h \ -particlesystem.cpp \ -particlesystem.h \ -physic.cpp \ -physic.h \ -player.cpp \ -player.h \ -scene.cpp \ -scene.h \ -setup.cpp \ -setup.h \ -sound.cpp \ -sound.h \ -sound_manager.h \ -sound_manager.cpp \ -special.cpp \ -special.h \ -sprite.h \ -sprite.cpp \ -sprite_manager.cpp \ -sprite_manager.h \ -supertux.cpp \ -timer.cpp \ -timer.h \ -title.cpp \ -title.h \ -type.cpp \ -type.h \ -worldmap.cpp \ -worldmap.h \ -tile.h \ -tile.cpp \ -tile_manager.h \ -tile_manager.cpp \ -resources.h \ -resources.cpp \ -gameobjs.h \ -gameobjs.cpp \ -game_object.cpp \ -game_object.h \ -background.h \ -background.cpp \ -tilemap.h \ -tilemap.cpp \ -moving_object.h \ -moving_object.cpp \ -serializable.h \ -vector.cpp \ -vector.h \ -sector.cpp \ -sector.h +supertux_SOURCES = badguy.cpp badguy.h bitmask.cpp bitmask.h camera.cpp \ + camera.h collision.cpp collision.h door.cpp door.h intro.cpp intro.h \ + gameloop.cpp gameloop.h high_scores.cpp high_scores.h interactive_object.cpp \ + interactive_object.h level.cpp level.h level_subset.cpp level_subset.h leveleditor.cpp \ + leveleditor.h particlesystem.cpp particlesystem.h player.cpp player.h scene.cpp \ + scene.h special.cpp special.h supertux.cpp title.cpp title.h worldmap.cpp \ + worldmap.h tile.h tile.cpp tile_manager.h tile_manager.cpp resources.h \ + resources.cpp gameobjs.h gameobjs.cpp background.h background.cpp tilemap.h \ + tilemap.cpp serializable.h sector.cpp sector.h misc.h misc.cpp # EOF # +INCLUDES = -I$(top_srcdir)/lib +noinst_HEADERS = misc.h |
From: Tobias G. <to...@us...> - 2004-07-20 18:06:22
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22989/src Modified Files: special.cpp Log Message: one forgotten #include change Index: special.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/special.cpp,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- special.cpp 20 Jul 2004 18:04:48 -0000 1.62 +++ special.cpp 20 Jul 2004 18:06:14 -0000 1.63 @@ -22,7 +22,7 @@ #include "SDL.h" -#include "defines.h" +#include "app/defines.h" #include "special.h" #include "camera.h" #include "gameloop.h" |
From: Tobias G. <to...@us...> - 2004-07-20 18:03:06
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22320/src Removed Files: defines.h Log Message: forgot removing it --- defines.h DELETED --- |
From: Tobias G. <to...@us...> - 2004-07-20 18:02:09
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22065 Added Files: libtool ltmain.sh Log Message: these two files are needed for libtool support --- NEW FILE: libtool --- #! /bin/sh # libtoolT - Provide generalized library-building support services. # Generated automatically by (GNU supertux 0.1.1) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # # This file is part of GNU Libtool: # Originally by Gordon Matzigkeit <go...@gn...>, 1996 # # 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 distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of [...5881 lines suppressed...] # Fix the shell variable $srcfile for the compiler. fix_srcfile_path="" # Set to yes if exported symbols are required. always_export_symbols=no # The commands to list exported symbols. export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds="" # Symbols that should not be listed in the preloaded symbols. exclude_expsyms="_GLOBAL_OFFSET_TABLE_" # Symbols that must always be exported. include_expsyms="" # ### END LIBTOOL TAG CONFIG: F77 --- NEW FILE: ltmain.sh --- # ltmain.sh - Provide generalized library-building support services. # NOTE: Changing this file will not affect anything until you rerun configure. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # Originally by Gordon Matzigkeit <go...@gn...>, 1996 # # 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 distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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 [...4943 lines suppressed...] If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$help" 1>&2 exit 1 ;; esac echo $echo "Try \`$modename --help' for more information about other modes." exit 0 # Local Variables: # mode:shell-script # sh-indentation:2 # End: |
From: Tobias G. <to...@us...> - 2004-07-20 18:00:52
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21786 Modified Files: config.h.in configure.ac Makefile.am Log Message: update for new SuperTux library Index: configure.ac =================================================================== RCS file: /cvsroot/super-tux/supertux/configure.ac,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- configure.ac 13 Jun 2004 22:24:06 -0000 1.30 +++ configure.ac 20 Jul 2004 18:00:43 -0000 1.31 @@ -23,6 +23,7 @@ AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL +AC_PROG_LIBTOOL dnl Checks for header files. AC_HEADER_DIRENT @@ -105,7 +106,8 @@ AC_OUTPUT(Makefile m4/Makefile intl/Makefile src/Makefile data/Makefile - po/Makefile.in) + po/Makefile.in + lib/Makefile) echo "" echo "Features:" Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.am 7 Jun 2004 18:11:09 -0000 1.7 +++ Makefile.am 20 Jul 2004 18:00:43 -0000 1.8 @@ -1,4 +1,4 @@ -SUBDIRS = intl m4 src data po +SUBDIRS = intl m4 lib src data po EXTRA_DIST = LEVELDESIGN TODO contrib/levelconverter-0.0.6_0.0.7.py autogen.sh ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = 1.6 dist-bzip2 Index: config.h.in =================================================================== RCS file: /cvsroot/super-tux/supertux/config.h.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- config.h.in 15 Jun 2004 14:21:21 -0000 1.2 +++ config.h.in 20 Jul 2004 18:00:43 -0000 1.3 @@ -33,6 +33,9 @@ */ #undef HAVE_DIRENT_H +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + /* Define to 1 if you have the `feof_unlocked' function. */ #undef HAVE_FEOF_UNLOCKED |
From: Tobias G. <to...@us...> - 2004-07-20 17:59:46
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21496/src Added Files: misc.cpp misc.h Log Message: misc stuff goes here. It is at least temporarly needed to realize the SuperTux library. --- NEW FILE: misc.cpp --- // SuperTux // Copyright (C) 2004 Tobas Glaesser <tob...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include "misc.h" void MyConfig::customload(LispReader& reader) { reader.read_int ("keyboard-jump", keymap.jump); reader.read_int ("keyboard-activate", keymap.activate); reader.read_int ("keyboard-duck", keymap.duck); reader.read_int ("keyboard-left", keymap.left); reader.read_int ("keyboard-right", keymap.right); reader.read_int ("keyboard-fire", keymap.fire); } void MyConfig::customsave(FILE * config) { fprintf(config, "\t(keyboard-jump %d)\n", keymap.jump); fprintf(config, "\t(keyboard-duck %d)\n", keymap.duck); fprintf(config, "\t(keyboard-left %d)\n", keymap.left); fprintf(config, "\t(keyboard-right %d)\n", keymap.right); fprintf(config, "\t(keyboard-fire %d)\n", keymap.fire); fprintf(config, "\t(keyboard-activate %d)\n", keymap.activate); } void process_options_menu(void) { switch (options_menu->check()) { case MNID_OPENGL: #ifndef NOOPENGL if(use_gl != options_menu->isToggled(MNID_OPENGL)) { use_gl = !use_gl; st_video_setup(); } #else options_menu->get_item_by_id(MNID_OPENGL).toggled = false; #endif break; case MNID_FULLSCREEN: if(use_fullscreen != options_menu->isToggled(MNID_FULLSCREEN)) { use_fullscreen = !use_fullscreen; st_video_setup(); } break; case MNID_SOUND: if(use_sound != options_menu->isToggled(MNID_SOUND)) use_sound = !use_sound; break; case MNID_MUSIC: if(use_music != options_menu->isToggled(MNID_MUSIC)) { use_music = !use_music; sound_manager->enable_music(use_music); } break; case MNID_SHOWFPS: if(show_fps != options_menu->isToggled(MNID_SHOWFPS)) show_fps = !show_fps; break; } } void st_menu(void) { main_menu = new Menu(); options_menu = new Menu(); options_keys_menu = new Menu(); options_joystick_menu = new Menu(); load_game_menu = new Menu(); save_game_menu = new Menu(); game_menu = new Menu(); highscore_menu = new Menu(); contrib_menu = new Menu(); contrib_subset_menu = new Menu(); worldmap_menu = new Menu(); main_menu->set_pos(screen->w/2, 335); main_menu->additem(MN_GOTO, _("Start Game"),0,load_game_menu, MNID_STARTGAME); main_menu->additem(MN_GOTO, _("Contrib Levels"),0,contrib_menu, MNID_LEVELS_CONTRIB); main_menu->additem(MN_GOTO, _("Options"),0,options_menu, MNID_OPTIONMENU); main_menu->additem(MN_ACTION, _("Level Editor"),0,0, MNID_LEVELEDITOR); main_menu->additem(MN_ACTION, _("Credits"),0,0, MNID_CREDITS); main_menu->additem(MN_ACTION, _("Quit"),0,0, MNID_QUITMAINMENU); options_menu->additem(MN_LABEL,_("Options"),0,0); options_menu->additem(MN_HL,"",0,0); #ifndef NOOPENGL options_menu->additem(MN_TOGGLE,_("OpenGL "),use_gl,0, MNID_OPENGL); #else options_menu->additem(MN_DEACTIVE,_("OpenGL (not supported)"),use_gl, 0, MNID_OPENGL); #endif options_menu->additem(MN_TOGGLE,_("Fullscreen"),use_fullscreen,0, MNID_FULLSCREEN); if(audio_device) { options_menu->additem(MN_TOGGLE,_("Sound "), use_sound,0, MNID_SOUND); options_menu->additem(MN_TOGGLE,_("Music "), use_music,0, MNID_MUSIC); } else { options_menu->additem(MN_DEACTIVE,_("Sound "), false,0, MNID_SOUND); options_menu->additem(MN_DEACTIVE,_("Music "), false,0, MNID_MUSIC); } options_menu->additem(MN_TOGGLE,_("Show FPS "),show_fps,0, MNID_SHOWFPS); options_menu->additem(MN_GOTO,_("Setup Keys"),0,options_keys_menu); if(use_joystick) options_menu->additem(MN_GOTO,_("Setup Joystick"),0,options_joystick_menu); options_menu->additem(MN_HL,"",0,0); options_menu->additem(MN_BACK,_("Back"),0,0); options_keys_menu->additem(MN_LABEL,_("Keyboard Setup"),0,0); options_keys_menu->additem(MN_HL,"",0,0); options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Left move"), 0,0, 0,&keymap.left); options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Right move"), 0,0, 0,&keymap.right); options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Jump"), 0,0, 0,&keymap.jump); options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Duck"), 0,0, 0,&keymap.duck); options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Activate"), 0, 0, 0, &keymap.activate); options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Power/Run"), 0,0, 0,&keymap.fire); options_keys_menu->additem(MN_HL,"",0,0); options_keys_menu->additem(MN_BACK,_("Back"),0,0); if(use_joystick) { options_joystick_menu->additem(MN_LABEL,_("Joystick Setup"),0,0); options_joystick_menu->additem(MN_HL,"",0,0); //options_joystick_menu->additem(MN_CONTROLFIELD_JS,"X axis", 0,0, 0,&joystick_keymap.x_axis); //options_joystick_menu->additem(MN_CONTROLFIELD_JS,"Y axis", 0,0, 0,&joystick_keymap.y_axis); options_joystick_menu->additem(MN_CONTROLFIELD_JS,_("A button"), 0,0, 0,&joystick_keymap.a_button); options_joystick_menu->additem(MN_CONTROLFIELD_JS,_("B button"), 0,0, 0,&joystick_keymap.b_button); //options_joystick_menu->additem(MN_CONTROLFIELD_JS,"Start", 0,0, 0,&joystick_keymap.start_button); //options_joystick_menu->additem(MN_CONTROLFIELD_JS,"DeadZone", 0,0, 0,&joystick_keymap.dead_zone); options_joystick_menu->additem(MN_HL,"",0,0); options_joystick_menu->additem(MN_BACK,_("Back"),0,0); } load_game_menu->additem(MN_LABEL,_("Start Game"),0,0); load_game_menu->additem(MN_HL,"",0,0); load_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0, 1); load_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0, 2); load_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0, 3); load_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0, 4); load_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0, 5); load_game_menu->additem(MN_HL,"",0,0); load_game_menu->additem(MN_BACK,_("Back"),0,0); save_game_menu->additem(MN_LABEL,_("Save Game"),0,0); save_game_menu->additem(MN_HL,"",0,0); save_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0, 1); save_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0, 2); save_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0, 3); save_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0, 4); save_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0, 5); save_game_menu->additem(MN_HL,"",0,0); save_game_menu->additem(MN_BACK,"Back",0,0); game_menu->additem(MN_LABEL,_("Pause"),0,0); game_menu->additem(MN_HL,"",0,0); game_menu->additem(MN_ACTION,_("Continue"),0,0,MNID_CONTINUE); game_menu->additem(MN_GOTO,_("Options"),0,options_menu); game_menu->additem(MN_HL,"",0,0); game_menu->additem(MN_ACTION,_("Abort Level"),0,0,MNID_ABORTLEVEL); worldmap_menu->additem(MN_LABEL,_("Pause"),0,0); worldmap_menu->additem(MN_HL,"",0,0); worldmap_menu->additem(MN_ACTION,_("Continue"),0,0, WorldMapNS::MNID_RETURNWORLDMAP); worldmap_menu->additem(MN_GOTO,_("Options"),0, options_menu); worldmap_menu->additem(MN_HL,"",0,0); worldmap_menu->additem(MN_ACTION,_("Quit Game"),0,0, WorldMapNS::MNID_QUITWORLDMAP); highscore_menu->additem(MN_TEXTFIELD,_("Enter your name:"),0,0); } void st_menu_free() { delete worldmap_menu; } --- NEW FILE: misc.h --- // SuperTux // Copyright (C) 2004 Tobas Glaesser <tob...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_MISC_H #define SUPERTUX_MISC_H #include "app/setup.h" #include "app/globals.h" #include "resources.h" #include "gui/menu.h" #include "utils/configfile.h" #include "player.h" #include "title.h" #include "worldmap.h" #include "gameloop.h" #include "app/gettext.h" class MyConfig : public Config { public: void customload(LispReader& reader); void customsave(FILE * config); }; enum OptionsMenuIDs { MNID_OPENGL, MNID_FULLSCREEN, MNID_SOUND, MNID_MUSIC, MNID_SHOWFPS }; /* Handle changes made to global settings in the options menu. */ void process_options_menu(void); /* Create and setup menus. */ void st_menu(void); void st_menu_free(); #endif //SUPERTUX_MISC_H |
Update of /cvsroot/super-tux/supertux/src/screen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21228/src/screen Removed Files: Makefile drawing_context.cpp drawing_context.h font.cpp font.h screen.cpp screen.h surface.cpp surface.h Log Message: removed them in favour of their new live in the SuperTux library --- font.cpp DELETED --- --- drawing_context.cpp DELETED --- --- surface.h DELETED --- --- font.h DELETED --- --- surface.cpp DELETED --- --- Makefile DELETED --- --- drawing_context.h DELETED --- --- screen.h DELETED --- --- screen.cpp DELETED --- |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21228/src Removed Files: configfile.cpp configfile.h exceptions.h game_object.cpp game_object.h gettext.h globals.cpp globals.h lispreader.cpp lispreader.h lispwriter.cpp lispwriter.h menu.cpp menu.h mousecursor.cpp mousecursor.h moving_object.cpp moving_object.h musicref.cpp musicref.h physic.cpp physic.h setup.cpp setup.h sound.cpp sound.h sound_manager.cpp sound_manager.h sprite.cpp sprite.h sprite_manager.cpp sprite_manager.h type.cpp type.h vector.cpp vector.h Log Message: removed them in favour of their new live in the SuperTux library --- moving_object.cpp DELETED --- --- vector.h DELETED --- --- sound_manager.h DELETED --- --- configfile.h DELETED --- --- setup.h DELETED --- --- sound.h DELETED --- --- game_object.cpp DELETED --- --- globals.h DELETED --- --- exceptions.h DELETED --- --- menu.cpp DELETED --- --- type.cpp DELETED --- --- physic.h DELETED --- --- lispwriter.h DELETED --- --- sprite.h DELETED --- --- globals.cpp DELETED --- --- lispreader.h DELETED --- --- vector.cpp DELETED --- --- game_object.h DELETED --- --- lispwriter.cpp DELETED --- --- gettext.h DELETED --- --- mousecursor.h DELETED --- --- configfile.cpp DELETED --- --- sprite_manager.cpp DELETED --- --- musicref.cpp DELETED --- --- setup.cpp DELETED --- --- sprite.cpp DELETED --- --- moving_object.h DELETED --- --- sound_manager.cpp DELETED --- --- physic.cpp DELETED --- --- musicref.h DELETED --- --- sound.cpp DELETED --- --- mousecursor.cpp DELETED --- --- type.h DELETED --- --- sprite_manager.h DELETED --- --- lispreader.cpp DELETED --- --- menu.h DELETED --- |
From: Tobias G. <to...@us...> - 2004-07-20 17:53:52
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20174/src Removed Files: timer.cpp timer.h Log Message: removed in favor of the new library --- timer.h DELETED --- --- timer.cpp DELETED --- |
From: Tobias G. <to...@us...> - 2004-07-20 17:51:50
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19557/lib/special Added Files: base.h game_object.cpp game_object.h moving_object.cpp moving_object.h sprite.cpp sprite.h sprite_manager.cpp sprite_manager.h stringlist.cpp stringlist.h timer.cpp timer.h Log Message: Generated SuperTux libtool library containing more general source, that could prove useful for other applications/games. Caution: It's not yet SuperTux independed, more work on this will follow, that's just the first step. The file structure isn't fixed, better ideas will surely find there way in it! --- NEW FILE: moving_object.cpp --- // $Id: moving_object.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include "special/moving_object.h" MovingObject::MovingObject() { base.x = base.y = base.width = base.height = 0; old_base = base; } MovingObject::~MovingObject() { } --- NEW FILE: timer.h --- // $Id: timer.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_TIMER_H #define SUPERTUX_TIMER_H extern unsigned int st_pause_ticks, st_pause_count; unsigned int st_get_ticks(void); void st_pause_ticks_init(void); void st_pause_ticks_start(void); void st_pause_ticks_stop(void); bool st_pause_ticks_started(void); class Timer { public: unsigned int period; unsigned int time; unsigned int (*get_ticks) (void); public: Timer(); void init(bool st_ticks); void start(unsigned int period); void stop(); /*====================================================================== return: NO = the timer is not started or it is over YES = otherwise ======================================================================*/ int check(); int started(); /*====================================================================== return: the time left (in millisecond) note : the returned value can be negative ======================================================================*/ int get_left(); int get_gone(); void fwrite(FILE* fi); void fread(FILE* fi); }; #endif /*SUPERTUX_TIMER_H*/ /* Local Variables: */ /* mode:c++ */ /* End: */ --- NEW FILE: sprite_manager.cpp --- // $Id: sprite_manager.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include <iostream> #include "utils/lispreader.h" #include "special/sprite_manager.h" SpriteManager::SpriteManager(const std::string& filename) { load_resfile(filename); } SpriteManager::~SpriteManager() { for(std::map<std::string, Sprite*>::iterator i = sprites.begin(); i != sprites.end(); ++i) { delete i->second; } } void SpriteManager::load_resfile(const std::string& filename) { lisp_object_t* root_obj = lisp_read_from_file(filename); if (!root_obj) { std::cout << "SpriteManager: Couldn't load: " << filename << std::endl; return; } lisp_object_t* cur = root_obj; if (strcmp(lisp_symbol(lisp_car(cur)), "supertux-resources") != 0) return; cur = lisp_cdr(cur); while(cur) { lisp_object_t* el = lisp_car(cur); if (strcmp(lisp_symbol(lisp_car(el)), "sprite") == 0) { Sprite* sprite = new Sprite(lisp_cdr(el)); Sprites::iterator i = sprites.find(sprite->get_name()); if (i == sprites.end()) { sprites[sprite->get_name()] = sprite; } else { delete i->second; i->second = sprite; std::cout << "Warning: dulpicate entry: '" << sprite->get_name() << "'" << std::endl; } } else { std::cout << "SpriteManager: Unknown tag" << std::endl; } cur = lisp_cdr(cur); } lisp_free(root_obj); } Sprite* SpriteManager::load(const std::string& name) { Sprites::iterator i = sprites.find(name); if (i != sprites.end()) { return i->second; } else { std::cout << "SpriteManager: Sprite '" << name << "' not found" << std::endl; return 0; } } /* EOF */ --- NEW FILE: stringlist.h --- // $Id: stringlist.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_STRINGLIST_H #define SUPERTUX_STRINGLIST_H struct string_list_type { int num_items; int active_item; char **item; }; void string_list_init(string_list_type* pstring_list); char* string_list_active(string_list_type* pstring_list); void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig); int string_list_find(string_list_type* pstring_list, const char* str); void string_list_sort(string_list_type* pstring_list); void string_list_add_item(string_list_type* pstring_list, const char* str); void string_list_free(string_list_type* pstring_list); #endif /*SUPERTUX_STRINGLIST_H*/ --- NEW FILE: game_object.cpp --- // $Id: game_object.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include "special/game_object.h" GameObject::GameObject() : wants_to_die(false) { } GameObject::~GameObject() { } --- NEW FILE: sprite.cpp --- // $Id: sprite.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include <iostream> #include <cmath> #include "app/globals.h" #include "app/setup.h" #include "special/sprite.h" #include "video/drawing_context.h" Sprite::Sprite(lisp_object_t* cur) { init_defaults(); LispReader reader(cur); if(!reader.read_string("name", name)) st_abort("Sprite wihtout name", ""); reader.read_int("x-hotspot", x_hotspot); reader.read_int("y-hotspot", y_hotspot); reader.read_float("fps", fps); std::vector<std::string> images; if(!reader.read_string_vector("images", images)) st_abort("Sprite contains no images: ", name.c_str()); for(std::vector<std::string>::size_type i = 0; i < images.size(); ++i) { surfaces.push_back( new Surface(datadir + "/images/" + images[i], true)); } frame_delay = 1000.0f/fps; } Sprite::~Sprite() { for(std::vector<Surface*>::iterator i = surfaces.begin(); i != surfaces.end(); ++i) delete *i; } void Sprite::init_defaults() { x_hotspot = 0; y_hotspot = 0; fps = 10; time = 0; frame_delay = 1000.0f/fps; } void Sprite::update(float /*delta*/) { //time += 10*delta; //std::cout << "Delta: " << delta << std::endl; } void Sprite::draw(DrawingContext& context, const Vector& pos, int layer, Uint32 drawing_effect) { time = SDL_GetTicks(); unsigned int frame = get_current_frame(); if (frame < surfaces.size()) { Surface* surface = surfaces[frame]; context.draw_surface(surface, pos - Vector(x_hotspot, y_hotspot), layer, drawing_effect); } } #if 0 void Sprite::draw_part(float sx, float sy, float x, float y, float w, float h) { time = SDL_GetTicks(); unsigned int frame = get_current_frame(); if (frame < surfaces.size()) surfaces[frame]->draw_part(sx, sy, x - x_hotspot, y - y_hotspot, w, h); } #endif void Sprite::reset() { time = 0; } int Sprite::get_current_frame() const { unsigned int frame = static_cast<int>(fmodf(time, surfaces.size()*frame_delay)/frame_delay); return frame % surfaces.size(); } int Sprite::get_width() const { return surfaces[get_current_frame()]->w; } int Sprite::get_height() const { return surfaces[get_current_frame()]->h; } /* EOF */ --- NEW FILE: moving_object.h --- // $Id: moving_object.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_MOVING_OBJECT_H #define SUPERTUX_MOVING_OBJECT_H #include "special/base.h" #include "special/game_object.h" #include "math/vector.h" //#include "rectangle.h" /** * Base class for all dynamic/moving game objects. This class contains things * for handling the bounding boxes and collision feedback. */ class MovingObject : public GameObject { public: MovingObject(); virtual ~MovingObject(); /** this function is called when the object collided with any other object */ virtual void collision(const MovingObject& other_object, int collision_type) = 0; Vector get_pos() const { return Vector(base.x, base.y); } base_type base; base_type old_base; protected: #if 0 // this will be used in my collision detection rewrite later /// the current position of the object Vector pos; /// the position we want to move until next frame Vector new_pos; /// the bounding box relative to the current position Rectangle bounding_box; #endif }; #endif /*SUPERTUX_MOVING_OBJECT_H*/ --- NEW FILE: base.h --- // $Id: base.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_TYPE_H #define SUPERTUX_TYPE_H #include <string> #include "SDL.h" /* 'Base' type for game objects */ struct base_type { float x; float y; float width; float height; }; #endif /*SUPERTUX_TYPE_H*/ --- NEW FILE: sprite.h --- // $Id: sprite.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_SPRITE_H #define SUPERTUX_SPRITE_H #include <string> #include <vector> #include "utils/lispreader.h" #include "video/surface.h" #include "math/vector.h" class Sprite { private: std::string name; int x_hotspot; int y_hotspot; /** Frames per second */ float fps; /** Number of seconds that a frame is displayed until it is switched to the next frame */ float frame_delay; float time; std::vector<Surface*> surfaces; void init_defaults(); public: /** cur has to be a pointer to data in the form of ((x-hotspot 5) (y-hotspot 10) ...) */ Sprite(lisp_object_t* cur); ~Sprite(); void reset(); /** Update the sprite and process to the next frame */ void update(float delta); void draw(DrawingContext& context, const Vector& pos, int layer, Uint32 drawing_effect = NONE_EFFECT); int get_current_frame() const; float get_fps() { return fps; } ; int get_frames() { return surfaces.size(); } ; std::string get_name() const { return name; } int get_width() const; int get_height() const; Surface* get_frame(unsigned int frame) { if(frame < surfaces.size()) return surfaces[frame]; else return surfaces[0]; } }; #endif /*SUPERTUX_SPRITE_H*/ /* Local Variables: */ /* mode:c++ */ /* End: */ --- NEW FILE: timer.cpp --- // $Id: timer.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include "SDL.h" #include "special/timer.h" unsigned int st_pause_ticks, st_pause_count; unsigned int st_get_ticks(void) { if(st_pause_count != 0) return /*SDL_GetTicks()*/ - st_pause_ticks /*- SDL_GetTicks()*/ + st_pause_count; else return SDL_GetTicks() - st_pause_ticks; } void st_pause_ticks_init(void) { st_pause_ticks = 0; st_pause_count = 0; } void st_pause_ticks_start(void) { if(st_pause_count == 0) st_pause_count = SDL_GetTicks(); } void st_pause_ticks_stop(void) { if(st_pause_count == 0) return; st_pause_ticks += SDL_GetTicks() - st_pause_count; st_pause_count = 0; } bool st_pause_ticks_started(void) { if(st_pause_count == 0) return false; else return true; } Timer::Timer() { init(true); } void Timer::init(bool st_ticks) { period = 0; time = 0; get_ticks = st_ticks ? st_get_ticks : SDL_GetTicks; } void Timer::start(unsigned int period_) { time = get_ticks(); period = period_; } void Timer::stop() { if(get_ticks == st_get_ticks) init(true); else init(false); } int Timer::check() { if((time != 0) && (time + period > get_ticks())) return true; else { time = 0; return false; } } int Timer::started() { if(time != 0) return true; else return false; } int Timer::get_left() { return (period - (get_ticks() - time)); } int Timer::get_gone() { return (get_ticks() - time); } void Timer::fwrite(FILE* fi) { unsigned int diff_ticks; int tick_mode; if(time != 0) diff_ticks = get_ticks() - time; else diff_ticks = 0; ::fwrite(&period,sizeof(unsigned int),1,fi); ::fwrite(&diff_ticks,sizeof(unsigned int),1,fi); if(get_ticks == st_get_ticks) tick_mode = true; else tick_mode = false; ::fwrite(&tick_mode,sizeof(unsigned int),1,fi); } void Timer::fread(FILE* fi) { unsigned int diff_ticks; int tick_mode; ::fread(&period,sizeof(unsigned int),1,fi); ::fread(&diff_ticks,sizeof(unsigned int),1,fi); ::fread(&tick_mode,sizeof(unsigned int),1,fi); if (tick_mode) get_ticks = st_get_ticks; else get_ticks = SDL_GetTicks; if (diff_ticks != 0) time = get_ticks() - diff_ticks; else time = 0; } /* EOF */ --- NEW FILE: game_object.h --- // $Id: game_object.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_GAMEOBJECT_H #define SUPERTUX_GAMEOBJECT_H #include <string> class DrawingContext; /** * Base class for all game objects. This contains functions for: * -querying the actual type of the object * -a flag that indicates if the object wants to be removed. Objects with this * flag will be removed at the end of each frame. This is alot safer than * having some uncontrollable "delete this" in the code. * -an action function that is called once per frame and allows the object to * update it's state. * * Most GameObjects will also implement the DrawableObject interface so that * they can actually be drawn on screen. */ class GameObject // TODO rename this once the game has been converted { public: GameObject(); virtual ~GameObject(); /** This function is called once per frame and allows the object to update * it's state. The elapsed_time is the time since the last frame and should be * the base for all timed things. */ virtual void action(float elapsed_time) = 0; /** The GameObject should draw itself onto the provided DrawingContext if this * function is called. */ virtual void draw(DrawingContext& context) = 0; /** returns true if the object is not scheduled to be removed yet */ bool is_valid() const { return !wants_to_die; } /** schedules this object to be removed at the end of the frame */ void remove_me() { wants_to_die = true; } private: /** this flag indicates if the object should be removed at the end of the * frame */ bool wants_to_die; }; #endif /*SUPERTUX_GAMEOBJECT_H*/ --- NEW FILE: stringlist.cpp --- // $Id: stringlist.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Tobias Glaesser <tob...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include "string.h" #include "stdlib.h" #include "special/stringlist.h" void string_list_init(string_list_type* pstring_list) { pstring_list->num_items = 0; pstring_list->active_item = -1; pstring_list->item = NULL; } char* string_list_active(string_list_type* pstring_list) { if(pstring_list == NULL) return ""; if(pstring_list->active_item != -1) return pstring_list->item[pstring_list->active_item]; else return ""; } void string_list_add_item(string_list_type* pstring_list,const char* str) { char *pnew_string; pnew_string = (char*) malloc(sizeof(char)*(strlen(str)+1)); strcpy(pnew_string,str); ++pstring_list->num_items; pstring_list->item = (char**) realloc(pstring_list->item,sizeof(char**)*pstring_list->num_items); pstring_list->item[pstring_list->num_items-1] = pnew_string; if(pstring_list->active_item == -1) pstring_list->active_item = 0; } void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig) { int i; string_list_free(pstring_list); for(i = 0; i < pstring_list_orig.num_items; ++i) string_list_add_item(pstring_list,pstring_list_orig.item[i]); } int string_list_find(string_list_type* pstring_list,const char* str) { int i; for(i = 0; i < pstring_list->num_items; ++i) { if(strcmp(pstring_list->item[i],str) == 0) { return i; } } return -1; } void string_list_sort(string_list_type* pstring_list) { int i,j,y; for(j = 0; j < pstring_list->num_items; ++j) for(i = 0; i < pstring_list->num_items-1; ++i) { y = strcmp(pstring_list->item[i],pstring_list->item[i+1]); if(y == 0) { continue; } else if(y < 0) { continue; } else if(y > 0) { char* char_pointer; char_pointer = pstring_list->item[i]; pstring_list->item[i] = pstring_list->item[i+1]; pstring_list->item[i+1] = char_pointer; continue; } } } void string_list_free(string_list_type* pstring_list) { if(pstring_list != NULL) { int i; for(i=0; i < pstring_list->num_items; ++i) free(pstring_list->item[i]); free(pstring_list->item); pstring_list->item = NULL; pstring_list->num_items = 0; pstring_list->active_item = -1; } } --- NEW FILE: sprite_manager.h --- // $Id: sprite_manager.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke <gr...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_SPRITE_MANAGER_H #define SUPERTUX_SPRITE_MANAGER_H #include <map> #include "special/sprite.h" class SpriteManager { private: typedef std::map<std::string, Sprite*> Sprites; Sprites sprites; public: SpriteManager(const std::string& filename); ~SpriteManager(); void load_resfile(const std::string& filename); /** loads a sprite. * WARNING: You must not delete the returned object. */ Sprite* load(const std::string& name); }; #endif /*SUPERTUX_SPRITE_MANAGER_H*/ /* Local Variables: */ /* mode:c++ */ /* End: */ |
From: Tobias G. <to...@us...> - 2004-07-20 17:51:50
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19557/lib/utils Added Files: configfile.cpp configfile.h exceptions.h lispreader.cpp lispreader.h lispwriter.cpp lispwriter.h Log Message: Generated SuperTux libtool library containing more general source, that could prove useful for other applications/games. Caution: It's not yet SuperTux independed, more work on this will follow, that's just the first step. The file structure isn't fixed, better ideas will surely find there way in it! --- NEW FILE: lispwriter.h --- // $Id: lispwriter.h,v 1.1 2004/07/20 17:51:38 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_LISPWRITER_H #define SUPERTUX_LISPWRITER_H #include <iostream> #include <string> #include <vector> class LispWriter { public: LispWriter(std::ostream& out); ~LispWriter(); void write_comment(const std::string& comment); void start_list(const std::string& listname); void write_int(const std::string& name, int value); void write_float(const std::string& name, float value); void write_string(const std::string& name, const std::string& value); void write_bool(const std::string& name, bool value); void write_int_vector(const std::string& name, const std::vector<int>& value); void write_int_vector(const std::string& name, const std::vector<unsigned int>& value); // add more write-functions when needed... void end_list(const std::string& listname); private: void indent(); std::ostream& out; int indent_depth; std::vector<std::string> lists; }; #endif --- NEW FILE: configfile.h --- // $Id: configfile.h,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Michael George <mi...@ge...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_CONFIGFILE_H #define SUPERTUX_CONFIGFILE_H #include "utils/lispreader.h" class Config { public: void load (); void save (); virtual void customload(LispReader& reader) {}; virtual void customsave(FILE * config) {}; }; extern Config* config; #endif /* Local Variables: */ /* mode:c++ */ /* End: */ --- NEW FILE: lispreader.h --- /* $Id: lispreader.h,v 1.1 2004/07/20 17:51:38 tobgle Exp $ */ /* * lispreader.h * * Copyright (C) 1998-2000 Mark Probst * Copyright (C) 2002 Ingo Ruhnke <gr...@gm...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef SUPERTUX_LISPREADER_H #define SUPERTUX_LISPREADER_H #include <cstdio> #include <string> #include <vector> #include <exception> #include <zlib.h> #include "utils/exceptions.h" #define LISP_STREAM_FILE 1 #define LISP_STREAM_STRING 2 #define LISP_STREAM_ANY 3 #define LISP_TYPE_INTERNAL -3 #define LISP_TYPE_PARSE_ERROR -2 #define LISP_TYPE_EOF -1 #define LISP_TYPE_NIL 0 #define LISP_TYPE_SYMBOL 1 #define LISP_TYPE_INTEGER 2 #define LISP_TYPE_STRING 3 #define LISP_TYPE_REAL 4 #define LISP_TYPE_CONS 5 #define LISP_TYPE_PATTERN_CONS 6 #define LISP_TYPE_BOOLEAN 7 #define LISP_TYPE_PATTERN_VAR 8 #define LISP_PATTERN_ANY 1 #define LISP_PATTERN_SYMBOL 2 #define LISP_PATTERN_STRING 3 #define LISP_PATTERN_INTEGER 4 #define LISP_PATTERN_REAL 5 #define LISP_PATTERN_BOOLEAN 6 #define LISP_PATTERN_LIST 7 #define LISP_PATTERN_OR 8 // Exception class LispReaderException : public SuperTuxException { public: LispReaderException(const char* _message = "lispreader error", const char* _file = "", const unsigned int _line = 0) : SuperTuxException(_message, _file, _line) { }; }; typedef struct { int type; union { FILE *file; struct { char *buf; int pos; } string; struct { void *data; int (*next_char) (void *data); void (*unget_char) (char c, void *data); } any; } v; } lisp_stream_t; typedef struct _lisp_object_t lisp_object_t; struct _lisp_object_t { int type; union { struct { struct _lisp_object_t *car; struct _lisp_object_t *cdr; } cons; char *string; int integer; float real; struct { int type; int index; struct _lisp_object_t *sub; } pattern; } v; }; lisp_stream_t* lisp_stream_init_file (lisp_stream_t *stream, FILE *file); lisp_stream_t* lisp_stream_init_string (lisp_stream_t *stream, char *buf); lisp_stream_t* lisp_stream_init_any (lisp_stream_t *stream, void *data, int (*next_char) (void *data), void (*unget_char) (char c, void *data)); lisp_object_t* lisp_read (lisp_stream_t *in); lisp_object_t* lisp_read_from_file(const std::string& filename); void lisp_free (lisp_object_t *obj); lisp_object_t* lisp_read_from_string (const char *buf); int lisp_compile_pattern (lisp_object_t **obj, int *num_subs); int lisp_match_pattern (lisp_object_t *pattern, lisp_object_t *obj, lisp_object_t **vars, int num_subs); int lisp_match_string (const char *pattern_string, lisp_object_t *obj, lisp_object_t **vars); int lisp_type (lisp_object_t *obj); int lisp_integer (lisp_object_t *obj); float lisp_real (lisp_object_t *obj); char* lisp_symbol (lisp_object_t *obj); char* lisp_string (lisp_object_t *obj); int lisp_boolean (lisp_object_t *obj); lisp_object_t* lisp_car (lisp_object_t *obj); lisp_object_t* lisp_cdr (lisp_object_t *obj); lisp_object_t* lisp_cxr (lisp_object_t *obj, const char *x); lisp_object_t* lisp_make_integer (int value); lisp_object_t* lisp_make_real (float value); lisp_object_t* lisp_make_symbol (const char *value); lisp_object_t* lisp_make_string (const char *value); lisp_object_t* lisp_make_cons (lisp_object_t *car, lisp_object_t *cdr); lisp_object_t* lisp_make_boolean (int value); int lisp_list_length (lisp_object_t *obj); lisp_object_t* lisp_list_nth_cdr (lisp_object_t *obj, int index); lisp_object_t* lisp_list_nth (lisp_object_t *obj, int index); void lisp_dump (lisp_object_t *obj, FILE *out); #define lisp_nil() ((lisp_object_t*)0) #define lisp_nil_p(obj) (obj == 0) #define lisp_integer_p(obj) (lisp_type((obj)) == LISP_TYPE_INTEGER) #define lisp_real_p(obj) (lisp_type((obj)) == LISP_TYPE_REAL) #define lisp_symbol_p(obj) (lisp_type((obj)) == LISP_TYPE_SYMBOL) #define lisp_string_p(obj) (lisp_type((obj)) == LISP_TYPE_STRING) #define lisp_cons_p(obj) (lisp_type((obj)) == LISP_TYPE_CONS) #define lisp_boolean_p(obj) (lisp_type((obj)) == LISP_TYPE_BOOLEAN) /** */ class LispReader { private: lisp_object_t* owner; lisp_object_t* lst; lisp_object_t* search_for(const char* name); public: /** cur == ((pos 1 2 3) (id 12 3 4)...) */ LispReader(lisp_object_t* l); ~LispReader(); bool read_int_vector(const char* name, std::vector<int>& vec); bool read_int_vector(const char* name, std::vector<unsigned int>& vec); bool read_char_vector(const char* name, std::vector<char>& vec); bool read_string_vector(const char* name, std::vector<std::string>& vec); bool read_string(const char* name, std::string& str, bool translatable = false); bool read_int(const char* name, int& i); bool read_float(const char* name, float& f); bool read_bool(const char* name, bool& b); bool read_lisp(const char* name, lisp_object_t*& b); lisp_object_t* read_lisp(const char* name); static LispReader* load(const std::string& filename, const std::string& toplevellist); lisp_object_t* get_lisp(); }; #endif /*SUPERTUX_LISPREADER_H*/ --- NEW FILE: lispwriter.cpp --- // $Id: lispwriter.cpp,v 1.1 2004/07/20 17:51:38 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include <iostream> #include "utils/lispwriter.h" LispWriter::LispWriter(std::ostream& newout) : out(newout), indent_depth(0) { } LispWriter::~LispWriter() { if(lists.size() > 0) { std::cerr << "Warning: Not all sections closed in lispwriter!\n"; } } void LispWriter::write_comment(const std::string& comment) { out << "; " << comment << "\n"; } void LispWriter::start_list(const std::string& listname) { indent(); out << '(' << listname << '\n'; indent_depth += 2; lists.push_back(listname); } void LispWriter::end_list(const std::string& listname) { if(lists.size() == 0) { std::cerr << "Trying to close list '" << listname << "', which is not open.\n"; return; } if(lists.back() != listname) { std::cerr << "Warning: trying to close list '" << listname << "' while list '" << lists.back() << "' is open.\n"; return; } lists.pop_back(); indent_depth -= 2; indent(); out << ")\n"; } void LispWriter::write_int(const std::string& name, int value) { indent(); out << '(' << name << ' ' << value << ")\n"; } void LispWriter::write_float(const std::string& name, float value) { indent(); out << '(' << name << ' ' << value << ")\n"; } void LispWriter::write_string(const std::string& name, const std::string& value) { indent(); out << '(' << name << " \"" << value << "\")\n"; } void LispWriter::write_bool(const std::string& name, bool value) { indent(); out << '(' << name << ' ' << (value ? "#t" : "#f") << ")\n"; } void LispWriter::write_int_vector(const std::string& name, const std::vector<int>& value) { indent(); out << '(' << name; for(std::vector<int>::const_iterator i = value.begin(); i != value.end(); ++i) out << " " << *i; out << ")\n"; } void LispWriter::write_int_vector(const std::string& name, const std::vector<unsigned int>& value) { indent(); out << '(' << name; for(std::vector<unsigned int>::const_iterator i = value.begin(); i != value.end(); ++i) out << " " << *i; out << ")\n"; } void LispWriter::indent() { for(int i = 0; i<indent_depth; ++i) out << ' '; } --- NEW FILE: configfile.cpp --- // $Id: configfile.cpp,v 1.1 2004/07/20 17:51:37 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Michael George <mi...@ge...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #include <cstdlib> #include <string> #include "utils/configfile.h" #include "app/setup.h" #include "app/globals.h" #ifdef WIN32 const char * config_filename = "/st_config.dat"; #else const char * config_filename = "/config"; #endif Config* config = 0; static void defaults () { /* Set defaults: */ debug_mode = false; audio_device = true; use_fullscreen = false; show_fps = false; use_gl = false; use_sound = true; use_music = true; } void Config::load() { FILE * file = NULL; defaults(); /* override defaults from config file */ file = opendata(config_filename, "r"); if (file == NULL) return; /* read config file */ lisp_stream_t stream; lisp_object_t * root_obj = NULL; lisp_stream_init_file (&stream, file); root_obj = lisp_read (&stream); if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR) return; if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-config") != 0) return; LispReader reader(lisp_cdr(root_obj)); reader.read_bool("fullscreen", use_fullscreen); reader.read_bool("sound", use_sound); reader.read_bool("music", use_music); reader.read_bool("show_fps", show_fps); std::string video; reader.read_string ("video", video); if (video == "opengl") use_gl = true; else use_gl = false; reader.read_int ("joystick", joystick_num); if (joystick_num >= 0) { reader.read_int ("joystick-x", joystick_keymap.x_axis); reader.read_int ("joystick-y", joystick_keymap.y_axis); reader.read_int ("joystick-a", joystick_keymap.a_button); reader.read_int ("joystick-b", joystick_keymap.b_button); reader.read_int ("joystick-start", joystick_keymap.start_button); reader.read_int ("joystick-deadzone", joystick_keymap.dead_zone); } customload(reader); lisp_free(root_obj); } void Config::save () { /* write settings to config file */ FILE * config = opendata(config_filename, "w"); if(config) { fprintf(config, "(supertux-config\n"); fprintf(config, "\t;; the following options can be set to #t or #f:\n"); fprintf(config, "\t(fullscreen %s)\n", use_fullscreen ? "#t" : "#f"); fprintf(config, "\t(sound %s)\n", use_sound ? "#t" : "#f"); fprintf(config, "\t(music %s)\n", use_music ? "#t" : "#f"); fprintf(config, "\t(show_fps %s)\n", show_fps ? "#t" : "#f"); fprintf(config, "\n\t;; either \"opengl\" or \"sdl\"\n"); fprintf(config, "\t(video \"%s\")\n", use_gl ? "opengl" : "sdl"); if(use_joystick) { fprintf(config, "\n\t;; joystick number:\n"); fprintf(config, "\t(joystick %d)\n", joystick_num); fprintf(config, "\t(joystick-x %d)\n", joystick_keymap.x_axis); fprintf(config, "\t(joystick-y %d)\n", joystick_keymap.y_axis); fprintf(config, "\t(joystick-a %d)\n", joystick_keymap.a_button); fprintf(config, "\t(joystick-b %d)\n", joystick_keymap.b_button); fprintf(config, "\t(joystick-start %d)\n", joystick_keymap.start_button); fprintf(config, "\t(joystick-deadzone %d)\n", joystick_keymap.dead_zone); } customsave(config); fprintf(config, ")\n"); } } /* EOF */ --- NEW FILE: exceptions.h --- // $Id: exceptions.h,v 1.1 2004/07/20 17:51:38 tobgle Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2003 Tobias Glaesser <tob...@gm...> // // 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 distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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. #ifndef SUPERTUX_EXCEPTIONS_H #define SUPERTUX_EXCEPTIONS_H // Exceptions #include <exception> #include <string> class SuperTuxException : public std::exception { public: SuperTuxException(const char* _message, const char* _file = "", const unsigned int _line = 0) : message(_message), file(_file), line(_line) { }; virtual ~SuperTuxException() throw() { }; const char* what() const throw() { return message; }; const char* what_file() const throw() { return file; }; const unsigned int what_line() const throw() { return line; }; private: const char* message; const char* file; const unsigned int line; }; #endif /*SUPERTUX_EXCEPTIONS_H*/ --- NEW FILE: lispreader.cpp --- /* $Id: lispreader.cpp,v 1.1 2004/07/20 17:51:38 tobgle Exp $ */ /* * lispreader.c * * Copyright (C) 1998-2000 Mark Probst * Copyright (C) 2002 Ingo Ruhnke <gr...@gm...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the [...1254 lines suppressed...] { return lst; } lisp_object_t* lisp_read_from_file(const std::string& filename) { FILE* in = fopen(filename.c_str(), "r"); if(!in) return 0; lisp_stream_t stream; lisp_stream_init_file(&stream, in); lisp_object_t* obj = lisp_read(&stream); fclose(in); return obj; } // EOF // |