ADDED: #1471 Added new class CWidgetManager, and started to move code into it from CInterfaceManager.

This commit is contained in:
dfighter1985 2012-05-30 02:12:37 +02:00
parent 5b51fcfe84
commit f898ae6b38
20 changed files with 587 additions and 736 deletions

View file

@ -17,6 +17,17 @@
#ifndef INTERFACE_COMMON_H
#define INTERFACE_COMMON_H
enum WindowsPriority
{
WIN_PRIORITY_WORLD_SPACE = 0,
WIN_PRIORITY_LOWEST = 1,
WIN_PRIORITY_LOW = 2,
WIN_PRIORITY_NORMAL = 3,
WIN_PRIORITY_HIGH = 4,
WIN_PRIORITY_HIGHEST = 5,
WIN_PRIORITY_MAX = 8
};
enum THotSpot
{
Hotspot_BL = 36, // 100100,

View file

@ -81,7 +81,7 @@ void CGameContextMenu::init(const std::string &srcMenuId)
std::string menuId = srcMenuId.empty() ? std::string("game_context_menu") : srcMenuId;
CInterfaceManager *pIM= CInterfaceManager::getInstance();
_GroupMenu = dynamic_cast<CGroupMenu*>(pIM->getWindowFromId ("ui:interface:" + menuId + ""));
_GroupMenu = dynamic_cast<CGroupMenu*>(CWidgetManager::getInstance()->getWindowFromId ("ui:interface:" + menuId + ""));
_ContextVal = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TARGET:CONTEXT_VAL", false);
if(_GroupMenu == NULL)

View file

@ -69,6 +69,7 @@
#include "sheet_manager.h"
#include "interface_v3/sbrick_manager.h"
#include "interface_v3/widget_manager.h"
//
#include "gabarit.h"
#include "hair_set.h"
@ -1072,6 +1073,8 @@ void prelogInit()
// resetTextContext ("bremenb.ttf", false);
resetTextContext ("ryzom.ttf", false);
CWidgetManager::getInstance();
CInterfaceManager::create( Driver, TextContext );
// Yoyo: initialize NOW the InputHandler for Event filtering.

View file

@ -942,10 +942,10 @@ class CAHResetInterface : public IActionHandler
{
uint32 i;
CInterfaceManager *pIM = CInterfaceManager::getInstance();
const vector<CInterfaceManager::SMasterGroup> &rVMG = pIM->getAllMasterGroup();
const vector<CWidgetManager::SMasterGroup> &rVMG = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
{
const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
const CWidgetManager::SMasterGroup &rMG = rVMG[nMasterGroup];
const vector<CInterfaceGroup*> &rV = rMG.Group->getGroups();
// Active all containers (that can be activated)
for (i = 0; i < rV.size(); ++i)
@ -962,7 +962,7 @@ class CAHResetInterface : public IActionHandler
}
pIM->checkCoords();
pIM->getMasterGroup((uint8)nMasterGroup).centerAllContainers();
CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).centerAllContainers();
// Pop in and close all containers
for (i = 0; i < rV.size(); ++i)
@ -980,7 +980,7 @@ class CAHResetInterface : public IActionHandler
}
}
pIM->getMasterGroup((uint8)nMasterGroup).deactiveAllContainers();
CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).deactiveAllContainers();
}
}
};
@ -992,11 +992,11 @@ class CAHUnlockAllContainer : public IActionHandler
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
const vector<CInterfaceManager::SMasterGroup> &rVMG = pIM->getAllMasterGroup();
const vector<CWidgetManager::SMasterGroup> &rVMG = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
{
// const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
pIM->getMasterGroup((uint8)nMasterGroup).unlockAllContainers();
CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).unlockAllContainers();
}
}
};

View file

@ -153,7 +153,7 @@ bool CChatWindow::create(const CChatWindowDesc &desc, const std::string &chatId)
// If root container
if (desc.FatherContainer == "ui:interface")
{
im->addWindowToMasterGroup("ui:interface", _Chat);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", _Chat);
_Chat->setParent(pRoot);
_Chat->setMovable(true);
_Chat->setActive(false);

View file

@ -186,7 +186,7 @@ void CFlyingTextManager::linkToInterface(CGroupInfo &gi)
// add to group and window list
CInterfaceManager *pIM= CInterfaceManager::getInstance();
pIM->addWindowToMasterGroup("ui:interface", gi.GroupInScene);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", gi.GroupInScene);
gi.GroupInScene->setParent(_Root);
_Root->addGroup (gi.GroupInScene);
}

View file

@ -233,7 +233,7 @@ void CGroupInSceneBubbleManager::init ()
if (group)
{
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", group);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
group->setParent(pRoot);
if (pRoot)
@ -538,7 +538,7 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t
pViewSkillMax->setText (toString(pSM->getMaxSkillValue((SKILLS::ESkills)skillId)));
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", group);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
group->setParent(pRoot);
if (pRoot)
@ -587,7 +587,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA
}
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", group);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
group->setParent(pRoot);
if (pRoot)
@ -636,7 +636,7 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message,
}
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", group);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
group->setParent(pRoot);
if (pRoot)
@ -710,7 +710,7 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont
}
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", group);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
group->setParent(pRoot);
if (pRoot)
@ -903,7 +903,7 @@ void CGroupInSceneBubbleManager::dynChatOpen (uint32 nBotUID, uint32 nBotName, c
return;
}
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", group);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
group->setParent(pRoot);
if (pRoot)
@ -1016,7 +1016,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con
return;
}
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", group);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
group->setParent(pRoot);
if (pRoot)

View file

@ -741,7 +741,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity)
info->setActive(true);
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", info);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", info);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
info->setParent(pRoot);
if (pRoot)

View file

