Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-on content language support + browser filter support #877

Merged
2 commits merged into from Apr 30, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions addons/skin.confluence/720p/AddonBrowser.xml
Expand Up @@ -83,6 +83,13 @@
<include>ButtonCommonValues</include> <include>ButtonCommonValues</include>
<label>25000</label> <label>25000</label>
</control> </control>
<control type="radiobutton" id ="7">
<description>Hide foreign</description>
<posx>0</posx>
<posy>210</posy>
<include>ButtonCommonValues</include>
<label>25001</label>
</control>
<include>CommonNowPlaying_Controls</include> <include>CommonNowPlaying_Controls</include>
</control> </control>
</control> </control>
Expand Down
1 change: 1 addition & 0 deletions language/English/strings.xml
Expand Up @@ -2252,6 +2252,7 @@
<string id="24100">To use this feature you must download an Add-on:</string> <string id="24100">To use this feature you must download an Add-on:</string>
<string id="24101">Would you like to download this Add-on?</string> <string id="24101">Would you like to download this Add-on?</string>
<string id="25000">Notifications</string> <string id="25000">Notifications</string>
<string id="25001">Hide foreign</string>


<!-- strings 29800 thru 29998 reserved strings used only in the default Project Mayhem III skin and not c++ code --> <!-- strings 29800 thru 29998 reserved strings used only in the default Project Mayhem III skin and not c++ code -->
<string id="29800">Library Mode</string> <string id="29800">Library Mode</string>
Expand Down
4 changes: 4 additions & 0 deletions xbmc/addons/Addon.cpp
Expand Up @@ -151,6 +151,10 @@ AddonProps::AddonProps(const cp_extension_t *ext)
description = CAddonMgr::Get().GetTranslatedString(metadata->configuration, "description"); description = CAddonMgr::Get().GetTranslatedString(metadata->configuration, "description");
disclaimer = CAddonMgr::Get().GetTranslatedString(metadata->configuration, "disclaimer"); disclaimer = CAddonMgr::Get().GetTranslatedString(metadata->configuration, "disclaimer");
license = CAddonMgr::Get().GetExtValue(metadata->configuration, "license"); license = CAddonMgr::Get().GetExtValue(metadata->configuration, "license");
CStdString language;
language = CAddonMgr::Get().GetExtValue(metadata->configuration, "language");
if (!language.IsEmpty())
extrainfo.insert(make_pair("language",language));
broken = CAddonMgr::Get().GetExtValue(metadata->configuration, "broken"); broken = CAddonMgr::Get().GetExtValue(metadata->configuration, "broken");
EMPTY_IF("nofanart",fanart) EMPTY_IF("nofanart",fanart)
EMPTY_IF("noicon",icon) EMPTY_IF("noicon",icon)
Expand Down
4 changes: 4 additions & 0 deletions xbmc/addons/AddonDatabase.cpp
Expand Up @@ -558,6 +558,10 @@ void CAddonDatabase::SetPropertiesFromAddon(const AddonPtr& addon,
pItem->SetProperty("Addon.StarRating",starrating); pItem->SetProperty("Addon.StarRating",starrating);
pItem->SetProperty("Addon.Path", addon->Path()); pItem->SetProperty("Addon.Path", addon->Path());
pItem->SetProperty("Addon.Broken", addon->Props().broken); pItem->SetProperty("Addon.Broken", addon->Props().broken);
std::map<CStdString,CStdString>::iterator it =
addon->Props().extrainfo.find("language");
if (it != addon->Props().extrainfo.end())
pItem->SetProperty("Addon.Language", it->second);
} }


bool CAddonDatabase::DisableAddon(const CStdString &addonID, bool disable /* = true */) bool CAddonDatabase::DisableAddon(const CStdString &addonID, bool disable /* = true */)
Expand Down
46 changes: 44 additions & 2 deletions xbmc/addons/GUIWindowAddonBrowser.cpp
Expand Up @@ -48,9 +48,11 @@
#include "settings/AdvancedSettings.h" #include "settings/AdvancedSettings.h"
#include "storage/MediaManager.h" #include "storage/MediaManager.h"
#include "settings/GUISettings.h" #include "settings/GUISettings.h"
#include "LangInfo.h"


#define CONTROL_AUTOUPDATE 5 #define CONTROL_AUTOUPDATE 5
#define CONTROL_SHUTUP 6 #define CONTROL_SHUTUP 6
#define CONTROL_FOREIGNFILTER 7


