Skip to content

Commit

Permalink
Added CHDDirectory class and small tweaks
Browse files Browse the repository at this point in the history
- Added CHDDirectory class to get data from the XBox HDD (used for only skins atm).
- Small tweaks and clean ups.
- Added the English localization XML file.
  • Loading branch information
PuxleyMartin committed Jan 5, 2018
1 parent 1df9cdd commit 9e26ece
Show file tree
Hide file tree
Showing 41 changed files with 1,706 additions and 56 deletions.
1,299 changes: 1,299 additions & 0 deletions language/English/strings.xml

Large diffs are not rendered by default.

23 changes: 21 additions & 2 deletions xbmc360/Application.cpp
Expand Up @@ -191,6 +191,26 @@ void CApplication::LoadSkin(const CStdString& strSkin)
CLog::Log(LOGINFO, "Skin loaded...");
}

void CApplication::ReloadSkin()
{
CGUIMessage msg(GUI_MSG_LOAD_SKIN, -1, g_windowManager.GetActiveWindow());
g_windowManager.SendMessage(msg);

// Reload the skin, restoring the previously focused control. We need this as
// the window unload will reset all control states.
CGUIWindow* pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
int iCtrlID = pWindow->GetFocusedControlID();
g_application.LoadSkin(g_guiSettings.GetString("LookAndFeel.Skin"));
pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());

g_windowManager.ActivateWindow(/*pWindow->GetID()*/WINDOW_SETTINGS_APPEARANCE);
/* if (pWindow && pWindow->HasSaveLastControl())
{
CGUIMessage msg3(GUI_MSG_SETFOCUS, g_windowManager.GetActiveWindow(), iCtrlID, 0); //TODO
pWindow->OnMessage(msg3);
}*/
}

void CApplication::UnloadSkin()
{
g_windowManager.DeInitialize();
Expand All @@ -203,8 +223,7 @@ void CApplication::Process()
// Check if we need to load a new skin
if(m_dwSkinTime && GetTickCount() >= m_dwSkinTime)
{
CGUIMessage msg(GUI_MSG_LOAD_SKIN, -1, g_windowManager.GetActiveWindow());
g_windowManager.SendMessage(msg);
ReloadSkin();
}

// Check if we need to activate the screensaver (if enabled)
Expand Down
5 changes: 3 additions & 2 deletions xbmc360/Application.h
Expand Up @@ -17,6 +17,7 @@ class CApplication: public CXBApplicationEX, public IPlayerCallback, public IMsg
void DelayLoadSkin();
void CancelDelayLoadSkin();
void LoadSkin(const CStdString& strSkin);
void ReloadSkin();
void UnloadSkin();

virtual bool Initialize();
Expand Down Expand Up @@ -49,14 +50,14 @@ class CApplication: public CXBApplicationEX, public IPlayerCallback, public IMsg
void ResetScreenSaver();
bool ResetScreenSaverWindow();
bool IsInScreenSaver() { return m_bScreenSave; };
void CheckScreenSaver(); //TODO Make private?
void CheckScreenSaver();

DWORD m_dwSkinTime;
IPlayer* m_pPlayer;

protected:
void FatalErrorHandler(bool InitD3D);
void ActivateScreenSaver();
void ActivateScreenSaver();

bool m_bScreenSave;
CStdString m_screenSaverMode;
Expand Down
2 changes: 1 addition & 1 deletion xbmc360/ButtonTranslator.h
@@ -1,7 +1,7 @@
#ifndef BUTTONTRANSLATOR_H
#define BUTTONTRANSLATOR_H

#include "utils\stdafx.h"
#include "utils\Stdafx.h"
#include "utils\StdString.h"

struct CButtonAction
Expand Down
67 changes: 67 additions & 0 deletions xbmc360/FileItem.cpp
@@ -0,0 +1,67 @@
#include "FileItem.h"

CFileItem::CFileItem(void)
{
m_strPath = "";
}

CFileItem::CFileItem(const CStdString& strLabel)
{
m_strPath = "";
m_strLabel = strLabel;
}

CFileItem::~CFileItem()
{
}

/////////////////////////////////////////////////////////////////////////////////
/////
///// CFileItemList
/////
//////////////////////////////////////////////////////////////////////////////////

CFileItemList::CFileItemList()
{
}

CFileItemList::~CFileItemList()
{
Clear();
}

CFileItem* CFileItemList::operator[] (int iItem)
{
return Get(iItem);
}

CFileItem* CFileItemList::Get(int iItem)
{
return m_items[iItem];
}

void CFileItemList::Add(CFileItem* pItem)
{
m_items.push_back(pItem);
}

int CFileItemList::Size() const
{
return (int)m_items.size();
}

void CFileItemList::Clear()
{
if (m_items.size())
{
IVECFILEITEMS i;
i = m_items.begin();
while (i != m_items.end())
{
CFileItem* pItem = *i;
delete pItem;
i = m_items.erase(i);
}
m_map.clear();
}
}
64 changes: 64 additions & 0 deletions xbmc360/FileItem.h
@@ -0,0 +1,64 @@
#ifndef H_CFILEITEM
#define H_CFILEITEM

#include "guilib\GUIListItem.h"
#include <map>
#include <vector>

class CFileItem : public CGUIListItem
{
public:
CFileItem(void);
CFileItem(const CStdString& strLabel);
~CFileItem();

void SetPath(CStdString strPath) { m_strPath = strPath; };

private:
CStdString m_strPath;
};

/*!
\brief A vector of pointer to CFileItem
\sa CFileItem
*/
typedef std::vector<CFileItem*> VECFILEITEMS;

/*
\brief A map of pointers to CFileItem
\sa CFileItem
*/
typedef std::map<CStdString, CFileItem*> MAPFILEITEMS;

/*
\brief Pair for MAPFILEITEMS
\sa MAPFILEITEMS
*/
typedef std::pair<CStdString, CFileItem*> MAPFILEITEMSPAIR;

/*!
\brief Iterator for VECFILEITEMS
\sa CFileItemList
*/
typedef std::vector<CFileItem*>::iterator IVECFILEITEMS;

class CFileItemList : public CFileItem
{
public:
CFileItemList();
CFileItemList(const CStdString& strPath);
virtual ~CFileItemList();

CFileItem* operator[] (int iItem);

void Clear();
CFileItem* Get(int iItem);
void Add(CFileItem* pItem);
int Size() const;

private:
VECFILEITEMS m_items;
MAPFILEITEMS m_map;
};

#endif //H_CFILEITEM
2 changes: 1 addition & 1 deletion xbmc360/GUISettings.cpp
Expand Up @@ -36,7 +36,7 @@ CGUISettings::CGUISettings()
// Appearance settings
AddGroup(7, 480);
AddCategory(7,"LookAndFeel", 14037);
AddString(1, "LookAndFeel.Skin", 166, "Project Mayhem III", SPIN_CONTROL_TEXT);
AddString(1, "LookAndFeel.Skin", 166, DEFAULT_SKIN, SPIN_CONTROL_TEXT);
AddString(2, "LookAndFeel.Language", 248, "English", SPIN_CONTROL_TEXT);
}

