- loads of changes in order to prepare for better input (not using char but SDLKey instead)
This commit is contained in:
parent
5f32d56b85
commit
4b6bc7a4a7
|
@ -52,14 +52,23 @@ void ChatManager::init(Console* console, int thisTeamIndex, const bool inMenu, s
|
|||
this->manualPlayerNameOverride = manualPlayerNameOverride;
|
||||
}
|
||||
|
||||
void ChatManager::keyUp(char key) {
|
||||
void ChatManager::setDisableTeamMode(bool value) {
|
||||
disableTeamMode = value;
|
||||
|
||||
if(disableTeamMode == true) {
|
||||
teamMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatManager::keyUp(SDL_KeyboardEvent key) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
try {
|
||||
if(editEnabled) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
if(key == vkEscape || key == SDLK_ESCAPE) {
|
||||
//if(key == vkEscape || key == SDLK_ESCAPE) {
|
||||
if(isKeyPressed(SDLK_ESCAPE,key) == true) {
|
||||
text.clear();
|
||||
editEnabled= false;
|
||||
}
|
||||
|
@ -74,16 +83,8 @@ void ChatManager::keyUp(char key) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void ChatManager::setDisableTeamMode(bool value) {
|
||||
disableTeamMode = value;
|
||||
|
||||
if(disableTeamMode == true) {
|
||||
teamMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatManager::keyDown(char key) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
void ChatManager::keyDown(SDL_KeyboardEvent key) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
try {
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -91,8 +92,9 @@ void ChatManager::keyDown(char key) {
|
|||
|
||||
//toggle team mode
|
||||
if(editEnabled == false && disableTeamMode == false &&
|
||||
key == configKeys.getCharKey("ChatTeamMode")) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
//key == configKeys.getCharKey("ChatTeamMode")) {
|
||||
isKeyPressed(configKeys.getSDLKey("ChatTeamMode"),key) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
if (!inMenu) {
|
||||
if (teamMode == true) {
|
||||
|
@ -101,26 +103,25 @@ void ChatManager::keyDown(char key) {
|
|||
"All"));
|
||||
} else {
|
||||
teamMode = true;
|
||||
console->addLine(lang.get("ChatMode") + ": " + lang.get(
|
||||
"Team"));
|
||||
console->addLine(lang.get("ChatMode") + ": " + lang.get("Team"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(key==vkReturn){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
//if(key==vkReturn) {
|
||||
if(isKeyPressed(SDLK_RETURN,key) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
SDL_keysym keystate = Window::getKeystate();
|
||||
if(keystate.mod & (KMOD_LALT | KMOD_RALT)){
|
||||
// alt+enter is ignored
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
if(editEnabled == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||
if(text.empty() == false) {
|
||||
|
@ -145,14 +146,15 @@ void ChatManager::keyDown(char key) {
|
|||
text.clear();
|
||||
}
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
switchOnEdit();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(key==vkBack) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
//else if(key==vkBack) {
|
||||
else if(isKeyPressed(SDLK_BACKSPACE,key) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
if(!text.empty()) {
|
||||
text.erase(text.end() -1);
|
||||
|
@ -170,26 +172,26 @@ void ChatManager::keyDown(char key) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void ChatManager::switchOnEdit(){
|
||||
void ChatManager::switchOnEdit() {
|
||||
editEnabled= true;
|
||||
text.clear();
|
||||
}
|
||||
|
||||
void ChatManager::keyPress(char c){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c,c);
|
||||
void ChatManager::keyPress(SDL_KeyboardEvent c) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c.keysym.sym,c.keysym.sym);
|
||||
|
||||
if(editEnabled && text.size()<maxTextLenght){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c,c);
|
||||
if(editEnabled && text.size() < maxTextLenght) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c.keysym.sym,c.keysym.sym);
|
||||
//space is the first meaningful code
|
||||
if(c>=' '){
|
||||
text+= c;
|
||||
if(extractKeyPressed(c) >= SDLK_SPACE) {
|
||||
text += extractKeyPressed(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatManager::addText(string text){
|
||||
if(editEnabled && text.size()+this->text.size()<maxTextLenght){
|
||||
this->text+= text;
|
||||
void ChatManager::addText(string text) {
|
||||
if(editEnabled && text.size() + this->text.size() < maxTextLenght) {
|
||||
this->text += text;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <string>
|
||||
#include "font.h"
|
||||
#include <SDL.h>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
|
@ -28,7 +29,7 @@ class Console;
|
|||
// class ChatManager
|
||||
// =====================================================
|
||||
|
||||
class ChatManager{
|
||||
class ChatManager {
|
||||
|
||||
private:
|
||||
bool editEnabled;
|
||||
|
@ -50,9 +51,9 @@ public:
|
|||
ChatManager();
|
||||
void init(Console* console, int thisTeamIndex, const bool inMenu=false, string manualPlayerNameOverride="");
|
||||
|
||||
void keyDown(char key);
|
||||
void keyUp(char key);
|
||||
void keyPress(char c);
|
||||
void keyDown(SDL_KeyboardEvent key);
|
||||
void keyUp(SDL_KeyboardEvent key);
|
||||
void keyPress(SDL_KeyboardEvent c);
|
||||
void updateNetwork();
|
||||
|
||||
bool getEditEnabled() const {return editEnabled;}
|
||||
|
|
|
@ -1491,9 +1491,9 @@ void Game::eventMouseWheel(int x, int y, int zDelta) {
|
|||
}
|
||||
}
|
||||
|
||||
void Game::keyDown(char key) {
|
||||
void Game::keyDown(SDL_KeyboardEvent key) {
|
||||
try {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d] gameStarted [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key, gameStarted);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d] gameStarted [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym, gameStarted);
|
||||
if(gameStarted == false) {
|
||||
return;
|
||||
}
|
||||
|
@ -1504,18 +1504,21 @@ void Game::keyDown(char key) {
|
|||
chatManager.keyDown(key);
|
||||
|
||||
if(chatManager.getEditEnabled() == false) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%d - %c]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%d - %c]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] key = [%d - %c] pausegame [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key,configKeys.getCharKey("PauseGame"));
|
||||
|
||||
if(key == configKeys.getCharKey("RenderNetworkStatus")) {
|
||||
//if(key == configKeys.getCharKey("RenderNetworkStatus")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("RenderNetworkStatus"),key) == true) {
|
||||
renderNetworkStatus= !renderNetworkStatus;
|
||||
}
|
||||
else if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
//else if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||
showFullConsole= true;
|
||||
}
|
||||
else if(key == configKeys.getCharKey("TogglePhotoMode")) {
|
||||
//else if(key == configKeys.getCharKey("TogglePhotoMode")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("TogglePhotoMode"),key) == true) {
|
||||
photoModeEnabled = !photoModeEnabled;
|
||||
if( photoModeEnabled == true &&
|
||||
this->gameSettings.isNetworkGame() == false) {
|
||||
|
@ -1527,7 +1530,8 @@ void Game::keyDown(char key) {
|
|||
|
||||
}
|
||||
//Toggle music
|
||||
else if(key == configKeys.getCharKey("ToggleMusic")) {
|
||||
//else if(key == configKeys.getCharKey("ToggleMusic")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ToggleMusic"),key) == true) {
|
||||
Config &config = Config::getInstance();
|
||||
StrSound *gameMusic = world.getThisFaction()->getType()->getMusic();
|
||||
if(gameMusic != NULL) {
|
||||
|
@ -1545,60 +1549,71 @@ void Game::keyDown(char key) {
|
|||
}
|
||||
}
|
||||
//move camera left
|
||||
else if(key == configKeys.getCharKey("CameraModeLeft")) {
|
||||
//else if(key == configKeys.getCharKey("CameraModeLeft")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraModeLeft"),key) == true) {
|
||||
gameCamera.setMoveX(-1);
|
||||
camLeftButtonDown=true;
|
||||
}
|
||||
//move camera right
|
||||
else if(key == configKeys.getCharKey("CameraModeRight")) {
|
||||
//else if(key == configKeys.getCharKey("CameraModeRight")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraModeRight"),key) == true) {
|
||||
gameCamera.setMoveX(1);
|
||||
camRightButtonDown=true;
|
||||
}
|
||||
//move camera up
|
||||
else if(key == configKeys.getCharKey("CameraModeUp")) {
|
||||
//else if(key == configKeys.getCharKey("CameraModeUp")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraModeUp"),key) == true) {
|
||||
gameCamera.setMoveZ(1);
|
||||
camUpButtonDown=true;
|
||||
}
|
||||
//move camera down
|
||||
else if(key == configKeys.getCharKey("CameraModeDown")) {
|
||||
//else if(key == configKeys.getCharKey("CameraModeDown")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraModeDown"),key) == true) {
|
||||
gameCamera.setMoveZ(-1);
|
||||
camDownButtonDown=true;
|
||||
}
|
||||
//change camera mode
|
||||
else if(key == configKeys.getCharKey("FreeCameraMode")) {
|
||||
//else if(key == configKeys.getCharKey("FreeCameraMode")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("FreeCameraMode"),key) == true) {
|
||||
gameCamera.switchState();
|
||||
string stateString= gameCamera.getState()==GameCamera::sGame? lang.get("GameCamera"): lang.get("FreeCamera");
|
||||
console.addLine(lang.get("CameraModeSet")+" "+ stateString);
|
||||
}
|
||||
//reset camera mode to normal
|
||||
else if(key == configKeys.getCharKey("ResetCameraMode")) {
|
||||
//else if(key == configKeys.getCharKey("ResetCameraMode")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ResetCameraMode"),key) == true) {
|
||||
gameCamera.resetPosition();
|
||||
}
|
||||
//pause
|
||||
else if(key == configKeys.getCharKey("PauseGame")) {
|
||||
//else if(key == configKeys.getCharKey("PauseGame")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("PauseGame"),key) == true) {
|
||||
//printf("Toggle pause paused = %d\n",paused);
|
||||
setPaused(!paused);
|
||||
}
|
||||
//switch display color
|
||||
else if(key == configKeys.getCharKey("ChangeFontColor")) {
|
||||
//else if(key == configKeys.getCharKey("ChangeFontColor")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ChangeFontColor"),key) == true) {
|
||||
gui.switchToNextDisplayColor();
|
||||
}
|
||||
//increment speed
|
||||
else if(key == configKeys.getCharKey("GameSpeedIncrease")) {
|
||||
//else if(key == configKeys.getCharKey("GameSpeedIncrease")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("GameSpeedIncrease"),key) == true) {
|
||||
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
||||
if(speedChangesAllowed){
|
||||
incSpeed();
|
||||
}
|
||||
}
|
||||
//decrement speed
|
||||
else if(key == configKeys.getCharKey("GameSpeedDecrease")) {
|
||||
//else if(key == configKeys.getCharKey("GameSpeedDecrease")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("GameSpeedDecrease"),key) == true) {
|
||||
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
||||
if(speedChangesAllowed){
|
||||
decSpeed();
|
||||
}
|
||||
}
|
||||
//exit
|
||||
else if(key == configKeys.getCharKey("ExitKey")) {
|
||||
//else if(key == configKeys.getCharKey("ExitKey")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ExitKey"),key) == true) {
|
||||
showMessageBox(lang.get("ExitGame?"), "", true);
|
||||
}
|
||||
//group
|
||||
|
@ -1608,10 +1623,14 @@ void Game::keyDown(char key) {
|
|||
|
||||
for(int idx = 1; idx <= Selection::maxGroups; idx++) {
|
||||
string keyName = "GroupUnitsKey" + intToStr(idx);
|
||||
char groupHotKey = configKeys.getCharKey(keyName.c_str());
|
||||
//char groupHotKey = configKeys.getCharKey(keyName.c_str());
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keyName [%s] group index = %d, key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),idx,groupHotKey,groupHotKey);
|
||||
|
||||
SDLKey groupHotKey = configKeys.getSDLKey(keyName.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keyName [%s] group index = %d, key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),idx,groupHotKey,groupHotKey);
|
||||
|
||||
if(key == groupHotKey) {
|
||||
//if(key == groupHotKey) {
|
||||
if(isKeyPressed(groupHotKey,key) == true) {
|
||||
//gui.groupKey(key-'0');
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
gui.groupKey(idx-1);
|
||||
|
@ -1630,19 +1649,23 @@ void Game::keyDown(char key) {
|
|||
}
|
||||
else {
|
||||
//rotate camera leftt
|
||||
if(key == configKeys.getCharKey("CameraRotateLeft")) {
|
||||
//if(key == configKeys.getCharKey("CameraRotateLeft")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("CameraRotateLeft"),key) == true) {
|
||||
gameCamera.setRotate(-1);
|
||||
}
|
||||
//rotate camera right
|
||||
else if(key == configKeys.getCharKey("CameraRotateRight")){
|
||||
//else if(key == configKeys.getCharKey("CameraRotateRight")){
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraRotateRight"),key) == true) {
|
||||
gameCamera.setRotate(1);
|
||||
}
|
||||
//camera up
|
||||
else if(key == configKeys.getCharKey("CameraRotateUp")) {
|
||||
//else if(key == configKeys.getCharKey("CameraRotateUp")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraRotateUp"),key) == true) {
|
||||
gameCamera.setMoveY(1);
|
||||
}
|
||||
//camera down
|
||||
else if(key == configKeys.getCharKey("CameraRotateDown")) {
|
||||
//else if(key == configKeys.getCharKey("CameraRotateDown")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraRotateDown"),key) == true) {
|
||||
gameCamera.setMoveY(-1);
|
||||
}
|
||||
}
|
||||
|
@ -1668,7 +1691,7 @@ void Game::keyDown(char key) {
|
|||
}
|
||||
}
|
||||
|
||||
void Game::keyUp(char key){
|
||||
void Game::keyUp(SDL_KeyboardEvent key) {
|
||||
try {
|
||||
if(gameStarted == false) {
|
||||
return;
|
||||
|
@ -1681,34 +1704,43 @@ void Game::keyUp(char key){
|
|||
else {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
//if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||
showFullConsole= false;
|
||||
}
|
||||
else if(key == configKeys.getCharKey("CameraRotateLeft") ||
|
||||
key == configKeys.getCharKey("CameraRotateRight")) {
|
||||
//else if(key == configKeys.getCharKey("CameraRotateLeft") ||
|
||||
// key == configKeys.getCharKey("CameraRotateRight")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraRotateLeft"),key) == true ||
|
||||
isKeyPressed(configKeys.getSDLKey("CameraRotateRight"),key) == true) {
|
||||
gameCamera.setRotate(0);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("CameraRotateDown") ||
|
||||
key == configKeys.getCharKey("CameraRotateUp")) {
|
||||
//else if(key == configKeys.getCharKey("CameraRotateDown") ||
|
||||
// key == configKeys.getCharKey("CameraRotateUp")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraRotateDown"),key) == true ||
|
||||
isKeyPressed(configKeys.getSDLKey("CameraRotateUp"),key) == true) {
|
||||
|
||||
gameCamera.setMoveY(0);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("CameraModeUp")){
|
||||
//else if(key == configKeys.getCharKey("CameraModeUp")){
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraModeUp"),key) == true) {
|
||||
gameCamera.setMoveZ(0);
|
||||
camUpButtonDown= false;
|
||||
calcCameraMoveZ();
|
||||
}
|
||||
else if(key == configKeys.getCharKey("CameraModeDown")){
|
||||
//else if(key == configKeys.getCharKey("CameraModeDown")){
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraModeDown"),key) == true) {
|
||||
gameCamera.setMoveZ(0);
|
||||
camDownButtonDown= false;
|
||||
calcCameraMoveZ();
|
||||
}
|
||||
|
||||
else if(key == configKeys.getCharKey("CameraModeLeft")){
|
||||
//else if(key == configKeys.getCharKey("CameraModeLeft")){
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraModeLeft"),key) == true) {
|
||||
gameCamera.setMoveX(0);
|
||||
camLeftButtonDown= false;
|
||||
calcCameraMoveX();
|
||||
}
|
||||
else if(key == configKeys.getCharKey("CameraModeRight")){
|
||||
//else if(key == configKeys.getCharKey("CameraModeRight")){
|
||||
else if(isKeyPressed(configKeys.getSDLKey("CameraModeRight"),key) == true) {
|
||||
gameCamera.setMoveX(0);
|
||||
camRightButtonDown= false;
|
||||
calcCameraMoveX();
|
||||
|
@ -1755,7 +1787,7 @@ void Game::calcCameraMoveZ(){
|
|||
|
||||
}
|
||||
|
||||
void Game::keyPress(char c){
|
||||
void Game::keyPress(SDL_KeyboardEvent c) {
|
||||
if(gameStarted == false) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -157,9 +157,9 @@ public:
|
|||
virtual void tick();
|
||||
|
||||
//event managing
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyUp(char key);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual void mouseDownLeft(int x, int y);
|
||||
virtual void mouseDownRight(int x, int y);
|
||||
virtual void mouseUpCenter(int x, int y);
|
||||
|
|
|
@ -345,6 +345,7 @@ const string Config::getString(const string &key,const char *defaultValueIfNotFo
|
|||
return properties.first.getString(key,defaultValueIfNotFound);
|
||||
}
|
||||
|
||||
/*
|
||||
SDLKey Config::translateSpecialStringToSDLKey(char c) const {
|
||||
SDLKey result = SDLK_UNKNOWN;
|
||||
if(c < 0) {
|
||||
|
@ -645,18 +646,138 @@ char Config::translateStringToCharKey(const string &value) const {
|
|||
result = tolower(result);
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
char Config::getCharKey(const char *key) const {
|
||||
SDLKey Config::translateStringToSDLKey(const string &value) const {
|
||||
SDLKey result = SDLK_UNKNOWN;
|
||||
|
||||
if(IsNumeric(value.c_str()) == true) {
|
||||
result = (SDLKey)strToInt(value);
|
||||
}
|
||||
else if(value.substr(0,2) == "vk") {
|
||||
if(value == "vkLeft") {
|
||||
result = SDLK_LEFT;
|
||||
}
|
||||
else if(value == "vkRight") {
|
||||
result = SDLK_RIGHT;
|
||||
}
|
||||
else if(value == "vkUp") {
|
||||
result = SDLK_UP;
|
||||
}
|
||||
else if(value == "vkDown") {
|
||||
result = SDLK_DOWN;
|
||||
}
|
||||
else if(value == "vkAdd") {
|
||||
result = SDLK_PLUS;
|
||||
}
|
||||
else if(value == "vkSubtract") {
|
||||
result = SDLK_MINUS;
|
||||
}
|
||||
else if(value == "vkEscape") {
|
||||
result = SDLK_ESCAPE;
|
||||
}
|
||||
else if(value == "vkF1") {
|
||||
result = SDLK_F1;
|
||||
}
|
||||
else if(value == "vkF2") {
|
||||
result = SDLK_F2;
|
||||
}
|
||||
else if(value == "vkF3") {
|
||||
result = SDLK_F3;
|
||||
}
|
||||
else if(value == "vkF4") {
|
||||
result = SDLK_F4;
|
||||
}
|
||||
else if(value == "vkF5") {
|
||||
result = SDLK_F5;
|
||||
}
|
||||
else if(value == "vkF6") {
|
||||
result = SDLK_F6;
|
||||
}
|
||||
else if(value == "vkF7") {
|
||||
result = SDLK_F7;
|
||||
}
|
||||
else if(value == "vkF8") {
|
||||
result = SDLK_F8;
|
||||
}
|
||||
else if(value == "vkF9") {
|
||||
result = SDLK_F9;
|
||||
}
|
||||
else if(value == "vkF10") {
|
||||
result = SDLK_F10;
|
||||
}
|
||||
else if(value == "vkF11") {
|
||||
result = SDLK_F11;
|
||||
}
|
||||
else if(value == "vkF12") {
|
||||
result = SDLK_F12;
|
||||
}
|
||||
else if(value == "vkPrint") {
|
||||
result = SDLK_PRINT;
|
||||
}
|
||||
else if(value == "vkPause") {
|
||||
result = SDLK_PAUSE;
|
||||
}
|
||||
else {
|
||||
string sError = "Unsupported key translation [" + value + "]";
|
||||
throw runtime_error(sError.c_str());
|
||||
}
|
||||
}
|
||||
else if(value.length() >= 1) {
|
||||
if(value.length() == 3 && value[0] == '\'' && value[2] == '\'') {
|
||||
result = (SDLKey)value[1];
|
||||
}
|
||||
else {
|
||||
bool foundKey = false;
|
||||
if(value.length() > 1) {
|
||||
for(int i = SDLK_UNKNOWN; i < SDLK_LAST; ++i) {
|
||||
SDLKey key = static_cast<SDLKey>(i);
|
||||
string keyName = SDL_GetKeyName(key);
|
||||
if(value == keyName) {
|
||||
result = key;
|
||||
foundKey = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(foundKey == false) {
|
||||
result = (SDLKey)value[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
string sError = "Unsupported key translation" + value;
|
||||
throw runtime_error(sError.c_str());
|
||||
}
|
||||
|
||||
// Because SDL is based on lower Ascii
|
||||
//result = tolower(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
SDLKey Config::getSDLKey(const char *key) const {
|
||||
if(fileLoaded.second == true &&
|
||||
properties.second.getString(key, defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||
|
||||
string value = properties.second.getString(key);
|
||||
return translateStringToCharKey(value);
|
||||
return translateStringToSDLKey(value);
|
||||
}
|
||||
string value = properties.first.getString(key);
|
||||
return translateStringToCharKey(value);
|
||||
return translateStringToSDLKey(value);
|
||||
}
|
||||
|
||||
//char Config::getCharKey(const char *key) const {
|
||||
// if(fileLoaded.second == true &&
|
||||
// properties.second.getString(key, defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||
//
|
||||
// string value = properties.second.getString(key);
|
||||
// return translateStringToCharKey(value);
|
||||
// }
|
||||
// string value = properties.first.getString(key);
|
||||
// return translateStringToCharKey(value);
|
||||
//}
|
||||
|
||||
void Config::setInt(const string &key, int value){
|
||||
if(fileLoaded.second == true) {
|
||||
properties.second.setInt(key, value);
|
||||
|
|
|
@ -75,7 +75,8 @@ public:
|
|||
bool getBool(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
float getFloat(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
const string getString(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
char getCharKey(const char *key) const;
|
||||
//char getCharKey(const char *key) const;
|
||||
SDLKey getSDLKey(const char *key) const;
|
||||
|
||||
void setInt(const string &key, int value);
|
||||
void setBool(const string &key, bool value);
|
||||
|
@ -91,8 +92,10 @@ public:
|
|||
|
||||
string getFileName(bool userFilename) const;
|
||||
|
||||
char translateStringToCharKey(const string &value) const;
|
||||
SDLKey translateSpecialStringToSDLKey(char c) const;
|
||||
//char translateStringToCharKey(const string &value) const;
|
||||
//SDLKey translateSpecialStringToSDLKey(char c) const;
|
||||
|
||||
SDLKey translateStringToSDLKey(const string &value) const;
|
||||
|
||||
string toString();
|
||||
};
|
||||
|
|
|
@ -327,25 +327,30 @@ void Gui::groupKey(int groupIndex) {
|
|||
}
|
||||
}
|
||||
|
||||
void Gui::hotKey(char key) {
|
||||
void Gui::hotKey(SDL_KeyboardEvent key) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] key = [%c][%d]\n",__FILE__,__FUNCTION__,key,key);
|
||||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(key == configKeys.getCharKey("HotKeyCenterCameraOnSelection")) {
|
||||
//if(key == configKeys.getCharKey("HotKeyCenterCameraOnSelection")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("HotKeyCenterCameraOnSelection"),key) == true) {
|
||||
centerCameraOnSelection();
|
||||
}
|
||||
else if(key == configKeys.getCharKey("HotKeySelectIdleHarvesterUnit")) {
|
||||
//else if(key == configKeys.getCharKey("HotKeySelectIdleHarvesterUnit")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("HotKeySelectIdleHarvesterUnit"),key) == true) {
|
||||
selectInterestingUnit(iutIdleHarvester);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("HotKeySelectBuiltBuilding")) {
|
||||
//else if(key == configKeys.getCharKey("HotKeySelectBuiltBuilding")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("HotKeySelectBuiltBuilding"),key) == true) {
|
||||
selectInterestingUnit(iutBuiltBuilding);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("HotKeyDumpWorldToLog")) {
|
||||
//else if(key == configKeys.getCharKey("HotKeyDumpWorldToLog")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("HotKeyDumpWorldToLog"),key) == true) {
|
||||
std::string worldLog = world->DumpWorldToLog();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] worldLog dumped to [%s]\n",__FILE__,__FUNCTION__,__LINE__,worldLog.c_str());
|
||||
}
|
||||
else if(key == configKeys.getCharKey("HotKeyRotateUnitDuringPlacement")){
|
||||
//else if(key == configKeys.getCharKey("HotKeyRotateUnitDuringPlacement")){
|
||||
else if(isKeyPressed(configKeys.getSDLKey("HotKeyRotateUnitDuringPlacement"),key) == true) {
|
||||
// Here the user triggers a unit rotation while placing a unit
|
||||
if(isPlacingBuilding()) {
|
||||
if(getBuilding()->getRotationAllowed()){
|
||||
|
@ -353,16 +358,20 @@ void Gui::hotKey(char key) {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(key == configKeys.getCharKey("HotKeySelectDamagedUnit")) {
|
||||
//else if(key == configKeys.getCharKey("HotKeySelectDamagedUnit")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("HotKeySelectDamagedUnit"),key) == true) {
|
||||
selectInterestingUnit(iutDamaged);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("HotKeySelectStoreUnit")) {
|
||||
//else if(key == configKeys.getCharKey("HotKeySelectStoreUnit")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("HotKeySelectStoreUnit"),key) == true) {
|
||||
selectInterestingUnit(iutStore);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("HotKeySelectedUnitsAttack")) {
|
||||
//else if(key == configKeys.getCharKey("HotKeySelectedUnitsAttack")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("HotKeySelectedUnitsAttack"),key) == true) {
|
||||
clickCommonCommand(ccAttack);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("HotKeySelectedUnitsStop")) {
|
||||
//else if(key == configKeys.getCharKey("HotKeySelectedUnitsStop")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("HotKeySelectedUnitsStop"),key) == true) {
|
||||
clickCommonCommand(ccStop);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ public:
|
|||
void mouseMoveGraphics(int x, int y);
|
||||
void mouseDoubleClickLeftGraphics(int x, int y);
|
||||
void groupKey(int groupIndex);
|
||||
void hotKey(char key);
|
||||
void hotKey(SDL_KeyboardEvent key);
|
||||
|
||||
//misc
|
||||
void switchToNextDisplayColor();
|
||||
|
|
|
@ -774,8 +774,8 @@ void MainWindow::eventMouseWheel(int x, int y, int zDelta) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MainWindow::eventKeyDown(char key){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||
void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym);
|
||||
|
||||
SDL_keysym keystate = Window::getKeystate();
|
||||
|
||||
|
@ -795,7 +795,8 @@ void MainWindow::eventKeyDown(char key){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(keystate.mod & (KMOD_LALT | KMOD_RALT)) {
|
||||
if(key == vkReturn) {
|
||||
//if(key == vkReturn) {
|
||||
if(isKeyPressed(SDLK_RETURN,key) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ALT-ENTER pressed\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// This stupidity only required in win32.
|
||||
|
@ -815,7 +816,8 @@ void MainWindow::eventKeyDown(char key){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("HotKeyShowDebug")) {
|
||||
//if(key == configKeys.getCharKey("HotKeyShowDebug")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("HotKeyShowDebug"),key) == true) {
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
//if(keystate.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
|
||||
|
@ -827,11 +829,13 @@ void MainWindow::eventKeyDown(char key){
|
|||
renderer.setShowDebugUI(!showDebugUI);
|
||||
}
|
||||
}
|
||||
else if(key == configKeys.getCharKey("ReloadINI")) {
|
||||
//else if(key == configKeys.getCharKey("ReloadINI")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ReloadINI"),key) == true) {
|
||||
Config &config = Config::getInstance();
|
||||
config.reload();
|
||||
}
|
||||
else if(key == configKeys.getCharKey("Screenshot")) {
|
||||
//else if(key == configKeys.getCharKey("Screenshot")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("Screenshot"),key) == true) {
|
||||
string userData = Config::getInstance().getString("UserData_Root","");
|
||||
if(userData != "") {
|
||||
endPathWithSlash(userData);
|
||||
|
@ -882,7 +886,7 @@ void MainWindow::eventKeyDown(char key){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MainWindow::eventKeyUp(char key){
|
||||
void MainWindow::eventKeyUp(SDL_KeyboardEvent key) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||
if(program == NULL) {
|
||||
throw runtime_error("In [MainWindow::eventKeyUp] ERROR, program == NULL!");
|
||||
|
@ -892,7 +896,7 @@ void MainWindow::eventKeyUp(char key){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||
}
|
||||
|
||||
void MainWindow::eventKeyPress(char c){
|
||||
void MainWindow::eventKeyPress(SDL_KeyboardEvent c) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
||||
if(program == NULL) {
|
||||
throw runtime_error("In [MainWindow::eventKeyPress] ERROR, program == NULL!");
|
||||
|
@ -904,7 +908,8 @@ void MainWindow::eventKeyPress(char c){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(c == configKeys.getCharKey("HotKeyToggleOSMouseEnabled")) {
|
||||
//if(c == configKeys.getCharKey("HotKeyToggleOSMouseEnabled")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("HotKeyToggleOSMouseEnabled"),c) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
bool showCursorState = false;
|
||||
|
@ -924,13 +929,13 @@ void MainWindow::eventKeyPress(char c){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
||||
}
|
||||
|
||||
void MainWindow::eventActivate(bool active){
|
||||
void MainWindow::eventActivate(bool active) {
|
||||
if(!active){
|
||||
//minimize();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::eventResize(SizeState sizeState){
|
||||
void MainWindow::eventResize(SizeState sizeState) {
|
||||
if(program == NULL) {
|
||||
throw runtime_error("In [MainWindow::eventResize] ERROR, program == NULL!");
|
||||
}
|
||||
|
|
|
@ -43,10 +43,10 @@ public:
|
|||
virtual void eventMouseUp(int x, int y, MouseButton mouseButton);
|
||||
virtual void eventMouseDoubleClick(int x, int y, MouseButton mouseButton);
|
||||
virtual void eventMouseMove(int x, int y, const MouseState *mouseState);
|
||||
virtual void eventKeyDown(char key);
|
||||
virtual void eventKeyDown(SDL_KeyboardEvent key);
|
||||
virtual void eventMouseWheel(int x, int y, int zDelta);
|
||||
virtual void eventKeyUp(char key);
|
||||
virtual void eventKeyPress(char c);
|
||||
virtual void eventKeyUp(SDL_KeyboardEvent key);
|
||||
virtual void eventKeyPress(SDL_KeyboardEvent c);
|
||||
virtual void eventActivate(bool active);
|
||||
virtual void eventResize(SizeState sizeState);
|
||||
virtual void eventClose();
|
||||
|
|
|
@ -99,17 +99,15 @@ void Program::ShowMessageProgramState::mouseDownLeft(int x, int y) {
|
|||
}
|
||||
}
|
||||
|
||||
void Program::ShowMessageProgramState::keyPress(char c){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
||||
void Program::ShowMessageProgramState::keyPress(SDL_KeyboardEvent c) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c.keysym.sym);
|
||||
|
||||
// if user pressed return we exit
|
||||
if(c == 13) {
|
||||
//if(c == 13) {
|
||||
if(isKeyPressed(SDLK_RETURN,c) == true) {
|
||||
program->exit();
|
||||
userWantsExit = true;
|
||||
}
|
||||
else {
|
||||
//msgBox.keyPress(c);
|
||||
}
|
||||
}
|
||||
|
||||
void Program::ShowMessageProgramState::mouseMove(int x, int y, const MouseState &mouseState) {
|
||||
|
@ -201,13 +199,14 @@ Program::~Program(){
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Program::keyDown(char key){
|
||||
|
||||
void Program::keyDown(SDL_KeyboardEvent key) {
|
||||
if(msgBox.getEnabled()) {
|
||||
SDL_keysym keystate = Window::getKeystate();
|
||||
//SDL_keysym keystate = Window::getKeystate();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(key == vkEscape || key == SDLK_ESCAPE ||
|
||||
((key == vkReturn || key == SDLK_RETURN || key == SDLK_KP_ENTER) && !(keystate.mod & (KMOD_LALT | KMOD_RALT)))) {
|
||||
|
||||
//if(key == vkEscape || key == SDLK_ESCAPE ||
|
||||
// ((key == vkReturn || key == SDLK_RETURN || key == SDLK_KP_ENTER) && !(keystate.mod & (KMOD_LALT | KMOD_RALT)))) {
|
||||
if(isKeyPressed(SDLK_ESCAPE,key) == true || ((isKeyPressed(SDLK_RETURN,key) == true) && !(key.keysym.mod & (KMOD_LALT | KMOD_RALT)))) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//printf("---> keystate [%d]\n",keystate);
|
||||
|
@ -219,11 +218,11 @@ void Program::keyDown(char key){
|
|||
programState->keyDown(key);
|
||||
}
|
||||
|
||||
void Program::keyUp(char key){
|
||||
void Program::keyUp(SDL_KeyboardEvent key) {
|
||||
programState->keyUp(key);
|
||||
}
|
||||
|
||||
void Program::keyPress(char c){
|
||||
void Program::keyPress(SDL_KeyboardEvent c) {
|
||||
programState->keyPress(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class MainWindow;
|
|||
/// Intro, MainMenu, Game, BattleEnd (State Design pattern)
|
||||
// =====================================================
|
||||
|
||||
class ProgramState{
|
||||
class ProgramState {
|
||||
protected:
|
||||
Program *program;
|
||||
|
||||
|
@ -85,9 +85,9 @@ public:
|
|||
virtual void mouseDoubleClickCenter(int x, int y){}
|
||||
virtual void eventMouseWheel(int x, int y, int zDelta){}
|
||||
virtual void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
virtual void keyDown(char key){};
|
||||
virtual void keyUp(char key){};
|
||||
virtual void keyPress(char c){};
|
||||
virtual void keyDown(SDL_KeyboardEvent key){};
|
||||
virtual void keyUp(SDL_KeyboardEvent key){};
|
||||
virtual void keyPress(SDL_KeyboardEvent c){};
|
||||
virtual void setStartXY(int X,int Y) { startX=X; startY=Y; }
|
||||
virtual void restoreToStartXY() { SDL_WarpMouse(startX, startY); }
|
||||
virtual bool isInSpecialKeyCaptureEvent() { return false; }
|
||||
|
@ -121,7 +121,7 @@ private:
|
|||
virtual void render();
|
||||
virtual void mouseDownLeft(int x, int y);
|
||||
virtual void mouseMove(int x, int y, const MouseState &mouseState);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual void update();
|
||||
virtual bool wantExit() { return userWantsExit; }
|
||||
};
|
||||
|
@ -153,9 +153,9 @@ public:
|
|||
void initScenario(WindowGl *window, string autoloadScenarioName);
|
||||
|
||||
//main
|
||||
void keyDown(char key);
|
||||
void keyUp(char key);
|
||||
void keyPress(char c);
|
||||
void keyDown(SDL_KeyboardEvent key);
|
||||
void keyUp(SDL_KeyboardEvent key);
|
||||
void keyPress(SDL_KeyboardEvent c);
|
||||
|
||||
void loop();
|
||||
void loopWorker();
|
||||
|
|
|
@ -154,15 +154,15 @@ void MainMenu::mouseDownRight(int x, int y){
|
|||
state->mouseClick(x, y, mbRight);
|
||||
}
|
||||
|
||||
void MainMenu::keyDown(char key){
|
||||
void MainMenu::keyDown(SDL_KeyboardEvent key) {
|
||||
state->keyDown(key);
|
||||
}
|
||||
|
||||
void MainMenu::keyUp(char key){
|
||||
void MainMenu::keyUp(SDL_KeyboardEvent key) {
|
||||
state->keyUp(key);
|
||||
}
|
||||
|
||||
void MainMenu::keyPress(char c){
|
||||
void MainMenu::keyPress(SDL_KeyboardEvent c) {
|
||||
state->keyPress(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class MenuState;
|
|||
/// Main menu ProgramState
|
||||
// =====================================================
|
||||
|
||||
class MainMenu: public ProgramState{
|
||||
class MainMenu: public ProgramState {
|
||||
|
||||
private:
|
||||
static MenuState *oldstate;
|
||||
|
@ -101,9 +101,9 @@ public:
|
|||
virtual void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
virtual void mouseDownLeft(int x, int y);
|
||||
virtual void mouseDownRight(int x, int y);
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyUp(char key);
|
||||
virtual void keyPress(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent key);
|
||||
|
||||
void setState(MenuState *state);
|
||||
virtual bool isInSpecialKeyCaptureEvent();
|
||||
|
@ -137,9 +137,9 @@ public:
|
|||
virtual void mouseMove(int x, int y, const MouseState *mouseState)=0;
|
||||
virtual void render()=0;
|
||||
virtual void update(){};
|
||||
virtual void keyDown(char key){};
|
||||
virtual void keyPress(char c){};
|
||||
virtual void keyUp(char key){};
|
||||
virtual void keyDown(SDL_KeyboardEvent key){};
|
||||
virtual void keyPress(SDL_KeyboardEvent c){};
|
||||
virtual void keyUp(SDL_KeyboardEvent key){};
|
||||
|
||||
const Camera *getCamera() const {return &camera;}
|
||||
|
||||
|
|
|
@ -161,9 +161,10 @@ void MenuStateAbout::render(){
|
|||
|
||||
}
|
||||
|
||||
void MenuStateAbout::keyDown(char key){
|
||||
void MenuStateAbout::keyDown(SDL_KeyboardEvent key){
|
||||
Config &configKeys= Config::getInstance(std::pair<ConfigType, ConfigType>(cfgMainKeys, cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("SaveGUILayout")){
|
||||
//if(key == configKeys.getCharKey("SaveGUILayout")){
|
||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved= GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void render();
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -2089,10 +2089,12 @@ bool MenuStateConnectedGame::hasNetworkGameSettings()
|
|||
return hasNetworkSlot;
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::keyDown(char key) {
|
||||
void MenuStateConnectedGame::keyDown(SDL_KeyboardEvent key) {
|
||||
if(activeInputLabel != NULL) {
|
||||
string text = activeInputLabel->getText();
|
||||
if(key == vkBack && text.length() > 0) {
|
||||
|
||||
//if(key == vkBack && text.length() > 0) {
|
||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true && text.length() > 0) {
|
||||
size_t found = text.find_last_of("_");
|
||||
if (found == string::npos) {
|
||||
text.erase(text.end() - 1);
|
||||
|
@ -2116,10 +2118,12 @@ void MenuStateConnectedGame::keyDown(char key) {
|
|||
if(chatManager.getEditEnabled() == false) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
//if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||
showFullConsole= true;
|
||||
}
|
||||
else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
Lang &lang= Lang::getInstance();
|
||||
console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
@ -2128,23 +2132,24 @@ void MenuStateConnectedGame::keyDown(char key) {
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::keyPress(char c) {
|
||||
void MenuStateConnectedGame::keyPress(SDL_KeyboardEvent c) {
|
||||
if(activeInputLabel != NULL) {
|
||||
int maxTextSize= 16;
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
if(&labelPlayerNames[i] == activeInputLabel) {
|
||||
if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') ||
|
||||
(c=='-') || (c=='(') || (c==')')) {
|
||||
SDLKey key = extractKeyPressed(c);
|
||||
//if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') ||
|
||||
// (c=='-') || (c=='(') || (c==')')) {
|
||||
if(activeInputLabel->getText().size() < maxTextSize) {
|
||||
string text= activeInputLabel->getText();
|
||||
text.insert(text.end() -1, c);
|
||||
text.insert(text.end() -1, key);
|
||||
activeInputLabel->setText(text);
|
||||
|
||||
switchSetupRequestFlagType |= ssrft_NetworkPlayerName;
|
||||
needToSetChangedGameSettings = true;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2153,7 +2158,7 @@ void MenuStateConnectedGame::keyPress(char c) {
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::keyUp(char key) {
|
||||
void MenuStateConnectedGame::keyUp(SDL_KeyboardEvent key) {
|
||||
if(activeInputLabel==NULL) {
|
||||
chatManager.keyUp(key);
|
||||
|
||||
|
@ -2163,7 +2168,8 @@ void MenuStateConnectedGame::keyUp(char key) {
|
|||
//send key to the chat manager
|
||||
chatManager.keyUp(key);
|
||||
}
|
||||
else if(key== configKeys.getCharKey("ShowFullConsole")) {
|
||||
//else if(key== configKeys.getCharKey("ShowFullConsole")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||
showFullConsole= false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,9 +179,9 @@ public:
|
|||
void render();
|
||||
void update();
|
||||
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyUp(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
|
||||
virtual bool isInSpecialKeyCaptureEvent();
|
||||
|
||||
|
|
|
@ -557,7 +557,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
// write hint to console:
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
console.addLine(lang.get("To switch off music press")+" - \""+configKeys.getCharKey("ToggleMusic")+"\"");
|
||||
console.addLine(lang.get("To switch off music press") + " - \"" + configKeys.getString("ToggleMusic") + "\"");
|
||||
|
||||
chatManager.init(&console, -1,true);
|
||||
|
||||
|
@ -2878,10 +2878,11 @@ void MenuStateCustomGame::updateNetworkSlots() {
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::keyDown(char key) {
|
||||
void MenuStateCustomGame::keyDown(SDL_KeyboardEvent key) {
|
||||
if(activeInputLabel != NULL) {
|
||||
string text = activeInputLabel->getText();
|
||||
if(key == vkBack && text.length() > 0) {
|
||||
//if(key == vkBack && text.length() > 0) {
|
||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true && text.length() > 0) {
|
||||
size_t found = text.find_last_of("_");
|
||||
if (found == string::npos) {
|
||||
text.erase(text.end() - 1);
|
||||
|
@ -2909,11 +2910,13 @@ void MenuStateCustomGame::keyDown(char key) {
|
|||
if(chatManager.getEditEnabled() == false) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
//if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||
showFullConsole= true;
|
||||
}
|
||||
//Toggle music
|
||||
else if(key == configKeys.getCharKey("ToggleMusic")) {
|
||||
//else if(key == configKeys.getCharKey("ToggleMusic")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ToggleMusic"),key) == true) {
|
||||
Config &config = Config::getInstance();
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
|
@ -2930,7 +2933,8 @@ void MenuStateCustomGame::keyDown(char key) {
|
|||
console.addLine(lang.get("GameMusic"));
|
||||
}
|
||||
}
|
||||
else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
Lang &lang= Lang::getInstance();
|
||||
console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
@ -2939,16 +2943,17 @@ void MenuStateCustomGame::keyDown(char key) {
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::keyPress(char c) {
|
||||
void MenuStateCustomGame::keyPress(SDL_KeyboardEvent c) {
|
||||
if(activeInputLabel != NULL) {
|
||||
int maxTextSize= 16;
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
if(&labelPlayerNames[i] == activeInputLabel) {
|
||||
if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') ||
|
||||
(c=='-') || (c=='(') || (c==')')) {
|
||||
SDLKey key = extractKeyPressed(c);
|
||||
//if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') ||
|
||||
// (c=='-') || (c=='(') || (c==')')) {
|
||||
if(activeInputLabel->getText().size() < maxTextSize) {
|
||||
string text= activeInputLabel->getText();
|
||||
text.insert(text.end()-1, c);
|
||||
text.insert(text.end()-1, key);
|
||||
activeInputLabel->setText(text);
|
||||
|
||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
@ -2957,7 +2962,7 @@ void MenuStateCustomGame::keyPress(char c) {
|
|||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2968,7 +2973,7 @@ void MenuStateCustomGame::keyPress(char c) {
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::keyUp(char key) {
|
||||
void MenuStateCustomGame::keyUp(SDL_KeyboardEvent key) {
|
||||
if(activeInputLabel==NULL) {
|
||||
if(hasNetworkGameSettings() == true) {
|
||||
chatManager.keyUp(key);
|
||||
|
@ -2981,7 +2986,8 @@ void MenuStateCustomGame::keyUp(char key) {
|
|||
chatManager.keyUp(key);
|
||||
}
|
||||
}
|
||||
else if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
//else if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||
showFullConsole= false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,9 +167,9 @@ public:
|
|||
void render();
|
||||
void update();
|
||||
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyUp(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
|
||||
|
||||
virtual void simpleTask(BaseThread *callingThread);
|
||||
|
|
|
@ -75,9 +75,10 @@ void MenuStateGraphicInfo::render(){
|
|||
renderer.renderConsole(&console,false,true);
|
||||
}
|
||||
|
||||
void MenuStateGraphicInfo::keyDown(char key) {
|
||||
void MenuStateGraphicInfo::keyDown(SDL_KeyboardEvent key) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void render();
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -461,8 +461,8 @@ void MenuStateJoinGame::update()
|
|||
if(clientInterface != NULL && clientInterface->getLaunchGame()) if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - D\n",__FILE__,__FUNCTION__);
|
||||
}
|
||||
|
||||
void MenuStateJoinGame::keyDown(char key) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
void MenuStateJoinGame::keyDown(SDL_KeyboardEvent key) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
if(clientInterface->isConnected() == false) {
|
||||
|
@ -470,17 +470,19 @@ void MenuStateJoinGame::keyDown(char key) {
|
|||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(key == vkBack) {
|
||||
//if(key == vkBack) {
|
||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
string text= labelServerIp.getText();
|
||||
|
||||
if(text.size()>1){
|
||||
if(text.size() > 1) {
|
||||
text.erase(text.end()-2);
|
||||
}
|
||||
|
||||
labelServerIp.setText(text);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
Lang &lang= Lang::getInstance();
|
||||
console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
@ -494,7 +496,8 @@ void MenuStateJoinGame::keyDown(char key) {
|
|||
|
||||
if(chatManager.getEditEnabled() == false) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
Lang &lang= Lang::getInstance();
|
||||
console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
@ -503,7 +506,7 @@ void MenuStateJoinGame::keyDown(char key) {
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateJoinGame::keyPress(char c) {
|
||||
void MenuStateJoinGame::keyPress(SDL_KeyboardEvent c) {
|
||||
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
|
||||
if(clientInterface->isConnected() == false) {
|
||||
|
@ -511,15 +514,18 @@ void MenuStateJoinGame::keyPress(char c) {
|
|||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(c>='0' && c<='9') {
|
||||
SDLKey key = extractKeyPressed(c);
|
||||
|
||||
if(labelServerIp.getText().size()<maxTextSize) {
|
||||
//if(c>='0' && c<='9') {
|
||||
if(key >= SDLK_0 && key <= SDLK_9) {
|
||||
if(labelServerIp.getText().size() < maxTextSize) {
|
||||
string text= labelServerIp.getText();
|
||||
text.insert(text.end()-1, c);
|
||||
text.insert(text.end()-1, key);
|
||||
labelServerIp.setText(text);
|
||||
}
|
||||
}
|
||||
else if (c=='.') {
|
||||
//else if (c=='.') {
|
||||
else if (key == SDLK_PERIOD) {
|
||||
if(labelServerIp.getText().size() < maxTextSize) {
|
||||
string text= labelServerIp.getText();
|
||||
text.insert(text.end()-1, '.');
|
||||
|
|
|
@ -71,8 +71,8 @@ public:
|
|||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void render();
|
||||
void update();
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
|
||||
virtual bool isInSpecialKeyCaptureEvent() { return chatManager.getEditEnabled(); }
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ MenuStateKeysetup::MenuStateKeysetup(Program *program, MainMenu *mainMenu):
|
|||
containerName = "KeySetup";
|
||||
|
||||
hotkeyIndex = -1;
|
||||
hotkeyChar = 0;
|
||||
hotkeyChar = SDLK_UNKNOWN;
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
int buttonRowPos=80;
|
||||
|
@ -106,7 +106,8 @@ MenuStateKeysetup::MenuStateKeysetup(Program *program, MainMenu *mainMenu):
|
|||
|
||||
string keyName = mergedProperties[i].second;
|
||||
if(keyName.length() > 0) {
|
||||
char c = configKeys.translateStringToCharKey(keyName);
|
||||
//char c = configKeys.translateStringToCharKey(keyName);
|
||||
SDLKey c = configKeys.translateStringToSDLKey(keyName);
|
||||
if(c > SDLK_UNKNOWN && c < SDLK_LAST) {
|
||||
SDLKey keysym = static_cast<SDLKey>(c);
|
||||
// SDL skips capital letters
|
||||
|
@ -246,7 +247,7 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
<= keyScrollBar.getVisibleEnd(); ++i) {
|
||||
if (keyButtons[i]->mouseClick(x, y)) {
|
||||
hotkeyIndex = i;
|
||||
hotkeyChar = 0;
|
||||
hotkeyChar = SDLK_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -336,78 +337,80 @@ void MenuStateKeysetup::showMessageBox(const string &text, const string &header,
|
|||
}
|
||||
|
||||
|
||||
void MenuStateKeysetup::keyDown(char key) {
|
||||
hotkeyChar = key;
|
||||
void MenuStateKeysetup::keyDown(SDL_KeyboardEvent key) {
|
||||
hotkeyChar = extractKeyPressed(key);
|
||||
printf("\nkeyDown [%d]\n",hotkeyChar);
|
||||
|
||||
string keyName = "";
|
||||
if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDLK_LAST) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key);
|
||||
keyName = SDL_GetKeyName(static_cast<SDLKey>(hotkeyChar));
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);
|
||||
keyName = SDL_GetKeyName(hotkeyChar);
|
||||
}
|
||||
//key = hotkeyChar;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);
|
||||
|
||||
SDLKey keysym = SDLK_UNKNOWN;
|
||||
if(keyName == "unknown key" || keyName == "") {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
keysym = configKeys.translateSpecialStringToSDLKey(hotkeyChar);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keysym [%d]\n",__FILE__,__FUNCTION__,__LINE__,keysym);
|
||||
|
||||
// SDL skips capital letters
|
||||
if(keysym >= 65 && keysym <= 90) {
|
||||
keysym = (SDLKey)((int)keysym + 32);
|
||||
}
|
||||
//if(keysym < 255) {
|
||||
// key = keysym;
|
||||
//}
|
||||
keyName = SDL_GetKeyName(keysym);
|
||||
}
|
||||
// SDLKey keysym = SDLK_UNKNOWN;
|
||||
// if(keyName == "unknown key" || keyName == "") {
|
||||
// Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
// keysym = configKeys.translateSpecialStringToSDLKey(hotkeyChar);
|
||||
//
|
||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keysym [%d]\n",__FILE__,__FUNCTION__,__LINE__,keysym);
|
||||
//
|
||||
// // SDL skips capital letters
|
||||
// if(keysym >= 65 && keysym <= 90) {
|
||||
// keysym = (SDLKey)((int)keysym + 32);
|
||||
// }
|
||||
// //if(keysym < 255) {
|
||||
// // key = keysym;
|
||||
// //}
|
||||
// keyName = SDL_GetKeyName(keysym);
|
||||
// }
|
||||
|
||||
char szBuf[1024] = "";
|
||||
sprintf(szBuf,"%s [%d][%d]",keyName.c_str(),key,keysym);
|
||||
//sprintf(szBuf,"%s [%d][%d]",keyName.c_str(),key.keysym.sym,keysym);
|
||||
sprintf(szBuf,"%s [%d][%d]",keyName.c_str(),key.keysym.sym,hotkeyChar);
|
||||
labelTestValue.setText(szBuf);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] hotkeyChar [%d]\n",__FILE__,__FUNCTION__,__LINE__,hotkeyChar);
|
||||
}
|
||||
|
||||
void MenuStateKeysetup::keyPress(char c) {
|
||||
void MenuStateKeysetup::keyPress(SDL_KeyboardEvent c) {
|
||||
}
|
||||
|
||||
void MenuStateKeysetup::keyUp(char key) {
|
||||
void MenuStateKeysetup::keyUp(SDL_KeyboardEvent key) {
|
||||
//Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(hotkeyIndex >= 0) {
|
||||
if(hotkeyChar != 0) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,hotkeyChar,key);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,hotkeyChar,key.keysym.sym);
|
||||
|
||||
string keyName = "";
|
||||
if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDLK_LAST) {
|
||||
keyName = SDL_GetKeyName(static_cast<SDLKey>(hotkeyChar));
|
||||
keyName = SDL_GetKeyName(hotkeyChar);
|
||||
}
|
||||
key = hotkeyChar;
|
||||
key.keysym.sym = hotkeyChar;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);
|
||||
|
||||
SDLKey keysym = SDLK_UNKNOWN;
|
||||
if(keyName == "unknown key" || keyName == "") {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
keysym = configKeys.translateSpecialStringToSDLKey(hotkeyChar);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keysym [%d]\n",__FILE__,__FUNCTION__,__LINE__,keysym);
|
||||
|
||||
// SDL skips capital letters
|
||||
if(keysym >= 65 && keysym <= 90) {
|
||||
keysym = (SDLKey)((int)keysym + 32);
|
||||
}
|
||||
if(keysym < 255) {
|
||||
key = keysym;
|
||||
}
|
||||
keyName = SDL_GetKeyName(keysym);
|
||||
// Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
// keysym = configKeys.translateSpecialStringToSDLKey(hotkeyChar);
|
||||
//
|
||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keysym [%d]\n",__FILE__,__FUNCTION__,__LINE__,keysym);
|
||||
//
|
||||
// // SDL skips capital letters
|
||||
// if(keysym >= 65 && keysym <= 90) {
|
||||
// keysym = (SDLKey)((int)keysym + 32);
|
||||
// }
|
||||
// if(keysym < 255) {
|
||||
// key = keysym;
|
||||
// }
|
||||
// keyName = SDL_GetKeyName(keysym);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);
|
||||
|
||||
if(keyName != "unknown key") {
|
||||
GraphicLabel *label= labels[hotkeyIndex];
|
||||
|
@ -418,41 +421,43 @@ void MenuStateKeysetup::keyUp(char key) {
|
|||
for(int i = 0; i < userProperties.size(); ++i) {
|
||||
string hotKeyName = userProperties[i].first;
|
||||
if(nameValuePair.first == hotKeyName) {
|
||||
if(keysym <= SDLK_ESCAPE || keysym > 255) {
|
||||
if(keysym <= SDLK_ESCAPE) {
|
||||
userProperties[i].second = intToStr(key);
|
||||
}
|
||||
else {
|
||||
userProperties[i].second = keyName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
userProperties[i].second = "";
|
||||
userProperties[i].second.push_back(key);
|
||||
}
|
||||
// if(keysym <= SDLK_ESCAPE || keysym > 255) {
|
||||
// if(keysym <= SDLK_ESCAPE) {
|
||||
// userProperties[i].second = intToStr(extractKeyPressed(key));
|
||||
// }
|
||||
// else {
|
||||
// userProperties[i].second = keyName;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// userProperties[i].second = "";
|
||||
// userProperties[i].second.push_back(extractKeyPressed(key));
|
||||
// }
|
||||
userProperties[i].second = keyName;
|
||||
isNewUserKeyEntry = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isNewUserKeyEntry == true) {
|
||||
pair<string,string> newNameValuePair = nameValuePair;
|
||||
if(keysym <= SDLK_ESCAPE || keysym > 255) {
|
||||
if(keysym <= SDLK_ESCAPE) {
|
||||
newNameValuePair.second = intToStr(key);
|
||||
}
|
||||
else {
|
||||
newNameValuePair.second = keyName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
newNameValuePair.second = key;
|
||||
}
|
||||
// if(keysym <= SDLK_ESCAPE || keysym > 255) {
|
||||
// if(keysym <= SDLK_ESCAPE) {
|
||||
// newNameValuePair.second = intToStr(extractKeyPressed(key));
|
||||
// }
|
||||
// else {
|
||||
// newNameValuePair.second = keyName;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// newNameValuePair.second = extractKeyPressed(key);
|
||||
// }
|
||||
newNameValuePair.second = keyName;
|
||||
userProperties.push_back(newNameValuePair);
|
||||
}
|
||||
}
|
||||
}
|
||||
hotkeyIndex = -1;
|
||||
hotkeyChar = 0;
|
||||
hotkeyChar = SDLK_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ private:
|
|||
vector<pair<string,string> > userProperties;
|
||||
|
||||
int hotkeyIndex;
|
||||
char hotkeyChar;
|
||||
//char hotkeyChar;
|
||||
SDLKey hotkeyChar;
|
||||
|
||||
GraphicLabel labelTestTitle;
|
||||
GraphicLabel labelTestValue;
|
||||
|
@ -65,9 +66,9 @@ public:
|
|||
void update();
|
||||
void render();
|
||||
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyUp(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
|
||||
virtual bool isInSpecialKeyCaptureEvent() { return true; }
|
||||
|
||||
|
|
|
@ -796,7 +796,7 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
|
|||
consoleIRC.addLine("---------------------------------------------");
|
||||
// write hint to console:
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
consoleIRC.addLine(Lang::getInstance().get("To switch off music press")+" - \""+configKeys.getCharKey("ToggleMusic")+"\"");
|
||||
consoleIRC.addLine(Lang::getInstance().get("To switch off music press")+" - \""+configKeys.getString("ToggleMusic")+"\"");
|
||||
|
||||
announcementLoaded=true;
|
||||
}
|
||||
|
@ -976,7 +976,7 @@ void MenuStateMasterserver::showMessageBox(const string &text, const string &hea
|
|||
}
|
||||
|
||||
|
||||
void MenuStateMasterserver::keyDown(char key) {
|
||||
void MenuStateMasterserver::keyDown(SDL_KeyboardEvent key) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if (ircClient != NULL && ircClient->isConnected() == true
|
||||
|
@ -985,7 +985,8 @@ void MenuStateMasterserver::keyDown(char key) {
|
|||
if (chatManager.getEditEnabled() == true) {
|
||||
//printf("keyDown key [%d] chatManager.getText() [%s]\n",key,chatManager.getText().c_str());
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if (key == vkReturn && ircClient != NULL) {
|
||||
//if (key == vkReturn && ircClient != NULL) {
|
||||
if(isKeyPressed(SDLK_RETURN,key) == true && ircClient != NULL) {
|
||||
ircClient->SendIRCCmdMessage(IRC_CHANNEL, chatManager.getText());
|
||||
}
|
||||
}
|
||||
|
@ -993,7 +994,8 @@ void MenuStateMasterserver::keyDown(char key) {
|
|||
chatManager.keyDown(key);
|
||||
}
|
||||
if(chatManager.getEditEnabled() == false) {
|
||||
if(key == configKeys.getCharKey("ToggleMusic")) {
|
||||
//if(key == configKeys.getCharKey("ToggleMusic")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("ToggleMusic"),key) == true) {
|
||||
Config &config = Config::getInstance();
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
|
@ -1010,7 +1012,8 @@ void MenuStateMasterserver::keyDown(char key) {
|
|||
consoleIRC.addLine(lang.get("GameMusic"));
|
||||
}
|
||||
}
|
||||
else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
Lang &lang= Lang::getInstance();
|
||||
consoleIRC.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
@ -1018,13 +1021,13 @@ void MenuStateMasterserver::keyDown(char key) {
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateMasterserver::keyPress(char c) {
|
||||
void MenuStateMasterserver::keyPress(SDL_KeyboardEvent c) {
|
||||
if (ircClient != NULL && ircClient->isConnected() == true
|
||||
&& ircClient->getHasJoinedChannel() == true) {
|
||||
chatManager.keyPress(c);
|
||||
}
|
||||
}
|
||||
void MenuStateMasterserver::keyUp(char key) {
|
||||
void MenuStateMasterserver::keyUp(SDL_KeyboardEvent key) {
|
||||
if (ircClient != NULL && ircClient->isConnected() == true
|
||||
&& ircClient->getHasJoinedChannel() == true) {
|
||||
chatManager.keyUp(key);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Martiño Figueroa
|
||||
// Copyright (C) 2001-2005 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -119,9 +119,9 @@ public:
|
|||
void update();
|
||||
void render();
|
||||
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyUp(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
|
||||
virtual void simpleTask(BaseThread *callingThread);
|
||||
virtual bool isInSpecialKeyCaptureEvent() { return chatManager.getEditEnabled(); }
|
||||
|
|
|
@ -2011,19 +2011,21 @@ void MenuStateMods::update() {
|
|||
console.update();
|
||||
}
|
||||
|
||||
void MenuStateMods::keyDown(char key) {
|
||||
void MenuStateMods::keyDown(SDL_KeyboardEvent key) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
//if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||
showFullConsole= true;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateMods::keyPress(char c) {
|
||||
void MenuStateMods::keyPress(SDL_KeyboardEvent c) {
|
||||
}
|
||||
|
||||
void MenuStateMods::keyUp(char key) {
|
||||
void MenuStateMods::keyUp(SDL_KeyboardEvent key) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(key== configKeys.getCharKey("ShowFullConsole")) {
|
||||
//if(key== configKeys.getCharKey("ShowFullConsole")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||
showFullConsole= false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,9 +186,9 @@ public:
|
|||
void render();
|
||||
void update();
|
||||
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyUp(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
|
||||
virtual void simpleTask(BaseThread *callingThread);
|
||||
|
||||
|
|
|
@ -133,9 +133,10 @@ void MenuStateNewGame::update(){
|
|||
console.update();
|
||||
}
|
||||
|
||||
void MenuStateNewGame::keyDown(char key) {
|
||||
void MenuStateNewGame::keyDown(SDL_KeyboardEvent key) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Martiño Figueroa
|
||||
// Copyright (C) 2001-2005 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void update();
|
||||
void render();
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -682,9 +682,10 @@ bool MenuStateOptions::isInSpecialKeyCaptureEvent() {
|
|||
return (activeInputLabel != NULL);
|
||||
}
|
||||
|
||||
void MenuStateOptions::keyDown(char key){
|
||||
void MenuStateOptions::keyDown(SDL_KeyboardEvent key) {
|
||||
if(activeInputLabel != NULL) {
|
||||
if(key == vkBack) {
|
||||
//if(key == vkBack) {
|
||||
if(isKeyPressed(SDLK_BACKSPACE,key) == true) {
|
||||
string text= activeInputLabel->getText();
|
||||
if(text.size() > 1) {
|
||||
text.erase(text.end()-2);
|
||||
|
@ -694,28 +695,29 @@ void MenuStateOptions::keyDown(char key){
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateOptions::keyPress(char c){
|
||||
if(activeInputLabel!=NULL)
|
||||
{
|
||||
void MenuStateOptions::keyPress(SDL_KeyboardEvent c) {
|
||||
if(activeInputLabel!=NULL) {
|
||||
//printf("[%d]\n",c); fflush(stdout);
|
||||
int maxTextSize= 16;
|
||||
if(&labelPlayerName==activeInputLabel){
|
||||
if((c>='0' && c<='9')||(c>='a' && c<='z')||(c>='A' && c<='Z')||
|
||||
if(&labelPlayerName==activeInputLabel) {
|
||||
SDLKey key = extractKeyPressed(c);
|
||||
//if((c>='0' && c<='9')||(c>='a' && c<='z')||(c>='A' && c<='Z')||
|
||||
// (c>=(192-256) && c<=(255-256))|| // test some support for accented letters in names, is this ok? (latin1 signed char)
|
||||
// no master server breaks, and a russian translation with game switched to KOI-8p encoding? probably irc too.
|
||||
// (use Shared::Platform::charSet in shared_lib/include/platform/sdl/gl_wrap.h ?)
|
||||
(c=='-')||(c=='(')||(c==')')){
|
||||
//(c=='-')||(c=='(')||(c==')')){
|
||||
if(activeInputLabel->getText().size()<maxTextSize){
|
||||
string text= activeInputLabel->getText();
|
||||
text.insert(text.end()-1, c);
|
||||
text.insert(text.end()-1, key);
|
||||
activeInputLabel->setText(text);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(c == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//if(c == configKeys.getCharKey("SaveGUILayout")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),c) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
|
|
@ -127,8 +127,8 @@ public:
|
|||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void render();
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyPress(char c);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual bool isInSpecialKeyCaptureEvent();
|
||||
|
||||
private:
|
||||
|
|
|
@ -210,18 +210,22 @@ void MenuStateRoot::update(){
|
|||
console.update();
|
||||
}
|
||||
|
||||
void MenuStateRoot::keyDown(char key) {
|
||||
void MenuStateRoot::keyDown(SDL_KeyboardEvent key) {
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] key = [%d - %c]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] key = [%d - %c]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym,key.keysym.sym);
|
||||
|
||||
//printf("\n\n\nIN MENU STATE ROOT KEYDOWN!!!\n\n\n");
|
||||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
//exit
|
||||
if(key == configKeys.getCharKey("ExitKey")) {
|
||||
//if(key == configKeys.getCharKey("ExitKey")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("ExitKey"),key) == true) {
|
||||
Lang &lang= Lang::getInstance();
|
||||
showMessageBox(lang.get("ExitGame?"), "", true);
|
||||
}
|
||||
else if(mainMessageBox.getEnabled() == true && key == vkReturn) {
|
||||
//else if(mainMessageBox.getEnabled() == true && key == vkReturn) {
|
||||
else if(mainMessageBox.getEnabled() == true && isKeyPressed(SDLK_RETURN,key) == true) {
|
||||
SDL_keysym keystate = Window::getKeystate();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keystate.mod [%d]\n",__FILE__,__FUNCTION__,__LINE__,keystate.mod);
|
||||
|
||||
|
@ -233,7 +237,8 @@ void MenuStateRoot::keyDown(char key) {
|
|||
program->exit();
|
||||
}
|
||||
}
|
||||
else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void render();
|
||||
void update();
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
};
|
||||
|
||||
|
|
|
@ -471,9 +471,10 @@ void MenuStateScenario::showMessageBox(const string &text, const string &header,
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateScenario::keyDown(char key) {
|
||||
void MenuStateScenario::keyDown(SDL_KeyboardEvent key) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
//if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
void setScenario(int i);
|
||||
int getScenarioCount() const { return listBoxScenario.getItemCount(); }
|
||||
|
||||
virtual void keyDown(char key);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -208,17 +208,17 @@ protected:
|
|||
virtual void eventMouseMove(int x, int y, const MouseState* mouseState){}
|
||||
virtual void eventMouseDoubleClick(int x, int y, MouseButton mouseButton){}
|
||||
virtual void eventMouseWheel(int x, int y, int zDelta) {}
|
||||
virtual void eventKeyDown(char key){}
|
||||
virtual void eventKeyUp(char key){}
|
||||
virtual void eventKeyPress(char c){}
|
||||
virtual void eventResize(){};
|
||||
virtual void eventPaint(){}
|
||||
virtual void eventTimer(int timerId){}
|
||||
virtual void eventActivate(bool activated){};
|
||||
virtual void eventResize(SizeState sizeState){};
|
||||
virtual void eventMenu(int menuId){}
|
||||
virtual void eventClose(){};
|
||||
virtual void eventDestroy(){};
|
||||
virtual void eventKeyDown(SDL_KeyboardEvent key) {}
|
||||
virtual void eventKeyUp(SDL_KeyboardEvent key) {}
|
||||
virtual void eventKeyPress(SDL_KeyboardEvent c) {}
|
||||
virtual void eventResize() {};
|
||||
virtual void eventPaint() {}
|
||||
virtual void eventTimer(int timerId) {}
|
||||
virtual void eventActivate(bool activated) {};
|
||||
virtual void eventResize(SizeState sizeState) {};
|
||||
virtual void eventMenu(int menuId) {}
|
||||
virtual void eventClose() {};
|
||||
virtual void eventDestroy() {};
|
||||
|
||||
private:
|
||||
/// needed to detect double clicks
|
||||
|
@ -230,6 +230,10 @@ private:
|
|||
static void toggleFullscreen();
|
||||
};
|
||||
|
||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input);
|
||||
SDLKey extractKeyPressed(SDL_KeyboardEvent input);
|
||||
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -190,12 +190,12 @@ bool Window::handleEvent() {
|
|||
}
|
||||
#endif
|
||||
if(global_window) {
|
||||
char key = getKey(event.key.keysym,true);
|
||||
key = tolower(key);
|
||||
//char key = getKey(event.key.keysym,true);
|
||||
//key = tolower(key);
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("******************* key [%d]\n",key);
|
||||
|
||||
global_window->eventKeyDown(key);
|
||||
global_window->eventKeyPress(getRawKey(event.key.keysym));
|
||||
global_window->eventKeyDown(event.key);
|
||||
global_window->eventKeyPress(event.key);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
@ -217,9 +217,9 @@ bool Window::handleEvent() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] KEY_UP, Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d]\n",__FILE__,__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode);
|
||||
|
||||
if(global_window) {
|
||||
char key = getKey(event.key.keysym,true);
|
||||
key = tolower(key);
|
||||
global_window->eventKeyUp(key);
|
||||
//char key = getKey(event.key.keysym,true);
|
||||
//key = tolower(key);
|
||||
global_window->eventKeyUp(event.key);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYUP ================================\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -942,4 +942,75 @@ char Window::getKey(SDL_keysym keysym,bool skipSpecialKeys) {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input) {
|
||||
Uint16 c = 0;
|
||||
if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
c = input.keysym.unicode;
|
||||
//c = toupper(c);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF));
|
||||
}
|
||||
//if(c == 0) {
|
||||
if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
||||
c = input.keysym.sym;
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
||||
|
||||
//c = (c & 0xFF);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
||||
|
||||
// SDL does NOT handle lowercase
|
||||
if(c >= 'A' && c <= 'Z') {
|
||||
c = tolower(c);
|
||||
}
|
||||
// SDL does NOT handle lowercase
|
||||
if(compareKey >= 'A' && compareKey <= 'Z') {
|
||||
compareKey = (SDLKey)tolower((char)compareKey);
|
||||
}
|
||||
|
||||
bool result = (c == compareKey);
|
||||
if(result == false) {
|
||||
if(compareKey == SDLK_RETURN) {
|
||||
result = (c == SDLK_KP_ENTER);
|
||||
}
|
||||
}
|
||||
|
||||
string compareKeyName = SDL_GetKeyName(compareKey);
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result);
|
||||
//printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
||||
SDLKey c = SDLK_UNKNOWN;
|
||||
if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
c = (SDLKey)input.keysym.unicode;
|
||||
//c = toupper(c);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF));
|
||||
}
|
||||
if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
||||
c = input.keysym.sym;
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
||||
|
||||
//c = (SDLKey)(c & 0xFF);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str());
|
||||
//printf ("In [%s::%s Line: %d] pressed key [%d - %s] input [%d - %s] input.keysym.unicode [%d]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str(),input.keysym.sym,inputKeyName.c_str(),input.keysym.unicode);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
Loading…
Reference in New Issue