Skip to content

Instantly share code, notes, and snippets.

@MilhouseVH
Last active July 12, 2016 20:35
Show Gist options
  • Save MilhouseVH/808e2c097178f47cd7792578079ed20b to your computer and use it in GitHub Desktop.
Save MilhouseVH/808e2c097178f47cd7792578079ed20b to your computer and use it in GitHub Desktop.
diff --git a/xbmc/dbwrappers/Database.cpp b/xbmc/dbwrappers/Database.cpp
index 4dc71c5..ef77953 100644
--- a/xbmc/dbwrappers/Database.cpp
+++ b/xbmc/dbwrappers/Database.cpp
@@ -29,6 +29,7 @@
#include "sqlitedataset.h"
#include "DatabaseManager.h"
#include "DbUrl.h"
+#include "utils/Splash.h"
#ifdef HAS_MYSQL
#include "mysqldataset.h"
@@ -367,6 +368,7 @@ bool CDatabase::Update(const DatabaseSettings &settings)
while (version >= GetMinSchemaVersion())
{
+ std::string splashmsg;
std::string dbName = dbSettings.name;
if (version)
dbName += StringUtils::Format("%d", version);
@@ -378,6 +380,10 @@ bool CDatabase::Update(const DatabaseSettings &settings)
{
CLog::Log(LOGNOTICE, "Old database found - updating from version %i to %i", version, GetSchemaVersion());
+ splashmsg = "Database migration in progress - please wait...";
+ splashmsg += "\nMigrating database " + dbSettings.name + " from v" + StringUtils::Format("%d", version) + " to v" + StringUtils::Format("%d", GetSchemaVersion());
+ CSplash::GetInstance().Show(splashmsg);
+
bool copy_fail = false;
try
diff --git a/xbmc/utils/Splash.cpp b/xbmc/utils/Splash.cpp
index 7e1d885..c06eb77 100644
--- a/xbmc/utils/Splash.cpp
+++ b/xbmc/utils/Splash.cpp
@@ -30,13 +30,16 @@
using namespace XFILE;
CSplash::CSplash()
- : m_image(nullptr)
{
+ m_messageLayout = NULL;
+ m_image = NULL;
+ m_layoutWasLoading = false;
}
CSplash::~CSplash()
{
delete m_image;
+ delete m_messageLayout;
}
CSplash& CSplash::GetInstance()
@@ -47,6 +50,11 @@ CSplash& CSplash::GetInstance()
void CSplash::Show()
{
+ Show("");
+}
+
+void CSplash::Show(const std::string& message)
+{
if (!m_image)
{
std::string splashImage = "special://home/media/Splash.png";
@@ -70,6 +78,34 @@ void CSplash::Show()
m_image->Render();
m_image->FreeResources();
+ // render message
+ if (!message.empty())
+ {
+ if (!m_layoutWasLoading)
+ {
+ // load arial font, white body, no shadow, size: 20, no additional styling
+ CGUIFont *messageFont = g_fontManager.LoadTTF("__splash__", "arial.ttf", 0xFFFFFFFF, 0, 24, FONT_STYLE_NORMAL, false, 1.0f, 1.0f, &res);
+ if (messageFont)
+ m_messageLayout = new CGUITextLayout(messageFont, true, 0);
+ m_layoutWasLoading = true;
+ }
+ if (m_messageLayout)
+ {
+ m_messageLayout->Update(message, 1150, false, true);
+ float textWidth, textHeight;
+ m_messageLayout->GetTextExtent(textWidth, textHeight);
+
+ int width = g_graphicsContext.GetWidth();
+ int height = g_graphicsContext.GetHeight();
+
+ // ideally place text in center of empty area below splash image
+ float y = m_image->GetTextureHeight() - 180;
+ if (y + textHeight > height) // make sure entire text is visible
+ y = height - textHeight - 30; // -30 for safe viewing area
+ m_messageLayout->RenderOutline(width/2, y, 0, 0xFF000000, XBFONT_CENTER_X, width);
+ }
+ }
+
//show it on screen
g_Windowing.EndRender();
g_graphicsContext.Flip(true, false);
diff --git a/xbmc/utils/Splash.h b/xbmc/utils/Splash.h
index d8c81c2..66fbae0 100644
--- a/xbmc/utils/Splash.h
+++ b/xbmc/utils/Splash.h
@@ -22,6 +22,7 @@
#include <string>
+class CGUITextLayout;
class CGUIImage;
class CSplash
@@ -30,6 +31,7 @@ public:
static CSplash& GetInstance();
void Show();
+ void Show(const std::string& message);
protected:
CSplash();
@@ -38,5 +40,7 @@ protected:
virtual ~CSplash();
private:
+ CGUITextLayout* m_messageLayout;
CGUIImage* m_image;
+ bool m_layoutWasLoading;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment