home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / Console.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-06  |  3.0 KB  |  88 lines

  1. #ifndef __Console_h__
  2. #define __Console_h__
  3.  
  4. #include "stdio.h"
  5.  
  6. #define CON_MAX_CVARS 128
  7. #define CON_MAX_CCMDS 128
  8. #define CON_MAX_ALIASES 128
  9.  
  10. //#define CON_FLAG_READ                0x0001
  11. //#define CON_FLAG_WRITE                0x0002
  12. //#define CON_FLAG_EXECUTE            0x0004
  13. //
  14. //#define CON_FLAG_CLIENT_READ        0x0001
  15. //#define CON_FLAG_CLIENT_WRITE        0x0002
  16. //#define CON_FLAG_CLIENT_EXECUTE        0x0004
  17. //
  18. //#define CON_FLAG_SERVER_READ        0x0008
  19. //#define CON_FLAG_SERVER_WRITE        0x000f
  20. //#define CON_FLAG_SERVER_EXECUTE        0x0010
  21.  
  22. #define CON_FLAG_SYSTEM                0x0001
  23. #define CON_FLAG_USER                0x0002
  24. #define CON_FLAG_READ_ONLY            0x0004
  25.  
  26. #define CON_FLAG_ALL_SET            0xffff
  27. #define CON_FLAG_NONE_SET            0x0000
  28.  
  29. #define CON_MAX_LINES            1024
  30. #define CON_MAX_HISTORY_LINES    256
  31. #define CON_MAX_STRING_LENGTH    256
  32.  
  33.  
  34. class CVar;
  35. class CCmd;
  36. class CAlias;
  37.  
  38. class Console{
  39. public:
  40.     CVar* cVars[CON_MAX_CVARS];        /* list with all registered cvars */
  41.     CCmd* cCmds[CON_MAX_CCMDS];        /* list with all registered ccmds */
  42.     CAlias* aliases[CON_MAX_ALIASES]; /* list with all registered aliases */
  43.     char* lines[CON_MAX_LINES];        /* array that holds ALL in-/output */
  44. //    char* historyLines[CON_MAX_HISTORY_LINES];    /* input history */
  45.  
  46.     unsigned short accessFlags;        // THINKABOUTME: private?
  47.  
  48.     Console();            /* */
  49.     ~Console();            /* */
  50.     
  51.     void input(const char* inputStr);                /*  */
  52.     void print(const char* formatString,...);        /* prints a format string on the console */
  53.     bool parse(const char* parseStr);                /* parses a string (i.e. executes the ccmds stored in it)*/
  54.     void clear();                                    /* clears all console lines (output) */
  55. //    void clearHistory();                            /* clears input history */
  56.  
  57.     bool registerCVar(CVar *cVar);                    /* registers a CVar; after that the console can work with it. */
  58.     bool unregisterCVar(CVar *cVar);                /* this takes a CVar 'out of' the console (i.e. it is not known any more) */
  59.     bool deleteCVar(CVar *cVar);                    /* this really DELETES a CVar completely */
  60.     CVar* getCVar(const char* name);                /* returns the CVar named 'name' or NULL if none exists */
  61.     bool registerCCmd(CCmd *cCmd);                    /* the following function do the same as their CVar counterparts */
  62.     bool unregisterCCmd(CCmd *cCmd);
  63.     bool deleteCCmd(CCmd *cCmd);
  64.     CCmd* getCCmd(const char* name);
  65.     bool registerAlias(CAlias *alias);                    /* the following function do the same as their CVar counterparts */
  66.     bool unregisterAlias(CAlias *alias);
  67.     bool deleteAlias(CAlias *alias);
  68.     CAlias* getAlias(const char* name);
  69.  
  70.     bool hasAccessToCVar(CVar* cVar, unsigned int desiredAccess);    /* checks whether or not the console has acces to a CVar */
  71.     bool hasAccessToCCmd(CCmd* cCmd, unsigned int desiredAccess);    /* dito */
  72.  
  73.     bool logOutput;
  74.  
  75.     void startLog(const char* filename);
  76.     void endLog();
  77.  
  78. protected:
  79.     FILE* logFile;
  80.  
  81.     void appendLine(const char* line);                    /* appends a line to the consoles output */
  82. //    void appendHistoryLine(const char* line);            /* appends a line to the consoles input history */
  83. };
  84.  
  85. extern Console* console;
  86.  
  87. #endif    /* __Console_h__ */
  88.