highscore now working

- added ControllerBase::EnableTextinput() for setting up unicode and key repetitions
- added new state GameStateEnterPlayerName
This commit is contained in:
2010-07-15 22:47:17 +02:00
parent 38096a4502
commit 91cdebd33a
11 changed files with 150 additions and 28 deletions
+11
View File
@@ -130,6 +130,17 @@ void ControllerBase::ProcessEvents () {
}
}
/** \brief Activates or deactivates unicode processing and key delays of the keyboard inputs */
void ControllerBase::EnableTextinput (bool textinput_state) {
if (textinput_state) {
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(500, 50);
} else {
SDL_EnableUNICODE(-1);
SDL_EnableKeyRepeat(0, 100);
}
}
/** \brief Keyboard processing */
bool ControllerBase::OnKeyDown (const SDL_keysym &keysym) {
if (mView->mOverlayManager.SendKeyDown (keysym))
+3
View File
@@ -44,6 +44,9 @@ class ControllerBase : public Module {
}
bool BindKey (int key, const char *command);
/** \brief Activates or deactivates unicode processing and key delays of the keyboard inputs */
void EnableTextinput (bool textinput_state);
protected:
/** \brief Initializes the system */
virtual int OnInit (int argc, char* argv[]);
+1 -1
View File
@@ -27,7 +27,7 @@
* have to know the number of bits that are to be reserved in advance so this
* is hard coded into the library for now.
*/
#define ENTITY_CONTROLLER_MAX_KEY_STATES 64
const int EntityControllerMaxKeyStates = 64;
namespace Engine {
+3 -3
View File
@@ -5,20 +5,20 @@
namespace Engine {
bool EntityControllerState::GetKey (int state) {
assert (state < ENTITY_CONTROLLER_MAX_KEY_STATES && state >= 0);
assert (state < EntityControllerMaxKeyStates && state >= 0);
return mKeyState.test (state);
}
void EntityControllerState::SetKey (int state) {
assert (state < ENTITY_CONTROLLER_MAX_KEY_STATES && state >= 0);
assert (state < EntityControllerMaxKeyStates && state >= 0);
LogDebug ("Setting Entity Key State %d", state);
mKeyState.set (state);
}
void EntityControllerState::UnsetKey (int state) {
assert (state < ENTITY_CONTROLLER_MAX_KEY_STATES && state >= 0);
assert (state < EntityControllerMaxKeyStates && state >= 0);
LogDebug ("Unsetting Entity Key State %d", state);
mKeyState.reset (state);
+1 -1
View File
@@ -100,7 +100,7 @@ struct EntityPhysicState {
* \todo [Low] The current design is very unflexible. Is there a better way?
*/
struct EntityControllerState {
std::bitset<ENTITY_CONTROLLER_MAX_KEY_STATES> mKeyState;
std::bitset<EntityControllerMaxKeyStates> mKeyState;
bool GetKey (int state);
void SetKey (int state);
+4 -3
View File
@@ -1,6 +1,7 @@
#include "DrawingsGL.h"
#include "OverlayBase.h"
#include "SimpleConsoleOverlay.h"
#include "ControllerBase.h"
#include "OGLFT.h"
@@ -16,10 +17,10 @@ bool SimpleConsoleOverlay::OnKeyDown (const SDL_keysym &keysym) {
if (mActive) {
// We have to call SetActive() to actually
// activate the unicode processing of SDL
SetActive (false);
EngineGetController()->EnableTextinput(false);
}
else {
SetActive (true);
EngineGetController()->EnableTextinput(true);
}
return true;
@@ -31,7 +32,7 @@ bool SimpleConsoleOverlay::OnKeyDown (const SDL_keysym &keysym) {
// check for input that requires actions
switch (keysym.sym) {
case SDLK_ESCAPE:
SetActive (false);
EngineGetController()->EnableTextinput(false);
return true;
break;
case SDLK_BACKSPACE: