Changed: Make number of virtual desktops dynamic

--HG--
branch : develop
This commit is contained in:
Nimetu 2018-03-15 21:58:49 +02:00
parent 23fa3d7460
commit 4851d1602d
3 changed files with 35 additions and 15 deletions

View file

@ -896,11 +896,8 @@ bool CChatGroupWindow::removeFreeTeller(const std::string &containerID)
if (i == _FreeTellers.size()) if (i == _FreeTellers.size())
return false; return false;
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
// Create the free teller in all the desktops images pIM->removeGroupContainerImageFromDesktops(_FreeTellers[i]->getId());
for (uint m = 0; m < MAX_NUM_MODES; ++m)
{
pIM->removeGroupContainerImage(_FreeTellers[i]->getId(), m);
}
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface")); CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface"));
CWidgetManager::getInstance()->unMakeWindow(_FreeTellers[i]); CWidgetManager::getInstance()->unMakeWindow(_FreeTellers[i]);
pRoot->delGroup (_FreeTellers[i]); pRoot->delGroup (_FreeTellers[i]);

View file

@ -502,6 +502,7 @@ CInterfaceManager::CInterfaceManager()
CViewRenderer::getInstance()->init(); CViewRenderer::getInstance()->init();
_CurrentMode = 0; _CurrentMode = 0;
_Modes.resize(MAX_NUM_MODES);
setInGame( false ); setInGame( false );
@ -1700,6 +1701,11 @@ bool CInterfaceManager::loadConfig (const string &filename)
f.serialCheck(NELID("GFCI")); f.serialCheck(NELID("GFCI"));
f.serial(nNbMode); f.serial(nNbMode);
f.serial(_CurrentMode); f.serial(_CurrentMode);
if (_CurrentMode > nNbMode)
{
_CurrentMode = 0;
}
if(ver>=10) if(ver>=10)
{ {
f.serial(_LastInGameScreenW); f.serial(_LastInGameScreenW);
@ -1707,10 +1713,16 @@ bool CInterfaceManager::loadConfig (const string &filename)
lastInGameScreenResLoaded= true; lastInGameScreenResLoaded= true;
} }
// Initialize at least number of modes that are saved in stream
_Modes.resize(std::max((uint32)MAX_NUM_MODES, nNbMode));
for (uint32 i = 0; i < _Modes.size(); ++i)
{
NLMISC::contReset(_Modes[i]);
}
// Load All Window configuration of all Modes // Load All Window configuration of all Modes
for (uint32 i = 0; i < nNbMode; ++i) for (uint32 i = 0; i < nNbMode; ++i)
{ {
NLMISC::contReset(_Modes[i]);
// must create a tmp mem stream because desktop image expect its datas to occupy the whole stream // must create a tmp mem stream because desktop image expect its datas to occupy the whole stream
// This is because of old system that manipulated desktop image direclty as a mem stream // This is because of old system that manipulated desktop image direclty as a mem stream
CMemStream ms; CMemStream ms;
@ -1890,7 +1902,7 @@ bool CInterfaceManager::saveConfig (const string &filename)
// cleanup all desktops // cleanup all desktops
for(uint k = 0; k < MAX_NUM_MODES; ++k) for(uint k = 0; k < _Modes.size(); ++k)
{ {
quitVisitor.Desktop = k; quitVisitor.Desktop = k;
setMode(k); setMode(k);
@ -1919,7 +1931,7 @@ bool CInterfaceManager::saveConfig (const string &filename)
uint32 i; uint32 i;
i = MAX_NUM_MODES; i = _Modes.size();
try try
{ {
f.serialVersion(ICFG_STREAM_VERSION); f.serialVersion(ICFG_STREAM_VERSION);
@ -1941,7 +1953,7 @@ bool CInterfaceManager::saveConfig (const string &filename)
f.serial(_LastInGameScreenH); f.serial(_LastInGameScreenH);
// Save All Window configuration of all Modes // Save All Window configuration of all Modes
for (i = 0; i < MAX_NUM_MODES; ++i) for (i = 0; i < _Modes.size(); ++i)
{ {
// must create a tmp mem stream because desktop image expect its datas to occupy the whole stream // must create a tmp mem stream because desktop image expect its datas to occupy the whole stream
// This is because of old system that manipulated desktop image direclty as a mem stream // This is because of old system that manipulated desktop image direclty as a mem stream
@ -2065,7 +2077,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event)
void CInterfaceManager::updateDesktops( uint32 newScreenW, uint32 newScreenH ) void CInterfaceManager::updateDesktops( uint32 newScreenW, uint32 newScreenH )
{ {
// *** Do it for All Backuped Desktops // *** Do it for All Backuped Desktops
for(uint md=0;md<MAX_NUM_MODES;md++) for(uint md=0; md<_Modes.size(); md++)
{ {
CInterfaceConfig::CDesktopImage &mode= _Modes[md]; CInterfaceConfig::CDesktopImage &mode= _Modes[md];
// For all containers of this mode // For all containers of this mode
@ -2413,7 +2425,7 @@ void CInterfaceManager::launchContextMenuInGame (const std::string &nameOfCM)
// *************************************************************************** // ***************************************************************************
void CInterfaceManager::updateGroupContainerImage(CGroupContainer &gc, uint8 mode) void CInterfaceManager::updateGroupContainerImage(CGroupContainer &gc, uint8 mode)
{ {
if (mode >= MAX_NUM_MODES) if (mode >= _Modes.size())
{ {
nlwarning("wrong desktop"); nlwarning("wrong desktop");
return; return;
@ -2424,7 +2436,7 @@ void CInterfaceManager::updateGroupContainerImage(CGroupContainer &gc, uint8 mod
// *************************************************************************** // ***************************************************************************
void CInterfaceManager::removeGroupContainerImage(const std::string &groupName, uint8 mode) void CInterfaceManager::removeGroupContainerImage(const std::string &groupName, uint8 mode)
{ {
if (mode >= MAX_NUM_MODES) if (mode >= _Modes.size())
{ {
nlwarning("wrong desktop"); nlwarning("wrong desktop");
return; return;
@ -2433,10 +2445,19 @@ void CInterfaceManager::removeGroupContainerImage(const std::string &groupName,
} }
// ***************************************************************************
void CInterfaceManager::removeGroupContainerImageFromDesktops(const std::string &groupName)
{
for (uint i = 0; i < _Modes.size(); i++)
{
_Modes[i].removeGroupContainerImage(groupName);
}
}
// *************************************************************************** // ***************************************************************************
void CInterfaceManager::setMode(uint8 newMode) void CInterfaceManager::setMode(uint8 newMode)
{ {
if (newMode >= MAX_NUM_MODES) if (newMode >= _Modes.size())
return; return;
if (newMode == _CurrentMode) if (newMode == _CurrentMode)
@ -2501,7 +2522,7 @@ void CInterfaceManager::setMode(uint8 newMode)
// *************************************************************************** // ***************************************************************************
void CInterfaceManager::resetMode(uint8 newMode) void CInterfaceManager::resetMode(uint8 newMode)
{ {
if (newMode >= MAX_NUM_MODES) if (newMode >= _Modes.size())
return; return;
NLMISC::contReset(_Modes[newMode]); NLMISC::contReset(_Modes[newMode]);
} }

View file

@ -316,6 +316,8 @@ public:
// Remove a group container from a virtual desktop image // Remove a group container from a virtual desktop image
// \param mode Index of the virtual desktop // \param mode Index of the virtual desktop
void removeGroupContainerImage(const std::string &groupName, uint8 mode); void removeGroupContainerImage(const std::string &groupName, uint8 mode);
// Remove group container from all virtual desktops
void removeGroupContainerImageFromDesktops(const std::string &groupName);
@ -583,7 +585,7 @@ private:
sint32 _LastInGameScreenW, _LastInGameScreenH; // Resolution used for last InGame interface sint32 _LastInGameScreenW, _LastInGameScreenH; // Resolution used for last InGame interface
// Modes // Modes
CInterfaceConfig::CDesktopImage _Modes[MAX_NUM_MODES]; std::vector<CInterfaceConfig::CDesktopImage> _Modes;
uint8 _CurrentMode; uint8 _CurrentMode;
// true when interface manager is running 'ingame' content // true when interface manager is running 'ingame' content