mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 15:58:31 +00:00
Version 0.8.0 beta
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
NAME = skindesignerapi
|
||||
LIBNAME = lib$(NAME)
|
||||
MAJOR = 0
|
||||
MINOR = 0.2
|
||||
MINOR = 1.0
|
||||
VERSION = $(MAJOR).$(MINOR)
|
||||
|
||||
SONAME = $(LIBNAME).so.$(MAJOR)
|
||||
|
@@ -3,37 +3,37 @@
|
||||
/**********************************************************************
|
||||
* cOsdElement
|
||||
**********************************************************************/
|
||||
skindesignerapi::cOsdElement::cOsdElement(skindesignerapi::ISkinDisplayPlugin *view) {
|
||||
skindesignerapi::cOsdElement::cOsdElement(skindesignerapi::ISkinDisplayPlugin *view, int viewId) {
|
||||
this->view = view;
|
||||
this->viewId = viewId;
|
||||
tk = NULL;
|
||||
}
|
||||
|
||||
skindesignerapi::cOsdElement::~cOsdElement() {
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdElement::ClearTokens(void) {
|
||||
stringTokens.clear();
|
||||
intTokens.clear();
|
||||
loopTokens.clear();
|
||||
tk->Clear();
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdElement::AddStringToken(string key, string value) {
|
||||
stringTokens.insert(pair<string,string>(key, value));
|
||||
int skindesignerapi::cOsdElement::GetLoopIndex(const char *loop) {
|
||||
return tk->LoopIndex(loop);
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdElement::AddIntToken(string key, int value) {
|
||||
intTokens.insert(pair<string,int>(key, value));
|
||||
void skindesignerapi::cOsdElement::SetLoop(vector<int> loopInfo) {
|
||||
tk->CreateLoopTokenContainer(&loopInfo);
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdElement::AddLoopToken(string loopName, map<string, string> &tokens) {
|
||||
map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
|
||||
if (hitLoop == loopTokens.end()) {
|
||||
vector<map<string, string> > tokenVector;
|
||||
tokenVector.push_back(tokens);
|
||||
loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
|
||||
} else {
|
||||
vector<map<string, string> > *tokenVector = &hitLoop->second;
|
||||
tokenVector->push_back(tokens);
|
||||
}
|
||||
void skindesignerapi::cOsdElement::AddStringToken(int index, const char *value) {
|
||||
tk->AddStringToken(index, value);
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdElement::AddIntToken(int index, int value) {
|
||||
tk->AddIntToken(index, value);
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdElement::AddLoopToken(int loopIndex, int row, int index, const char *value) {
|
||||
tk->AddLoopToken(loopIndex, row, index, value);
|
||||
}
|
||||
|
||||
bool skindesignerapi::cOsdElement::ChannelLogoExists(string channelId) {
|
||||
@@ -41,166 +41,162 @@ bool skindesignerapi::cOsdElement::ChannelLogoExists(string channelId) {
|
||||
}
|
||||
|
||||
string skindesignerapi::cOsdElement::GetEpgImagePath(void) {
|
||||
return view->GetEpgImagePath();
|
||||
return view->GetEpgImagePath();
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdElement::DebugTokenContainer(void) {
|
||||
tk->Debug();
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* cViewElement
|
||||
**********************************************************************/
|
||||
skindesignerapi::cViewElement::cViewElement(skindesignerapi::ISkinDisplayPlugin *view, int viewElementID) : cOsdElement(view) {
|
||||
this->viewElementID = viewElementID;
|
||||
skindesignerapi::cViewElement::cViewElement(skindesignerapi::ISkinDisplayPlugin *view, int viewId, int viewElementId) : cOsdElement(view, viewId) {
|
||||
this->viewElementId = viewElementId;
|
||||
}
|
||||
|
||||
skindesignerapi::cViewElement::~cViewElement() {
|
||||
view->ClearViewElement(viewElementId, viewId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewElement::Clear(void) {
|
||||
if (!view)
|
||||
return;
|
||||
view->ClearViewElement(viewElementID);
|
||||
view->ClearViewElement(viewElementId, viewId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewElement::Display(void) {
|
||||
if (!view)
|
||||
return;
|
||||
view->SetViewElementIntTokens(&intTokens);
|
||||
view->SetViewElementStringTokens(&stringTokens);
|
||||
view->SetViewElementLoopTokens(&loopTokens);
|
||||
view->DisplayViewElement(viewElementID);
|
||||
view->SetViewElementTokens(viewElementId, viewId, tk);
|
||||
view->DisplayViewElement(viewElementId, viewId);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* cViewGrid
|
||||
**********************************************************************/
|
||||
skindesignerapi::cViewGrid::cViewGrid(skindesignerapi::ISkinDisplayPlugin *view, int viewGridID) : cOsdElement(view) {
|
||||
this->viewGridID = viewGridID;
|
||||
skindesignerapi::cViewGrid::cViewGrid(skindesignerapi::ISkinDisplayPlugin *view, int viewId, int viewGridId) : cOsdElement(view, viewId) {
|
||||
this->viewGridId = viewGridId;
|
||||
}
|
||||
|
||||
skindesignerapi::cViewGrid::~cViewGrid() {
|
||||
if (!view)
|
||||
return;
|
||||
view->ClearGrids(viewGridID);
|
||||
view->ClearGrids(viewId, viewGridId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewGrid::SetGrid(long gridID, double x, double y, double width, double height) {
|
||||
if (!view)
|
||||
return;
|
||||
view->SetGrid(viewGridID, gridID, x, y, width, height, &intTokens, &stringTokens);
|
||||
void skindesignerapi::cViewGrid::SetGrid(long gridId, double x, double y, double width, double height) {
|
||||
view->SetGrid(gridId, viewId, viewGridId, x, y, width, height, tk);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewGrid::SetCurrent(long gridID, bool current) {
|
||||
if (!view)
|
||||
return;
|
||||
view->SetGridCurrent(viewGridID, gridID, current);
|
||||
void skindesignerapi::cViewGrid::SetCurrent(long gridId, bool current) {
|
||||
view->SetGridCurrent(gridId, viewId, viewGridId, current);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewGrid::MoveGrid(long gridID, double x, double y, double width, double height) {
|
||||
if (!view)
|
||||
return;
|
||||
view->SetGrid(viewGridID, gridID, x, y, width, height, NULL, NULL);
|
||||
void skindesignerapi::cViewGrid::MoveGrid(long gridId, double x, double y, double width, double height) {
|
||||
view->SetGrid(gridId, viewId, viewGridId, x, y, width, height, NULL);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewGrid::Delete(long gridID) {
|
||||
if (!view)
|
||||
return;
|
||||
view->DeleteGrid(viewGridID, gridID);
|
||||
void skindesignerapi::cViewGrid::Delete(long gridId) {
|
||||
view->DeleteGrid(gridId, viewId, viewGridId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewGrid::Clear(void) {
|
||||
if (!view)
|
||||
return;
|
||||
view->ClearGrids(viewGridID);
|
||||
view->ClearGrids(viewId, viewGridId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewGrid::Display(void) {
|
||||
if (!view)
|
||||
return;
|
||||
view->DisplayGrids(viewGridID);
|
||||
view->DisplayGrids(viewId, viewGridId);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* cViewTab
|
||||
**********************************************************************/
|
||||
skindesignerapi::cViewTab::cViewTab(skindesignerapi::ISkinDisplayPlugin *view) : cOsdElement(view) {
|
||||
skindesignerapi::cViewTab::cViewTab(skindesignerapi::ISkinDisplayPlugin *view, int viewId) : cOsdElement(view, viewId) {
|
||||
}
|
||||
|
||||
skindesignerapi::cViewTab::~cViewTab() {
|
||||
view->ClearTab(viewId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewTab::Init(void) {
|
||||
view->SetTabIntTokens(&intTokens);
|
||||
view->SetTabStringTokens(&stringTokens);
|
||||
view->SetTabLoopTokens(&loopTokens);
|
||||
view->SetTabs();
|
||||
view->SetTabTokens(viewId, tk);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewTab::Left(void) {
|
||||
view->TabLeft();
|
||||
view->TabLeft(viewId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewTab::Right(void) {
|
||||
view->TabRight();
|
||||
view->TabRight(viewId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewTab::Up(void) {
|
||||
view->TabUp();
|
||||
view->TabUp(viewId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewTab::Down(void) {
|
||||
view->TabDown();
|
||||
view->TabDown(viewId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cViewTab::Display(void) {
|
||||
if (!view)
|
||||
return;
|
||||
view->DisplayTabs();
|
||||
view->DisplayTabs(viewId);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* cOsdView
|
||||
**********************************************************************/
|
||||
skindesignerapi::cOsdView::cOsdView(skindesignerapi::ISkinDisplayPlugin *displayPlugin) {
|
||||
skindesignerapi::cOsdView::cOsdView(skindesignerapi::cPluginStructure *plugStruct, skindesignerapi::ISkinDisplayPlugin *displayPlugin, int viewId) {
|
||||
this->plugStruct = plugStruct;
|
||||
this->displayPlugin = displayPlugin;
|
||||
this->viewId = viewId;
|
||||
}
|
||||
|
||||
skindesignerapi::cOsdView::~cOsdView() {
|
||||
delete displayPlugin;
|
||||
if (displayPlugin && (viewId == 0))
|
||||
displayPlugin->CloseOsd();
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdView::Deactivate(bool hide) {
|
||||
if (!displayPlugin)
|
||||
return;
|
||||
displayPlugin->Deactivate(hide);
|
||||
displayPlugin->Deactivate(viewId, hide);
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdView::Activate(void) {
|
||||
if (!displayPlugin)
|
||||
return;
|
||||
displayPlugin->Activate();
|
||||
displayPlugin->Activate(viewId);
|
||||
}
|
||||
|
||||
skindesignerapi::cViewElement *skindesignerapi::cOsdView::GetViewElement(int viewElementID) {
|
||||
skindesignerapi::cViewElement *skindesignerapi::cOsdView::GetViewElement(int viewElementId) {
|
||||
if (!displayPlugin)
|
||||
return NULL;
|
||||
return new cViewElement(displayPlugin, viewElementID);
|
||||
cTokenContainer *tk = plugStruct->GetTokenContainerVE(viewId, viewElementId);
|
||||
if (!tk)
|
||||
return NULL;
|
||||
skindesignerapi::cViewElement *ve = new cViewElement(displayPlugin, viewId, viewElementId);
|
||||
ve->SetTokenContainer(tk);
|
||||
return ve;
|
||||
}
|
||||
|
||||
skindesignerapi::cViewGrid *skindesignerapi::cOsdView::GetViewGrid(int viewGridID) {
|
||||
skindesignerapi::cViewGrid *skindesignerapi::cOsdView::GetViewGrid(int viewGridId) {
|
||||
if (!displayPlugin)
|
||||
return NULL;
|
||||
displayPlugin->InitGrids(viewGridID);
|
||||
return new cViewGrid(displayPlugin, viewGridID);
|
||||
cTokenContainer *tk = plugStruct->GetTokenContainerGE(viewId, viewGridId);
|
||||
if (!tk)
|
||||
return NULL;
|
||||
skindesignerapi::cViewGrid *ge = new cViewGrid(displayPlugin, viewId, viewGridId);
|
||||
ge->SetTokenContainer(tk);
|
||||
return ge;
|
||||
}
|
||||
|
||||
skindesignerapi::cViewTab *skindesignerapi::cOsdView::GetViewTabs(void) {
|
||||
if (!displayPlugin)
|
||||
return NULL;
|
||||
return new cViewTab(displayPlugin);
|
||||
cTokenContainer *tk = plugStruct->GetTokenContainerTab(viewId);
|
||||
if (!tk)
|
||||
return NULL;
|
||||
skindesignerapi::cViewTab *tab = new cViewTab(displayPlugin, viewId);
|
||||
tab->SetTokenContainer(tk);
|
||||
return tab;
|
||||
}
|
||||
|
||||
void skindesignerapi::cOsdView::Display(void) {
|
||||
if (!displayPlugin)
|
||||
return;
|
||||
displayPlugin->Flush();
|
||||
if (displayPlugin)
|
||||
displayPlugin->Flush();
|
||||
}
|
||||
|
@@ -12,19 +12,22 @@ namespace skindesignerapi {
|
||||
|
||||
class cOsdElement {
|
||||
protected:
|
||||
int viewId;
|
||||
ISkinDisplayPlugin *view;
|
||||
map < string, string > stringTokens;
|
||||
map < string, int > intTokens;
|
||||
map < string, vector< map< string, string > > > loopTokens;
|
||||
cTokenContainer *tk;
|
||||
public:
|
||||
cOsdElement(ISkinDisplayPlugin *view);
|
||||
cOsdElement(ISkinDisplayPlugin *view, int viewId);
|
||||
virtual ~cOsdElement();
|
||||
void AddLoopToken(string loopName, map<string, string> &tokens);
|
||||
void AddStringToken(string key, string value);
|
||||
void AddIntToken(string key, int value);
|
||||
void SetTokenContainer(cTokenContainer *tk) { this->tk = tk; };
|
||||
int GetLoopIndex(const char *loop);
|
||||
void SetLoop(vector<int> loopInfo);
|
||||
void AddLoopToken(int loopIndex, int row, int index, const char *value);
|
||||
void AddStringToken(int index, const char *value);
|
||||
void AddIntToken(int index, int value);
|
||||
void ClearTokens(void);
|
||||
bool ChannelLogoExists(string channelId);
|
||||
string GetEpgImagePath(void);
|
||||
void DebugTokenContainer(void);
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
@@ -32,9 +35,9 @@ public:
|
||||
**********************************************************************/
|
||||
class cViewElement : public cOsdElement {
|
||||
private:
|
||||
int viewElementID;
|
||||
int viewElementId;
|
||||
public:
|
||||
cViewElement(ISkinDisplayPlugin *view, int viewElementID);
|
||||
cViewElement(ISkinDisplayPlugin *view, int viewId, int viewElementId);
|
||||
virtual ~cViewElement();
|
||||
void Clear(void);
|
||||
void Display(void);
|
||||
@@ -45,14 +48,14 @@ public:
|
||||
**********************************************************************/
|
||||
class cViewGrid : public cOsdElement {
|
||||
private:
|
||||
int viewGridID;
|
||||
int viewGridId;
|
||||
public:
|
||||
cViewGrid(ISkinDisplayPlugin *view, int viewGridID);
|
||||
cViewGrid(ISkinDisplayPlugin *view, int viewId, int viewGridId);
|
||||
virtual ~cViewGrid();
|
||||
void SetGrid(long gridID, double x, double y, double width, double height);
|
||||
void SetCurrent(long gridID, bool current);
|
||||
void MoveGrid(long gridID, double x, double y, double width, double height);
|
||||
void Delete(long gridID);
|
||||
void SetGrid(long gridId, double x, double y, double width, double height);
|
||||
void SetCurrent(long gridId, bool current);
|
||||
void MoveGrid(long gridId, double x, double y, double width, double height);
|
||||
void Delete(long gridId);
|
||||
void Clear(void);
|
||||
void Display(void);
|
||||
};
|
||||
@@ -63,7 +66,7 @@ public:
|
||||
class cViewTab : public cOsdElement {
|
||||
private:
|
||||
public:
|
||||
cViewTab(ISkinDisplayPlugin *view);
|
||||
cViewTab(ISkinDisplayPlugin *view, int viewId);
|
||||
virtual ~cViewTab();
|
||||
void Init(void);
|
||||
void Left(void);
|
||||
@@ -79,8 +82,10 @@ public:
|
||||
class cOsdView {
|
||||
private:
|
||||
ISkinDisplayPlugin *displayPlugin;
|
||||
cPluginStructure *plugStruct;
|
||||
int viewId;
|
||||
public:
|
||||
cOsdView(ISkinDisplayPlugin *displayPlugin);
|
||||
cOsdView(cPluginStructure *plugStruct, ISkinDisplayPlugin *displayPlugin, int viewId);
|
||||
virtual ~cOsdView();
|
||||
void Deactivate(bool hide);
|
||||
void Activate(void);
|
||||
|
92
libskindesignerapi/pluginstructure.c
Normal file
92
libskindesignerapi/pluginstructure.c
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "pluginstructure.h"
|
||||
|
||||
skindesignerapi::cPluginStructure::cPluginStructure(void) {
|
||||
name = "";
|
||||
libskindesignerAPIVersion = "undefined";
|
||||
id = -1;
|
||||
rootview = "";
|
||||
};
|
||||
|
||||
skindesignerapi::cPluginStructure::~cPluginStructure(void) {
|
||||
for (map<int,sPlugMenu>::iterator it = menus.begin(); it != menus.end(); it++) {
|
||||
delete (it->second).tokenContainer;
|
||||
}
|
||||
};
|
||||
|
||||
void skindesignerapi::cPluginStructure::RegisterMenu(int key, int type, string tpl, skindesignerapi::cTokenContainer *tk) {
|
||||
tk->CreateContainers();
|
||||
sPlugMenu s;
|
||||
s.type = type;
|
||||
s.tplname = tpl;
|
||||
s.tokenContainer = tk;
|
||||
menus.insert(pair<int, sPlugMenu>(key, s));
|
||||
}
|
||||
|
||||
skindesignerapi::cTokenContainer *skindesignerapi::cPluginStructure::GetMenuTokenContainer(int key) {
|
||||
map<int, sPlugMenu>::iterator hit = menus.find(key);
|
||||
if (hit == menus.end())
|
||||
return NULL;
|
||||
return hit->second.tokenContainer;
|
||||
}
|
||||
|
||||
void skindesignerapi::cPluginStructure::RegisterRootView(string templateName) {
|
||||
rootview = templateName;
|
||||
}
|
||||
|
||||
void skindesignerapi::cPluginStructure::RegisterSubView(int subView, string templateName) {
|
||||
subviews.insert(pair<int, string>(subView, templateName));
|
||||
}
|
||||
|
||||
void skindesignerapi::cPluginStructure::RegisterViewElement(int view, int viewElement, string name, skindesignerapi::cTokenContainer *tk) {
|
||||
tk->CreateContainers();
|
||||
sPlugViewElement ve;
|
||||
ve.id = viewElement;
|
||||
ve.viewId = view;
|
||||
ve.name = name;
|
||||
ve.tokenContainer = tk;
|
||||
viewelements.insert(pair<int, sPlugViewElement>(view, ve));
|
||||
}
|
||||
|
||||
void skindesignerapi::cPluginStructure::RegisterViewGrid(int view, int viewGrid, string name, skindesignerapi::cTokenContainer *tk) {
|
||||
tk->CreateContainers();
|
||||
sPlugViewGrid vg;
|
||||
vg.id = viewGrid;
|
||||
vg.viewId = view;
|
||||
vg.name = name;
|
||||
vg.tokenContainer = tk;
|
||||
viewgrids.insert(pair<int, sPlugViewGrid>(view, vg));
|
||||
}
|
||||
|
||||
void skindesignerapi::cPluginStructure::RegisterViewTab(int view, skindesignerapi::cTokenContainer *tk) {
|
||||
tk->CreateContainers();
|
||||
viewtabs.insert(pair<int, skindesignerapi::cTokenContainer*>(view, tk));
|
||||
}
|
||||
|
||||
skindesignerapi::cTokenContainer *skindesignerapi::cPluginStructure::GetTokenContainerVE(int viewId, int veId) {
|
||||
pair<multimap<int, sPlugViewElement>::iterator, multimap<int, sPlugViewElement>::iterator> range;
|
||||
range = viewelements.equal_range(viewId);
|
||||
for (multimap<int, sPlugViewElement>::iterator it=range.first; it!=range.second; ++it) {
|
||||
sPlugViewElement *ve = &it->second;
|
||||
if (ve->id == veId)
|
||||
return ve->tokenContainer;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
skindesignerapi::cTokenContainer *skindesignerapi::cPluginStructure::GetTokenContainerGE(int viewId, int geId) {
|
||||
pair<multimap<int, sPlugViewGrid>::iterator, multimap<int, sPlugViewGrid>::iterator> range;
|
||||
range = viewgrids.equal_range(viewId);
|
||||
for (multimap<int, sPlugViewGrid>::iterator it=range.first; it!=range.second; ++it) {
|
||||
sPlugViewGrid *ge = &it->second;
|
||||
if (ge->id == geId)
|
||||
return ge->tokenContainer;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
skindesignerapi::cTokenContainer *skindesignerapi::cPluginStructure::GetTokenContainerTab(int viewId) {
|
||||
map<int,skindesignerapi::cTokenContainer*>::iterator hit = viewtabs.find(viewId);
|
||||
if (hit == viewtabs.end())
|
||||
return NULL;
|
||||
return hit->second;
|
||||
}
|
57
libskindesignerapi/pluginstructure.h
Normal file
57
libskindesignerapi/pluginstructure.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef __PLUGINSTRUCTURE_H
|
||||
#define __PLUGINSTRUCTURE_H
|
||||
|
||||
#include "tokencontainer.h"
|
||||
|
||||
namespace skindesignerapi {
|
||||
|
||||
struct sPlugMenu {
|
||||
int type;
|
||||
string tplname;
|
||||
cTokenContainer *tokenContainer;
|
||||
};
|
||||
|
||||
struct sPlugViewElement {
|
||||
int id;
|
||||
int viewId;
|
||||
string name;
|
||||
cTokenContainer *tokenContainer;
|
||||
};
|
||||
|
||||
struct sPlugViewGrid {
|
||||
int id;
|
||||
int viewId;
|
||||
string name;
|
||||
cTokenContainer *tokenContainer;
|
||||
};
|
||||
|
||||
class cPluginStructure {
|
||||
public:
|
||||
cPluginStructure(void);
|
||||
~cPluginStructure(void);
|
||||
void RegisterMenu(int key, int type, string tpl, cTokenContainer *tk);
|
||||
cTokenContainer *GetMenuTokenContainer(int key);
|
||||
void RegisterRootView(string templateName);
|
||||
void RegisterSubView(int subView, string templateName);
|
||||
void RegisterViewElement(int view, int viewElement, string name, cTokenContainer *tk);
|
||||
void RegisterViewGrid(int view, int viewGrid, string name, cTokenContainer *tk);
|
||||
void RegisterViewTab(int view, cTokenContainer *tk);
|
||||
cTokenContainer *GetTokenContainerVE(int viewId, int veId);
|
||||
cTokenContainer *GetTokenContainerGE(int viewId, int geId);
|
||||
cTokenContainer *GetTokenContainerTab(int viewId);
|
||||
string name; //name of plugin
|
||||
string libskindesignerAPIVersion; //skindesigner API Version plugin is using
|
||||
int id; //id of plugin in skindesigner
|
||||
//basic plugin interface
|
||||
map< int, sPlugMenu > menus; //menus as key -> sPlugMenu struct hashmap
|
||||
//advanced plugin interface
|
||||
string rootview; //template name of root view
|
||||
map< int, string > subviews; //subviews as subviewid -> template name map
|
||||
multimap< int, sPlugViewElement > viewelements; //viewelements as viewid -> sPlugViewElement struct multimap
|
||||
multimap< int, sPlugViewGrid > viewgrids; //viewgrids as viewid -> sPlugViewGrid struct hashmap
|
||||
map< int, cTokenContainer* > viewtabs; //viewtabs as viewid -> tokencontainer hashmap
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif //__PLUGINSTRUCTURE_H
|
@@ -3,31 +3,37 @@
|
||||
skindesignerapi::SkindesignerAPI *skindesignerapi::SkindesignerAPI::skindesigner = NULL;
|
||||
|
||||
skindesignerapi::SkindesignerAPI::SkindesignerAPI(void) {
|
||||
if (skindesigner != NULL)
|
||||
esyslog("skindesigner should only be loaded once");
|
||||
else
|
||||
skindesigner = this;
|
||||
if (skindesigner != NULL)
|
||||
esyslog("skindesigner should only be loaded once");
|
||||
else
|
||||
skindesigner = this;
|
||||
}
|
||||
|
||||
skindesignerapi::SkindesignerAPI::~SkindesignerAPI(void) {
|
||||
if (skindesigner == this)
|
||||
skindesigner = NULL;
|
||||
if (skindesigner == this)
|
||||
skindesigner = NULL;
|
||||
}
|
||||
|
||||
bool skindesignerapi::SkindesignerAPI::ServiceAvailable(void) {
|
||||
if (skindesigner)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool skindesignerapi::SkindesignerAPI::RegisterPlugin(cPluginStructure *plugStructure) {
|
||||
if (skindesigner)
|
||||
return skindesigner->ServiceRegisterPlugin(plugStructure);
|
||||
return false;
|
||||
if (skindesigner)
|
||||
return skindesigner->ServiceRegisterPlugin(plugStructure);
|
||||
return false;
|
||||
}
|
||||
|
||||
skindesignerapi::ISDDisplayMenu *skindesignerapi::SkindesignerAPI::GetDisplayMenu() {
|
||||
if (skindesigner)
|
||||
return skindesigner->ServiceGetDisplayMenu();
|
||||
return NULL;
|
||||
if (skindesigner)
|
||||
return skindesigner->ServiceGetDisplayMenu();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
skindesignerapi::ISkinDisplayPlugin *skindesignerapi::SkindesignerAPI::GetDisplayPlugin(string pluginName, int viewID, int subViewID) {
|
||||
if (skindesigner)
|
||||
return skindesigner->ServiceGetDisplayPlugin(pluginName, viewID, subViewID);
|
||||
return NULL;
|
||||
}
|
||||
skindesignerapi::ISkinDisplayPlugin *skindesignerapi::SkindesignerAPI::GetDisplayPlugin(int plugId) {
|
||||
if (skindesigner)
|
||||
return skindesigner->ServiceGetDisplayPlugin(plugId);
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -7,92 +7,51 @@ using namespace std;
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <vdr/osdbase.h>
|
||||
#include "pluginstructure.h"
|
||||
#include "tokencontainer.h"
|
||||
|
||||
namespace skindesignerapi {
|
||||
|
||||
enum eMenuType {
|
||||
mtList,
|
||||
mtText
|
||||
};
|
||||
|
||||
class ISDDisplayMenu : public cSkinDisplayMenu {
|
||||
public:
|
||||
virtual void SetTitle(const char *Title) = 0;
|
||||
virtual void SetPluginMenu(string name, int menu, int type, bool init) = 0;
|
||||
virtual bool SetItemPlugin(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens, int Index, bool Current, bool Selectable) = 0;
|
||||
virtual bool SetPluginText(map<string,string> *stringTokens, map<string,int> *intTokens, map<string,vector<map<string,string> > > *loopTokens) = 0;
|
||||
virtual void SetPluginMenu(int plugId, int menuId, int type, bool init) = 0;
|
||||
virtual bool SetItemPlugin(cTokenContainer *tk, int Index, bool Current, bool Selectable) = 0;
|
||||
virtual bool SetPluginText(cTokenContainer *tk) = 0;
|
||||
};
|
||||
|
||||
class ISkinDisplayPlugin {
|
||||
public:
|
||||
virtual ~ISkinDisplayPlugin(void) {};
|
||||
virtual void Deactivate(bool hide) = 0;
|
||||
virtual void Activate(void) = 0;
|
||||
virtual void ClearViewElement(int id) = 0;
|
||||
virtual void DisplayViewElement(int id) = 0;
|
||||
virtual void SetViewElementIntTokens(map<string,int> *intTokens) = 0;
|
||||
virtual void SetViewElementStringTokens(map<string,string> *stringTokens) = 0;
|
||||
virtual void SetViewElementLoopTokens(map<string,vector<map<string,string> > > *loopTokens) = 0;
|
||||
virtual void InitGrids(int viewGridID) = 0;
|
||||
virtual void SetGrid(int viewGridID, long gridID, double x, double y, double width, double height, map<string,int> *intTokens, map<string,string> *stringTokens) = 0;
|
||||
virtual void SetGridCurrent(int viewGridID, long gridID, bool current) = 0;
|
||||
virtual void DeleteGrid(int viewGridID, long gridID) = 0;
|
||||
virtual void DisplayGrids(int viewGridID) = 0;
|
||||
virtual void ClearGrids(int viewGridID) = 0;
|
||||
virtual void SetTabIntTokens(map<string,int> *intTokens) = 0;
|
||||
virtual void SetTabStringTokens(map<string,string> *stringTokens) = 0;
|
||||
virtual void SetTabLoopTokens(map<string,vector<map<string,string> > > *loopTokens) = 0;
|
||||
virtual void SetTabs(void) = 0;
|
||||
virtual void TabLeft(void) = 0;
|
||||
virtual void TabRight(void) = 0;
|
||||
virtual void TabUp(void) = 0;
|
||||
virtual void TabDown(void) = 0;
|
||||
virtual void DisplayTabs(void) = 0;
|
||||
virtual bool InitOsd(void) = 0;
|
||||
virtual void CloseOsd(void) = 0;
|
||||
virtual void Deactivate(int viewId, bool hide) = 0;
|
||||
virtual void Activate(int viewId) = 0;
|
||||
virtual void SetViewElementTokens(int id, int viewId, skindesignerapi::cTokenContainer *tk) = 0;
|
||||
virtual void ClearViewElement(int id, int viewId) = 0;
|
||||
virtual void DisplayViewElement(int id, int viewId) = 0;
|
||||
virtual void SetGrid(long id, int viewId, int viewGridId, double x, double y, double width, double height, skindesignerapi::cTokenContainer *tk) = 0;
|
||||
virtual void SetGridCurrent(long id, int viewId, int viewGridId, bool current) = 0;
|
||||
virtual void DeleteGrid(long id, int viewId, int viewGridId) = 0;
|
||||
virtual void DisplayGrids(int viewId, int viewGridId) = 0;
|
||||
virtual void ClearGrids(int viewId, int viewGridId) = 0;
|
||||
virtual void SetTabTokens(int viewId, skindesignerapi::cTokenContainer *tk) = 0;
|
||||
virtual void TabLeft(int viewId) = 0;
|
||||
virtual void TabRight(int viewId) = 0;
|
||||
virtual void TabUp(int viewId) = 0;
|
||||
virtual void TabDown(int viewId) = 0;
|
||||
virtual void DisplayTabs(int viewId) = 0;
|
||||
virtual void ClearTab(int viewId) = 0;
|
||||
virtual void Flush(void) = 0;
|
||||
virtual bool ChannelLogoExists(string channelId) = 0;
|
||||
virtual string GetEpgImagePath(void) = 0;
|
||||
};
|
||||
|
||||
class cPluginStructure {
|
||||
public:
|
||||
cPluginStructure(void) {
|
||||
name = "";
|
||||
libskindesignerAPIVersion = "undefined";
|
||||
};
|
||||
void SetMenu(int key, string templateName) {
|
||||
menus.insert(pair<int, string>(key, templateName));
|
||||
}
|
||||
void SetView(int key, string templateName) {
|
||||
views.insert(pair<int, string>(key, templateName));
|
||||
}
|
||||
void SetSubView(int view, int subView, string templateName) {
|
||||
pair<int, string> sub = make_pair(subView, templateName);
|
||||
subViews.insert(pair<int, pair<int, string> >(view, sub));
|
||||
}
|
||||
void SetViewElement(int view, int viewElement, string name) {
|
||||
map< int, map<int, string> >::iterator hit = viewElements.find(view);
|
||||
if (hit == viewElements.end()) {
|
||||
map<int, string> vE;
|
||||
vE.insert(pair<int, string >(viewElement, name));
|
||||
viewElements.insert(pair<int, map < int, string > >(view, vE));
|
||||
} else {
|
||||
(hit->second).insert(pair<int, string >(viewElement, name));
|
||||
}
|
||||
}
|
||||
void SetViewGrid(int view, int viewGrid, string name) {
|
||||
map< int, map<int, string> >::iterator hit = viewGrids.find(view);
|
||||
if (hit == viewGrids.end()) {
|
||||
map<int, string> vG;
|
||||
vG.insert(pair<int, string >(viewGrid, name));
|
||||
viewGrids.insert(pair<int, map < int, string > >(view, vG));
|
||||
} else {
|
||||
(hit->second).insert(pair<int, string >(viewGrid, name));
|
||||
}
|
||||
}
|
||||
string name; //name of plugin
|
||||
string libskindesignerAPIVersion; //skindesigner API Version plugin is using
|
||||
map< int, string > menus; //menus as key -> templatename hashmap
|
||||
map< int, string> views; //standalone views as key -> templatename hashmap
|
||||
multimap< int, pair <int, string> > subViews; //subviews of standalone views as view -> (subview, templatename) multimap
|
||||
map< int, map <int, string> > viewElements; //viewelements as key -> (viewelement, viewelementname) hashmap
|
||||
map< int, map <int, string> > viewGrids; //viewgrids as key -> (viewgrid, viewgridname) hashmap
|
||||
};
|
||||
|
||||
class SkindesignerAPI {
|
||||
private:
|
||||
static SkindesignerAPI* skindesigner;
|
||||
@@ -101,11 +60,12 @@ protected:
|
||||
virtual ~SkindesignerAPI(void);
|
||||
virtual bool ServiceRegisterPlugin(cPluginStructure *plugStructure) = 0;
|
||||
virtual ISDDisplayMenu *ServiceGetDisplayMenu(void) = 0;
|
||||
virtual ISkinDisplayPlugin *ServiceGetDisplayPlugin(string pluginName, int viewID, int subViewID) = 0;
|
||||
virtual ISkinDisplayPlugin *ServiceGetDisplayPlugin(int plugId) = 0;
|
||||
public:
|
||||
static bool ServiceAvailable(void);
|
||||
static bool RegisterPlugin(cPluginStructure *plugStructure);
|
||||
static ISDDisplayMenu *GetDisplayMenu(void);
|
||||
static ISkinDisplayPlugin *GetDisplayPlugin(string pluginName, int viewID, int subViewID);
|
||||
static ISkinDisplayPlugin *GetDisplayPlugin(int plugId);
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -4,44 +4,61 @@
|
||||
* cSkindesignerOsdObject
|
||||
**********************************************************************/
|
||||
|
||||
skindesignerapi::cSkindesignerOsdObject::cSkindesignerOsdObject(void) {
|
||||
pluginName = "";
|
||||
skindesignerapi::cSkindesignerOsdObject::cSkindesignerOsdObject(cPluginStructure *plugStruct) {
|
||||
this->plugStruct = plugStruct;
|
||||
init = true;
|
||||
}
|
||||
|
||||
skindesignerapi::cSkindesignerOsdObject::~cSkindesignerOsdObject() {
|
||||
}
|
||||
|
||||
bool skindesignerapi::cSkindesignerOsdObject::InitSkindesignerInterface(string pluginName) {
|
||||
this->pluginName = pluginName;
|
||||
return true;
|
||||
}
|
||||
|
||||
skindesignerapi::cOsdView *skindesignerapi::cSkindesignerOsdObject::GetOsdView(int viewID, int subViewID) {
|
||||
ISkinDisplayPlugin *displayPlugin = SkindesignerAPI::GetDisplayPlugin(pluginName, viewID, subViewID);
|
||||
skindesignerapi::cOsdView *skindesignerapi::cSkindesignerOsdObject::GetOsdView(int subViewId) {
|
||||
ISkinDisplayPlugin *displayPlugin = SkindesignerAPI::GetDisplayPlugin(plugStruct->id);
|
||||
if (!displayPlugin)
|
||||
return NULL;
|
||||
cOsdView *view = new cOsdView(displayPlugin);
|
||||
if (init) {
|
||||
init = false;
|
||||
if (!displayPlugin->InitOsd()) {
|
||||
esyslog("skindesignerapi: error opening osd");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
cOsdView *view = NULL;
|
||||
if (subViewId > -1)
|
||||
view = new cOsdView(plugStruct, displayPlugin, subViewId);
|
||||
else {
|
||||
view = new cOsdView(plugStruct, displayPlugin, 0);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
bool skindesignerapi::cSkindesignerOsdObject::SkindesignerAvailable(void) {
|
||||
return SkindesignerAPI::ServiceAvailable();
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* cSkindesignerOsdItem
|
||||
**********************************************************************/
|
||||
skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(eOSState State) : cOsdItem(State) {
|
||||
skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(cTokenContainer *tk, eOSState State) : cOsdItem(State) {
|
||||
sdDisplayMenu = NULL;
|
||||
tokenContainer = new skindesignerapi::cTokenContainer(*tk);
|
||||
tokenContainer->CreateContainers();
|
||||
}
|
||||
|
||||
skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) {
|
||||
skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(cTokenContainer *tk, const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) {
|
||||
sdDisplayMenu = NULL;
|
||||
tokenContainer = new skindesignerapi::cTokenContainer(*tk);
|
||||
tokenContainer->CreateContainers();
|
||||
}
|
||||
|
||||
skindesignerapi::cSkindesignerOsdItem::~cSkindesignerOsdItem() {
|
||||
|
||||
delete tokenContainer;
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) {
|
||||
if (sdDisplayMenu) {
|
||||
if (!sdDisplayMenu->SetItemPlugin(&stringTokens, &intTokens, &loopTokens, Index, Current, Selectable)) {
|
||||
if (!sdDisplayMenu->SetItemPlugin(tokenContainer, Index, Current, Selectable)) {
|
||||
DisplayMenu->SetItem(Text(), Index, Current, Selectable);
|
||||
}
|
||||
} else {
|
||||
@@ -49,59 +66,61 @@ void skindesignerapi::cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *Displa
|
||||
}
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdItem::AddStringToken(string key, string value) {
|
||||
stringTokens.insert(pair<string,string>(key, value));
|
||||
int skindesignerapi::cSkindesignerOsdItem::GetLoopIndex(const char *loop) {
|
||||
return tokenContainer->LoopIndex(loop);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdItem::AddIntToken(string key, int value) {
|
||||
intTokens.insert(pair<string,int>(key, value));
|
||||
void skindesignerapi::cSkindesignerOsdItem::SetLoop(vector<int> loopInfo) {
|
||||
tokenContainer->CreateLoopTokenContainer(&loopInfo);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdItem::AddLoopToken(string loopName, map<string, string> &tokens) {
|
||||
map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
|
||||
if (hitLoop == loopTokens.end()) {
|
||||
vector<map<string, string> > tokenVector;
|
||||
tokenVector.push_back(tokens);
|
||||
loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
|
||||
} else {
|
||||
vector<map<string, string> > *tokenVector = &hitLoop->second;
|
||||
tokenVector->push_back(tokens);
|
||||
}
|
||||
void skindesignerapi::cSkindesignerOsdItem::AddStringToken(int index, const char *value) {
|
||||
tokenContainer->AddStringToken(index, value);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdItem::AddIntToken(int index, int value) {
|
||||
tokenContainer->AddIntToken(index, value);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdItem::AddLoopToken(int loopIndex, int row, int index, const char *value) {
|
||||
tokenContainer->AddLoopToken(loopIndex, row, index, value);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* cSkindesignerOsdMenu
|
||||
**********************************************************************/
|
||||
skindesignerapi::cSkindesignerOsdMenu::cSkindesignerOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) {
|
||||
skindesignerapi::cSkindesignerOsdMenu::cSkindesignerOsdMenu(skindesignerapi::cPluginStructure *plugStruct, const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) {
|
||||
this->plugStruct = plugStruct;
|
||||
tokenContainer = NULL;
|
||||
init = true;
|
||||
activeMenu = 0;
|
||||
firstCallCleared = false;
|
||||
secondCall = false;
|
||||
firstMenu = -1;
|
||||
firstType = mtList;
|
||||
displayText = false;
|
||||
sdDisplayMenu = NULL;
|
||||
pluginName = "";
|
||||
SetMenuCategory(mcPlugin);
|
||||
SetSkinDesignerDisplayMenu();
|
||||
}
|
||||
|
||||
skindesignerapi::cSkindesignerOsdMenu::~cSkindesignerOsdMenu() {
|
||||
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::SetPluginMenu(int menu, eMenuType type) {
|
||||
void skindesignerapi::cSkindesignerOsdMenu::SetPluginMenu(int menuId, eMenuType type) {
|
||||
activeMenu = menuId;
|
||||
if (firstCallCleared) {
|
||||
firstMenu = menu;
|
||||
firstMenu = menuId;
|
||||
firstType = type;
|
||||
}
|
||||
if (type == mtList)
|
||||
displayText = false;
|
||||
else if (type == mtText)
|
||||
displayText = true;
|
||||
|
||||
if (sdDisplayMenu) {
|
||||
sdDisplayMenu->SetPluginMenu(pluginName, menu, type, init);
|
||||
int plugId = plugStruct->id;
|
||||
sdDisplayMenu->SetPluginMenu(plugId, menuId, type, init);
|
||||
}
|
||||
init = false;
|
||||
}
|
||||
@@ -113,29 +132,32 @@ bool skindesignerapi::cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) {
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::ClearTokens(void) {
|
||||
text = "";
|
||||
stringTokens.clear();
|
||||
intTokens.clear();
|
||||
loopTokens.clear();
|
||||
if (tokenContainer)
|
||||
tokenContainer->Clear();
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::AddStringToken(string key, string value) {
|
||||
stringTokens.insert(pair<string,string>(key, value));
|
||||
int skindesignerapi::cSkindesignerOsdMenu::GetLoopIndex(const char *loop) {
|
||||
return tokenContainer->LoopIndex(loop);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::AddIntToken(string key, int value) {
|
||||
intTokens.insert(pair<string,int>(key, value));
|
||||
void skindesignerapi::cSkindesignerOsdMenu::SetLoop(vector<int> loopInfo) {
|
||||
tokenContainer->CreateLoopTokenContainer(&loopInfo);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::AddLoopToken(string loopName, map<string, string> &tokens) {
|
||||
map<string, vector<map<string, string> > >::iterator hitLoop = loopTokens.find(loopName);
|
||||
if (hitLoop == loopTokens.end()) {
|
||||
vector<map<string, string> > tokenVector;
|
||||
tokenVector.push_back(tokens);
|
||||
loopTokens.insert(pair<string, vector<map<string, string> > >(loopName, tokenVector));
|
||||
} else {
|
||||
vector<map<string, string> > *tokenVector = &hitLoop->second;
|
||||
tokenVector->push_back(tokens);
|
||||
}
|
||||
void skindesignerapi::cSkindesignerOsdMenu::SetTokenContainer(cTokenContainer *tk) {
|
||||
tokenContainer = tk;
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::AddStringToken(int index, const char *value) {
|
||||
tokenContainer->AddStringToken(index, value);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::AddIntToken(int index, int value) {
|
||||
tokenContainer->AddIntToken(index, value);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::AddLoopToken(int loopIndex, int row, int index, const char *value) {
|
||||
tokenContainer->AddLoopToken(loopIndex, row, index, value);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::TextKeyLeft(void) {
|
||||
@@ -162,6 +184,12 @@ void skindesignerapi::cSkindesignerOsdMenu::TextKeyDown(void) {
|
||||
DisplayMenu()->Scroll(false, false);
|
||||
}
|
||||
|
||||
skindesignerapi::cTokenContainer *skindesignerapi::cSkindesignerOsdMenu::GetTokenContainer(int menuId) {
|
||||
if (!plugStruct)
|
||||
return NULL;
|
||||
return plugStruct->GetMenuTokenContainer(menuId);
|
||||
}
|
||||
|
||||
void skindesignerapi::cSkindesignerOsdMenu::Display(void) {
|
||||
if (firstCallCleared) {
|
||||
firstCallCleared = false;
|
||||
@@ -174,11 +202,13 @@ void skindesignerapi::cSkindesignerOsdMenu::Display(void) {
|
||||
}
|
||||
if (displayText) {
|
||||
if (sdDisplayMenu) {
|
||||
sdDisplayMenu->SetMenuCategory(mcPlugin);
|
||||
sdDisplayMenu->SetTitle(Title());
|
||||
if (sdDisplayMenu->SetPluginText(&stringTokens, &intTokens, &loopTokens)) {
|
||||
if (tokenContainer && sdDisplayMenu->SetPluginText(tokenContainer)) {
|
||||
sdDisplayMenu->Flush();
|
||||
} else {
|
||||
DisplayMenu()->Clear();
|
||||
DisplayMenu()->SetMenuCategory(mcText);
|
||||
DisplayMenu()->SetTitle(Title());
|
||||
DisplayMenu()->SetText(text.c_str(), false);
|
||||
DisplayMenu()->Flush();
|
||||
@@ -192,6 +222,7 @@ void skindesignerapi::cSkindesignerOsdMenu::Display(void) {
|
||||
return;
|
||||
}
|
||||
if (sdDisplayMenu) {
|
||||
//sdDisplayMenu->SetMenuCategory(mcPlugin);
|
||||
sdDisplayMenu->SetTitle(Title());
|
||||
for (cOsdItem *item = First(); item; item = Next(item)) {
|
||||
cSkindesignerOsdItem *sdItem = dynamic_cast<cSkindesignerOsdItem*>(item);
|
||||
|
@@ -13,11 +13,6 @@
|
||||
|
||||
namespace skindesignerapi {
|
||||
|
||||
enum eMenuType {
|
||||
mtList,
|
||||
mtText
|
||||
};
|
||||
|
||||
class cOsdView;
|
||||
|
||||
/**********************************************************************
|
||||
@@ -25,11 +20,12 @@ class cOsdView;
|
||||
**********************************************************************/
|
||||
class cSkindesignerOsdObject : public cOsdObject {
|
||||
protected:
|
||||
string pluginName;
|
||||
bool InitSkindesignerInterface(string pluginName);
|
||||
cOsdView *GetOsdView(int viewID, int subViewID = -1);
|
||||
bool init;
|
||||
cPluginStructure *plugStruct;
|
||||
cOsdView *GetOsdView(int subViewId = -1);
|
||||
bool SkindesignerAvailable(void);
|
||||
public:
|
||||
cSkindesignerOsdObject(void);
|
||||
cSkindesignerOsdObject(cPluginStructure *plugStruct);
|
||||
virtual ~cSkindesignerOsdObject();
|
||||
virtual void Show(void) {};
|
||||
};
|
||||
@@ -40,19 +36,19 @@ public:
|
||||
class cSkindesignerOsdItem : public cOsdItem {
|
||||
private:
|
||||
ISDDisplayMenu *sdDisplayMenu;
|
||||
map < string, string > stringTokens;
|
||||
map < string, int > intTokens;
|
||||
map < string, vector< map< string, string > > > loopTokens;
|
||||
cTokenContainer *tokenContainer;
|
||||
protected:
|
||||
public:
|
||||
cSkindesignerOsdItem(eOSState State = osUnknown);
|
||||
cSkindesignerOsdItem(const char *Text, eOSState State = osUnknown, bool Selectable = true);
|
||||
cSkindesignerOsdItem(cTokenContainer *tk, eOSState State = osUnknown);
|
||||
cSkindesignerOsdItem(cTokenContainer *tk, const char *Text, eOSState State = osUnknown, bool Selectable = true);
|
||||
virtual ~cSkindesignerOsdItem();
|
||||
virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable);
|
||||
void SetDisplayMenu(ISDDisplayMenu *sdDisplayMenu) { this->sdDisplayMenu = sdDisplayMenu; };
|
||||
void AddStringToken(string key, string value);
|
||||
void AddIntToken(string key, int value);
|
||||
void AddLoopToken(string loopName, map<string, string> &tokens);
|
||||
int GetLoopIndex(const char *loop);
|
||||
void SetLoop(vector<int> loopInfo);
|
||||
void AddStringToken(int index, const char *value);
|
||||
void AddIntToken(int index, int value);
|
||||
void AddLoopToken(int loopIndex, int row, int index, const char *value);
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
@@ -60,34 +56,37 @@ public:
|
||||
**********************************************************************/
|
||||
class cSkindesignerOsdMenu : public cOsdMenu {
|
||||
private:
|
||||
cPluginStructure *plugStruct;
|
||||
cTokenContainer *tokenContainer;
|
||||
int activeMenu;
|
||||
bool init;
|
||||
bool firstCallCleared;
|
||||
bool secondCall;
|
||||
int firstMenu;
|
||||
eMenuType firstType;
|
||||
bool displayText;
|
||||
string pluginName;
|
||||
ISDDisplayMenu *sdDisplayMenu;
|
||||
string text;
|
||||
map < string, string > stringTokens;
|
||||
map < string, int > intTokens;
|
||||
map < string, vector< map< string, string > > > loopTokens;
|
||||
bool SetSkinDesignerDisplayMenu(void);
|
||||
protected:
|
||||
void SetPluginName(const char *name);
|
||||
void FirstCallCleared(void) { firstCallCleared = true; };
|
||||
void ClearTokens(void);
|
||||
void SetPluginName(string name) {pluginName = name; };
|
||||
void SetPluginMenu(int menu, eMenuType type);
|
||||
void SetTokenContainer(cTokenContainer *tk);
|
||||
void SetPluginMenu(int menuId, eMenuType type);
|
||||
void SetText(string text) { this->text = text; };
|
||||
void AddStringToken(string key, string value);
|
||||
void AddIntToken(string key, int value);
|
||||
void AddLoopToken(string loopName, map<string, string> &tokens);
|
||||
int GetLoopIndex(const char *loop);
|
||||
void SetLoop(vector<int> loopInfo);
|
||||
void AddStringToken(int index, const char *value);
|
||||
void AddIntToken(int index, int value);
|
||||
void AddLoopToken(int loopIndex, int row, int index, const char *value);
|
||||
void TextKeyLeft(void);
|
||||
void TextKeyRight(void);
|
||||
void TextKeyUp(void);
|
||||
void TextKeyDown(void);
|
||||
cTokenContainer *GetTokenContainer(int menuId);
|
||||
public:
|
||||
cSkindesignerOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0);
|
||||
cSkindesignerOsdMenu(skindesignerapi::cPluginStructure *plugStruct, const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0);
|
||||
virtual ~cSkindesignerOsdMenu();
|
||||
virtual void Display(void);
|
||||
};
|
||||
|
305
libskindesignerapi/tokencontainer.c
Normal file
305
libskindesignerapi/tokencontainer.c
Normal file
@@ -0,0 +1,305 @@
|
||||
#include "tokencontainer.h"
|
||||
|
||||
skindesignerapi::cTokenContainer::cTokenContainer(void) {
|
||||
numIntTokens = 0;
|
||||
numStringTokens = 0;
|
||||
stringTokens = NULL;
|
||||
intTokens = NULL;
|
||||
stNames = NULL;
|
||||
itNames = NULL;
|
||||
}
|
||||
|
||||
skindesignerapi::cTokenContainer::cTokenContainer(const cTokenContainer &other) {
|
||||
numIntTokens = 0;
|
||||
numStringTokens = 0;
|
||||
stringTokens = NULL;
|
||||
intTokens = NULL;
|
||||
stNames = NULL;
|
||||
itNames = NULL;
|
||||
stringTokenNames = other.stringTokenNames;
|
||||
intTokenNames = other.intTokenNames;
|
||||
loopTokenNames = other.loopTokenNames;
|
||||
loopNameMapping = other.loopNameMapping;
|
||||
}
|
||||
|
||||
skindesignerapi::cTokenContainer::~cTokenContainer(void) {
|
||||
Clear();
|
||||
delete[] intTokens;
|
||||
delete[] stringTokens;
|
||||
delete[] stNames;
|
||||
delete[] itNames;
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::CreateContainers(void) {
|
||||
numIntTokens = intTokenNames.size();
|
||||
if (numIntTokens) {
|
||||
intTokens = new int[numIntTokens];
|
||||
itNames = new string[numIntTokens];
|
||||
for (int i=0; i < numIntTokens; i++) {
|
||||
intTokens[i] = -1;
|
||||
itNames[i] = GetIntTokenName(i);
|
||||
}
|
||||
}
|
||||
numStringTokens = stringTokenNames.size();
|
||||
if (numStringTokens) {
|
||||
stringTokens = new char*[numStringTokens];
|
||||
stNames = new string[numStringTokens];
|
||||
for (int i=0; i < numStringTokens; i++) {
|
||||
stringTokens[i] = NULL;
|
||||
stNames[i] = GetStringTokenName(i);
|
||||
}
|
||||
}
|
||||
|
||||
int numLoops = loopTokenNames.size();
|
||||
for (int i = 0; i < numLoops; ++i) {
|
||||
vector<string> loopToken;
|
||||
int numLoopTokens = loopTokenNames[i].size();
|
||||
for (int j = 0; j < numLoopTokens; ++j) {
|
||||
string tokenName = GetLoopTokenName(i, j);
|
||||
loopToken.push_back(tokenName);
|
||||
}
|
||||
ltNames.push_back(loopToken);
|
||||
}
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::CreateLoopTokenContainer(vector<int> *loopInfo) {
|
||||
int numLoops = loopInfo->size();
|
||||
for (int i = 0; i < numLoops; ++i) {
|
||||
numLoopTokens.push_back(loopInfo->at(i));
|
||||
int rows = loopInfo->at(i);
|
||||
char*** loopToks = new char**[rows];
|
||||
for (int j = 0; j < rows ; ++j) {
|
||||
int numLoopTokens = loopTokenNames[i].size();
|
||||
loopToks[j] = new char*[numLoopTokens];
|
||||
for (int k = 0; k < numLoopTokens; ++k) {
|
||||
loopToks[j][k] = NULL;
|
||||
}
|
||||
}
|
||||
loopTokens.push_back(loopToks);
|
||||
}
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::DeleteLoopTokenContainer(void) {
|
||||
int i = 0;
|
||||
for (vector<char***>::iterator it = loopTokens.begin(); it != loopTokens.end(); it++) {
|
||||
char*** loopToks = *it;
|
||||
for (int j = 0; j < numLoopTokens[i] ; j++) {
|
||||
int numToks = loopTokenNames[i].size();
|
||||
for (int k = 0; k < numToks; ++k) {
|
||||
free(loopToks[j][k]);
|
||||
}
|
||||
delete[] loopToks[j];
|
||||
}
|
||||
delete[] loopToks;
|
||||
++i;
|
||||
}
|
||||
loopTokens.clear();
|
||||
numLoopTokens.clear();
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::DefineStringToken(string name, int index) {
|
||||
stringTokenNames.insert(pair<string, int>(name, index));
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::DefineIntToken(string name, int index) {
|
||||
intTokenNames.insert(pair<string, int>(name, index));
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::DefineLoopToken(string name, int index) {
|
||||
string loopName = LoopName(name);
|
||||
int loopIndex = LoopIndex(loopName, true);
|
||||
if ((int)loopTokenNames.size() < loopIndex+1) {
|
||||
map<string, int> newloop;
|
||||
newloop.insert(pair<string, int>(name, index));
|
||||
loopTokenNames.push_back(newloop);
|
||||
return;
|
||||
}
|
||||
loopTokenNames[loopIndex].insert(pair<string, int>(name, index));
|
||||
}
|
||||
|
||||
int skindesignerapi::cTokenContainer::GetNumDefinedIntTokens(void) {
|
||||
return intTokenNames.size();
|
||||
}
|
||||
|
||||
int skindesignerapi::cTokenContainer::LoopIndex(string name, bool createNew) {
|
||||
map<string, int>::iterator hit = loopNameMapping.find(name);
|
||||
if (hit != loopNameMapping.end())
|
||||
return hit->second;
|
||||
if (!createNew)
|
||||
return -1;
|
||||
int index = loopNameMapping.size();
|
||||
loopNameMapping.insert(pair<string, int>(name, index));
|
||||
return index;
|
||||
}
|
||||
|
||||
int skindesignerapi::cTokenContainer::StringTokenIndex(string name) {
|
||||
map<string, int>::iterator hit = stringTokenNames.find(name);
|
||||
if (hit == stringTokenNames.end())
|
||||
return -1;
|
||||
return hit->second;
|
||||
}
|
||||
|
||||
int skindesignerapi::cTokenContainer::IntTokenIndex(string name) {
|
||||
map<string, int>::iterator hit = intTokenNames.find(name);
|
||||
if (hit == intTokenNames.end())
|
||||
return -1;
|
||||
return hit->second;
|
||||
}
|
||||
|
||||
int skindesignerapi::cTokenContainer::LoopTokenIndex(string name) {
|
||||
string loopName = LoopName(name);
|
||||
int loopIndex = LoopIndex(loopName);
|
||||
if (loopIndex > -1 && loopIndex < (int)loopTokenNames.size()) {
|
||||
map<string, int>::iterator hit = loopTokenNames[loopIndex].find(name);
|
||||
if (hit == loopTokenNames[loopIndex].end())
|
||||
return -1;
|
||||
return hit->second;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::AddIntToken(int index, int value) {
|
||||
intTokens[index] = value;
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::AddStringToken(int index, const char *value) {
|
||||
if (value)
|
||||
stringTokens[index] = strdup(value);
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::AddLoopToken(int loopIndex, int row, int index, const char *value) {
|
||||
if (value) {
|
||||
loopTokens[loopIndex][row][index] = strdup(value);
|
||||
}
|
||||
}
|
||||
|
||||
int skindesignerapi::cTokenContainer::NumLoops(int loopIndex) {
|
||||
int numLT = numLoopTokens.size();
|
||||
if (loopIndex >= 0 && loopIndex < numLT)
|
||||
return numLoopTokens[loopIndex];
|
||||
return 0;
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::SetTokens(cTokenContainer *other) {
|
||||
//Set Int and String Tokens
|
||||
if (numIntTokens) {
|
||||
for (int i=0; i < numIntTokens; i++) {
|
||||
AddIntToken(i, other->IntToken(i));
|
||||
}
|
||||
}
|
||||
if (numStringTokens) {
|
||||
for (int i=0; i < numStringTokens; i++) {
|
||||
AddStringToken(i, other->StringToken(i));
|
||||
}
|
||||
}
|
||||
//Set Looptoken Container
|
||||
set<int> loopIndices;
|
||||
for (map<string, int>::iterator it = loopNameMapping.begin(); it != loopNameMapping.end(); it++) {
|
||||
loopIndices.insert(it->second);
|
||||
}
|
||||
vector<int> loopInfo;
|
||||
for (set<int>::iterator it = loopIndices.begin(); it != loopIndices.end(); it++) {
|
||||
loopInfo.push_back(other->NumLoops(*it));
|
||||
}
|
||||
CreateLoopTokenContainer(&loopInfo);
|
||||
//Set Loop Tokens
|
||||
int i = 0;
|
||||
for (vector<int>::iterator it = loopInfo.begin(); it != loopInfo.end(); it++) {
|
||||
int numRows = *it;
|
||||
int numCols = loopTokenNames[i].size();
|
||||
for (int j = 0; j < numRows; j++) {
|
||||
for (int k = 0; k < numCols; k++) {
|
||||
AddLoopToken(i, j, k, other->LoopToken(i, j, k));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::Clear(void) {
|
||||
if (numIntTokens) {
|
||||
for (int i=0; i < numIntTokens; i++) {
|
||||
intTokens[i] = -1;
|
||||
}
|
||||
}
|
||||
if (numStringTokens) {
|
||||
for (int i=0; i < numStringTokens; i++) {
|
||||
free(stringTokens[i]);
|
||||
stringTokens[i] = NULL;
|
||||
}
|
||||
}
|
||||
DeleteLoopTokenContainer();
|
||||
}
|
||||
|
||||
void skindesignerapi::cTokenContainer::Debug(void) {
|
||||
/*
|
||||
esyslog("skindesigner: TokenContainer defined string tokens");
|
||||
for (map<string, int>::iterator it = stringTokenNames.begin(); it != stringTokenNames.end(); it++) {
|
||||
esyslog("skindesigner: name %s id %d", (it->first).c_str(), it->second);
|
||||
}
|
||||
esyslog("skindesigner: TokenContainer defined int tokens");
|
||||
for (map<string, int>::iterator it = intTokenNames.begin(); it != intTokenNames.end(); it++) {
|
||||
esyslog("skindesigner: name %s id %d", (it->first).c_str(), it->second);
|
||||
}
|
||||
*/
|
||||
esyslog("skindesigner: TokenContainer content");
|
||||
for (int i=0; i < numStringTokens; i++) {
|
||||
if (stringTokens[i])
|
||||
esyslog("skindesigner: stringtoken %d. %s: \"%s\"", i, stNames[i].c_str(), stringTokens[i]);
|
||||
else
|
||||
esyslog("skindesigner: stringtoken %d. %s: empty", i, stNames[i].c_str());
|
||||
}
|
||||
for (int i=0; i < numIntTokens; i++) {
|
||||
if (intTokens[i] >= 0)
|
||||
esyslog("skindesigner: inttoken %d. %s: %d", i, itNames[i].c_str(), intTokens[i]);
|
||||
else
|
||||
esyslog("skindesigner: inttoken %d. %s: empty", i, itNames[i].c_str());
|
||||
}
|
||||
|
||||
for (size_t i=0; i < loopTokens.size(); i++) {
|
||||
for (int j = 0; j < numLoopTokens[i]; j++) {
|
||||
esyslog("skindesigner: row %d", j);
|
||||
for (size_t k = 0; k < loopTokenNames[i].size(); k++) {
|
||||
if (loopTokens[i][j][k])
|
||||
esyslog("skindesigner: looptoken %d. %s: \"%s\"", (int)k, ltNames[i][k].c_str(), loopTokens[i][j][k]);
|
||||
else
|
||||
esyslog("skindesigner: looptoken %d. %s: empty", (int)k, ltNames[i][k].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string skindesignerapi::cTokenContainer::GetStringTokenName(int id) {
|
||||
for (map<string, int>::iterator it = stringTokenNames.begin(); it != stringTokenNames.end(); it++) {
|
||||
if (it->second == id)
|
||||
return it->first;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
string skindesignerapi::cTokenContainer::GetIntTokenName(int id) {
|
||||
for (map<string, int>::iterator it = intTokenNames.begin(); it != intTokenNames.end(); it++) {
|
||||
if (it->second == id)
|
||||
return it->first;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
string skindesignerapi::cTokenContainer::GetLoopTokenName(int loop, int id) {
|
||||
for (map<string, int>::iterator it = loopTokenNames[loop].begin(); it != loopTokenNames[loop].end(); it++) {
|
||||
if (it->second == id)
|
||||
return it->first;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//Get name of loop from a loop token name
|
||||
string skindesignerapi::cTokenContainer::LoopName(string &loopToken) {
|
||||
size_t hit = loopToken.find('{');
|
||||
if (hit != 0)
|
||||
return "";
|
||||
hit = loopToken.find('[');
|
||||
if (hit == string::npos)
|
||||
return "";
|
||||
return loopToken.substr(1, hit-1);
|
||||
}
|
69
libskindesignerapi/tokencontainer.h
Normal file
69
libskindesignerapi/tokencontainer.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef __TOKENCONTAINER_H
|
||||
#define __TOKENCONTAINER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vdr/plugin.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace skindesignerapi {
|
||||
|
||||
class cTokenContainer {
|
||||
private:
|
||||
int numIntTokens;
|
||||
int numStringTokens;
|
||||
vector<int> numLoopTokens;
|
||||
//token containers
|
||||
char **stringTokens;
|
||||
int *intTokens;
|
||||
vector<char***>loopTokens;
|
||||
//mapping id --> name
|
||||
string *stNames;
|
||||
string *itNames;
|
||||
vector< vector<string> > ltNames;
|
||||
//mapping name --> id
|
||||
map<string, int> stringTokenNames;
|
||||
map<string, int> intTokenNames;
|
||||
vector< map<string, int> > loopTokenNames;
|
||||
//get token name from id
|
||||
string GetStringTokenName(int id);
|
||||
string GetIntTokenName(int id);
|
||||
string GetLoopTokenName(int loop, int id);
|
||||
//looptoken management
|
||||
string LoopName(string &loopToken);
|
||||
map<string, int> loopNameMapping;
|
||||
void DeleteLoopTokenContainer(void);
|
||||
public:
|
||||
cTokenContainer(void);
|
||||
cTokenContainer(const cTokenContainer &other);
|
||||
~cTokenContainer(void);
|
||||
void CreateContainers(void);
|
||||
void CreateLoopTokenContainer(vector<int> *loopInfo);
|
||||
void DefineStringToken (string name, int index);
|
||||
void DefineIntToken (string name, int index);
|
||||
void DefineLoopToken (string name, int index);
|
||||
int GetNumDefinedIntTokens(void);
|
||||
int LoopIndex (string name, bool createNew = false);
|
||||
int StringTokenIndex (string name);
|
||||
int IntTokenIndex (string name);
|
||||
int LoopTokenIndex (string name);
|
||||
void AddIntToken (int index, int value);
|
||||
void AddStringToken (int index, const char *value);
|
||||
void AddLoopToken (int loopIndex, int row, int index, const char *value);
|
||||
char *StringToken (int index) { return stringTokens[index]; };
|
||||
int IntToken (int index) { return intTokens[index]; };
|
||||
char *LoopToken (int i, int j, int k) { return loopTokens[i][j][k]; };
|
||||
int NumLoops (int loopIndex);
|
||||
void SetTokens (cTokenContainer *other);
|
||||
void Clear(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
}
|
||||
#endif //__TOKENCONTAINER_H
|
Reference in New Issue
Block a user