gcsx_debug.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* GCSx
  2. ** DEBUG.H
  3. **
  4. ** Debugging functions, including console I/O
  5. */
  6. /*****************************************************************************
  7. ** Copyright (C) 2003-2006 Janson
  8. **
  9. ** This program is free software; you can redistribute it and/or modify
  10. ** it under the terms of the GNU General Public License as published by
  11. ** the Free Software Foundation; either version 2 of the License, or
  12. ** (at your option) any later version.
  13. **
  14. ** This program is distributed in the hope that it will be useful,
  15. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ** GNU General Public License for more details.
  18. **
  19. ** You should have received a copy of the GNU General Public License
  20. ** along with this program; if not, write to the Free Software
  21. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  22. *****************************************************************************/
  23. #ifndef __GCSx_DEBUG_H_
  24. #define __GCSx_DEBUG_H_
  25. // Debugging console
  26. class DebugWin : public EditBox {
  27. public:
  28. enum {
  29. MAX_COMMAND_HISTORY = 99,
  30. };
  31. std::vector<std::string> commandHistory;
  32. protected:
  33. unsigned int commandHistoryPosition;
  34. int newCommand;
  35. void updateTitlebar();
  36. void prepOpen();
  37. void paintText(const std::string& text, const std::string& entireLine, int posInLine, int x, int y, SDL_Surface* destSurface, int isSelected = 0) const;
  38. void selectAllConsole();
  39. void cursorToStart(int drag = 0);
  40. void cursorToEnd(int drag = 0);
  41. public:
  42. DebugWin();
  43. virtual ~DebugWin();
  44. void init() { fillLineMap(); }
  45. int event(int hasFocus, const SDL_Event* event);
  46. int wantsToBeDeleted() const;
  47. void addLine(const char* text);
  48. };
  49. // Init buffer can happen early; window requires GUI elements in place
  50. void initDebugBuffer();
  51. void initDebugWindow();
  52. void beginExitStage();
  53. void exitDebug();
  54. DebugWin* debugWindow();
  55. // Output debugging text
  56. int debugLevel(int newLevel = -1);
  57. void debugWrite(int level, const char* text, ...);
  58. void debugWrite(const char* text, ...);
  59. void debugStdout(int level, const char* text, ...);
  60. void debugStdout(const char* text, ...);
  61. void debugDump(const void* data, int size, int toStdOut = 0);
  62. void debugClear();
  63. // Popup an error box outside of our GUI (@TODO: currently on Win32 only)
  64. void systemErrorBox(const char* text, const char* title = NULL);
  65. // Basic error/msg dialogs, using our GUI
  66. // OK only
  67. void guiErrorBox(const std::string& text, const std::string& title);
  68. // OK/Cancel
  69. int guiConfirmBox(const std::string& text, const std::string& title);
  70. // One to five buttons of your choice, returns 1 to 5; ESC returns 0
  71. int guiMessageBox(const std::string& text, const std::string& title, const std::string* buttonA, const std::string* buttonB = NULL, const std::string* buttonC = NULL, const std::string* buttonD = NULL, const std::string* buttonE = NULL);
  72. // OK only, with [ ] Don't show this warning again
  73. // returns true to disable warning
  74. int guiRemindBox(const std::string& text, const std::string& title);
  75. // Error box titles and some standard strings
  76. extern const std::string errorTitleInvalidEntry;
  77. extern const std::string errorTitleVideo;
  78. extern const std::string errorTitleException;
  79. extern const std::string errorTitleImageOverflow;
  80. extern const std::string errorTitleResourceLoad;
  81. extern const std::string errorTitleFile;
  82. extern const std::string errorTitleImport;
  83. extern const std::string errorTitleDuplicateName;
  84. extern const std::string errorTitleMissingName;
  85. extern const std::string errorTitleInUse;
  86. extern const std::string warnTitleReminder;
  87. extern const std::string messageBoxYes;
  88. extern const std::string messageBoxNo;
  89. extern const std::string messageBoxOK;
  90. extern const std::string messageBoxCancel;
  91. extern const std::string messageBoxReminder;
  92. #endif