aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--gui/console.cpp46
-rw-r--r--gui/console.h5
3 files changed, 48 insertions, 5 deletions
diff --git a/TODO b/TODO
index d0bf14b8ce..b91ce4f0b6 100644
--- a/TODO
+++ b/TODO
@@ -132,8 +132,6 @@ General
frequently gives the engine time to do these "other things".
* Default to saving games in $HOME if in savepath is not defined maybe something
like ~/Library/ScummVM/ for OS X and ~/.scummvm/ for everything else
-* Eye candy: make console sliding down and up when activated. Similiar to current
- SAGA engine console.
Build System
============
diff --git a/gui/console.cpp b/gui/console.cpp
index 43a6d5ca04..e78489347b 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -34,6 +34,9 @@ extern const Graphics::NewFont g_consolefont;
#define kConsoleCharWidth (g_consolefont.getMaxCharWidth())
#define kConsoleLineHeight (g_consolefont.getFontHeight() + 2)
+enum {
+ kConsoleSlideDownDuration = 300 // Time in milliseconds
+};
#define PROMPT ") "
@@ -62,6 +65,9 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent)
_caretVisible = false;
_caretTime = 0;
+ _slideUpAndClose = false;
+ _slideTime = 0;
+
// Add scrollbar
_scrollBar = new ScrollBarWidget(this, _w - kScrollBarWidth - 1, 0, kScrollBarWidth, _h);
_scrollBar->setTarget(this);
@@ -97,7 +103,21 @@ void ConsoleDialog::reflowLayout() {
_linesPerPage = (_h - 2) / kConsoleLineHeight;
}
+void ConsoleDialog::slideUpAndClose() {
+ if (!_slideUpAndClose) {
+ _slideTime = g_system->getMillis();
+ _slideUpAndClose = true;
+ }
+}
+
void ConsoleDialog::open() {
+ // Initiate sliding the console down. We do a very simple trick to achieve
+ // this effect: we simply move the console dialog just above (outside) the
+ // visible screen area, then shift it down in handleTickle() over a
+ // certain period of time.
+ _y = -_h;
+ _slideTime = g_system->getMillis();
+
Dialog::open();
if (_promptStartPos == -1) {
print(PROMPT);
@@ -144,6 +164,23 @@ void ConsoleDialog::handleTickle() {
_caretTime = time + kCaretBlinkTime;
drawCaret(_caretVisible);
}
+
+ // Perform the "slide animation".
+ if (_slideUpAndClose) {
+ _y = -(int)(_h * (float)(g_system->getMillis() - _slideTime) / kConsoleSlideDownDuration);
+ if (_y <= -_h) {
+ _slideUpAndClose = false;
+ close();
+ } else
+ draw();
+ } else
+ if (_y < 0) {
+ _y = -(int)(_h * (1.0 - (float)(g_system->getMillis() - _slideTime) / kConsoleSlideDownDuration));
+ if (_y > 0)
+ _y = 0;
+
+ draw();
+ }
}
void ConsoleDialog::handleMouseWheel(int x, int y, int direction) {
@@ -152,6 +189,9 @@ void ConsoleDialog::handleMouseWheel(int x, int y, int direction) {
void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
int i;
+
+ if (_slideUpAndClose)
+ return;
switch (keycode) {
case '\n': // enter/return
@@ -193,11 +233,11 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
draw();
if (!keepRunning)
- close();
+ slideUpAndClose();
break;
}
case 27: // escape
- close();
+ slideUpAndClose();
break;
case 8: // backspace
if (_caretVisible)
@@ -295,7 +335,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
break;
default:
if (ascii == '~' || ascii == '#') {
- close();
+ slideUpAndClose();
} else if (modifiers == OSystem::KBD_CTRL) {
specialKeys(keycode);
} else if (isprint((char)ascii)) {
diff --git a/gui/console.h b/gui/console.h
index 7b5cef34ce..49dae71c8b 100644
--- a/gui/console.h
+++ b/gui/console.h
@@ -58,6 +58,9 @@ protected:
bool _caretVisible;
uint32 _caretTime;
+
+ bool _slideUpAndClose;
+ uint32 _slideTime;
ScrollBarWidget *_scrollBar;
@@ -78,6 +81,8 @@ protected:
float _widthPercent, _heightPercent;
void reflowLayout();
+
+ void slideUpAndClose();
public:
ConsoleDialog(float widthPercent, float heightPercent);