- attempt to NOT convert to utf8 twice
This commit is contained in:
parent
fd8ed536bb
commit
aa677cfc97
|
@ -19,6 +19,7 @@
|
|||
#include "core_data.h"
|
||||
#include "util.h"
|
||||
#include <stdexcept>
|
||||
#include "string_utils.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -183,8 +184,13 @@ void ChatManager::keyPress(SDL_KeyboardEvent 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(extractKeyPressed(c) >= SDLK_SPACE) {
|
||||
text += extractKeyPressed(c);
|
||||
SDLKey key = extractKeyPressed(c);
|
||||
if(key >= SDLK_SPACE) {
|
||||
char szCharText[20]="";
|
||||
sprintf(szCharText,"%c",key);
|
||||
char *utfStr = String::ConvertToUTF8(&szCharText[0]);
|
||||
text += utfStr;
|
||||
delete [] utfStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
#include <algorithm>
|
||||
#include <time.h>
|
||||
#include "cache_manager.h"
|
||||
#include "leak_dumper.h"
|
||||
#include "string_utils.h"
|
||||
#include "map_preview.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
|
@ -2142,7 +2143,13 @@ void MenuStateConnectedGame::keyPress(SDL_KeyboardEvent c) {
|
|||
// (c=='-') || (c=='(') || (c==')')) {
|
||||
if(activeInputLabel->getText().size() < maxTextSize) {
|
||||
string text= activeInputLabel->getText();
|
||||
text.insert(text.end() -1, key);
|
||||
|
||||
char szCharText[20]="";
|
||||
sprintf(szCharText,"%c",key);
|
||||
char *utfStr = String::ConvertToUTF8(&szCharText[0]);
|
||||
text.insert(text.end() -1, utfStr[0]);
|
||||
delete [] utfStr;
|
||||
|
||||
activeInputLabel->setText(text);
|
||||
|
||||
switchSetupRequestFlagType |= ssrft_NetworkPlayerName;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "cache_manager.h"
|
||||
#include <iterator>
|
||||
#include "map_preview.h"
|
||||
#include "string_utils.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
@ -2953,7 +2954,13 @@ void MenuStateCustomGame::keyPress(SDL_KeyboardEvent c) {
|
|||
// (c=='-') || (c=='(') || (c==')')) {
|
||||
if(activeInputLabel->getText().size() < maxTextSize) {
|
||||
string text= activeInputLabel->getText();
|
||||
text.insert(text.end()-1, key);
|
||||
//text.insert(text.end()-1, key);
|
||||
char szCharText[20]="";
|
||||
sprintf(szCharText,"%c",key);
|
||||
char *utfStr = String::ConvertToUTF8(&szCharText[0]);
|
||||
text.insert(text.end() -1, utfStr[0]);
|
||||
delete [] utfStr;
|
||||
|
||||
activeInputLabel->setText(text);
|
||||
|
||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "client_interface.h"
|
||||
#include "conversion.h"
|
||||
#include "game.h"
|
||||
#include "string_utils.h"
|
||||
#include "socket.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
@ -520,7 +521,13 @@ void MenuStateJoinGame::keyPress(SDL_KeyboardEvent c) {
|
|||
if(key >= SDLK_0 && key <= SDLK_9) {
|
||||
if(labelServerIp.getText().size() < maxTextSize) {
|
||||
string text= labelServerIp.getText();
|
||||
text.insert(text.end()-1, key);
|
||||
//text.insert(text.end()-1, key);
|
||||
char szCharText[20]="";
|
||||
sprintf(szCharText,"%c",key);
|
||||
char *utfStr = String::ConvertToUTF8(&szCharText[0]);
|
||||
text.insert(text.end() -1, utfStr[0]);
|
||||
delete [] utfStr;
|
||||
|
||||
labelServerIp.setText(text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "util.h"
|
||||
#include "menu_state_graphic_info.h"
|
||||
#include "menu_state_keysetup.h"
|
||||
|
||||
#include "string_utils.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
|
@ -708,7 +708,13 @@ void MenuStateOptions::keyPress(SDL_KeyboardEvent c) {
|
|||
//(c=='-')||(c=='(')||(c==')')){
|
||||
if(activeInputLabel->getText().size()<maxTextSize){
|
||||
string text= activeInputLabel->getText();
|
||||
text.insert(text.end()-1, key);
|
||||
//text.insert(text.end()-1, key);
|
||||
char szCharText[20]="";
|
||||
sprintf(szCharText,"%c",key);
|
||||
char *utfStr = String::ConvertToUTF8(&szCharText[0]);
|
||||
text.insert(text.end() -1, utfStr[0]);
|
||||
delete [] utfStr;
|
||||
|
||||
activeInputLabel->setText(text);
|
||||
}
|
||||
//}
|
||||
|
|
|
@ -249,21 +249,21 @@ void TotalUpgrade::reset() {
|
|||
|
||||
void TotalUpgrade::sum(const UpgradeTypeBase *ut) {
|
||||
maxHp+= ut->getMaxHp();
|
||||
maxHp = max(0,maxHp);
|
||||
//maxHp = max(0,maxHp);
|
||||
maxEp+= ut->getMaxEp();
|
||||
maxEp = max(0,maxEp);
|
||||
//maxEp = max(0,maxEp);
|
||||
sight+= ut->getSight();
|
||||
sight = max(0,sight);
|
||||
//sight = max(0,sight);
|
||||
armor+= ut->getArmor();
|
||||
armor = max(0,armor);
|
||||
//armor = max(0,armor);
|
||||
attackStrength+= ut->getAttackStrength();
|
||||
attackStrength = max(0,attackStrength);
|
||||
//attackStrength = max(0,attackStrength);
|
||||
attackRange+= ut->getAttackRange();
|
||||
attackRange = max(0,attackRange);
|
||||
//attackRange = max(0,attackRange);
|
||||
moveSpeed+= ut->getMoveSpeed();
|
||||
moveSpeed = max(0,moveSpeed);
|
||||
//moveSpeed = max(0,moveSpeed);
|
||||
prodSpeed+= ut->getProdSpeed();
|
||||
prodSpeed = max(0,prodSpeed);
|
||||
//prodSpeed = max(0,prodSpeed);
|
||||
}
|
||||
|
||||
void TotalUpgrade::incLevel(const UnitType *ut) {
|
||||
|
|
|
@ -67,9 +67,9 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
|
|||
|
||||
Vec2f rasterPos;
|
||||
if(font->getTextHandler() != NULL) {
|
||||
char *utfStr = String::ConvertToUTF8(renderText.c_str());
|
||||
renderText = utfStr;
|
||||
delete [] utfStr;
|
||||
//char *utfStr = String::ConvertToUTF8(renderText.c_str());
|
||||
//renderText = utfStr;
|
||||
//delete [] utfStr;
|
||||
|
||||
if(centered) {
|
||||
rasterPos.x= x - font->getTextHandler()->Advance(renderText.c_str()) / 2.f;
|
||||
|
@ -455,9 +455,9 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
|
|||
FontMetrics *metrics= font->getMetrics();
|
||||
|
||||
if(font->getTextHandler() != NULL) {
|
||||
char *utfStr = String::ConvertToUTF8(renderText.c_str());
|
||||
renderText = utfStr;
|
||||
delete [] utfStr;
|
||||
//char *utfStr = String::ConvertToUTF8(renderText.c_str());
|
||||
//renderText = utfStr;
|
||||
//delete [] utfStr;
|
||||
|
||||
//centered = false;
|
||||
if(centered) {
|
||||
|
|
|
@ -990,7 +990,8 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input) {
|
|||
|
||||
SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
||||
SDLKey c = SDLK_UNKNOWN;
|
||||
if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||
if(input.keysym.unicode > 0) {
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user