From bc3572462299f72e92bb4ad08615846ab7ad9f23 Mon Sep 17 00:00:00 2001 From: Inky Date: Tue, 8 Jan 2019 02:33:18 +0100 Subject: [PATCH 1/4] Added: Inventory filter for animals --HG-- branch : develop --- .../src/interface_v3/inventory_manager.cpp | 18 ++++++++++++++++-- .../src/interface_v3/inventory_manager.h | 12 ++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index 0d23e19ec..5f9ff2d3b 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -2003,6 +2003,9 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */) prop = xmlGetProp (cur, (xmlChar*)"filter_tool"); if (prop) DbFilterTool = NLGUI::CDBManager::getInstance()->getDbProp(prop.str()); + prop = xmlGetProp (cur, (xmlChar*)"filter_pet"); + if (prop) DbFilterPet = NLGUI::CDBManager::getInstance()->getDbProp(prop.str()); + prop = xmlGetProp (cur, (xmlChar*)"filter_mp"); if (prop) DbFilterMP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str()); @@ -2079,6 +2082,13 @@ bool SBagOptions::isSomethingChanged() LastDbFilterTool = (DbFilterTool->getValue8() != 0); } + if (DbFilterPet != NULL) + if ((DbFilterPet->getValue8() != 0) != LastDbFilterPet) + { + bRet = true; + LastDbFilterPet = (DbFilterPet->getValue8() != 0); + } + if (DbFilterMP != NULL) if ((DbFilterMP->getValue8() != 0) != LastDbFilterMP) { @@ -2117,6 +2127,7 @@ bool SBagOptions::canDisplay(CDBCtrlSheet *pCS) const bool bFilterArmor = getFilterArmor(); bool bFilterWeapon = getFilterWeapon(); bool bFilterTool = getFilterTool(); + bool bFilterPet = getFilterPet(); bool bFilterMP = getFilterMP(); bool bFilterMissMP = getFilterMissMP(); bool bFilterTP = getFilterTP(); @@ -2168,10 +2179,13 @@ bool SBagOptions::canDisplay(CDBCtrlSheet *pCS) const (pIS->Family == ITEMFAMILY::HARVEST_TOOL) || (pIS->Family == ITEMFAMILY::TAMING_TOOL) || (pIS->Family == ITEMFAMILY::TRAINING_TOOL) || - (pIS->Family == ITEMFAMILY::BAG) || - (pIS->Family == ITEMFAMILY::PET_ANIMAL_TICKET) ) + (pIS->Family == ITEMFAMILY::BAG)) if (!bFilterTool) bDisplay = false; + // Pet + if (pIS->Family == ITEMFAMILY::PET_ANIMAL_TICKET) + if (!bFilterPet) bDisplay = false; + // MP if ((pIS->Family == ITEMFAMILY::RAW_MATERIAL) && pIS->canBuildSomeItemPart()) if (!bFilterMP) bDisplay = false; diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.h b/code/ryzom/client/src/interface_v3/inventory_manager.h index d1c5dbe8c..364874f36 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.h +++ b/code/ryzom/client/src/interface_v3/inventory_manager.h @@ -509,6 +509,7 @@ struct SBagOptions NLMISC::CCDBNodeLeaf *DbFilterArmor; NLMISC::CCDBNodeLeaf *DbFilterWeapon; NLMISC::CCDBNodeLeaf *DbFilterTool; + NLMISC::CCDBNodeLeaf *DbFilterPet; NLMISC::CCDBNodeLeaf *DbFilterMP; NLMISC::CCDBNodeLeaf *DbFilterMissMP; NLMISC::CCDBNodeLeaf *DbFilterTP; @@ -516,6 +517,7 @@ struct SBagOptions bool LastDbFilterArmor; bool LastDbFilterWeapon; bool LastDbFilterTool; + bool LastDbFilterPet; bool LastDbFilterMP; bool LastDbFilterMissMP; bool LastDbFilterTP; @@ -529,8 +531,8 @@ struct SBagOptions SBagOptions() { InvType = CInventoryManager::InvUnknown; - DbFilterArmor = DbFilterWeapon = DbFilterTool = DbFilterMP = DbFilterMissMP = DbFilterTP = NULL; - LastDbFilterArmor = LastDbFilterWeapon = LastDbFilterTool = LastDbFilterMP = LastDbFilterMissMP = LastDbFilterTP = false; + DbFilterArmor = DbFilterWeapon = DbFilterTool = DbFilterPet = DbFilterMP = DbFilterMissMP = DbFilterTP = NULL; + LastDbFilterArmor = LastDbFilterWeapon = LastDbFilterTool = LastDbFilterPet = LastDbFilterMP = LastDbFilterMissMP = LastDbFilterTP = false; SearchFilterChanged = false; SearchQualityMin = 0; SearchQualityMax = 999; @@ -561,6 +563,12 @@ struct SBagOptions return (DbFilterTool->getValue8()!=0); } + bool getFilterPet() const + { + if (DbFilterPet == NULL) return true; + return (DbFilterPet->getValue8()!=0); + } + bool getFilterMP() const { if (DbFilterMP == NULL) return true; From dda8a36ee275c91415f3b345a601cd3f535e97a8 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 8 Jan 2019 11:31:50 +0200 Subject: [PATCH 2/4] Changed: Allow to set custom sizing chars for text --HG-- branch : develop --- code/nel/include/nel/gui/view_text.h | 6 +++ code/nel/src/gui/view_text.cpp | 69 ++++++++++++++++++++++------ 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index aa1d83330..b9ef7211c 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -100,6 +100,9 @@ namespace NLGUI void setMultiMaxLine(uint l) { _MultiMaxLine = l; } void setMultiMinLine(uint l) { _MultiMinLine = l; } + // Override chars used to compute font size + void setFontSizing(const std::string &chars, const std::string &fallback); + // Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF void enableStringSelection(uint start, uint end); void disableStringSelection(); @@ -244,6 +247,9 @@ namespace NLGUI bool _Oblique; // width of the font in pixel. Just a Hint for tabing format (computed with '_') float _FontWidth; + // strings to use when computing font size + ucstring _FontSizingChars; + ucstring _FontSizingFallback; // height of the font in pixel. // use getFontHeight float _FontHeight; diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 8d36c046d..03dd52701 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -97,7 +97,6 @@ namespace NLGUI _InvalidTextContext= true; _FirstLineX = 0; - computeFontSize (); _SingleLineTextClamped= false; _OverExtendViewText= false; @@ -110,6 +109,14 @@ namespace NLGUI _LetterColors = NULL; _Setuped= false; _AutoClampOffset = 0; + + // Letter size + // - "_" that should be the character with the lowest part + // - A with an accent for the highest part + _FontSizingChars.fromUtf8("_\xc3\x84"); + // fallback if SizingChars are not supported by font + _FontSizingFallback.fromUtf8("|"); + computeFontSize (); } // *************************************************************************** @@ -370,6 +377,16 @@ namespace NLGUI { return toString( _ContinuousUpdate ); } + else + if ( name == "sizing_chars" ) + { + return _FontSizingChars.toUtf8(); + } + else + if ( name == "sizing_fallback" ) + { + return _FontSizingFallback.toUtf8(); + } else return ""; } @@ -615,6 +632,18 @@ namespace NLGUI return true; } + else + if( name == "sizing_chars" ) + { + _FontSizingChars.fromUtf8(value); + return true; + } + else + if( name == "sizing_fallback" ) + { + _FontSizingFallback.fromUtf8(value); + return true; + } else return false; } @@ -679,6 +708,8 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "clamp_right", BAD_CAST toString( _ClampRight ).c_str() ); xmlSetProp( node, BAD_CAST "auto_clamp_offset", BAD_CAST toString( _AutoClampOffset ).c_str() ); xmlSetProp( node, BAD_CAST "continuous_update", BAD_CAST toString( _ContinuousUpdate ).c_str() ); + xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST _FontSizingChars.toUtf8().c_str() ); + xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST _FontSizingFallback.toUtf8().c_str() ); return true; } @@ -854,6 +885,17 @@ namespace NLGUI _ContinuousUpdate = convertBool(prop); } + // "_Ä" lowest/highest chars (underscore, A+diaeresis) + _FontSizingChars.fromUtf8("_\xc3\x84"); + prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_chars" ); + if (prop) + _FontSizingChars.fromUtf8((const char*)prop); + + // fallback if SizingChars are not supported by font + _FontSizingFallback.fromUtf8("|"); + prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_fallback" ); + if (prop) + _FontSizingFallback.fromUtf8((const char*)prop); computeFontSize (); } @@ -1325,6 +1367,15 @@ namespace NLGUI _FormatTags.clear(); } + // *************************************************************************** + void CViewText::setFontSizing(const std::string &chars, const std::string &fallback) + { + _FontSizingChars.clear(); + _FontSizingChars.fromUtf8(chars); + _FontSizingFallback.clear(); + _FontSizingFallback.fromUtf8(fallback); + } + // *************************************************************************** void CViewText::setFontName(const std::string &name) { @@ -2856,22 +2907,14 @@ namespace NLGUI TextContext->setOblique (_Oblique); // Letter size - ucstring chars; - // instead of using the height of "|" that depends on font, - // we're using 2 characters: - // - "_" that should be the character with the lowest part - // - A with an accent for the highest part - chars.fromUtf8("_\xc3\x84"); - - // for now we can't know that directly from UTextContext - UTextContext::CStringInfo si = TextContext->getStringInfo(chars); + UTextContext::CStringInfo si = TextContext->getStringInfo(_FontSizingChars); // font generator changes unknown glyphs to dot '.'. use fallback if it looks odd if (_FontSize > (si.StringHeight + si.StringLine)) { - chars.fromUtf8("|"); - si = TextContext->getStringInfo(chars); + si = TextContext->getStringInfo(_FontSizingFallback); } + // add a padding of 1 pixel else the top will be truncated _FontHeight = si.StringHeight + 1; _FontLegHeight = si.StringLine; @@ -2880,7 +2923,7 @@ namespace NLGUI si = TextContext->getStringInfo(ucstring(" ")); _SpaceWidth = si.StringWidth; - // Font Width + // Font Width (used for ) si = TextContext->getStringInfo(ucstring("_")); _FontWidth = si.StringWidth; } From 8b69d673be7ff09d9ca21298ebe9a17585830b21 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 8 Jan 2019 11:32:01 +0200 Subject: [PATCH 3/4] Changed: Allow to set font size without adding global font size coef --HG-- branch : develop --- code/nel/include/nel/gui/view_text.h | 3 +- code/nel/src/gui/view_text.cpp | 61 +++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index b9ef7211c..5fe86dee5 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -82,7 +82,7 @@ namespace NLGUI void setText (const ucstring &text); void setFontName (const std::string &name); - void setFontSize (sint nFontSize); + void setFontSize (sint nFontSize, bool coef = true); void setEmbolden (bool nEmbolden); void setOblique (bool nOblique); void setColor (const NLMISC::CRGBA &color); @@ -243,6 +243,7 @@ namespace NLGUI std::string _FontName; /// the font size sint _FontSize; + bool _FontSizeCoef; bool _Embolden; bool _Oblique; // width of the font in pixel. Just a Hint for tabing format (computed with '_') diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 03dd52701..e991d8170 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -65,6 +65,7 @@ namespace NLGUI _FontSize = 12 + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); + _FontSizeCoef = true; _FontName.clear(); _Embolden = false; _Oblique = false; @@ -141,6 +142,7 @@ namespace NLGUI setupDefault (); _FontSize = FontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + _FontSizeCoef = true; _Color = Color; _Shadow = Shadow; _ShadowOutline = ShadowOutline; @@ -185,6 +187,7 @@ namespace NLGUI _PosRef = vt._PosRef; _FontSize = vt._FontSize; + _FontSizeCoef = vt._FontSizeCoef; _Embolden = vt._Embolden; _Oblique = vt._Oblique; _Underlined = vt._Underlined; @@ -248,9 +251,15 @@ namespace NLGUI else if( name == "fontsize" ) { - return toString( - _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32() - ); + if (_FontSizeCoef) + return toString(_FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32()); + + return toString(_FontSize); + } + else + if ( name == "fontsize_coef" ) + { + return toString(_FontSizeCoef); } else if( name == "fontweight" ) @@ -425,6 +434,22 @@ namespace NLGUI return true; } else + if( name == "fontsize_coef" ) + { + bool b; + bool oldValue = _FontSizeCoef; + if (fromString( value, b) ) + _FontSizeCoef = b; + // must only change font size when current state changes + if (_FontSizeCoef != oldValue) + { + if (_FontSizeCoef) + _FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); + else + _FontSize -= CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); + } + } + else if( name == "fontweight" ) { if (value == "bold") @@ -653,10 +678,11 @@ namespace NLGUI { xmlSetProp( node, BAD_CAST "color", BAD_CAST toString( _Color ).c_str() ); xmlSetProp( node, BAD_CAST "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() ); - xmlSetProp( node, BAD_CAST "fontsize", - BAD_CAST toString( - _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32() - ).c_str() ); + + sint32 fontSize = _FontSize; + if (_FontSizeCoef) fontSize -= CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); + xmlSetProp( node, BAD_CAST "fontsize", BAD_CAST toString(fontSize).c_str() ); + xmlSetProp( node, BAD_CAST "fontsize_coef", BAD_CAST toString(_FontSizeCoef).c_str() ); std::string fontweight("normal"); if (_Embolden) @@ -755,6 +781,16 @@ namespace NLGUI _FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); } + prop = (char*) xmlGetProp( cur, (xmlChar*)"fontsize_coef" ); + _FontSizeCoef = true; + if (prop) + { + _FontSizeCoef = convertBool(prop); + if (!_FontSizeCoef) + _FontSize -= CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"fontweight" ); _Embolden = false; if (prop) @@ -1395,9 +1431,11 @@ namespace NLGUI } // *************************************************************************** - void CViewText::setFontSize (sint nFontSize) + void CViewText::setFontSize (sint nFontSize, bool coef) { - _FontSize = nFontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + _FontSize = nFontSize; + if (coef) _FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + _FontSizeCoef = coef; computeFontSize (); invalidateContent(); } @@ -1405,7 +1443,10 @@ namespace NLGUI // *************************************************************************** sint CViewText::getFontSize() const { - return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + if (_FontSizeCoef) + return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + + return _FontSize; } // *************************************************************************** From a7b931353c356bb09b597bd0bf5857a5fc37e43d Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 8 Jan 2019 11:39:02 +0200 Subject: [PATCH 4/4] Changed: Fixes for client local/debug mode --HG-- branch : develop --- .../ryzom/client/src/interface_v3/action_handler_game.cpp | 4 ++-- code/ryzom/client/src/interface_v3/group_html_webig.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 836a4df28..c5faa16d9 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -4238,7 +4238,7 @@ public: string fileName = getParam(sParams, "music"); // don't play if db is in init stage - if (IngameDbMngr.initInProgress()) return; + if (!ClientCfg.Local && IngameDbMngr.initInProgress()) return; if(SoundMngr) SoundMngr->playEventMusic(fileName, xFade, loop); @@ -4260,7 +4260,7 @@ public: string fileName= getParam(sParams, "music"); // don't play if db is in init stage - if (IngameDbMngr.initInProgress()) return; + if (!ClientCfg.Local && IngameDbMngr.initInProgress()) return; if(SoundMngr) SoundMngr->stopEventMusic(fileName, xFade); diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.cpp b/code/ryzom/client/src/interface_v3/group_html_webig.cpp index fe2fa5229..66cfecdad 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -54,7 +54,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowseHome, "browse_home"); static string getWebAuthKey() { - if(!UserEntity) return ""; + if(!UserEntity || !NetMngr.getLoginCookie().isValid()) return ""; // authkey = uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; @@ -83,7 +83,7 @@ void addWebIGParams (string &url, bool trustedDomain) { url += string("&cid=") + toString(cid) + string("&authkey=") + getWebAuthKey(); - + if (url.find('$') != string::npos) { strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender())); @@ -304,6 +304,8 @@ CGroupHTMLAuth::~CGroupHTMLAuth() void CGroupHTMLAuth::addHTTPGetParams (string &url, bool trustedDomain) { + if(!UserEntity || !NetMngr.getLoginCookie().isValid()) return; + addWebIGParams(url, trustedDomain); } @@ -311,7 +313,7 @@ void CGroupHTMLAuth::addHTTPGetParams (string &url, bool trustedDomain) void CGroupHTMLAuth::addHTTPPostParams (SFormFields &formfields, bool trustedDomain) { - if(!UserEntity) return; + if(!UserEntity || !NetMngr.getLoginCookie().isValid()) return; uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; formfields.add("shardid", toString(CharacterHomeSessionId));