8d9bf11a6861cbc3694dcf3ab05d437be802a84b
[vuplus_xbmc] / xbmc / addons / Skin.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://www.xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "Addon.h"
24 #include "guilib/GraphicContext.h" // needed for the RESOLUTION members
25 #include "guilib/GUIIncludes.h"    // needed for the GUIInclude member
26 #define CREDIT_LINE_LENGTH 50
27
28 class TiXmlNode;
29
30 namespace ADDON
31 {
32
33 class CSkinInfo : public CAddon
34 {
35 public:
36   class CStartupWindow
37   {
38   public:
39     CStartupWindow(int id, const CStdString &name)
40     {
41       m_id = id; m_name = name;
42     };
43     int m_id;
44     CStdString m_name;
45   };
46
47   //FIXME remove this, kept for current repo handling
48   CSkinInfo(const ADDON::AddonProps &props, const RESOLUTION_INFO &res = RESOLUTION_INFO());
49   CSkinInfo(const cp_extension_t *ext);
50   virtual ~CSkinInfo();
51
52   /*! \brief Load resultion information from directories in Path().
53    */
54   void Start();
55
56   bool HasSkinFile(const CStdString &strFile) const;
57
58   /*! \brief Get the full path to the specified file in the skin
59    We search for XML files in the skin folder that best matches the current resolution.
60    \param file XML file to look for
61    \param res [out] If non-NULL, the resolution that the returned XML file is in is returned.  Defaults to NULL.
62    \param baseDir [in] If non-empty, the given directory is searched instead of the skin's directory.  Defaults to empty.
63    \return path to the XML file
64    */
65   CStdString GetSkinPath(const CStdString& file, RESOLUTION_INFO *res = NULL, const CStdString& baseDir = "") const;
66
67   double GetVersion() const { return m_Version; };
68
69   /*! \brief Return whether skin debugging is enabled
70    \return true if skin debugging (set via <debugging>true</debugging> in skin.xml) is enabled.
71    */
72   bool IsDebugging() const { return m_debugging; };
73
74   /*! \brief Get the id of the first window to load
75    The first window is generally Startup.xml unless it doesn't exist or if the skinner
76    has specified which start windows they support and the user is going to somewhere other
77    than the home screen.
78    \return id of the first window to load
79    */
80   int GetFirstWindow() const;
81
82   /*! \brief Get the id of the window the user wants to start in after any skin animation
83    \return id of the start window
84    */
85   int GetStartWindow() const;
86
87   /*! \brief Translate a resolution string
88    \param name the string to translate
89    \param res [out] the resolution structure if name is valid
90    \return true if the resolution is valid, false otherwise
91    */
92   static bool TranslateResolution(const CStdString &name, RESOLUTION_INFO &res);
93
94   void ResolveIncludes(TiXmlElement *node, std::map<int, bool>* xmlIncludeConditions = NULL);
95
96   float GetEffectsSlowdown() const { return m_effectsSlowDown; };
97
98   const std::vector<CStartupWindow> &GetStartupWindows() const { return m_startupWindows; };
99
100   /*! \brief Retrieve the skin paths to search for skin XML files
101    \param paths [out] vector of paths to search, in order.
102    */
103   void GetSkinPaths(std::vector<CStdString> &paths) const;
104
105   bool IsInUse() const;
106
107   const CStdString& GetCurrentAspect() const { return m_currentAspect; }
108
109 //  static bool Check(const CStdString& strSkinDir); // checks if everything is present and accounted for without loading the skin
110   static double GetMinVersion();
111   void LoadIncludes();
112   const INFO::CSkinVariableString* CreateSkinVariable(const CStdString& name, int context);
113 protected:
114   /*! \brief Given a resolution, retrieve the corresponding directory name
115    \param res RESOLUTION to translate
116    \return directory name for res
117    */
118   CStdString GetDirFromRes(RESOLUTION res) const;
119
120   /*! \brief grab a resolution tag from a skin's configuration data
121    \param props passed addoninfo structure to check for resolution
122    \param tag name of the tag to look for
123    \param res resolution to return
124    \return true if we find a valid resolution, false otherwise
125    */
126   void GetDefaultResolution(const cp_extension_t *ext, const char *tag, RESOLUTION &res, const RESOLUTION &def) const;
127
128   bool LoadStartupWindows(const cp_extension_t *ext);
129
130   RESOLUTION_INFO m_defaultRes;
131   std::vector<RESOLUTION_INFO> m_resolutions;
132
133   double m_Version;
134
135   float m_effectsSlowDown;
136   CGUIIncludes m_includes;
137   CStdString m_currentAspect;
138
139   std::vector<CStartupWindow> m_startupWindows;
140   bool m_onlyAnimateToHome;
141   bool m_debugging;
142 };
143
144 } /*namespace ADDON*/
145
146 extern boost::shared_ptr<ADDON::CSkinInfo> g_SkinInfo;