Merge branch 'atys' into ryzom/ark/features

ryzom/ark/features
Ulukyn 5 years ago
commit b9d1cf26b7

@ -31,7 +31,7 @@ namespace NLGUI
class CViewBitmap;
class CGroupList;
class CGroupMenu;
class CGroupSubMenu;
/**
* CViewTextMenu is an element of a sub menu
@ -50,7 +50,6 @@ namespace NLGUI
_Checked = false;
_Checkable = false;
_CheckBox = NULL;
_ParentMenu = NULL;
Over = false;
}
@ -61,8 +60,6 @@ namespace NLGUI
bool getCheckable() const { return _Checkable; }
void setCheckable(bool c);
void setCheckBox(CViewBitmap *checkBox) { _CheckBox = checkBox; }
void setParentMenu(CGroupSubMenu *parentMenu) { _ParentMenu = parentMenu; };
void setActive (bool g);
CViewBitmap * getCheckBox() const { return _CheckBox; }
bool getFormatted () const { return getMultiLine (); }
@ -89,7 +86,6 @@ namespace NLGUI
bool _Grayed;
bool _Checked;
bool _Checkable;
CGroupSubMenu *_ParentMenu;
};
/**

@ -114,19 +114,6 @@ namespace NLGUI
OldShadowColorGrayed.A = OldColorGrayed.A = (uint8)a;
}
// ------------------------------------------------------------------------------------------------
void CViewTextMenu::setActive (bool state)
{
if (_ParentMenu)
_ParentMenu->setActive(state);
if (_Active != state)
{
_Active = state;
invalidateCoords();
}
}
// ------------------------------------------------------------------------------------------------
// CGroupSubMenu
// ------------------------------------------------------------------------------------------------
@ -303,9 +290,6 @@ namespace NLGUI
if (cond) strCond = (const char*)cond;
CXMLAutoPtr params((const char*) xmlGetProp (cur, (xmlChar*)"params"));
if (params) strParams = (const char*)params;
CXMLAutoPtr icon((const char*) xmlGetProp (cur, (xmlChar*)"icon"));
if (icon)
strTexture = (const char*)icon;
CXMLAutoPtr strCheckable((const char*) xmlGetProp (cur, (xmlChar*)"checkable"));
bool bCheckable = false;
if (strCheckable) bCheckable = convertBool (strCheckable);
@ -391,6 +375,23 @@ namespace NLGUI
if (pUG)
setUserGroupRight((uint)_Lines.size()-1, pUG, true);
}
// usergroup from simple icon
CXMLAutoPtr icon((const char*) xmlGetProp (cur, (xmlChar*)"icon"));
if (icon)
{
typedef std::pair<std::string, std::string> TTmplParams;
std::vector<TTmplParams> vparams;
uint lineIndex = _Lines.size()-1;
vparams.push_back(TTmplParams("id", toString("icon%d", lineIndex)));
vparams.push_back(TTmplParams("sizeref", ""));
vparams.push_back(TTmplParams("icon_texture", (const char*)icon));
//vparams.push_back(TTmplParams("icon_color", options.ColorNormal.toString()));
string lineId = toString("%s:icon", pV->getId().c_str());
CInterfaceGroup *pUG = CWidgetManager::getInstance()->getParser()->createGroupInstance("menu_row_icon", lineId, vparams);
if (pUG)
setUserGroupLeft((uint)_Lines.size()-1, pUG, true);
}
}
cur = cur->next;
}
@ -409,11 +410,11 @@ namespace NLGUI
pVB->setSerializable( false );
pVB->setParent (this);
pVB->setParentPos (parentPos);
pVB->setParentPosRef (Hotspot_BL);
pVB->setPosRef (Hotspot_BR);
pVB->setParentPosRef (Hotspot_ML);
pVB->setPosRef (Hotspot_MR);
pVB->setTexture(texture);
pVB->setModulateGlobalColor(false);
pVB->setX (MENU_WIDGET_X);
pVB->setX (-2);
addView (pVB);
return pVB;
}
@ -583,8 +584,6 @@ namespace NLGUI
CGroupFrame::updateCoords();
bool mustUpdate = false;
if (_MaxVisibleLine > 0 && sint32(_Lines.size())>_MaxVisibleLine)
{
for(k = 0; k < _Lines.size(); ++k)
@ -592,14 +591,11 @@ namespace NLGUI
{
// compute max height of widgets on the left of text
sint32 widgetMaxH = 0;
if (_Lines[k].ViewText->getActive())
{
if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal();
if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal());
if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal());
if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal());
widgetMaxH = std::max(widgetMaxH, _Lines[k].ViewText->getHReal());
}
if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal();
if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal());
if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal());
if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal());
widgetMaxH = std::max(widgetMaxH, _Lines[k].ViewText->getHReal());
_GroupList->setMaxH(widgetMaxH*_MaxVisibleLine+_GroupList->getSpace()*(_MaxVisibleLine-1));
if (_ScrollBar == NULL)
{
@ -618,7 +614,6 @@ namespace NLGUI
_SelectionView->setW (-8-8-2);
_ScrollBar->setSerializable( false );
addCtrl(_ScrollBar);
mustUpdate = true;
}
break;
}
@ -642,54 +637,39 @@ namespace NLGUI
{
// compute max height of widgets on the left of text
sint32 widgetMaxH = 0;
sint32 textHReal = 0;
if (_Lines[k].ViewText->getActive())
{
if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal();
if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal());
if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal());
if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal());
textHReal = _Lines[k].ViewText->getHReal();
}
_Lines[k].HReal = max(widgetMaxH, textHReal);
_Lines[k].TextDY = textDYPos;
if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal();
if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal());
if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal());
if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal());
sint32 textHReal= _Lines[k].ViewText->getHReal();
_Lines[k].HReal= max(widgetMaxH, textHReal);
_Lines[k].TextDY= textDYPos;
if(widgetMaxH>textHReal)
_Lines[k].TextDY += (widgetMaxH-textHReal) / 2;
_Lines[k].TextDY+= (widgetMaxH-textHReal) / 2;
}
}
// *** Update Text Positions
// sint32 currX = 0;
sint32 maxTextW = 0;
for(k = 0; k < _Lines.size(); ++k)
{
if (_Lines[k].ViewText)
{
// Setup Y
_Lines[k].ViewText->setY(_Lines[k].TextDY);
maxTextW = max(maxTextW, _Lines[k].ViewText->getW());
}
}
if (mustUpdate)
{
CGroupFrame::updateCoords();
}
CGroupFrame::updateCoords();
// *** Setup SubMenus and CheckBoxes Positions
sint32 maxViewW = 0;
for (i = 1; i < _Views.size(); ++i)
{
CViewBitmap *pVB = dynamic_cast<CViewBitmap *>(_Views[i]);
if (pVB == NULL) continue;
if (pVB->getId() == ID_MENU_SUBMENU)
{
// Look for the next line of the menu that contains a sub menu
@ -1252,7 +1232,7 @@ namespace NLGUI
pV->setCaseMode(_GroupMenu->getCaseMode());
if (formatted)
{
pV->setMultiLine (true);
pV->setMultiLine (true);
pV->setMultiLineMaxWOnly (true);
pV->setTextFormatTaged (name);
}
@ -1278,7 +1258,6 @@ namespace NLGUI
_GroupList->addChild (pV);
CViewBitmap *checkBox = NULL;
CViewBitmap *icon = NULL;
if (checkable)
{
@ -1287,6 +1266,15 @@ namespace NLGUI
pV->setCheckBox(checkBox);
}
CViewBitmap *icon = NULL;
if (!texture.empty())
{
if (_GroupList->getNumChildren() == 1)
pV->setX(20);
icon = createIcon(pV, texture);
}
tmp.ViewText = pV;
tmp.Separator = NULL;
tmp.AHName = ah;
@ -1300,39 +1288,12 @@ namespace NLGUI
tmp.Id = id;
pV->setId(_GroupMenu->getId()+":"+tmp.Id);
{
typedef std::pair<std::string, std::string> TTmplParams;
std::vector<TTmplParams> vparams;
uint lineIndex = _Lines.size()-1;
vparams.push_back(TTmplParams("id", toString("icon%d", lineIndex)));
vparams.push_back(TTmplParams("sizeref", ""));
vparams.push_back(TTmplParams("icon_texture", texture));
//vparams.push_back(TTmplParams("icon_color", options.ColorNormal.toString()));
string lineId = toString("%s:icon", pV->getId().c_str());
CInterfaceGroup *pUGLeft = CWidgetManager::getInstance()->getParser()->createGroupInstance("menu_row_icon", lineId, vparams);
if (pUGLeft)
{
tmp.UserGroupLeft = pUGLeft;
tmp.UserGroupLeftOwnership = true;
addGroup(pUGLeft);
pUGLeft->setParent(this);
pUGLeft->setParentPos(this);
pUGLeft->setParentPosRef (Hotspot_BL);
pUGLeft->setPosRef (Hotspot_BL);
pUGLeft->setX(LEFT_MENU_WIDGET_X);
}
}
_Lines.push_back (tmp);
// Add an empty sub menu by default
_SubMenus.push_back (NULL);
_GroupMenu->invalidateCoords();
return pV;

@ -271,7 +271,6 @@ void CItemSheet::build(const NLGEORGES::UFormElm &item)
string IconText;
if(!item.getValueByName (IconText, "3d.text overlay"))
debug("key '3d.text overlay' not found.");
IconText = toLower(IconText);
IdIconText = ClientSheetsStrings.add(IconText);
// See if this item can be hiden when equipped

@ -131,7 +131,6 @@ void COutpostBuildingSheet::build(const NLGEORGES::UFormElm &root)
string IconText;
if(!root.getValueByName (IconText, "text overlay"))
debug("key 'text overlay' not found.");
IconText = toLower(IconText);
IdIconText = ClientSheetsStrings.add(IconText);
}

@ -1300,10 +1300,10 @@ void CDBCtrlSheet::setupItem ()
// special icon text
if( _NeedSetup || _ItemSheet->getIconText() != _OptString )
{
// compute from OptString. Allow only 1 line and 4 chars
// compute from OptString. Allow only 1 line (-2 for padding)
_OptString= _ItemSheet->getIconText();
// Display Top Left
setupCharBitmaps(40, 1, 6, true);
setupCharBitmaps(40-2, 1, true);
}
// Special Item requirement
@ -1417,8 +1417,8 @@ void CDBCtrlSheet::setupMacro()
{
if (!_NeedSetup) return;
// compute from OptString
setupCharBitmaps(26, 4, 5);
// compute from OptString (-2 for padding)
setupCharBitmaps(26-2, 4);
_NeedSetup = false;
@ -1720,8 +1720,8 @@ void CDBCtrlSheet::setupDisplayAsPhrase(const std::vector<NLMISC::CSheetId> &bri
{
// recompute text
_OptString= iconName;
// compute from OptString. Allow only 1 line and 5 chars
setupCharBitmaps(26, 1, 5);
// compute from OptString. Allow only 1 line (-2 for padding)
setupCharBitmaps(26-2, 1);
}
}
}
@ -1847,10 +1847,10 @@ void CDBCtrlSheet::setupOutpostBuilding()
// special icon text
if (pOBSheet->getIconText() != _OptString)
{
// compute from OptString. Allow only 1 line and 4 chars
// compute from OptString. Allow only 1 line, (-2 for padding)
_OptString= pOBSheet->getIconText();
// Display Top Left
setupCharBitmaps(40, 1, 6, true);
setupCharBitmaps(40-2, 1, true);
}
}
else
@ -1893,28 +1893,32 @@ void CDBCtrlSheet::resetCharBitmaps()
}
// ***************************************************************************
void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar, bool topDown)
void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, bool topDown)
{
// Use the optString for the Macro name
_OptString = toLower(_OptString);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance();
_CharBitmaps.clear();
if(maxLine<=0) return;
if(maxLine<=0)
return;
std::string text(_OptString);
// check for icon text 'uiitLabel'
if (text.size() > 4 && text[0] == 'u' && text[1] == 'i' && text[2] == 'i' && text[3] == 't' && CI18N::hasTranslation(text))
{
// NOTE: translated text is expected to be us-ascii only
text = CI18N::get(text).toUtf8();
}
text = toLower(text);
CViewRenderer &rVR = *CViewRenderer::getInstance();
uint h = rVR.getTypoTextureH('a');
sint lineNb = 0;
sint curLineSize = 0;
uint i;
uint xChar= 0;
for (i = 0; i < _OptString.size(); ++i)
for (i = 0; i < text.size(); ++i)
{
char c = _OptString[i];
char c = text[i];
sint32 w = rVR.getTypoTextureW(c);
if ((curLineSize + w) > maxW || (sint32)xChar>=maxWChar)
if ((curLineSize + w) > maxW)
{
lineNb ++;
if (lineNb == maxLine) break;

@ -815,7 +815,7 @@ private:
// remove enchant and buff markers from item icon
void clearIconBuffs();
void setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar= 1000, bool topDown= false);
void setupCharBitmaps(sint32 maxW, sint32 maxLine, bool topDown= false);
void resetCharBitmaps();
void displayCharBitmaps(sint32 rdrLayer, sint32 x, sint32 y, NLMISC::CRGBA color);

@ -437,6 +437,7 @@ CGroupMap::CGroupMap(const TCtorParam &param)
_HomeLM = NULL;
_LandmarkFilter.clear();
_MatchedLandmarks.clear();
_UserLandMarkVisible = true;
//
_ScaleMax = 8.f;
_ScaleMaxR2 = 8.f;
@ -2626,7 +2627,11 @@ void CGroupMap::createContinentLandMarks()
CLandMarkOptions options = getUserLandMarkOptions(k);
addLandMark(_UserLM, mapPos, _CurContinent->UserLandMarks[k].Title, options);
if (_LandmarkFilter.size() > 0)
if (!_UserLandMarkVisible)
{
_UserLM.back()->setActive(false);
}
else if (_LandmarkFilter.size() > 0)
{
if (filterLandmark(_CurContinent->UserLandMarks[k].Title))
{
@ -2700,7 +2705,7 @@ void CGroupMap::updateUserLandMarks()
addLandMark(_UserLM, mapPos, _CurContinent->UserLandMarks[k].Title, getUserLandMarkOptions(k));
// hide landmark if not matching filter
if (!filterLandmark(_CurContinent->UserLandMarks[k].Title))
if (!_UserLandMarkVisible || !filterLandmark(_CurContinent->UserLandMarks[k].Title))
_UserLM.back()->setActive(false);
}
invalidateCoords();
@ -2979,6 +2984,15 @@ CLandMarkOptions CGroupMap::getUserLandMarkOptions(uint32 lmindex) const
}
//============================================================================================================
void CGroupMap::setUserLandMarkVisible(bool state)
{
if (_UserLandMarkVisible != state)
{
_UserLandMarkVisible = state;
updateUserLandMarks();
}
}
//============================================================================================================
void CGroupMap::updatePlayerPos()
@ -3765,6 +3779,9 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC:
// no continent selected (ie world map view)
if (!_CurContinent) return;
// user markers not visible
if (!_UserLandMarkVisible) return;
// sort landmarks, keep indices
typedef std::pair<uint, float> TSortedDistPair;
std::vector<TSortedDistPair> sortedIndices;
@ -3926,9 +3943,9 @@ REGISTER_ACTION_HANDLER(CAHLandMarkSelected, "land_mark_selected");
// Remove a user landmark
class CAHRemoveUserLandMark : public IActionHandler
{
virtual void execute (CCtrlBase *pCaller, const string &/* params */)
virtual void execute (CCtrlBase * /* pCaller */, const string &/* params */)
{
CCtrlButton *button = dynamic_cast<CCtrlButton *>(pCaller);
CCtrlButton *button = dynamic_cast<CCtrlButton*>(CWidgetManager::getInstance()->getCtrlLaunchingModal());
if (!button) return;
CGroupMap *map = dynamic_cast<CGroupMap *>(button->getParent());
if (!map) return;
@ -3936,6 +3953,8 @@ class CAHRemoveUserLandMark : public IActionHandler
// close the rename window & create window
closeLandMarkNameDialog();
LastSelectedLandMark = NULL;
// close confirmation
CAHManager::getInstance()->runActionHandler("leave_modal", NULL);
}
};
REGISTER_ACTION_HANDLER(CAHRemoveUserLandMark, "remove_user_landmark");
@ -4315,6 +4334,33 @@ NLMISC_COMMAND( setMap, "Change the map", "" )
return true;
}
//=========================================================================================================
// toggle user landmarks visibility
// no arguments - toggle show/hide
// 0 - hide
// 1 - show (any non "0" value)
NLMISC_COMMAND( showHideUserLandMark, "Show/Hide user landmarks", "0|1")
{
const std::string mapId("ui:interface:map:content:map_content:actual_map");
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CGroupMap *map = dynamic_cast<CGroupMap*>(CWidgetManager::getInstance()->getElementFromId(mapId));
if (!map)
{
nlwarning("Unable to find map element '%s'", mapId.c_str());
return false;
}
bool state;
if (args.size() == 0)
state = !map->getUserLandMarkVisible();
else
state = !(args[0] == "0");
map->setUserLandMarkVisible(state);
return true;
}
////////////////////
// DEBUG COMMANDS //
////////////////////

@ -299,6 +299,10 @@ public:
void updateClosestLandMarkMenu(const std::string &menu, const NLMISC::CVector2f &pos) const;
// show/hide all user landmarks
void setUserLandMarkVisible(bool state);
bool getUserLandMarkVisible() const { return _UserLandMarkVisible; };
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
// A non rectangular button to click on zone of the map
@ -473,6 +477,9 @@ private:
// LANDMARKS //
///////////////
// if false, user landmarks are not drawn
bool _UserLandMarkVisible;
// landmarks of continent
TLandMarkButtonVect _ContinentLM;
TLandMarkTextVect _ContinentText;

Loading…
Cancel
Save