2015-04-02 15:09:41 +02:00
|
|
|
#include "skindesignerosdbase.h"
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* cSkindesignerOsdObject
|
|
|
|
**********************************************************************/
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
skindesignerapi::cSkindesignerOsdObject::cSkindesignerOsdObject(cPluginStructure *plugStruct) {
|
|
|
|
this->plugStruct = plugStruct;
|
|
|
|
init = true;
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
skindesignerapi::cSkindesignerOsdObject::~cSkindesignerOsdObject() {
|
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
skindesignerapi::cOsdView *skindesignerapi::cSkindesignerOsdObject::GetOsdView(int subViewId) {
|
|
|
|
ISkinDisplayPlugin *displayPlugin = SkindesignerAPI::GetDisplayPlugin(plugStruct->id);
|
2015-04-02 15:09:41 +02:00
|
|
|
if (!displayPlugin)
|
|
|
|
return NULL;
|
2016-01-26 18:32:38 +01:00
|
|
|
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);
|
|
|
|
}
|
2015-04-02 15:09:41 +02:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
bool skindesignerapi::cSkindesignerOsdObject::SkindesignerAvailable(void) {
|
|
|
|
return SkindesignerAPI::ServiceAvailable();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-02 15:09:41 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* cSkindesignerOsdItem
|
|
|
|
**********************************************************************/
|
2016-01-26 18:32:38 +01:00
|
|
|
skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(cTokenContainer *tk, eOSState State) : cOsdItem(State) {
|
2015-04-02 15:09:41 +02:00
|
|
|
sdDisplayMenu = NULL;
|
2016-01-26 18:32:38 +01:00
|
|
|
tokenContainer = new skindesignerapi::cTokenContainer(*tk);
|
|
|
|
tokenContainer->CreateContainers();
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
skindesignerapi::cSkindesignerOsdItem::cSkindesignerOsdItem(cTokenContainer *tk, const char *Text, eOSState State, bool Selectable) : cOsdItem(Text, State, Selectable) {
|
2015-04-02 15:09:41 +02:00
|
|
|
sdDisplayMenu = NULL;
|
2016-01-26 18:32:38 +01:00
|
|
|
tokenContainer = new skindesignerapi::cTokenContainer(*tk);
|
|
|
|
tokenContainer->CreateContainers();
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
skindesignerapi::cSkindesignerOsdItem::~cSkindesignerOsdItem() {
|
2016-01-26 18:32:38 +01:00
|
|
|
delete tokenContainer;
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void skindesignerapi::cSkindesignerOsdItem::SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable) {
|
|
|
|
if (sdDisplayMenu) {
|
2016-01-26 18:32:38 +01:00
|
|
|
if (!sdDisplayMenu->SetItemPlugin(tokenContainer, Index, Current, Selectable)) {
|
2015-04-02 15:09:41 +02:00
|
|
|
DisplayMenu->SetItem(Text(), Index, Current, Selectable);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DisplayMenu->SetItem(Text(), Index, Current, Selectable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
int skindesignerapi::cSkindesignerOsdItem::GetLoopIndex(const char *loop) {
|
|
|
|
return tokenContainer->LoopIndex(loop);
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
void skindesignerapi::cSkindesignerOsdItem::SetLoop(vector<int> loopInfo) {
|
|
|
|
tokenContainer->CreateLoopTokenContainer(&loopInfo);
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
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);
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* cSkindesignerOsdMenu
|
|
|
|
**********************************************************************/
|
2016-01-26 18:32:38 +01:00
|
|
|
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;
|
2015-04-02 15:09:41 +02:00
|
|
|
init = true;
|
2016-01-26 18:32:38 +01:00
|
|
|
activeMenu = 0;
|
2015-05-30 16:43:59 +02:00
|
|
|
firstCallCleared = false;
|
|
|
|
secondCall = false;
|
|
|
|
firstMenu = -1;
|
|
|
|
firstType = mtList;
|
2015-04-02 15:09:41 +02:00
|
|
|
displayText = false;
|
|
|
|
sdDisplayMenu = NULL;
|
|
|
|
SetMenuCategory(mcPlugin);
|
|
|
|
SetSkinDesignerDisplayMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
skindesignerapi::cSkindesignerOsdMenu::~cSkindesignerOsdMenu() {
|
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
void skindesignerapi::cSkindesignerOsdMenu::SetPluginMenu(int menuId, eMenuType type) {
|
|
|
|
activeMenu = menuId;
|
2015-05-30 16:43:59 +02:00
|
|
|
if (firstCallCleared) {
|
2016-01-26 18:32:38 +01:00
|
|
|
firstMenu = menuId;
|
2015-05-30 16:43:59 +02:00
|
|
|
firstType = type;
|
|
|
|
}
|
2015-04-02 15:09:41 +02:00
|
|
|
if (type == mtList)
|
|
|
|
displayText = false;
|
|
|
|
else if (type == mtText)
|
|
|
|
displayText = true;
|
|
|
|
if (sdDisplayMenu) {
|
2016-01-26 18:32:38 +01:00
|
|
|
int plugId = plugStruct->id;
|
|
|
|
sdDisplayMenu->SetPluginMenu(plugId, menuId, type, init);
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
init = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool skindesignerapi::cSkindesignerOsdMenu::SetSkinDesignerDisplayMenu(void) {
|
|
|
|
sdDisplayMenu = SkindesignerAPI::GetDisplayMenu();
|
|
|
|
return (sdDisplayMenu != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void skindesignerapi::cSkindesignerOsdMenu::ClearTokens(void) {
|
|
|
|
text = "";
|
2016-01-26 18:32:38 +01:00
|
|
|
if (tokenContainer)
|
|
|
|
tokenContainer->Clear();
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
int skindesignerapi::cSkindesignerOsdMenu::GetLoopIndex(const char *loop) {
|
|
|
|
return tokenContainer->LoopIndex(loop);
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
void skindesignerapi::cSkindesignerOsdMenu::SetLoop(vector<int> loopInfo) {
|
|
|
|
tokenContainer->CreateLoopTokenContainer(&loopInfo);
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
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);
|
2015-04-02 15:09:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void skindesignerapi::cSkindesignerOsdMenu::TextKeyLeft(void) {
|
|
|
|
if (!displayText)
|
|
|
|
return;
|
|
|
|
DisplayMenu()->Scroll(true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void skindesignerapi::cSkindesignerOsdMenu::TextKeyRight(void) {
|
|
|
|
if (!displayText)
|
|
|
|
return;
|
|
|
|
DisplayMenu()->Scroll(false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void skindesignerapi::cSkindesignerOsdMenu::TextKeyUp(void) {
|
|
|
|
if (!displayText)
|
|
|
|
return;
|
|
|
|
DisplayMenu()->Scroll(true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void skindesignerapi::cSkindesignerOsdMenu::TextKeyDown(void) {
|
|
|
|
if (!displayText)
|
|
|
|
return;
|
|
|
|
DisplayMenu()->Scroll(false, false);
|
|
|
|
}
|
|
|
|
|
2016-01-26 18:32:38 +01:00
|
|
|
skindesignerapi::cTokenContainer *skindesignerapi::cSkindesignerOsdMenu::GetTokenContainer(int menuId) {
|
|
|
|
if (!plugStruct)
|
|
|
|
return NULL;
|
|
|
|
return plugStruct->GetMenuTokenContainer(menuId);
|
|
|
|
}
|
|
|
|
|
2015-04-02 15:09:41 +02:00
|
|
|
void skindesignerapi::cSkindesignerOsdMenu::Display(void) {
|
2015-05-30 16:43:59 +02:00
|
|
|
if (firstCallCleared) {
|
|
|
|
firstCallCleared = false;
|
|
|
|
secondCall = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (secondCall) {
|
|
|
|
SetSkinDesignerDisplayMenu();
|
|
|
|
SetPluginMenu(firstMenu, firstType);
|
|
|
|
}
|
2015-04-02 15:09:41 +02:00
|
|
|
if (displayText) {
|
|
|
|
if (sdDisplayMenu) {
|
2016-01-26 18:32:38 +01:00
|
|
|
sdDisplayMenu->SetMenuCategory(mcPlugin);
|
2015-04-02 15:09:41 +02:00
|
|
|
sdDisplayMenu->SetTitle(Title());
|
2016-01-26 18:32:38 +01:00
|
|
|
if (tokenContainer && sdDisplayMenu->SetPluginText(tokenContainer)) {
|
2015-04-02 15:09:41 +02:00
|
|
|
sdDisplayMenu->Flush();
|
|
|
|
} else {
|
|
|
|
DisplayMenu()->Clear();
|
2016-01-26 18:32:38 +01:00
|
|
|
DisplayMenu()->SetMenuCategory(mcText);
|
2015-04-02 15:09:41 +02:00
|
|
|
DisplayMenu()->SetTitle(Title());
|
|
|
|
DisplayMenu()->SetText(text.c_str(), false);
|
|
|
|
DisplayMenu()->Flush();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DisplayMenu()->Clear();
|
|
|
|
DisplayMenu()->SetTitle(Title());
|
|
|
|
DisplayMenu()->SetText(text.c_str(), false);
|
|
|
|
DisplayMenu()->Flush();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (sdDisplayMenu) {
|
2016-01-26 18:32:38 +01:00
|
|
|
//sdDisplayMenu->SetMenuCategory(mcPlugin);
|
2015-04-02 15:09:41 +02:00
|
|
|
sdDisplayMenu->SetTitle(Title());
|
|
|
|
for (cOsdItem *item = First(); item; item = Next(item)) {
|
|
|
|
cSkindesignerOsdItem *sdItem = dynamic_cast<cSkindesignerOsdItem*>(item);
|
|
|
|
if (sdItem) {
|
|
|
|
sdItem->SetDisplayMenu(sdDisplayMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cOsdMenu::Display();
|
|
|
|
}
|