{
if (event.type == SDL_KEYDOWN)
{
- Console::instance->toggle();
+ Console::current()->toggle();
}
}
- else if (Console::instance->hasFocus())
+ else if (Console::current()->hasFocus())
{
// if console is open: send key there
process_console_key_event(event);
void
KeyboardManager::process_text_input_event(const SDL_TextInputEvent& event)
{
- if (Console::instance->hasFocus()) {
+ if (Console::current()->hasFocus()) {
for(int i = 0; event.text[i] != '\0'; ++i)
{
- Console::instance->input(event.text[i]);
+ Console::current()->input(event.text[i]);
}
}
}
switch (event.keysym.sym) {
case SDLK_RETURN:
- Console::instance->enter();
+ Console::current()->enter();
break;
case SDLK_BACKSPACE:
- Console::instance->backspace();
+ Console::current()->backspace();
break;
case SDLK_TAB:
- Console::instance->autocomplete();
+ Console::current()->autocomplete();
break;
case SDLK_PAGEUP:
- Console::instance->scroll(-1);
+ Console::current()->scroll(-1);
break;
case SDLK_PAGEDOWN:
- Console::instance->scroll(+1);
+ Console::current()->scroll(+1);
break;
case SDLK_HOME:
- Console::instance->move_cursor(-65535);
+ Console::current()->move_cursor(-65535);
break;
case SDLK_END:
- Console::instance->move_cursor(+65535);
+ Console::current()->move_cursor(+65535);
break;
case SDLK_UP:
- Console::instance->show_history(-1);
+ Console::current()->show_history(-1);
break;
case SDLK_DOWN:
- Console::instance->show_history(+1);
+ Console::current()->show_history(+1);
break;
case SDLK_LEFT:
- Console::instance->move_cursor(-1);
+ Console::current()->move_cursor(-1);
break;
case SDLK_RIGHT:
- Console::instance->move_cursor(+1);
+ Console::current()->move_cursor(+1);
break;
default:
break;
#include <sstream>
#include <vector>
+#include "util/currenton.hpp"
#include "video/font_ptr.hpp"
#include "video/surface_ptr.hpp"
class ConsoleCommandReceiver;
class DrawingContext;
-class Console
+class Console : public Currenton<Console>
{
public:
Console();
~Console();
- static Console* instance;
-
static std::ostream output; /**< stream of characters to output to the console. Do not forget to send std::endl or to flush the stream. */
void init_graphics();
int sync()
{
int result = std::stringbuf::sync();
- if(Console::instance != NULL)
- Console::instance->flush(this);
+ if(Console::current())
+ Console::current()->flush(this);
return result;
}
};
}
init_sdl();
- Console::instance = new Console();
+ Console console;
timelog("controller");
g_input_manager = new InputManager();
timelog("audio");
init_audio();
- Console::instance->init_graphics();
+ Console::current()->init_graphics();
timelog("scripting");
scripting::init_squirrel(g_config->enable_script_debugger);
g_config = NULL;
delete g_input_manager;
g_input_manager = NULL;
- delete Console::instance;
- Console::instance = NULL;
scripting::exit_squirrel();
delete texture_manager;
texture_manager = NULL;
m_screen_fade->draw(context);
}
- Console::instance->draw(context);
+ Console::current()->draw(context);
if (g_config->show_fps)
{
m_screen_fade->update(elapsed_time);
}
- Console::instance->update(elapsed_time);
+ Console::current()->update(elapsed_time);
}
void
else if (event.key.keysym.sym == SDLK_F1 &&
event.key.keysym.mod & KMOD_CTRL)
{
- Console::instance->toggle();
+ Console::current()->toggle();
g_config->console_enabled = true;
g_config->save();
}