From d1f4250b10d10b4ce6126524dc14cb1cfc1abee9 Mon Sep 17 00:00:00 2001 From: learn_more Date: Sun, 9 Mar 2014 14:32:45 +0100 Subject: [PATCH] fix some windows build issues Fixes #169 by ignoring the activation key. --- Sources/Client/ChatWindow.cpp | 2 +- Sources/Client/Client.cpp | 16 +++++++++++++--- Sources/Client/ClientUI.cpp | 10 +++++++++- Sources/Client/ClientUI.h | 5 +++++ Sources/Client/HitTestDebugger.cpp | 1 + 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Sources/Client/ChatWindow.cpp b/Sources/Client/ChatWindow.cpp index 1f7d341b..45306763 100644 --- a/Sources/Client/ChatWindow.cpp +++ b/Sources/Client/ChatWindow.cpp @@ -259,7 +259,7 @@ namespace spades { float y = firstY; - Vector4 shadowColor = {0, 0, 0, 0.8}; + Vector4 shadowColor = {0, 0, 0, 0.8f}; for(it = entries.begin(); it != entries.end(); ++it){ ChatEntry& ent = *it; diff --git a/Sources/Client/Client.cpp b/Sources/Client/Client.cpp index 1bf5cd05..868297c5 100644 --- a/Sources/Client/Client.cpp +++ b/Sources/Client/Client.cpp @@ -956,7 +956,7 @@ namespace spades { void Client::TextInputEvent(const std::string &ch){ SPADES_MARK_FUNCTION(); - if(scriptedUI->NeedsInput()) { + if (scriptedUI->NeedsInput() && !scriptedUI->isIgnored(ch)) { scriptedUI->TextInputEvent(ch); return; } @@ -968,7 +968,7 @@ namespace spades { int start, int len) { SPADES_MARK_FUNCTION(); - if(scriptedUI->NeedsInput()) { + if (scriptedUI->NeedsInput() && !scriptedUI->isIgnored(ch)) { scriptedUI->TextEditingEvent(ch, start, len); return; } @@ -1021,7 +1021,14 @@ namespace spades { SPADES_MARK_FUNCTION(); if(scriptedUI->NeedsInput()) { - scriptedUI->KeyEvent(name, down); + if (!scriptedUI->isIgnored(name)) { + scriptedUI->KeyEvent(name, down); + } + else { + if (!down) { + scriptedUI->setIgnored(""); + } + } return; } @@ -1195,12 +1202,15 @@ namespace spades { }else if(CheckKey(cg_keyGlobalChat, name) && down){ // global chat scriptedUI->EnterGlobalChatWindow(); + scriptedUI->setIgnored(name); }else if(CheckKey(cg_keyTeamChat, name) && down){ // team chat scriptedUI->EnterTeamChatWindow(); + scriptedUI->setIgnored(name); }else if(name == "/" && down){ // command scriptedUI->EnterCommandWindow(); + scriptedUI->setIgnored(name); }else if(CheckKey(cg_keyCaptureColor, name) && down){ CaptureColor(); }else if(CheckKey(cg_keyChangeMapScale, name) && down){ diff --git a/Sources/Client/ClientUI.cpp b/Sources/Client/ClientUI.cpp index 84bdd23f..7506d6f0 100644 --- a/Sources/Client/ClientUI.cpp +++ b/Sources/Client/ClientUI.cpp @@ -277,7 +277,15 @@ namespace spades { c->SetObject(&*ui); c.ExecuteChecked(); } - + + bool ClientUI::isIgnored(const std::string& key) + { + return !ignoreInput.empty() && ignoreInput == key; + } + void ClientUI::setIgnored(const std::string& key) + { + ignoreInput = key; + } } } diff --git a/Sources/Client/ClientUI.h b/Sources/Client/ClientUI.h index ebc29ff0..4bb1e954 100644 --- a/Sources/Client/ClientUI.h +++ b/Sources/Client/ClientUI.h @@ -43,6 +43,7 @@ namespace spades { // weak reference Client *client; + std::string ignoreInput; void SendChat(const std::string&, bool isGlobal); @@ -80,6 +81,10 @@ namespace spades { void EnterTeamChatWindow(); void EnterCommandWindow(); void CloseUI(); + + //lm: so the chat does not have the initial chat key + bool isIgnored(const std::string& key); + void setIgnored(const std::string& key); };; } } diff --git a/Sources/Client/HitTestDebugger.cpp b/Sources/Client/HitTestDebugger.cpp index 649c0683..6abd23b2 100644 --- a/Sources/Client/HitTestDebugger.cpp +++ b/Sources/Client/HitTestDebugger.cpp @@ -30,6 +30,7 @@ #include "GameMap.h" #include #include +#include //windows needs this. SPADES_SETTING(cg_smp, "");