diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 1d19212c9..3995dcbf8 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -871,7 +871,7 @@ MACRO(NL_SETUP_BUILD) ENDIF(ANDROID) IF(APPLE) - ADD_PLATFORM_FLAGS("-gdwarf-2") + ADD_PLATFORM_FLAGS("-gdwarf-2 -D_DARWIN_UNLIMITED_STREAMS") ENDIF(APPLE) # Fix "relocation R_X86_64_32 against.." error on x64 platforms diff --git a/code/nel/include/nel/gui/ctrl_button.h b/code/nel/include/nel/gui/ctrl_button.h index 02b827329..1910ea72a 100644 --- a/code/nel/include/nel/gui/ctrl_button.h +++ b/code/nel/include/nel/gui/ctrl_button.h @@ -51,7 +51,7 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; // Init part - virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void updateCoords(); diff --git a/code/nel/include/nel/gui/ctrl_draggable.h b/code/nel/include/nel/gui/ctrl_draggable.h index 3f625db1d..22ace71e0 100644 --- a/code/nel/include/nel/gui/ctrl_draggable.h +++ b/code/nel/include/nel/gui/ctrl_draggable.h @@ -29,7 +29,7 @@ namespace NLGUI DECLARE_UI_CLASS( CCtrlDraggable ) CCtrlDraggable( const TCtorParam ¶m ); - virtual ~CCtrlDraggable(){}; + virtual ~CCtrlDraggable(){} static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; } bool isDragged() const{ return dragged; } diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h index 4f5251a8b..69898639d 100644 --- a/code/nel/include/nel/gui/ctrl_text_button.h +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -49,7 +49,7 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; // Init part - virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void checkCoords(); virtual void updateCoords(); diff --git a/code/nel/include/nel/gui/dbgroup_combo_box.h b/code/nel/include/nel/gui/dbgroup_combo_box.h index 1aac8bb1f..87e6d758a 100644 --- a/code/nel/include/nel/gui/dbgroup_combo_box.h +++ b/code/nel/include/nel/gui/dbgroup_combo_box.h @@ -64,7 +64,7 @@ namespace NLGUI uint getTextPos(uint nId) const; const ucstring &getTexture(uint i) const; void setGrayed(uint i, bool g); - const bool getGrayed(uint i) const; + bool getGrayed(uint i) const; void removeText(uint nPos); uint getNumTexts() const {return (uint)_Texts.size();} void sortText(); diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 18ec9045a..0a2d107fb 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -72,10 +72,12 @@ namespace NLGUI GroupChildren = 4 /// module can parse when parsing the group children }; - IParserModule(){ + IParserModule() + { parser = NULL; parsingStage = None; } + virtual ~IParserModule(){} bool canParseInStage( ParsingStage stage ) diff --git a/code/nel/include/nel/gui/view_pointer.h b/code/nel/include/nel/gui/view_pointer.h index 382135a92..1cc7a4b0c 100644 --- a/code/nel/include/nel/gui/view_pointer.h +++ b/code/nel/include/nel/gui/view_pointer.h @@ -71,13 +71,13 @@ namespace NLGUI private: /// Drawing helpers - virtual bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawResizer(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawRotate(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawScale(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawColorPicker(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawLink(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawBrowse(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } + virtual bool drawPan(CCtrlBase* /* pCB */, NLMISC::CRGBA /* col */) { return false; } virtual bool drawCustom(CCtrlBase* pCB); protected: diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 9d8ff060e..cfb51af8e 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -71,7 +71,7 @@ namespace NLGUI class IOnWidgetsDrawnHandler { public: - virtual ~IOnWidgetsDrawnHandler(){}; + virtual ~IOnWidgetsDrawnHandler(){} virtual void process() = 0; }; diff --git a/code/nel/include/nel/misc/i18n.h b/code/nel/include/nel/misc/i18n.h index 1102a8907..5f270a490 100644 --- a/code/nel/include/nel/misc/i18n.h +++ b/code/nel/include/nel/misc/i18n.h @@ -127,6 +127,9 @@ public: /// Returns the code of the language ("fr", "en", ...) defined on system static std::string getSystemLanguageCode (); + /// Define the code of the language ("fr", "en", ...) defined on system + static bool setSystemLanguageCode (const std::string &languageCode); + /// Find a string in the selected language and return his association. static const ucstring &get (const std::string &label); @@ -230,6 +233,7 @@ private: static std::vector _LanguageCodes; static std::vector _LanguageNames; + static std::string _SystemLanguageCode; static bool _LanguagesNamesLoaded; diff --git a/code/nel/include/nel/misc/i_xml.h b/code/nel/include/nel/misc/i_xml.h index 20ee8a7e0..b078eb7ee 100644 --- a/code/nel/include/nel/misc/i_xml.h +++ b/code/nel/include/nel/misc/i_xml.h @@ -236,9 +236,6 @@ private: // If not NULL, binary mode detected, use this stream in serials IStream *_BinaryStream; - - // System dependant structure for locale - void* _Locale; }; diff --git a/code/nel/include/nel/misc/o_xml.h b/code/nel/include/nel/misc/o_xml.h index 8346a6884..5bafacd60 100644 --- a/code/nel/include/nel/misc/o_xml.h +++ b/code/nel/include/nel/misc/o_xml.h @@ -181,9 +181,6 @@ private: // Error message std::string _ErrorString; - - // System dependant structure for locale - void* _Locale; }; diff --git a/code/nel/include/nel/net/inet_address.h b/code/nel/include/nel/net/inet_address.h index dcf5b3708..b7dba0614 100644 --- a/code/nel/include/nel/net/inet_address.h +++ b/code/nel/include/nel/net/inet_address.h @@ -32,6 +32,12 @@ struct in6_addr; #ifdef NL_OS_WINDOWS // automatically add the win socket library if you use nel network part #pragma comment(lib, "ws2_32.lib") + +// it seems that the default loop back address is not defined for ipv6 +#ifndef IN6ADDR_LOOPBACK_INIT +#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } +#endif + #endif namespace NLMISC @@ -137,6 +143,9 @@ public: /// Returns true if this CInetAddress is 127.0.0.1 bool is127001 () const; + /// Returns true if this CInetAddress is a loop back address + bool isLoopbackIPAddress () const; + /// Creates a CInetAddress object with local host address, port=0 static CInetAddress localHost(); diff --git a/code/nel/include/nel/pipeline/tool_logger.h b/code/nel/include/nel/pipeline/tool_logger.h index 55b3b2455..3abd72f47 100644 --- a/code/nel/include/nel/pipeline/tool_logger.h +++ b/code/nel/include/nel/pipeline/tool_logger.h @@ -39,6 +39,7 @@ // NeL includes #include #include +#include // Project includes @@ -102,7 +103,7 @@ public: { releaseError(); - m_ErrorLog = fopen(errorLog.c_str(), "wt"); + m_ErrorLog = NLMISC::nlfopen(errorLog, "wt"); fwrite(s_ErrorHeader.c_str(), 1, s_ErrorHeader.length(), m_ErrorLog); fwrite("\n", 1, 1, m_ErrorLog); fflush(m_ErrorLog); @@ -113,7 +114,7 @@ public: { releaseDepend(); - m_DependLog = fopen(dependLog.c_str(), "wt"); + m_DependLog = NLMISC::nlfopen(dependLog, "wt"); fwrite(s_DependHeader.c_str(), 1, s_DependHeader.length(), m_DependLog); fwrite("\n", 1, 1, m_DependLog); // fflush(m_DependLog); diff --git a/code/nel/samples/3d/cluster_viewer/main.cpp b/code/nel/samples/3d/cluster_viewer/main.cpp index d7956adbe..ef05d557e 100644 --- a/code/nel/samples/3d/cluster_viewer/main.cpp +++ b/code/nel/samples/3d/cluster_viewer/main.cpp @@ -23,6 +23,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/file.h" +#include "nel/misc/common.h" #include "nel/misc/path.h" #include "nel/misc/bitmap.h" #include "nel/misc/events.h" @@ -115,7 +116,7 @@ void LoadSceneScript (const char *ScriptName, CScene* pScene, vector &D float posx, posy, posz; float roti, rotj, rotk; - FILE *f = fopen (CPath::lookup(ScriptName).c_str(),"rb"); + FILE *f = nlfopen (CPath::lookup(ScriptName), "rb"); fseek (f, 0, SEEK_END); uint file_size = ftell (f); fseek (f, 0, SEEK_SET); diff --git a/code/nel/samples/net/service/chat_service.cpp b/code/nel/samples/net/service/chat_service.cpp index 36b438e44..c2efc71f4 100644 --- a/code/nel/samples/net/service/chat_service.cpp +++ b/code/nel/samples/net/service/chat_service.cpp @@ -60,7 +60,7 @@ public: nlinfo ("init() was called"); -// fp = fopen (NLMISC::CFile::findNewFile("stat.csv").c_str(), "wt"); +// fp = nlfopen (NLMISC::CFile::findNewFile("stat.csv"), "wt"); } bool update () diff --git a/code/nel/samples/net/udp/bench_service.cpp b/code/nel/samples/net/udp/bench_service.cpp index 4b75a6b93..22f570260 100644 --- a/code/nel/samples/net/udp/bench_service.cpp +++ b/code/nel/samples/net/udp/bench_service.cpp @@ -33,6 +33,7 @@ #endif +#include "nel/misc/common.h" #include "nel/misc/debug.h" #include "nel/misc/mem_stream.h" #include "nel/misc/path.h" @@ -276,11 +277,11 @@ void CClient::updatePong (sint64 pingTime, sint64 pongTime, uint32 pongNumber, u } string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".pong"; - FILE *fp = fopen (fn.c_str(), "rt"); + FILE *fp = nlfopen (fn, "rt"); if (fp == NULL) { // new file, add the header - FILE *fp = fopen (fn.c_str(), "wt"); + FILE *fp = nlfopen (fn, "wt"); if (fp != NULL) { fprintf (fp, "#%s\t%s\t%s\t%s\n", "PingTime", "PongTime", "Delta", "PingNumber"); @@ -292,7 +293,7 @@ void CClient::updatePong (sint64 pingTime, sint64 pongTime, uint32 pongNumber, u fclose (fp); } - fp = fopen (fn.c_str(), "at"); + fp = nlfopen (fn, "at"); if (fp == NULL) { nlwarning ("Can't open pong file name '%s'", fn.c_str()); diff --git a/code/nel/samples/net/udp/client.cpp b/code/nel/samples/net/udp/client.cpp index 90de35bb2..0cdb98c53 100644 --- a/code/nel/samples/net/udp/client.cpp +++ b/code/nel/samples/net/udp/client.cpp @@ -21,6 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/debug.h" +#include "nel/misc/common.h" #include "nel/misc/mem_stream.h" #include "nel/misc/time_nl.h" #include "nel/misc/config_file.h" @@ -112,7 +113,7 @@ void exit (const string &reason) void createConfigFile() { - FILE *fp = fopen ("client.cfg", "wt"); + FILE *fp = nlfopen ("client.cfg", "wt"); if (fp == NULL) { InfoLog->displayRawNL ("Can't create client.cfg"); @@ -159,7 +160,7 @@ void checkConnectionName () void loadConfigFile () { - FILE *fp = fopen ("client.cfg", "rt"); + FILE *fp = nlfopen ("client.cfg", "rt"); if (fp == NULL) { createConfigFile(); diff --git a/code/nel/src/3d/driver/opengl/CMakeLists.txt b/code/nel/src/3d/driver/opengl/CMakeLists.txt index edff05d2a..21d790668 100644 --- a/code/nel/src/3d/driver/opengl/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengl/CMakeLists.txt @@ -40,8 +40,6 @@ NL_ADD_LIB_SUFFIX(${NLDRV_OGL_LIB}) NL_ADD_RUNTIME_FLAGS(${NLDRV_OGL_LIB}) IF(WIN32) - INCLUDE_DIRECTORIES(BEFORE ${DXSDK_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY}) ADD_DEFINITIONS(-DDRIVER_OPENGL_EXPORTS) ENDIF() diff --git a/code/nel/src/3d/driver/opengles/CMakeLists.txt b/code/nel/src/3d/driver/opengles/CMakeLists.txt index e6d10fae5..8cac2dfea 100644 --- a/code/nel/src/3d/driver/opengles/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengles/CMakeLists.txt @@ -38,8 +38,6 @@ NL_ADD_LIB_SUFFIX(${NLDRV_OGLES_LIB}) NL_ADD_RUNTIME_FLAGS(${NLDRV_OGLES_LIB}) IF(WIN32) - INCLUDE_DIRECTORIES(BEFORE ${DXSDK_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(${NLDRV_OGLES_LIB} ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY}) ADD_DEFINITIONS(/DDRIVER_OPENGLES_EXPORTS) ENDIF() diff --git a/code/nel/src/gui/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp index bc54003da..d689dd71c 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -40,7 +40,8 @@ namespace NLGUI { char c = toLower( s[ i ] ); - switch( c ){ + switch( c ) + { case 'l': _Align &= ~1; break; diff --git a/code/nel/src/gui/dbgroup_combo_box.cpp b/code/nel/src/gui/dbgroup_combo_box.cpp index 572d69ad4..184829e4c 100644 --- a/code/nel/src/gui/dbgroup_combo_box.cpp +++ b/code/nel/src/gui/dbgroup_combo_box.cpp @@ -321,7 +321,7 @@ namespace NLGUI } // *************************************************************************** - const bool CDBGroupComboBox::getGrayed(uint i) const + bool CDBGroupComboBox::getGrayed(uint i) const { if(i<_Grayed.size()) return _Grayed[i]; diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 1b5e36964..2c225b3ce 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -5882,9 +5882,11 @@ namespace NLGUI { const char* digits = (Type == "I" ? upper : lower); uint8 i, d=0; - do { + do + { uint32 num = number % 10; - if (num % 5 < 4){ + if (num % 5 < 4) + { for (i = num % 5; i > 0; i--) { ret.insert(ret.begin(), digits[d]); @@ -5904,7 +5906,9 @@ namespace NLGUI } number /= 10; d += 2; - } while (number > 0); + } + while (number > 0); + if (Type == "I") { ret = toUpper(ret); diff --git a/code/nel/src/gui/group_html_parser.cpp b/code/nel/src/gui/group_html_parser.cpp index 260e6a96f..de96a63ea 100644 --- a/code/nel/src/gui/group_html_parser.cpp +++ b/code/nel/src/gui/group_html_parser.cpp @@ -121,69 +121,112 @@ namespace NLGUI // *************************************************************************** // http://stackoverflow.com/a/18335183 - static std::string correct_non_utf_8(const std::string &str) + static std::string correctNonUtf8(const std::string &str) { - int i,f_size=str.size(); + int i, f_size=str.size(); unsigned char c,c2,c3,c4; std::string to; to.reserve(f_size); - for(i=0 ; i127 && c2<192){//valid 2byte UTF8 - if(c==194 && c2<160){//control char, skipping + } + else if (c < 224 && i + 1 < f_size) + { + //possibly 2byte UTF8 + c2 = (unsigned char)(str[i+1]); + + if (c2 > 127 && c2 < 192) + { + //valid 2byte UTF8 + if (c == 194 && c2 < 160) + { + //control char, skipping ; - }else{ + } + else + { to.append(1,c); to.append(1,c2); } i++; continue; } - }else if(c<240 && i+2127 && c2<192 && c3>127 && c3<192){//valid 3byte UTF8 + } + else if (c < 240 && i + 2 < f_size) + { + // possibly 3byte UTF8 + c2 = (unsigned char)(str[i+1]); + c3 = (unsigned char)(str[i+2]); + + if (c2 > 127 && c2 < 192 && c3 > 127 && c3 < 192) + { + // valid 3byte UTF8 to.append(1,c); to.append(1,c2); to.append(1,c3); i+=2; continue; } - }else if(c<245 && i+3127 && c2<192 && c3>127 && c3<192 && c4>127 && c4<192){//valid 4byte UTF8 + } + else if (c < 245 && i + 3 < f_size) + { + //possibly 4byte UTF8 + c2 = (unsigned char)(str[i+1]); + c3 = (unsigned char)(str[i+2]); + c4 = (unsigned char)(str[i+3]); + if (c2 > 127 && c2 < 192 && c3 > 127 && c3 < 192 && c4 > 127 && c4 < 192) + { + //valid 4byte UTF8 to.append(1,c); to.append(1,c2); to.append(1,c3); @@ -192,6 +235,7 @@ namespace NLGUI continue; } } + //invalid UTF8, converting ASCII (c>245 || string too short for multi-byte)) to.append(1,(unsigned char)195); to.append(1,c-64); @@ -250,7 +294,7 @@ namespace NLGUI } // if there is invalid utf-8 chars, then libxml will break everything after first it finds. - htmlString = correct_non_utf_8(htmlString); + htmlString = correctNonUtf8(htmlString); } // *************************************************************************** diff --git a/code/nel/src/misc/CMakeLists.txt b/code/nel/src/misc/CMakeLists.txt index fb6752982..53993161c 100644 --- a/code/nel/src/misc/CMakeLists.txt +++ b/code/nel/src/misc/CMakeLists.txt @@ -201,12 +201,6 @@ ELSE(WITH_STATIC OR WIN32) TARGET_LINK_LIBRARIES(nelmisc ${PNG_LIBRARY}) ENDIF(WITH_STATIC OR WIN32) -# For DirectInput (di_event_emitter) -IF(WIN32) - INCLUDE_DIRECTORIES(BEFORE ${DXSDK_INCLUDE_DIR}) - TARGET_LINK_LIBRARIES(nelmisc ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY} winmm dbghelp) -ENDIF(WIN32) - IF(UNIX) TARGET_LINK_LIBRARIES(nelmisc -lc -ldl) IF(NOT APPLE) diff --git a/code/nel/src/misc/app_context.cpp b/code/nel/src/misc/app_context.cpp index 2383fcda5..5206681f9 100644 --- a/code/nel/src/misc/app_context.cpp +++ b/code/nel/src/misc/app_context.cpp @@ -19,6 +19,8 @@ #include "nel/misc/dynloadlib.h" #include "nel/misc/command.h" +#include + #ifdef DEBUG_NEW #define new DEBUG_NEW #endif @@ -85,6 +87,9 @@ void INelContext::contextReady() _NelContext = this; *(_getInstance()) = this; + // set numeric locale to C to avoid the use of decimal separators different of a dot + char *locale = setlocale(LC_NUMERIC, "C"); + // register any pending thinks // register local instance counter in the global instance counter manager diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index 11a27e67e..5574a8597 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -3106,11 +3106,17 @@ bool CBitmap::blit(const CBitmap *src, sint32 x, sint32 y) // Private : float CBitmap::getColorInterp (float x, float y, float colorInXY00, float colorInXY10, float colorInXY01, float colorInXY11) const { + if (colorInXY00 == colorInXY10 + && colorInXY00 == colorInXY01 + && colorInXY00 == colorInXY11) + return colorInXY00; // Fix rounding error for alpha 255... + float res = colorInXY00*(1.0f-x)*(1.0f-y) + colorInXY10*( x)*(1.0f-y) + colorInXY01*(1.0f-x)*( y) + colorInXY11*( x)*( y); - clamp (res, 0.0f, 255.0f); + clamp(res, 0.0f, 255.0f); + return res; } diff --git a/code/nel/src/misc/bitmap_gif.cpp b/code/nel/src/misc/bitmap_gif.cpp index 30e8b652c..4ae9dd0cf 100644 --- a/code/nel/src/misc/bitmap_gif.cpp +++ b/code/nel/src/misc/bitmap_gif.cpp @@ -49,7 +49,8 @@ static uint8 INTERLACED_OFFSET[] = { 0, 4, 2, 1 }; static uint8 INTERLACED_JUMP[] = { 8, 8, 4, 2 }; #endif -static int readGIFData(GifFileType *gif, GifByteType *data, int length){ +static int readGIFData(GifFileType *gif, GifByteType *data, int length) +{ NLMISC::IStream *f = static_cast(gif->UserData); if(!f->isReading()) return 0; diff --git a/code/nel/src/misc/config_file/config_file.cpp b/code/nel/src/misc/config_file/config_file.cpp index 093992487..bab1c123b 100644 --- a/code/nel/src/misc/config_file/config_file.cpp +++ b/code/nel/src/misc/config_file/config_file.cpp @@ -316,6 +316,13 @@ CConfigFile::~CConfigFile () void CConfigFile::load (const string &fileName, bool lookupPaths ) { + char *locale = setlocale(LC_NUMERIC, NULL); + + if (!locale || strcmp(locale, "C")) + { + nlerror("Numeric locale not defined to C, an external library possibly redefined it!"); + } + if(fileName.empty()) { nlwarning ("CF: Can't load a empty file name configfile"); @@ -597,8 +604,12 @@ bool CConfigFile::exists (const std::string &varName) void CConfigFile::save () const { - // Avoid any problem, Force Locale to default - setlocale(LC_ALL, "C"); + char *locale = setlocale(LC_NUMERIC, NULL); + + if (!locale || strcmp(locale, "C")) + { + nlerror("Numeric locale not defined to C, an external library possibly redefined it!"); + } FILE *fp = nlfopen (getFilename(), "w"); if (fp == NULL) diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index 2f1bee325..b64116c1c 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -43,6 +43,7 @@ string CI18N::_SelectedLanguageCode; CI18N::ILoadProxy *CI18N::_LoadProxy = 0; vector CI18N::_LanguageCodes; vector CI18N::_LanguageNames; +std::string CI18N::_SystemLanguageCode; bool CI18N::noResolution = false; void CI18N::setLoadProxy(ILoadProxy *loadProxy) @@ -248,10 +249,8 @@ bool CI18N::isLanguageCodeSupported(const std::string &lang) std::string CI18N::getSystemLanguageCode () { - static std::string s_cachedSystemLanguage; - - if (!s_cachedSystemLanguage.empty()) - return s_cachedSystemLanguage; + if (!_SystemLanguageCode.empty()) + return _SystemLanguageCode; #ifdef NL_OS_MAC // under OS X, locale is only defined in console, not in UI @@ -317,7 +316,7 @@ std::string CI18N::getSystemLanguageCode () // only keep language code if supported by NeL if (isLanguageCodeSupported(lang)) { - s_cachedSystemLanguage = lang; + _SystemLanguageCode = lang; break; } } @@ -328,21 +327,116 @@ std::string CI18N::getSystemLanguageCode () } #endif - // use system locale (works under Linux and Windows) - if (s_cachedSystemLanguage.empty()) +#ifdef NL_OS_WINDOWS + // use user locale under Windows (since Vista) + if (_SystemLanguageCode.empty()) { - std::string lang = NLMISC::toLower(std::string(setlocale(LC_CTYPE, ""))); + // GetUserDefaultLocaleName prototype + typedef int (WINAPI* GetUserDefaultLocaleNamePtr)(LPWSTR lpLocaleName, int cchLocaleName); - // only keep 2 first characters - if (lang.size() > 1) - s_cachedSystemLanguage = lang.substr(0, 2); + // get pointer on GetUserDefaultLocaleName, kernel32.dll is always in memory so no need to call LoadLibrary + GetUserDefaultLocaleNamePtr nlGetUserDefaultLocaleName = (GetUserDefaultLocaleNamePtr)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetUserDefaultLocaleName"); + + // only use it if found + if (nlGetUserDefaultLocaleName) + { + // get user locale + wchar_t buffer[LOCALE_NAME_MAX_LENGTH]; + sint res = nlGetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH); + + // convert wide string to std::string + std::string lang = wideToUtf8(buffer); + + // only keep 2 first characters + if (lang.size() > 1) + _SystemLanguageCode = lang.substr(0, 2); + } + } +#endif + + // use system locale (works under OS X, Linux and Windows) + if (_SystemLanguageCode.empty()) + { + // get default locale + char *locale = setlocale(LC_CTYPE, ""); + + if (locale) + { + std::string lang(locale); + +#ifdef NL_OS_WINDOWS + // be sure supported languages are initialized + initLanguages(); + + // locales names are different under Windows, for example: French_France.1252 + for(uint i = 0; i < _LanguageNames.size(); ++i) + { + std::string name = _LanguageNames[i].toUtf8(); + + // so we compare the language name with the supported ones + if (lang.compare(0, name.length(), name) == 0) + { + // found, so use its code + _SystemLanguageCode = _LanguageCodes[i]; + break; + } + } +#else + // only keep 2 first characters + if (lang.size() > 1) + _SystemLanguageCode = NLMISC::toLower(lang).substr(0, 2); +#endif + } } // english is default language - if (s_cachedSystemLanguage.empty()) - s_cachedSystemLanguage = "en"; + if (_SystemLanguageCode.empty()) + _SystemLanguageCode = "en"; - return s_cachedSystemLanguage; + return _SystemLanguageCode; +} + +bool CI18N::setSystemLanguageCode (const std::string &languageCode) +{ + // be sure supported languages are initialized + initLanguages(); + + std::string lang = NLMISC::toLower(languageCode); + + // specified language is really a code (2 characters) + if (lang.length() == 2) + { + // check if language code is supported + for(uint i = 0; i < _LanguageCodes.size(); ++i) + { + std::string code = NLMISC::toLower(_LanguageCodes[i]); + + if (lang == code) + { + // found, so use it + _SystemLanguageCode = lang; + return true; + } + } + } + // specified language is something else + else + { + // check if language name is supported + for(uint i = 0; i < _LanguageNames.size(); ++i) + { + std::string name = NLMISC::toLower(_LanguageNames[i].toUtf8()); + + if (name == lang) + { + // found, so use its code + _SystemLanguageCode = _LanguageCodes[i]; + return true; + } + } + } + + return false; } void CI18N::removeCComment(ucstring &commentedString) diff --git a/code/nel/src/misc/i_xml.cpp b/code/nel/src/misc/i_xml.cpp index e722f3eee..fbd8f5d9f 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -24,11 +24,6 @@ // Include from libxml2 #include -#if defined(NL_OS_WINDOWS) && defined(NL_COMP_VC_VERSION) && NL_COMP_VC_VERSION >= 80 -#define USE_LOCALE_ATOF -#include -#endif - using namespace std; #define NLMISC_READ_BUFFER_SIZE 1024 @@ -46,26 +41,10 @@ const char SEPARATOR = ' '; // *************************************************************************** -#define readnumber(dest,thetype,digits,convfunc) \ +#define readnumber(dest,digits) \ string number_as_string; \ serialSeparatedBufferIn( number_as_string ); \ - dest = (thetype)convfunc( number_as_string.c_str() ); - -#ifdef USE_LOCALE_ATOF - -#define readnumberlocale(dest,thetype,digits,convfunc) \ - string number_as_string; \ - serialSeparatedBufferIn( number_as_string ); \ - dest = (thetype)convfunc( number_as_string.c_str(), (_locale_t)_Locale ); - -#define nl_atof _atof_l - -#else - -#define readnumberlocale(dest,thetype,digits,convfunc) readnumber(dest,thetype,digits,convfunc) -#define nl_atof atof - -#endif + NLMISC::fromString(number_as_string, dest); // *************************************************************************** @@ -91,13 +70,6 @@ CIXml::CIXml () : IStream (true /* Input mode */) _ErrorString = ""; _TryBinaryMode = false; _BinaryStream = NULL; - -#ifdef USE_LOCALE_ATOF - // create C numeric locale - _Locale = _create_locale(LC_NUMERIC, "C"); -#else - _Locale = NULL; -#endif } // *************************************************************************** @@ -113,13 +85,6 @@ CIXml::CIXml (bool tryBinaryMode) : IStream (true /* Input mode */) _ErrorString = ""; _TryBinaryMode = tryBinaryMode; _BinaryStream = NULL; - -#ifdef USE_LOCALE_ATOF - // create C numeric locale - _Locale = _create_locale(LC_NUMERIC, "C"); -#else - _Locale = NULL; -#endif } // *************************************************************************** @@ -128,10 +93,6 @@ CIXml::~CIXml () { // Release release (); - -#ifdef USE_LOCALE_ATOF - if (_Locale) _free_locale((_locale_t)_Locale); -#endif } // *************************************************************************** @@ -468,7 +429,7 @@ void CIXml::serial(uint8 &b) else { // Read the number - readnumber( b, uint8, 3, atoi ); + readnumber( b, 3 ); } } @@ -482,7 +443,7 @@ void CIXml::serial(sint8 &b) } else { - readnumber( b, sint8, 4, atoi ); + readnumber( b, 4 ); } } @@ -496,7 +457,7 @@ void CIXml::serial(uint16 &b) } else { - readnumber( b, uint16, 5, atoi ); + readnumber( b, 5 ); } } @@ -510,7 +471,7 @@ void CIXml::serial(sint16 &b) } else { - readnumber( b, sint16, 6, atoi ); + readnumber( b, 6 ); } } @@ -529,7 +490,7 @@ void CIXml::serial(uint32 &b) } else { - readnumber( b, uint32, 10, atoui ); + readnumber( b, 10 ); } } @@ -543,7 +504,7 @@ void CIXml::serial(sint32 &b) } else { - readnumber( b, sint32, 11, atoi ); + readnumber( b, 11 ); } } @@ -557,7 +518,7 @@ void CIXml::serial(uint64 &b) } else { - readnumber( b, uint64, 20, atoiInt64 ); + readnumber( b, 20 ); } } @@ -571,7 +532,7 @@ void CIXml::serial(sint64 &b) } else { - readnumber( b, sint64, 20, atoiInt64 ); + readnumber( b, 20 ); } } @@ -585,7 +546,7 @@ void CIXml::serial(float &b) } else { - readnumberlocale( b, float, 128, nl_atof ); + readnumber( b, 128 ); } } @@ -599,7 +560,7 @@ void CIXml::serial(double &b) } else { - readnumberlocale( b, double, 128, nl_atof ); + readnumber( b, 128 ); } } diff --git a/code/nel/src/misc/o_xml.cpp b/code/nel/src/misc/o_xml.cpp index d07362904..6df48ef80 100644 --- a/code/nel/src/misc/o_xml.cpp +++ b/code/nel/src/misc/o_xml.cpp @@ -43,22 +43,11 @@ const char SEPARATOR = ' '; // *************************************************************************** -#ifdef USE_LOCALE_SPRINTF - -#define writenumber(src,format,digits) \ - char number_as_cstring [digits+1]; \ - _sprintf_l( number_as_cstring, format, (_locale_t)_Locale, src ); \ - serialSeparatedBufferOut( number_as_cstring ); - -#else - #define writenumber(src,format,digits) \ char number_as_cstring [digits+1]; \ sprintf( number_as_cstring, format, src ); \ serialSeparatedBufferOut( number_as_cstring ); -#endif - // *************************************************************************** // XML callbacks // *************************************************************************** @@ -149,13 +138,6 @@ COXml::COXml () : IStream (false /* Output mode */) // Push begin _PushBegin = false; - -#ifdef USE_LOCALE_SPRINTF - // create C numeric locale - _Locale = _create_locale(LC_NUMERIC, "C"); -#else - _Locale = NULL; -#endif } // *************************************************************************** @@ -215,10 +197,6 @@ COXml::~COXml () { // Flush document to the internal stream flush (); - -#ifdef USE_LOCALE_SPRINTF - if (_Locale) _free_locale((_locale_t)_Locale); -#endif } // *************************************************************************** diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index b5375e005..b4057e315 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1963,14 +1963,15 @@ bool CFile::createEmptyFile (const std::string& filename) bool CFile::fileExists (const string& filename) { //H_AUTO(FileExists); -#ifdef NL_OS_WINDOWS - DWORD attr = GetFileAttributesW(utf8ToWide(filename)); - // attributes are valid and file is not a directory - if (attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY)) return false; - return true; -#else - return access(filename.c_str(), R_OK) != -1; -#endif + FILE *file = nlfopen(filename, "rb"); + + if (file) + { + fclose(file); + return true; + } + + return false; } diff --git a/code/nel/src/net/inet_address.cpp b/code/nel/src/net/inet_address.cpp index 9dc7f5d00..093bf8dcb 100644 --- a/code/nel/src/net/inet_address.cpp +++ b/code/nel/src/net/inet_address.cpp @@ -92,18 +92,18 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) BOOLEAN IN6_IS_ADDR_UNSPECIFIED(CONST IN6_ADDR *a) { - // - // We can't use the in6addr_any variable, since that would - // require existing callers to link with a specific library. - // - return (BOOLEAN)((a->s6_words[0] == 0) && - (a->s6_words[1] == 0) && - (a->s6_words[2] == 0) && - (a->s6_words[3] == 0) && - (a->s6_words[4] == 0) && - (a->s6_words[5] == 0) && - (a->s6_words[6] == 0) && - (a->s6_words[7] == 0)); + // + // We can't use the in6addr_any variable, since that would + // require existing callers to link with a specific library. + // + return (BOOLEAN)((a->s6_words[0] == 0) && + (a->s6_words[1] == 0) && + (a->s6_words[2] == 0) && + (a->s6_words[3] == 0) && + (a->s6_words[4] == 0) && + (a->s6_words[5] == 0) && + (a->s6_words[6] == 0) && + (a->s6_words[7] == 0)); } #endif @@ -714,25 +714,51 @@ std::vector CInetAddress::localAddresses() if (status) { // will come here if the local hostname (/etc/hostname in Linux) is not the real name - throw ESocket( (string("Hostname resolution failed for ")+string(localhost)).c_str() ); + throw ESocket( toString("Hostname resolution failed for %s", localhost).c_str() ); } struct addrinfo *p = res; + // for loopback ipv4 + bool IPv4LoopbackAdded = false; + + // for loopback ipv6 + bool IPv6LoopbackAdded = false; + // process all addresses while (p != NULL) { // check address family if (p->ai_family == AF_INET) { - // ipv4 + // loopback ipv4 + if (!IPv4LoopbackAdded) + { + // add loopback address only once + struct in_addr psin_addrIPv4; + psin_addrIPv4.s_addr = htonl(INADDR_LOOPBACK); + vect.push_back(CInetAddress(&psin_addrIPv4, localhost)); + + IPv4LoopbackAdded = true; + } + struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr; vect.push_back( CInetAddress( &ipv4->sin_addr, localhost ) ); + } else if (p->ai_family == AF_INET6) { - // ipv6 + // loopback ipv6 + if (!IPv6LoopbackAdded) + { + // add loopback address only once + struct in6_addr psin_addrIPv6 = IN6ADDR_LOOPBACK_INIT; + vect.push_back(CInetAddress(&psin_addrIPv6, localhost)); + + IPv6LoopbackAdded = true; + } + struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr; vect.push_back( CInetAddress( &ipv6->sin6_addr, localhost ) ); @@ -747,7 +773,7 @@ std::vector CInetAddress::localAddresses() if(vect.empty()) { - throw ESocket( (string("No network card detected for ")+string(localhost)).c_str() ); + throw ESocket(toString("No network card detected for %s", localhost).c_str() ); } return vect; @@ -758,6 +784,16 @@ bool CInetAddress::is127001 () const return (internalIPAddress () == htonl(0x7F000001)); } +bool CInetAddress::isLoopbackIPAddress () const +{ + std::string sIPAddress = ipAddress(); + + return (sIPAddress.compare("::") == 0) || + (sIPAddress.compare("::1") == 0) || + (sIPAddress.compare("127.0.0.1") == 0) || + (sIPAddress.compare("0:0:0:0:0:0:0:1") == 0); +} + std::string vectorCInetAddressToString(const std::vector &addrs) { diff --git a/code/nel/src/net/unified_network.cpp b/code/nel/src/net/unified_network.cpp index 0f4396ef5..ee882f547 100644 --- a/code/nel/src/net/unified_network.cpp +++ b/code/nel/src/net/unified_network.cpp @@ -828,17 +828,17 @@ void CUnifiedNetwork::addService(const string &name, const vector for (uint i = 0; i < addr.size(); i++) { // first we have to look if we have a network that can established the connection - + uint j = 0; - // it s 127.0.0.1, it s ok - if (!addr[i].is127001 ()) + + if (!addr[i].isLoopbackIPAddress()) { + // it's loopback ip address, it's ok for (j = 0; j < laddr.size (); j++) { if (laddr[j].internalNetAddress () == addr[i].internalNetAddress ()) { - // it's ok, we can try - break; + break; // it's ok, we can try } } @@ -1272,8 +1272,7 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) uint8 connectionId = _IdCnx[sid.get()].DefaultNetwork; if (nid == 0xFF) - { - // it s often happen because they didn't set a good network configuration, so it s in debug to disable it easily + { // default network //nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId); } else if (nid >= _IdCnx[sid.get()].NetworkConnectionAssociations.size()) @@ -1294,8 +1293,12 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) if (connectionId >= _IdCnx[sid.get()].Connections.size() || !_IdCnx[sid.get()].Connections[connectionId].valid() || !_IdCnx[sid.get()].Connections[connectionId].CbNetBase->connected()) { - // there's a problem with the selected connectionID, so try to find a valid one - nlwarning ("HNETL5: Can't find selected connection id %hu to send message to %s because connection is not valid or connected, find a valid connection id", (uint16)connectionId, _IdCnx[sid.get()].ServiceName.c_str ()); + + if (nid != 0xFF) + { + // not a default network. There's a problem with the selected connectionID, so try to find a valid one + nlwarning ("HNETL5: Can't find selected connection id %hu to send message to %s because connection is not valid or connected, find a valid connection id", (uint16)connectionId, _IdCnx[sid.get()].ServiceName.c_str ()); + } for (connectionId = 0; connectionId < _IdCnx[sid.get()].Connections.size(); connectionId++) { @@ -1303,6 +1306,19 @@ uint8 CUnifiedNetwork::findConnectionId (TServiceId sid, uint8 nid) { // we found one at last, use this one //nldebug ("HNETL5: Ok, we found a valid connectionid, use %hu", (uint16)connectionId); + if (nid < _IdCnx[sid.get()].NetworkConnectionAssociations.size()) + { + _IdCnx[sid.get()].NetworkConnectionAssociations[nid] = connectionId; // we set the preferred networkConnectionAssociation + } + else + { + if (nid == 0xFF) + { + _IdCnx[sid.get()].DefaultNetwork = connectionId; + } + } + + nlwarning ("HNETL5: selected connection id %hu from network %hu to send message to %s", (uint16)connectionId, (uint16)nid, _IdCnx[sid.get()].ServiceName.c_str ()); break; } } @@ -1782,7 +1798,7 @@ bool CUnifiedNetwork::isServiceLocal (TServiceId sid) { for (uint j = 0; j < _IdCnx[sid.get()].ExtAddress.size(); j++) { - if (_IdCnx[sid.get()].ExtAddress[j].is127001 ()) + if (_IdCnx[sid.get()].ExtAddress[j].isLoopbackIPAddress ()) return true; if (_IdCnx[sid.get()].ExtAddress[j].internalIPAddress () == laddr[i].internalIPAddress ()) diff --git a/code/nel/src/sound/audio_decoder_vorbis.cpp b/code/nel/src/sound/audio_decoder_vorbis.cpp index e438d43cc..1c11c32d7 100644 --- a/code/nel/src/sound/audio_decoder_vorbis.cpp +++ b/code/nel/src/sound/audio_decoder_vorbis.cpp @@ -195,13 +195,17 @@ uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 m uint8 CAudioDecoderVorbis::getChannels() { vorbis_info *vi = ov_info(&_OggVorbisFile, -1); - return (uint8)vi->channels; + if (vi) return (uint8)vi->channels; + nlwarning("ov_info returned NULL"); + return 0; } uint CAudioDecoderVorbis::getSamplesPerSec() { vorbis_info *vi = ov_info(&_OggVorbisFile, -1); - return (uint)vi->rate; + if (vi) return (uint)vi->rate; + nlwarning("ov_info returned NULL"); + return 0; } uint8 CAudioDecoderVorbis::getBitsPerSample() diff --git a/code/nel/tools/3d/file_info/main.cpp b/code/nel/tools/3d/file_info/main.cpp index b781e43fe..e8c6e072b 100644 --- a/code/nel/tools/3d/file_info/main.cpp +++ b/code/nel/tools/3d/file_info/main.cpp @@ -17,6 +17,7 @@ #include "nel/misc/file.h" #include "nel/misc/path.h" +#include "nel/misc/common.h" #include "nel/3d/scene_group.h" #include "nel/3d/zone.h" #include "nel/3d/skeleton_shape.h" @@ -660,9 +661,7 @@ int main(int argc, const char *argv[]) options.insert (argv[i]); // Open log - FILE *logStream; - logStream= fopen(std::string(getLogDirectory() + "file_info.log").c_str(), "wt"); - + FILE *logStream = nlfopen(getLogDirectory() + "file_info.log", "wt"); // parse dir or file ?? const char *fileName= argv[1]; diff --git a/code/nel/tools/3d/lightmap_optimizer/main.cpp b/code/nel/tools/3d/lightmap_optimizer/main.cpp index f7e999799..077cc83b5 100644 --- a/code/nel/tools/3d/lightmap_optimizer/main.cpp +++ b/code/nel/tools/3d/lightmap_optimizer/main.cpp @@ -998,7 +998,8 @@ int main(int nNbArg, char **ppArgs) ChDir (sExeDir); // out a text file, with list of - FILE *out= fopen(ppArgs[4], "wt"); + FILE *out = NLMISC::nlfopen(ppArgs[4], "wt"); + if(!out) { outString(string("ERROR: cannot save ")+ppArgs[4]); diff --git a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h index 2c5b38f92..588d8a898 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h +++ b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h @@ -29,12 +29,6 @@ along with this program. If not, see . #undef free #endif -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include diff --git a/code/nel/tools/3d/panoply_preview/main_window.h b/code/nel/tools/3d/panoply_preview/main_window.h index 1d864249b..3e3d2f025 100644 --- a/code/nel/tools/3d/panoply_preview/main_window.h +++ b/code/nel/tools/3d/panoply_preview/main_window.h @@ -21,12 +21,6 @@ // STL includes // Qt includes -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include // NeL includes diff --git a/code/nel/tools/3d/panoply_preview/panoply_preview.h b/code/nel/tools/3d/panoply_preview/panoply_preview.h index 794a223f8..9fbe2bad3 100644 --- a/code/nel/tools/3d/panoply_preview/panoply_preview.h +++ b/code/nel/tools/3d/panoply_preview/panoply_preview.h @@ -21,12 +21,6 @@ // STL includes // Qt includes -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include #include diff --git a/code/nel/tools/3d/plugin_max/nel_export/nel_export_lightmap_v2.cpp b/code/nel/tools/3d/plugin_max/nel_export/nel_export_lightmap_v2.cpp index b79e4884f..f6cd6b80d 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/nel_export_lightmap_v2.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/nel_export_lightmap_v2.cpp @@ -8,6 +8,7 @@ #include "nel/misc/time_nl.h" #include "nel/misc/file.h" +#include "nel/misc/common.h" #include "nel/misc/triangle.h" #include "nel/misc/bsphere.h" #include "3d/quad_tree.h" @@ -3121,8 +3122,8 @@ void CNelExport::deleteLM(INode& ZeNode) sprintf( tmp, "%d", i ); sSaveName += tmp; sSaveName += ".tga"; - FILE *file; - if( file = fopen(sSaveName.c_str(),"rb") ) + FILE *file = nlfopen(sSaveName, "rb") + if (file) { fclose( file ); DeleteFile( sSaveName.c_str() ); @@ -3521,8 +3522,8 @@ bool CNelExport::exportScene(std::vector& vectNode) sprintf( tmp, "%d", i ); sSaveName += tmp; sSaveName += ".tga"; - FILE *file; - if( file = fopen(sSaveName.c_str(),"rb") ) + FILE *file = nlfopen(sSaveName, "rb"); + if (file) { fclose( file ); DeleteFile( sSaveName.c_str() ); diff --git a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp index 0c4d08c4a..a63fcc969 100644 --- a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp +++ b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see . #include +#include #include #include #include @@ -851,7 +852,7 @@ bool ShapesExporter::renderPS(UInstance &entity, const string &output_path, doub { if(step > 0) { - FILE *fp = fopen(string(CPath::standardizePath(output_path)+"nb_steps.txt").c_str(), "w"); + FILE *fp = nlfopen(CPath::standardizePath(output_path)+"nb_steps.txt", "w"); if(fp) { fprintf(fp, "%d", step); fclose(fp); } } nlinfo("PS duration %f after %f with nothing with %d steps, dt %f", duration, startTime, step, deltaTime); @@ -873,7 +874,7 @@ bool ShapesExporter::createThumbnail(const string &filename, const string &path) uint selectedFrame = 0; if(CFile::getExtension(filename) == "ps") { - FILE *fp = fopen(string(CPath::standardizePath(output_path)+"nb_steps.txt").c_str(), "r"); + FILE *fp = nlfopen(CPath::standardizePath(output_path)+"nb_steps.txt", "r"); if(fp) { char str[100]; diff --git a/code/nel/tools/3d/shared_widgets/command_log.h b/code/nel/tools/3d/shared_widgets/command_log.h index 16bc21c9d..ec6332601 100644 --- a/code/nel/tools/3d/shared_widgets/command_log.h +++ b/code/nel/tools/3d/shared_widgets/command_log.h @@ -34,12 +34,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // STL includes // Qt includes -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include #include diff --git a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp index 7f3275694..5e40a4cca 100644 --- a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp +++ b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp @@ -18,6 +18,7 @@ #include #include "nel/misc/file.h" +#include "nel/misc/common.h" #include "nel/misc/bitmap.h" #include "nel/misc/path.h" #include "nel/misc/debug.h" @@ -49,7 +50,7 @@ std::string getOutputFileName(const std::string &inputFileName); uint8 getType(const std::string &sFileNameDest) { uint32 dds; - FILE *f = fopen(sFileNameDest.c_str(),"rb"); + FILE *f = nlfopen(sFileNameDest, "rb"); if(f==NULL) { return NOT_DEFINED; @@ -105,7 +106,7 @@ uint8 getType(const std::string &sFileNameDest) bool sameType(const std::string &sFileNameDest, uint8 &algo, bool wantMipMap) { uint32 dds; - FILE *f = fopen(sFileNameDest.c_str(),"rb"); + FILE *f = nlfopen(sFileNameDest, "rb"); if(f==NULL) { return false; diff --git a/code/nel/tools/3d/tile_edit_qt/common.h b/code/nel/tools/3d/tile_edit_qt/common.h index 685195251..6cafbbd8a 100644 --- a/code/nel/tools/3d/tile_edit_qt/common.h +++ b/code/nel/tools/3d/tile_edit_qt/common.h @@ -26,12 +26,6 @@ #undef free #endif -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include diff --git a/code/nel/tools/3d/zone_welder/zone_welder.cpp b/code/nel/tools/3d/zone_welder/zone_welder.cpp index f30a4b38b..7ca1d822a 100644 --- a/code/nel/tools/3d/zone_welder/zone_welder.cpp +++ b/code/nel/tools/3d/zone_welder/zone_welder.cpp @@ -20,6 +20,7 @@ #include #include "nel/misc/types_nl.h" #include "nel/misc/file.h" +#include "nel/misc/common.h" #include "nel/3d/quad_tree.h" #include "nel/3d/zone.h" #include "nel/3d/landscape.h" @@ -978,7 +979,7 @@ int main(sint argc, char **argv) } #if WELD_LOG - fdbg = fopen("log.txt","wt"); + fdbg = nlfopen("log.txt","wt"); fprintf(fdbg,"Center zone : %s\n",argv[1]); #endif diff --git a/code/nel/tools/3d/zviewer/zviewer.cpp b/code/nel/tools/3d/zviewer/zviewer.cpp index 9d64badb1..c5f4419a4 100644 --- a/code/nel/tools/3d/zviewer/zviewer.cpp +++ b/code/nel/tools/3d/zviewer/zviewer.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -743,7 +744,7 @@ void displayZones() \****************************************************************/ void writeConfigFile(const char * configFileName) { - FILE * f = fopen(configFileName,"wt"); + FILE * f = nlfopen(configFileName, "wt"); if(f==NULL) { @@ -801,7 +802,7 @@ void writeConfigFile(const char * configFileName) \****************************************************************/ void initViewerConfig(const char * configFileName) { - FILE * f = fopen(configFileName,"rt"); + FILE *f = nlfopen(configFileName, "rt"); if(f==NULL) { nlwarning("'%s' not found, default values used", configFileName); diff --git a/code/nel/tools/georges/georges2csv/georges2csv.cpp b/code/nel/tools/georges/georges2csv/georges2csv.cpp index 018a6abff..339479bfe 100644 --- a/code/nel/tools/georges/georges2csv/georges2csv.cpp +++ b/code/nel/tools/georges/georges2csv/georges2csv.cpp @@ -32,6 +32,7 @@ #include "nel/misc/file.h" #include "nel/misc/smart_ptr.h" #include "nel/misc/command.h" +#include "nel/misc/common.h" #include "nel/misc/path.h" //#include "nel/memory/memory_manager.h" #include "nel/misc/i18n.h" @@ -685,12 +686,13 @@ void convertCsvFile( const string &file, bool generate, const string& sheetType { const uint BUFFER_SIZE = 16*1024; char lineBuffer[BUFFER_SIZE]; - FILE *s; vector fields; vector args; - if ((s = fopen(file.c_str(), "r")) == NULL) + FILE *s = nlfopen(file, "r"); + + if (s == NULL) { fprintf(stderr, "Can't find file %s to convert\n", file.c_str()); return; diff --git a/code/nel/tools/misc/crash_report/crash_report_data.h b/code/nel/tools/misc/crash_report/crash_report_data.h index 8a7f2ffcb..f2d222189 100644 --- a/code/nel/tools/misc/crash_report/crash_report_data.h +++ b/code/nel/tools/misc/crash_report/crash_report_data.h @@ -20,12 +20,6 @@ #ifndef RCERROR_DATA #define RCERROR_DATA -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include struct SCrashReportData diff --git a/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp b/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp index 100bd4e9c..340655e36 100644 --- a/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp +++ b/code/nel/tools/misc/data_mirror/data_mirrorDlg.cpp @@ -20,6 +20,7 @@ #include "progress_dialog.h" #include #include "nel/misc/file.h" +#include "nel/misc/common.h" using namespace std; using namespace NLMISC; @@ -468,9 +469,13 @@ void CData_mirrorDlg::OnOK() if (!LogDirectory.empty()) { string sTmp = LogDirectory + "data_mirror.txt"; - FILE *f = fopen(sTmp.c_str(),"at"); - fprintf(f,"Modified file : %s\n", dest.c_str()); - fclose(f); + FILE *f = nlfopen(sTmp ,"at"); + + if (f) + { + fprintf(f,"Modified file : %s\n", dest.c_str()); + fclose(f); + } } } @@ -503,9 +508,12 @@ void CData_mirrorDlg::OnOK() if (!LogDirectory.empty()) { string sTmp = LogDirectory + "data_mirror.txt"; - FILE *f = fopen(sTmp.c_str(),"at"); - fprintf(f,"Added file : %s\n", dest.c_str()); - fclose(f); + FILE *f = nlfopen(sTmp, "at"); + if (f) + { + fprintf(f,"Added file : %s\n", dest.c_str()); + fclose(f); + } } } @@ -535,9 +543,13 @@ void CData_mirrorDlg::OnOK() if (!LogDirectory.empty()) { string sTmp = LogDirectory + "data_mirror.txt"; - FILE *f = fopen(sTmp.c_str(),"at"); - fprintf(f,"Removed file : %s\n", dest.c_str()); - fclose(f); + FILE *f = nlfopen(sTmp, "at"); + + if (f) + { + fprintf(f,"Removed file : %s\n", dest.c_str()); + fclose(f); + } } } } diff --git a/code/nel/tools/misc/disp_sheet_id/main.cpp b/code/nel/tools/misc/disp_sheet_id/main.cpp index 7445023ce..c7fe6f782 100644 --- a/code/nel/tools/misc/disp_sheet_id/main.cpp +++ b/code/nel/tools/misc/disp_sheet_id/main.cpp @@ -40,6 +40,7 @@ int _getch() #include "nel/misc/path.h" #include "nel/misc/sheet_id.h" +#include "nel/misc/common.h" #include @@ -86,7 +87,7 @@ int main(int argc, const char *argv[]) sort(sheets.begin(), sheets.end(), Pred); // display. - FILE *out= fopen("sheetid.txt", "wb"); + FILE *out= nlfopen("sheetid.txt", "wb"); if(out) { for(uint i=0;i #include +#include #include #include @@ -567,9 +568,9 @@ int main( int argc, char ** argv ) // dump the list of extensions in a txt file if( dumpExtensions ) { - FILE * extListOutput; string extListFileName = outputPath + "sheet_ext.txt"; - if( !(extListOutput = fopen(extListFileName.c_str(),"w")) ) + FILE *extListOutput = nlfopen(extListFileName, "w"); + if (!extListOutput) { nlwarning("Can't open output file %s",extListFileName.c_str()); return 1; diff --git a/code/nel/tools/misc/words_dic_qt/words_dicDlg.h b/code/nel/tools/misc/words_dic_qt/words_dicDlg.h index 707eaaa44..dcf27e838 100644 --- a/code/nel/tools/misc/words_dic_qt/words_dicDlg.h +++ b/code/nel/tools/misc/words_dic_qt/words_dicDlg.h @@ -1,12 +1,6 @@ #ifndef WORDS_DICDLG_H #define WORDS_DICDLG_H -#include - -#ifdef Q_COMPILER_RVALUE_REFS -#undef Q_COMPILER_RVALUE_REFS -#endif - #include #include "ui_words_dic_Qt.h" diff --git a/code/nel/tools/misc/xml_packer/xml_packer.cpp b/code/nel/tools/misc/xml_packer/xml_packer.cpp index 2d7695de4..7f7417020 100644 --- a/code/nel/tools/misc/xml_packer/xml_packer.cpp +++ b/code/nel/tools/misc/xml_packer/xml_packer.cpp @@ -17,6 +17,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/app_context.h" #include "nel/misc/path.h" +#include "nel/misc/common.h" #include "nel/misc/sstring.h" #include "nel/misc/algo.h" @@ -228,7 +229,7 @@ int main(int argc, char *argv[]) // read the index file set fileInIndex; char lineBuffer[1024]; - FILE *fp = fopen(indexFileName.c_str(), "rt"); + FILE *fp = nlfopen(indexFileName, "rt"); while (fgets(lineBuffer, 1024, fp)) fileInIndex.insert(CSString(lineBuffer).strip()); @@ -263,8 +264,8 @@ int main(int argc, char *argv[]) if (!validFiles.empty() && needRepack) { // open the pack file - // FILE *fp = fopen(filename.c_str(), "wt"); - FILE *fp = fopen(packFileName.c_str(), "wt"); + // FILE *fp = nlfopen(filename, "wt"); + FILE *fp = nlfopen(packFileName, "wt"); fprintf(fp, "\n"); @@ -275,7 +276,7 @@ int main(int argc, char *argv[]) printf("Adding file '%s'...\n", CFile::getFilename(subFileName).c_str()); fprintf(fp, " \n", CFile::getFilename(subFileName).c_str()); - FILE *subFp = fopen(subFileName.c_str(), "rt"); + FILE *subFp = nlfopen(subFileName, "rt"); nlassert(subFp != NULL); char buffer[MaxLineSize]; char *result; @@ -304,7 +305,7 @@ int main(int argc, char *argv[]) fclose(fp); // write the disposable index file used by pack to check for erased file - fp = fopen(indexFileName.c_str(), "wt"); + fp = nlfopen(indexFileName, "wt"); for (uint i=0; i") char str[1024]; - FILE *fp = fopen(fn.c_str(), "rt"); + FILE *fp = nlfopen(fn, "rt"); if (fp != NULL) { while (true) @@ -1654,7 +1654,7 @@ NLMISC_COMMAND(aesSystem, "Execute a system() call", "") log.displayNL("No stdout"); } - fp = fopen(fne.c_str(), "rt"); + fp = nlfopen(fne, "rt"); if (fp != NULL) { while (true) diff --git a/code/nelns/login_system/nel_launcher_windows_ext2/patch.cpp b/code/nelns/login_system/nel_launcher_windows_ext2/patch.cpp index a60f129fa..b55c8cdff 100644 --- a/code/nelns/login_system/nel_launcher_windows_ext2/patch.cpp +++ b/code/nelns/login_system/nel_launcher_windows_ext2/patch.cpp @@ -27,6 +27,7 @@ #endif #include "nel/misc/debug.h" +#include "nel/misc/common.h" #include "nel/misc/path.h" #include "nel/misc/thread.h" @@ -586,7 +587,7 @@ private: string dest = filename.substr(0, filename.size ()-4); setRWAccess(dest); if(VerboseLog) nlinfo("Calling fopen('%s','wb')", dest.c_str()); - FILE *fp = fopen (dest.c_str(), "wb"); + FILE *fp = nlfopen (dest, "wb"); if (fp == NULL) { string err = toString("Can't open file '%s' : code=%d %s, (error code 32)", dest.c_str(), errno, strerror(errno)); diff --git a/code/ryzom/client/client_default.cfg b/code/ryzom/client/client_default.cfg index cc0a1e02b..f020283f9 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -454,6 +454,7 @@ XMLInterfaceFiles = { "config.xml", "widgets.xml", "webig_widgets.xml", + "appzone.xml", "player.xml", "inventory.xml", "interaction.xml", diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/appzone.lua b/code/ryzom/client/data/gamedev/interfaces_v3/appzone.lua new file mode 100644 index 000000000..1332eb3d5 --- /dev/null +++ b/code/ryzom/client/data/gamedev/interfaces_v3/appzone.lua @@ -0,0 +1,192 @@ + +-- global +AppZone = { + id = "ui:interface:appzone", + homeuri = "?action=appzone_toolbar", + launchuri = "?action=launch_app", + addappuri = "?action=list_user_apps", + mode = "h_bar", + imagesize = 26 +} + +-- use client.cfg value when available +local uri getClientCfg("AppZoneUrl") +if uri == nil or uri == '' then + uri = 'http://app.ryzom.com/' +end + +AppZone.homeuri = uri .. AppZone.homeuri +AppZone.launchuri = uri .. AppZone.launchuri +AppZone.addappuri = uri .. AppZone.addappuri + +function AppZone:getRoot() + return getUI(self.id) +end + +function AppZone:onButtonHome() + local webig = getUI("ui:interface:webig") + webig:find("html").url = self.addappuri + webig.active = true +end + +function AppZone:calculateSize(count, spacer, mode) + local w, h + if mode == "h_bar" then + -- icon=32, space=2+2 + w = count * self.imagesize + spacer * 15 + w = w + 55 + 10 + 20 + h = self.imagesize + 2 + elseif mode == "h_box" then + w = count * self.imagesize + w = w + 20 + h = self.imagesize + 2 + h = h * spacer + h = h + 15 + elseif mode == "v_bar" then + -- icon=32, space=2+2 + h = count * self.imagesize + spacer * 15 + h = h + 20 + 20 + 12 + w = self.imagesize + 2 + 18 + else + h = count * self.imagesize + h = h + 20 + 25 + w = self.imagesize + 2 + w = w * spacer + w = w + 16 + end + + local ui = getUI("ui:interface") + if w > ui.w then + w = ui.w + end + if h > ui.h then + h = ui.h + end + + return w, h +end + +function AppZone:setElementCount(count,spacer,m) + self.mode = m + + local root = self:getRoot() + local content = root:find("content") + local html = root:find("html") + + local button_toggle = root:find("toggle_mode") + local button_reload = root:find("browse_reload") + local button_home = root:find("browse_home") + + local w, h = self:calculateSize(count, spacer, self.mode) + root.h = h + root.w = w + content.w = w + content.h = h + + -- set position of buttons + if self.mode == "h_bar" then + -- button_toggle.posref = "BL BL" + button_toggle.x = 2 + button_toggle.y = 0 + -- button_reload.posref = "TL BL" + html.x = 15 + html.y = 0 + button_reload.x = -25 + button_reload.y = -25 + -- button_home.posref = "BR BR" + button_home.x = 0 + button_home.y = -3 + 5 + elseif self.mode == "h_box" then + -- button_toggle.posref = "TL TL" + button_toggle.x = 2 + button_toggle.y = h - 15 + -- button_reload.posref = "TL BL" + html.x = 0 + html.y = -20 + button_reload.x = -25 + button_reload.y = -4 - 20 + -- button_home.posref = "BR BR" + button_home.x = 0 + button_home.y = -3 + h - 18 + elseif self.mode == "v_bar" then + -- button_toggle.posref = "TL TL" + button_toggle.x = 2 + button_toggle.y = h - 15 + -- button_reload.posref = "TL BL" + html.x = 0 + html.y = -20 + button_reload.x = 0 + button_reload.y = -4 + -- button_home.posref = "BR BR" + button_home.x = 4 - 7 + button_home.y = -3 + else + -- button_toggle.posref = "TL TL" + button_toggle.x = 2 + button_toggle.y = h - 15 + -- button_reload.posref = "TL BL" + html.x = 0 + html.y = -20 + button_reload.x = -25 + button_reload.y = -4 - 20 + -- button_home.posref = "BR BR" + button_home.x = 0 - w + 54 + 12 + button_home.y = -3 + end +end + +function AppZone:setMode(m) + self.mode = m + + self:reload() +end + +function AppZone:setActive(s) + self:getRoot().active = s +end + +function AppZone:launchApp(appid, appwin, appurl) + if not appwin then + if string.match(appid, "^[0-9]+$") then + appwin = "app" .. tostring(appid) + else + appwin = "webig" + end + end + + if not appurl then + appurl = self.launchuri .. "&appid=" .. tostring(appid) + end + + if WebBrowser then + WebBrowser:openWindow(appwin, appurl) + else + -- fallback if WebBrowser not present + local webig = getUI("ui:interface:webig") + webig:find("html").url = appurl; + webig.active = true + end +end + +function AppZone:reload() + local url = self.homeuri + url = url .. "&mode=" .. tostring(self.mode) + + local html = self:getRoot():find("html") + html.url = url +end + +-- slash command: /appzone +function AppZone:handle(cmd) + if cmd == 'show' then + self:setActive(true) + elseif cmd == 'hide' then + self:setActive(false) + elseif cmd == 'reload' then + self:reload() + elseif cmd == 'list' then + self:onButtonHome() + else + self:launchApp(cmd) + end +end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/appzone.xml b/code/ryzom/client/data/gamedev/interfaces_v3/appzone.xml new file mode 100644 index 000000000..c6f08c3b2 --- /dev/null +++ b/code/ryzom/client/data/gamedev/interfaces_v3/appzone.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/bg_downloader.lua b/code/ryzom/client/data/gamedev/interfaces_v3/bg_downloader.lua index c2569b301..161012d9e 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/bg_downloader.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/bg_downloader.lua @@ -32,7 +32,7 @@ end ------------------------------------------------------------------------------------------------------------ function bgdownloader:setIcon(icon) - local bm = self:getProgressGroup():find("bm"); + local bm = self:getProgressGroup():find("bm") if icon == "" then bm.active = false else diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/bot_chat_v4.lua b/code/ryzom/client/data/gamedev/interfaces_v3/bot_chat_v4.lua index 2b9d8fb3c..f0b3ec913 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/bot_chat_v4.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/bot_chat_v4.lua @@ -4,7 +4,7 @@ ------------------------------------------------------------------------------------------------------------ -- create the game namespace without reseting if already created in an other file. if (game==nil) then - game= {}; + game = {} end @@ -12,14 +12,14 @@ end -- called to construct guild flags background in the modal window function game:bcCreateGuildInitFlags() - local ui = getUICaller(); + local ui = getUICaller() for i = 0,14 do - local uiBack = getUI(getUIId(ui) .. ':back' .. i); - uiBack.image1.back = i+1; - uiBack.image1.symbol = 0; - uiBack.image1.color1 = runExpr('makeRGB(255,255,255)'); - uiBack.image1.color2 = runExpr('makeRGB(0,0,0)'); + local uiBack = getUI(getUIId(ui) .. ':back' .. i) + uiBack.image1.back = i+1 + uiBack.image1.symbol = 0 + uiBack.image1.color1 = runExpr('makeRGB(255,255,255)') + uiBack.image1.color2 = runExpr('makeRGB(0,0,0)') end end @@ -28,37 +28,37 @@ end -- trap some parts should be deprecated ... try to clean it up function game:bcMissionsUpdate() - local mt = getDbProp('UI:TEMP:MISSION:MISSION_TYPE'); + local mt = getDbProp('UI:TEMP:MISSION:MISSION_TYPE') -- init bot_chat_missions title - local title = 'uiBotChatMissions'; - if (mt == 3) then title = 'uiBotChatZCCharges'; - elseif (mt == 4) then title = 'uiBotChatBuilding'; - elseif (mt == 5) then title = 'uiBotChatRMBuy'; - elseif (mt == 6) then title = 'uiBotChatRMUpgrade'; + local title = 'uiBotChatMissions' + if (mt == 3) then title = 'uiBotChatZCCharges' + elseif (mt == 4) then title = 'uiBotChatBuilding' + elseif (mt == 5) then title = 'uiBotChatRMBuy' + elseif (mt == 6) then title = 'uiBotChatRMUpgrade' end - local ui = getUI('ui:interface:bot_chat_missions'); - ui.title = title; + local ui = getUI('ui:interface:bot_chat_missions') + ui.title = title -- init desc - title = 'uiSelectMission'; - if (mt == 3) then title = 'uiSelectZCCharge'; - elseif (mt == 4) then title = 'uiSelectBuilding'; - elseif (mt == 5) then title = 'uiSelectRMBuy'; - elseif (mt == 6) then title = 'uiSelectRMUpgrade'; + title = 'uiSelectMission' + if (mt == 3) then title = 'uiSelectZCCharge' + elseif (mt == 4) then title = 'uiSelectBuilding' + elseif (mt == 5) then title = 'uiSelectRMBuy' + elseif (mt == 6) then title = 'uiSelectRMUpgrade' end - ui.header_opened.mission_title.hardtext = title; + ui.header_opened.mission_title.hardtext = title - ui.header_opened.zc_duty.active = (mt == 3); - ui.header_opened.xp_guild.active = ((mt == 5) or (mt == 6)); + ui.header_opened.zc_duty.active = (mt == 3) + ui.header_opened.xp_guild.active = ((mt == 5) or (mt == 6)) -- init bot_chat_accept_mission title - title = 'uiAcceptMission'; - if (mt == 3) then title = 'uiAcceptZCCharge'; - elseif (mt == 4) then title = 'uiAcceptBuilding'; - elseif (mt == 5) then title = 'uiAcceptRMBuy'; - elseif (mt == 6) then title = 'uiAcceptRMUpgrade'; + title = 'uiAcceptMission' + if (mt == 3) then title = 'uiAcceptZCCharge' + elseif (mt == 4) then title = 'uiAcceptBuilding' + elseif (mt == 5) then title = 'uiAcceptRMBuy' + elseif (mt == 6) then title = 'uiAcceptRMUpgrade' end - ui = getUI('ui:interface:bot_chat_accept_mission'); + ui = getUI('ui:interface:bot_chat_accept_mission') ui.title = title; end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/help.lua b/code/ryzom/client/data/gamedev/interfaces_v3/help.lua index 07a7fcd2c..d6c6da720 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/help.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/help.lua @@ -3,36 +3,36 @@ ------------------------------------------------------------------------------------------------------------ -- create the game namespace without reseting if already created in an other file. if (help==nil) then - help= {}; + help = {} end ------------------------------------------------------------------------------------------------------------ -- function help:closeCSBrowserHeader() - local ui = getUI('ui:interface:cs_browser'); + local ui = getUI('ui:interface:cs_browser') -- save size - ui_cs_browser_h = ui.h; - ui_cs_browser_w = ui.w; + ui_cs_browser_h = ui.h + ui_cs_browser_w = ui.w -- reduce window size - ui.pop_min_h = 32; - ui.h = 0; - ui.w = 216; + ui.pop_min_h = 32 + ui.h = 0 + ui.w = 216 end ------------------------------------------------------------------------------------------------------------ -- function help:openCSBrowserHeader() - local ui = getUI('ui:interface:cs_browser'); - ui.pop_min_h = 96; + local ui = getUI('ui:interface:cs_browser') + ui.pop_min_h = 96 -- set size from saved values if (ui_cs_browser_h ~= nil) then - ui.h = ui_cs_browser_h; + ui.h = ui_cs_browser_h end if (ui_cs_browser_w ~= nil) then - ui.w = ui_cs_browser_w; + ui.w = ui_cs_browser_w end end \ No newline at end of file diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua b/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua index a4deeb05a..12210fadf 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/info_player.lua @@ -161,7 +161,7 @@ end ------------------------------------------------------------------------------------------------------------ -- Compute the current Max Resist function game:getMagicResistMaxLevel() - local mlvl= self:getMagicResistBaseLevel() + getDbProp(formatUI('%player_resist_maxratio')); + local mlvl= 25 + self:getMagicResistBaseLevel() + getDbProp(formatUI('%player_resist_maxratio')); return math.max(0,mlvl); end @@ -267,27 +267,27 @@ function game:onDrawNpcWebPage() local available if config.Local == 1 then available = (NicoMagicURL ~= "") - else - available = isDynStringAvailable(self.NpcWebPage.UrlTextId) + else + available = isDynStringAvailable(self.NpcWebPage.UrlTextId) end - if(available) then + if(available) then local ucUrl if config.Local == 1 then - ucUrl = ucstring(NicoMagicURL) -- for test in local mode + ucUrl = ucstring(NicoMagicURL) -- for test in local mode else ucUrl = getDynString(self.NpcWebPage.UrlTextId); end -- browse local uiStr= getUIId(getUICaller()); - -- if the url + -- if the url local utf8Url = ucUrl:toUtf8() - local isRing = string.find(utf8Url, "ring_access_point=1") ~= nil + local isRing = string.find(utf8Url, "ring_access_point=1") ~= nil if isRing then getUI("ui:interface:npc_web_browser").active = false runAH(nil, "context_ring_sessions", "") return else - local hideWindow = string.find(utf8Url, "_hideWindow=1") ~= nil + local hideWindow = string.find(utf8Url, "_hideWindow=1") ~= nil if hideWindow then getUI("ui:interface:npc_web_browser").active = false end @@ -336,14 +336,14 @@ function game:startNpcWebPage() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:closeNpcWebBrowserHeader() local ui = getUI('ui:interface:npc_web_browser'); - + -- save size ui_npc_web_browser_h = ui.h; ui_npc_web_browser_w = ui.w; - + -- reduce window size ui.pop_min_h = 32; ui.h = 0; @@ -351,7 +351,7 @@ function game:closeNpcWebBrowserHeader() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:openNpcWebBrowserHeader() local ui = getUI('ui:interface:npc_web_browser'); ui.pop_min_h = 96; @@ -360,7 +360,7 @@ function game:openNpcWebBrowserHeader() if (ui_npc_web_browser_h ~= nil) then ui.h = ui_npc_web_browser_h; end - + if (ui_npc_web_browser_w ~= nil) then ui.w = ui_npc_web_browser_w; end @@ -538,7 +538,7 @@ function game:updateFameBar(path) uiMaxLimit.x = barX + barW * (fameMax + 100) / 200; -- init bar3d - if (bar3dStart < bar3dLimit) then + if (bar3dStart < bar3dLimit) then uiBar3d.x= bar3dStart; uiBar3d.w= bar3dLimit-bar3dStart; else @@ -553,7 +553,7 @@ function game:updateFameBarTT(path) local fameMax = getDbProp(path .. ':THRESHOLD'); local text = i18n.get('uittFameMaxPossible'); - text = findReplaceAll(text, '%famemax', tostring(fameMax)); + text = findReplaceAll(text, '%famemax', tostring(fameMax)); setContextHelpText(text); end @@ -564,12 +564,12 @@ function game:getPvpEffects() local i; local hasBonus = false; local hasMalus = false; - + local text = '' local textBonus = ''; local textMalus = ''; local fmt; - + -- check every malus and bonus for i=0, n do local path = formatUI('SERVER:PVP_EFFECTS:#1', i); @@ -611,7 +611,7 @@ function game:getPvpEffects() end ------------------------------------------------------------------------------------------------------------ -function game:getFactionName(id) +function game:getFactionName(id) if (id == self.TPVPClan.Kami) then return i18n.get('uiFameKami'); elseif (id == self.TPVPClan.Karavan) then @@ -636,10 +636,10 @@ function game:getAllegiancePoints() local civPoints = getDbProp(path .. ':CIV_POINTS'); local cult = getDbProp(path .. ':CULT'); local cultPoints = getDbProp(path .. ':CULT_POINTS'); - + local text; local uiGroup= getUICaller(); - + -- civ allegiance if (civ == self.TPVPClan.None or civ == self.TPVPClan.Neutral) then text = i18n.get('uiPvpFameNoCivAllegiance'); @@ -647,9 +647,9 @@ function game:getAllegiancePoints() text = i18n.get('uiPvpFameAllegiancePoints'); text = findReplaceAll(text, '%faction', self:getFactionName(civ)); text = findReplaceAll(text, '%points', tostring(civPoints)); - end + end uiGroup.civ_allegiance_pts.uc_hardtext_format = text; - + -- cult allegiance if (cult == self.TPVPClan.None or cult == self.TPVPClan.Neutral) then text = i18n.get('uiPvpFameNoCultAllegiance'); @@ -698,11 +698,11 @@ function game:fameAllegianceTooltipCultGuild() end ------------------------------------------------------------------------------------------------------------ --- +-- function game:tooltipDeltaValue(base, max) -- Calculate delta local val = max - base; - + local text; if (val == 0) then text = concatUCString('@{FFFF}', tostring(max)); @@ -729,37 +729,37 @@ function game:tooltipDeltaValue(base, max) text = concatUCString(text, ')'); end end - + return text; end ------------------------------------------------------------------------------------------------------------ --- +-- function game:tooltipScore(dbBase, dbMax, ttFormat) -- Get DB values local base = getDbProp(dbBase); local max = getDbProp(dbMax); - + -- Tooltip text local fmt = i18n.get(ttFormat); local text = self:tooltipDeltaValue(base, max); fmt = findReplaceAll(fmt, "%n", text ); - + -- Set tooltip setContextHelpText(fmt); end ------------------------------------------------------------------------------------------------------------ --- +-- function game:tooltipScoreEP(dbBase, dbMax, ttFormat, dbLvl, dbMod) -- Defender level local defLvl= getDbProp(formatUI(dbLvl)); defLvl = math.max(0, defLvl); - + -- Attacker level local attLvl = getBaseSkillValueMaxChildren(getSkillIdFromName('SF')); - + -- Get DB values local base = getDbProp(dbBase); local max = getDbProp(dbMax); @@ -774,7 +774,7 @@ function game:tooltipScoreEP(dbBase, dbMax, ttFormat, dbLvl, dbMod) fmt = findReplaceAll(fmt, "%n", text ); fmt = findReplaceAll(fmt, "%l", tostring(attLvl)); fmt = findReplaceAll(fmt, "%p", textChance); - + -- Set tooltip setContextHelpText(fmt); end @@ -786,7 +786,7 @@ end ---------------------------------- RING STATS --------------------------------------------------- ------------------------------------------------------------------------------------------------------------- -RingPlayerInfo = +RingPlayerInfo = { WaitingInfo = false, LastRefreshTime = 0, @@ -810,7 +810,7 @@ end -- function RingPlayerInfo:initRingStatPlayer() - setOnDraw(self:getWindow(), "RingPlayerInfo:onRingRatingPlayerDraw()") + setOnDraw(self:getWindow(), "RingPlayerInfo:onRingRatingPlayerDraw()") end -------------------------------------------------------------------------------------------------------------- @@ -819,16 +819,16 @@ function RingPlayerInfo:onRingRatingPlayerDraw() local timeInSec = nltime.getLocalTime() / 1000 if self.WaitingInfo then - if timeInSec - self.LastRefreshTime > self.WaitingPeriod then + if timeInSec - self.LastRefreshTime > self.WaitingPeriod then self.WaitingInfo = false self.LastRefreshTime = nltime.getLocalTime() / 1000 - else + else if not self.InfoReceived then --debugInfo("No received info") end end else - if timeInSec - self.LastRefreshTime > self.RefreshPeriod then + if timeInSec - self.LastRefreshTime > self.RefreshPeriod then self:refresh() else --debugInfo("pas de refresh") @@ -844,7 +844,7 @@ function RingPlayerInfo:updatePendingRefresh() if self.PendingRefresh then local currTime = nltime.getLocalTime() / 1000 - if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then + if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then self.LastRefreshQuerryTime = currTime self.PendingRefresh = false game.getRingStats() @@ -924,10 +924,10 @@ end -- function RingPlayerInfo:refresh() - self.PendingRefresh = true + self.PendingRefresh = true self.LastRefreshTime = nltime.getLocalTime() / 1000 self.WaitingInfo = true -end +end -------------------------------------------------------------------------------------------------------------- -- @@ -937,7 +937,7 @@ function RingPlayerInfo:tooltipEcosystemPoints(rp, maxRp, ttFormat) local fmt = i18n.get(ttFormat); fmt = findReplaceAll(fmt, "%n", rp ); fmt = findReplaceAll(fmt, "%p", maxRp ); - + -- Set tooltip return fmt; end @@ -954,8 +954,8 @@ function RingPlayerInfo:updateRRPSLevel(dbVal, tooltip) local ui= getUICaller(); local uiText= ui.val; - -- set the text - uiText.uc_hardtext= tostring(val) + -- set the text + uiText.uc_hardtext= tostring(val) self:tooltipRRPs(dbVal, tooltip) end @@ -970,7 +970,7 @@ function RingPlayerInfo:tooltipRRPs(dbBase, ttFormat) local fmt = i18n.get(ttFormat); local text = tostring(val) fmt = findReplaceAll(fmt, "%n", text ); - + -- Set tooltip setContextHelpText(fmt); end @@ -1013,7 +1013,7 @@ end -------------------------------------------------------------------------------------------------------------- -- function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText) - + local org = getDbProp(path.."1:VALUE") getUICaller()[uiOrgText].uc_hardtext = i18n.get('uiOrganization_' .. org) @@ -1022,7 +1022,7 @@ function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText) local points = getDbProp(path.."3:VALUE") getUICaller()[uiPointsText].uc_hardtext= points - + end ------------------------------------------------------------------------------------------------------------ @@ -1033,10 +1033,10 @@ end -------------------------------------------------------------------------------------------------------------- -function game:popMissionList() - local menu = getUI("ui:interface:mission_cb_menu") +function game:popMissionList() + local menu = getUI("ui:interface:mission_cb_menu") enableModalWindow(getUICaller(), "ui:interface:mission_cb_menu") - self:updateMissionMenuSize() + self:updateMissionMenuSize() end @@ -1053,12 +1053,12 @@ function game:getMissionDbPath(missionIndex) return "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - numMissions) else return "SERVER:MISSIONS:" .. tostring(missionIndex) - end + end end -------------------------------------------------------------------------------------------------------------- -function game:getCurrMissionIndex() - local result = getDbProp("UI:SAVE:MISSION_SELECTED") +function game:getCurrMissionIndex() + local result = getDbProp("UI:SAVE:MISSION_SELECTED") return result end @@ -1071,10 +1071,10 @@ end function game:updateCurrMissionComboBox() local numMissions = tonumber(getDefine("ipj_nb_mission")) local missionFound = false - local cb = getUI("ui:interface:info_player_journal:content:mission_combo") - local missionList = getUI("ui:interface:info_player_journal:content:mission_list") + local cb = getUI("ui:interface:info_player_journal:content:mission_combo") + local missionList = getUI("ui:interface:info_player_journal:content:mission_list") for i = 0, numMissions - 1 do - if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0 + if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0 or getDbProp("SERVER:GROUP:MISSIONS:" .. i .. ":TITLE") ~= 0 then missionFound = true break @@ -1095,20 +1095,20 @@ function game:updateCurrMissionComboBox() missionList.no_available_mission.active = false cb.arrow.active = true cb.select.active = true - local currMission = self:getCurrMissionIndex() + local currMission = self:getCurrMissionIndex() - local dbPath = self:getMissionDbPath(currMission) - -- - local selected = (currMission ~= -1) + local dbPath = self:getMissionDbPath(currMission) + -- + local selected = (currMission ~= -1) if selected then cb.mission_title.textid_dblink = dbPath .. ":TITLE" selected = (tile ~= 0) - end + end cb.mission_ico.active = selected cb.mission_title.active = selected cb.no_selected_mission.active = not selected missionList.no_selected_mission.active = not selected - if selected then + if selected then if getDbProp(dbPath .. ":FINISHED") == 0 then cb.mission_ico.texture = runExpr("getMissionSmallIcon(" .. tostring(getDbProp(dbPath .. ":ICON") .. ")")) elseif getDbProp(dbPath .. ":FINISHED") == 1 then @@ -1116,17 +1116,17 @@ function game:updateCurrMissionComboBox() else cb.mission_ico.texture = "Small_Task_Failed.tga" end - end + end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionSelected(index) +function game:onMissionSelected(index) disableModalWindow() self:updateCurrMissionComboBox() end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionSelected(index) +function game:onGroupMissionSelected(index) disableModalWindow() self:updateCurrMissionComboBox() end @@ -1138,33 +1138,33 @@ function game:onMissionDBIndexChanged() -- if selection was made from the list, update the other list if missionIndex >= self:getGroupMissionFirstIndex() then local groupMissionIndex = missionIndex - self:getGroupMissionFirstIndex() - getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true + getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true getUI("ui:interface:mission_cb_menu:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true else - getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true + getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true getUI("ui:interface:mission_cb_menu:mission_list:b_title" .. tostring(missionIndex)).pushed = true end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionTitleChanged(index) +function game:onMissionTitleChanged(index) -- if title is not nil then a new mission has been added -> if db initilization is over, then selected this new mission - if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then - if game.InGameDbInitialized or config.Local then + if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then + if game.InGameDbInitialized or config.Local then self:setCurrentMission(index) end - else + else self:updateCurrMissionComboBox() self:updateMissionMenuSize() end end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionTitleChanged(index) - if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then - if game.InGameDbInitialized or config.Local then +function game:onGroupMissionTitleChanged(index) + if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then + if game.InGameDbInitialized or config.Local then self:setCurrentMission(index + 15) end - else + else self:updateCurrMissionComboBox() self:updateMissionMenuSize() end @@ -1174,21 +1174,21 @@ end function game:updateMissionMenuSize() local parentCB = getUI("ui:interface:info_player_journal:content:mission_combo") local menu = getUI("ui:interface:mission_cb_menu") - if not menu.active then return end + if not menu.active then return end local maxNumMissions = 2 * self:getGroupMissionFirstIndex() - local missionCount = 0 + local missionCount = 0 for k = 0, maxNumMissions - 1 do if getDbProp(self:getMissionDbPath(k) .. ":TITLE") ~= 0 then - missionCount = missionCount + 1 + missionCount = missionCount + 1 end - end + end menu.h = 8 + missionCount * 18 menu.y = 0 menu:updateCoords() local y = parentCB.y_real - menu.h_real - 1 if y < 0 then y = parentCB.y_real + parentCB.h_real + 1 - end + end local scrW local scrH scrW, scrH = getWindowSize() @@ -1197,7 +1197,7 @@ function game:updateMissionMenuSize() end menu.w = parentCB.w_real menu.y = y - menu.x = parentCB.x_real + menu.x = parentCB.x_real menu.h = 8 + missionCount * 18 menu:invalidateCoords() end @@ -1205,7 +1205,7 @@ end -------------------------------------------------------------------------------------------------------------- --function game:updateMissionDescCloseButton(index) -- local dbPath = self:getMissionDbPath(index) --- if index == self:getCurrMissionIndex() then +-- if index == self:getCurrMissionIndex() then -- local closeText = getUI("ui:interface:info_player_journal:content:desc:close") -- local button = getUI("ui:interface:info_player_journal:content:desc:uppart:over_icon") -- local finished = getDbProp(dbPath .. ":FINISHED") @@ -1224,29 +1224,29 @@ end --end -------------------------------------------------------------------------------------------------------------- -function game:onMissionFinished(index) - self:updateCurrMissionComboBox() +function game:onMissionFinished(index) + self:updateCurrMissionComboBox() --self:updateMissionDescCloseButton(index) end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionFinished(index) +function game:onGroupMissionFinished(index) self:updateCurrMissionComboBox() --self:updateMissionDescCloseButton(index + game:getGroupMissionFirstIndex()) end -------------------------------------------------------------------------------------------------------------- -function game:expandMissionList() - local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") +function game:expandMissionList() + local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") missionCB.active = not missionCB.active self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -function game:updateMissionWindowLayout() +function game:updateMissionWindowLayout() if not isInRingMode() then local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") - local missionList = getUI("ui:interface:info_player_journal:content:mission_list") + local missionList = getUI("ui:interface:info_player_journal:content:mission_list") local fake = getUI("ui:interface:info_player_journal:content:fake") local sepBis = getUI("ui:interface:info_player_journal:content:separator_bis") local desc = getUI("ui:interface:info_player_journal:content:desc") @@ -1254,18 +1254,18 @@ function game:updateMissionWindowLayout() local popMinH local win = getUI("ui:interface:info_player_journal") - if missionCB.active then - sepBis.active = false + if missionCB.active then + sepBis.active = false missionList.active = false fake.sizeref="" fake.y = -32 fake.h = 0 - expanded = 0 + expanded = 0 desc.max_sizeref ="wh" desc.max_h= -42 win.pop_min_h = 152 - win.content_y_offset - else - sepBis.active = true + else + sepBis.active = true missionList.active = true fake.sizeref="wh5" fake.y = -8 @@ -1274,23 +1274,23 @@ function game:updateMissionWindowLayout() desc.max_sizeref ="wh5" desc.max_h=16 win.pop_min_h = 152 - win.content_y_offset - end + end - local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") + local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") fixedEntry:updateCoords() desc.max_h = desc.max_h - fixedEntry.h setDbProp("UI:SAVE:EXPAND_MISSION_LIST", expanded) - getUI("ui:interface:info_player_journal"):invalidateCoords() + getUI("ui:interface:info_player_journal"):invalidateCoords() end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionJournalOpened() +function game:onMissionJournalOpened() local missionDesc = getUI("ui:interface:info_player_journal:content:desc") - missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1 + missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1 - local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST") + local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST") self:updateMissionJournalMode() if not isInRingMode() then @@ -1304,9 +1304,9 @@ function game:onMissionJournalOpened() self:updateMissionJournalHeader() self:updateMissionWindowLayout() - self:updateMissionJournalFixedEntry() + self:updateMissionJournalFixedEntry() + - end @@ -1315,12 +1315,12 @@ function game:updateMissionJournalHeader() local win = getUI("ui:interface:info_player_journal") local headerActive = getDbProp("UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE") ~= 0 win.header_active = headerActive - win.right_button_enabled = headerActive + win.right_button_enabled = headerActive if headerActive then - win.uc_title_opened = i18n.get("uiJournalTitle") + win.uc_title_opened = i18n.get("uiJournalTitle") win.content_y_offset = 0 else - win.uc_title_opened = ucstring("") + win.uc_title_opened = ucstring("") win.content_y_offset = win.header_opened.h_real + 3 end end @@ -1329,13 +1329,13 @@ end -------------------------------------------------------------------------------------------------------------- function game:updateMissionJournalFixedEntry() -- update fixed entry text - - local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry") + + local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry") local fixedEntryMain = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") - + fixedEntryRing.active = game.InGameDbInitialized and isInRingMode() - fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode() - + fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode() + local id = "uiFixedMissionEntry" @@ -1346,22 +1346,22 @@ function game:updateMissionJournalFixedEntry() end if isPlayerFreeTrial() then id = id .. "_Trial" - end + end else - if isInRingMode() then - id = id .. "_R2" - else + if isInRingMode() then + id = id .. "_R2" + else id = id .. "_Mainland_" .. getUserRace() end - end + end fixedEntryMain.uc_hardtext = i18n.get(id) fixedEntryRing.uc_hardtext = i18n.get(id) - + self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -function game:setCurrentMission(index) +function game:setCurrentMission(index) mw = getMissionWindow() mw.active = game.InGameDbInitialized if index < self:getGroupMissionFirstIndex() then @@ -1372,7 +1372,7 @@ function game:setCurrentMission(index) end -------------------------------------------------------------------------------------------------------------- -function game:onMissionComboWheelUp() +function game:onMissionComboWheelUp() local currMissionIndex = self:getCurrMissionIndex() while currMissionIndex > 0 do currMissionIndex = currMissionIndex - 1 @@ -1384,7 +1384,7 @@ function game:onMissionComboWheelUp() end -------------------------------------------------------------------------------------------------------------- -function game:onMissionComboWheelDown() +function game:onMissionComboWheelDown() local currMissionIndex = self:getCurrMissionIndex() local maxNumMission = 2 * self:getGroupMissionFirstIndex() while currMissionIndex < (maxNumMission - 1) do @@ -1399,37 +1399,37 @@ end -------------------------------------------------------------------------------------------------------------- -function game:toggleMissionJournalCaption() - local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE" +function game:toggleMissionJournalCaption() + local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE" setDbProp(dbPath, 1 - getDbProp(dbPath)) - local win = getUI("ui:interface:info_player_journal") + local win = getUI("ui:interface:info_player_journal") self:updateMissionJournalHeader() self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -- handler called by C++ to tell that the main loop is about to begin -function game:onMainLoopBegin() - game.InGameDbInitialized = false +function game:onMainLoopBegin() + game.InGameDbInitialized = false game.PrevSessionMission = getDbProp("UI:VARIABLES:MISSION_SELECTED_PREV_SESSION") - + debugInfo("onMainLoopBegin()") end -------------------------------------------------------------------------------------------------------------- -- handler called by C++ to tell that all initial value have been set in the db -function game:onInGameDbInitialized() +function game:onInGameDbInitialized() game.InGameDbInitialized = true - -- if the journal is opened, force an update for the fixed entry text + -- if the journal is opened, force an update for the fixed entry text -- (says if we're in start island, paying account ...) need DB flags like -- IS_NEWBIE & IS_TRIAL to be received - game:updateMissionJournalFixedEntry() - -- If a mission was previously selected, restore it + game:updateMissionJournalFixedEntry() + -- If a mission was previously selected, restore it if game.PrevSessionMission ~= -1 then - self:setCurrentMission(game.PrevSessionMission) + self:setCurrentMission(game.PrevSessionMission) end - + game:setInfoPlayerCharacterRace() end @@ -1437,7 +1437,7 @@ function game:onWebIgReady() -- Call init webig getUI("ui:interface:web_transactions:content:html"):browse("home") getUI("ui:interface:webig:content:html"):browse("home") - + end -------------------------------------------------------------------------------------------------------------- @@ -1464,7 +1464,7 @@ end -------------------------------------------------------------------------------------------------------------- -- ring journal on / off -function game:setMissionJournalRingMode(isRing) +function game:setMissionJournalRingMode(isRing) local journal = getUI("ui:interface:info_player_journal") if isRing then journal.content.expand_mission_list.active = false @@ -1480,7 +1480,7 @@ function game:setMissionJournalRingMode(isRing) journal.no_available_missions.active = true else journal.content.expand_mission_list.active = true - journal.no_available_missions.active = false; + journal.no_available_missions.active = false; journal.content.active = true; --journal.content.mission_list.active = true; journal.content.sv.active = true; @@ -1494,8 +1494,8 @@ end -------------------------------------------------------------------------------------------------------------- -- update mission journal depending on wether we're in the ring or not function game:updateMissionJournalMode() - --local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test' - game:setMissionJournalRingMode(isInRingMode()) + --local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test' + game:setMissionJournalRingMode(isInRingMode()) end @@ -1521,22 +1521,22 @@ function game:onNewMissionStepAdded(stepIndex) end -- debugInfo("New Step") - if missionIndex < 15 then + if missionIndex < 15 then dbPath = "SERVER:MISSIONS:" .. tostring(missionIndex) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT" - else + else dbPath = "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - 15) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT" - end + end local stringID = getDbProp(dbPath) if stringID ~= 0 then -- debugInfo(tostring(stringID)) table.insert(remainingMissionTextIDs, stringID) - setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()") - else + setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()") + else end end function game:ensureLastMissionStepVisibility0() - + local missing = false for k, v in pairs(remainingMissionTextIDs) do if not isDynStringAvailable(v) then @@ -1545,54 +1545,54 @@ function game:ensureLastMissionStepVisibility0() end end local missionWnd = getMissionWindow() - if not missing then + if not missing then remainingMissionTextIDs = {} - -- delay real update to newt frame - setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()") + -- delay real update to newt frame + setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()") else - -- for debug : dump the list of remaining "dyn string" + -- for debug : dump the list of remaining "dyn string" --local stringList = "{" --for k, v in remainingMissionTextIDs do - -- if not isDynStringAvailable(v) then + -- if not isDynStringAvailable(v) then -- stringList = stringList .. " " .. tostring(v) -- end --end - --stringList = stringList .. "}" + --stringList = stringList .. "}" end end -function game:ensureLastMissionStepVisibility1() +function game:ensureLastMissionStepVisibility1() local missionWnd = getMissionWindow() - local scrollBar = missionWnd:find("sv_desc") - --scrollBar.trackPos = 20000 -- move upward + local scrollBar = missionWnd:find("sv_desc") + --scrollBar.trackPos = 20000 -- move upward --scrollBar:updateCoords() - --setOnDraw(missionWnd, "") - local descWnd = missionWnd:find("desc") + --setOnDraw(missionWnd, "") + local descWnd = missionWnd:find("desc") local maxNumSteps = getDefine("ipj_nb_goal") local topStep - for stepIndex = 0, maxNumSteps -1 do + for stepIndex = 0, maxNumSteps -1 do local currStep = descWnd["step" .. tostring(stepIndex)] if currStep.active then topStep = currStep end end -- debugInfo("Found step : " .. topStep.hardtext) - if topStep == nil then + if topStep == nil then return - end + end scrollBar:ensureVisible(topStep, "M", "M") - + --local wantedY = topStep.h_real / 2 - (descWnd.y_real - topStep.y_real) - --local wantedY = descWnd.y_real + descWnd.h_real - topStep.y_real - --local offsetY = wantedY - descWnd.max_h_real / 2 - --if offsetY < 0 then offsetY = 0 end + --local wantedY = descWnd.y_real + descWnd.h_real - topStep.y_real + --local offsetY = wantedY - descWnd.max_h_real / 2 + --if offsetY < 0 then offsetY = 0 end --descWnd.ofsy = offsetY --descWnd:invalidateCoords() --descWnd:updateCoords() - setOnDraw(missionWnd, "") - + setOnDraw(missionWnd, "") + end -------------------------------------------------------------------------------------------------------------- @@ -1606,9 +1606,9 @@ end function game:addRpJob(jobtype, id, value, rpjobs) local base_path = "ui:interface:info_player_skills:content:rpjobs:rpjob_"..jobtype.."_"..id..":rpjob_"..jobtype.."_infos_"..id - + local group = getUI("ui:interface:info_player_skills:content:rpjobs:rpjob_"..jobtype.."_"..id) - + if (value == nil) then group.active = false else @@ -1618,16 +1618,16 @@ function game:addRpJob(jobtype, id, value, rpjobs) group.active = false else group.active = true - + local echelon_value = rpjobs[sitem][1] local quantity = rpjobs[sitem][2] - + local maxlevel = (echelon_value*6)-30 - + if (quantity > maxlevel) then quantity = maxlevel end - + local base = getUI(base_path..":t") base.hardtext = i18n.get(name):toUtf8() local ui = getUI(base_path..":icon") @@ -1657,7 +1657,7 @@ function game:getRPJobs() rpjobs_elementary = {} rpjobs_roleplay = {} rpjobs = {} - + for i = 0, 499, 1 do local sheet = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":SHEET") if (sheet ~= 0) then @@ -1665,7 +1665,7 @@ function game:getRPJobs() if (string.sub(name, 0, 6) == "rpjob_") then local quality = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":QUALITY") local quantity = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":QUANTITY") - + if (name == "rpjob_advanced.sitem") then table.insert(rpjobs_advanced, quality) else @@ -1688,7 +1688,7 @@ function game:getRPJobs() end end end - + for id=1,2,1 do game:addRpJob("advanced", id, rpjobs_advanced[id], rpjobs) end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/out_v2_appear.lua b/code/ryzom/client/data/gamedev/interfaces_v3/out_v2_appear.lua index 1c8a86342..43727200a 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/out_v2_appear.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/out_v2_appear.lua @@ -3,8 +3,8 @@ ------------------------------------------------------------------------------------------------------------ -- create the game namespace without reseting if already created in an other file. -if (outgame==nil) then - outgame= {}; +if (outgame == nil) then + outgame = {} end @@ -20,15 +20,13 @@ end -- Fyros function outgame:getFyrosFirstName() - local nbFyrosFirstNames = 0; - for _ in pairs(fyrosFirstNames) do nbFyrosFirstNames = nbFyrosFirstNames + 1 end + local nbFyrosFirstNames = #fyrosFirstNames return fyrosFirstNames[math.random(nbFyrosFirstNames)] end function outgame:getFyrosLastName() - local nbFyrosLastNames = 0; - for _ in pairs(fyrosLastNames) do nbFyrosLastNames = nbFyrosLastNames + 1 end + local nbFyrosLastNames = #fyrosLastNames return fyrosLastNames[math.random(nbFyrosLastNames)] end @@ -36,98 +34,97 @@ end -- Matis function outgame:getMatisFirstName(sex) -- 1 = male, 2 = female - local dbNameSex = getDbProp("UI:TEMP:NAME_SEX"); + local dbNameSex = getDbProp("UI:TEMP:NAME_SEX") if sex ~= nil then - dbNameSex = sex; + dbNameSex = sex end local FirstName = "" if tonumber(dbNameSex) == 1 then - local nbMatisMaleFirstNames = 0; - for _ in pairs(matisMaleFirstNames) do nbMatisMaleFirstNames = nbMatisMaleFirstNames + 1 end - FirstName = matisMaleFirstNames[math.random(nbMatisMaleFirstNames)]; + local nbMatisMaleFirstNames = #matisMaleFirstNames + FirstName = matisMaleFirstNames[math.random(nbMatisMaleFirstNames)] else - local nbMatisFemaleFirstNames = 0; - for _ in pairs(matisFemaleFirstNames) do nbMatisFemaleFirstNames = nbMatisFemaleFirstNames + 1 end - FirstName = matisFemaleFirstNames[math.random(nbMatisFemaleFirstNames)]; + local nbMatisFemaleFirstNames = #matisFemaleFirstNames + FirstName = matisFemaleFirstNames[math.random(nbMatisFemaleFirstNames)] end - return FirstName; + return FirstName end function outgame:getMatisLastName() - - local nbMatisLastNames = 0; - for _ in pairs(matisLastNames) do nbMatisLastNames = nbMatisLastNames + 1 end + local nbMatisLastNames = #matisLastNames return matisLastNames[math.random(nbMatisLastNames)] end -- Tryker function outgame:getTrykerFirstName() - local nbTrykerFirstNames = 0; - for _ in pairs(trykerFirstNames) do nbTrykerFirstNames = nbTrykerFirstNames + 1 end + local nbTrykerFirstNames = #trykerFirstNames return trykerFirstNames[math.random(nbTrykerFirstNames)] end function outgame:getTrykerLastName() - local nbTrykerLastNames = 0; - for _ in pairs(trykerLastNames) do nbTrykerLastNames = nbTrykerLastNames + 1 end + local nbTrykerLastNames = #trykerLastNames return trykerLastNames[math.random(nbTrykerLastNames)] end -- Zoraï function outgame:getZoraiFirstName() - local nbFirstNamesOne = 0; - for _ in pairs(zoraiFirstNamesOne) do nbFirstNamesOne = nbFirstNamesOne + 1 end - local FirstNameOne = zoraiFirstNamesOne[math.random(nbFirstNamesOne)]; + local nbFirstNamesOne = #zoraiFirstNamesOne + local FirstNameOne = zoraiFirstNamesOne[math.random(nbFirstNamesOne)] - local nbFirstNamesTwo = 0; - for _ in pairs(zoraiFirstNamesTwo) do nbFirstNamesTwo = nbFirstNamesTwo + 1 end - local FirstNameTwo = zoraiFirstNamesTwo[math.random(nbFirstNamesTwo)]; + local nbFirstNamesTwo = #zoraiFirstNamesTwo + local FirstNameTwo = zoraiFirstNamesTwo[math.random(nbFirstNamesTwo)] return FirstNameOne .. "-" .. FirstNameTwo end + function outgame:getZoraiLastName() - local nbLastNames = 0; - for _ in pairs(zoraiLastNames) do nbLastNames = nbLastNames + 1 end + local nbLastNames = #zoraiLastNames return zoraiLastNames[math.random(nbLastNames)] end function outgame:procGenerateName() - local uiNameFull = getUI("ui:outgame:appear_name:name_full"); - local uiGenText = getUI("ui:outgame:appear_name:eb"); - local dbNameRace = getDbProp("UI:TEMP:NAME_RACE"); - local dbNameSubRaceFirstName = getDbProp("UI:TEMP:NAME_SUB_RACE_FIRST_NAME"); - local dbNameSubRaceLastName = getDbProp("UI:TEMP:NAME_SUB_RACE_LAST_NAME"); + local uiNameFull = getUI("ui:outgame:appear_name:name_full") + local uiGenText = getUI("ui:outgame:appear_name:eb") + local dbNameRace = getDbProp("UI:TEMP:NAME_RACE") + local dbNameSubRaceFirstName = getDbProp("UI:TEMP:NAME_SUB_RACE_FIRST_NAME") + local dbNameSubRaceLastName = getDbProp("UI:TEMP:NAME_SUB_RACE_LAST_NAME") - local nameResult = ""; - local fullnameResult = ""; + local nameResult = "" + local fullnameResult = "" -- Look at outgame:procUpdateNameRaceLabel() for the "race" list. -- fy ma try zo --> local firstName = "test2" local lastName = "test" + + -- Fyros and Matis are using "first name, last name" order + -- Trykers and Zoraïs are using "last name, first name" order if tonumber(dbNameRace) == 1 then -- Fyros firstName = self:getFyrosFirstName() lastName = self:getFyrosLastName() + fullnameResult = firstName .. " " .. lastName elseif tonumber(dbNameRace) == 2 then -- Matis firstName = self:getMatisFirstName() lastName = self:getMatisLastName() + fullnameResult = firstName .. " " .. lastName elseif tonumber(dbNameRace) == 3 then -- Tryker firstName = self:getTrykerFirstName() lastName = self:getTrykerLastName() + fullnameResult = lastName .. " " .. firstName elseif tonumber(dbNameRace) == 4 then -- Zorai firstName = self:getZoraiFirstName() lastName = self:getZoraiLastName() + fullnameResult = lastName .. " " .. firstName elseif tonumber(dbNameRace) == 5 then -- Maraudeurs @@ -163,97 +160,99 @@ function outgame:procGenerateName() -- Zorai lastName = self:getZoraiLastName() end + + fullnameResult = firstName .. " " .. lastName end - fullnameResult = firstName .. " " .. lastName + -- always use first name for character name nameResult = firstName - uiNameFull.hardtext = fullnameResult; + uiNameFull.hardtext = fullnameResult - nameResult = string.gsub(nameResult, "'", ""); - nameResult = string.gsub(nameResult, " ", ""); - nameResult = string.gsub(nameResult, "-", ""); - nameResult = string.lower( nameResult ); - nameResult = nameResult:gsub("^%l", string.upper); - uiGenText.input_string = nameResult; + nameResult = string.gsub(nameResult, "'", "") + nameResult = string.gsub(nameResult, " ", "") + nameResult = string.gsub(nameResult, "-", "") + nameResult = string.lower(nameResult) + nameResult = nameResult:gsub("^%l", string.upper) + uiGenText.input_string = nameResult end -- Name sex slider update. function outgame:procUpdateNameSexLabel() local nameSexType = { "uiCP_Sex_Male", "uiCP_Sex_Female" } - local uiNameSexText = getUI("ui:outgame:appear_name:name_sex_slider:name_sex"); - local uiNameSex = getDbProp("UI:TEMP:NAME_SEX"); + local uiNameSexText = getUI("ui:outgame:appear_name:name_sex_slider:name_sex") + local uiNameSex = getDbProp("UI:TEMP:NAME_SEX") - tempstr = tostring(i18n.get(nameSexType[tonumber(uiNameSex)])); - tempstr = string.lower(tempstr); - tempstr = (tempstr:gsub("^%l", string.upper)); + tempstr = tostring(i18n.get(nameSexType[tonumber(uiNameSex)])) + tempstr = string.lower(tempstr) + tempstr = (tempstr:gsub("^%l", string.upper)) - uiNameSexText.hardtext = tempstr; + uiNameSexText.hardtext = tempstr end -- Name race slider update. function outgame:procUpdateNameRaceLabel() local nameRaceType = { "Fyros", "Matis", "Tryker", "Zoraï", "uiCP_Maraudeur" } - local uiNameRaceText = getUI("ui:outgame:appear_name:name_race_slider:name_race"); - local dbNameRace = getDbProp("UI:TEMP:NAME_RACE"); + local uiNameRaceText = getUI("ui:outgame:appear_name:name_race_slider:name_race") + local dbNameRace = getDbProp("UI:TEMP:NAME_RACE") - local uiNameSexSlider = getUI("ui:outgame:appear_name:name_sex_slider"); + local uiNameSexSlider = getUI("ui:outgame:appear_name:name_sex_slider") - local uiNameSubRaceFirstNameSlider = getUI("ui:outgame:appear_name:name_sub_race_first_name_slider"); - local uiNameSubRaceLastNameSlider = getUI("ui:outgame:appear_name:name_sub_race_last_name_slider"); + local uiNameSubRaceFirstNameSlider = getUI("ui:outgame:appear_name:name_sub_race_first_name_slider") + local uiNameSubRaceLastNameSlider = getUI("ui:outgame:appear_name:name_sub_race_last_name_slider") - local uiNameGenerate = getUI("ui:outgame:appear_name:generate"); + local uiNameGenerate = getUI("ui:outgame:appear_name:generate") -- Show/Hide sex slider uiNameGenerate.y = "-50" if tonumber(dbNameRace) == 2 then - uiNameSexSlider.active = true; + uiNameSexSlider.active = true uiNameGenerate.y = "-65" else - uiNameSexSlider.active = false; + uiNameSexSlider.active = false end -- Show/Hide sub race slider if tonumber(dbNameRace) == 5 then - uiNameSubRaceFirstNameSlider.active = true; - uiNameSubRaceLastNameSlider.active = true; + uiNameSubRaceFirstNameSlider.active = true + uiNameSubRaceLastNameSlider.active = true uiNameGenerate.y = "-105" else - uiNameSubRaceFirstNameSlider.active = false; - uiNameSubRaceLastNameSlider.active = false; + uiNameSubRaceFirstNameSlider.active = false + uiNameSubRaceLastNameSlider.active = false end - uiNameRaceText.hardtext = tostring(nameRaceType[tonumber(dbNameRace)]); + uiNameRaceText.hardtext = tostring(nameRaceType[tonumber(dbNameRace)]) end -local matisF = "Matis " .. (string.lower(tostring(i18n.get("uiCP_Sex_Female")) )):gsub("^%l", string.upper); -local matisM = "Matis " .. (string.lower(tostring(i18n.get("uiCP_Sex_Male")) )):gsub("^%l", string.upper); +local matisF = "Matis " .. (string.lower(tostring(i18n.get("uiCP_Sex_Female")) )):gsub("^%l", string.upper) +local matisM = "Matis " .. (string.lower(tostring(i18n.get("uiCP_Sex_Male")) )):gsub("^%l", string.upper) function outgame:procUpdateNameSubRaceFirstNameLabel() local nameSubRaceFirstNameType = { "Fyros", matisM, matisF, "Tryker", "Zoraï" } - local uiNameSubRaceFirstNameText = getUI("ui:outgame:appear_name:name_sub_race_first_name_slider:name_race"); - local dbNameSubRaceFirstName = getDbProp("UI:TEMP:NAME_SUB_RACE_FIRST_NAME"); + local uiNameSubRaceFirstNameText = getUI("ui:outgame:appear_name:name_sub_race_first_name_slider:name_race") + local dbNameSubRaceFirstName = getDbProp("UI:TEMP:NAME_SUB_RACE_FIRST_NAME") - uiNameSubRaceFirstNameText.hardtext= tostring(nameSubRaceFirstNameType[tonumber(dbNameSubRaceFirstName)]); + uiNameSubRaceFirstNameText.hardtext= tostring(nameSubRaceFirstNameType[tonumber(dbNameSubRaceFirstName)]) end function outgame:procUpdateNameSubRaceLastNameLabel() local nameSubRaceLastNameType = { "Fyros", "Matis", "Tryker", "Zoraï" } - local uiNameSubRaceLastNameText = getUI("ui:outgame:appear_name:name_sub_race_last_name_slider:name_race"); - local dbNameSubRaceLastName = getDbProp("UI:TEMP:NAME_SUB_RACE_LAST_NAME"); + local uiNameSubRaceLastNameText = getUI("ui:outgame:appear_name:name_sub_race_last_name_slider:name_race") + local dbNameSubRaceLastName = getDbProp("UI:TEMP:NAME_SUB_RACE_LAST_NAME") - uiNameSubRaceLastNameText.hardtext= tostring(nameSubRaceLastNameType[tonumber(dbNameSubRaceLastName)]); + uiNameSubRaceLastNameText.hardtext= tostring(nameSubRaceLastNameType[tonumber(dbNameSubRaceLastName)]) end ------------------------------------------------------------------------------------------------------------ -- called to construct icons function outgame:activePackElement(id, icon) - local uiDesc = getUI("ui:outgame:appear:job_options:options:desc"); - uiDesc['ico' .. tostring(id)].active= true; - uiDesc['ico' .. tostring(id)].texture= icon; - uiDesc['ico' .. tostring(id) .. 'txt'].active= true; + local uiDesc = getUI("ui:outgame:appear:job_options:options:desc") + uiDesc['ico' .. tostring(id)].active = true + uiDesc['ico' .. tostring(id)].texture = icon + uiDesc['ico' .. tostring(id) .. 'txt'].active = true end @@ -261,13 +260,13 @@ end -- called to construct pack text function outgame:setPackJobText(id, spec) -- Set Pack content - local uiPackText = getUI("ui:outgame:appear:job_options:options:desc:pack_" .. id); - uiPackText.hardtext= "uiCP_Job_" .. id .. tostring(spec); + local uiPackText = getUI("ui:outgame:appear:job_options:options:desc:pack_" .. id) + uiPackText.hardtext= "uiCP_Job_" .. id .. tostring(spec) -- Set specialization text - local uiResText = getUI("ui:outgame:appear:job_options:options:result:res"); + local uiResText = getUI("ui:outgame:appear:job_options:options:result:res") if(spec==2) then - uiResText.hardtext= "uiCP_Res_" .. id; + uiResText.hardtext= "uiCP_Res_" .. id end end @@ -275,63 +274,63 @@ end -- called to construct pack function outgame:buildActionPack() - local uiDesc = getUI("ui:outgame:appear:job_options:options:desc"); + local uiDesc = getUI("ui:outgame:appear:job_options:options:desc") if (uiDesc==nil) then - return; + return end -- Reset All for i = 1,20 do - uiDesc['ico' .. tostring(i)].active= false; - uiDesc['ico' .. tostring(i) .. 'txt'].active= false; + uiDesc['ico' .. tostring(i)].active = false + uiDesc['ico' .. tostring(i) .. 'txt'].active = false end -- Build Default Combat - self:activePackElement(1, 'f1.tga'); -- Dagger - self:activePackElement(2, 'f2.tga'); -- Accurate Attack + self:activePackElement(1, 'f1.tga') -- Dagger + self:activePackElement(2, 'f2.tga') -- Accurate Attack -- Build Default Magic - self:activePackElement(6, 'm2.tga'); -- Gloves - self:activePackElement(7, 'm1.tga'); -- Acid + self:activePackElement(6, 'm2.tga') -- Gloves + self:activePackElement(7, 'm1.tga') -- Acid -- Build Default Forage - self:activePackElement(11, 'g1.tga'); -- Forage Tool - self:activePackElement(12, 'g2.tga'); -- Basic Extract + self:activePackElement(11, 'g1.tga') -- Forage Tool + self:activePackElement(12, 'g2.tga') -- Basic Extract -- Build Default Craft - self:activePackElement(16, 'c2.tga'); -- Craft Tool - self:activePackElement(17, 'c1.tga'); -- 50 raw mat - self:activePackElement(18, 'c3.tga'); -- Craft Root - self:activePackElement(19, 'c4.tga'); -- Boots Plan + self:activePackElement(16, 'c2.tga') -- Craft Tool + self:activePackElement(17, 'c1.tga') -- 50 raw mat + self:activePackElement(18, 'c3.tga') -- Craft Root + self:activePackElement(19, 'c4.tga') -- Boots Plan -- Build Option if (getDbProp('UI:TEMP:JOB_FIGHT') == 2) then - self:activePackElement(3, 'f3.tga'); -- Increase damage + self:activePackElement(3, 'f3.tga') -- Increase damage elseif (getDbProp('UI:TEMP:JOB_MAGIC') == 2) then - self:activePackElement(8, 'm5.tga'); -- Fear + self:activePackElement(8, 'm5.tga') -- Fear elseif (getDbProp('UI:TEMP:JOB_FORAGE') == 2) then - self:activePackElement(13, 'g3.tga'); -- Basic Prospection + self:activePackElement(13, 'g3.tga') -- Basic Prospection elseif (getDbProp('UI:TEMP:JOB_CRAFT') == 2) then - self:activePackElement(20, 'c6.tga'); -- Gloves Plan - self:activePackElement(17, 'c5.tga'); -- Replace 17, with 100x RawMat + self:activePackElement(20, 'c6.tga') -- Gloves Plan + self:activePackElement(17, 'c5.tga') -- Replace 17, with 100x RawMat end -- Reset Text - self:setPackJobText('F', 1); - self:setPackJobText('M', 1); - self:setPackJobText('G', 1); - self:setPackJobText('C', 1); + self:setPackJobText('F', 1) + self:setPackJobText('M', 1) + self:setPackJobText('G', 1) + self:setPackJobText('C', 1) -- Set correct text for specalized version if (getDbProp('UI:TEMP:JOB_FIGHT') == 2) then - self:setPackJobText('F', 2); + self:setPackJobText('F', 2) elseif (getDbProp('UI:TEMP:JOB_MAGIC') == 2) then - self:setPackJobText('M', 2); + self:setPackJobText('M', 2) elseif (getDbProp('UI:TEMP:JOB_FORAGE') == 2) then - self:setPackJobText('G', 2); + self:setPackJobText('G', 2) elseif (getDbProp('UI:TEMP:JOB_CRAFT') == 2) then - self:setPackJobText('C', 2); + self:setPackJobText('C', 2) end end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/reset.xml b/code/ryzom/client/data/gamedev/interfaces_v3/reset.xml index 1d7e0c66d..8c14f2567 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/reset.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/reset.xml @@ -91,7 +91,11 @@ - + + + + + @@ -470,4 +474,4 @@ - \ No newline at end of file + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/ring_access_point_filter.lua b/code/ryzom/client/data/gamedev/interfaces_v3/ring_access_point_filter.lua index aa1b7b7cc..44a0451d7 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/ring_access_point_filter.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/ring_access_point_filter.lua @@ -109,7 +109,7 @@ function game.RingAccessPointFilter:validate() if config.Local == 1 then ucUrl = ucstring(NicoMagicURL) -- for test in local mode else - ucUrl = getDynString(game.NpcWebPage.UrlTextId); + ucUrl = getDynString(game.NpcWebPage.UrlTextId) end debugInfo(tostring(ucUrl)) local utf8Url = ucUrl:toUtf8() diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.lua b/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.lua index 7ac4c68dd..9dc6035fb 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.lua @@ -2,39 +2,39 @@ ------------------------------------------------------------------------------------------------------------ -- create the game namespace without reseting if already created in an other file. if (game==nil) then - game= {}; + game = {} end ------------------------------------------------------------------------------------------------------------ -- function game:getMilkoTooltipWithKey(prop, tooltip, tooltip_pushed, name, param) - local tt; + local tt -- Check if button is toggled and choose the good tooltip if (prop ~= '' and tooltip_pushed ~= '') then - local db = getDbProp(prop); + local db = getDbProp(prop) if (db == 1) then - tt = tooltip_pushed; + tt = tooltip_pushed else - tt = tooltip; + tt = tooltip end else tt = tooltip; end -- Get key shortcut - local text = i18n.get(tt); - local key = runExpr('getKey(\'' .. name .. '\',\'' .. param .. '\',1)'); + local text = i18n.get(tt) + local key = runExpr('getKey(\'' .. name .. '\',\'' .. param .. '\',1)') if (key ~= nil and key ~= '') then - key = ' @{2F2F}(' .. key .. ')'; - text = concatUCString(text, key); + key = ' @{2F2F}(' .. key .. ')' + text = concatUCString(text, key) end - setContextHelpText(text); + setContextHelpText(text) end function game:taskbarDisableTooltip(ui) - local uiGroup = getUI(ui); - disableContextHelpForControl(uiGroup); + local uiGroup = getUI(ui) + disableContextHelpForControl(uiGroup) end \ No newline at end of file diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml b/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml index 0c42103f3..e497f25e3 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml @@ -1091,7 +1091,10 @@ - + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/webbrowser.lua b/code/ryzom/client/data/gamedev/interfaces_v3/webbrowser.lua new file mode 100644 index 000000000..f51d7a9da --- /dev/null +++ b/code/ryzom/client/data/gamedev/interfaces_v3/webbrowser.lua @@ -0,0 +1,161 @@ + +-- global +WebBrowser = { + template = "webig_browser", + apps = {} +} + +function WebBrowser:openWindow(id, url) + -- default value if url is not set + url = url or "http://app.ryzom.com/" + + local newWindow = false + local app = self:findAppById(id) + + if not app then + app = {} + app.id = id + app.title = "" + app.url = url + -- getUI() object + app.uiWindow = nil + app.winid = "ui:interface:" .. id + app.winw = 780 + app.winh = 500 + app.minimized = true + app.activeUrl = "" + + table.insert(self.apps, app) + end + + if not app.uiWindow then + -- if there is window present (eg, 'webig'), then reuse it + app.uiWindow = getUI(app.winid, false) + if not app.uiWindow then + app.uiWindow = createRootGroupInstance(self.template, app.id, { + x = 0, y = 0, w = app.winw, h = app.winh, home = app.url, + browse_redo = "ui:interface:" .. app.id .. ":browser:header_opened:browse_redo", + browse_undo = "ui:interface:" .. app.id .. ":browser:header_opened:browse_undo", + browse_refresh = "ui:interface:" .. app.id .. ":browser:header_opened:browse_refresh" + }) + if not app.uiWindow then + return + end + app.uiWindow:center() + end + + newWindow = true + end + + app.activeUrl = url + + -- trigger on_open event + if not app.uiWindow.opened then + app.uiWindow.opened = true + end + + -- trigger on_active event + if not app.uiWindow.active then + app.uiWindow.active = true + end + + local html = app.uiWindow:find("html") + html:browse(url) + + setTopWindow(app.uiWindow) +end + +function WebBrowser:findAppById(id) + for k,app in pairs(self.apps) do + if app.id == id then + return app + end + end + return nil +end + +function WebBrowser:findAppFromUiCaller() + -- id = app123 + local id = getUICaller().id:match("ui:interface:([^:]*):?") + local app = self:findAppById(id) + if app then + return app + end +end + +function WebBrowser:onActive() + if app then + self:restoreWindow(app) + end +end + +function WebBrowser:onClickHeaderClose() + local app = self:findAppFromUiCaller() + if app then + self:saveWindow(app) + end +end + +function WebBrowser:onClickHeaderOpen() + local app = self:findAppFromUiCaller() + if app then + self:restoreWindow(app) + end +end + +-- save current window dimension and minimize window +function WebBrowser:saveWindow(app) + app.minimized = true + app.winw = app.uiWindow.w + app.winh = app.uiWindow.h + -- minimize + app.uiWindow.w = 150 + app.uiWindow.h = 0 +end + +function WebBrowser:restoreWindow(app) + if app.minimized then + app.uiWindow.w = app.winw + app.uiWindow.h = app.winh + app.minimized = false + end +end + +function WebBrowser:onClickRedo() + -- caller is :header_opened:browse_redo + local uiWindow = getUICaller().parent.parent + local html = uiWindow:find("html") + if html ~= nil then + runAH(nil, "browse_redo", "name=" .. html.id) + end +end + +function WebBrowser:onClickUndo() + -- caller is :header_opened:browse_undo + local uiWindow = getUICaller().parent.parent + + local html = uiWindow:find("html") + if html ~= nil then + runAH(nil, "browse_undo", "name=" .. html.id) + end +end + +function WebBrowser:onClickRefresh() + -- caller is :header_opened:browse_refresh + local uiWindow = getUICaller().parent.parent + + local html = uiWindow:find("html") + if html ~= nil then + html:refresh() + end +end + +function WebBrowser:onClickHome() + -- caller is :header_opened:browse_home + local uiWindow = getUICaller().parent.parent + + local html = uiWindow:find("html") + if html ~= nil then + html:browse("home") + end +end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/webig.lua b/code/ryzom/client/data/gamedev/interfaces_v3/webig.lua index 9b88c02f7..516cc62d7 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/webig.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/webig.lua @@ -180,7 +180,7 @@ function webig:doRemoveDbSheetQuantity(sheet_list, ctrl) end end ---assert(nil, "RELOADABLE SCRIPT"); +--assert(nil, "RELOADABLE SCRIPT") diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml index 10431b84c..b806edb8d 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml @@ -6927,7 +6927,203 @@ - + + + + + + +