Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
Nimetu 6 years ago
commit 5e42d09482

@ -82,7 +82,7 @@ namespace NLGUI
void setText (const ucstring &text); void setText (const ucstring &text);
void setFontName (const std::string &name); void setFontName (const std::string &name);
void setFontSize (sint nFontSize); void setFontSize (sint nFontSize, bool coef = true);
void setEmbolden (bool nEmbolden); void setEmbolden (bool nEmbolden);
void setOblique (bool nOblique); void setOblique (bool nOblique);
void setColor (const NLMISC::CRGBA &color); void setColor (const NLMISC::CRGBA &color);
@ -100,6 +100,9 @@ namespace NLGUI
void setMultiMaxLine(uint l) { _MultiMaxLine = l; } void setMultiMaxLine(uint l) { _MultiMaxLine = l; }
void setMultiMinLine(uint l) { _MultiMinLine = 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 // Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF
void enableStringSelection(uint start, uint end); void enableStringSelection(uint start, uint end);
void disableStringSelection(); void disableStringSelection();
@ -240,10 +243,14 @@ namespace NLGUI
std::string _FontName; std::string _FontName;
/// the font size /// the font size
sint _FontSize; sint _FontSize;
bool _FontSizeCoef;
bool _Embolden; bool _Embolden;
bool _Oblique; bool _Oblique;
// width of the font in pixel. Just a Hint for tabing format (computed with '_') // width of the font in pixel. Just a Hint for tabing format (computed with '_')
float _FontWidth; float _FontWidth;
// strings to use when computing font size
ucstring _FontSizingChars;
ucstring _FontSizingFallback;
// height of the font in pixel. // height of the font in pixel.
// use getFontHeight // use getFontHeight
float _FontHeight; float _FontHeight;

@ -65,6 +65,7 @@ namespace NLGUI
_FontSize = 12 + _FontSize = 12 +
CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32();
_FontSizeCoef = true;
_FontName.clear(); _FontName.clear();
_Embolden = false; _Embolden = false;
_Oblique = false; _Oblique = false;
@ -97,7 +98,6 @@ namespace NLGUI
_InvalidTextContext= true; _InvalidTextContext= true;
_FirstLineX = 0; _FirstLineX = 0;
computeFontSize ();
_SingleLineTextClamped= false; _SingleLineTextClamped= false;
_OverExtendViewText= false; _OverExtendViewText= false;
@ -110,6 +110,14 @@ namespace NLGUI
_LetterColors = NULL; _LetterColors = NULL;
_Setuped= false; _Setuped= false;
_AutoClampOffset = 0; _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 ();
} }
// *************************************************************************** // ***************************************************************************
@ -134,6 +142,7 @@ namespace NLGUI
setupDefault (); setupDefault ();
_FontSize = FontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); _FontSize = FontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32();
_FontSizeCoef = true;
_Color = Color; _Color = Color;
_Shadow = Shadow; _Shadow = Shadow;
_ShadowOutline = ShadowOutline; _ShadowOutline = ShadowOutline;
@ -178,6 +187,7 @@ namespace NLGUI
_PosRef = vt._PosRef; _PosRef = vt._PosRef;
_FontSize = vt._FontSize; _FontSize = vt._FontSize;
_FontSizeCoef = vt._FontSizeCoef;
_Embolden = vt._Embolden; _Embolden = vt._Embolden;
_Oblique = vt._Oblique; _Oblique = vt._Oblique;
_Underlined = vt._Underlined; _Underlined = vt._Underlined;
@ -241,9 +251,15 @@ namespace NLGUI
else else
if( name == "fontsize" ) if( name == "fontsize" )
{ {
return toString( if (_FontSizeCoef)
_FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32() return toString(_FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32());
);
return toString(_FontSize);
}
else
if ( name == "fontsize_coef" )
{
return toString(_FontSizeCoef);
} }
else else
if( name == "fontweight" ) if( name == "fontweight" )
@ -370,6 +386,16 @@ namespace NLGUI
{ {
return toString( _ContinuousUpdate ); return toString( _ContinuousUpdate );
} }
else
if ( name == "sizing_chars" )
{
return _FontSizingChars.toUtf8();
}
else
if ( name == "sizing_fallback" )
{
return _FontSizingFallback.toUtf8();
}
else else
return ""; return "";
} }
@ -408,6 +434,22 @@ namespace NLGUI
return true; return true;
} }
else 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( name == "fontweight" )
{ {
if (value == "bold") if (value == "bold")
@ -615,6 +657,18 @@ namespace NLGUI
return true; return true;
} }
else
if( name == "sizing_chars" )
{
_FontSizingChars.fromUtf8(value);
return true;
}
else
if( name == "sizing_fallback" )
{
_FontSizingFallback.fromUtf8(value);
return true;
}
else else
return false; return false;
} }
@ -624,10 +678,11 @@ namespace NLGUI
{ {
xmlSetProp( node, BAD_CAST "color", BAD_CAST toString( _Color ).c_str() ); 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 "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() );
xmlSetProp( node, BAD_CAST "fontsize",
BAD_CAST toString( sint32 fontSize = _FontSize;
_FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32() if (_FontSizeCoef) fontSize -= CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32();
).c_str() ); 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"); std::string fontweight("normal");
if (_Embolden) if (_Embolden)
@ -679,6 +734,8 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "clamp_right", BAD_CAST toString( _ClampRight ).c_str() ); 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 "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 "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; return true;
} }
@ -724,6 +781,16 @@ namespace NLGUI
_FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); _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" ); prop = (char*) xmlGetProp( cur, (xmlChar*)"fontweight" );
_Embolden = false; _Embolden = false;
if (prop) if (prop)
@ -854,6 +921,17 @@ namespace NLGUI
_ContinuousUpdate = convertBool(prop); _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 (); computeFontSize ();
} }
@ -1328,6 +1406,15 @@ namespace NLGUI
_FormatTags.clear(); _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) void CViewText::setFontName(const std::string &name)
{ {
@ -1347,9 +1434,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 (); computeFontSize ();
invalidateContent(); invalidateContent();
} }
@ -1357,7 +1446,10 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
sint CViewText::getFontSize() const sint CViewText::getFontSize() const
{ {
return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); if (_FontSizeCoef)
return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32();
return _FontSize;
} }
// *************************************************************************** // ***************************************************************************
@ -2859,22 +2951,14 @@ namespace NLGUI
TextContext->setOblique (_Oblique); TextContext->setOblique (_Oblique);
// Letter size // Letter size
ucstring chars; UTextContext::CStringInfo si = TextContext->getStringInfo(_FontSizingChars);
// 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);
// font generator changes unknown glyphs to dot '.'. use fallback if it looks odd // font generator changes unknown glyphs to dot '.'. use fallback if it looks odd
if (_FontSize > (si.StringHeight + si.StringLine)) if (_FontSize > (si.StringHeight + si.StringLine))
{ {
chars.fromUtf8("|"); si = TextContext->getStringInfo(_FontSizingFallback);
si = TextContext->getStringInfo(chars);
} }
// add a padding of 1 pixel else the top will be truncated // add a padding of 1 pixel else the top will be truncated
_FontHeight = si.StringHeight + 1; _FontHeight = si.StringHeight + 1;
_FontLegHeight = si.StringLine; _FontLegHeight = si.StringLine;
@ -2883,7 +2967,7 @@ namespace NLGUI
si = TextContext->getStringInfo(ucstring(" ")); si = TextContext->getStringInfo(ucstring(" "));
_SpaceWidth = si.StringWidth; _SpaceWidth = si.StringWidth;
// Font Width // Font Width (used for <tab>)
si = TextContext->getStringInfo(ucstring("_")); si = TextContext->getStringInfo(ucstring("_"));
_FontWidth = si.StringWidth; _FontWidth = si.StringWidth;
} }