Expand Down
1 change: 1 addition & 0 deletions xbmc360/GUISettings.h
Expand Up @@ -3,6 +3,7 @@

#include "utils\StdString.h"
#include "guilib\tinyxml\tinyxml.h"
#include "Settings.h"

#include <map>
#include <vector>
Expand Down
2 changes: 2 additions & 0 deletions xbmc360/Settings.h
Expand Up @@ -4,6 +4,8 @@
#include "utils\StdString.h"
#include "guilib\tinyxml\tinyxml.h"

#define DEFAULT_SKIN "Project Mayhem III"

class CSettings
{
public:
Expand Down
2 changes: 1 addition & 1 deletion xbmc360/XBApplicationEx.h
@@ -1,7 +1,7 @@
#ifndef H_CXBAPPLICATIONEX
#define H_CXBAPPLICATIONEX

#include "utils\stdafx.h"
#include "utils\Stdafx.h"
#include "xbox\XBInput.h"
#include <xui.h>

Expand Down
2 changes: 1 addition & 1 deletion xbmc360/cores/DVDPlayer/DVDClock.cpp
@@ -1,4 +1,4 @@
#include "..\..\utils\stdafx.h"
#include "..\..\utils\Stdafx.h"
#include "DVDClock.h"
#include <math.h>

Expand Down
2 changes: 1 addition & 1 deletion xbmc360/cores/VideoRenderers/BaseRenderer.h
@@ -1,7 +1,7 @@
#ifndef CBASERENDERER_H
#define CBASERENDERER_H

#include "..\..\utils\stdafx.h"
#include "..\..\utils\Stdafx.h"

typedef struct RGB32Image_s
{
Expand Down
2 changes: 1 addition & 1 deletion xbmc360/cores/VideoRenderers/RGBRenderer.h
Expand Up @@ -2,7 +2,7 @@
#define RGB_RENDERER_H

#include "BaseRenderer.h"
#include "..\..\Utils\stdafx.h"
#include "..\..\Utils\Stdafx.h"

class CRGBRenderer : public CBaseRenderer
{
Expand Down
93 changes: 93 additions & 0 deletions xbmc360/filesystem/HDDirectory.cpp
@@ -0,0 +1,93 @@
#include "HDDirectory.h"
#include "..\utils\Stdafx.h"
#include "..\utils\URIUtils.h"

using namespace XFILE;

CHDDirectory::CHDDirectory(void)
{
}

CHDDirectory::~CHDDirectory(void)
{
}

bool CHDDirectory::GetDirectory(const CStdString& strPath1, CFileItemList &items)
{
WIN32_FIND_DATA wfd;
HANDLE hFind;

CStdString strPath=strPath1;
CStdString strRoot = strPath;

memset(&wfd, 0, sizeof(wfd));
URIUtils::AddSlashAtEnd(strRoot);
strRoot.Replace("/", "\\");

CStdString strSearchMask = strRoot;
strSearchMask += "*.*";

hFind = FindFirstFile(strSearchMask.c_str(), &wfd);

if (INVALID_HANDLE_VALUE == hFind)
return false;

// List all the files in the directory with some info about them.
do
{
if (wfd.cFileName[0] != 0)
{
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
CStdString strLabel=wfd.cFileName;
CFileItem* pItem(new CFileItem(strLabel));
CStdString itemPath = strRoot + wfd.cFileName;
pItem->m_bIsFolder = true;
URIUtils::AddSlashAtEnd(itemPath);
pItem->SetPath(itemPath);
// FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localTime); //TODO
// pItem->m_dateTime=localTime; //TODO

items.Add(pItem);
}
else
{
CStdString strLabel=wfd.cFileName;
CFileItem* pItem(new CFileItem(strLabel));
CStdString itemPath = strRoot + wfd.cFileName;
pItem->SetPath(itemPath);
pItem->m_bIsFolder = false;
// pItem->m_dwSize = CUtil::ToInt64(wfd.nFileSizeHigh, wfd.nFileSizeLow); //TODO
// FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localTime); //TODO
// pItem->m_dateTime=localTime; //TODO

items.Add(pItem);
}
}
}
while (FindNextFile(hFind, &wfd) != 0);

FindClose(hFind);

return true;
}

bool CHDDirectory::Exists(const char* strPath)
{
if (!strPath || !*strPath)
return false;

CStdString strReplaced=strPath;
// g_charsetConverter.utf8ToStringCharset(strReplaced); //TODO

strReplaced.Replace("/","\\");

URIUtils::AddSlashAtEnd(strReplaced);

DWORD attributes = GetFileAttributes(strReplaced.c_str());

if (FILE_ATTRIBUTE_DIRECTORY & attributes)
return true;

return false;
}
22 changes: 22 additions & 0 deletions xbmc360/filesystem/HDDirectory.h
@@ -0,0 +1,22 @@
#ifndef H_CHDDDIRECTORY
#define H_CHDDDIRECTORY

#include "..\utils\StdString.h"
#include "..\FileItem.h"

namespace XFILE
{

class CHDDirectory
{
public:
CHDDirectory(void);
~CHDDirectory(void);

bool GetDirectory(const CStdString& strPath, CFileItemList &items);
bool Exists(const char* strPath);
};

}

#endif //H_CHDDDIRECTORY
2 changes: 1 addition & 1 deletion xbmc360/guilib/GUID3DTexture.h
@@ -1,7 +1,7 @@
#ifndef GUILIB_GUID3DTEXTURE_H
#define GUILIB_GUID3DTEXTURE_H

#include "..\utils\stdafx.h"
#include "..\utils\Stdafx.h"
#include "GUITexture.h"

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion xbmc360/guilib/GUIFont.cpp
Expand Up @@ -87,7 +87,7 @@ bool CGUIFont::DrawText( float fPosX, float fPosY, DWORD dwColor, const CStdStri

if(dwFlags & XUI_FONT_STYLE_RIGHT_ALIGN) //HACK: Using XUI to do this should be easy, but it's a pain in the butt...
{
clipRect.right = g_graphicsContext.GetWidth() - fPosX + 131;
clipRect.right = g_graphicsContext.GetWidth() - fPosX + clipRect.GetWidth();
fPosX = fPosX - clipRect.GetWidth();
}

Expand Down

0 comments on commit 9e26ece

Please sign in to comment.