void CGUIVisualisationControl::LoadVisualisation() { CSingleLock lock (m_critSection); if (m_pVisualisation) FreeVisualisation(); m_bInitialized = false; /* check if any other control beat us to the punch */ if(m_globalvis) return; CVisualisationFactory factory; CStdString strVisz; m_currentVis = g_guiSettings.GetString("mymusic.visualisation"); #ifdef HAS_KARAOKE if (g_application.m_pCdgParser && g_guiSettings.GetBool("karaoke.enabled")) { // if viz == none, then show the cdg backgound if (m_currentVis.Equals("None")) g_application.m_pCdgParser->SetBGTransparent(false); else g_application.m_pCdgParser->SetBGTransparent(true); } #endif if (m_currentVis.Equals("None")) return; strVisz.Format("Q:\\visualisations\\%s", m_currentVis.c_str()); m_pVisualisation = factory.LoadVisualisation(strVisz); if (m_pVisualisation) { if (m_pVisualisation->HandlesOwnDisplay() == false) g_graphicsContext.CaptureStateBlock(); float x = g_graphicsContext.ScaleFinalXCoord(GetXPosition(), GetYPosition()); float y = g_graphicsContext.ScaleFinalYCoord(GetXPosition(), GetYPosition()); float w = g_graphicsContext.ScaleFinalXCoord(GetXPosition() + GetWidth(), GetYPosition() + GetHeight()) - x; float h = g_graphicsContext.ScaleFinalYCoord(GetXPosition() + GetWidth(), GetYPosition() + GetHeight()) - y; if (x < 0) x = 0; if (y < 0) y = 0; if (x + w > g_graphicsContext.GetWidth()) w = g_graphicsContext.GetWidth() - x; if (y + h > g_graphicsContext.GetHeight()) h = g_graphicsContext.GetHeight() - y; #ifdef __APPLE__ // If it's handling its own display, make a child window for it to do so in. if (m_pVisualisation->HandlesOwnDisplay() == true) Cocoa_MakeChildWindow(); #endif m_pVisualisation->Create((int)(x+0.5f), (int)(y+0.5f), (int)(w+0.5f), (int)(h+0.5f)); if (m_pVisualisation->HandlesOwnDisplay() == false) g_graphicsContext.ApplyStateBlock(); VerifyGLState(); if (g_application.m_pPlayer) g_application.m_pPlayer->RegisterAudioCallback(this); // Create new audio buffers CreateBuffers(); m_globalvis = true; } // tell our app that we're back CGUIMessage msg(GUI_MSG_VISUALISATION_LOADED, 0, 0, 0, 0, m_pVisualisation); g_graphicsContext.SendMessage(msg); }
void CGUIVisualisationControl::LoadVisualisation() { CSingleLock lock (m_critSection); if (m_pVisualisation) FreeVisualisation(); m_bInitialized = false; /* check if any other control beat us to the punch */ if(m_globalvis) return; CVisualisationFactory factory; CStdString strVisz, strModule; m_currentVis = g_guiSettings.GetString("mymusic.visualisation"); if (m_currentVis.Equals("None")) return; // check if it's a multi-vis and if it is , get it's module name { int colonPos = m_currentVis.ReverseFind(":"); if ( colonPos > 0 ) { strModule = m_currentVis.Mid( colonPos+1 ); strVisz = m_currentVis.Mid( 0, colonPos ); m_pVisualisation = factory.LoadVisualisation(strVisz, strModule); } else { strVisz = m_currentVis; m_pVisualisation = factory.LoadVisualisation(strVisz); } } if (m_pVisualisation) { float z = 0; g_graphicsContext.CaptureStateBlock(); float x = GetXPosition(); float y = GetYPosition(); float w = GetXPosition() + GetWidth(); float h = GetYPosition() + GetHeight() - y; g_graphicsContext.ScaleFinalCoords(x, y, z); g_graphicsContext.ScaleFinalCoords(w, h, z); if (x < 0) x = 0; if (y < 0) y = 0; if (x + w > g_graphicsContext.GetWidth()) w = g_graphicsContext.GetWidth() - x; if (y + h > g_graphicsContext.GetHeight()) h = g_graphicsContext.GetHeight() - y; m_pVisualisation->Create((int)(x+0.5f), (int)(y+0.5f), (int)(w+0.5f), (int)(h+0.5f)); g_graphicsContext.ApplyStateBlock(); VerifyGLState(); if (g_application.m_pPlayer) g_application.m_pPlayer->RegisterAudioCallback(this); // Create new audio buffers CreateBuffers(); m_globalvis = true; m_bInitialized = true; } // tell our app that we're back CGUIMessage msg(GUI_MSG_VISUALISATION_LOADED, 0, 0, 0, 0, m_pVisualisation); g_windowManager.SendMessage(msg); }