mirror of
https://github.com/glest/glest-source.git
synced 2025-08-22 16:02:50 +02:00
- added ability to switch languages from nearly anywhere (and new hotkeys to do so):
CTRL+L shows language popup selection, CTRL+SHIFT+L toggles to next language automatically
This commit is contained in:
@@ -52,6 +52,34 @@ int Font::faceResolution = 72;
|
||||
string Font::langHeightText = "yW";
|
||||
//
|
||||
|
||||
void Font::resetToDefaults() {
|
||||
Font::charCount = 256;
|
||||
Font::fontTypeName = "Times New Roman";
|
||||
Font::fontIsMultibyte = false;
|
||||
Font::forceLegacyFonts = false;
|
||||
Font::fontIsRightToLeft = false;
|
||||
|
||||
// This value is used to scale the font text rendering
|
||||
// in 3D render mode
|
||||
Font::scaleFontValue = 0.80f;
|
||||
// This value is used for centering font text vertically (height)
|
||||
Font::scaleFontValueCenterHFactor = 4.0f;
|
||||
//float Font::scaleFontValue = 1.0;
|
||||
//float Font::scaleFontValueCenterHFactor = 4.0;
|
||||
|
||||
Font::baseSize = 3;
|
||||
|
||||
Font::faceResolution = 72;
|
||||
Font::langHeightText = "yW";
|
||||
|
||||
#if defined(WIN32)
|
||||
string newEnvValue = "MEGAGLEST_FONT=";
|
||||
_putenv(newEnvValue.c_str());
|
||||
#else
|
||||
unsetenv("MEGAGLEST_FONT");
|
||||
#endif
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class FontMetrics
|
||||
// =====================================================
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "graphics_interface.h"
|
||||
#include "graphics_factory.h"
|
||||
#include <stdexcept>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared { namespace Graphics {
|
||||
@@ -40,6 +41,26 @@ Font3D *FontManager::newFont3D() {
|
||||
return font;
|
||||
}
|
||||
|
||||
void FontManager::endFont(Font *font,bool mustExistInList) {
|
||||
if(font != NULL) {
|
||||
bool found = false;
|
||||
for(unsigned int i=0; i < fonts.size(); ++i) {
|
||||
if(fonts[i] != NULL && font == fonts[i]) {
|
||||
found = true;
|
||||
fonts.erase(fonts.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found == false && mustExistInList == true) {
|
||||
throw std::runtime_error("found == false in endFont");
|
||||
}
|
||||
if(found == true) {
|
||||
font->end();
|
||||
delete font;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FontManager::init() {
|
||||
for(size_t i=0; i<fonts.size(); ++i) {
|
||||
if(fonts[i] != NULL) {
|
||||
|
@@ -62,11 +62,11 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
|
||||
//ftFont = new FTGLPixmapFont("/usr/share/fonts/truetype/arphic/uming.ttc");
|
||||
if(type == ftht_2D) {
|
||||
ftFont = new FTGLPixmapFont(fontFile);
|
||||
//printf("2D font [%s]\n",fontFile);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("2D font [%s]\n",fontFile);
|
||||
}
|
||||
else if(type == ftht_3D) {
|
||||
ftFont = new FTGLTextureFont(fontFile);
|
||||
//printf("3D font [%s]\n",fontFile);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("3D font [%s]\n",fontFile);
|
||||
}
|
||||
else {
|
||||
throw runtime_error("font render type not set to a known value!");
|
||||
@@ -234,6 +234,7 @@ void TextFTGL::Render(const char* str, const int len) {
|
||||
if(len != 0) {
|
||||
//printf("FTGL Render [%s] facesize = %d\n",str,ftFont->FaceSize());
|
||||
assertGl();
|
||||
|
||||
ftFont->Render(str, len);
|
||||
//assertGl();
|
||||
GLenum error = glGetError();
|
||||
|
@@ -393,6 +393,11 @@ void TextRenderer3DGl::render(const string &text, float x, float y, bool center
|
||||
//}
|
||||
//if(isRLM == true) {
|
||||
if(is_string_all_ascii(renderText) == false) {
|
||||
//printf("\n\nORIGINAL TEXT [%s]\n\n",text.c_str());
|
||||
//for(int i = 0; i < renderText.size(); ++i) {
|
||||
// printf("i = %d c [%c][%d][%X]\n",i,renderText[i],renderText[i],renderText[i]);
|
||||
//}
|
||||
|
||||
strrev_utf8(renderText);
|
||||
}
|
||||
}
|
||||
|
@@ -83,6 +83,41 @@ void get_nickname(const char *sourceNick,char *destNick,size_t maxDestBufferSize
|
||||
irc_target_get_nick(sourceNickStr.c_str(),destNick,maxDestBufferSize);
|
||||
}
|
||||
|
||||
void event_notice (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) {
|
||||
dump_event (session, event, origin, params, count);
|
||||
|
||||
if(origin == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("NOTICE from '%s': %s", origin, params[1]);
|
||||
|
||||
if(strcasecmp (origin, "nickserv")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(strstr (params[1], "This nick is not registered") == params[1]) {
|
||||
//std::string regcmd = "REGISTER " + gCfg.irc_nickserv_pass + " NOMAIL";
|
||||
//gLog.Add (CLog::INFO, "Registering our nick with NICKSERV");
|
||||
//irc_cmd_msg (session, "nickserv", regcmd.c_str());
|
||||
}
|
||||
else if(strstr (params[1], "This nickname is registered and protected") == params[1]) {
|
||||
//std::string identcmd = "IDENTIFY " + gCfg.irc_nickserv_pass;
|
||||
//gLog.Add (CLog::INFO, "Identifying our nick with NICKSERV");
|
||||
//irc_cmd_msg (session, "nickserv", identcmd.c_str());
|
||||
|
||||
// IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||
// if(ctx != NULL) {
|
||||
// if(ctx->getExecute_cmd_onconnect() != "") {
|
||||
// irc_cmd_msg(session, "nickserv", ctx->getExecute_cmd_onconnect().c_str());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
else if(strstr (params[1], "Password accepted - you are now recognized") == params[1]) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Nickserv authentication succeed.");
|
||||
}
|
||||
}
|
||||
|
||||
void event_join(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) {
|
||||
dump_event (session, event, origin, params, count);
|
||||
|
||||
@@ -125,7 +160,18 @@ void event_connect (irc_session_t * session, const char * event, const char * or
|
||||
|
||||
dump_event(session, event, origin, params, count);
|
||||
|
||||
if(ctx != NULL) {
|
||||
//IRC: Event "433", origin: "leguin.freenode.net", params: 3 [*|softcoder|Nickname is already in use.]
|
||||
// printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
// if(strstr (params[1], "Nickname is already in use") == params[1]) {
|
||||
// IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||
// if(ctx != NULL) {
|
||||
// if(ctx->getExecute_cmd_onconnect() != "") {
|
||||
// irc_cmd_msg(session, "nickserv", ctx->getExecute_cmd_onconnect().c_str());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
if(ctx != NULL) {
|
||||
irc_cmd_join(session, ctx->getChannel().c_str(), 0);
|
||||
}
|
||||
}
|
||||
@@ -188,6 +234,9 @@ void dcc_file_recv_callback (irc_session_t * session, irc_dcc_t id, int status,
|
||||
}
|
||||
|
||||
void event_channel(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) {
|
||||
//IRC: Event "433", origin: "leguin.freenode.net", params: 3 [*|softcoder|Nickname is already in use.]
|
||||
printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if ( count != 2 )
|
||||
return;
|
||||
|
||||
@@ -309,8 +358,40 @@ void event_numeric(irc_session_t * session, unsigned int event, const char * ori
|
||||
//irc_auto_rename_nick(session);
|
||||
//IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||
//if(ctx != NULL) {
|
||||
|
||||
// {
|
||||
// //IRC: Event "433", origin: "leguin.freenode.net", params: 3 [*|softcoder|Nickname is already in use.]
|
||||
// printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
// //if(strstr (params[1], "Nickname is already in use") == params[1]) {
|
||||
// IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||
// if(ctx != NULL) {
|
||||
// if(ctx->getExecute_cmd_onconnect() != "") {
|
||||
// irc_cmd_msg(session, "nickserv", ctx->getExecute_cmd_onconnect().c_str());
|
||||
// }
|
||||
// }
|
||||
// //}
|
||||
// }
|
||||
break;
|
||||
|
||||
case LIBIRC_RFC_ERR_NOTREGISTERED :
|
||||
//irc_auto_rename_nick(session);
|
||||
//IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||
//if(ctx != NULL) {
|
||||
// {
|
||||
//===> IRC: Event "451", origin: "leguin.freenode.net", params: 2 [*|You have not registered]
|
||||
// printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
// //if(strstr (params[1], "Nickname is already in use") == params[1]) {
|
||||
// IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||
// if(ctx != NULL) {
|
||||
// //if(ctx->getExecute_cmd_onconnect() != "") {
|
||||
// //irc_cmd_msg(session, "nickserv", ctx->getExecute_cmd_onconnect().c_str());
|
||||
// string cmd = "REGISTER " + ctx->getNick() + " NOMAIL";
|
||||
// irc_cmd_msg (session, "nickserv", cmd.c_str());
|
||||
// //}
|
||||
// }
|
||||
// //}
|
||||
// }
|
||||
break;
|
||||
|
||||
case LIBIRC_RFC_RPL_TOPIC :
|
||||
break;
|
||||
case LIBIRC_RFC_RPL_NAMREPLY :
|
||||
@@ -462,7 +543,7 @@ void IRCThread::execute() {
|
||||
irc_callbacks_t callbacks;
|
||||
ircSession=NULL;
|
||||
|
||||
if(argv.size() != 3) {
|
||||
if(argv.size() != 5) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC Usage: <server> <nick> <channel> : got params [%ld]\n",(long int)argv.size());
|
||||
return;
|
||||
}
|
||||
@@ -479,7 +560,7 @@ void IRCThread::execute() {
|
||||
callbacks.event_kick = dump_event;
|
||||
callbacks.event_channel = event_channel;
|
||||
callbacks.event_privmsg = event_privmsg;
|
||||
callbacks.event_notice = dump_event;
|
||||
callbacks.event_notice = event_notice;
|
||||
callbacks.event_invite = dump_event;
|
||||
callbacks.event_umode = dump_event;
|
||||
callbacks.event_ctcp_rep = dump_event;
|
||||
@@ -500,6 +581,19 @@ void IRCThread::execute() {
|
||||
return;
|
||||
}
|
||||
|
||||
// this->execute_cmd_onconnect = "";
|
||||
// if(argv.size() >= 5) {
|
||||
// this->execute_cmd_onconnect = argv[4]; // /msg NickServ identify <password>.
|
||||
// }
|
||||
|
||||
// this->password = "";
|
||||
// if(argv.size() >= 5) {
|
||||
// this->password = argv[4];
|
||||
// }
|
||||
this->username = argv[1];
|
||||
if(argv.size() >= 4) {
|
||||
this->username = argv[3];
|
||||
}
|
||||
this->channel = argv[2];
|
||||
this->nick = argv[1];
|
||||
irc_set_ctx(ircSession, this);
|
||||
@@ -508,7 +602,7 @@ void IRCThread::execute() {
|
||||
return;
|
||||
}
|
||||
|
||||
if(irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->nick.c_str(), "megaglest")) {
|
||||
if(irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->username.c_str(), "megaglest")) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC Could not connect: %s\n", irc_strerror (irc_errno(ircSession)));
|
||||
return;
|
||||
}
|
||||
|
@@ -816,39 +816,71 @@ namespace Shared { namespace Util {
|
||||
#define SWP(x,y) (x^=y, y^=x, x^=y)
|
||||
|
||||
void strrev_utf8(char *p) {
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
|
||||
char *q = p;
|
||||
strrev(p); /* call base case */
|
||||
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
|
||||
/* Ok, now fix bass-ackwards UTF chars. */
|
||||
while(q && *q) ++q; /* find eos */
|
||||
while(p < --q)
|
||||
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
while(p < --q) {
|
||||
//printf("In [%s::%s] Line: %d p [%s] q [%s]\n",__FILE__,__FUNCTION__,__LINE__,p,q); fflush(stdout);
|
||||
|
||||
switch( (*q & 0xF0) >> 4 ) {
|
||||
case 0xF: /* U+010000-U+10FFFF: four bytes. */
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
SWP(*(q-0), *(q-3));
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
SWP(*(q-1), *(q-2));
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
q -= 3;
|
||||
break;
|
||||
case 0xE: /* U+000800-U+00FFFF: three bytes. */
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
SWP(*(q-0), *(q-2));
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
q -= 2;
|
||||
break;
|
||||
case 0xC: /* fall-through */
|
||||
case 0xD: /* U+000080-U+0007FF: two bytes. */
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
SWP(*(q-0), *(q-1));
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
q--;
|
||||
break;
|
||||
}
|
||||
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
}
|
||||
//printf("In [%s::%s] Line: %d p [%s]\n",__FILE__,__FUNCTION__,__LINE__,p); fflush(stdout);
|
||||
}
|
||||
|
||||
void strrev_utf8(std::string &p) {
|
||||
int bufSize = p.size()+1;
|
||||
char *szBuf = new char[bufSize];
|
||||
strcpy(szBuf,p.c_str());
|
||||
szBuf[bufSize] = '\0';
|
||||
strrev_utf8(&szBuf[0]);
|
||||
p = szBuf;
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
|
||||
delete [] szBuf;
|
||||
if(p.length() > 0) {
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
|
||||
int bufSize = p.length()*4;
|
||||
char *szBuf = new char[bufSize];
|
||||
memset(szBuf,0,bufSize);
|
||||
strcpy(szBuf,p.c_str());
|
||||
//szBuf[bufSize] = '\0';
|
||||
strrev_utf8(szBuf);
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
p = std::string(szBuf);
|
||||
|
||||
//printf("In [%s::%s] Line: %d bufSize = %d p.size() = %d p [%s]\n",__FILE__,__FUNCTION__,__LINE__,bufSize,p.length(),p.c_str()); fflush(stdout);
|
||||
|
||||
delete [] szBuf;
|
||||
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
}
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); fflush(stdout);
|
||||
}
|
||||
|
||||
bool is_string_all_ascii(std::string str) {
|
||||
|
Reference in New Issue
Block a user