diff --git a/CMakeLists.txt b/CMakeLists.txt index 96efcd0e8..bb3e1352e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,20 @@ IF(WITH_STATIC) IF(LIBLZMA_LIBRARIES) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES}) ENDIF() + + # under Linux and OS X, recent libxml2 versions are linked against libicu + # FIND_PACKAGE(Icu) + FIND_LIBRARY(ICU_LIBRARY icuuc) + IF(ICU_LIBRARY) + FIND_LIBRARY(ICU_DATA_LIBRARY icudata) + IF(ICU_LIBRARY) + MESSAGE(STATUS "ICU UC was found: ${ICU_LIBRARY}") + ELSE() + MESSAGE(STATUS "ICU UC was NOT found") + ENDIF() + SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICU_DATA_LIBRARY} ${ICU_LIBRARY}) + ENDIF() + ENDIF() ENDIF() diff --git a/nel/include/nel/gui/ctrl_scroll.h b/nel/include/nel/gui/ctrl_scroll.h index 76827dd29..4052e6cea 100644 --- a/nel/include/nel/gui/ctrl_scroll.h +++ b/nel/include/nel/gui/ctrl_scroll.h @@ -177,6 +177,7 @@ namespace NLGUI bool _MouseDown : 1; bool _CallingAH : 1; bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button + bool _Keyboard : 1; bool _Frozen : 1; bool _Scale : 1; diff --git a/nel/src/gui/ctrl_scroll.cpp b/nel/src/gui/ctrl_scroll.cpp index b40498186..d9191e770 100644 --- a/nel/src/gui/ctrl_scroll.cpp +++ b/nel/src/gui/ctrl_scroll.cpp @@ -57,6 +57,7 @@ namespace NLGUI _MouseDown = false; _CallingAH = false; _Cancelable = false; + _Keyboard = false; _Target = NULL; _Inverted = false; _IsDBLink = false; @@ -225,6 +226,11 @@ namespace NLGUI return toString( _Cancelable ); } else + if( name == "keyboard" ) + { + return toString( _Keyboard ); + } + else if( name == "frozen" ) { return toString( _Frozen ); @@ -405,6 +411,14 @@ namespace NLGUI return; } else + if( name == "keyboard" ) + { + bool b; + if( fromString( value, b ) ) + _Keyboard = b; + return; + } + else if( name == "frozen" ) { bool b; @@ -474,6 +488,7 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "target_stepy", BAD_CAST toString( _TargetStepY ).c_str() ); xmlSetProp( node, BAD_CAST "step_value", BAD_CAST toString( _StepValue ).c_str() ); xmlSetProp( node, BAD_CAST "cancelable", BAD_CAST toString( _Cancelable ).c_str() ); + xmlSetProp( node, BAD_CAST "keyboard", BAD_CAST toString( _Keyboard ).c_str() ); xmlSetProp( node, BAD_CAST "frozen", BAD_CAST toString( _Frozen ).c_str() ); return node; @@ -589,6 +604,9 @@ namespace NLGUI prop = (char*) xmlGetProp( node, (xmlChar*)"cancelable" ); if (prop) _Cancelable = convertBool(prop); + prop = (char*) xmlGetProp( node, (xmlChar*)"keyboard" ); + if (prop) _Keyboard = convertBool(prop); + prop= (char*) xmlGetProp (node, (xmlChar*)"frozen"); _Frozen = false; if (prop) @@ -912,6 +930,30 @@ namespace NLGUI return true; } } + else if (event.getType() == NLGUI::CEventDescriptor::key) + { + const NLGUI::CEventDescriptorKey &eventDesc = (const NLGUI::CEventDescriptorKey &)event; + + if (eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keydown) + { + if (_Keyboard) + { + sint32 i = 0; + // direction + if (eventDesc.getKey() == KeyNEXT) i++; + else if (eventDesc.getKey() == KeyPRIOR) i--; + else + return false; + + if (_Vertical) + moveTrackY(-(i * _TargetStepY)); + else + moveTrackX(-(i * _TargetStepX)); + + return true; + } + } + } return false; } diff --git a/nel/src/gui/widget_manager.cpp b/nel/src/gui/widget_manager.cpp index 685cf7540..34656eac5 100644 --- a/nel/src/gui/widget_manager.cpp +++ b/nel/src/gui/widget_manager.cpp @@ -2312,7 +2312,7 @@ namespace NLGUI // Hide menu if the key is pushed // if ((eventDesc.getKeyEventType() == CEventDescriptorKey::keydown) && !_ModalStack.empty() && !eventDesc.getKeyAlt() && !eventDesc.getKeyCtrl() && !eventDesc.getKeyShift()) // Hide menu (or popup menu) is ESCAPE pressed - if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyESCAPE ) + if( eventDesc.getKeyEventType() == CEventDescriptorKey::keydown && eventDesc.getKey() == NLMISC::KeyESCAPE ) { if( hasModal() ) { @@ -2323,7 +2323,7 @@ namespace NLGUI } // Manage "quit window" If the Key is ESCAPE, no captureKeyboard - if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyESCAPE ) + if( eventDesc.getKeyEventType() == CEventDescriptorKey::keydown && eventDesc.getKey() == NLMISC::KeyESCAPE ) { // Get the last escapable active top window. NB: this is ergonomically better. CInterfaceGroup *win= getLastEscapableTopWindow(); diff --git a/ryzom/client/src/commands.cpp b/ryzom/client/src/commands.cpp index e64796b28..d756c938c 100644 --- a/ryzom/client/src/commands.cpp +++ b/ryzom/client/src/commands.cpp @@ -1344,7 +1344,7 @@ NLMISC_COMMAND(db, "Modify Database"," ") else pIM->displaySystemInfo(toString("DB '%s' does not exist.", args[0].c_str())); #else - pIM->displaySystemInfo(ucstring("Can't write to DB when in Final Version.")); + pIM->displaySystemInfo("Can't write to DB when in Final Version."); #endif } else if (size == 1) diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index 332931b07..9e1fcf51d 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -157,9 +157,11 @@ std::string RingEditorKeySet = "keys_r2ed.xml"; string ScenarioFileName; sint LoginCharsel = -1; -static const char *KeySetVarName = "BuiltInKeySets"; +std::string ImportCharacter; +static const char *KeySetVarName = "BuiltInKeySets"; +#define GROUP_LIST_CHARACTER "ui:outgame:charsel_import:import_list" #define GROUP_LIST_MAINLAND "ui:outgame:appear_mainland:mainland_list" #define GROUP_LIST_KEYSET "ui:outgame:appear_keyset:keyset_list" vector Mainlands; @@ -2136,7 +2138,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); + //CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND)); if (pList == NULL) @@ -2215,7 +2217,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); + //CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND)); pList->clearGroups(); } @@ -2456,7 +2458,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); + //CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); pList->clearGroups(); } @@ -3433,3 +3435,239 @@ class CAHOpenRingSessions : public IActionHandler } }; REGISTER_ACTION_HANDLER (CAHOpenRingSessions, "open_ring_sessions"); + +// *************************************************************************** +class CAHInitImportCharacter : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + { + CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CHARACTER)); + if (!list) + { + nlwarning("element " GROUP_LIST_CHARACTER " not found probably bad outgame.xml"); + return; + } + + // retrieve saved files + std::vector savedCharacters; + CPath::getPathContent("save/", false, false, true, savedCharacters); + + CInterfaceGroup *newLine; + CInterfaceGroup *prevLine; + + for (uint i = 0; i < savedCharacters.size(); ++i) + { + // search saved characters only + if (testWildCard(CFile::getFilename(savedCharacters[i]), "character_*.save")) + { + const std::string id = CFile::getFilenameWithoutExtension(savedCharacters[i]).substr(strlen("character_")); + if (id.empty()) + continue; + + std::vector> params; + params.clear(); + params.push_back(std::pair("id", id)); + // adjust ref + if (list->getNumGroup() > 0) + params.push_back(std::pair("posref", "BL TL")); + + newLine = CWidgetManager::getInstance()->getParser()->createGroupInstance("t_import", GROUP_LIST_CHARACTER, params); + if (newLine) + { + CViewText *text = dynamic_cast(newLine->getView("name")); + if (text) + text->setText(ucstring(savedCharacters[i])); + + // first button is pushed + CCtrlButton *button = dynamic_cast(newLine->getCtrl("but")); + if (button && list->getNumGroup() == 0) + button->setPushed(true); + + // add to the list now + newLine->setParent(list); + newLine->setParentSize(list); + newLine->setParentPos(prevLine); + + list->addGroup(newLine); + + prevLine = newLine; + } + } + } + // none case + if (list->getNumGroup() == 0) + CLuaManager::getInstance().executeLuaScript("outgame:procCharselNotifaction(3)"); + + list->invalidateCoords(); + } +}; +REGISTER_ACTION_HANDLER( CAHInitImportCharacter, "import_char_init" ); + +// *************************************************************************** +class CAHResetImportCharacter : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + { + CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CHARACTER)); + if (list) + list->clearGroups(); + + if (!ImportCharacter.empty()) + ImportCharacter = ""; + } +}; +REGISTER_ACTION_HANDLER( CAHResetImportCharacter, "import_char_reset" ); + +// *************************************************************************** +class CAHSelectImportCharacter : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const std::string &Params) + { + struct CUnpush : public CInterfaceElementVisitor + { + CCtrlBase *Ref; + virtual void visitCtrl(CCtrlBase *ctrl) + { + if (ctrl == Ref) return; + CCtrlBaseButton *but = dynamic_cast(ctrl); + if (but) + { + but->setPushed(false); + } + } + }; + CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CHARACTER)); + if (!list) + return; + + // unselect + if (Params.empty()) + { + CUnpush unpusher; + unpusher.Ref = pCaller; + list->visit(&unpusher); + } + + // now select + std::string name; + if (Params.empty()) + { + CCtrlButton *pCB = dynamic_cast(pCaller); + if (!pCB) + return; + + std::string id = pCB->getId(); + id = id.substr(0, id.rfind(':')); + + if (!fromString(id.substr(id.rfind(':')+1, id.size()), name)) + return; + + pCB->setPushed(true); + } + else + if (!fromString(Params, name)) + return; + + ImportCharacter = ""; + // check filename and store + if (CFile::fileExists(toString("save/character_%s.save", name.c_str()))) + ImportCharacter = name; + } +}; +REGISTER_ACTION_HANDLER( CAHSelectImportCharacter, "import_char_select" ); + +// *************************************************************************** +class CAHImportCharacter : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + { + if (ImportCharacter.empty()) + return; + + if (!CFile::fileExists(toString("save/character_%s.save", ImportCharacter.c_str()))) + return; + + bool success = false; + + CIFile fd; + CCharacterSummary CS; + // use temporary file until close() + if (fd.open(toString("save/character_%s.save", ImportCharacter.c_str()))) + { + try + { + CS.serial(fd); + SCharacter3DSetup::setupDBFromCharacterSummary("UI:TEMP:CHAR3D", CS); + + // validate import + CDBManager::getInstance()->getDbProp("UI:TEMP:IMPORT")->setValue32(1); + success = true; + } + catch (const EStream &e) + { + nlwarning(e.what()); + } + fd.close(); + } + else + nlwarning("Failed to open file: save/character_%s.save", ImportCharacter.c_str()); + + // user notification + if (!success) + CLuaManager::getInstance().executeLuaScript("outgame:procCharselNotifaction(2)"); + else + CAHManager::getInstance()->runActionHandler("proc", NULL, "proc_charsel_create_new"); + } +}; +REGISTER_ACTION_HANDLER( CAHImportCharacter, "import_char" ); + +// *************************************************************************** +class CAHExportCharacter : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) + { + if (Params.empty()) + return; + + sint32 slot = -1; + if (!fromString(getParam(Params, "slot"), slot)) + return; + + if (slot >= CharacterSummaries.size() || slot < 0) + return; + + // retrieve infos + CCharacterSummary &CS = CharacterSummaries[slot]; + if (CS.Name.empty()) + return; + + // extract name + const std::string name = buildPlayerNameForSaveFile(CS.Name.toString()); + + COFile fd; + bool success = false; + // use temporary file until close() + if (fd.open(toString("save/character_%s.save", name.c_str()), false, false, true)) + { + try + { + fd.serial(CS); + fd.flush(); + // validate + success = true; + } + catch (const EStream &e) + { + nlwarning(e.what()); + } + fd.close(); + } + else + nlwarning("Failed to open file: save/character_%s.save", name.c_str()); + + const uint8 val = (success == true) ? 0 : 1; + // user notification + CLuaManager::getInstance().executeLuaScript(toString("outgame:procCharselNotifaction(%i)", val)); + } +}; +REGISTER_ACTION_HANDLER( CAHExportCharacter, "export_char" ); diff --git a/ryzom/client/src/events_listener.cpp b/ryzom/client/src/events_listener.cpp index 879bd5a2a..cfa9d2b3c 100644 --- a/ryzom/client/src/events_listener.cpp +++ b/ryzom/client/src/events_listener.cpp @@ -172,16 +172,12 @@ void CEventsListener::operator()(const CEvent& event) // Get in pixel space, centered uint32 drW, drH; Driver->getWindowSize(drW, drH); - float fX = mouseEvent->X; // from 0 to 1.0 - float fY = (ClientCfg.FreeLookInverted ? -mouseEvent->Y : mouseEvent->Y); - sint scX = (sint32)(fX * (float)drW) - ((sint32)drW >> 1); // in pixels, centered - sint scY = (sint32)(fY * (float)drH) - ((sint32)drH >> 1); + sint scX = (sint32)(mouseEvent->X * (float)drW) - ((sint32)drW >> 1); // in pixels, centered + sint scY = (sint32)(mouseEvent->Y * (float)drH) - ((sint32)drH >> 1); if (!s_MouseFreeLookReady) { - float pfX = _MouseX; - float pfY = (ClientCfg.FreeLookInverted ? -_MouseY : _MouseY); - sint pscX = (sint32)(pfX * (float)drW) - ((sint32)drW >> 1); // in pixels, centered - sint pscY = (sint32)(pfY * (float)drH) - ((sint32)drH >> 1); + sint pscX = (sint32)(_MouseX * (float)drW) - ((sint32)drW >> 1); // in pixels, centered + sint pscY = (sint32)(_MouseY * (float)drH) - ((sint32)drH >> 1); s_MouseFreeLookReady = true; s_MouseFreeLookLastX = pscX; s_MouseFreeLookLastY = pscY; @@ -199,13 +195,12 @@ void CEventsListener::operator()(const CEvent& event) } // Get delta since last center - sint scXd = scX - s_MouseFreeLookLastX; - sint scYd = scY - s_MouseFreeLookLastY; + s_MouseFreeLookFrameX += (scX - s_MouseFreeLookLastX); + s_MouseFreeLookFrameY += (scY - s_MouseFreeLookLastY) * (ClientCfg.FreeLookInverted ? -1 : 1); + s_MouseFreeLookLastX = scX; s_MouseFreeLookLastY = scY; - s_MouseFreeLookFrameX += scXd; - s_MouseFreeLookFrameY += scYd; // updateFreeLookPos is called in updateMouseSmoothing per frame // Center cursor diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index bee955ba4..a78c94681 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -75,11 +75,20 @@ void CCompassTarget::serial(NLMISC::IStream &f) } } f.serialCheck(NELID("CTAR")); - f.serialVersion(0); + sint version = f.serialVersion(1); f.serial(Pos); // for the name, try to save a string identifier if possible, because language may be changed between // save & reload - f.serial(Name); + if (version < 1) + { + ucstring name; // Serial old version + f.serial(name); + Name = name.toUtf8(); + } + else + { + f.serial(Name); + } std::string language = toLower(ClientCfg.LanguageCode); f.serial(language); f.serialEnum(_Type);