diff options
-rw-r--r-- | gui/console.cpp | 35 | ||||
-rw-r--r-- | gui/console.h | 7 | ||||
-rw-r--r-- | scumm/debugger.cpp | 2 |
3 files changed, 32 insertions, 12 deletions
diff --git a/gui/console.cpp b/gui/console.cpp index 53fdeba312..8c381e485a 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -34,10 +34,12 @@ * to erase a single character, do scrolling etc. * - a *lot* of others things, this code is in no way complete and heavily under progress */ -ConsoleDialog::ConsoleDialog(NewGui *gui, int _realWidth) - : Dialog(gui, 0, 0, _realWidth, 12 * kLineHeight + 2) { - _lineWidth = (_w - kScrollBarWidth - 2) / kCharWidth; - _linesPerPage = (_h - 2) / kLineHeight; +ConsoleDialog::ConsoleDialog(NewGui *gui, float widthPercent, float heightPercent) + : Dialog(gui, 0, 0, 1, 1), + _widthPercent(widthPercent), _heightPercent(heightPercent) { + + // Setup basic layout/dialog size + reflowLayout(); memset(_buffer, ' ', kBufferSize); _linesInBuffer = kBufferSize / _lineWidth; @@ -52,12 +54,6 @@ ConsoleDialog::ConsoleDialog(NewGui *gui, int _realWidth) _scrollBar = new ScrollBarWidget(this, _w - kScrollBarWidth - 1, 0, kScrollBarWidth, _h); _scrollBar->setTarget(this); - // Display greetings & prompt - print(gScummVMFullVersion); - print("\nConsole is ready\n"); - - _promptStartPos = _promptEndPos = -1; - // Init callback _callbackProc = 0; _callbackRefCon = 0; @@ -68,6 +64,25 @@ ConsoleDialog::ConsoleDialog(NewGui *gui, int _realWidth) _historySize = 0; for (int i = 0; i < kHistorySize; i++) _history[i][0] = '\0'; + + // Display greetings & prompt + print(gScummVMFullVersion); + print("\nConsole is ready\n"); + + _promptStartPos = _promptEndPos = -1; +} + +void ConsoleDialog::reflowLayout() { + // Calculate the real width/height (rounded to char/line multiples + _w = (uint16)(_widthPercent * g_system->get_overlay_width()); +// _w = (_widthPercent * g_system->get_overlay_width() - kScrollBarWidth - 2) / kCharWidth; +// _w = _w * kCharWidth + kScrollBarWidth + 2; + _h = (uint16)((_heightPercent * g_system->get_overlay_height() - 2) / kLineHeight); + _h = _h * kLineHeight + 2; + + // Calculate depending values + _lineWidth = (_w - kScrollBarWidth - 2) / kCharWidth; + _linesPerPage = (_h - 2) / kLineHeight; } void ConsoleDialog::open() { diff --git a/gui/console.h b/gui/console.h index 4af9eafd2e..27db2df681 100644 --- a/gui/console.h +++ b/gui/console.h @@ -72,9 +72,14 @@ protected: int _historySize; int _historyIndex; int _historyLine; + + + float _widthPercent, _heightPercent; + + void reflowLayout(); public: - ConsoleDialog(NewGui *gui, int _realWidth); + ConsoleDialog(NewGui *gui, float widthPercent, float heightPercent); void open(); void drawDialog(); diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index 700d285d04..8f49b6dd25 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -200,7 +200,7 @@ void ScummDebugger::DCmd_Register(const char *cmdname, DebugProc pointer) { void ScummDebugger::enter() { #if USE_CONSOLE if (!_s->_debuggerDialog) { - _s->_debuggerDialog = new ConsoleDialog(_s->_newgui, _s->_screenWidth); + _s->_debuggerDialog = new ConsoleDialog(_s->_newgui, 1.0, 0.67); Debug_Printf("Debugger started, type 'exit' to return to the game.\n"); Debug_Printf("Type 'help' to see a little list of commands and variables.\n"); |