@ -522,10 +522,10 @@ void CInterfaceConfig::CDesktopImage::fromCurrentDesktop()
// Count number of container to save
uint32 nCount = 0, nMasterGroup, i, nCount2;
const vector<CInterfaceManager::SMasterGroup> &rVMG = pIM->getAllMasterGroup();
const vector<CWidgetManager::SMasterGroup> &rVMG = CWidgetManager::getInstance()->getAllMasterGroup();
for (nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
{
const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
const CWidgetManager::SMasterGroup &rMG = rVMG[nMasterGroup];
const vector<CInterfaceGroup*> &rV = rMG.Group->getGroups();
for (i = 0; i < rV.size(); ++i)
{
@ -541,7 +541,7 @@ void CInterfaceConfig::CDesktopImage::fromCurrentDesktop()
// retrieve all containers
for (nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
{
const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
const CWidgetManager::SMasterGroup &rMG = rVMG[nMasterGroup];
const vector<CInterfaceGroup*> &rV = rMG.Group->getGroups();
for (i = 0; i < rV.size(); ++i)
{

View file

@ -351,11 +351,6 @@ CInterfaceManager::~CInterfaceManager()
{
reset(); // to flush IDStringWaiters
//delete the interface group
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{
delete _MasterGroups[i].Group;
}
_ParentPositionsMap.clear();
_ParentSizesMap.clear();
_ParentSizesMaxMap.clear();
@ -1893,6 +1888,7 @@ bool CInterfaceManager::saveConfig (const string &filename)
void CInterfaceManager::checkCoords()
{
H_AUTO ( RZ_Interface_validateCoords )
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
uint32 nMasterGroup;
@ -1902,7 +1898,7 @@ void CInterfaceManager::checkCoords()
// checkCoords all the windows
for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++)
@ -1928,7 +1924,7 @@ void CInterfaceManager::checkCoords()
// updateCoords all the needed windows
for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++)
@ -2071,12 +2067,13 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera)
To minimize texture swapping, we first sort per Window, then we sort per layer, then we render per Global Texture.
Computed String are rendered in on big drawQuads at last part of each layer
*/
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
IngameDbMngr.flushObserverCalls();
NLGUI::CDBManager::getInstance()->flushObserverCalls();
//
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
// Sort world space windows
@ -2231,10 +2228,11 @@ CCtrlBase* CInterfaceManager::getNewContextHelpCtrl()
// ----------------------------------------------------------------------------
CInterfaceGroup *CInterfaceManager::getWindowForActiveMasterGroup(const std::string &window)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
// Search for all elements
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
const SMasterGroup &rMG = _MasterGroups[nMasterGroup];
const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
CInterfaceElement *pEL= getElementFromId( rMG.Group->getId() + ":" + window);
@ -3260,6 +3258,7 @@ void CInterfaceManager::getNewWindowCoordToNewScreenSize(sint32 &x, sint32 &y, s
// ------------------------------------------------------------------------------------------------
void CInterfaceManager::moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 newScreenH, bool fixCurrentUI)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
// If resolutions correctly setuped, and really different from new setup
if( _LastInGameScreenW >0 && _LastInGameScreenH>0 &&
newScreenW >0 && newScreenH>0 &&
@ -3272,7 +3271,7 @@ void CInterfaceManager::moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32
// only for ui:interface (not login, nor outgame)
for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if(!rMG.Group || rMG.Group->getId()!="ui:interface")
continue;
@ -3346,10 +3345,12 @@ void CInterfaceManager::updateAllLocalisedElements()
_ViewRenderer.checkNewScreenSize ();
_ViewRenderer.getScreenSize (w, h);
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
// Update ui:* (limit the master containers to the height of the screen)
for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
rMG.Group->setW (w);
rMG.Group->setH (h);
}
@ -3363,7 +3364,7 @@ void CInterfaceManager::updateAllLocalisedElements()
// Invalidate coordinates of all Windows of each MasterGroup
for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
rMG.Group->invalidateTexts (false);
rMG.Group->invalidateCoords ();
@ -3383,7 +3384,7 @@ void CInterfaceManager::updateAllLocalisedElements()
// setup for all
for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
bool bActive = rMG.Group->getActive ();
rMG.Group->setActive (true);
rMG.Group->updateCoords ();
@ -3396,7 +3397,7 @@ void CInterfaceManager::updateAllLocalisedElements()
// Action by default (container opening
for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
rMG.Group->launch ();
}
@ -3489,9 +3490,10 @@ CInterfaceGroup* CInterfaceManager::getWindowUnder (sint32 x, sint32 y)
{
H_AUTO (RZ_Interface_Window_Under )
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--)
@ -3516,9 +3518,10 @@ CInterfaceGroup* CInterfaceManager::getWindowUnder (sint32 x, sint32 y)
// ------------------------------------------------------------------------------------------------
CInterfaceGroup* CInterfaceManager::getGroupUnder (sint32 x, sint32 y)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--)
@ -3550,11 +3553,13 @@ void CInterfaceManager::getViewsUnder (sint32 x, sint32 y, std::vector<CViewBase
if(_ViewRenderer.isMinimized())
return;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
uint32 sw, sh;
_ViewRenderer.getScreenSize(sw, sh);
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--)
@ -3586,11 +3591,13 @@ void CInterfaceManager::getCtrlsUnder (sint32 x, sint32 y, std::vector<CCtrlBase
if(_ViewRenderer.isMinimized())
return;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
uint32 sw, sh;
_ViewRenderer.getScreenSize(sw, sh);
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--)
@ -3624,11 +3631,13 @@ void CInterfaceManager::getGroupsUnder (sint32 x, sint32 y, std::vector<CInterfa
if(_ViewRenderer.isMinimized())
return;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
uint32 sw, sh;
_ViewRenderer.getScreenSize(sw, sh);
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--)
@ -3660,7 +3669,7 @@ void CInterfaceManager::getGroupsUnder (sint32 x, sint32 y, std::vector<CInterfa
// ------------------------------------------------------------------------------------------------
void CInterfaceManager::activateMasterGroup (const std::string &sMasterGroupName, bool bActive)
{
CInterfaceGroup *pIG = getMasterGroupFromId (sMasterGroupName);
CInterfaceGroup *pIG = CWidgetManager::getInstance()->getMasterGroupFromId (sMasterGroupName);
if (pIG != NULL)
{
pIG->setActive(bActive);
@ -3688,10 +3697,12 @@ CInterfaceElement* CInterfaceManager::getElementFromId (const std::string &sEltI
if(sEltId == _CtrlLaunchingModalId)
return getCtrlLaunchingModal();
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
// Search for all elements
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CInterfaceElement *pIEL = rMG.Group->getElement (sEltId);
if (pIEL != NULL)
return pIEL;
@ -3735,10 +3746,11 @@ CInterfaceElement* CInterfaceManager::getElementFromId (const std::string &sStar
// ------------------------------------------------------------------------------------------------
void CInterfaceManager::setTopWindow (CInterfaceGroup* win)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
//find the window in the window list
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
rMG.setTopWindow(win);
@ -3772,9 +3784,10 @@ void CInterfaceManager::setTopWindow (CInterfaceGroup* win)
// ------------------------------------------------------------------------------------------------
void CInterfaceManager::setBackWindow(CInterfaceGroup* win)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
rMG.setBackWindow(win);
@ -3798,9 +3811,10 @@ void CInterfaceManager::setBackWindow(CInterfaceGroup* win)
// ------------------------------------------------------------------------------------------------
CInterfaceGroup *CInterfaceManager::getTopWindow (uint8 nPriority) const
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
const SMasterGroup &rMG = _MasterGroups[nMasterGroup];
const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
// return the first.
@ -3817,9 +3831,10 @@ CInterfaceGroup *CInterfaceManager::getTopWindow (uint8 nPriority) const
// ------------------------------------------------------------------------------------------------
CInterfaceGroup *CInterfaceManager::getBackWindow (uint8 nPriority) const
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
const SMasterGroup &rMG = _MasterGroups[nMasterGroup];
const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
// return the first.
@ -4280,6 +4295,7 @@ void CInterfaceManager::disableContextHelpForControl(CCtrlBase *pCtrl)
void CInterfaceManager::makeWindow(CInterfaceGroup *group)
{
if (!group) return;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
uint32 i = 0;
for (i = 0; i < _MasterGroups.size(); ++i)
{
@ -4311,6 +4327,7 @@ void CInterfaceManager::makeWindow(CInterfaceGroup *group)
void CInterfaceManager::unMakeWindow(CInterfaceGroup *group, bool noWarning)
{
if (!group) return;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
uint32 i = 0;
for (i = 0; i < _MasterGroups.size(); ++i)
{
@ -4478,15 +4495,15 @@ void CInterfaceManager::launchContextMenuInGame (const std::string &nameOfCM)
if (_ModalStack.empty())
{
// We must be in-game !
CInterfaceGroup *pMG = getMasterGroupFromId("ui:interface");
CInterfaceGroup *pMG = CWidgetManager::getInstance()->getMasterGroupFromId("ui:interface");
// TMP nico : try with login screen:
if (!pMG)
{
pMG = getMasterGroupFromId("ui:login");
pMG = CWidgetManager::getInstance()->getMasterGroupFromId("ui:login");
}
if (!pMG)
{
pMG = getMasterGroupFromId("ui:outgame");
pMG = CWidgetManager::getInstance()->getMasterGroupFromId("ui:outgame");
}
if ((pMG != NULL) && (pMG->getActive()))
{
@ -4580,10 +4597,12 @@ void CInterfaceManager::setMode(uint8 newMode)
if (newMode == _CurrentMode)
return;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
// Check if we can change vdesk !
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority)
@ -4653,6 +4672,7 @@ struct CDumpedGroup
// ***************************************************************************
void CInterfaceManager::dumpUI(bool /* indent */)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
std::vector<CDumpedGroup> left;
left.resize(_MasterGroups.size());
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
@ -4727,9 +4747,10 @@ void CInterfaceManager::dumpUI(bool /* indent */)
// ***************************************************************************
void CInterfaceManager::displayUIViewBBoxs(const std::string &uiFilter)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority)
{
list<CInterfaceGroup*> &rList = rMG.PrioritizedWindows[nPriority];
@ -4745,9 +4766,10 @@ void CInterfaceManager::displayUIViewBBoxs(const std::string &uiFilter)
// ***************************************************************************
void CInterfaceManager::displayUICtrlBBoxs(const std::string &uiFilter)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority)
{
list<CInterfaceGroup*> &rList = rMG.PrioritizedWindows[nPriority];
@ -4763,9 +4785,10 @@ void CInterfaceManager::displayUICtrlBBoxs(const std::string &uiFilter)
// ***************************************************************************
void CInterfaceManager::displayUIGroupBBoxs(const std::string &uiFilter)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority)
{
list<CInterfaceGroup*> &rList = rMG.PrioritizedWindows[nPriority];
@ -4870,9 +4893,10 @@ bool CInterfaceManager::saveKeys(const std::string &filename)
// ***************************************************************************
CInterfaceGroup *CInterfaceManager::getLastEscapableTopWindow() const
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
const SMasterGroup &rMG = _MasterGroups[nMasterGroup];
const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--)
@ -4894,9 +4918,10 @@ CInterfaceGroup *CInterfaceManager::getLastEscapableTopWindow() const
// ***************************************************************************
void CInterfaceManager::setWindowPriority (CInterfaceGroup *pWin, uint8 nNewPriority)
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
if (rMG.isWindowPresent(pWin))
@ -4944,9 +4969,10 @@ void CInterfaceManager::log(const ucstring &str)
// ***************************************************************************
void CInterfaceManager::clearAllEditBox()
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority)
{
list<CInterfaceGroup*> &rList = rMG.PrioritizedWindows[nPriority];
@ -4964,9 +4990,10 @@ void CInterfaceManager::clearAllEditBox()
// ***************************************************************************
void CInterfaceManager::restoreAllContainersBackupPosition()
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority)
{
list<CInterfaceGroup*> &rList = rMG.PrioritizedWindows[nPriority];
@ -4983,9 +5010,10 @@ void CInterfaceManager::restoreAllContainersBackupPosition()
// ***************************************************************************
uint8 CInterfaceManager::getLastTopWindowPriority() const
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
const SMasterGroup &rMG = _MasterGroups[nMasterGroup];
const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
return rMG.LastTopWindowPriority;
@ -5078,6 +5106,7 @@ void CInterfaceManager::submitEvent (const std::string &event)
void CInterfaceManager::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
if (_MasterGroups[nMasterGroup].Group)
@ -5604,9 +5633,10 @@ void CInterfaceManager::notifyForumUpdated()
void CInterfaceManager::resetTextIndex()
{
uint32 nMasterGroup;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
rMG.Group->invalidateTexts (true);
for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++)
@ -5948,9 +5978,10 @@ void CInterfaceManager::luaGarbageCollect()
// ***************************************************************************
void CInterfaceManager::hideAllWindows()
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++)
@ -5971,9 +6002,10 @@ void CInterfaceManager::hideAllWindows()
// ***************************************************************************
void CInterfaceManager::hideAllNonSavableWindows()
{
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getActive())
{
for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++)

View file

@ -292,194 +292,6 @@ private:
map<string,CInterfaceGroup*> _Accel;
};
// ----------------------------------------------------------------------------
// SMasterGroup
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void CInterfaceParser::SMasterGroup::addWindow(CInterfaceGroup *pIG, uint8 nPrio)
{
nlassert(nPrio<WIN_PRIORITY_MAX);
// Priority WIN_PRIORITY_WORLD_SPACE is only for CGroupInScene !
// Add this group in another priority list
nlassert ((nPrio!=WIN_PRIORITY_MAX) || (dynamic_cast<CGroupInScene*>(pIG)!=NULL));
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
// If the element already exists in the list return !
if (*it == pIG)
return;
it++;
}
}
PrioritizedWindows[nPrio].push_back(pIG);
}
// ----------------------------------------------------------------------------
void CInterfaceParser::SMasterGroup::delWindow(CInterfaceGroup *pIG)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if ((*it) == pIG)
{
PrioritizedWindows[i].erase(it);
return;
}
it++;
}
}
}
// ----------------------------------------------------------------------------
CInterfaceGroup* CInterfaceParser::SMasterGroup::getWindowFromId(const std::string &winID)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if ((*it)->getId() == winID)
return *it;
it++;
}
}
return NULL;
}
// ----------------------------------------------------------------------------
bool CInterfaceParser::SMasterGroup::isWindowPresent(CInterfaceGroup *pIG)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if ((*it) == pIG)
return true;
it++;
}
}
return false;
}
// Set a window top in its priority queue
// ----------------------------------------------------------------------------
void CInterfaceParser::SMasterGroup::setTopWindow(CInterfaceGroup *pIG)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if (*it == pIG)
{
PrioritizedWindows[i].erase(it);
PrioritizedWindows[i].push_back(pIG);
LastTopWindowPriority= i;
return;
}
it++;
}
}
// todo hulud interface syntax error
nlwarning("window %s do not exist in a priority list", pIG->getId().c_str());
}
// ----------------------------------------------------------------------------
void CInterfaceParser::SMasterGroup::setBackWindow(CInterfaceGroup *pIG)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if (*it == pIG)
{
PrioritizedWindows[i].erase(it);
PrioritizedWindows[i].push_front(pIG);
return;
}
it++;
}
}
// todo hulud interface syntax error
nlwarning("window %s do not exist in a priority list", pIG->getId().c_str());
}
// ----------------------------------------------------------------------------
void CInterfaceParser::SMasterGroup::deactiveAllContainers()
{
vector<CGroupContainer*> gcs;
// Make first a list of all window (Warning: all group container are not window!)
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(*it);
if (pGC != NULL)
gcs.push_back(pGC);
it++;
}
}
// Then hide them. Must do this in 2 times, because setActive(false) change PrioritizedWindows,
// and hence invalidate its.
for (uint32 i = 0; i < gcs.size(); ++i)
{
gcs[i]->setActive(false);
}
}
// ----------------------------------------------------------------------------
void CInterfaceParser::SMasterGroup::centerAllContainers()
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(*it);
if ((pGC != NULL) && (pGC->getParent() != NULL))
{
sint32 wParent = pGC->getParent()->getW(false);
sint32 w = pGC->getW(false);
pGC->setXAndInvalidateCoords((wParent - w) / 2);
sint32 hParent = pGC->getParent()->getH(false);
sint32 h = pGC->getH(false);
pGC->setYAndInvalidateCoords(h+(hParent - h) / 2);
}
it++;
}
}
}
// ----------------------------------------------------------------------------
void CInterfaceParser::SMasterGroup::unlockAllContainers()
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(*it);
if (pGC != NULL)
pGC->setLocked(false);
it++;
}
}
}
// ----------------------------------------------------------------------------
// CInterfaceParser
// ----------------------------------------------------------------------------
@ -734,7 +546,7 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload)
{
H_AUTO(parseXMLDocument);
SMasterGroup *curRoot = NULL;
CWidgetManager::SMasterGroup *curRoot = NULL;
CInterfaceGroup *rootGroup = NULL;
//parse templates
xmlNodePtr curNode = root->children;
@ -744,6 +556,8 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload)
Actions.reserveCategories((uint)Actions.getCategories ().size()+actionCategoryCount);
EditActions.reserveCategories(1);
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
while (curNode)
{
// first solve define for the xml node and his sons
@ -840,12 +654,12 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload)
CXMLAutoPtr ptr((const char*)xmlGetProp (root, (xmlChar*)"id"));
if (ptr)
{
rootGroup = getMasterGroupFromId (string("ui:") + (const char*)ptr);
rootGroup = CWidgetManager::getInstance()->getMasterGroupFromId (string("ui:") + (const char*)ptr);
if (rootGroup == NULL)
{
rootGroup = (CInterfaceGroup*)(new CRootGroup(CViewBase::TCtorParam()));
rootGroup->parse (root, NULL);
SMasterGroup mg;
CWidgetManager::SMasterGroup mg;
mg.Group = rootGroup;
_MasterGroups.push_back (mg);
}
@ -982,7 +796,7 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload)
{
H_AUTO(addWindowToMasterGroup)
SMasterGroup &rMG = _MasterGroups[i];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[i];
// insert all modals
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
@ -991,7 +805,7 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload)
if(pIG)
{
// add to the window list
addWindowToMasterGroup(rMG.Group->getId(), pIG);
CWidgetManager::getInstance()->addWindowToMasterGroup(rMG.Group->getId(), pIG);
}
}
}
@ -1979,9 +1793,10 @@ bool CInterfaceParser::parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGro
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
CInterfaceElement *pEltFound = NULL;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{
SMasterGroup &rMG = _MasterGroups[i];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[i];
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
@ -2026,10 +1841,11 @@ bool CInterfaceParser::setupTreeNode (xmlNodePtr cur, CGroupContainer * /* paren
{
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{
SMasterGroup &rMG = _MasterGroups[i];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[i];
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
@ -2119,14 +1935,15 @@ bool CInterfaceParser::setupTreeNode (xmlNodePtr cur, CGroupContainer * /* paren
}
// ----------------------------------------------------------------------------
bool CInterfaceParser::setupTree (xmlNodePtr cur, SMasterGroup * /* parentGroup */)
bool CInterfaceParser::setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup * /* parentGroup */)
{
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{
SMasterGroup &rMG = _MasterGroups[i];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[i];
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
@ -2186,16 +2003,17 @@ bool CInterfaceParser::setupTree (xmlNodePtr cur, SMasterGroup * /* parentGroup
// ----------------------------------------------------------------------------
bool CInterfaceParser::parseTree (xmlNodePtr cur, SMasterGroup *parentGroup)
bool CInterfaceParser::parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup)
{
H_AUTO(parseTree )
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{
SMasterGroup &rMG = _MasterGroups[i];
CWidgetManager::SMasterGroup &rMG = _MasterGroups[i];
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
@ -2239,7 +2057,7 @@ bool CInterfaceParser::parseTree (xmlNodePtr cur, SMasterGroup *parentGroup)
}
// Ok add it.
addWindowToMasterGroup(parentGroup->Group->getId(), pIG);
CWidgetManager::getInstance()->addWindowToMasterGroup(parentGroup->Group->getId(), pIG);
CGroupContainer *pIC = dynamic_cast<CGroupContainer*>(pEltFound);
if (pIC != NULL)
@ -2417,7 +2235,7 @@ bool CInterfaceParser::initCoordsAndLuaScript()
parentpos = parent->getElement(EltName);
//if the element has no parent, check the windows
else
parentpos = getWindowFromId(EltName);
parentpos = CWidgetManager::getInstance()->getWindowFromId(EltName);
if (parentpos == NULL)
{
@ -2448,7 +2266,7 @@ bool CInterfaceParser::initCoordsAndLuaScript()
parentsize = parent->getElement(EltName);
//if the element has no parent, check the windows
else
parentsize = getWindowFromId(EltName);
parentsize = CWidgetManager::getInstance()->getWindowFromId(EltName);
}
if (parentsize == NULL)
@ -2481,7 +2299,7 @@ bool CInterfaceParser::initCoordsAndLuaScript()
parentsizemax = parent->getElement(EltName);
//if the element has no parent, check the windows
else
parentsizemax = getWindowFromId(EltName);
parentsizemax = CWidgetManager::getInstance()->getWindowFromId(EltName);
}
if (parentsizemax == NULL)
@ -2536,60 +2354,6 @@ void CInterfaceParser::addLuaClassAssociation (CInterfaceGroup *group, const std
_LuaClassAssociation.insert (std::map<CInterfaceGroup*,std::string>::value_type(group, luaScript));
}
// ----------------------------------------------------------------------------
CInterfaceGroup* CInterfaceParser::getMasterGroupFromId (const std::string &MasterGroupName)
{
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{
if (_MasterGroups[i].Group->getId() == MasterGroupName)
return _MasterGroups[i].Group;
}
return NULL;
}
// ----------------------------------------------------------------------------
CInterfaceGroup* CInterfaceParser::getWindowFromId (const std::string & groupId)
{
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CInterfaceGroup *pIG = rMG.getWindowFromId(groupId);
if (pIG != NULL)
return pIG;
}
return NULL;
}
// ----------------------------------------------------------------------------
void CInterfaceParser::addWindowToMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG)
{
// Warning this function is not smart : its a o(n) !
if (pIG == NULL) return;
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getId() == sMasterGroupName)
{
rMG.addWindow(pIG, pIG->getPriority());
}
}
}
// ----------------------------------------------------------------------------
void CInterfaceParser::removeWindowFromMasterGroup(const std::string &sMasterGroupName,CInterfaceGroup *pIG)
{
// Warning this function is not smart : its a o(n) !
if (pIG == NULL) return;
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getId() == sMasterGroupName)
{
rMG.delWindow(pIG);
}
}
}
// ***************************************************************************
const std::string &CInterfaceParser::getDefine(const std::string &id) const
{
@ -3830,38 +3594,7 @@ void CInterfaceParser::removeAllAnims()
}
// ***************************************************************************
void unlinkAllContainers (CInterfaceGroup *pIG)
{
const vector<CInterfaceGroup*> &rG = pIG->getGroups();
for(uint i = 0; i < rG.size(); ++i)
unlinkAllContainers (rG[i]);
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(pIG);
if (pGC != NULL)
pGC->removeAllContainers();
}
// ***************************************************************************
void CInterfaceParser::removeAllMasterGroups()
{
uint i;
NLMISC::TTime initStart;
initStart = ryzomGetLocalTime ();
for (i = 0; i < _MasterGroups.size(); ++i)
unlinkAllContainers (_MasterGroups[i].Group);
//nlinfo ("%d seconds for all unlinkAllContainers", (uint32)(ryzomGetLocalTime ()-initStart)/1000);
initStart = ryzomGetLocalTime ();
// Yoyo: important to not Leave NULL in the array, because of CGroupHTML and LibWWW callback
// that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^)
while(!_MasterGroups.empty())
{
delete _MasterGroups.back().Group;
_MasterGroups.pop_back();
}
//nlinfo ("%d seconds for all delete _MasterGroups", (uint32)(ryzomGetLocalTime ()-initStart)/1000);
}
// ***************************************************************************
void CInterfaceParser::removeAll()
@ -3886,7 +3619,7 @@ void CInterfaceParser::removeAll()
removeAllAnims();
//nlinfo ("%d seconds for removeAllAnims", (uint32)(ryzomGetLocalTime ()-initStart)/1000);
initStart = ryzomGetLocalTime ();
removeAllMasterGroups();
CWidgetManager::getInstance()->removeAllMasterGroups();
//nlinfo ("%d seconds for removeAllMasterGroups", (uint32)(ryzomGetLocalTime ()-initStart)/1000);
_StyleMap.clear();
_CtrlSheetSelection.deleteGroups();
@ -4054,141 +3787,7 @@ bool CInterfaceParser::parseCareerGeneratorParams(xmlNodePtr cur,
// ***************************************************************************
bool CInterfaceParser::parseBrickCareerGenerator(xmlNodePtr /* cur */)
{
H_AUTO(parseBrickCareerGenerator)
// No more CAREER / Bricks!!!
// TODO_BRICK: remove this code.
return false;
/*
CBrickManager *pBM= CBrickManager::getInstance();
CXMLAutoPtr prop;
string templateCareer;
string templateJob;
string templateBrick;
string careerWindowBase;
string jobWindowBase;
string brickWindowBase;
xmlNodePtr rootTreeNode;
bool brickTypeFilter;
BRICK_TYPE::EBrickType brickType;
if(! parseCareerGeneratorParams(cur, templateCareer, templateJob, careerWindowBase, jobWindowBase, rootTreeNode,
brickTypeFilter, brickType) )
return false;
if(!brickTypeFilter)
{
nlwarning("'brick_carrer_generator' must be filtered. 'brick_type' must not be 'none'");
return false;
}
// Read Brick specials.
prop = xmlGetProp (cur, (xmlChar*)"template_brick");
if(prop) templateBrick= (const char*)prop;
else
{
nlwarning("prop 'template_brick' not found");
return false;
}
prop = xmlGetProp (cur, (xmlChar*)"brick_window");
if(prop) brickWindowBase= (const char*)prop;
else
{
nlwarning("prop 'brick_window' not found");
return false;
}
// read the XStart for bricks that are in Jobs (not in career).
sint32 xstartCareer=0;
prop = xmlGetProp (cur, (xmlChar*)"xstart_career");
if(prop) fromString((const char*)prop, xstartCareer);
sint32 xstartJob=0;
prop = xmlGetProp (cur, (xmlChar*)"xstart_job");
if(prop) fromString((const char*)prop, xstartJob);
// **** Create all existing careers
xmlNodePtr nextSibling=cur;
for(uint careerId=0;careerId<BRICKS_MAX_CAREER;careerId++)
{
const CBrickCareer *career= NULL;
// get the career for our wanted brick type
career= pBM->getCareer(brickType, (ROLES::ERole)careerId );
// if no filter, then dispplay all careers
if(career)
{
string carreerWindowId= careerWindowBase + toString(careerId);
// Ok, create the xml node to instanciate the career
xmlNodePtr node= xmlNewNode(cur->ns, (xmlChar*)"instance" );
xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateCareer.c_str());
xmlSetProp(node, (xmlChar*)"careerid", (xmlChar*)toString(careerId).c_str());
xmlSetProp(node, (xmlChar*)"id", (xmlChar*)carreerWindowId.c_str());
// add it before rootContainer => next to nextSibling
xmlAddNextSibling (nextSibling, node);
nextSibling = nextSibling->next;
// Create the associated tree node
xmlNodePtr careerTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" );
xmlSetProp(careerTreeNode, (xmlChar*)"node", (xmlChar*)carreerWindowId.c_str());
// link it to the root
xmlAddChild(rootTreeNode, careerTreeNode);
// **** create bricks in the career common Job.
string brickWindowId= brickWindowBase + toString(careerId) + "_c_";
createJobBricks(brickType, nextSibling, careerTreeNode, career->Common, templateBrick, brickWindowId, xstartCareer);
// **** create all existing jobs.
sint numJobs;
// parse jobs of the career
numJobs= career->Jobs.size();
// for all jobs to parse
for(sint jobIndex=0;jobIndex<numJobs;jobIndex++)
{
// get the jobId, ie the index of the job in the database (0 to 7)
sint jobId;
jobId= JOBS::getJobDBIndex( career->Jobs[jobIndex].Job );
// if the job exist
if(jobId>=0)
{
string jobWindowId= jobWindowBase + toString(careerId) + "_" + toString(jobId);
// create the xml node to instanciate the job
xmlNodePtr node= xmlNewNode(cur->ns, (xmlChar*)"instance" );
xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateJob.c_str());
xmlSetProp(node, (xmlChar*)"careerid", (xmlChar*)toString(careerId).c_str());
xmlSetProp(node, (xmlChar*)"jobid", (xmlChar*)toString(jobId).c_str());
xmlSetProp(node, (xmlChar*)"id", (xmlChar*)jobWindowId.c_str());
// add it before rootContainer => next to nextSibling
xmlAddNextSibling (nextSibling, node);
nextSibling = nextSibling->next;
// Create the associated tree node
xmlNodePtr jobTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" );
xmlSetProp(jobTreeNode, (xmlChar*)"node", (xmlChar*)jobWindowId.c_str());
// link it
xmlAddChild(careerTreeNode, jobTreeNode);
// **** create bricks in the Job.
string brickWindowId= brickWindowBase + toString(careerId) + "_" + toString(jobId) + "_";
createJobBricks(brickType, nextSibling, jobTreeNode, career->Jobs[jobIndex], templateBrick, brickWindowId, xstartJob);
}
}
}
}
return true;*/
}
@ -4196,163 +3795,13 @@ bool CInterfaceParser::parseBrickCareerGenerator(xmlNodePtr /* cur */)
void CInterfaceParser::createJobBricks(BRICK_TYPE::EBrickType brickType, xmlNodePtr &nextSibling, xmlNodePtr parentTreeNode,
const CBrickJob &/* job */, const string &/* templateBrick */, const string &/* baseWindowId */, sint32 /* xstart */)
{
// No more CAREER / Bricks!!!
// TODO_BRICK: remove this code.
/*
uint brickWndIndex=0;
// Must Parse Family and Special ShopKeeper Family too!
uint numFamilyStd= job.Family.size();
uint numFamilyTotal= numFamilyStd + job.SpecialShopkeeperFamily.size();
// For all the families of brick.
for(uint familyId= 0; familyId<numFamilyTotal; familyId++)
{
const CBrickFamily &brickFamily= familyId<numFamilyStd?
job.Family[familyId] :
job.SpecialShopkeeperFamily[familyId-numFamilyStd];
// For Magic, must parse all bricks of the family
if(brickType== BRICK_TYPE::MAGIC)
{
for(uint i=0;i<brickFamily.Bricks.size();i++)
{
string windowId= baseWindowId + toString(brickWndIndex++);
// create the xml node to instanciate the brick group
xmlNodePtr node= xmlNewNode(nextSibling->ns, (xmlChar*)"instance" );
xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateBrick.c_str());
xmlSetProp(node, (xmlChar*)"root_brick", (xmlChar*)toString(brickFamily.Bricks[i].asInt()).c_str());
xmlSetProp(node, (xmlChar*)"id", (xmlChar*)windowId.c_str() );
xmlSetProp(node, (xmlChar*)"xstart", (xmlChar*)toString(xstart).c_str() );
// add it before rootContainer => next to nextSibling
xmlAddNextSibling (nextSibling, node);
nextSibling = nextSibling->next;
// Create the associated tree node
xmlNodePtr brickTreeNode= xmlNewNode(nextSibling->ns, (xmlChar*)"tree" );
xmlSetProp(brickTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str());
// link it
xmlAddChild(parentTreeNode, brickTreeNode);
}
}
// For Combat-Special, parse only the brickFamily
else
{
string windowId= baseWindowId + toString(brickWndIndex++);
// create the xml node to instanciate the brick group
xmlNodePtr node= xmlNewNode(nextSibling->ns, (xmlChar*)"instance" );
xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateBrick.c_str());
xmlSetProp(node, (xmlChar*)"brick_family", (xmlChar*)toString(brickFamily.Family).c_str());
xmlSetProp(node, (xmlChar*)"id", (xmlChar*)windowId.c_str() );
xmlSetProp(node, (xmlChar*)"xstart", (xmlChar*)toString(xstart).c_str() );
// add it before rootContainer => next to nextSibling
xmlAddNextSibling (nextSibling, node);
nextSibling = nextSibling->next;
// Create the associated tree node
xmlNodePtr brickTreeNode= xmlNewNode(nextSibling->ns, (xmlChar*)"tree" );
xmlSetProp(brickTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str());
// link it
xmlAddChild(parentTreeNode, brickTreeNode);
}
}
*/
}
// ***************************************************************************
bool CInterfaceParser::parseBrickSuffixGenerator(xmlNodePtr /* cur */)
{
H_AUTO(parseBrickSuffixGenerator)
// No more CAREER / Bricks!!!
// TODO_BRICK: remove this code.
return false;
/*
CBrickManager *pBM= CBrickManager::getInstance();
CXMLAutoPtr prop;
string templateBrick;
string brickWindowBase;
xmlNodePtr rootTreeNode;
BRICK_TYPE::EBrickType brickType;
// create or search the root container.
if(!parseGeneratorRootContainer(cur, rootTreeNode))
return false;
// Read Brick specials.
prop = xmlGetProp (cur, (xmlChar*)"template_brick");
if(prop) templateBrick= (const char*)prop;
else
{
nlwarning("prop 'template_brick' not found");
return false;
}
prop = xmlGetProp (cur, (xmlChar*)"brick_window");
if(prop) brickWindowBase= (const char*)prop;
else
{
nlwarning("prop 'brick_window' not found");
return false;
}
// read the XStart for bricks that are in Jobs (not in career).
sint32 xstart=0;
prop = xmlGetProp (cur, (xmlChar*)"xstart");
if(prop) fromString((const char*)prop, xstart);
// Read BrickType
prop = xmlGetProp (cur, (xmlChar*)"brick_type");
if(prop)
{
brickType= BRICK_TYPE::toBrickType((const char*)prop);
if(brickType == BRICK_TYPE::UNKNOWN)
{
nlwarning("'brick_type' UKNOWN in brick_suffix_generator (NB: none not allowed)");
return false;
}
}
else
{
nlwarning("prop 'brick_type' not found");
return false;
}
// **** Create All Suffix for the brickType.
const std::vector<CBrickFamily> &bfs= pBM->getBrickSuffixes(brickType);
xmlNodePtr nextSibling=cur;
for(uint i=0;i<bfs.size();i++)
{
string windowId= brickWindowBase + toString(i);
// create the xml node to instanciate the brick group
xmlNodePtr node= xmlNewNode(nextSibling->ns, (xmlChar*)"instance" );
xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateBrick.c_str());
xmlSetProp(node, (xmlChar*)"brick_family", (xmlChar*)toString(bfs[i].Family).c_str());
xmlSetProp(node, (xmlChar*)"id", (xmlChar*)windowId.c_str() );
xmlSetProp(node, (xmlChar*)"xstart", (xmlChar*)toString(xstart).c_str() );
// add it before rootContainer => next to nextSibling
xmlAddNextSibling (nextSibling, node);
nextSibling = nextSibling->next;
// Create the associated tree node
xmlNodePtr brickTreeNode= xmlNewNode(nextSibling->ns, (xmlChar*)"tree" );
xmlSetProp(brickTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str());
// link it
xmlAddChild(rootTreeNode, brickTreeNode);
}
return true;*/
}
@ -4501,53 +3950,6 @@ bool CInterfaceParser::solveStyle(xmlNodePtr cur)
// ***************************************************************************
class CElementToSort
{
public:
CInterfaceGroup *pIG;
float Distance;
bool operator< (const CElementToSort& other) const
{
// We want first farest views
return Distance > other.Distance;
}
};
void CInterfaceParser::SMasterGroup::sortWorldSpaceGroup ()
{
H_AUTO ( RZ_Interface_sortWorldSpaceGroup )
static vector<CElementToSort> sortTable;
sortTable.clear ();
// Fill the sort table
list<CInterfaceGroup*>::iterator it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin();
while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end())
{
sortTable.push_back (CElementToSort ());
CElementToSort &elm = sortTable.back();
elm.pIG = *it;
elm.Distance = (static_cast<CGroupInScene*>(*it))->getDepthForZSort();
it++;
}
// Sort the table
std::sort (sortTable.begin(), sortTable.end());
// Fill the final table
uint i = 0;
it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin();
while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end())
{
*it = sortTable[i].pIG;
it++;
i++;
}
}
#ifdef LUA_NEVRAX_VERSION
class CLuaDebugBreakScreen : public IDebuggedAppMainLoop

