diff options
-rw-r--r-- | scumm/dialogs.cpp | 47 | ||||
-rw-r--r-- | scumm/dialogs.h | 11 | ||||
-rw-r--r-- | scumm/scumm.h | 2 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 15 |
4 files changed, 69 insertions, 6 deletions
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index eae5d22305..16b8cc21ba 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -665,12 +665,55 @@ void InfoDialog::setInfoText(const String& message) #pragma mark - +PauseDialog::PauseDialog(NewGui *gui, Scumm *scumm) + : InfoDialog(gui, scumm, 10) +{ +} #pragma mark - -PauseDialog::PauseDialog(NewGui *gui, Scumm *scumm) - : InfoDialog(gui, scumm, 10) +DebuggerDialog::DebuggerDialog(NewGui *gui, Scumm *scumm, int width, int height) + : ScummDialog(gui, scumm, 0, 0, width, height) +{ + draw(); +} + +void DebuggerDialog::drawDialog() { + //int history_len = cmd_history.size(); + + // Draw box and border + _gui->blendRect(_x, _y, _w, _h, _gui->_bgcolor); + /*_gui->line(_x, _y, _x, _h, _gui->_color); + _gui->line(_w, _y, _w, _y, _gui->_color); + _gui->line(_x, _h, _w, _h, _gui->_shadowcolor);*/ + + _gui->addDirtyRect(_x, _y, _w, _h); + + // Draw items + // ... history_len - ((_h / kLineHeight) * _page) +} + +void DebuggerDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { + if ((ascii == '~') || (keycode == 27)) { // Total abort on tilde or escape + close(); + return; + } else if (ascii == '\r' || ascii == '\n') { // Run command on enter/newline + // TODO: Add some kind of pop() method to StringList, + // so we can remove old obsolete entries and not waste memory + cmd_history.push_back(cmd_current); + // _scumm.debugger.parseCommand(cmd_current, (void*)this.printCallback); + cmd_current.clear(); + draw(); + } else if (keycode == 8) { // Backspace + cmd_current.deleteLastChar(); + draw(); + } else if ((keycode >= 31) && (keycode <= 122)) { // Printable ASCII, add to string + cmd_current+=(char)ascii; + draw(); + } else { + debug(2, "Unhandled keycode from DebuggerDialog: %d\n", keycode); + } } #ifdef _WIN32_WCE diff --git a/scumm/dialogs.h b/scumm/dialogs.h index abe21082d2..4a0f27b22b 100644 --- a/scumm/dialogs.h +++ b/scumm/dialogs.h @@ -134,6 +134,17 @@ public: PauseDialog(NewGui *gui, Scumm *scumm); }; +class DebuggerDialog : public ScummDialog { +protected: + ScummVM::StringList cmd_history; + String cmd_current; + +public: + DebuggerDialog(NewGui *gui, Scumm *scumm, int width, int height); + virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); + virtual void drawDialog(); +}; + #ifdef _WIN32_WCE class KeysDialog : public ScummDialog { diff --git a/scumm/scumm.h b/scumm/scumm.h index 9978f8913a..424fde2573 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -337,11 +337,13 @@ public: Dialog *_pauseDialog; Dialog *_optionsDialog; Dialog *_saveLoadDialog; + Dialog *_debuggerDialog; int runDialog(Dialog *dialog); void pauseDialog(); void saveloadDialog(); void optionsDialog(); + void debuggerDialog(); void displayError(const char *message, ...); // Misc startup/event functions diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 437fda4a17..7b77c9a176 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -988,10 +988,8 @@ int Scumm::runDialog(Dialog *dialog) void Scumm::pauseDialog() { - if (!_pauseDialog) { + if (!_pauseDialog) _pauseDialog = new PauseDialog(_newgui, this); - } - runDialog(_pauseDialog); } @@ -1002,6 +1000,13 @@ void Scumm::saveloadDialog() runDialog(_saveLoadDialog); } +void Scumm::debuggerDialog() +{ + if (!_debuggerDialog) + _debuggerDialog = new DebuggerDialog(_newgui, this, _realWidth, _realHeight / 5); + runDialog(_debuggerDialog); +} + void Scumm::optionsDialog() { if (!_optionsDialog) @@ -1130,7 +1135,9 @@ void Scumm::processKbd() _defaultTalkDelay = 5; _vars[VAR_CHARINC] = _defaultTalkDelay / 20; - } + } else if (_lastKeyHit == '~') { // Debug console + debuggerDialog(); + } _mouseButStat = _lastKeyHit; } |