Permalink
Browse files

add Register*, Translate* (name->vector pos), Get* methods in GUIInfo…

…Manager for SkinVariableString
  • Loading branch information...
1 parent 2741f73 commit 8db21b7f6c26a99b0e1a3e29adfb7ec1172faf82 @pieh pieh committed Sep 4, 2011
Showing with 43 additions and 0 deletions.
  1. +35 −0 xbmc/GUIInfoManager.cpp
  2. +8 −0 xbmc/GUIInfoManager.h
View
@@ -3668,6 +3668,8 @@ void CGUIInfoManager::Clear()
for (unsigned int i = 0; i < m_bools.size(); ++i)
delete m_bools[i];
m_bools.clear();
+
+ m_skinVariableStrings.clear();
}
void CGUIInfoManager::UpdateFPS()
@@ -4480,3 +4482,36 @@ bool CGUIInfoManager::GetLibraryBool(int condition)
}
return false;
}
+
+int CGUIInfoManager::RegisterSkinVariableString(const CSkinVariableString& info)
+{
+ CSingleLock lock(m_critInfo);
+ int id = TranslateSkinVariableString(info.GetName());
+ if (id != 0)
+ return id;
+
+ m_skinVariableStrings.push_back(info);
+ return CONDITIONAL_LABEL_START + m_skinVariableStrings.size() - 1;
+}
+
+int CGUIInfoManager::TranslateSkinVariableString(const CStdString& name)
+{
+ for (vector<CSkinVariableString>::const_iterator it = m_skinVariableStrings.begin();
+ it != m_skinVariableStrings.end(); ++it)
+ {
+ if (it->GetName().Equals(name))
+ return it - m_skinVariableStrings.begin() + CONDITIONAL_LABEL_START;
+ }
+ return 0;
+}
+
+CStdString CGUIInfoManager::GetSkinVariableString(int info, int contextWindow,
+ bool preferImage /*= false*/,
+ const CGUIListItem *item /*= NULL*/)
+{
+ info -= CONDITIONAL_LABEL_START;
+ if (info >= 0 && info < (int)m_skinVariableStrings.size())
+ return m_skinVariableStrings[info].GetValue(contextWindow, preferImage, item);
+
+ return "";
+}
View
@@ -32,6 +32,7 @@
#include "guilib/IMsgTargetCallback.h"
#include "inttypes.h"
#include "XBDateTime.h"
+#include "interfaces/info/SkinVariable.h"
#include <list>
#include <map>
@@ -492,6 +493,9 @@ namespace INFO
#define MUSICPLAYER_PROPERTY_OFFSET 900 // last 100 id's reserved for musicplayer props.
+#define CONDITIONAL_LABEL_START LISTITEM_END + 1 // 36001
+#define CONDITIONAL_LABEL_END 37000
+
// the multiple information vector
#define MULTI_INFO_START 40000
#define MULTI_INFO_END 99999
@@ -672,6 +676,9 @@ class CGUIInfoManager : public IMsgTargetCallback
int TranslateSingleString(const CStdString &strCondition);
+ int RegisterSkinVariableString(const INFO::CSkinVariableString& info);
+ int TranslateSkinVariableString(const CStdString& name);
+ CStdString GetSkinVariableString(int info, int contextWindow, bool preferImage = false, const CGUIListItem *item=NULL);
protected:
friend class INFO::InfoSingle;
bool GetBool(int condition, int contextWindow = 0, const CGUIListItem *item=NULL);
@@ -763,6 +770,7 @@ class CGUIInfoManager : public IMsgTargetCallback
int m_prevWindowID;
std::vector<INFO::InfoBool*> m_bools;
+ std::vector<INFO::CSkinVariableString> m_skinVariableStrings;
unsigned int m_updateTime;
int m_libraryHasMusic;

0 comments on commit 8db21b7

Please sign in to comment.