View file

@ -26,6 +26,7 @@
#include "nel/misc/smart_ptr.h"
#include "game_share/brick_types.h"
#include "nel/gui/lua_helper.h"
#include "widget_manager.h"
using namespace NLGUI;
// ***************************************************************************
@ -40,16 +41,6 @@ class CInterfaceLink;
class CBrickJob;
class CCtrlBase;
// ***************************************************************************
#define WIN_PRIORITY_MAX 8
#define WIN_PRIORITY_WORLD_SPACE 0
#define WIN_PRIORITY_LOWEST 1
#define WIN_PRIORITY_LOW 2
#define WIN_PRIORITY_NORMAL 3
#define WIN_PRIORITY_HIGH 4
#define WIN_PRIORITY_HIGHEST 5
// ***************************************************************************
/**
* class managing the interface parsing
@ -66,34 +57,6 @@ public:
CInterfaceParser();
virtual ~CInterfaceParser();
struct SMasterGroup
{
SMasterGroup()
{
Group= NULL;
LastTopWindowPriority= WIN_PRIORITY_NORMAL;
}
CInterfaceGroup *Group;
std::list<CInterfaceGroup*> PrioritizedWindows[WIN_PRIORITY_MAX];
void addWindow(CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL);
void delWindow(CInterfaceGroup *pIG);
CInterfaceGroup *getWindowFromId(const std::string &winID);
bool isWindowPresent(CInterfaceGroup *pIG);
// Set a window top in its priority queue
void setTopWindow(CInterfaceGroup *pIG);
void setBackWindow(CInterfaceGroup *pIG);
void deactiveAllContainers();
void centerAllContainers();
void unlockAllContainers();
// Sort the world space group
void sortWorldSpaceGroup ();
uint8 LastTopWindowPriority;
};
public:
/**
@ -134,7 +97,7 @@ public:
bool parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup);
bool parseTree (xmlNodePtr cur, SMasterGroup *parentGroup);
bool parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup);
bool parseDefine(xmlNodePtr cur);
@ -166,7 +129,7 @@ public:
bool parseLUAScript (xmlNodePtr cur);
bool setupTree (xmlNodePtr cur, SMasterGroup *parentGroup);
bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup);
bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup);
// Called by each parse in parseXMLDocument
@ -197,13 +160,6 @@ public:
/**
* Accessors
*/
CInterfaceGroup* getMasterGroupFromId (const std::string &MasterGroupName);
const std::vector<SMasterGroup> &getAllMasterGroup() { return _MasterGroups; }
SMasterGroup& getMasterGroup(uint8 i) { return _MasterGroups[i]; }
CInterfaceGroup* getWindowFromId (const std::string & groupId);
void addWindowToMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG);
void removeWindowFromMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG);
// access to control sheet selection
CCtrlSheetSelection &getCtrlSheetSelection() { return _CtrlSheetSelection; }
@ -267,7 +223,6 @@ public:
void removeAllDefines();
void removeAllTemplates();
void removeAllAnims();
void removeAllMasterGroups();
void removeAll();
// @}
@ -295,9 +250,6 @@ protected:
CViewPointer *_Pointer;
// Master groups encapsulate all windows
std::vector<SMasterGroup> _MasterGroups;
// Options description
std::map<std::string, NLMISC::CSmartPtr<CInterfaceOptions> > _OptionsMap;

