highscore now working
- added ControllerBase::EnableTextinput() for setting up unicode and key repetitions - added new state GameStateEnterPlayerName
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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
@@ -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 {
|
||||
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user