@ -4239,7 +4239,7 @@ public:
string fileName = getParam(sParams, "music"); string fileName = getParam(sParams, "music");
// don't play if db is in init stage // don't play if db is in init stage
if (IngameDbMngr.initInProgress()) return; if (!ClientCfg.Local && IngameDbMngr.initInProgress()) return;
if(SoundMngr) if(SoundMngr)
SoundMngr->playEventMusic(fileName, xFade, loop); SoundMngr->playEventMusic(fileName, xFade, loop);
@ -4261,7 +4261,7 @@ public:
string fileName= getParam(sParams, "music"); string fileName= getParam(sParams, "music");
// don't play if db is in init stage // don't play if db is in init stage
if (IngameDbMngr.initInProgress()) return; if (!ClientCfg.Local && IngameDbMngr.initInProgress()) return;
if(SoundMngr) if(SoundMngr)
SoundMngr->stopEventMusic(fileName, xFade); SoundMngr->stopEventMusic(fileName, xFade);

@ -54,7 +54,7 @@ REGISTER_ACTION_HANDLER( CHandlerBrowseHome, "browse_home");
static string getWebAuthKey() static string getWebAuthKey()
{ {
if(!UserEntity) return ""; if(!UserEntity || !NetMngr.getLoginCookie().isValid()) return "";
// authkey = <sharid><name><cid><cookie> // authkey = <sharid><name><cid><cookie>
uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot;
@ -83,7 +83,7 @@ void addWebIGParams (string &url, bool trustedDomain)
{ {
url += string("&cid=") + toString(cid) + url += string("&cid=") + toString(cid) +
string("&authkey=") + getWebAuthKey(); string("&authkey=") + getWebAuthKey();
if (url.find('$') != string::npos) if (url.find('$') != string::npos)
{ {
strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender())); strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender()));
@ -304,6 +304,8 @@ CGroupHTMLAuth::~CGroupHTMLAuth()
void CGroupHTMLAuth::addHTTPGetParams (string &url, bool trustedDomain) void CGroupHTMLAuth::addHTTPGetParams (string &url, bool trustedDomain)
{ {
if(!UserEntity || !NetMngr.getLoginCookie().isValid()) return;
addWebIGParams(url, trustedDomain); addWebIGParams(url, trustedDomain);
} }
@ -311,7 +313,7 @@ void CGroupHTMLAuth::addHTTPGetParams (string &url, bool trustedDomain)
void CGroupHTMLAuth::addHTTPPostParams (SFormFields &formfields, 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; uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot;
formfields.add("shardid", toString(CharacterHomeSessionId)); formfields.add("shardid", toString(CharacterHomeSessionId));

@ -2021,6 +2021,9 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */)
prop = xmlGetProp (cur, (xmlChar*)"filter_tool"); prop = xmlGetProp (cur, (xmlChar*)"filter_tool");
if (prop) DbFilterTool = NLGUI::CDBManager::getInstance()->getDbProp(prop.str()); 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"); prop = xmlGetProp (cur, (xmlChar*)"filter_mp");
if (prop) DbFilterMP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str()); if (prop) DbFilterMP = NLGUI::CDBManager::getInstance()->getDbProp(prop.str());
@ -2097,6 +2100,13 @@ bool SBagOptions::isSomethingChanged()
LastDbFilterTool = (DbFilterTool->getValue8() != 0); LastDbFilterTool = (DbFilterTool->getValue8() != 0);
} }
if (DbFilterPet != NULL)
if ((DbFilterPet->getValue8() != 0) != LastDbFilterPet)
{
bRet = true;
LastDbFilterPet = (DbFilterPet->getValue8() != 0);
}
if (DbFilterMP != NULL) if (DbFilterMP != NULL)
if ((DbFilterMP->getValue8() != 0) != LastDbFilterMP) if ((DbFilterMP->getValue8() != 0) != LastDbFilterMP)
{ {
@ -2135,6 +2145,7 @@ bool SBagOptions::canDisplay(CDBCtrlSheet *pCS) const
bool bFilterArmor = getFilterArmor(); bool bFilterArmor = getFilterArmor();
bool bFilterWeapon = getFilterWeapon(); bool bFilterWeapon = getFilterWeapon();
bool bFilterTool = getFilterTool(); bool bFilterTool = getFilterTool();
bool bFilterPet = getFilterPet();
bool bFilterMP = getFilterMP(); bool bFilterMP = getFilterMP();
bool bFilterMissMP = getFilterMissMP(); bool bFilterMissMP = getFilterMissMP();
bool bFilterTP = getFilterTP(); bool bFilterTP = getFilterTP();
@ -2186,10 +2197,13 @@ bool SBagOptions::canDisplay(CDBCtrlSheet *pCS) const
(pIS->Family == ITEMFAMILY::HARVEST_TOOL) || (pIS->Family == ITEMFAMILY::HARVEST_TOOL) ||
(pIS->Family == ITEMFAMILY::TAMING_TOOL) || (pIS->Family == ITEMFAMILY::TAMING_TOOL) ||
(pIS->Family == ITEMFAMILY::TRAINING_TOOL) || (pIS->Family == ITEMFAMILY::TRAINING_TOOL) ||
(pIS->Family == ITEMFAMILY::BAG) || (pIS->Family == ITEMFAMILY::BAG))
(pIS->Family == ITEMFAMILY::PET_ANIMAL_TICKET) )
if (!bFilterTool) bDisplay = false; if (!bFilterTool) bDisplay = false;
// Pet
if (pIS->Family == ITEMFAMILY::PET_ANIMAL_TICKET)
if (!bFilterPet) bDisplay = false;
// MP // MP
if ((pIS->Family == ITEMFAMILY::RAW_MATERIAL) && pIS->canBuildSomeItemPart()) if ((pIS->Family == ITEMFAMILY::RAW_MATERIAL) && pIS->canBuildSomeItemPart())
if (!bFilterMP) bDisplay = false; if (!bFilterMP) bDisplay = false;