using namespace ADDON; using namespace ADDON;
using namespace XFILE; using namespace XFILE;
Expand Down Expand Up @@ -100,6 +102,13 @@ bool CGUIWindowAddonBrowser::OnMessage(CGUIMessage& message)
g_settings.Save(); g_settings.Save();
return true; return true;
} }
else if (iControl == CONTROL_FOREIGNFILTER)
{
g_settings.m_bAddonForeignFilter = !g_settings.m_bAddonForeignFilter;
g_settings.Save();
Update(m_vecItems->GetPath());
return true;
}
else if (m_viewControl.HasControl(iControl)) // list/thumb control else if (m_viewControl.HasControl(iControl)) // list/thumb control
{ {
// get selected item // get selected item
Expand Down Expand Up @@ -246,9 +255,23 @@ void CGUIWindowAddonBrowser::UpdateButtons()
{ {
SET_CONTROL_SELECTED(GetID(),CONTROL_AUTOUPDATE,g_settings.m_bAddonAutoUpdate); SET_CONTROL_SELECTED(GetID(),CONTROL_AUTOUPDATE,g_settings.m_bAddonAutoUpdate);
SET_CONTROL_SELECTED(GetID(),CONTROL_SHUTUP,g_settings.m_bAddonNotifications); SET_CONTROL_SELECTED(GetID(),CONTROL_SHUTUP,g_settings.m_bAddonNotifications);
SET_CONTROL_SELECTED(GetID(),CONTROL_FOREIGNFILTER,g_settings.m_bAddonForeignFilter);
CGUIMediaWindow::UpdateButtons(); CGUIMediaWindow::UpdateButtons();
} }


static bool FilterVar(bool valid, const CVariant& variant,
const std::string& check)
{
if (!valid)
return false;

if (variant.isNull() || variant.asString().empty())
return false;

std::string regions = variant.asString();
return regions.find(check) == std::string::npos;
}

bool CGUIWindowAddonBrowser::GetDirectory(const CStdString& strDirectory, bool CGUIWindowAddonBrowser::GetDirectory(const CStdString& strDirectory,
CFileItemList& items) CFileItemList& items)
{ {
Expand All @@ -275,7 +298,26 @@ bool CGUIWindowAddonBrowser::GetDirectory(const CStdString& strDirectory,


} }
else else
{
result = CGUIMediaWindow::GetDirectory(strDirectory,items); result = CGUIMediaWindow::GetDirectory(strDirectory,items);
if (g_settings.m_bAddonForeignFilter)
{
int i=0;
while (i < items.Size())
{
if (FilterVar(g_settings.m_bAddonForeignFilter,
items[i]->GetProperty("Addon.Language"), "en") ||
FilterVar(g_settings.m_bAddonForeignFilter,
items[i]->GetProperty("Addon.Language"),
g_langInfo.GetLanguageLocale()))
{
items.Remove(i);
}
else
i++;
}
}
}


if (strDirectory.IsEmpty() && CAddonInstaller::Get().IsDownloading()) if (strDirectory.IsEmpty() && CAddonInstaller::Get().IsDownloading())
{ {
Expand Down
3 changes: 3 additions & 0 deletions xbmc/settings/Settings.cpp
Expand Up @@ -93,6 +93,7 @@ void CSettings::Initialize()
m_bStartVideoWindowed = false; m_bStartVideoWindowed = false;
m_bAddonAutoUpdate = true; m_bAddonAutoUpdate = true;
m_bAddonNotifications = true; m_bAddonNotifications = true;
m_bAddonForeignFilter = false;


m_nVolumeLevel = 0; m_nVolumeLevel = 0;
m_dynamicRangeCompressionLevel = 0; m_dynamicRangeCompressionLevel = 0;
Expand Down Expand Up @@ -667,6 +668,7 @@ bool CSettings::LoadSettings(const CStdString& strSettingsFile)
GetInteger(pElement, "httpapibroadcastport", m_HttpApiBroadcastPort, 8278, 1, 65535); GetInteger(pElement, "httpapibroadcastport", m_HttpApiBroadcastPort, 8278, 1, 65535);
XMLUtils::GetBoolean(pElement, "addonautoupdate", m_bAddonAutoUpdate); XMLUtils::GetBoolean(pElement, "addonautoupdate", m_bAddonAutoUpdate);
XMLUtils::GetBoolean(pElement, "addonnotifications", m_bAddonNotifications); XMLUtils::GetBoolean(pElement, "addonnotifications", m_bAddonNotifications);
XMLUtils::GetBoolean(pElement, "addonforeignfilter", m_bAddonForeignFilter);
} }


pElement = pRootElement->FirstChildElement("defaultvideosettings"); pElement = pRootElement->FirstChildElement("defaultvideosettings");
Expand Down Expand Up @@ -870,6 +872,7 @@ bool CSettings::SaveSettings(const CStdString& strSettingsFile, CGUISettings *lo
XMLUtils::SetInt(pNode, "httpapibroadcastlevel", m_HttpApiBroadcastLevel); XMLUtils::SetInt(pNode, "httpapibroadcastlevel", m_HttpApiBroadcastLevel);
XMLUtils::SetBoolean(pNode, "addonautoupdate", m_bAddonAutoUpdate); XMLUtils::SetBoolean(pNode, "addonautoupdate", m_bAddonAutoUpdate);
XMLUtils::SetBoolean(pNode, "addonnotifications", m_bAddonNotifications); XMLUtils::SetBoolean(pNode, "addonnotifications", m_bAddonNotifications);
XMLUtils::SetBoolean(pNode, "addonforeignfilter", m_bAddonForeignFilter);


// default video settings // default video settings
TiXmlElement videoSettingsNode("defaultvideosettings"); TiXmlElement videoSettingsNode("defaultvideosettings");
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/Settings.h
Expand Up @@ -208,6 +208,7 @@ class CSettings
bool m_bStartVideoWindowed; bool m_bStartVideoWindowed;
bool m_bAddonAutoUpdate; bool m_bAddonAutoUpdate;
bool m_bAddonNotifications; bool m_bAddonNotifications;
bool m_bAddonForeignFilter;


int m_iVideoStartWindow; int m_iVideoStartWindow;


Expand Down