mirror of
https://github.com/glest/glest-source.git
synced 2025-09-28 08:29:00 +02:00
- attempt to see if IRC chat works better with sdl2 textinput
This commit is contained in:
@@ -95,6 +95,23 @@ void ChatManager::keyUp(SDL_KeyboardEvent key) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
bool ChatManager::textInput(std::string text) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] text [%s]\n",__FILE__,__FUNCTION__,__LINE__,text.c_str());
|
||||
|
||||
int maxTextLenAllowed = (customCB != NULL ? this->maxCustomTextLength : maxTextLenght);
|
||||
if(editEnabled && (int)text.size() < maxTextLenAllowed) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//space is the first meaningful code
|
||||
//wchar_t key = extractKeyPressedUnicode(c);
|
||||
//wchar_t textAppend[] = { key, 0 };
|
||||
std::wstring widestr = std::wstring(text.begin(), text.end());
|
||||
const wchar_t *textAppend = widestr.c_str();
|
||||
appendText(textAppend);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@@ -77,6 +77,7 @@ public:
|
||||
ChatManager();
|
||||
void init(Console* console, int thisTeamIndex, const bool inMenu=false, string manualPlayerNameOverride="");
|
||||
|
||||
bool textInput(std::string text);
|
||||
void keyDown(SDL_KeyboardEvent key);
|
||||
void keyUp(SDL_KeyboardEvent key);
|
||||
void keyPress(SDL_KeyboardEvent c);
|
||||
|
@@ -1090,6 +1090,20 @@ void MainWindow::toggleLanguage(string language) {
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::eventTextInput(std::string text) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,text.c_str());
|
||||
|
||||
if(program == NULL) {
|
||||
throw megaglest_runtime_error("In [MainWindow::eventKeyDown] ERROR, program == NULL!");
|
||||
}
|
||||
|
||||
bool result = program->textInput(text);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] result = %d\n",__FILE__,__FUNCTION__,__LINE__,result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym);
|
||||
|
||||
|
@@ -48,6 +48,7 @@ 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 bool eventTextInput(std::string text);
|
||||
virtual void eventKeyDown(SDL_KeyboardEvent key);
|
||||
virtual void eventMouseWheel(int x, int y, int zDelta);
|
||||
virtual void eventKeyUp(SDL_KeyboardEvent key);
|
||||
|
@@ -321,6 +321,14 @@ void Program::restoreStateFromSystemError() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Program::textInput(std::string text) {
|
||||
if(msgBox.getEnabled()) {
|
||||
return false;
|
||||
}
|
||||
//delegate event
|
||||
return programState->textInput(text);
|
||||
}
|
||||
|
||||
void Program::keyDown(SDL_KeyboardEvent key) {
|
||||
if(msgBox.getEnabled()) {
|
||||
//SDL_keysym keystate = Window::getKeystate();
|
||||
|
@@ -94,6 +94,7 @@ 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 bool textInput(std::string text){ return false; };
|
||||
virtual void keyDown(SDL_KeyboardEvent key){};
|
||||
virtual void keyUp(SDL_KeyboardEvent key){};
|
||||
virtual void keyPress(SDL_KeyboardEvent c){};
|
||||
@@ -192,6 +193,7 @@ public:
|
||||
void initScenario(WindowGl *window, string autoloadScenarioName);
|
||||
|
||||
//main
|
||||
bool textInput(std::string text);
|
||||
void keyDown(SDL_KeyboardEvent key);
|
||||
void keyUp(SDL_KeyboardEvent key);
|
||||
void keyPress(SDL_KeyboardEvent c);
|
||||
|
@@ -233,6 +233,9 @@ void MainMenu::mouseUpLeft(int x, int y){
|
||||
state->mouseUp(x, y, mbLeft);
|
||||
}
|
||||
|
||||
bool MainMenu::textInput(std::string text) {
|
||||
return state->textInput(text);
|
||||
}
|
||||
void MainMenu::keyDown(SDL_KeyboardEvent key) {
|
||||
state->keyDown(key);
|
||||
}
|
||||
|
@@ -75,6 +75,7 @@ public:
|
||||
virtual void mouseDownLeft(int x, int y);
|
||||
virtual void mouseDownRight(int x, int y);
|
||||
virtual void mouseUpLeft(int x, int y);
|
||||
virtual bool textInput(std::string text);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent key);
|
||||
@@ -120,6 +121,8 @@ public:
|
||||
virtual void mouseMove(int x, int y, const MouseState *mouseState)=0;
|
||||
virtual void render()=0;
|
||||
virtual void update(){};
|
||||
|
||||
virtual bool textInput(std::string text) {return false; }
|
||||
virtual void keyDown(SDL_KeyboardEvent key){};
|
||||
virtual void keyPress(SDL_KeyboardEvent c){};
|
||||
virtual void keyUp(SDL_KeyboardEvent key){};
|
||||
|
@@ -1194,7 +1194,19 @@ void MenuStateMasterserver::showMessageBox(const string &text, const string &hea
|
||||
}
|
||||
|
||||
|
||||
bool MenuStateMasterserver::textInput(std::string text) {
|
||||
//printf("In [%s::%s Line: %d] text [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,text.c_str());
|
||||
|
||||
if (ircClient != NULL && ircClient->isConnected() == true
|
||||
&& ircClient->getHasJoinedChannel() == true) {
|
||||
return chatManager.textInput(text);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MenuStateMasterserver::keyDown(SDL_KeyboardEvent key) {
|
||||
//printf("In [%s::%s Line: %d] key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key.keysym.sym);
|
||||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if (ircClient != NULL && ircClient->isConnected() == true
|
||||
|
@@ -122,6 +122,7 @@ public:
|
||||
void update();
|
||||
void render();
|
||||
|
||||
virtual bool textInput(std::string text);
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
virtual void keyPress(SDL_KeyboardEvent c);
|
||||
virtual void keyUp(SDL_KeyboardEvent key);
|
||||
|
@@ -204,6 +204,7 @@ protected:
|
||||
virtual void eventKeyDown(SDL_KeyboardEvent key) {}
|
||||
virtual void eventKeyUp(SDL_KeyboardEvent key) {}
|
||||
virtual void eventKeyPress(SDL_KeyboardEvent c) {}
|
||||
virtual bool eventTextInput(std::string text) { return false; }
|
||||
virtual void eventResize() {};
|
||||
virtual void eventPaint() {}
|
||||
virtual void eventTimer(int timerId) {}
|
||||
|
@@ -321,11 +321,11 @@ bool Window::handleEvent() {
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("******************* key [%d]\n",key);
|
||||
|
||||
//event.key.keysym.mod = SDL_GetModState();
|
||||
|
||||
if(global_window->eventTextInput(event.text.text) == false) {
|
||||
event.key.keysym.sym = event.text.text[0];
|
||||
|
||||
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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
@@ -338,10 +338,9 @@ bool Window::handleEvent() {
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
//printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
{
|
||||
|
||||
//printf("In SDL_KEYDOWN\n");
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYDOWN ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
// if(SDL_GetModState() == 0 && event.key.keysym.sym != SDLK_BACKSPACE) {
|
||||
|
Reference in New Issue
Block a user