projects
/
supertux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c946dc6
)
Made Console into a Currenton
author
Ingo Ruhnke
<grumbel@gmail.com>
Sun, 17 Aug 2014 17:05:07 +0000
(19:05 +0200)
committer
Ingo Ruhnke
<grumbel@gmail.com>
Sun, 17 Aug 2014 20:34:30 +0000
(22:34 +0200)
src/control/keyboard_manager.cpp
patch
|
blob
|
history
src/supertux/console.cpp
patch
|
blob
|
history
src/supertux/console.hpp
patch
|
blob
|
history
src/supertux/main.cpp
patch
|
blob
|
history
src/supertux/screen_manager.cpp
patch
|
blob
|
history
src/util/log.cpp
patch
|
blob
|
history
diff --git
a/src/control/keyboard_manager.cpp
b/src/control/keyboard_manager.cpp
index
0fe55b6
..
32c947a
100644
(file)
--- a/
src/control/keyboard_manager.cpp
+++ b/
src/control/keyboard_manager.cpp
@@
-69,10
+69,10
@@
KeyboardManager::process_key_event(const SDL_KeyboardEvent& event)
{
if (event.type == SDL_KEYDOWN)
{
{
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);
{
// if console is open: send key there
process_console_key_event(event);
@@
-102,10
+102,10
@@
KeyboardManager::process_key_event(const SDL_KeyboardEvent& event)
void
KeyboardManager::process_text_input_event(const SDL_TextInputEvent& 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)
{
for(int i = 0; event.text[i] != '\0'; ++i)
{
- Console::
instance
->input(event.text[i]);
+ Console::
current()
->input(event.text[i]);
}
}
}
}
}
}
@@
-117,37
+117,37
@@
KeyboardManager::process_console_key_event(const SDL_KeyboardEvent& event)
switch (event.keysym.sym) {
case SDLK_RETURN:
switch (event.keysym.sym) {
case SDLK_RETURN:
- Console::
instance
->enter();
+ Console::
current()
->enter();
break;
case SDLK_BACKSPACE:
break;
case SDLK_BACKSPACE:
- Console::
instance
->backspace();
+ Console::
current()
->backspace();
break;
case SDLK_TAB:
break;
case SDLK_TAB:
- Console::
instance
->autocomplete();
+ Console::
current()
->autocomplete();
break;
case SDLK_PAGEUP:
break;
case SDLK_PAGEUP:
- Console::
instance
->scroll(-1);
+ Console::
current()
->scroll(-1);
break;
case SDLK_PAGEDOWN:
break;
case SDLK_PAGEDOWN:
- Console::
instance
->scroll(+1);
+ Console::
current()
->scroll(+1);
break;
case SDLK_HOME:
break;
case SDLK_HOME:
- Console::
instance
->move_cursor(-65535);
+ Console::
current()
->move_cursor(-65535);
break;
case SDLK_END:
break;
case SDLK_END:
- Console::
instance
->move_cursor(+65535);
+ Console::
current()
->move_cursor(+65535);
break;
case SDLK_UP:
break;
case SDLK_UP:
- Console::
instance
->show_history(-1);
+ Console::
current()
->show_history(-1);
break;
case SDLK_DOWN:
break;
case SDLK_DOWN:
- Console::
instance
->show_history(+1);
+ Console::
current()
->show_history(+1);
break;
case SDLK_LEFT:
break;
case SDLK_LEFT:
- Console::
instance
->move_cursor(-1);
+ Console::
current()
->move_cursor(-1);
break;
case SDLK_RIGHT:
break;
case SDLK_RIGHT:
- Console::
instance
->move_cursor(+1);
+ Console::
current()
->move_cursor(+1);
break;
default:
break;
break;
default:
break;
diff --git
a/src/supertux/console.cpp
b/src/supertux/console.cpp
index
523ffd7
..
8686390
100644
(file)
--- a/
src/supertux/console.cpp
+++ b/
src/supertux/console.cpp
@@
-522,7
+522,6
@@
Console::draw(DrawingContext& context)
context.pop_transform();
}
context.pop_transform();
}
-Console* Console::instance = NULL;
int Console::inputBufferPosition = 0;
std::string Console::inputBuffer;
ConsoleStreamBuffer Console::outputBuffer;
int Console::inputBufferPosition = 0;
std::string Console::inputBuffer;
ConsoleStreamBuffer Console::outputBuffer;
diff --git
a/src/supertux/console.hpp
b/src/supertux/console.hpp
index
9c60898
..
e8599ca
100644
(file)
--- a/
src/supertux/console.hpp
+++ b/
src/supertux/console.hpp
@@
-23,6
+23,7
@@
#include <sstream>
#include <vector>
#include <sstream>
#include <vector>
+#include "util/currenton.hpp"
#include "video/font_ptr.hpp"
#include "video/surface_ptr.hpp"
#include "video/font_ptr.hpp"
#include "video/surface_ptr.hpp"
@@
-31,14
+32,12
@@
class ConsoleStreamBuffer;
class ConsoleCommandReceiver;
class DrawingContext;
class ConsoleCommandReceiver;
class DrawingContext;
-class Console
+class Console
: public Currenton<Console>
{
public:
Console();
~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();
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();
@@
-113,8
+112,8
@@
public:
int sync()
{
int result = std::stringbuf::sync();
int sync()
{
int result = std::stringbuf::sync();
- if(Console::
instance != NULL
)
- Console::
instance
->flush(this);
+ if(Console::
current()
)
+ Console::
current()
->flush(this);
return result;
}
};
return result;
}
};
diff --git
a/src/supertux/main.cpp
b/src/supertux/main.cpp
index
376e5ee
..
7054f37
100644
(file)
--- a/
src/supertux/main.cpp
+++ b/
src/supertux/main.cpp
@@
-328,7
+328,7
@@
Main::run(int argc, char** argv)
}
init_sdl();
}
init_sdl();
- Console
::instance = new Console()
;
+ Console
console
;
timelog("controller");
g_input_manager = new InputManager();
timelog("controller");
g_input_manager = new InputManager();
@@
-345,7
+345,7
@@
Main::run(int argc, char** argv)
timelog("audio");
init_audio();
timelog("audio");
init_audio();
- Console::
instance
->init_graphics();
+ Console::
current()
->init_graphics();
timelog("scripting");
scripting::init_squirrel(g_config->enable_script_debugger);
timelog("scripting");
scripting::init_squirrel(g_config->enable_script_debugger);
@@
-421,8
+421,6
@@
Main::run(int argc, char** argv)
g_config = NULL;
delete g_input_manager;
g_input_manager = NULL;
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;
scripting::exit_squirrel();
delete texture_manager;
texture_manager = NULL;
diff --git
a/src/supertux/screen_manager.cpp
b/src/supertux/screen_manager.cpp
index
ea716ce
..
f680e7a
100644
(file)
--- a/
src/supertux/screen_manager.cpp
+++ b/
src/supertux/screen_manager.cpp
@@
-137,7
+137,7
@@
ScreenManager::draw(DrawingContext& context)
m_screen_fade->draw(context);
}
m_screen_fade->draw(context);
}
- Console::
instance
->draw(context);
+ Console::
current()
->draw(context);
if (g_config->show_fps)
{
if (g_config->show_fps)
{
@@
-184,7
+184,7
@@
ScreenManager::update_gamelogic(float elapsed_time)
m_screen_fade->update(elapsed_time);
}
m_screen_fade->update(elapsed_time);
}
- Console::
instance
->update(elapsed_time);
+ Console::
current()
->update(elapsed_time);
}
void
}
void
@@
-234,7
+234,7
@@
ScreenManager::process_events()
else if (event.key.keysym.sym == SDLK_F1 &&
event.key.keysym.mod & KMOD_CTRL)
{
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();
}
g_config->console_enabled = true;
g_config->save();
}
diff --git
a/src/util/log.cpp
b/src/util/log.cpp
index
cb8ed6d
..
0b30709
100644
(file)
--- a/
src/util/log.cpp
+++ b/
src/util/log.cpp
@@
-26,7
+26,7
@@
LogLevel g_log_level = LOG_WARNING;
static std::ostream& get_logging_instance (void)
{
static std::ostream& get_logging_instance (void)
{
- if (Console::
instance != NULL
)
+ if (Console::
current()
)
return (Console::output);
else
return (std::cerr);
return (Console::output);
else
return (std::cerr);