Skip to content

Commit

Permalink
[addons] allow binary addon to use label id with every id
Browse files Browse the repository at this point in the history
This change the id usage of strings on new binary addons to override
a kodi string id with a own for him itself.
  • Loading branch information
AlwinEsch committed Aug 29, 2017
1 parent e0d4b77 commit f2b6002
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions xbmc/addons/interfaces/General.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool Interface_General::open_settings_dialog(void* kodiBase)
return CGUIDialogAddonSettings::ShowForAddon(addonInfo);
}

char* Interface_General::get_localized_string(void* kodiBase, long dwCode)
char* Interface_General::get_localized_string(void* kodiBase, long label_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
if (!addon)
Expand All @@ -158,13 +158,10 @@ char* Interface_General::get_localized_string(void* kodiBase, long dwCode)
if (g_application.m_bStop)
return nullptr;

std::string string;
if ((dwCode >= 30000 && dwCode <= 30999) || (dwCode >= 32000 && dwCode <= 32999))
string = g_localizeStrings.GetAddonString(addon->ID(), dwCode).c_str();
else
string = g_localizeStrings.Get(dwCode).c_str();

char* buffer = strdup(string.c_str());
std::string label = g_localizeStrings.GetAddonString(addon->ID(), label_id);
if (label.empty())
label = g_localizeStrings.Get(label_id);
char* buffer = strdup(label.c_str());
return buffer;
}

Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/interfaces/General.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace ADDON
//@{
static char* get_addon_info(void* kodiBase, const char* id);
static bool open_settings_dialog(void* kodiBase);
static char* get_localized_string(void* kodiBase, long dwCode);
static char* get_localized_string(void* kodiBase, long label_id);
static char* unknown_to_utf8(void* kodiBase, const char* source, bool* ret, bool failOnBadChar);
static char* get_language(void* kodiBase, int format, bool region);
static bool queue_notification(void* kodiBase, int type, const char* header, const char* message, const char* imageFile, unsigned int displayTime, bool withSound, unsigned int messageTime);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct AddonToKodiFuncTable_kodi
char* (*get_addon_info)(void* kodiBase, const char* id);
bool (*open_settings_dialog)(void* kodiBase);
char* (*unknown_to_utf8)(void* kodiBase, const char* source, bool* ret, bool failOnBadChar);
char* (*get_localized_string)(void* kodiBase, long dwCode);
char* (*get_localized_string)(void* kodiBase, long label_id);
char* (*get_language)(void* kodiBase, int format, bool region);
bool (*queue_notification)(void* kodiBase, int type, const char* header, const char* message, const char* imageFile, unsigned int displayTime, bool withSound, unsigned int messageTime);
void (*get_md5)(void* kodiBase, const char* text, char* md5);
Expand Down

0 comments on commit f2b6002

Please sign in to comment.