From: Christoph Sommer Date: Sun, 9 Apr 2006 01:23:04 +0000 (+0000) Subject: Subtle animation of Console background / X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=93c6baa28d9373e797aa969352f0523556b049eb;p=supertux.git Subtle animation of Console background / Console wraps long lines / Implemented "quit" command for GameSession SVN-Revision: 3277 --- diff --git a/data/images/engine/console2.png b/data/images/engine/console2.png new file mode 100644 index 000000000..b89a7e24a Binary files /dev/null and b/data/images/engine/console2.png differ diff --git a/src/console.cpp b/src/console.cpp index 8f590bbaa..32c115036 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -33,11 +33,13 @@ namespace { Console::Console() { background = new Surface("images/engine/console.png"); + background2 = new Surface("images/engine/console2.png"); } Console::~Console() { delete background; + delete background2; } void @@ -107,14 +109,18 @@ Console::autocomplete() void Console::addLine(std::string s) { + std::cerr << s << std::endl; + while (s.length() > 99) { + lines.push_front(s.substr(0, 99-3)+"..."); + s = "..."+s.substr(99-3); + } lines.push_front(s); - if (lines.size() >= 65535) lines.pop_back(); + while (lines.size() >= 65535) lines.pop_back(); if (height < 64) { if (height < 4+9) height=4+9; height+=9; } ticks=60; - std::cerr << s << std::endl; } void @@ -178,7 +184,11 @@ Console::draw(DrawingContext& context) if (height == 0) return; } + context.draw_surface(background2, Vector(SCREEN_WIDTH/2 - background->get_width()/2 - background->get_width() + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1); + context.draw_surface(background2, Vector(SCREEN_WIDTH/2 - background->get_width()/2 + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1); context.draw_surface(background, Vector(SCREEN_WIDTH/2 - background->get_width()/2, height - background->get_height()), LAYER_FOREGROUND1+1); + backgroundOffset+=10; + if (backgroundOffset > (int)background->get_width()) backgroundOffset -= (int)background->get_width(); int lineNo = 0; @@ -229,4 +239,5 @@ ConsoleStreamBuffer Console::outputBuffer; std::ostream Console::input(&Console::inputBuffer); std::ostream Console::output(&Console::outputBuffer); int Console::offset = 0; +int Console::backgroundOffset = 0; diff --git a/src/console.hpp b/src/console.hpp index 53267b34c..98571ab23 100644 --- a/src/console.hpp +++ b/src/console.hpp @@ -58,6 +58,8 @@ class Console static std::list lines; /**< backbuffer of lines sent to the console */ static std::map > commands; /**< map of console commands and a list of associated ConsoleCommandReceivers */ Surface* background; /**< console background image */ + Surface* background2; /**< second, moving console background image */ + static int backgroundOffset; /**< current offset of scrolling background image */ static int height; /**< height of the console in px */ static int offset; /**< decrease to scroll text up */ static bool focused; /**< true if console has input focus */ diff --git a/src/game_session.cpp b/src/game_session.cpp index 9e458bf0e..35c482969 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -437,7 +437,7 @@ GameSession::consoleCommand(std::string command) return true; } if (command == "quit") { - msg_info << "Please implement me! :-)" << std::endl; + main_loop->quit(); return true; }