Main Page   Class Hierarchy   Compound List   File List   Compound Members  

util.h

00001 // Utility functions and defines that won't fit in any other file
00002 
00003 #ifndef __UTIL_H_
00004 #define __UTIL_H_
00005 
00006 #include <SDL.h>
00007 #include <string>
00008 
00009 using namespace std;
00010 
00011 #include "infomenu.h"
00012 
00013 #ifdef __GCC__
00014 template <class T> T MIN(T a, T b) {return a<?b;};
00015 template <class T> T MAX(T a, T b) {return a>?b;};
00016 #else
00017 template <class T> T MIN(T a, T b) {return a<b ? a : b;};
00018 template <class T> T MAX(T a, T b) {return a>b ? a : b;};
00019 #endif
00020 
00021 #ifdef _MSC_VER // if the compiler is from Microsoft
00022 #define DIR_SEPARATOR "\\"
00023 #else
00024 #define DIR_SEPARATOR "/"
00025 #endif
00026 
00027 // Used to give more information about when and where an exception happens
00028 // $$$ Removed: there's no constructor for a string to show a number (solutions?)
00029 // $$$ Watch the try-catch block in main.cpp to see how to do this in the old-fashioned way.
00030 //
00031 //#define HANDLE_EXCEPTION(str) ((string(__FILE__)+',') + (string(__LINE__)+": ") + str)
00032 
00033 
00037 Uint32 getPixel(SDL_Surface* surface, int x, int y);
00038 void putPixel(SDL_Surface* surface, int x, int y, Uint32 color);
00039 
00040 /* 1. create a surface of src.w and src.h size
00041    2. copy the origin in the surface
00042    3. fill the pixels that has the mask color with the dest color
00043 */
00044 SDL_Surface* fillSurface(SDL_Surface* origin, SDL_Rect src,
00045                          Uint32 mask, Uint32 color);
00046 
00047 int charToInt(char c);
00048 char intToChar(int i);
00049 void perierror(string c);
00050 
00051 //const unsigned MAXPLAYERS = 20;
00052 //const unsigned MAXTOOLS = 10000;
00053 //const unsigned MAXBUILDINGS = 1000;
00054 
00055 
00056 /*
00057   Convert a SDL keysym to a char. If it is not a printable character
00058   it returns 0;
00059  */
00060 char keysym2char(SDL_keysym keysym);
00061 
00062 /* Load an image. */
00063 SDL_Surface* loadImage(string const & name, bool transparent=false);
00064 
00065 /* wait for a key press */
00066 void waitForKey();
00067 
00068 class Graphics;
00069 
00070 /* display an info modal message box */
00071 void infoMessage(string const& msg, Graphics& graphics);
00072 
00073 #endif

Generated on Thu Jun 6 17:22:20 2002 for Perihelion by doxygen1.2.15