123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- /* GCSx
- ** DEBUG.H
- **
- ** Debugging functions, including console I/O
- */
- /*****************************************************************************
- ** Copyright (C) 2003-2006 Janson
- **
- ** 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, USA.
- *****************************************************************************/
- #ifndef __GCSx_DEBUG_H_
- #define __GCSx_DEBUG_H_
- // Debugging console
- class DebugWin : public EditBox {
- public:
- enum {
- MAX_COMMAND_HISTORY = 99,
- };
- std::vector<std::string> commandHistory;
-
- protected:
- unsigned int commandHistoryPosition;
- int newCommand;
- void updateTitlebar();
- void prepOpen();
- void paintText(const std::string& text, const std::string& entireLine, int posInLine, int x, int y, SDL_Surface* destSurface, int isSelected = 0) const;
- void selectAllConsole();
- void cursorToStart(int drag = 0);
- void cursorToEnd(int drag = 0);
- public:
- DebugWin();
- virtual ~DebugWin();
- void init() { fillLineMap(); }
- int event(int hasFocus, const SDL_Event* event);
- int wantsToBeDeleted() const;
- void addLine(const char* text);
- };
- // Init buffer can happen early; window requires GUI elements in place
- void initDebugBuffer();
- void initDebugWindow();
- void beginExitStage();
- void exitDebug();
- DebugWin* debugWindow();
- // Output debugging text
- int debugLevel(int newLevel = -1);
- void debugWrite(int level, const char* text, ...);
- void debugWrite(const char* text, ...);
- void debugStdout(int level, const char* text, ...);
- void debugStdout(const char* text, ...);
- void debugDump(const void* data, int size, int toStdOut = 0);
- void debugClear();
- // Popup an error box outside of our GUI (@TODO: currently on Win32 only)
- void systemErrorBox(const char* text, const char* title = NULL);
- // Basic error/msg dialogs, using our GUI
- // OK only
- void guiErrorBox(const std::string& text, const std::string& title);
- // OK/Cancel
- int guiConfirmBox(const std::string& text, const std::string& title);
- // One to five buttons of your choice, returns 1 to 5; ESC returns 0
- 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);
- // OK only, with [ ] Don't show this warning again
- // returns true to disable warning
- int guiRemindBox(const std::string& text, const std::string& title);
- // Error box titles and some standard strings
- extern const std::string errorTitleInvalidEntry;
- extern const std::string errorTitleVideo;
- extern const std::string errorTitleException;
- extern const std::string errorTitleImageOverflow;
- extern const std::string errorTitleResourceLoad;
- extern const std::string errorTitleFile;
- extern const std::string errorTitleImport;
- extern const std::string errorTitleDuplicateName;
- extern const std::string errorTitleMissingName;
- extern const std::string errorTitleInUse;
- extern const std::string warnTitleReminder;
- extern const std::string messageBoxYes;
- extern const std::string messageBoxNo;
- extern const std::string messageBoxOK;
- extern const std::string messageBoxCancel;
- extern const std::string messageBoxReminder;
- #endif
|