@ -509,6 +509,7 @@ struct SBagOptions
NLMISC::CCDBNodeLeaf *DbFilterArmor; NLMISC::CCDBNodeLeaf *DbFilterArmor;
NLMISC::CCDBNodeLeaf *DbFilterWeapon; NLMISC::CCDBNodeLeaf *DbFilterWeapon;
NLMISC::CCDBNodeLeaf *DbFilterTool; NLMISC::CCDBNodeLeaf *DbFilterTool;
NLMISC::CCDBNodeLeaf *DbFilterPet;
NLMISC::CCDBNodeLeaf *DbFilterMP; NLMISC::CCDBNodeLeaf *DbFilterMP;
NLMISC::CCDBNodeLeaf *DbFilterMissMP; NLMISC::CCDBNodeLeaf *DbFilterMissMP;
NLMISC::CCDBNodeLeaf *DbFilterTP; NLMISC::CCDBNodeLeaf *DbFilterTP;
@ -516,6 +517,7 @@ struct SBagOptions
bool LastDbFilterArmor; bool LastDbFilterArmor;
bool LastDbFilterWeapon; bool LastDbFilterWeapon;
bool LastDbFilterTool; bool LastDbFilterTool;
bool LastDbFilterPet;
bool LastDbFilterMP; bool LastDbFilterMP;
bool LastDbFilterMissMP; bool LastDbFilterMissMP;
bool LastDbFilterTP; bool LastDbFilterTP;
@ -529,8 +531,8 @@ struct SBagOptions
SBagOptions() SBagOptions()
{ {
InvType = CInventoryManager::InvUnknown; InvType = CInventoryManager::InvUnknown;
DbFilterArmor = DbFilterWeapon = DbFilterTool = DbFilterMP = DbFilterMissMP = DbFilterTP = NULL; DbFilterArmor = DbFilterWeapon = DbFilterTool = DbFilterPet = DbFilterMP = DbFilterMissMP = DbFilterTP = NULL;
LastDbFilterArmor = LastDbFilterWeapon = LastDbFilterTool = LastDbFilterMP = LastDbFilterMissMP = LastDbFilterTP = false; LastDbFilterArmor = LastDbFilterWeapon = LastDbFilterTool = LastDbFilterPet = LastDbFilterMP = LastDbFilterMissMP = LastDbFilterTP = false;
SearchFilterChanged = false; SearchFilterChanged = false;
SearchQualityMin = 0; SearchQualityMin = 0;
SearchQualityMax = 999; SearchQualityMax = 999;
@ -561,6 +563,12 @@ struct SBagOptions
return (DbFilterTool->getValue8()!=0); return (DbFilterTool->getValue8()!=0);
} }
bool getFilterPet() const
{
if (DbFilterPet == NULL) return true;
return (DbFilterPet->getValue8()!=0);
}
bool getFilterMP() const bool getFilterMP() const
{ {
if (DbFilterMP == NULL) return true; if (DbFilterMP == NULL) return true;

Loading…
Cancel
Save