vdr-plugin-skindesigner/libskindesigner/skindesignerosdbase.c

210 lines
6.4 KiB
C
Raw Normal View History

2014-11-15 09:47:22 +01:00
#include "skindesignerosdbase.h"
2015-03-12 17:28:35 +01:00
#include "osdelements.h"
/**********************************************************************
* cSkindesignerOsdObject
**********************************************************************/
cSkindesignerOsdObject::cSkindesignerOsdObject(void) {
pSkinDesigner = NULL;
pluginName = "";
}
cSkindesignerOsdObject::~cSkindesignerOsdObject() {
}
bool cSkindesignerOsdObject::InitSkindesignerInterface(string pluginName) {
this->pluginName = pluginName;
pSkinDesigner = cPluginManager::GetPlugin("skindesigner");
if (!pSkinDesigner) {
return false;
}
return true;
}
cOsdView *cSkindesignerOsdObject::GetOsdView(int viewID, int subViewID) {
cSkinDisplayPlugin *displayPlugin = NULL;
cOsdView *view = NULL;
GetDisplayPlugin call;
call.pluginName = pluginName;
call.viewID = viewID;
call.subViewID = subViewID;
bool ok = pSkinDesigner->Service("GetDisplayPlugin", &call);
if (ok) {
displayPlugin = call.displayPlugin;
view = new cOsdView(displayPlugin);
}
return view;
}
2014-11-15 09:47:22 +01:00
/**********************************************************************
* cSkindesignerOsdItem
**********************************************************************/
cSkindesignerOsdItem::cSkindesignerOsdItem(eOSState State) : cOsdItem(State) {
2014-11-25 14:33:59 +01:00
sdDisplayMenu = NULL;
2014-11-15 09:47:22 +01:00
}
cSkindesignerOsdItem::cSkindesignerOsdItem(const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) {
2014-11-25 14:33:59 +01:00
sdDisplayMenu = NULL;
2014-11-15 09:47:22 +01:00
}
cSkindesignerOsdItem::~cSkindesignerOsdItem() {
}
void cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) {
2014-11-25 14:33:59 +01:00
if (sdDisplayMenu) {
if (!sdDisplayMenu->SetItemPlugin(&stringTokens, &intTokens, &loopTokens, Index, Current, Selectable)) {
DisplayMenu->SetItem(Text(), Index, Current, Selectable);
}
} else {
DisplayMenu->SetItem(Text(), Index, Current, Selectable);
}
2014-11-15 09:47:22 +01:00
}
void cSkindesignerOsdItem::AddStringToken(string key, string value) {
2014-11-25 14:33:59 +01:00
stringTokens.insert(pair<string,string>(key, value));
2014-11-15 09:47:22 +01:00
}
void cSkindesignerOsdItem::AddIntToken(string key, int value) {
2014-11-25 14:33:59 +01:00
intTokens.insert(pair<string,int>(key, value));
2014-11-15 09:47:22 +01:00
}
void cSkindesignerOsdItem::AddLoopToken(string loopName, map<string, string> &tokens) {
2014-11-25 14:33:59 +01:00
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);
}
2014-11-15 09:47:22 +01:00
}
/**********************************************************************
* cSkindesignerOsdMenu
**********************************************************************/
cSkindesignerOsdMenu::cSkindesignerOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) : cOsdMenu(Title, c0, c1, c2, c3, c4) {
2014-11-25 14:33:59 +01:00
init = true;
2014-11-15 09:47:22 +01:00
displayText = false;
2014-11-25 14:33:59 +01:00
sdDisplayMenu = NULL;
pluginName = "";
SetMenuCategory(mcPlugin);
SetSkinDesignerDisplayMenu();
2014-11-15 09:47:22 +01:00
}
cSkindesignerOsdMenu::~cSkindesignerOsdMenu() {
}
void cSkindesignerOsdMenu::SetPluginMenu(int menu, eMenuType type) {
2014-11-25 14:33:59 +01:00
if (type == mtList)
displayText = false;
else if (type == mtText)
displayText = true;
if (sdDisplayMenu) {
sdDisplayMenu->SetPluginMenu(pluginName, menu, type, init);
}
2014-11-15 09:47:22 +01:00
init = false;
}
bool cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) {
2014-11-25 14:33:59 +01:00
static cPlugin *pSkinDesigner = cPluginManager::GetPlugin("skindesigner");
if (!pSkinDesigner) {
return false;
}
GetDisplayMenu call;
bool ok = pSkinDesigner->Service("GetDisplayMenu", &call);
if (ok && call.displayMenu) {
sdDisplayMenu = call.displayMenu;
return true;
}
return false;
2014-11-15 09:47:22 +01:00
}
void cSkindesignerOsdMenu::ClearTokens(void) {
2014-11-25 14:33:59 +01:00
text = "";
2014-11-15 09:47:22 +01:00
stringTokens.clear();
intTokens.clear();
loopTokens.clear();
}
void cSkindesignerOsdMenu::AddStringToken(string key, string value) {
2014-11-25 14:33:59 +01:00
stringTokens.insert(pair<string,string>(key, value));
2014-11-15 09:47:22 +01:00
}
void cSkindesignerOsdMenu::AddIntToken(string key, int value) {
2014-11-25 14:33:59 +01:00
intTokens.insert(pair<string,int>(key, value));
2014-11-15 09:47:22 +01:00
}
void cSkindesignerOsdMenu::AddLoopToken(string loopName, map<string, string> &tokens) {
2014-11-25 14:33:59 +01:00
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);
}
2014-11-15 09:47:22 +01:00
}
void cSkindesignerOsdMenu::TextKeyLeft(void) {
if (!displayText)
return;
DisplayMenu()->Scroll(true, true);
}
void cSkindesignerOsdMenu::TextKeyRight(void) {
if (!displayText)
return;
DisplayMenu()->Scroll(false, true);
}
void cSkindesignerOsdMenu::TextKeyUp(void) {
if (!displayText)
return;
DisplayMenu()->Scroll(true, false);
}
void cSkindesignerOsdMenu::TextKeyDown(void) {
if (!displayText)
return;
DisplayMenu()->Scroll(false, false);
}
void cSkindesignerOsdMenu::Display(void) {
2014-11-25 14:33:59 +01:00
if (displayText) {
if (sdDisplayMenu) {
sdDisplayMenu->SetTitle(Title());
2014-11-25 14:33:59 +01:00
if (sdDisplayMenu->SetPluginText(&stringTokens, &intTokens, &loopTokens)) {
2014-11-15 09:47:22 +01:00
sdDisplayMenu->Flush();
} else {
DisplayMenu()->Clear();
DisplayMenu()->SetTitle(Title());
2014-11-15 09:47:22 +01:00
DisplayMenu()->SetText(text.c_str(), false);
DisplayMenu()->Flush();
}
2014-11-25 14:33:59 +01:00
} else {
2014-11-15 09:47:22 +01:00
DisplayMenu()->Clear();
DisplayMenu()->SetTitle(Title());
2014-11-25 14:33:59 +01:00
DisplayMenu()->SetText(text.c_str(), false);
2014-11-15 09:47:22 +01:00
DisplayMenu()->Flush();
2014-11-25 14:33:59 +01:00
}
2014-11-15 09:47:22 +01:00
return;
2014-11-25 14:33:59 +01:00
}
if (sdDisplayMenu) {
sdDisplayMenu->SetTitle(Title());
2014-11-25 14:33:59 +01:00
for (cOsdItem *item = First(); item; item = Next(item)) {
cSkindesignerOsdItem *sdItem = dynamic_cast<cSkindesignerOsdItem*>(item);
if (sdItem) {
2014-11-25 14:33:59 +01:00
sdItem->SetDisplayMenu(sdDisplayMenu);
}
2014-11-25 14:33:59 +01:00
}
}
cOsdMenu::Display();
2014-11-15 09:47:22 +01:00
}