View file

@ -2554,7 +2554,7 @@ int CLuaIHMRyzom::createRootGroupInstance(CLuaState &ls)
{
result->setId("ui:interface:"+string(ls.toString(2)));
result->updateCoords();
im->addWindowToMasterGroup("ui:interface", result);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", result);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(im->getElementFromId("ui:interface"));
result->setParent(pRoot);
if (pRoot)

View file

@ -432,7 +432,7 @@ void CModalContainerEditCmd::create(const std::string &name, bool bDefKey, bool
}
WinName = "ui:interface:" + name;
pIM->addWindowToMasterGroup("ui:interface", Win);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", Win);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
Win->setParent(pRoot);
pRoot->addGroup(Win);

View file

@ -100,7 +100,7 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha
// Root container
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(im->getElementFromId("ui:interface"));
im->addWindowToMasterGroup("ui:interface", gc);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", gc);
gc->setParent(pRoot);
pRoot->addGroup (gc);
}

View file

@ -0,0 +1,366 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "widget_manager.h"
#include "interface_group.h"
#include "group_container.h"
#include "group_in_scene.h"
CWidgetManager* CWidgetManager::instance = NULL;
// ----------------------------------------------------------------------------
// SMasterGroup
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void CWidgetManager::SMasterGroup::addWindow(CInterfaceGroup *pIG, uint8 nPrio)
{
nlassert(nPrio<WIN_PRIORITY_MAX);
// Priority WIN_PRIORITY_WORLD_SPACE is only for CGroupInScene !
// Add this group in another priority list
nlassert ((nPrio!=WIN_PRIORITY_MAX) || (dynamic_cast<CGroupInScene*>(pIG)!=NULL));
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
// If the element already exists in the list return !
if (*it == pIG)
return;
it++;
}
}
PrioritizedWindows[nPrio].push_back(pIG);
}
// ----------------------------------------------------------------------------
void CWidgetManager::SMasterGroup::delWindow(CInterfaceGroup *pIG)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if ((*it) == pIG)
{
PrioritizedWindows[i].erase(it);
return;
}
it++;
}
}
}
// ----------------------------------------------------------------------------
CInterfaceGroup* CWidgetManager::SMasterGroup::getWindowFromId(const std::string &winID)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if ((*it)->getId() == winID)
return *it;
it++;
}
}
return NULL;
}
// ----------------------------------------------------------------------------
bool CWidgetManager::SMasterGroup::isWindowPresent(CInterfaceGroup *pIG)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if ((*it) == pIG)
return true;
it++;
}
}
return false;
}
// Set a window top in its priority queue
// ----------------------------------------------------------------------------
void CWidgetManager::SMasterGroup::setTopWindow(CInterfaceGroup *pIG)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if (*it == pIG)
{
PrioritizedWindows[i].erase(it);
PrioritizedWindows[i].push_back(pIG);
LastTopWindowPriority= i;
return;
}
it++;
}
}
// todo hulud interface syntax error
nlwarning("window %s do not exist in a priority list", pIG->getId().c_str());
}
// ----------------------------------------------------------------------------
void CWidgetManager::SMasterGroup::setBackWindow(CInterfaceGroup *pIG)
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
if (*it == pIG)
{
PrioritizedWindows[i].erase(it);
PrioritizedWindows[i].push_front(pIG);
return;
}
it++;
}
}
// todo hulud interface syntax error
nlwarning("window %s do not exist in a priority list", pIG->getId().c_str());
}
// ----------------------------------------------------------------------------
void CWidgetManager::SMasterGroup::deactiveAllContainers()
{
std::vector<CGroupContainer*> gcs;
// Make first a list of all window (Warning: all group container are not window!)
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(*it);
if (pGC != NULL)
gcs.push_back(pGC);
it++;
}
}
// Then hide them. Must do this in 2 times, because setActive(false) change PrioritizedWindows,
// and hence invalidate its.
for (uint32 i = 0; i < gcs.size(); ++i)
{
gcs[i]->setActive(false);
}
}
// ----------------------------------------------------------------------------
void CWidgetManager::SMasterGroup::centerAllContainers()
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(*it);
if ((pGC != NULL) && (pGC->getParent() != NULL))
{
sint32 wParent = pGC->getParent()->getW(false);
sint32 w = pGC->getW(false);
pGC->setXAndInvalidateCoords((wParent - w) / 2);
sint32 hParent = pGC->getParent()->getH(false);
sint32 h = pGC->getH(false);
pGC->setYAndInvalidateCoords(h+(hParent - h) / 2);
}
it++;
}
}
}
// ----------------------------------------------------------------------------
void CWidgetManager::SMasterGroup::unlockAllContainers()
{
for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i)
{
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[i].begin();
while (it != PrioritizedWindows[i].end())
{
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(*it);
if (pGC != NULL)
pGC->setLocked(false);
it++;
}
}
}
class CElementToSort
{
public:
CInterfaceGroup *pIG;
float Distance;
bool operator< (const CElementToSort& other) const
{
// We want first farest views
return Distance > other.Distance;
}
};
void CWidgetManager::SMasterGroup::sortWorldSpaceGroup ()
{
static std::vector<CElementToSort> sortTable;
sortTable.clear ();
// Fill the sort table
std::list<CInterfaceGroup*>::iterator it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin();
while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end())
{
sortTable.push_back (CElementToSort ());
CElementToSort &elm = sortTable.back();
elm.pIG = *it;
elm.Distance = (static_cast<CGroupInScene*>(*it))->getDepthForZSort();
it++;
}
// Sort the table
std::sort (sortTable.begin(), sortTable.end());
// Fill the final table
uint i = 0;
it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin();
while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end())
{
*it = sortTable[i].pIG;
it++;
i++;
}
}
CWidgetManager* CWidgetManager::getInstance()
{
if( instance == NULL )
instance = new CWidgetManager;
return instance;
}
void CWidgetManager::release()
{
delete instance;
instance = NULL;
}
// ----------------------------------------------------------------------------
CInterfaceGroup* CWidgetManager::getMasterGroupFromId (const std::string &MasterGroupName)
{
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{
if (_MasterGroups[i].Group->getId() == MasterGroupName)
return _MasterGroups[i].Group;
}
return NULL;
}
// ----------------------------------------------------------------------------
CInterfaceGroup* CWidgetManager::getWindowFromId (const std::string & groupId)
{
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
CInterfaceGroup *pIG = rMG.getWindowFromId(groupId);
if (pIG != NULL)
return pIG;
}
return NULL;
}
// ----------------------------------------------------------------------------
void CWidgetManager::addWindowToMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG)
{
// Warning this function is not smart : its a o(n) !
if (pIG == NULL) return;
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getId() == sMasterGroupName)
{
rMG.addWindow(pIG, pIG->getPriority());
}
}
}
// ----------------------------------------------------------------------------
void CWidgetManager::removeWindowFromMasterGroup(const std::string &sMasterGroupName,CInterfaceGroup *pIG)
{
// Warning this function is not smart : its a o(n) !
if (pIG == NULL) return;
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup)
{
SMasterGroup &rMG = _MasterGroups[nMasterGroup];
if (rMG.Group->getId() == sMasterGroupName)
{
rMG.delWindow(pIG);
}
}
}
void unlinkAllContainers (CInterfaceGroup *pIG)
{
const std::vector<CInterfaceGroup*> &rG = pIG->getGroups();
for(uint i = 0; i < rG.size(); ++i)
unlinkAllContainers (rG[i]);
CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(pIG);
if (pGC != NULL)
pGC->removeAllContainers();
}
// ***************************************************************************
void CWidgetManager::removeAllMasterGroups()
{
uint i;
for (i = 0; i < _MasterGroups.size(); ++i)
unlinkAllContainers (_MasterGroups[i].Group);
// Yoyo: important to not Leave NULL in the array, because of CGroupHTML and LibWWW callback
// that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^)
while(!_MasterGroups.empty())
{
delete _MasterGroups.back().Group;
_MasterGroups.pop_back();
}
}
CWidgetManager::CWidgetManager()
{
}
CWidgetManager::~CWidgetManager()
{
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
{
delete _MasterGroups[i].Group;
}
}

View file

@ -0,0 +1,84 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef WIDGET_MANAGER_H
#define WIDGET_MANAGER_H
#include <string>
#include <vector>
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_common.h"
class CInterfaceGroup;
/// Manages the GUI widgets
class CWidgetManager{
public:
struct SMasterGroup
{
SMasterGroup()
{
Group = NULL;
LastTopWindowPriority = WIN_PRIORITY_NORMAL;
}
CInterfaceGroup *Group;
std::list< CInterfaceGroup* > PrioritizedWindows[ WIN_PRIORITY_MAX ];
void addWindow( CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL );
void delWindow( CInterfaceGroup *pIG );
CInterfaceGroup *getWindowFromId( const std::string &winID );
bool isWindowPresent( CInterfaceGroup *pIG );
// Set a window top in its priority queue
void setTopWindow( CInterfaceGroup *pIG );
void setBackWindow( CInterfaceGroup *pIG );
void deactiveAllContainers();
void centerAllContainers();
void unlockAllContainers();
// Sort the world space group
void sortWorldSpaceGroup ();
uint8 LastTopWindowPriority;
};
static CWidgetManager* getInstance();
static void release();
CInterfaceGroup* getMasterGroupFromId( const std::string &MasterGroupName );
std::vector< SMasterGroup > &getAllMasterGroup(){ return _MasterGroups; }
SMasterGroup& getMasterGroup( uint8 i ) { return _MasterGroups[ i ]; }
CInterfaceGroup* getWindowFromId( const std::string &groupId );
void addWindowToMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG );
void removeWindowFromMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG );
void removeAllMasterGroups();
private:
CWidgetManager();
~CWidgetManager();
static CWidgetManager *instance;
// Master groups encapsulate all windows
std::vector< SMasterGroup > _MasterGroups;
};
#endif

View file

@ -1285,7 +1285,7 @@ void impulseBeginTrade(NLMISC::CBitMemStream &impulse)
{
if (PermanentlyBanned) return;
//open trade window
CInterfaceGroup* win = CInterfaceManager::getInstance()->getWindowFromId("ui:interface:trade");
CInterfaceGroup* win = CWidgetManager::getInstance()->getWindowFromId("ui:interface:trade");
if (!win)
{
nlwarning("invalid interface ui:interface:trade");

View file

@ -441,7 +441,7 @@ void CDisplayerVisual::onPostRender()
else
{
// Link to the interface
pIM->addWindowToMasterGroup("ui:interface", group);
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId("ui:interface"));
group->setParent(pRoot);
if (pRoot)

View file

@ -636,6 +636,7 @@ void release()
NLNET::IModuleManager::releaseInstance();
delete &CLuaManager::getInstance();
NLGUI::CDBManager::release();
CWidgetManager::release();